[gtk+] gtk/gtkcolorbutton.c: Do not use deprecated GdkColor api



commit 912375ff38556289902590e59b6a65e5ea92d6b7
Author: Javier JardÃn <jjardon gnome org>
Date:   Tue Jan 3 18:12:15 2012 +0100

    gtk/gtkcolorbutton.c: Do not use deprecated GdkColor api

 gtk/gtkcolorbutton.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 0be2b89..bee1bec 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -932,7 +932,19 @@ gtk_color_button_set_property (GObject      *object,
       gtk_color_button_set_title (color_button, g_value_get_string (value));
       break;
     case PROP_COLOR:
-      gtk_color_button_set_color (color_button, g_value_get_boxed (value));
+      {
+        GdkColor *color;
+        GdkRGBA rgba;
+
+        color = g_value_get_boxed (value);
+
+        rgba.red = color->red / 65535.0;
+        rgba.green = color->green / 65535.0;
+        rgba.blue = color->blue / 65535.0;
+        rgba.alpha = 1.0;
+
+        gtk_color_button_set_rgba (color_button, &rgba);
+      }
       break;
     case PROP_ALPHA:
       gtk_color_button_set_alpha (color_button, g_value_get_uint (value));
@@ -953,7 +965,6 @@ gtk_color_button_get_property (GObject    *object,
                                GParamSpec *pspec)
 {
   GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
-  GdkColor color;
 
   switch (param_id)
     {
@@ -964,8 +975,18 @@ gtk_color_button_get_property (GObject    *object,
       g_value_set_string (value, gtk_color_button_get_title (color_button));
       break;
     case PROP_COLOR:
-      gtk_color_button_get_color (color_button, &color);
-      g_value_set_boxed (value, &color);
+      {
+        GdkColor color;
+        GdkRGBA rgba;
+
+        gtk_color_button_get_rgba (color_button, &rgba);
+
+        color.red = (guint16) (rgba.red * 65535 + 0.5);
+        color.green = (guint16) (rgba.green * 65535 + 0.5);
+        color.blue = (guint16) (rgba.blue * 65535 + 0.5);
+
+        g_value_set_boxed (value, &color);
+      }
       break;
     case PROP_ALPHA:
       g_value_set_uint (value, gtk_color_button_get_alpha (color_button));



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