diff options
-rw-r--r-- | src/profile-editor.c | 43 | ||||
-rw-r--r-- | src/terminal-profile.c | 206 | ||||
-rw-r--r-- | src/terminal-profile.h | 4 | ||||
-rw-r--r-- | src/terminal-screen.c | 77 | ||||
-rw-r--r-- | src/terminal-util.c | 22 |
5 files changed, 175 insertions, 177 deletions
diff --git a/src/profile-editor.c b/src/profile-editor.c index cd7f07a..c22522b 100644 --- a/src/profile-editor.c +++ b/src/profile-editor.c @@ -34,31 +34,36 @@ typedef struct _TerminalColorScheme TerminalColorScheme; struct _TerminalColorScheme { const char *name; - const GdkColor foreground; - const GdkColor background; + const GdkRGBA foreground; + const GdkRGBA background; }; static const TerminalColorScheme color_schemes[] = { { N_("Black on light yellow"), - { 0, 0x0000, 0x0000, 0x0000 }, { 0, 0xFFFF, 0xFFFF, 0xDDDD } + { 0, 0, 0, 1 }, + { 1, 1, 0.866667, 1 } }, { N_("Black on white"), - { 0, 0x0000, 0x0000, 0x0000 }, { 0, 0xFFFF, 0xFFFF, 0xFFFF } + { 0, 0, 0, 1 }, + { 1, 1, 1, 1 } }, { N_("Gray on black"), - { 0, 0xAAAA, 0xAAAA, 0xAAAA }, { 0, 0x0000, 0x0000, 0x0000 } + { 0.666667, 0.666667, 0.666667, 1 }, + { 0, 0, 0, 1 } }, { N_("Green on black"), - { 0, 0x0000, 0xFFFF, 0x0000 }, { 0, 0x0000, 0x0000, 0x0000 } + { 0, 1, 0, 1 }, + { 0, 0, 0, 1 } }, { N_("White on black"), - { 0, 0xFFFF, 0xFFFF, 0xFFFF }, { 0, 0x0000, 0x0000, 0x0000 } + { 1, 1, 1, 1 }, + { 0, 0, 0, 1 } } }; @@ -349,7 +354,7 @@ profile_colors_notify_scheme_combo_cb (TerminalProfile *profile, GParamSpec *pspec, GtkComboBox *combo) { - const GdkColor *fg, *bg; + const GdkRGBA *fg, *bg; guint i; fg = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR); @@ -359,8 +364,8 @@ profile_colors_notify_scheme_combo_cb (TerminalProfile *profile, { for (i = 0; i < G_N_ELEMENTS (color_schemes); ++i) { - if (gdk_color_equal (fg, &color_schemes[i].foreground) && - gdk_color_equal (bg, &color_schemes[i].background)) + if (gdk_rgba_equal (&fg, &color_schemes[i].foreground) && + gdk_rgba_equal (&bg, &color_schemes[i].background)) break; } } @@ -413,15 +418,15 @@ profile_palette_notify_scheme_combo_cb (TerminalProfile *profile, } static void -palette_color_notify_cb (GtkColorButton *button, +palette_color_notify_cb (GtkColorChooser *button, GParamSpec *pspec, TerminalProfile *profile) { GtkWidget *editor; - GdkColor color; + GdkRGBA color; guint i; - gtk_color_button_get_color (button, &color); + gtk_color_chooser_get_rgba (button, &color); i = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "palette-entry-index")); editor = gtk_widget_get_toplevel (GTK_WIDGET (button)); @@ -436,7 +441,7 @@ profile_palette_notify_colorpickers_cb (TerminalProfile *profile, GtkWidget *editor) { GtkWidget *w; - GdkColor colors[TERMINAL_PALETTE_SIZE]; + GdkRGBA colors[TERMINAL_PALETTE_SIZE]; guint n_colors, i; n_colors = G_N_ELEMENTS (colors); @@ -446,16 +451,16 @@ profile_palette_notify_colorpickers_cb (TerminalProfile *profile, for (i = 0; i < n_colors; i++) { char name[32]; - GdkColor old_color; + GdkRGBA old_color; g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1); w = profile_editor_get_widget (editor, name); - gtk_color_button_get_color (GTK_COLOR_BUTTON (w), &old_color); - if (!gdk_color_equal (&old_color, &colors[i])) + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (w), &old_color); + if (!gdk_rgba_equal (&old_color, &colors[i])) { g_signal_handlers_block_by_func (w, G_CALLBACK (palette_color_notify_cb), profile); - gtk_color_button_set_color (GTK_COLOR_BUTTON (w), &colors[i]); + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (w), &colors[i]); g_signal_handlers_unblock_by_func (w, G_CALLBACK (palette_color_notify_cb), profile); } } @@ -730,7 +735,7 @@ terminal_profile_edit (TerminalProfile *profile, gtk_widget_set_tooltip_text (w, text); g_free (text); - g_signal_connect (w, "notify::color", + g_signal_connect (w, "notify::rgba", G_CALLBACK (palette_color_notify_cb), profile); } diff --git a/src/terminal-profile.c b/src/terminal-profile.c index 8109338..b8a7fba 100644 --- a/src/terminal-profile.c +++ b/src/terminal-profile.c @@ -186,92 +186,89 @@ struct _TerminalProfilePrivate guint forgotten : 1; }; -static const GdkColor terminal_palettes[TERMINAL_PALETTE_N_BUILTINS][TERMINAL_PALETTE_SIZE] = +static const GdkRGBA terminal_palettes[TERMINAL_PALETTE_N_BUILTINS][TERMINAL_PALETTE_SIZE] = { /* Tango palette */ { - { 0, 0x0000, 0x0000, 0x0000 }, - { 0, 0xcccc, 0x0000, 0x0000 }, - { 0, 0x4e4e, 0x9a9a, 0x0606 }, - { 0, 0xc4c4, 0xa0a0, 0x0000 }, - { 0, 0x3434, 0x6565, 0xa4a4 }, - { 0, 0x7575, 0x5050, 0x7b7b }, - { 0, 0x0606, 0x9820, 0x9a9a }, - { 0, 0xd3d3, 0xd7d7, 0xcfcf }, - { 0, 0x5555, 0x5757, 0x5353 }, - { 0, 0xefef, 0x2929, 0x2929 }, - { 0, 0x8a8a, 0xe2e2, 0x3434 }, - { 0, 0xfcfc, 0xe9e9, 0x4f4f }, - { 0, 0x7272, 0x9f9f, 0xcfcf }, - { 0, 0xadad, 0x7f7f, 0xa8a8 }, - { 0, 0x3434, 0xe2e2, 0xe2e2 }, - { 0, 0xeeee, 0xeeee, 0xecec } + { 0, 0, 0, 1 }, + { 0.8, 0, 0, 1 }, + { 0.305882, 0.603922, 0.0235294, 1 }, + { 0.768627, 0.627451, 0, 1 }, + { 0.203922, 0.396078, 0.643137, 1 }, + { 0.458824, 0.313725, 0.482353, 1 }, + { 0.0235294, 0.596078, 0.603922, 1 }, + { 0.827451, 0.843137, 0.811765, 1 }, + { 0.333333, 0.341176, 0.32549, 1 }, + { 0.937255, 0.160784, 0.160784, 1 }, + { 0.541176, 0.886275, 0.203922, 1 }, + { 0.988235, 0.913725, 0.309804, 1 }, + { 0.447059, 0.623529, 0.811765, 1 }, + { 0.678431, 0.498039, 0.658824, 1 }, + { 0.203922, 0.886275, 0.886275, 1 }, + { 0.933333, 0.933333, 0.92549, 1 }, }, /* Linux palette */ { - { 0, 0x0000, 0x0000, 0x0000 }, - { 0, 0xaaaa, 0x0000, 0x0000 }, - { 0, 0x0000, 0xaaaa, 0x0000 }, - { 0, 0xaaaa, 0x5555, 0x0000 }, - { 0, 0x0000, 0x0000, 0xaaaa }, - { 0, 0xaaaa, 0x0000, 0xaaaa }, - { 0, 0x0000, 0xaaaa, 0xaaaa }, - { 0, 0xaaaa, 0xaaaa, 0xaaaa }, - { 0, 0x5555, 0x5555, 0x5555 }, - { 0, 0xffff, 0x5555, 0x5555 }, - { 0, 0x5555, 0xffff, 0x5555 }, - { 0, 0xffff, 0xffff, 0x5555 }, - { 0, 0x5555, 0x5555, 0xffff }, - { 0, 0xffff, 0x5555, 0xffff }, - { 0, 0x5555, 0xffff, 0xffff }, - { 0, 0xffff, 0xffff, 0xffff } + { 0, 0, 0, 1 }, + { 0.666667, 0, 0, 1 }, + { 0, 0.666667, 0, 1 }, + { 0.666667, 0.333333, 0, 1 }, + { 0, 0, 0.666667, 1 }, + { 0.666667, 0, 0.666667, 1 }, + { 0, 0.666667, 0.666667, 1 }, + { 0.666667, 0.666667, 0.666667, 1 }, + { 0.333333, 0.333333, 0.333333, 1 }, + { 1, 0.333333, 0.333333, 1 }, + { 0.333333, 1, 0.333333, 1 }, + { 1, 1, 0.333333, 1 }, + { 0.333333, 0.333333, 1, 1 }, + { 1, 0.333333, 1, 1 }, + { 0.333333, 1, 1, 1 }, + { 1, 1, 1, 1 }, }, /* XTerm palette */ { - { 0, 0x0000, 0x0000, 0x0000 }, - { 0, 0xcdcb, 0x0000, 0x0000 }, - { 0, 0x0000, 0xcdcb, 0x0000 }, - { 0, 0xcdcb, 0xcdcb, 0x0000 }, - { 0, 0x1e1a, 0x908f, 0xffff }, - { 0, 0xcdcb, 0x0000, 0xcdcb }, - { 0, 0x0000, 0xcdcb, 0xcdcb }, - { 0, 0xe5e2, 0xe5e2, 0xe5e2 }, - { 0, 0x4ccc, 0x4ccc, 0x4ccc }, - { 0, 0xffff, 0x0000, 0x0000 }, - { 0, 0x0000, 0xffff, 0x0000 }, - { 0, 0xffff, 0xffff, 0x0000 }, - { 0, 0x4645, 0x8281, 0xb4ae }, - { 0, 0xffff, 0x0000, 0xffff }, - { 0, 0x0000, 0xffff, 0xffff }, - { 0, 0xffff, 0xffff, 0xffff } + { 0, 0, 0, 1 }, + { 0.803922, 0, 0, 1 }, + { 0, 0.803922, 0, 1 }, + { 0.803922, 0.803922, 0, 1 }, + { 0.117647, 0.564706, 1, 1 }, + { 0.803922, 0, 0.803922, 1 }, + { 0, 0.803922, 0.803922, 1 }, + { 0.898039, 0.898039, 0.898039, 1 }, + { 0.298039, 0.298039, 0.298039, 1 }, + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 1, 1, 0, 1 }, + { 0.27451, 0.509804, 0.705882, 1 }, + { 1, 0, 1, 1 }, + { 0, 1, 1, 1 }, + { 1, 1, 1, 1 }, }, /* RXVT palette */ { - { 0, 0x0000, 0x0000, 0x0000 }, - { 0, 0xcdcd, 0x0000, 0x0000 }, - { 0, 0x0000, 0xcdcd, 0x0000 }, - { 0, 0xcdcd, 0xcdcd, 0x0000 }, - { 0, 0x0000, 0x0000, 0xcdcd }, - { 0, 0xcdcd, 0x0000, 0xcdcd }, - { 0, 0x0000, 0xcdcd, 0xcdcd }, - { 0, 0xfafa, 0xebeb, 0xd7d7 }, - { 0, 0x4040, 0x4040, 0x4040 }, - { 0, 0xffff, 0x0000, 0x0000 }, - { 0, 0x0000, 0xffff, 0x0000 }, - { 0, 0xffff, 0xffff, 0x0000 }, - { 0, 0x0000, 0x0000, 0xffff }, - { 0, 0xffff, 0x0000, 0xffff }, - { 0, 0x0000, 0xffff, 0xffff }, - { 0, 0xffff, 0xffff, 0xffff } + { 0, 0, 0, 1 }, + { 0.803922, 0, 0, 1 }, + { 0, 0.803922, 0, 1 }, + { 0.803922, 0.803922, 0, 1 }, + { 0, 0, 0.803922, 1 }, + { 0.803922, 0, 0.803922, 1 }, + { 0, 0.803922, 0.803922, 1 }, + { 0.980392, 0.921569, 0.843137, 1 }, + { 0.25098, 0.25098, 0.25098, 1 }, + { 1, 0, 0, 1 }, + { 0, 1, 0, 1 }, + { 1, 1, 0, 1 }, + { 0, 0, 1, 1 }, + { 1, 0, 1, 1 }, + { 0, 1, 1, 1 }, + { 1, 1, 1, 1 }, } }; -static const GdkColor default_fg_color = { 0, 0, 0, 0 }; -static const GdkColor default_bg_color = { 0, 0xffff, 0xffff, 0xdddd }; - enum { FORGOTTEN, @@ -293,17 +290,32 @@ static GQuark gsettings_key_quark; G_DEFINE_TYPE (TerminalProfile, terminal_profile, G_TYPE_OBJECT); +/* gdk_rgba_equal is too strict! */ static gboolean -palette_cmp (const GdkColor *ca, - const GdkColor *cb) +rgba_equal (const GdkRGBA *a, + const GdkRGBA *b) { - guint i; + gdouble dr, dg, db, da; - for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i) - if (!gdk_color_equal (&ca[i], &cb[i])) - return FALSE; + dr = a->red - b->red; + dg = a->green - b->green; + db = a->blue - b->blue; + da = a->alpha - b->alpha; - return TRUE; + return (dr * dr + dg * dg + db * db + da * da) < 1e-4; +} + +static gboolean +palette_cmp (const GdkRGBA *ca, + const GdkRGBA *cb) +{ + guint i; + + for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i) + if (!rgba_equal (&ca[i], &cb[i])) + return FALSE; + + return TRUE; } static GParamSpec * @@ -340,7 +352,7 @@ get_prop_value_from_prop_name (TerminalProfile *profile, static void set_value_from_palette (GValue *ret_value, - const GdkColor *colors, + const GdkRGBA *colors, guint n_colors) { GValueArray *array; @@ -388,7 +400,7 @@ values_equal (GParamSpec *pspec, return TRUE; if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR) - return gdk_color_equal (g_value_get_boxed (va), g_value_get_boxed (vb)); + return rgba_equal (g_value_get_boxed (va), g_value_get_boxed (vb)); if (G_PARAM_SPEC_VALUE_TYPE (pspec) == PANGO_TYPE_FONT_DESCRIPTION) return pango_font_description_equal (g_value_get_boxed (va), g_value_get_boxed (vb)); @@ -406,7 +418,7 @@ values_equal (GParamSpec *pspec, return FALSE; for (i = 0; i < ara->n_values; ++i) - if (!gdk_color_equal (g_value_get_boxed (g_value_array_get_nth (ara, i)), + if (!rgba_equal (g_value_get_boxed (g_value_array_get_nth (ara, i)), g_value_get_boxed (g_value_array_get_nth (arb, i)))) return FALSE; @@ -575,12 +587,12 @@ terminal_profile_gsettings_notify_cb (GSettings *settings, } else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR) { - GdkColor color; + GdkRGBA color; if (!g_variant_is_of_type (settings_value, G_VARIANT_TYPE_STRING)) goto out; - if (!gdk_color_parse (g_variant_get_string (settings_value, NULL), &color)) + if (!gdk_rgba_parse (&color, g_variant_get_string (settings_value, NULL))) goto out; g_value_set_boxed (&value, &color); @@ -612,7 +624,7 @@ terminal_profile_gsettings_notify_cb (GSettings *settings, G_PARAM_SPEC_VALUE_TYPE (G_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec) == GDK_TYPE_COLOR) { char **color_strings; - GdkColor *colors; + GdkRGBA *colors; int n_colors, i; if (!g_variant_is_of_type (settings_value, G_VARIANT_TYPE_STRING)) @@ -623,10 +635,10 @@ terminal_profile_gsettings_notify_cb (GSettings *settings, goto out; n_colors = g_strv_length (color_strings); - colors = g_new0 (GdkColor, n_colors); + colors = g_new0 (GdkRGBA, n_colors); for (i = 0; i < n_colors; ++i) { - if (!gdk_color_parse (color_strings[i], &colors[i])) + if (!gdk_rgba_parse (&colors[i], color_strings[i])) continue; /* ignore errors */ } g_strfreev (color_strings); @@ -734,7 +746,7 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile, } else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR) { - GdkColor *color; + GdkRGBA *color; char str[16]; color = g_value_get_boxed (value); @@ -743,9 +755,9 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile, g_snprintf (str, sizeof (str), "#%04X%04X%04X", - color->red, - color->green, - color->blue); + (guint) (color->red * 65535), + (guint) (color->green * 65535), + (guint) (color->blue * 65535)); g_settings_set_string (changeset, key, str); } @@ -785,7 +797,7 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile, string = g_string_sized_new (n_colors * (1 /* # */ + 3 * 4) + n_colors /* : separators and terminating \0 */); for (i = 0; i < n_colors; ++i) { - GdkColor *color; + GdkRGBA *color; if (i > 0) g_string_append_c (string, ':'); @@ -796,9 +808,9 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile, g_string_append_printf (string, "#%04X%04X%04X", - color->red, - color->green, - color->blue); + (guint) (color->red * 65535), + (guint) (color->green * 65535), + (guint) (color->blue * 65535)); } g_settings_set_string (changeset, key, string->str); @@ -1544,7 +1556,7 @@ terminal_profile_reset_property (TerminalProfile *profile, gboolean terminal_profile_get_palette (TerminalProfile *profile, - GdkColor *colors, + GdkRGBA *colors, guint *n_colors) { TerminalProfilePrivate *priv; @@ -1562,7 +1574,7 @@ terminal_profile_get_palette (TerminalProfile *profile, n = MIN (array->n_values, *n_colors); for (i = 0; i < n; ++i) { - GdkColor *color = g_value_get_boxed (g_value_array_get_nth (array, i)); + GdkRGBA *color = g_value_get_boxed (g_value_array_get_nth (array, i)); if (!color) continue; /* shouldn't happen!! */ @@ -1577,7 +1589,7 @@ gboolean terminal_profile_get_palette_is_builtin (TerminalProfile *profile, guint *n) { - GdkColor colors[TERMINAL_PALETTE_SIZE]; + GdkRGBA colors[TERMINAL_PALETTE_SIZE]; guint n_colors; guint i; @@ -1613,12 +1625,12 @@ terminal_profile_set_palette_builtin (TerminalProfile *profile, gboolean terminal_profile_modify_palette_entry (TerminalProfile *profile, guint i, - const GdkColor *color) + const GdkRGBA *color) { TerminalProfilePrivate *priv = profile->priv; GValueArray *array; GValue *value; - GdkColor *old_color; + GdkRGBA *old_color; array = g_value_get_boxed (g_value_array_get_nth (priv->properties, PROP_PALETTE)); if (!array || @@ -1628,7 +1640,7 @@ terminal_profile_modify_palette_entry (TerminalProfile *profile, value = g_value_array_get_nth (array, i); old_color = g_value_get_boxed (value); if (!old_color || - !gdk_color_equal (old_color, color)) + !rgba_equal (old_color, color)) { g_value_set_boxed (value, color); g_object_notify (G_OBJECT (profile), TERMINAL_PROFILE_PALETTE); diff --git a/src/terminal-profile.h b/src/terminal-profile.h index a60d4c9..eae5a53 100644 --- a/src/terminal-profile.h +++ b/src/terminal-profile.h @@ -174,7 +174,7 @@ const char* terminal_profile_get_property_string (TerminalProfile *prof const char *prop_name); gboolean terminal_profile_get_palette (TerminalProfile *profile, - GdkColor *colors, + GdkRGBA *colors, guint *n_colors); gboolean terminal_profile_get_palette_is_builtin (TerminalProfile *profile, @@ -185,7 +185,7 @@ void terminal_profile_set_palette_builtin (TerminalProfile *prof gboolean terminal_profile_modify_palette_entry (TerminalProfile *profile, guint i, - const GdkColor *color); + const GdkRGBA *color); G_END_DECLS diff --git a/src/terminal-screen.c b/src/terminal-screen.c index d23ce2d..b7f472e 100644 --- a/src/terminal-screen.c +++ b/src/terminal-screen.c @@ -1009,74 +1009,54 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile, g_object_thaw_notify (object); } -/* TODO: Once Gtk2 support is dropped, mate-terminal should be converted to use GdkRGBA everywhere instead of GdkColor. */ -static GdkRGBA * -gdk_color_to_rgba (const GdkColor *color, - double alpha, - GdkRGBA *rgba) -{ - if (color == NULL) - return NULL; - rgba->red = color->red / 65535.0; - rgba->green = color->green / 65535.0; - rgba->blue = color->blue / 65535.0; - rgba->alpha = alpha; - return rgba; -} - static void update_color_scheme (TerminalScreen *screen) { TerminalScreenPrivate *priv = screen->priv; TerminalProfile *profile = priv->profile; - GdkColor colors[TERMINAL_PALETTE_SIZE]; - const GdkColor *fg_color, *bg_color, *bold_color; - GdkColor fg, bg; + GdkRGBA colors[TERMINAL_PALETTE_SIZE]; + const GdkRGBA *fg_rgba, *bg_rgba, *bold_rgba; + double bg_alpha = 1.0; + GdkRGBA fg, bg; guint n_colors; GtkStyleContext *context; - GdkRGBA rgba; context = gtk_widget_get_style_context (GTK_WIDGET (screen)); - gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &rgba); - rgba_to_color (&fg, &rgba); - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba); - rgba_to_color (&bg, &rgba); + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); + gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); + gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); + gtk_style_context_restore (context); - bold_color = NULL; + bold_rgba = NULL; if (!terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_THEME_COLORS)) { - fg_color = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR); - bg_color = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BACKGROUND_COLOR); + fg_rgba = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR); + bg_rgba = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BACKGROUND_COLOR); if (!terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG)) - bold_color = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BOLD_COLOR); + bold_rgba = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BOLD_COLOR); - if (fg_color) - fg = *fg_color; - if (bg_color) - bg = *bg_color; + if (fg_rgba) + fg = *fg_rgba; + if (bg_rgba) + bg = *bg_rgba; } n_colors = G_N_ELEMENTS (colors); terminal_profile_get_palette (priv->profile, colors, &n_colors); - GdkRGBA colors_rgba[TERMINAL_PALETTE_SIZE]; - GdkRGBA fg_rgba, bg_rgba, bold_rgba; - double alpha = 1.0; - int i; - - for (i = 0; i < n_colors; i++) - gdk_color_to_rgba (&colors[i], 1.0, &colors_rgba[i]); if (terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE) == TERMINAL_BACKGROUND_TRANSPARENT) - alpha = terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS); + bg_alpha = terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS); + bg.alpha = bg_alpha; + vte_terminal_set_colors (VTE_TERMINAL (screen), - gdk_color_to_rgba (&fg, 1.0, &fg_rgba), - gdk_color_to_rgba (&bg, alpha, &bg_rgba), - colors_rgba, n_colors); - if (bold_color) + &fg, &bg, + colors, n_colors); + if (bold_rgba) vte_terminal_set_color_bold (VTE_TERMINAL (screen), - gdk_color_to_rgba (bold_color, 1.0, &bold_rgba)); + bold_rgba); } void @@ -1975,7 +1955,7 @@ terminal_screen_drag_data_received (GtkWidget *widget, case TARGET_COLOR: { guint16 *data = (guint16 *)selection_data_data; - GdkColor color; + GdkRGBA color; /* We accept drops with the wrong format, since the KDE color * chooser incorrectly drops application/x-color with format 8. @@ -1984,9 +1964,10 @@ terminal_screen_drag_data_received (GtkWidget *widget, if (selection_data_length != 8) return; - color.red = data[0]; - color.green = data[1]; - color.blue = data[2]; + color.red = (double) data[0] / 65535.; + color.green = (double) data[1] / 65535.; + color.blue = (double) data[2] / 65535.; + color.alpha = 1.; /* FIXME: use opacity from data[3] */ g_object_set (priv->profile, diff --git a/src/terminal-util.c b/src/terminal-util.c index 6797c8b..c8b367c 100644 --- a/src/terminal-util.c +++ b/src/terminal-util.c @@ -816,18 +816,18 @@ object_change_notify_cb (PropertyChange *change) g_object_get (object, object_prop, &value, NULL); gtk_range_set_value (GTK_RANGE (widget), value); } - else if (GTK_IS_COLOR_BUTTON (widget)) + else if (GTK_IS_COLOR_CHOOSER (widget)) { - GdkColor *color; - GdkColor old_color; + GdkRGBA *color; + GdkRGBA old_color; g_object_get (object, object_prop, &color, NULL); - gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &old_color); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &old_color); - if (color && !gdk_color_equal (color, &old_color)) - gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), color); + if (color && !gdk_rgba_equal (color, &old_color)) + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (widget), color); if (color) - gdk_color_free (color); + gdk_rgba_free (color); } else if (GTK_IS_FONT_BUTTON (widget)) { @@ -912,11 +912,11 @@ widget_change_notify_cb (PropertyChange *change) value = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); g_object_set (object, object_prop, value, NULL); } - else if (GTK_IS_COLOR_BUTTON (widget)) + else if (GTK_IS_COLOR_CHOOSER (widget)) { - GdkColor color; + GdkRGBA color; - gtk_color_button_get_color (GTK_COLOR_BUTTON (widget), &color); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); g_object_set (object, object_prop, &color, NULL); } else if (GTK_IS_FONT_BUTTON (widget)) @@ -977,7 +977,7 @@ terminal_util_bind_object_property_to_widget (GObject *object, signal_name = "notify::text"; else if (GTK_IS_COMBO_BOX (widget)) signal_name = "notify::active"; - else if (GTK_IS_COLOR_BUTTON (widget)) + else if (GTK_IS_COLOR_CHOOSER (widget)) signal_name = "notify::color"; else if (GTK_IS_FONT_BUTTON (widget)) signal_name = "notify::font-name"; |