From 2d88eaebd52cdd58e6e0fc0b7eb8975f44b62a5f Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 31 Aug 2003 02:56:55 +0000 Subject: [PATCH] - Replaced gnome color pickers with mygal color combos. - Made context of all color groups NULL. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@278 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/ui-property-bar.c | 6 ++--- glabels2/src/wdgt-bc-props.c | 40 ++++++++++++++++++----------- glabels2/src/wdgt-fill.c | 39 +++++++++++++++++++--------- glabels2/src/wdgt-line.c | 43 +++++++++++++++++++++---------- glabels2/src/wdgt-text-props.c | 46 ++++++++++++++++++++++------------ 5 files changed, 116 insertions(+), 58 deletions(-) diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index ed0e8d6d..a71cb199 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -340,7 +340,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar, (gpointer)property_bar); /* Text color widget */ - cg = color_group_fetch ("text_color_group", ui_component); + cg = color_group_fetch ("text_color_group", NULL); pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color); property_bar->text_color_combo = color_combo_new (pixbuf, _("Default"), @@ -355,7 +355,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar, "/PropertyToolbar/PropTextColor"); /* Fill color widget */ - cg = color_group_fetch ("fill_color_group", ui_component); + cg = color_group_fetch ("fill_color_group", NULL); pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color); property_bar->fill_color_combo = color_combo_new (pixbuf, _("No fill"), @@ -370,7 +370,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *property_bar, "/PropertyToolbar/PropFillColor"); /* Line color widget */ - cg = color_group_fetch ("line_color_group", ui_component); + cg = color_group_fetch ("line_color_group", NULL); pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); property_bar->line_color_combo = color_combo_new (pixbuf, _("No line"), diff --git a/glabels2/src/wdgt-bc-props.c b/glabels2/src/wdgt-bc-props.c index e0169fb0..f76063b5 100644 --- a/glabels2/src/wdgt-bc-props.c +++ b/glabels2/src/wdgt-bc-props.c @@ -22,6 +22,8 @@ #include +#include "mygal/widget-color-combo.h" +#include "prefs.h" #include "wdgt-bc-props.h" #include "marshal.h" #include "color.h" @@ -151,8 +153,9 @@ gl_wdgt_bc_props_new (void) static void gl_wdgt_bc_props_construct (glWdgtBCProps *prop) { - GtkWidget *wvbox, *whbox, *wlabel; - GtkObject *adjust; + GtkWidget *wvbox, *whbox, *wlabel; + ColorGroup *cg; + GdkColor *gdk_color; wvbox = GTK_WIDGET (prop); @@ -166,8 +169,13 @@ gl_wdgt_bc_props_construct (glWdgtBCProps *prop) gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_label); /* Line Color picker widget */ - prop->color_picker = gnome_color_picker_new (); - g_signal_connect_swapped (G_OBJECT (prop->color_picker), "color_set", + cg = color_group_fetch ("line_color_group", NULL); + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + prop->color_picker = color_combo_new (NULL, _("Default"), gdk_color, cg); + color_combo_box_set_preview_relief (COLOR_COMBO(prop->color_picker), + GTK_RELIEF_NORMAL); + g_free (gdk_color); + g_signal_connect_swapped (G_OBJECT (prop->color_picker), "color_changed", G_CALLBACK (changed_cb), G_OBJECT (prop)); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_picker); @@ -190,13 +198,17 @@ void gl_wdgt_bc_props_get_params (glWdgtBCProps *prop, guint *color) { - guint8 r, g, b, a; + GdkColor *gdk_color; + gboolean is_default; - /* ------- Get updated line color ------ */ - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (prop->color_picker), - &r, &g, &b, &a); - *color = GL_COLOR_A (r, g, b, a); + gdk_color = color_combo_get_color (COLOR_COMBO(prop->color_picker), + &is_default); + if (is_default) { + *color = gl_prefs->default_line_color; + } else { + *color = gl_color_from_gdk_color (gdk_color); + } } /***************************************************************************/ @@ -206,11 +218,11 @@ void gl_wdgt_bc_props_set_params (glWdgtBCProps *prop, guint color) { - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (prop->color_picker), - GL_COLOR_I_RED (color), - GL_COLOR_I_GREEN (color), - GL_COLOR_I_BLUE (color), - GL_COLOR_I_ALPHA (color)); + GdkColor *gdk_color; + + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(prop->color_picker), gdk_color); + g_free (gdk_color); } /****************************************************************************/ diff --git a/glabels2/src/wdgt-fill.c b/glabels2/src/wdgt-fill.c index 795fb9a6..c2c59703 100644 --- a/glabels2/src/wdgt-fill.c +++ b/glabels2/src/wdgt-fill.c @@ -22,6 +22,8 @@ #include +#include "mygal/widget-color-combo.h" +#include "prefs.h" #include "wdgt-fill.h" #include "marshal.h" #include "color.h" @@ -152,7 +154,9 @@ gl_wdgt_fill_new (void) static void gl_wdgt_fill_construct (glWdgtFill *fill) { - GtkWidget *wvbox, *whbox; + GtkWidget *wvbox, *whbox; + ColorGroup *cg; + GdkColor *gdk_color; wvbox = GTK_WIDGET (fill); @@ -166,8 +170,13 @@ gl_wdgt_fill_construct (glWdgtFill *fill) gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_label); /* Fill Color picker widget */ - fill->color_picker = gnome_color_picker_new (); - g_signal_connect_swapped (G_OBJECT (fill->color_picker), "color_set", + cg = color_group_fetch ("fill_color_group", NULL); + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + fill->color_picker = color_combo_new (NULL, _("No fill"), gdk_color, cg); + color_combo_box_set_preview_relief (COLOR_COMBO(fill->color_picker), + GTK_RELIEF_NORMAL); + g_free (gdk_color); + g_signal_connect_swapped (G_OBJECT (fill->color_picker), "color_changed", G_CALLBACK (changed_cb), G_OBJECT (fill)); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_picker); @@ -190,11 +199,17 @@ void gl_wdgt_fill_get_params (glWdgtFill *fill, guint *color) { - guint8 r, g, b, a; + GdkColor *gdk_color; + gboolean is_default; - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (fill->color_picker), - &r, &g, &b, &a); - *color = GL_COLOR_A (r, g, b, a); + gdk_color = color_combo_get_color (COLOR_COMBO(fill->color_picker), + &is_default); + + if (is_default) { + *color = GL_COLOR_NONE; + } else { + *color = gl_color_from_gdk_color (gdk_color); + } } /****************************************************************************/ @@ -204,11 +219,11 @@ void gl_wdgt_fill_set_params (glWdgtFill *fill, guint color) { - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (fill->color_picker), - GL_COLOR_I_RED (color), - GL_COLOR_I_GREEN (color), - GL_COLOR_I_BLUE (color), - GL_COLOR_I_ALPHA (color)); + GdkColor *gdk_color; + + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(fill->color_picker), gdk_color); + g_free (gdk_color); } /****************************************************************************/ diff --git a/glabels2/src/wdgt-line.c b/glabels2/src/wdgt-line.c index 8682c647..b975b1f1 100644 --- a/glabels2/src/wdgt-line.c +++ b/glabels2/src/wdgt-line.c @@ -22,6 +22,8 @@ #include +#include "mygal/widget-color-combo.h" +#include "prefs.h" #include "wdgt-line.h" #include "marshal.h" #include "color.h" @@ -57,6 +59,7 @@ static void gl_wdgt_line_finalize (GObject *object); static void gl_wdgt_line_construct (glWdgtLine *line); static void changed_cb (glWdgtLine *line); + /****************************************************************************/ /* Boilerplate Object stuff. */ @@ -153,8 +156,10 @@ gl_wdgt_line_new (void) static void gl_wdgt_line_construct (glWdgtLine *line) { - GtkWidget *wvbox, *wframe, *whbox; - GtkObject *adjust; + GtkWidget *wvbox, *wframe, *whbox; + GtkObject *adjust; + ColorGroup *cg; + GdkColor *gdk_color; wvbox = GTK_WIDGET (line); @@ -191,8 +196,13 @@ gl_wdgt_line_construct (glWdgtLine *line) gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_label); /* Line Color picker widget */ - line->color_picker = gnome_color_picker_new (); - g_signal_connect_swapped (G_OBJECT (line->color_picker), "color_set", + cg = color_group_fetch ("line_color_group", NULL); + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + line->color_picker = color_combo_new (NULL, _("No line"), gdk_color, cg); + color_combo_box_set_preview_relief (COLOR_COMBO(line->color_picker), + GTK_RELIEF_NORMAL); + g_free (gdk_color); + g_signal_connect_swapped (G_OBJECT (line->color_picker), "color_changed", G_CALLBACK (changed_cb), G_OBJECT (line)); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_picker); @@ -217,14 +227,20 @@ gl_wdgt_line_get_params (glWdgtLine *line, gdouble *width, guint *color) { - guint8 r, g, b, a; + GdkColor *gdk_color; + gboolean is_default; *width = gtk_spin_button_get_value (GTK_SPIN_BUTTON(line->width_spin)); - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (line->color_picker), - &r, &g, &b, &a); - *color = GL_COLOR_A (r, g, b, a); + gdk_color = color_combo_get_color (COLOR_COMBO(line->color_picker), + &is_default); + + if (is_default) { + *color = GL_COLOR_NONE; + } else { + *color = gl_color_from_gdk_color (gdk_color); + } } /****************************************************************************/ @@ -235,13 +251,14 @@ gl_wdgt_line_set_params (glWdgtLine *line, gdouble width, guint color) { + GdkColor *gdk_color; + gtk_spin_button_set_value (GTK_SPIN_BUTTON (line->width_spin), width); - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (line->color_picker), - GL_COLOR_I_RED (color), - GL_COLOR_I_GREEN (color), - GL_COLOR_I_BLUE (color), - GL_COLOR_I_ALPHA (color)); + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(line->color_picker), gdk_color); + g_free (gdk_color); + } /****************************************************************************/ diff --git a/glabels2/src/wdgt-text-props.c b/glabels2/src/wdgt-text-props.c index b261687a..15b867fd 100644 --- a/glabels2/src/wdgt-text-props.c +++ b/glabels2/src/wdgt-text-props.c @@ -24,6 +24,8 @@ #include +#include "mygal/widget-color-combo.h" +#include "prefs.h" #include "wdgt-text-props.h" #include "marshal.h" #include "color.h" @@ -167,9 +169,11 @@ gl_wdgt_text_props_new (void) static void gl_wdgt_text_props_construct (glWdgtTextProps *text) { - GtkWidget *wvbox, *whbox, *wcombo, *wbhbox; - GList *family_names = NULL; - GtkObject *adjust; + GtkWidget *wvbox, *whbox, *wcombo, *wbhbox; + GList *family_names = NULL; + GtkObject *adjust; + ColorGroup *cg; + GdkColor *gdk_color; wvbox = GTK_WIDGET (text); @@ -232,8 +236,13 @@ gl_wdgt_text_props_construct (glWdgtTextProps *text) gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_label); /* Text Color picker widget */ - text->color_picker = gnome_color_picker_new (); - g_signal_connect_swapped (G_OBJECT (text->color_picker), "color_set", + cg = color_group_fetch ("text_color_group", NULL); + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + text->color_picker = color_combo_new (NULL, _("Default"), gdk_color, cg); + color_combo_box_set_preview_relief (COLOR_COMBO(text->color_picker), + GTK_RELIEF_NORMAL); + g_free (gdk_color); + g_signal_connect_swapped (G_OBJECT (text->color_picker), "color_changed", G_CALLBACK (changed_cb), G_OBJECT (text)); gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_picker); @@ -356,7 +365,8 @@ gl_wdgt_text_props_get_params (glWdgtTextProps *text, guint *color, GtkJustification *just) { - guint8 r, g, b, a; + GdkColor *gdk_color; + gboolean is_default; /* ------ Get updated font information ------ */ *font_family = @@ -375,9 +385,14 @@ gl_wdgt_text_props_get_params (glWdgtTextProps *text, (text->font_i_button)); /* ------ Get updated color ------ */ - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (text->color_picker), - &r, &g, &b, &a); - *color = GL_COLOR_A (r, g, b, a); + gdk_color = color_combo_get_color (COLOR_COMBO(text->color_picker), + &is_default); + + if (is_default) { + *color = gl_prefs->default_text_color; + } else { + *color = gl_color_from_gdk_color (gdk_color); + } /* ------- Get updated justification ------ */ if (gtk_toggle_button_get_active @@ -409,8 +424,9 @@ gl_wdgt_text_props_set_params (glWdgtTextProps *text, guint color, GtkJustification just) { - GList *family_names; - gchar *good_font_family; + GList *family_names; + gchar *good_font_family; + GdkColor *gdk_color; /* Make sure we have a valid font family. if not provide a good default. */ family_names = gnome_font_family_list (); @@ -437,11 +453,9 @@ gl_wdgt_text_props_set_params (glWdgtTextProps *text, gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->font_i_button), font_italic_flag); - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (text->color_picker), - GL_COLOR_I_RED (color), - GL_COLOR_I_GREEN (color), - GL_COLOR_I_BLUE (color), - GL_COLOR_I_ALPHA (color)); + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(text->color_picker), gdk_color); + g_free (gdk_color); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->left_button), (just == GTK_JUSTIFY_LEFT)); -- 2.39.5