From: Jim Evins Date: Wed, 29 Apr 2009 18:20:54 +0000 (+0000) Subject: 2009-04-29 Jim Evins X-Git-Tag: glabels-2_2_5~5 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=30da2882aea0fedfe88020c61dc642beee5a0a9d;p=glabels 2009-04-29 Jim Evins * 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 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 819d633d..e3164ca2 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2009-04-29 Jim Evins + + * 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 * data/glade/object-editor.glade: diff --git a/glabels2/src/color.c b/glabels2/src/color.c index e8c039dc..e4bf3bdf 100644 --- a/glabels2/src/color.c +++ b/glabels2/src/color.c @@ -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; } diff --git a/glabels2/src/mygal/widget-color-combo.c b/glabels2/src/mygal/widget-color-combo.c index 5ca2708f..8f365456 100644 --- a/glabels2/src/mygal/widget-color-combo.c +++ b/glabels2/src/mygal/widget-color-combo.c @@ -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); diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index bb2d99a8..02a153d6 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -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); diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index d128682c..005c8380 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -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);