]> git.sur5r.net Git - glabels/commitdiff
2009-04-29 Jim Evins <evins@purple>
authorJim Evins <evins@snaught.com>
Wed, 29 Apr 2009 18:20:54 +0000 (18:20 +0000)
committerJim Evins <evins@snaught.com>
Wed, 29 Apr 2009 18:20:54 +0000 (18:20 +0000)
* src/color.c: (gl_color_to_gdk_color), (gl_color_from_gdk_color):
* src/mygal/widget-color-combo.c: (color_combo_new):
* src/object-editor.c: (gl_object_editor_construct_color_combo):
* src/ui-property-bar.c: (gl_ui_property_bar_construct_color_combo):
Bug #2760830.  Display correct preview color in color combos when default
color selected.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/branches/glabels-2_2@834 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/ChangeLog
glabels2/src/color.c
glabels2/src/mygal/widget-color-combo.c
glabels2/src/object-editor.c
glabels2/src/ui-property-bar.c

index 819d633d4f589d3a22b874829d9f48b73e73d0e6..e3164ca2520dee3ed4bc8fd2573f1e8e0e44117c 100644 (file)
@@ -1,3 +1,12 @@
+2009-04-29  Jim Evins  <evins@purple>
+
+       * src/color.c: (gl_color_to_gdk_color), (gl_color_from_gdk_color):
+       * src/mygal/widget-color-combo.c: (color_combo_new):
+       * src/object-editor.c: (gl_object_editor_construct_color_combo):
+       * src/ui-property-bar.c: (gl_ui_property_bar_construct_color_combo):
+               Bug #2760830.  Display correct preview color in color combos when default
+               color selected.
+
 2009-04-28  Jim Evins  <evins@purple>
 
        * data/glade/object-editor.glade:
index e8c039dc7078c380ef3ebb62151cdab599fd6e63..e4bf3bdf192f84a54695807208123fc7ee386c3d 100644 (file)
@@ -63,13 +63,16 @@ gl_color_shadow (guint   base_color,
 GdkColor *
 gl_color_to_gdk_color (guint color)
 {
-        GdkColor *gdk_color;
+        GdkColor *gdk_color = NULL;
 
-        gdk_color = g_new0 (GdkColor, 1);
+        if ( GL_COLOR_F_ALPHA (color) )
+        {
+                gdk_color = g_new0 (GdkColor, 1);
 
-        gdk_color->red   = GL_COLOR_F_RED   (color) * 65535;
-        gdk_color->green = GL_COLOR_F_GREEN (color) * 65535;
-        gdk_color->blue  = GL_COLOR_F_BLUE  (color) * 65535;
+                gdk_color->red   = GL_COLOR_F_RED   (color) * 65535;
+                gdk_color->green = GL_COLOR_F_GREEN (color) * 65535;
+                gdk_color->blue  = GL_COLOR_F_BLUE  (color) * 65535;
+        }
 
         return gdk_color;
 }
@@ -80,11 +83,14 @@ gl_color_to_gdk_color (guint color)
 guint
 gl_color_from_gdk_color (GdkColor *gdk_color)
 {
-        guint color;
+        guint color = GL_COLOR_NONE;
 
-        color = GL_COLOR ((gdk_color->red   >>8),
-                          (gdk_color->green >>8),
-                          (gdk_color->blue  >>8));
+        if ( gdk_color )
+        {
+                color = GL_COLOR ((gdk_color->red   >>8),
+                                  (gdk_color->green >>8),
+                                  (gdk_color->blue  >>8));
+        }
 
         return color;
 }
index 5ca2708f837c67b8cba7e1eb3ee9a142d2728da4..8f365456d511ef5741582d8b099815ade212a926 100644 (file)
@@ -327,7 +327,10 @@ color_combo_new (GdkPixbuf *icon, char const *no_color_label,
 
        cc = g_object_new (COLOR_COMBO_TYPE, NULL);
 
-        cc->default_color = default_color;
+       if ( default_color )
+       {
+               cc->default_color = gdk_color_copy (default_color);
+       }
 
        color_combo_construct (cc, icon, no_color_label, color_group);
 
index bb2d99a8f4e1df4844625772dae6434a63fc3086..02a153d6b5f26e1bc782741d55f781e35e42dfe2 100644 (file)
@@ -576,7 +576,6 @@ gl_object_editor_construct_color_combo (gchar *name,
        GtkWidget  *color_combo;
        ColorGroup *cg;
        gchar      *cg_name;
-       guint       color;
        GdkColor   *gdk_color;
        gchar      *no_color;
 
@@ -584,33 +583,32 @@ gl_object_editor_construct_color_combo (gchar *name,
 
        case 3:
                cg_name  = "shadow_color_group";
-               color    = GL_COLOR_SHADOW_DEFAULT;
+                gdk_color = gl_color_to_gdk_color (GL_COLOR_SHADOW_DEFAULT);
                no_color = _("Default");
                break;
 
        case 2:
                cg_name  = "text_color_group";
-               color    = gl_prefs->default_text_color;
+                gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
                no_color = _("Default");
                break;
 
        case 1:
                cg_name  = "line_color_group";
-               color    = gl_prefs->default_line_color;
+                gdk_color = NULL;
                no_color = _("No line");
                break;
 
        case 0:
        default:
                cg_name  = "fill_color_group";
-               color    = gl_prefs->default_fill_color;
+                gdk_color = NULL;
                no_color = _("No fill");
                break;
 
        }
 
        cg = color_group_fetch (cg_name, NULL);
-        gdk_color = gl_color_to_gdk_color (color);
        color_combo = color_combo_new (NULL, no_color, gdk_color, cg);
         g_free (gdk_color);
 
index d128682c3c8512c136a6604cf4166431f9dcc3bd..005c8380095c7429511e38da7a11852bb141e6f6 100644 (file)
@@ -1220,7 +1220,6 @@ gl_ui_property_bar_construct_color_combo (gchar *name,
        GtkWidget  *color_combo;
        ColorGroup *cg;
        gchar      *cg_name;
-       guint       color;
        GdkColor   *gdk_color;
        gchar      *no_color;
        GdkPixbuf  *pixbuf = NULL;
@@ -1229,14 +1228,14 @@ gl_ui_property_bar_construct_color_combo (gchar *name,
 
        case 0:
                cg_name  = "text_color_group";
-               color    = gl_prefs->default_text_color;
+                gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color);
                no_color = _("Default");
                pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL);
                break;
 
        case 2:
                cg_name  = "line_color_group";
-               color    = gl_prefs->default_line_color;
+                gdk_color = NULL;
                no_color = _("No line");
                pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL);
                break;
@@ -1244,7 +1243,7 @@ gl_ui_property_bar_construct_color_combo (gchar *name,
        case 1:
        default:
                cg_name  = "fill_color_group";
-               color    = gl_prefs->default_fill_color;
+                gdk_color = NULL;
                no_color = _("No fill");
                pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL);
                break;
@@ -1252,7 +1251,6 @@ gl_ui_property_bar_construct_color_combo (gchar *name,
        }
 
        cg = color_group_fetch (cg_name, NULL);
-        gdk_color = gl_color_to_gdk_color (color);
        color_combo = color_combo_new (pixbuf, no_color, gdk_color, cg);
         g_free (gdk_color);