port GdkColors to GdkRGBA and GtkColorButton to GtkColorChooser
with help from Alexei Sorokin inspired from: https://git.gnome.org/browse/gnome-terminal/commit/?id=84099c3master-1.22
parent
40a42eb82a
commit
d85c96ad64
|
@ -34,31 +34,36 @@ typedef struct _TerminalColorScheme TerminalColorScheme;
|
||||||
struct _TerminalColorScheme
|
struct _TerminalColorScheme
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
const GdkColor foreground;
|
const GdkRGBA foreground;
|
||||||
const GdkColor background;
|
const GdkRGBA background;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const TerminalColorScheme color_schemes[] =
|
static const TerminalColorScheme color_schemes[] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
N_("Black on light yellow"),
|
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"),
|
N_("Black on white"),
|
||||||
{ 0, 0x0000, 0x0000, 0x0000 }, { 0, 0xFFFF, 0xFFFF, 0xFFFF }
|
{ 0, 0, 0, 1 },
|
||||||
|
{ 1, 1, 1, 1 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
N_("Gray on black"),
|
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"),
|
N_("Green on black"),
|
||||||
{ 0, 0x0000, 0xFFFF, 0x0000 }, { 0, 0x0000, 0x0000, 0x0000 }
|
{ 0, 1, 0, 1 },
|
||||||
|
{ 0, 0, 0, 1 }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
N_("White on black"),
|
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,
|
GParamSpec *pspec,
|
||||||
GtkComboBox *combo)
|
GtkComboBox *combo)
|
||||||
{
|
{
|
||||||
const GdkColor *fg, *bg;
|
const GdkRGBA *fg, *bg;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
fg = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR);
|
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)
|
for (i = 0; i < G_N_ELEMENTS (color_schemes); ++i)
|
||||||
{
|
{
|
||||||
if (gdk_color_equal (fg, &color_schemes[i].foreground) &&
|
if (gdk_rgba_equal (&fg, &color_schemes[i].foreground) &&
|
||||||
gdk_color_equal (bg, &color_schemes[i].background))
|
gdk_rgba_equal (&bg, &color_schemes[i].background))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,15 +418,15 @@ profile_palette_notify_scheme_combo_cb (TerminalProfile *profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
palette_color_notify_cb (GtkColorButton *button,
|
palette_color_notify_cb (GtkColorChooser *button,
|
||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
TerminalProfile *profile)
|
TerminalProfile *profile)
|
||||||
{
|
{
|
||||||
GtkWidget *editor;
|
GtkWidget *editor;
|
||||||
GdkColor color;
|
GdkRGBA color;
|
||||||
guint i;
|
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"));
|
i = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "palette-entry-index"));
|
||||||
|
|
||||||
editor = gtk_widget_get_toplevel (GTK_WIDGET (button));
|
editor = gtk_widget_get_toplevel (GTK_WIDGET (button));
|
||||||
|
@ -436,7 +441,7 @@ profile_palette_notify_colorpickers_cb (TerminalProfile *profile,
|
||||||
GtkWidget *editor)
|
GtkWidget *editor)
|
||||||
{
|
{
|
||||||
GtkWidget *w;
|
GtkWidget *w;
|
||||||
GdkColor colors[TERMINAL_PALETTE_SIZE];
|
GdkRGBA colors[TERMINAL_PALETTE_SIZE];
|
||||||
guint n_colors, i;
|
guint n_colors, i;
|
||||||
|
|
||||||
n_colors = G_N_ELEMENTS (colors);
|
n_colors = G_N_ELEMENTS (colors);
|
||||||
|
@ -446,16 +451,16 @@ profile_palette_notify_colorpickers_cb (TerminalProfile *profile,
|
||||||
for (i = 0; i < n_colors; i++)
|
for (i = 0; i < n_colors; i++)
|
||||||
{
|
{
|
||||||
char name[32];
|
char name[32];
|
||||||
GdkColor old_color;
|
GdkRGBA old_color;
|
||||||
|
|
||||||
g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1);
|
g_snprintf (name, sizeof (name), "palette-colorpicker-%d", i + 1);
|
||||||
w = profile_editor_get_widget (editor, name);
|
w = profile_editor_get_widget (editor, name);
|
||||||
|
|
||||||
gtk_color_button_get_color (GTK_COLOR_BUTTON (w), &old_color);
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (w), &old_color);
|
||||||
if (!gdk_color_equal (&old_color, &colors[i]))
|
if (!gdk_rgba_equal (&old_color, &colors[i]))
|
||||||
{
|
{
|
||||||
g_signal_handlers_block_by_func (w, G_CALLBACK (palette_color_notify_cb), profile);
|
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);
|
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);
|
gtk_widget_set_tooltip_text (w, text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
|
|
||||||
g_signal_connect (w, "notify::color",
|
g_signal_connect (w, "notify::rgba",
|
||||||
G_CALLBACK (palette_color_notify_cb),
|
G_CALLBACK (palette_color_notify_cb),
|
||||||
profile);
|
profile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,92 +186,89 @@ struct _TerminalProfilePrivate
|
||||||
guint forgotten : 1;
|
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 */
|
/* Tango palette */
|
||||||
{
|
{
|
||||||
{ 0, 0x0000, 0x0000, 0x0000 },
|
{ 0, 0, 0, 1 },
|
||||||
{ 0, 0xcccc, 0x0000, 0x0000 },
|
{ 0.8, 0, 0, 1 },
|
||||||
{ 0, 0x4e4e, 0x9a9a, 0x0606 },
|
{ 0.305882, 0.603922, 0.0235294, 1 },
|
||||||
{ 0, 0xc4c4, 0xa0a0, 0x0000 },
|
{ 0.768627, 0.627451, 0, 1 },
|
||||||
{ 0, 0x3434, 0x6565, 0xa4a4 },
|
{ 0.203922, 0.396078, 0.643137, 1 },
|
||||||
{ 0, 0x7575, 0x5050, 0x7b7b },
|
{ 0.458824, 0.313725, 0.482353, 1 },
|
||||||
{ 0, 0x0606, 0x9820, 0x9a9a },
|
{ 0.0235294, 0.596078, 0.603922, 1 },
|
||||||
{ 0, 0xd3d3, 0xd7d7, 0xcfcf },
|
{ 0.827451, 0.843137, 0.811765, 1 },
|
||||||
{ 0, 0x5555, 0x5757, 0x5353 },
|
{ 0.333333, 0.341176, 0.32549, 1 },
|
||||||
{ 0, 0xefef, 0x2929, 0x2929 },
|
{ 0.937255, 0.160784, 0.160784, 1 },
|
||||||
{ 0, 0x8a8a, 0xe2e2, 0x3434 },
|
{ 0.541176, 0.886275, 0.203922, 1 },
|
||||||
{ 0, 0xfcfc, 0xe9e9, 0x4f4f },
|
{ 0.988235, 0.913725, 0.309804, 1 },
|
||||||
{ 0, 0x7272, 0x9f9f, 0xcfcf },
|
{ 0.447059, 0.623529, 0.811765, 1 },
|
||||||
{ 0, 0xadad, 0x7f7f, 0xa8a8 },
|
{ 0.678431, 0.498039, 0.658824, 1 },
|
||||||
{ 0, 0x3434, 0xe2e2, 0xe2e2 },
|
{ 0.203922, 0.886275, 0.886275, 1 },
|
||||||
{ 0, 0xeeee, 0xeeee, 0xecec }
|
{ 0.933333, 0.933333, 0.92549, 1 },
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Linux palette */
|
/* Linux palette */
|
||||||
{
|
{
|
||||||
{ 0, 0x0000, 0x0000, 0x0000 },
|
{ 0, 0, 0, 1 },
|
||||||
{ 0, 0xaaaa, 0x0000, 0x0000 },
|
{ 0.666667, 0, 0, 1 },
|
||||||
{ 0, 0x0000, 0xaaaa, 0x0000 },
|
{ 0, 0.666667, 0, 1 },
|
||||||
{ 0, 0xaaaa, 0x5555, 0x0000 },
|
{ 0.666667, 0.333333, 0, 1 },
|
||||||
{ 0, 0x0000, 0x0000, 0xaaaa },
|
{ 0, 0, 0.666667, 1 },
|
||||||
{ 0, 0xaaaa, 0x0000, 0xaaaa },
|
{ 0.666667, 0, 0.666667, 1 },
|
||||||
{ 0, 0x0000, 0xaaaa, 0xaaaa },
|
{ 0, 0.666667, 0.666667, 1 },
|
||||||
{ 0, 0xaaaa, 0xaaaa, 0xaaaa },
|
{ 0.666667, 0.666667, 0.666667, 1 },
|
||||||
{ 0, 0x5555, 0x5555, 0x5555 },
|
{ 0.333333, 0.333333, 0.333333, 1 },
|
||||||
{ 0, 0xffff, 0x5555, 0x5555 },
|
{ 1, 0.333333, 0.333333, 1 },
|
||||||
{ 0, 0x5555, 0xffff, 0x5555 },
|
{ 0.333333, 1, 0.333333, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0x5555 },
|
{ 1, 1, 0.333333, 1 },
|
||||||
{ 0, 0x5555, 0x5555, 0xffff },
|
{ 0.333333, 0.333333, 1, 1 },
|
||||||
{ 0, 0xffff, 0x5555, 0xffff },
|
{ 1, 0.333333, 1, 1 },
|
||||||
{ 0, 0x5555, 0xffff, 0xffff },
|
{ 0.333333, 1, 1, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0xffff }
|
{ 1, 1, 1, 1 },
|
||||||
},
|
},
|
||||||
|
|
||||||
/* XTerm palette */
|
/* XTerm palette */
|
||||||
{
|
{
|
||||||
{ 0, 0x0000, 0x0000, 0x0000 },
|
{ 0, 0, 0, 1 },
|
||||||
{ 0, 0xcdcb, 0x0000, 0x0000 },
|
{ 0.803922, 0, 0, 1 },
|
||||||
{ 0, 0x0000, 0xcdcb, 0x0000 },
|
{ 0, 0.803922, 0, 1 },
|
||||||
{ 0, 0xcdcb, 0xcdcb, 0x0000 },
|
{ 0.803922, 0.803922, 0, 1 },
|
||||||
{ 0, 0x1e1a, 0x908f, 0xffff },
|
{ 0.117647, 0.564706, 1, 1 },
|
||||||
{ 0, 0xcdcb, 0x0000, 0xcdcb },
|
{ 0.803922, 0, 0.803922, 1 },
|
||||||
{ 0, 0x0000, 0xcdcb, 0xcdcb },
|
{ 0, 0.803922, 0.803922, 1 },
|
||||||
{ 0, 0xe5e2, 0xe5e2, 0xe5e2 },
|
{ 0.898039, 0.898039, 0.898039, 1 },
|
||||||
{ 0, 0x4ccc, 0x4ccc, 0x4ccc },
|
{ 0.298039, 0.298039, 0.298039, 1 },
|
||||||
{ 0, 0xffff, 0x0000, 0x0000 },
|
{ 1, 0, 0, 1 },
|
||||||
{ 0, 0x0000, 0xffff, 0x0000 },
|
{ 0, 1, 0, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0x0000 },
|
{ 1, 1, 0, 1 },
|
||||||
{ 0, 0x4645, 0x8281, 0xb4ae },
|
{ 0.27451, 0.509804, 0.705882, 1 },
|
||||||
{ 0, 0xffff, 0x0000, 0xffff },
|
{ 1, 0, 1, 1 },
|
||||||
{ 0, 0x0000, 0xffff, 0xffff },
|
{ 0, 1, 1, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0xffff }
|
{ 1, 1, 1, 1 },
|
||||||
},
|
},
|
||||||
|
|
||||||
/* RXVT palette */
|
/* RXVT palette */
|
||||||
{
|
{
|
||||||
{ 0, 0x0000, 0x0000, 0x0000 },
|
{ 0, 0, 0, 1 },
|
||||||
{ 0, 0xcdcd, 0x0000, 0x0000 },
|
{ 0.803922, 0, 0, 1 },
|
||||||
{ 0, 0x0000, 0xcdcd, 0x0000 },
|
{ 0, 0.803922, 0, 1 },
|
||||||
{ 0, 0xcdcd, 0xcdcd, 0x0000 },
|
{ 0.803922, 0.803922, 0, 1 },
|
||||||
{ 0, 0x0000, 0x0000, 0xcdcd },
|
{ 0, 0, 0.803922, 1 },
|
||||||
{ 0, 0xcdcd, 0x0000, 0xcdcd },
|
{ 0.803922, 0, 0.803922, 1 },
|
||||||
{ 0, 0x0000, 0xcdcd, 0xcdcd },
|
{ 0, 0.803922, 0.803922, 1 },
|
||||||
{ 0, 0xfafa, 0xebeb, 0xd7d7 },
|
{ 0.980392, 0.921569, 0.843137, 1 },
|
||||||
{ 0, 0x4040, 0x4040, 0x4040 },
|
{ 0.25098, 0.25098, 0.25098, 1 },
|
||||||
{ 0, 0xffff, 0x0000, 0x0000 },
|
{ 1, 0, 0, 1 },
|
||||||
{ 0, 0x0000, 0xffff, 0x0000 },
|
{ 0, 1, 0, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0x0000 },
|
{ 1, 1, 0, 1 },
|
||||||
{ 0, 0x0000, 0x0000, 0xffff },
|
{ 0, 0, 1, 1 },
|
||||||
{ 0, 0xffff, 0x0000, 0xffff },
|
{ 1, 0, 1, 1 },
|
||||||
{ 0, 0x0000, 0xffff, 0xffff },
|
{ 0, 1, 1, 1 },
|
||||||
{ 0, 0xffff, 0xffff, 0xffff }
|
{ 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
|
enum
|
||||||
{
|
{
|
||||||
FORGOTTEN,
|
FORGOTTEN,
|
||||||
|
@ -293,14 +290,29 @@ static GQuark gsettings_key_quark;
|
||||||
|
|
||||||
G_DEFINE_TYPE (TerminalProfile, terminal_profile, G_TYPE_OBJECT);
|
G_DEFINE_TYPE (TerminalProfile, terminal_profile, G_TYPE_OBJECT);
|
||||||
|
|
||||||
|
/* gdk_rgba_equal is too strict! */
|
||||||
static gboolean
|
static gboolean
|
||||||
palette_cmp (const GdkColor *ca,
|
rgba_equal (const GdkRGBA *a,
|
||||||
const GdkColor *cb)
|
const GdkRGBA *b)
|
||||||
|
{
|
||||||
|
gdouble dr, dg, db, da;
|
||||||
|
|
||||||
|
dr = a->red - b->red;
|
||||||
|
dg = a->green - b->green;
|
||||||
|
db = a->blue - b->blue;
|
||||||
|
da = a->alpha - b->alpha;
|
||||||
|
|
||||||
|
return (dr * dr + dg * dg + db * db + da * da) < 1e-4;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
palette_cmp (const GdkRGBA *ca,
|
||||||
|
const GdkRGBA *cb)
|
||||||
{
|
{
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
|
for (i = 0; i < TERMINAL_PALETTE_SIZE; ++i)
|
||||||
if (!gdk_color_equal (&ca[i], &cb[i]))
|
if (!rgba_equal (&ca[i], &cb[i]))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -340,7 +352,7 @@ get_prop_value_from_prop_name (TerminalProfile *profile,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_value_from_palette (GValue *ret_value,
|
set_value_from_palette (GValue *ret_value,
|
||||||
const GdkColor *colors,
|
const GdkRGBA *colors,
|
||||||
guint n_colors)
|
guint n_colors)
|
||||||
{
|
{
|
||||||
GValueArray *array;
|
GValueArray *array;
|
||||||
|
@ -388,7 +400,7 @@ values_equal (GParamSpec *pspec,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR)
|
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)
|
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));
|
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;
|
return FALSE;
|
||||||
|
|
||||||
for (i = 0; i < ara->n_values; ++i)
|
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))))
|
g_value_get_boxed (g_value_array_get_nth (arb, i))))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -575,12 +587,12 @@ terminal_profile_gsettings_notify_cb (GSettings *settings,
|
||||||
}
|
}
|
||||||
else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR)
|
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))
|
if (!g_variant_is_of_type (settings_value, G_VARIANT_TYPE_STRING))
|
||||||
goto out;
|
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;
|
goto out;
|
||||||
|
|
||||||
g_value_set_boxed (&value, &color);
|
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)
|
G_PARAM_SPEC_VALUE_TYPE (G_PARAM_SPEC_VALUE_ARRAY (pspec)->element_spec) == GDK_TYPE_COLOR)
|
||||||
{
|
{
|
||||||
char **color_strings;
|
char **color_strings;
|
||||||
GdkColor *colors;
|
GdkRGBA *colors;
|
||||||
int n_colors, i;
|
int n_colors, i;
|
||||||
|
|
||||||
if (!g_variant_is_of_type (settings_value, G_VARIANT_TYPE_STRING))
|
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;
|
goto out;
|
||||||
|
|
||||||
n_colors = g_strv_length (color_strings);
|
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)
|
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 */
|
continue; /* ignore errors */
|
||||||
}
|
}
|
||||||
g_strfreev (color_strings);
|
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)
|
else if (G_PARAM_SPEC_VALUE_TYPE (pspec) == GDK_TYPE_COLOR)
|
||||||
{
|
{
|
||||||
GdkColor *color;
|
GdkRGBA *color;
|
||||||
char str[16];
|
char str[16];
|
||||||
|
|
||||||
color = g_value_get_boxed (value);
|
color = g_value_get_boxed (value);
|
||||||
|
@ -743,9 +755,9 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile,
|
||||||
|
|
||||||
g_snprintf (str, sizeof (str),
|
g_snprintf (str, sizeof (str),
|
||||||
"#%04X%04X%04X",
|
"#%04X%04X%04X",
|
||||||
color->red,
|
(guint) (color->red * 65535),
|
||||||
color->green,
|
(guint) (color->green * 65535),
|
||||||
color->blue);
|
(guint) (color->blue * 65535));
|
||||||
|
|
||||||
g_settings_set_string (changeset, key, str);
|
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 */);
|
string = g_string_sized_new (n_colors * (1 /* # */ + 3 * 4) + n_colors /* : separators and terminating \0 */);
|
||||||
for (i = 0; i < n_colors; ++i)
|
for (i = 0; i < n_colors; ++i)
|
||||||
{
|
{
|
||||||
GdkColor *color;
|
GdkRGBA *color;
|
||||||
|
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
g_string_append_c (string, ':');
|
g_string_append_c (string, ':');
|
||||||
|
@ -796,9 +808,9 @@ terminal_profile_gsettings_changeset_add (TerminalProfile *profile,
|
||||||
|
|
||||||
g_string_append_printf (string,
|
g_string_append_printf (string,
|
||||||
"#%04X%04X%04X",
|
"#%04X%04X%04X",
|
||||||
color->red,
|
(guint) (color->red * 65535),
|
||||||
color->green,
|
(guint) (color->green * 65535),
|
||||||
color->blue);
|
(guint) (color->blue * 65535));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_settings_set_string (changeset, key, string->str);
|
g_settings_set_string (changeset, key, string->str);
|
||||||
|
@ -1544,7 +1556,7 @@ terminal_profile_reset_property (TerminalProfile *profile,
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
terminal_profile_get_palette (TerminalProfile *profile,
|
terminal_profile_get_palette (TerminalProfile *profile,
|
||||||
GdkColor *colors,
|
GdkRGBA *colors,
|
||||||
guint *n_colors)
|
guint *n_colors)
|
||||||
{
|
{
|
||||||
TerminalProfilePrivate *priv;
|
TerminalProfilePrivate *priv;
|
||||||
|
@ -1562,7 +1574,7 @@ terminal_profile_get_palette (TerminalProfile *profile,
|
||||||
n = MIN (array->n_values, *n_colors);
|
n = MIN (array->n_values, *n_colors);
|
||||||
for (i = 0; i < n; ++i)
|
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)
|
if (!color)
|
||||||
continue; /* shouldn't happen!! */
|
continue; /* shouldn't happen!! */
|
||||||
|
|
||||||
|
@ -1577,7 +1589,7 @@ gboolean
|
||||||
terminal_profile_get_palette_is_builtin (TerminalProfile *profile,
|
terminal_profile_get_palette_is_builtin (TerminalProfile *profile,
|
||||||
guint *n)
|
guint *n)
|
||||||
{
|
{
|
||||||
GdkColor colors[TERMINAL_PALETTE_SIZE];
|
GdkRGBA colors[TERMINAL_PALETTE_SIZE];
|
||||||
guint n_colors;
|
guint n_colors;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
@ -1613,12 +1625,12 @@ terminal_profile_set_palette_builtin (TerminalProfile *profile,
|
||||||
gboolean
|
gboolean
|
||||||
terminal_profile_modify_palette_entry (TerminalProfile *profile,
|
terminal_profile_modify_palette_entry (TerminalProfile *profile,
|
||||||
guint i,
|
guint i,
|
||||||
const GdkColor *color)
|
const GdkRGBA *color)
|
||||||
{
|
{
|
||||||
TerminalProfilePrivate *priv = profile->priv;
|
TerminalProfilePrivate *priv = profile->priv;
|
||||||
GValueArray *array;
|
GValueArray *array;
|
||||||
GValue *value;
|
GValue *value;
|
||||||
GdkColor *old_color;
|
GdkRGBA *old_color;
|
||||||
|
|
||||||
array = g_value_get_boxed (g_value_array_get_nth (priv->properties, PROP_PALETTE));
|
array = g_value_get_boxed (g_value_array_get_nth (priv->properties, PROP_PALETTE));
|
||||||
if (!array ||
|
if (!array ||
|
||||||
|
@ -1628,7 +1640,7 @@ terminal_profile_modify_palette_entry (TerminalProfile *profile,
|
||||||
value = g_value_array_get_nth (array, i);
|
value = g_value_array_get_nth (array, i);
|
||||||
old_color = g_value_get_boxed (value);
|
old_color = g_value_get_boxed (value);
|
||||||
if (!old_color ||
|
if (!old_color ||
|
||||||
!gdk_color_equal (old_color, color))
|
!rgba_equal (old_color, color))
|
||||||
{
|
{
|
||||||
g_value_set_boxed (value, color);
|
g_value_set_boxed (value, color);
|
||||||
g_object_notify (G_OBJECT (profile), TERMINAL_PROFILE_PALETTE);
|
g_object_notify (G_OBJECT (profile), TERMINAL_PROFILE_PALETTE);
|
||||||
|
|
|
@ -174,7 +174,7 @@ const char* terminal_profile_get_property_string (TerminalProfile *prof
|
||||||
const char *prop_name);
|
const char *prop_name);
|
||||||
|
|
||||||
gboolean terminal_profile_get_palette (TerminalProfile *profile,
|
gboolean terminal_profile_get_palette (TerminalProfile *profile,
|
||||||
GdkColor *colors,
|
GdkRGBA *colors,
|
||||||
guint *n_colors);
|
guint *n_colors);
|
||||||
|
|
||||||
gboolean terminal_profile_get_palette_is_builtin (TerminalProfile *profile,
|
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,
|
gboolean terminal_profile_modify_palette_entry (TerminalProfile *profile,
|
||||||
guint i,
|
guint i,
|
||||||
const GdkColor *color);
|
const GdkRGBA *color);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -1009,74 +1009,54 @@ terminal_screen_profile_notify_cb (TerminalProfile *profile,
|
||||||
g_object_thaw_notify (object);
|
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
|
static void
|
||||||
update_color_scheme (TerminalScreen *screen)
|
update_color_scheme (TerminalScreen *screen)
|
||||||
{
|
{
|
||||||
TerminalScreenPrivate *priv = screen->priv;
|
TerminalScreenPrivate *priv = screen->priv;
|
||||||
TerminalProfile *profile = priv->profile;
|
TerminalProfile *profile = priv->profile;
|
||||||
GdkColor colors[TERMINAL_PALETTE_SIZE];
|
GdkRGBA colors[TERMINAL_PALETTE_SIZE];
|
||||||
const GdkColor *fg_color, *bg_color, *bold_color;
|
const GdkRGBA *fg_rgba, *bg_rgba, *bold_rgba;
|
||||||
GdkColor fg, bg;
|
double bg_alpha = 1.0;
|
||||||
|
GdkRGBA fg, bg;
|
||||||
guint n_colors;
|
guint n_colors;
|
||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GdkRGBA rgba;
|
|
||||||
|
|
||||||
context = gtk_widget_get_style_context (GTK_WIDGET (screen));
|
context = gtk_widget_get_style_context (GTK_WIDGET (screen));
|
||||||
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &rgba);
|
gtk_style_context_save (context);
|
||||||
rgba_to_color (&fg, &rgba);
|
gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
|
||||||
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba);
|
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg);
|
||||||
rgba_to_color (&bg, &rgba);
|
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))
|
if (!terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_THEME_COLORS))
|
||||||
{
|
{
|
||||||
fg_color = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR);
|
fg_rgba = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FOREGROUND_COLOR);
|
||||||
bg_color = terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_BACKGROUND_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))
|
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)
|
if (fg_rgba)
|
||||||
fg = *fg_color;
|
fg = *fg_rgba;
|
||||||
if (bg_color)
|
if (bg_rgba)
|
||||||
bg = *bg_color;
|
bg = *bg_rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_colors = G_N_ELEMENTS (colors);
|
n_colors = G_N_ELEMENTS (colors);
|
||||||
terminal_profile_get_palette (priv->profile, colors, &n_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)
|
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),
|
vte_terminal_set_colors (VTE_TERMINAL (screen),
|
||||||
gdk_color_to_rgba (&fg, 1.0, &fg_rgba),
|
&fg, &bg,
|
||||||
gdk_color_to_rgba (&bg, alpha, &bg_rgba),
|
colors, n_colors);
|
||||||
colors_rgba, n_colors);
|
if (bold_rgba)
|
||||||
if (bold_color)
|
|
||||||
vte_terminal_set_color_bold (VTE_TERMINAL (screen),
|
vte_terminal_set_color_bold (VTE_TERMINAL (screen),
|
||||||
gdk_color_to_rgba (bold_color, 1.0, &bold_rgba));
|
bold_rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1975,7 +1955,7 @@ terminal_screen_drag_data_received (GtkWidget *widget,
|
||||||
case TARGET_COLOR:
|
case TARGET_COLOR:
|
||||||
{
|
{
|
||||||
guint16 *data = (guint16 *)selection_data_data;
|
guint16 *data = (guint16 *)selection_data_data;
|
||||||
GdkColor color;
|
GdkRGBA color;
|
||||||
|
|
||||||
/* We accept drops with the wrong format, since the KDE color
|
/* We accept drops with the wrong format, since the KDE color
|
||||||
* chooser incorrectly drops application/x-color with format 8.
|
* 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)
|
if (selection_data_length != 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
color.red = data[0];
|
color.red = (double) data[0] / 65535.;
|
||||||
color.green = data[1];
|
color.green = (double) data[1] / 65535.;
|
||||||
color.blue = data[2];
|
color.blue = (double) data[2] / 65535.;
|
||||||
|
color.alpha = 1.;
|
||||||
/* FIXME: use opacity from data[3] */
|
/* FIXME: use opacity from data[3] */
|
||||||
|
|
||||||
g_object_set (priv->profile,
|
g_object_set (priv->profile,
|
||||||
|
|
|
@ -816,18 +816,18 @@ object_change_notify_cb (PropertyChange *change)
|
||||||
g_object_get (object, object_prop, &value, NULL);
|
g_object_get (object, object_prop, &value, NULL);
|
||||||
gtk_range_set_value (GTK_RANGE (widget), value);
|
gtk_range_set_value (GTK_RANGE (widget), value);
|
||||||
}
|
}
|
||||||
else if (GTK_IS_COLOR_BUTTON (widget))
|
else if (GTK_IS_COLOR_CHOOSER (widget))
|
||||||
{
|
{
|
||||||
GdkColor *color;
|
GdkRGBA *color;
|
||||||
GdkColor old_color;
|
GdkRGBA old_color;
|
||||||
|
|
||||||
g_object_get (object, object_prop, &color, NULL);
|
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))
|
if (color && !gdk_rgba_equal (color, &old_color))
|
||||||
gtk_color_button_set_color (GTK_COLOR_BUTTON (widget), color);
|
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (widget), color);
|
||||||
if (color)
|
if (color)
|
||||||
gdk_color_free (color);
|
gdk_rgba_free (color);
|
||||||
}
|
}
|
||||||
else if (GTK_IS_FONT_BUTTON (widget))
|
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));
|
value = gtk_combo_box_get_active (GTK_COMBO_BOX (widget));
|
||||||
g_object_set (object, object_prop, value, NULL);
|
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);
|
g_object_set (object, object_prop, &color, NULL);
|
||||||
}
|
}
|
||||||
else if (GTK_IS_FONT_BUTTON (widget))
|
else if (GTK_IS_FONT_BUTTON (widget))
|
||||||
|
@ -977,7 +977,7 @@ terminal_util_bind_object_property_to_widget (GObject *object,
|
||||||
signal_name = "notify::text";
|
signal_name = "notify::text";
|
||||||
else if (GTK_IS_COMBO_BOX (widget))
|
else if (GTK_IS_COMBO_BOX (widget))
|
||||||
signal_name = "notify::active";
|
signal_name = "notify::active";
|
||||||
else if (GTK_IS_COLOR_BUTTON (widget))
|
else if (GTK_IS_COLOR_CHOOSER (widget))
|
||||||
signal_name = "notify::color";
|
signal_name = "notify::color";
|
||||||
else if (GTK_IS_FONT_BUTTON (widget))
|
else if (GTK_IS_FONT_BUTTON (widget))
|
||||||
signal_name = "notify::font-name";
|
signal_name = "notify::font-name";
|
||||||
|
|
Loading…
Reference in New Issue