Commit f553b839 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte
Browse files

GladeGtkLabel: fix color attributes handling

Properly load/save pango color attributes

Fix issue #474 "GtkLabel: setup text attribute issues"
parent df807dd1
Pipeline #216472 passed with stages
in 3 minutes and 23 seconds
......@@ -707,7 +707,8 @@ value_icon_activate (GtkCellRendererToggle *cell_renderer,
GtkTreeIter iter;
PangoAttrType type;
AttrEditType edit_type;
GdkRGBA color = {0,};
PangoColor color;
GdkRGBA rgba;
gchar *text = NULL, *new_text;
/* Find type etc */
......@@ -726,25 +727,25 @@ value_icon_activate (GtkCellRendererToggle *cell_renderer,
dialog = gtk_color_chooser_dialog_new (_("Select a color"),
GTK_WINDOW (glade_app_get_window ()));
/* Get response etc... */
if (text && gdk_rgba_parse (&color, text))
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
if (text && pango_color_parse (&color, text))
{
rgba.red = color.red / 65535.0;
rgba.green = color.green / 65535.0;
rgba.blue = color.blue / 65535.0;
rgba.alpha = 1.0;
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
}
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
{
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
color.red = (gint16) (rgba.red * 65535);
color.green = (gint16) (rgba.green * 65535);
color.blue = (gint16) (rgba.blue * 65535);
/* Use PangoColor string format */
if (((guint8)(color.red * 0xFF)) * 0x101 == (guint16)(color.red * 0xFFFF) &&
((guint8)(color.green * 0xFF)) * 0x101 == (guint16)(color.green * 0xFFFF) &&
((guint8)(color.blue * 0xFF)) * 0x101 == (guint16)(color.blue * 0xFFFF))
new_text = g_strdup_printf ("#%02X%02X%02X",
(guint8)(color.red * 0xFF),
(guint8)(color.green * 0xFF),
(guint8)(color.blue * 0xFF));
else
new_text = g_strdup_printf ("#%04X%04X%04X",
(guint16)(color.red * 0xFFFF),
(guint16)(color.green * 0xFFFF),
(guint16)(color.blue * 0xFFFF));
new_text = pango_color_to_string (&color);
gtk_list_store_set (GTK_LIST_STORE (eprop_attrs->model), &iter,
COLUMN_TEXT, new_text,
......
......@@ -68,7 +68,7 @@ glade_gtk_label_set_attributes (GObject *object, const GValue *value)
PangoLanguage *language;
PangoFontDescription *font_desc;
PangoAttrList *attrs = NULL;
GdkColor *color;
PangoColor *color;
GList *list;
for (list = g_value_get_boxed (value); list; list = list->next)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment