* 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
+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:
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;
}
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;
}
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);
GtkWidget *color_combo;
ColorGroup *cg;
gchar *cg_name;
- guint color;
GdkColor *gdk_color;
gchar *no_color;
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);
GtkWidget *color_combo;
ColorGroup *cg;
gchar *cg_name;
- guint color;
GdkColor *gdk_color;
gchar *no_color;
GdkPixbuf *pixbuf = NULL;
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;
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;
}
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);