[glade] GladeGtkLabel: fix color attributes handling
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] GladeGtkLabel: fix color attributes handling
- Date: Fri, 25 Sep 2020 22:22:00 +0000 (UTC)
commit f553b839bd7b994b0168dba0313b38b00cb190bf
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Fri Sep 25 19:19:00 2020 -0300
GladeGtkLabel: fix color attributes handling
Properly load/save pango color attributes
Fix issue #474 "GtkLabel: setup text attribute issues"
plugins/gtk+/glade-attributes.c | 33 +++++++++++++++++----------------
plugins/gtk+/glade-gtk-label.c | 2 +-
2 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/plugins/gtk+/glade-attributes.c b/plugins/gtk+/glade-attributes.c
index a3b560ce..1f57510d 100644
--- a/plugins/gtk+/glade-attributes.c
+++ b/plugins/gtk+/glade-attributes.c
@@ -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,
diff --git a/plugins/gtk+/glade-gtk-label.c b/plugins/gtk+/glade-gtk-label.c
index 9b127592..58d20df9 100644
--- a/plugins/gtk+/glade-gtk-label.c
+++ b/plugins/gtk+/glade-gtk-label.c
@@ -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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]