[gimp] app: use GdkRGBA instead of GdkColor for text tags



commit ab17727d444c4c647696e0bcdb679b2624c65830
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jul 3 22:31:32 2018 +0200

    app: use GdkRGBA instead of GdkColor for text tags

 app/widgets/gimptextbuffer.c | 27 ++++++---------------------
 app/widgets/gimptexttag.c    | 26 ++++++++------------------
 app/widgets/gimptexttag.h    |  4 ++--
 3 files changed, 16 insertions(+), 41 deletions(-)
---
diff --git a/app/widgets/gimptextbuffer.c b/app/widgets/gimptextbuffer.c
index 50ced78edd..04bcb8b68a 100644
--- a/app/widgets/gimptextbuffer.c
+++ b/app/widgets/gimptextbuffer.c
@@ -962,7 +962,6 @@ gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer,
   GList      *list;
   GtkTextTag *tag;
   gchar       name[256];
-  GdkColor    gdk_color;
   guchar      r, g, b;
 
   gimp_rgb_get_uchar (color, &r, &g, &b);
@@ -990,14 +989,10 @@ gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "color-#%02x%02x%02x",
               r, g, b);
 
-  gdk_color.red   = (r << 8) | r;
-  gdk_color.green = (g << 8) | g;
-  gdk_color.blue  = (b << 8) | b;
-
   tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer),
                                     name,
-                                    "foreground-gdk", &gdk_color,
-                                    "foreground-set", TRUE,
+                                    "foreground-rgba", (GdkRGBA *) color,
+                                    "foreground-set",  TRUE,
                                     NULL);
 
   buffer->color_tags = g_list_prepend (buffer->color_tags, tag);
@@ -1048,7 +1043,6 @@ gimp_text_buffer_get_preedit_color_tag (GimpTextBuffer *buffer,
   GList      *list;
   GtkTextTag *tag;
   gchar       name[256];
-  GdkColor    gdk_color;
   guchar      r, g, b;
 
   gimp_rgb_get_uchar (color, &r, &g, &b);
@@ -1076,14 +1070,10 @@ gimp_text_buffer_get_preedit_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "preedit-color-#%02x%02x%02x",
               r, g, b);
 
-  gdk_color.red   = (r << 8) | r;
-  gdk_color.green = (g << 8) | g;
-  gdk_color.blue  = (b << 8) | b;
-
   tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer),
                                     name,
-                                    "foreground-gdk", &gdk_color,
-                                    "foreground-set", TRUE,
+                                    "foreground-rgba", (GdkRGBA *) color,
+                                    "foreground-set",  TRUE,
                                     NULL);
 
   buffer->preedit_color_tags = g_list_prepend (buffer->preedit_color_tags, tag);
@@ -1132,7 +1122,6 @@ gimp_text_buffer_get_preedit_bg_color_tag (GimpTextBuffer *buffer,
   GList      *list;
   GtkTextTag *tag;
   gchar       name[256];
-  GdkColor    gdk_color;
   guchar      r, g, b;
 
   gimp_rgb_get_uchar (color, &r, &g, &b);
@@ -1160,14 +1149,10 @@ gimp_text_buffer_get_preedit_bg_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "bg-color-#%02x%02x%02x",
               r, g, b);
 
-  gdk_color.red   = (r << 8) | r;
-  gdk_color.green = (g << 8) | g;
-  gdk_color.blue  = (b << 8) | b;
-
   tag = gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (buffer),
                                     name,
-                                    "background-gdk", &gdk_color,
-                                    "background-set", TRUE,
+                                    "background-rgba", (GdkRGBA *) color,
+                                    "background-set",  TRUE,
                                     NULL);
 
   buffer->preedit_bg_color_tags = g_list_prepend (buffer->preedit_bg_color_tags, tag);
diff --git a/app/widgets/gimptexttag.c b/app/widgets/gimptexttag.c
index 5cf7681ad7..88c0159ea3 100644
--- a/app/widgets/gimptexttag.c
+++ b/app/widgets/gimptexttag.c
@@ -84,22 +84,17 @@ gboolean
 gimp_text_tag_get_fg_color (GtkTextTag *tag,
                             GimpRGB    *color)
 {
-  GdkColor *gdk_color;
+  GdkRGBA  *rgba;
   gboolean  set;
-  guchar    r, g, b;
 
   g_object_get (tag,
                 "foreground-set",             &set,
-                GIMP_TEXT_PROP_NAME_FG_COLOR, &gdk_color,
+                GIMP_TEXT_PROP_NAME_FG_COLOR, &rgba,
                 NULL);
 
-  r = gdk_color->red   >> 8;
-  g = gdk_color->green >> 8;
-  b = gdk_color->blue  >> 8;
+  gimp_rgb_set (color, rgba->red, rgba->green, rgba->blue);
 
-  gimp_rgb_set_uchar (color, r, g, b);
-
-  gdk_color_free (gdk_color);
+  gdk_rgba_free (rgba);
 
   return set;
 }
@@ -108,22 +103,17 @@ gboolean
 gimp_text_tag_get_bg_color (GtkTextTag *tag,
                             GimpRGB    *color)
 {
-  GdkColor *gdk_color;
+  GdkRGBA  *rgba;
   gboolean  set;
-  guchar    r, g, b;
 
   g_object_get (tag,
                 "background-set",             &set,
-                GIMP_TEXT_PROP_NAME_BG_COLOR, &gdk_color,
+                GIMP_TEXT_PROP_NAME_BG_COLOR, &rgba,
                 NULL);
 
-  r = gdk_color->red   >> 8;
-  g = gdk_color->green >> 8;
-  b = gdk_color->blue  >> 8;
-
-  gimp_rgb_set_uchar (color, r, g, b);
+  gimp_rgb_set (color, rgba->red, rgba->green, rgba->blue);
 
-  gdk_color_free (gdk_color);
+  gdk_rgba_free (rgba);
 
   return set;
 }
diff --git a/app/widgets/gimptexttag.h b/app/widgets/gimptexttag.h
index 7e0ebfcdc0..3a2bfe2cb1 100644
--- a/app/widgets/gimptexttag.h
+++ b/app/widgets/gimptexttag.h
@@ -28,8 +28,8 @@
 #define GIMP_TEXT_PROP_NAME_BASELINE "rise"
 #define GIMP_TEXT_PROP_NAME_KERNING  "rise" /* FIXME */
 #define GIMP_TEXT_PROP_NAME_FONT     "font"
-#define GIMP_TEXT_PROP_NAME_FG_COLOR "foreground-gdk"
-#define GIMP_TEXT_PROP_NAME_BG_COLOR "background-gdk"
+#define GIMP_TEXT_PROP_NAME_FG_COLOR "foreground-rgba"
+#define GIMP_TEXT_PROP_NAME_BG_COLOR "background-rgba"
 
 
 gint       gimp_text_tag_get_size     (GtkTextTag *tag);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]