From 1d2976f934a80c41cffd87220793d8a88a51965d Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Sun, 18 Apr 2004 23:48:30 +0000 Subject: [PATCH] app/widgets/gimppropwidgets.[ch] replaced 2004-04-19 Sven Neumann * app/widgets/gimppropwidgets.[ch] * app/gui/preferences-dialog.c: replaced gimp_prop_boolean_option_menu_new() with gimp_prop_boolean_combo_box_new(). --- ChangeLog | 7 ++ app/dialogs/preferences-dialog.c | 38 ++++---- app/gui/preferences-dialog.c | 38 ++++---- app/widgets/gimppropwidgets.c | 152 ++++++++++++++++++++----------- app/widgets/gimppropwidgets.h | 2 +- libgimpwidgets/gimppropwidgets.c | 152 ++++++++++++++++++++----------- libgimpwidgets/gimppropwidgets.h | 2 +- 7 files changed, 243 insertions(+), 148 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c2f0e6c67..7180842ba7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-04-19 Sven Neumann + + * app/widgets/gimppropwidgets.[ch] + * app/gui/preferences-dialog.c: replaced + gimp_prop_boolean_option_menu_new() with + gimp_prop_boolean_combo_box_new(). + 2004-04-19 Sven Neumann * app/widgets/gimpenumstore.[ch]: avoid unnecessary casts. diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 824a637caf..c24d25b1ad 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -805,18 +805,18 @@ prefs_enum_combo_box_add (GObject *config, } static GtkWidget * -prefs_boolean_option_menu_add (GObject *config, - const gchar *property_name, - const gchar *true_text, - const gchar *false_text, - const gchar *label, - GtkTable *table, - gint table_row) +prefs_boolean_combo_box_add (GObject *config, + const gchar *property_name, + const gchar *true_text, + const gchar *false_text, + const gchar *label, + GtkTable *table, + gint table_row) { GtkWidget *menu; - menu = gimp_prop_boolean_option_menu_new (config, property_name, - true_text, false_text); + menu = gimp_prop_boolean_combo_box_new (config, property_name, + true_text, false_text); if (menu) gimp_table_attach_aligned (table, 0, table_row, @@ -1506,11 +1506,11 @@ prefs_dialog_new (Gimp *gimp, table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); - prefs_boolean_option_menu_add (object, "initial-zoom-to-fit", - _("Fit to Window"), - "1:1", - _("Inital Zoom Ratio:"), - GTK_TABLE (table), 0); + prefs_boolean_combo_box_add (object, "initial-zoom-to-fit", + _("Fit to Window"), + "1:1", + _("Inital Zoom Ratio:"), + GTK_TABLE (table), 0); /* Pointer Movement Feedback */ vbox2 = prefs_frame_new (_("Pointer Movement Feedback"), @@ -1931,11 +1931,11 @@ prefs_dialog_new (Gimp *gimp, table = prefs_table_new (2, GTK_CONTAINER (vbox2), TRUE); - prefs_boolean_option_menu_add (object, "trust-dirty-flag", - _("Only when Modified"), - _("Always"), - _("\"File -> Save\" Saves the Image:"), - GTK_TABLE (table), 0); + prefs_boolean_combo_box_add (object, "trust-dirty-flag", + _("Only when Modified"), + _("Always"), + _("\"File -> Save\" Saves the Image:"), + GTK_TABLE (table), 0); prefs_enum_combo_box_add (object, "thumbnail-size", 0, 0, _("Size of Thumbnail Files:"), GTK_TABLE (table), 1); diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index 824a637caf..c24d25b1ad 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -805,18 +805,18 @@ prefs_enum_combo_box_add (GObject *config, } static GtkWidget * -prefs_boolean_option_menu_add (GObject *config, - const gchar *property_name, - const gchar *true_text, - const gchar *false_text, - const gchar *label, - GtkTable *table, - gint table_row) +prefs_boolean_combo_box_add (GObject *config, + const gchar *property_name, + const gchar *true_text, + const gchar *false_text, + const gchar *label, + GtkTable *table, + gint table_row) { GtkWidget *menu; - menu = gimp_prop_boolean_option_menu_new (config, property_name, - true_text, false_text); + menu = gimp_prop_boolean_combo_box_new (config, property_name, + true_text, false_text); if (menu) gimp_table_attach_aligned (table, 0, table_row, @@ -1506,11 +1506,11 @@ prefs_dialog_new (Gimp *gimp, table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE); - prefs_boolean_option_menu_add (object, "initial-zoom-to-fit", - _("Fit to Window"), - "1:1", - _("Inital Zoom Ratio:"), - GTK_TABLE (table), 0); + prefs_boolean_combo_box_add (object, "initial-zoom-to-fit", + _("Fit to Window"), + "1:1", + _("Inital Zoom Ratio:"), + GTK_TABLE (table), 0); /* Pointer Movement Feedback */ vbox2 = prefs_frame_new (_("Pointer Movement Feedback"), @@ -1931,11 +1931,11 @@ prefs_dialog_new (Gimp *gimp, table = prefs_table_new (2, GTK_CONTAINER (vbox2), TRUE); - prefs_boolean_option_menu_add (object, "trust-dirty-flag", - _("Only when Modified"), - _("Always"), - _("\"File -> Save\" Saves the Image:"), - GTK_TABLE (table), 0); + prefs_boolean_combo_box_add (object, "trust-dirty-flag", + _("Only when Modified"), + _("Always"), + _("\"File -> Save\" Saves the Image:"), + GTK_TABLE (table), 0); prefs_enum_combo_box_add (object, "thumbnail-size", 0, 0, _("Size of Thumbnail Files:"), GTK_TABLE (table), 1); diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c index ed332b99c7..5c6817f8e2 100644 --- a/app/widgets/gimppropwidgets.c +++ b/app/widgets/gimppropwidgets.c @@ -380,15 +380,98 @@ gimp_prop_enum_combo_box_notify (GObject *config, } -/******************/ -/* option menus */ -/******************/ +/************************/ +/* boolean combo box */ +/************************/ -static void gimp_prop_option_menu_callback (GtkWidget *widget, - GObject *config); -static void gimp_prop_option_menu_notify (GObject *config, - GParamSpec *param_spec, - GtkWidget *menu); +static void gimp_prop_boolean_combo_box_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_boolean_combo_box_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *widget); + + +GtkWidget * +gimp_prop_boolean_combo_box_new (GObject *config, + const gchar *property_name, + const gchar *true_text, + const gchar *false_text) +{ + GParamSpec *param_spec; + GtkWidget *combo_box; + gboolean value; + + param_spec = check_param_spec (config, property_name, + G_TYPE_PARAM_BOOLEAN, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &value, + NULL); + + combo_box = gtk_combo_box_new_text (); + + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), true_text); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), false_text); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), value ? 0 : 1); + + g_signal_connect (combo_box, "changed", + G_CALLBACK (gimp_prop_boolean_combo_box_callback), + config); + + set_param_spec (G_OBJECT (combo_box), combo_box, param_spec); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_boolean_combo_box_notify), + combo_box); + + return combo_box; +} + +static void +gimp_prop_boolean_combo_box_callback (GtkWidget *widget, + GObject *config) +{ + GParamSpec *param_spec; + gint value; + + param_spec = get_param_spec (G_OBJECT (widget)); + if (! param_spec) + return; + + value = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); + + g_object_set (config, + param_spec->name, value ? FALSE : TRUE, + NULL); +} + +static void +gimp_prop_boolean_combo_box_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *combo_box) +{ + gint value; + + g_object_get (config, + param_spec->name, &value, + NULL); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), value ? 0 : 1); +} + + +/****************/ +/* paint menu */ +/****************/ + +static void gimp_prop_paint_menu_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_paint_menu_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *menu); GtkWidget * gimp_prop_paint_mode_menu_new (GObject *config, @@ -408,7 +491,7 @@ gimp_prop_paint_mode_menu_new (GObject *config, property_name, &value, NULL); - menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback), + menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_paint_menu_callback), config, with_behind_mode, value); @@ -416,54 +499,15 @@ gimp_prop_paint_mode_menu_new (GObject *config, set_param_spec (G_OBJECT (menu), menu, param_spec); connect_notify (config, property_name, - G_CALLBACK (gimp_prop_option_menu_notify), - menu); - - return menu; -} - - -GtkWidget * -gimp_prop_boolean_option_menu_new (GObject *config, - const gchar *property_name, - const gchar *true_text, - const gchar *false_text) -{ - GParamSpec *param_spec; - GtkWidget *menu; - gboolean value; - - param_spec = check_param_spec (config, property_name, - G_TYPE_PARAM_BOOLEAN, G_STRLOC); - if (! param_spec) - return NULL; - - g_object_get (config, - property_name, &value, - NULL); - - menu = - gimp_int_option_menu_new (FALSE, - G_CALLBACK (gimp_prop_option_menu_callback), - config, value, - - true_text, TRUE, NULL, - false_text, FALSE, NULL, - - NULL); - - set_param_spec (G_OBJECT (menu), menu, param_spec); - - connect_notify (config, property_name, - G_CALLBACK (gimp_prop_option_menu_notify), + G_CALLBACK (gimp_prop_paint_menu_notify), menu); return menu; } static void -gimp_prop_option_menu_callback (GtkWidget *widget, - GObject *config) +gimp_prop_paint_menu_callback (GtkWidget *widget, + GObject *config) { if (GTK_IS_MENU (widget->parent)) { @@ -491,9 +535,9 @@ gimp_prop_option_menu_callback (GtkWidget *widget, } static void -gimp_prop_option_menu_notify (GObject *config, - GParamSpec *param_spec, - GtkWidget *menu) +gimp_prop_paint_menu_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *menu) { gint value; diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h index feb919034c..f4299fc3ee 100644 --- a/app/widgets/gimppropwidgets.h +++ b/app/widgets/gimppropwidgets.h @@ -28,7 +28,7 @@ GtkWidget * gimp_prop_check_button_new (GObject *config, const gchar *property_name, const gchar *label); -GtkWidget * gimp_prop_boolean_option_menu_new (GObject *config, +GtkWidget * gimp_prop_boolean_combo_box_new (GObject *config, const gchar *property_name, const gchar *true_text, const gchar *false_text); diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c index ed332b99c7..5c6817f8e2 100644 --- a/libgimpwidgets/gimppropwidgets.c +++ b/libgimpwidgets/gimppropwidgets.c @@ -380,15 +380,98 @@ gimp_prop_enum_combo_box_notify (GObject *config, } -/******************/ -/* option menus */ -/******************/ +/************************/ +/* boolean combo box */ +/************************/ -static void gimp_prop_option_menu_callback (GtkWidget *widget, - GObject *config); -static void gimp_prop_option_menu_notify (GObject *config, - GParamSpec *param_spec, - GtkWidget *menu); +static void gimp_prop_boolean_combo_box_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_boolean_combo_box_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *widget); + + +GtkWidget * +gimp_prop_boolean_combo_box_new (GObject *config, + const gchar *property_name, + const gchar *true_text, + const gchar *false_text) +{ + GParamSpec *param_spec; + GtkWidget *combo_box; + gboolean value; + + param_spec = check_param_spec (config, property_name, + G_TYPE_PARAM_BOOLEAN, G_STRLOC); + if (! param_spec) + return NULL; + + g_object_get (config, + property_name, &value, + NULL); + + combo_box = gtk_combo_box_new_text (); + + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), true_text); + gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), false_text); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), value ? 0 : 1); + + g_signal_connect (combo_box, "changed", + G_CALLBACK (gimp_prop_boolean_combo_box_callback), + config); + + set_param_spec (G_OBJECT (combo_box), combo_box, param_spec); + + connect_notify (config, property_name, + G_CALLBACK (gimp_prop_boolean_combo_box_notify), + combo_box); + + return combo_box; +} + +static void +gimp_prop_boolean_combo_box_callback (GtkWidget *widget, + GObject *config) +{ + GParamSpec *param_spec; + gint value; + + param_spec = get_param_spec (G_OBJECT (widget)); + if (! param_spec) + return; + + value = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); + + g_object_set (config, + param_spec->name, value ? FALSE : TRUE, + NULL); +} + +static void +gimp_prop_boolean_combo_box_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *combo_box) +{ + gint value; + + g_object_get (config, + param_spec->name, &value, + NULL); + + gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), value ? 0 : 1); +} + + +/****************/ +/* paint menu */ +/****************/ + +static void gimp_prop_paint_menu_callback (GtkWidget *widget, + GObject *config); +static void gimp_prop_paint_menu_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *menu); GtkWidget * gimp_prop_paint_mode_menu_new (GObject *config, @@ -408,7 +491,7 @@ gimp_prop_paint_mode_menu_new (GObject *config, property_name, &value, NULL); - menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_option_menu_callback), + menu = gimp_paint_mode_menu_new (G_CALLBACK (gimp_prop_paint_menu_callback), config, with_behind_mode, value); @@ -416,54 +499,15 @@ gimp_prop_paint_mode_menu_new (GObject *config, set_param_spec (G_OBJECT (menu), menu, param_spec); connect_notify (config, property_name, - G_CALLBACK (gimp_prop_option_menu_notify), - menu); - - return menu; -} - - -GtkWidget * -gimp_prop_boolean_option_menu_new (GObject *config, - const gchar *property_name, - const gchar *true_text, - const gchar *false_text) -{ - GParamSpec *param_spec; - GtkWidget *menu; - gboolean value; - - param_spec = check_param_spec (config, property_name, - G_TYPE_PARAM_BOOLEAN, G_STRLOC); - if (! param_spec) - return NULL; - - g_object_get (config, - property_name, &value, - NULL); - - menu = - gimp_int_option_menu_new (FALSE, - G_CALLBACK (gimp_prop_option_menu_callback), - config, value, - - true_text, TRUE, NULL, - false_text, FALSE, NULL, - - NULL); - - set_param_spec (G_OBJECT (menu), menu, param_spec); - - connect_notify (config, property_name, - G_CALLBACK (gimp_prop_option_menu_notify), + G_CALLBACK (gimp_prop_paint_menu_notify), menu); return menu; } static void -gimp_prop_option_menu_callback (GtkWidget *widget, - GObject *config) +gimp_prop_paint_menu_callback (GtkWidget *widget, + GObject *config) { if (GTK_IS_MENU (widget->parent)) { @@ -491,9 +535,9 @@ gimp_prop_option_menu_callback (GtkWidget *widget, } static void -gimp_prop_option_menu_notify (GObject *config, - GParamSpec *param_spec, - GtkWidget *menu) +gimp_prop_paint_menu_notify (GObject *config, + GParamSpec *param_spec, + GtkWidget *menu) { gint value; diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h index feb919034c..f4299fc3ee 100644 --- a/libgimpwidgets/gimppropwidgets.h +++ b/libgimpwidgets/gimppropwidgets.h @@ -28,7 +28,7 @@ GtkWidget * gimp_prop_check_button_new (GObject *config, const gchar *property_name, const gchar *label); -GtkWidget * gimp_prop_boolean_option_menu_new (GObject *config, +GtkWidget * gimp_prop_boolean_combo_box_new (GObject *config, const gchar *property_name, const gchar *true_text, const gchar *false_text);