[gimp/gtk3-port: 195/235] app: remove gimp_rgb_get,set_gdk_color()



commit 363e164b150dbb25b9e94083fc4ea1349abb5d3f
Author: Michael Natterer <mitch gimp org>
Date:   Wed Feb 23 08:57:00 2011 +0100

    app: remove gimp_rgb_get,set_gdk_color()
    
    and inline the few lines into their only users.

 app/widgets/gimptextbuffer.c    |   13 +++++++---
 app/widgets/gimptexttag.c       |   15 +++++++++--
 app/widgets/gimpwidgets-utils.c |   50 ---------------------------------------
 app/widgets/gimpwidgets-utils.h |    4 ---
 4 files changed, 21 insertions(+), 61 deletions(-)
---
diff --git a/app/widgets/gimptextbuffer.c b/app/widgets/gimptextbuffer.c
index a2052be..9d3ec2a 100644
--- a/app/widgets/gimptextbuffer.c
+++ b/app/widgets/gimptextbuffer.c
@@ -33,7 +33,6 @@
 #include "gimptextbuffer.h"
 #include "gimptextbuffer-serialize.h"
 #include "gimptexttag.h"
-#include "gimpwidgets-utils.h"
 
 #include "gimp-intl.h"
 
@@ -972,7 +971,9 @@ gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "color-#%02x%02x%02x",
               r, g, b);
 
-  gimp_rgb_get_gdk_color (color, &gdk_color);
+  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,
@@ -1054,7 +1055,9 @@ gimp_text_buffer_get_preedit_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "preedit-color-#%02x%02x%02x",
               r, g, b);
 
-  gimp_rgb_get_gdk_color (color, &gdk_color);
+  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,
@@ -1136,7 +1139,9 @@ gimp_text_buffer_get_preedit_bg_color_tag (GimpTextBuffer *buffer,
   g_snprintf (name, sizeof (name), "bg-color-#%02x%02x%02x",
               r, g, b);
 
-  gimp_rgb_get_gdk_color (color, &gdk_color);
+  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,
diff --git a/app/widgets/gimptexttag.c b/app/widgets/gimptexttag.c
index 893fe71..11deb78 100644
--- a/app/widgets/gimptexttag.c
+++ b/app/widgets/gimptexttag.c
@@ -28,7 +28,6 @@
 #include "widgets-types.h"
 
 #include "gimptexttag.h"
-#include "gimpwidgets-utils.h"
 
 
 gint
@@ -86,12 +85,17 @@ gimp_text_tag_get_color (GtkTextTag *tag,
                          GimpRGB    *color)
 {
   GdkColor *gdk_color;
+  guchar    r, g, b;
 
   g_object_get (tag,
                 GIMP_TEXT_PROP_NAME_COLOR, &gdk_color,
                 NULL);
 
-  gimp_rgb_set_gdk_color (color, gdk_color);
+  r = gdk_color->red   >> 8;
+  g = gdk_color->green >> 8;
+  b = gdk_color->blue  >> 8;
+
+  gimp_rgb_set_uchar (color, r, g, b);
 
   gdk_color_free (gdk_color);
 }
@@ -101,12 +105,17 @@ gimp_text_tag_get_bg_color (GtkTextTag *tag,
                             GimpRGB    *color)
 {
   GdkColor *gdk_color;
+  guchar    r, g, b;
 
   g_object_get (tag,
                 GIMP_TEXT_PROP_NAME_BG_COLOR, &gdk_color,
                 NULL);
 
-  gimp_rgb_set_gdk_color (color, gdk_color);
+  r = gdk_color->red   >> 8;
+  g = gdk_color->green >> 8;
+  b = gdk_color->blue  >> 8;
+
+  gimp_rgb_set_uchar (color, r, g, b);
 
   gdk_color_free (gdk_color);
 }
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 2f23d96..51ebc21 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -837,56 +837,6 @@ gimp_get_monitor_resolution (GdkScreen *screen,
   *yres = ROUND (y);
 }
 
-
-/**
- * gimp_rgb_get_gdk_color:
- * @rgb: the source color as #GimpRGB
- * @gdk_color: pointer to a #GdkColor
- *
- * Initializes @gdk_color from a #GimpRGB. This function does not
- * allocate the color for you. Depending on how you want to use it,
- * you may have to call gdk_colormap_alloc_color().
- **/
-void
-gimp_rgb_get_gdk_color (const GimpRGB *rgb,
-                        GdkColor      *gdk_color)
-{
-  guchar r, g, b;
-
-  g_return_if_fail (rgb != NULL);
-  g_return_if_fail (gdk_color != NULL);
-
-  gimp_rgb_get_uchar (rgb, &r, &g, &b);
-
-  gdk_color->red   = (r << 8) | r;
-  gdk_color->green = (g << 8) | g;
-  gdk_color->blue  = (b << 8) | b;
-}
-
-/**
- * gimp_rgb_set_gdk_color:
- * @rgb: a #GimpRGB that is to be set
- * @gdk_color: pointer to the source #GdkColor
- *
- * Initializes @rgb from a #GdkColor. This function does not touch
- * the alpha value of @rgb.
- **/
-void
-gimp_rgb_set_gdk_color (GimpRGB        *rgb,
-                        const GdkColor *gdk_color)
-{
-  guchar r, g, b;
-
-  g_return_if_fail (rgb != NULL);
-  g_return_if_fail (gdk_color != NULL);
-
-  r = gdk_color->red   >> 8;
-  g = gdk_color->green >> 8;
-  b = gdk_color->blue  >> 8;
-
-  gimp_rgb_set_uchar (rgb, r, g, b);
-}
-
 gboolean
 gimp_get_style_color (GtkWidget   *widget,
                       const gchar *property_name,
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index 655eb0b..b0e1a7e 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -73,10 +73,6 @@ void              gimp_get_monitor_resolution      (GdkScreen            *screen
                                                     gint                  monitor,
                                                     gdouble              *xres,
                                                     gdouble              *yres);
-void              gimp_rgb_get_gdk_color           (const GimpRGB        *rgb,
-                                                    GdkColor             *gdk_color);
-void              gimp_rgb_set_gdk_color           (GimpRGB              *rgb,
-                                                    const GdkColor       *gdk_color);
 gboolean          gimp_get_style_color             (GtkWidget            *widget,
                                                     const gchar          *property_name,
                                                     GdkRGBA              *color);


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