diff --git a/ChangeLog b/ChangeLog index 2207193b6e..ef726f1a13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2004-04-21 Sven Neumann + + * libgimp/gimpdrawablecombobox.c + * libgimp/gimpimagecombobox.c + * libgimp/gimpmenu.c: changed the label for the empty menu from + "None" to "Empty" since that's what GTK+ uses. + + * libgimpwidgets/gimpintcombobox.[ch]: added convenience function + gimp_int_combo_box_connect(). + + * plug-ins/common/bumpmap.c + * plug-ins/common/compose.c + * plug-ins/common/depthmerge.c + * plug-ins/common/displace.c + * plug-ins/common/lic.c + * plug-ins/common/warp.c: ported to GimpDrawableComboBox. + + * plug-ins/Lighting/lighting_ui.c + * plug-ins/MapObject/mapobject_ui.c + * plug-ins/common/sample_colorize.c: use + gimp_int_combo_box_connect(). This restores the correct behaviour + of setting the drawable_ID to the first drawable from the list if + it's invalid. + 2004-04-21 Michael Natterer * app/widgets/Makefile.am diff --git a/devel-docs/ChangeLog b/devel-docs/ChangeLog index dffd2bff5c..d8cacb1f11 100644 --- a/devel-docs/ChangeLog +++ b/devel-docs/ChangeLog @@ -1,3 +1,8 @@ +2004-04-21 Sven Neumann + + * libgimpwidgets/libgimpwidgets-sections.txt + * libgimpwidgets/tmpl/gimpintcombobox.sgml: updated. + 2004-04-21 Sven Neumann * libgimp/libgimp-docs.sgml diff --git a/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt b/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt index a6eafd38ff..bdccb6338a 100644 --- a/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt +++ b/devel-docs/libgimpwidgets/libgimpwidgets-sections.txt @@ -189,6 +189,7 @@ gimp_int_combo_box_prepend gimp_int_combo_box_append gimp_int_combo_box_set_active gimp_int_combo_box_get_active +gimp_int_combo_box_connect GimpIntComboBoxClass GIMP_INT_COMBO_BOX diff --git a/devel-docs/libgimpwidgets/tmpl/gimpintcombobox.sgml b/devel-docs/libgimpwidgets/tmpl/gimpintcombobox.sgml index 7e64dcaa93..e4457bbda8 100644 --- a/devel-docs/libgimpwidgets/tmpl/gimpintcombobox.sgml +++ b/devel-docs/libgimpwidgets/tmpl/gimpintcombobox.sgml @@ -90,3 +90,15 @@ GimpIntComboBox @Returns: + + + + + +@combo_box: +@value: +@callback: +@data: +@Returns: + + diff --git a/libgimp/gimpdrawablecombobox.c b/libgimp/gimpdrawablecombobox.c index e73e234cc4..40153793b4 100644 --- a/libgimp/gimpdrawablecombobox.c +++ b/libgimp/gimpdrawablecombobox.c @@ -37,13 +37,13 @@ #define MENU_THUMBNAIL_SIZE 24 -static gint gimp_drawable_combo_box_model_add (GtkListStore *store, - gint32 image, - gint num_drawables, - gint32 *drawables, - GimpDrawableConstraintFunc constraint, - gpointer data); -static void gimp_drawable_combo_box_model_add_none (GtkListStore *store); +static gint gimp_drawable_combo_box_model_add (GtkListStore *store, + gint32 image, + gint num_drawables, + gint32 *drawables, + GimpDrawableConstraintFunc constraint, + gpointer data); +static void gimp_drawable_combo_box_model_add_empty (GtkListStore *store); /** @@ -105,7 +105,7 @@ gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -159,7 +159,7 @@ gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -213,7 +213,7 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -273,13 +273,13 @@ gimp_drawable_combo_box_model_add (GtkListStore *store, } static void -gimp_drawable_combo_box_model_add_none (GtkListStore *store) +gimp_drawable_combo_box_model_add_empty (GtkListStore *store) { GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, GIMP_INT_STORE_VALUE, -1, - GIMP_INT_STORE_LABEL, _("(None)"), + GIMP_INT_STORE_LABEL, _("(Empty)"), -1); } diff --git a/libgimp/gimpimagecombobox.c b/libgimp/gimpimagecombobox.c index 05ca5c70c6..d6ea66ecf6 100644 --- a/libgimp/gimpimagecombobox.c +++ b/libgimp/gimpimagecombobox.c @@ -37,12 +37,12 @@ #define MENU_THUMBNAIL_SIZE 24 -static void gimp_image_combo_box_model_add (GtkListStore *store, - gint num_images, - gint32 *images, - GimpImageConstraintFunc constraint, - gpointer data); -static void gimp_image_combo_box_model_add_none (GtkListStore *store); +static void gimp_image_combo_box_model_add (GtkListStore *store, + gint num_images, + gint32 *images, + GimpImageConstraintFunc constraint, + gpointer data); +static void gimp_image_combo_box_model_add_empty (GtkListStore *store); /** @@ -84,7 +84,7 @@ gimp_image_combo_box_new (GimpImageConstraintFunc constraint, num_images, images, constraint, data); else - gimp_image_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_image_combo_box_model_add_empty (GTK_LIST_STORE (model)); g_free (images); @@ -137,13 +137,13 @@ gimp_image_combo_box_model_add (GtkListStore *store, } static void -gimp_image_combo_box_model_add_none (GtkListStore *store) +gimp_image_combo_box_model_add_empty (GtkListStore *store) { GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, GIMP_INT_STORE_VALUE, -1, - GIMP_INT_STORE_LABEL, _("(None)"), + GIMP_INT_STORE_LABEL, _("(Empty)"), -1); } diff --git a/libgimp/gimpitemcombobox.c b/libgimp/gimpitemcombobox.c index e73e234cc4..40153793b4 100644 --- a/libgimp/gimpitemcombobox.c +++ b/libgimp/gimpitemcombobox.c @@ -37,13 +37,13 @@ #define MENU_THUMBNAIL_SIZE 24 -static gint gimp_drawable_combo_box_model_add (GtkListStore *store, - gint32 image, - gint num_drawables, - gint32 *drawables, - GimpDrawableConstraintFunc constraint, - gpointer data); -static void gimp_drawable_combo_box_model_add_none (GtkListStore *store); +static gint gimp_drawable_combo_box_model_add (GtkListStore *store, + gint32 image, + gint num_drawables, + gint32 *drawables, + GimpDrawableConstraintFunc constraint, + gpointer data); +static void gimp_drawable_combo_box_model_add_empty (GtkListStore *store); /** @@ -105,7 +105,7 @@ gimp_drawable_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -159,7 +159,7 @@ gimp_channel_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -213,7 +213,7 @@ gimp_layer_combo_box_new (GimpDrawableConstraintFunc constraint, g_free (images); if (! added) - gimp_drawable_combo_box_model_add_none (GTK_LIST_STORE (model)); + gimp_drawable_combo_box_model_add_empty (GTK_LIST_STORE (model)); if (gtk_tree_model_get_iter_first (model, &iter)) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter); @@ -273,13 +273,13 @@ gimp_drawable_combo_box_model_add (GtkListStore *store, } static void -gimp_drawable_combo_box_model_add_none (GtkListStore *store) +gimp_drawable_combo_box_model_add_empty (GtkListStore *store) { GtkTreeIter iter; gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, GIMP_INT_STORE_VALUE, -1, - GIMP_INT_STORE_LABEL, _("(None)"), + GIMP_INT_STORE_LABEL, _("(Empty)"), -1); } diff --git a/libgimp/gimpmenu.c b/libgimp/gimpmenu.c index 359bc5c0ec..c115ece949 100644 --- a/libgimp/gimpmenu.c +++ b/libgimp/gimpmenu.c @@ -46,7 +46,7 @@ static GtkWidget * gimp_menu_add_item (GtkWidget *menu, const gchar *image_name, const gchar *drawable_name, gint32 any_ID); -static GtkWidget * gimp_menu_add_none (GtkWidget *menu); +static GtkWidget * gimp_menu_add_empty (GtkWidget *menu); static GtkWidget * gimp_menu_make_preview (gint32 any_ID, gboolean is_image, gint width, @@ -102,7 +102,7 @@ gimp_image_menu_new (GimpConstraintFunc constraint, } if (k == 0) - gimp_menu_add_none (menu); + gimp_menu_add_empty (menu); (* callback) (image, data); @@ -170,7 +170,7 @@ gimp_layer_menu_new (GimpConstraintFunc constraint, g_free (images); if (k == 0) - gimp_menu_add_none (menu); + gimp_menu_add_empty (menu); (* callback) (layer, data); @@ -238,7 +238,7 @@ gimp_channel_menu_new (GimpConstraintFunc constraint, g_free (images); if (k == 0) - gimp_menu_add_none (menu); + gimp_menu_add_empty (menu); (* callback) (channel, data); @@ -327,7 +327,7 @@ gimp_drawable_menu_new (GimpConstraintFunc constraint, g_free (images); if (k == 0) - gimp_menu_add_none (menu); + gimp_menu_add_empty (menu); (* callback) (drawable, data); @@ -400,11 +400,11 @@ gimp_menu_add_item (GtkWidget *menu, } static GtkWidget * -gimp_menu_add_none (GtkWidget *menu) +gimp_menu_add_empty (GtkWidget *menu) { GtkWidget *menuitem; - menuitem = gtk_menu_item_new_with_label (_("(None)")); + menuitem = gtk_menu_item_new_with_label (_("(Empty)")); gtk_widget_set_sensitive (menuitem, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_widget_show (menuitem); diff --git a/libgimpwidgets/gimpintcombobox.c b/libgimpwidgets/gimpintcombobox.c index 359ef38ec8..b1f5ef53d0 100644 --- a/libgimpwidgets/gimpintcombobox.c +++ b/libgimpwidgets/gimpintcombobox.c @@ -349,3 +349,43 @@ gimp_int_combo_box_get_active (GimpIntComboBox *combo_box, return FALSE; } + +/** + * gimp_int_combo_box_connect: + * @combo_box: a #GimpIntComboBox + * @value: the value to set + * @callback: a callback to connect to the @combo_box's "changed" signal + * @data: a pointer passed as data to g_signal_connect() + * + * A convenience function that sets the inital @value of a + * #GimpIntComboBox and connects @callback to the "changed" + * signal. + * + * This function also calls the @callback once after setting the + * initial @value. This is often convenient when working with combo + * boxes that select a default active item (like for example + * gimp_drawable_combo_box_new). If you pass an invalid initial + * @value, the @callback will be called with the default item active. + * + * Return value: the signal handler ID as returned by g_signal_connect() + * + * Since: GIMP 2.2 + **/ +gulong +gimp_int_combo_box_connect (GimpIntComboBox *combo_box, + gint value, + GCallback callback, + gpointer data) +{ + gulong handler = 0; + + g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), 0); + + if (callback) + handler = g_signal_connect (combo_box, "changed", callback, data); + + if (! gimp_int_combo_box_set_active (combo_box, value)) + g_signal_emit_by_name (combo_box, "changed", NULL); + + return handler; +} diff --git a/libgimpwidgets/gimpintcombobox.h b/libgimpwidgets/gimpintcombobox.h index a65e792025..d46acd16de 100644 --- a/libgimpwidgets/gimpintcombobox.h +++ b/libgimpwidgets/gimpintcombobox.h @@ -71,6 +71,11 @@ gboolean gimp_int_combo_box_set_active (GimpIntComboBox *combo_box, gboolean gimp_int_combo_box_get_active (GimpIntComboBox *combo_box, gint *value); +gulong gimp_int_combo_box_connect (GimpIntComboBox *combo_box, + gint value, + GCallback callback, + gpointer data); + G_END_DECLS diff --git a/plug-ins/Lighting/lighting_ui.c b/plug-ins/Lighting/lighting_ui.c index e1c29c951d..1ca842d11e 100644 --- a/plug-ins/Lighting/lighting_ui.c +++ b/plug-ins/Lighting/lighting_ui.c @@ -898,12 +898,9 @@ create_bump_page (void) g_object_set_data (G_OBJECT (toggle), "set_sensitive", table); combo = gimp_drawable_combo_box_new (bumpmap_constrain, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), - mapvals.bumpmap_id); - - g_signal_connect (combo, "changed", - G_CALLBACK (gimp_int_combo_box_get_active), - &mapvals.bumpmap_id); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.bumpmap_id, + G_CALLBACK (gimp_int_combo_box_get_active), + &mapvals.bumpmap_id); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Bumpm_ap Image:"), 1.0, 0.5, @@ -989,12 +986,9 @@ create_environment_page (void) g_object_set_data (G_OBJECT (toggle), "set_sensitive", table); combo = gimp_drawable_combo_box_new (envmap_constrain, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), - mapvals.envmap_id); - - g_signal_connect (combo, "changed", - G_CALLBACK (envmap_combo_callback), - NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.envmap_id, + G_CALLBACK (envmap_combo_callback), + NULL); gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("En_vironment Image:"), 1.0, 0.5, diff --git a/plug-ins/MapObject/mapobject_ui.c b/plug-ins/MapObject/mapobject_ui.c index 2e30d0347a..1485d75dbb 100644 --- a/plug-ins/MapObject/mapobject_ui.c +++ b/plug-ins/MapObject/mapobject_ui.c @@ -1136,12 +1136,10 @@ create_box_page (void) GtkWidget *combo; combo = gimp_drawable_combo_box_new (box_constrain, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), - mapvals.boxmap_id[i]); - - g_signal_connect (combo, "changed", - G_CALLBACK (gimp_int_combo_box_get_active), - &mapvals.boxmap_id[i]); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), + mapvals.boxmap_id[i], + G_CALLBACK (gimp_int_combo_box_get_active), + &mapvals.boxmap_id[i]); gimp_table_attach_aligned (GTK_TABLE (table), 0, i, gettext (labels[i]), 1.0, 0.5, @@ -1229,12 +1227,10 @@ create_cylinder_page (void) GtkWidget *combo; combo = gimp_drawable_combo_box_new (cylinder_constrain, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), - mapvals.cylindermap_id[i]); - - g_signal_connect (combo, "changed", - G_CALLBACK (gimp_int_combo_box_get_active), - &mapvals.cylindermap_id[i]); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), + mapvals.cylindermap_id[i], + G_CALLBACK (gimp_int_combo_box_get_active), + &mapvals.cylindermap_id[i]); gimp_table_attach_aligned (GTK_TABLE (table), 0, i, gettext (labels[i]), 1.0, 0.5, diff --git a/plug-ins/common/bumpmap.c b/plug-ins/common/bumpmap.c index 7762882805..c1c18b66be 100644 --- a/plug-ins/common/bumpmap.c +++ b/plug-ins/common/bumpmap.c @@ -257,7 +257,7 @@ static void dialog_tiled_callback (GtkWidget *widget, gpointer data); static void dialog_map_type_callback (GtkWidget *widget, gpointer data); static gint dialog_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -static void dialog_bumpmap_callback (gint32 id, gpointer data); +static void dialog_bumpmap_callback (GtkWidget *widget, gpointer data); static void dialog_dscale_update (GtkAdjustment *adjustment, gdouble *value); static void dialog_iscale_update_normal (GtkAdjustment *adjustment, gint *value); @@ -862,8 +862,7 @@ bumpmap_dialog (void) GtkWidget *scrollbar; GtkWidget *table; GtkWidget *right_vbox; - GtkWidget *option_menu; - GtkWidget *menu; + GtkWidget *combo; GtkWidget *button; GtkObject *adj; gint i; @@ -1023,15 +1022,13 @@ bumpmap_dialog (void) gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - option_menu = gtk_option_menu_new (); - menu = gimp_drawable_menu_new (dialog_constrain, - dialog_bumpmap_callback, - NULL, - bmvals.bumpmap_id); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); + combo = gimp_drawable_combo_box_new (dialog_constrain, NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), bmvals.bumpmap_id, + G_CALLBACK (dialog_bumpmap_callback), + NULL); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("_Bump Map:"), 1.0, 0.5, - option_menu, 2, TRUE); + _("_Bump Map:"), 1.0, 0.5, combo, 2, TRUE); sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); @@ -1782,31 +1779,33 @@ dialog_map_type_callback (GtkWidget *widget, } } -static gint +static gboolean dialog_constrain (gint32 image_id, gint32 drawable_id, gpointer data) { - if (drawable_id == -1) - return TRUE; - return (gimp_drawable_is_rgb (drawable_id) || gimp_drawable_is_gray (drawable_id)); } static void -dialog_bumpmap_callback (gint32 id, - gpointer data) +dialog_bumpmap_callback (GtkWidget *widget, + gpointer data) { - if (bmvals.bumpmap_id == id) + gint value; + + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value); + + if (bmvals.bumpmap_id == value) { dialog_new_bumpmap (FALSE); } else { - bmvals.bumpmap_id = id; + bmvals.bumpmap_id = value; dialog_new_bumpmap (TRUE); } + dialog_update_preview (); } diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c index 7099da0a00..6f4247a464 100644 --- a/plug-ins/common/compose.c +++ b/plug-ins/common/compose.c @@ -51,9 +51,9 @@ static void run (const gchar *name, gint *nreturn_vals, GimpParam **return_vals); -static gint32 compose (const gchar *compose_type, - gint32 *compose_ID, - gboolean compose_by_drawable); +static gint32 compose (const gchar *compose_type, + gint32 *compose_ID, + gboolean compose_by_drawable); static gint32 create_new_image (const gchar *filename, guint width, @@ -91,9 +91,6 @@ static gboolean check_gray (gint32 image_id, gint32 drawable_id, gpointer data); -static void image_menu_callback (gint32 id, - gpointer data); - static void compose_type_toggle_update (GtkWidget *widget, gpointer data); @@ -1067,7 +1064,6 @@ compose_dialog (const gchar *compose_type, GtkWidget *label; GtkWidget *table; GtkWidget *image; - GtkWidget *image_option_menu, *image_menu; GSList *group; gint j, compose_idx; gboolean run; @@ -1130,6 +1126,7 @@ compose_dialog (const gchar *compose_type, for (j = 0; j < MAX_COMPOSE_IMAGES; j++) { + GtkWidget *combo; const gchar *text; image = gtk_image_new_from_stock (compose_dsc[compose_idx].channel_icon[j], @@ -1149,17 +1146,18 @@ compose_dialog (const gchar *compose_type, gtk_widget_show (label); composeint.select_ID[j] = drawable_ID; - composeint.channel_menu[j] = image_option_menu = gtk_option_menu_new (); - image_menu = gimp_drawable_menu_new (check_gray, - image_menu_callback, - &(composeint.select_ID[j]), - composeint.select_ID[j]); - gtk_table_attach (GTK_TABLE (table), image_option_menu, 2, 3, j, j+1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (image_option_menu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu), - image_menu); + combo = gimp_drawable_combo_box_new (check_gray, NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), + composeint.select_ID[j], + G_CALLBACK (gimp_int_combo_box_get_active), + &composeint.select_ID[j]); + + gtk_table_attach (GTK_TABLE (table), combo, 2, 3, j, j+1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (combo); + + composeint.channel_menu[j] = combo; } /* Set sensitivity of last menu */ @@ -1224,19 +1222,10 @@ check_gray (gint32 image_id, { return ((gimp_image_base_type (image_id) == GIMP_GRAY) && - (gimp_image_width (image_id) == composeint.width) && + (gimp_image_width (image_id) == composeint.width) && (gimp_image_height (image_id) == composeint.height)); } - -static void -image_menu_callback (gint32 id, - gpointer data) -{ - *(gint32 *) data = id; -} - - static void compose_type_toggle_update (GtkWidget *widget, gpointer data) diff --git a/plug-ins/common/depthmerge.c b/plug-ins/common/depthmerge.c index 3f58bf76d6..c45d03e485 100644 --- a/plug-ins/common/depthmerge.c +++ b/plug-ins/common/depthmerge.c @@ -95,11 +95,11 @@ typedef struct _DepthMerge DepthMergeInterface *interface; DepthMergeParams params; - GimpDrawable *resultDrawable; - GimpDrawable *source1Drawable; - GimpDrawable *source2Drawable; - GimpDrawable *depthMap1Drawable; - GimpDrawable *depthMap2Drawable; + GimpDrawable *resultDrawable; + GimpDrawable *source1Drawable; + GimpDrawable *source2Drawable; + GimpDrawable *depthMap1Drawable; + GimpDrawable *depthMap2Drawable; gint selectionX0; gint selectionY0; gint selectionX1; @@ -119,21 +119,21 @@ void DepthMerge_executeRegion (DepthMerge *dm, guchar *depthMap1Row, guchar *depthMap2Row, guchar *resultRow, - gint length); + gint length); gint32 DepthMerge_dialog (DepthMerge *dm); void DepthMerge_buildPreviewSourceImage(DepthMerge *dm); void DepthMerge_updatePreview (DepthMerge *dm); -gint constraintResultSizeAndResultColorOrGray(gint32 imageId, - gint32 drawableId, gpointer data); -gint constraintResultSizeAndGray(gint32 imageId, - gint32 drawableId, gpointer data); +static gboolean dm_constraint (gint32 imageId, + gint32 drawableId, + gpointer data); + +static void dialogSource1ChangedCallback (GtkWidget *widget, DepthMerge *dm); +static void dialogSource2ChangedCallback (GtkWidget *widget, DepthMerge *dm); +static void dialogDepthMap1ChangedCallback (GtkWidget *widget, DepthMerge *dm); +static void dialogDepthMap2ChangedCallback (GtkWidget *widget, DepthMerge *dm); -void dialogSource1ChangedCallback (gint32 id, gpointer data); -void dialogSource2ChangedCallback (gint32 id, gpointer data); -void dialogDepthMap1ChangedCallback (gint32 id, gpointer data); -void dialogDepthMap2ChangedCallback (gint32 id, gpointer data); void dialogValueScaleUpdateCallback (GtkAdjustment *adjustment, gpointer data); void dialogValueEntryUpdateCallback (GtkWidget *widget, gpointer data); @@ -624,9 +624,8 @@ DepthMerge_dialog (DepthMerge *dm) GtkWidget *topTable; GtkWidget *previewFrame; GtkWidget *sourceTable; - GtkWidget *tempLabel; - GtkWidget *tempOptionMenu; - GtkWidget *tempMenu; + GtkWidget *label; + GtkWidget *combo; GtkWidget *numericParameterTable; GtkObject *adj; gboolean run; @@ -679,73 +678,65 @@ DepthMerge_dialog (DepthMerge *dm) GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); gtk_widget_show (sourceTable); - tempLabel = gtk_label_new (_("Source 1:")); - gtk_misc_set_alignment (GTK_MISC (tempLabel), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 0, 1, 0, 1, + label = gtk_label_new (_("Source 1:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (sourceTable), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (tempLabel); + gtk_widget_show (label); - tempOptionMenu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 1, 2, 0, 1, + combo = gimp_drawable_combo_box_new (dm_constraint, dm); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.source1, + G_CALLBACK (dialogSource1ChangedCallback), + dm); + + gtk_table_attach (GTK_TABLE (sourceTable), combo, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (tempOptionMenu); - tempMenu = gimp_drawable_menu_new (constraintResultSizeAndResultColorOrGray, - dialogSource1ChangedCallback, - dm, - dm->params.source1); - gtk_option_menu_set_menu (GTK_OPTION_MENU (tempOptionMenu), tempMenu); - gtk_widget_show (tempOptionMenu); + gtk_widget_show (combo); - tempLabel = gtk_label_new(_("Depth Map:")); - gtk_misc_set_alignment(GTK_MISC(tempLabel), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 2, 3, 0, 1, + label = gtk_label_new(_("Depth Map:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (sourceTable), label, 2, 3, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (tempLabel); + gtk_widget_show (label); - tempOptionMenu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 3, 4, 0, 1, + combo = gimp_drawable_combo_box_new (dm_constraint, dm); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.depthMap1, + G_CALLBACK (dialogDepthMap1ChangedCallback), + dm); + + gtk_table_attach (GTK_TABLE (sourceTable), combo, 3, 4, 0, 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (tempOptionMenu); - tempMenu = gimp_drawable_menu_new (constraintResultSizeAndResultColorOrGray, - dialogDepthMap1ChangedCallback, - dm, - dm->params.depthMap1); - gtk_option_menu_set_menu (GTK_OPTION_MENU (tempOptionMenu), tempMenu); - gtk_widget_show (tempOptionMenu); + gtk_widget_show (combo); - tempLabel = gtk_label_new (_("Source 2:")); - gtk_misc_set_alignment (GTK_MISC (tempLabel), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 0, 1, 1, 2, + label = gtk_label_new (_("Source 2:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (sourceTable), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (tempLabel); + gtk_widget_show (label); - tempOptionMenu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 1, 2, 1, 2, + combo = gimp_drawable_combo_box_new (dm_constraint, dm); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.source2, + G_CALLBACK (dialogSource2ChangedCallback), + dm); + + gtk_table_attach (GTK_TABLE (sourceTable), combo, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (tempOptionMenu); - tempMenu = gimp_drawable_menu_new (constraintResultSizeAndResultColorOrGray, - dialogSource2ChangedCallback, - dm, - dm->params.source2); - gtk_option_menu_set_menu (GTK_OPTION_MENU (tempOptionMenu), tempMenu); - gtk_widget_show (tempOptionMenu); + gtk_widget_show (combo); - tempLabel = gtk_label_new (_("Depth Map:")); - gtk_misc_set_alignment(GTK_MISC(tempLabel), 1.0, 0.5); - gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 2, 3, 1, 2, + label = gtk_label_new (_("Depth Map:")); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_table_attach (GTK_TABLE (sourceTable), label, 2, 3, 1, 2, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (tempLabel); + gtk_widget_show (label); - tempOptionMenu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 3, 4, 1, 2, + combo = gimp_drawable_combo_box_new (dm_constraint, dm); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dm->params.depthMap2, + G_CALLBACK (dialogDepthMap2ChangedCallback), + dm); + + gtk_table_attach (GTK_TABLE (sourceTable), combo, 3, 4, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gtk_widget_show (tempOptionMenu); - tempMenu = gimp_drawable_menu_new (constraintResultSizeAndResultColorOrGray, - dialogDepthMap2ChangedCallback, - dm, - dm->params.depthMap2); - gtk_option_menu_set_menu (GTK_OPTION_MENU (tempOptionMenu), tempMenu); - gtk_widget_show (tempOptionMenu); + gtk_widget_show (combo); /* Numeric parameters */ numericParameterTable = gtk_table_new(4, 3, FALSE); @@ -928,10 +919,10 @@ DepthMerge_updatePreview (DepthMerge *dm) /* ----- Callbacks ----- */ -gint -constraintResultSizeAndResultColorOrGray (gint32 imageId, - gint32 drawableId, - gpointer data) +static gboolean +dm_constraint (gint32 imageId, + gint32 drawableId, + gpointer data) { DepthMerge *dm = (DepthMerge *)data; @@ -945,32 +936,19 @@ constraintResultSizeAndResultColorOrGray (gint32 imageId, gimp_drawable_is_gray (drawableId)))); } -gint -constraintResultSizeAndGray (gint32 imageId, - gint32 drawableId, - gpointer data) +static void +dialogSource1ChangedCallback (GtkWidget *widget, + DepthMerge *dm) { - DepthMerge *dm = (DepthMerge *)data; - - return((drawableId == -1) || - ((gimp_drawable_width (drawableId) == - gimp_drawable_width (dm->params.result)) && - (gimp_drawable_height (drawableId) == - gimp_drawable_height (dm->params.result)) && - (gimp_drawable_is_gray (drawableId)))); -} - -void -dialogSource1ChangedCallback (gint32 id, - gpointer data) -{ - DepthMerge *dm = (DepthMerge *)data; - - if (dm->source1Drawable != NULL) + if (dm->source1Drawable) gimp_drawable_detach (dm->source1Drawable); - dm->params.source1 = id; - dm->source1Drawable = (dm->params.source1 == -1) ? NULL : - gimp_drawable_get (dm->params.source1); + + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), + &dm->params.source1); + + dm->source1Drawable = ((dm->params.source1 == -1) ? + NULL : + gimp_drawable_get (dm->params.source1)); util_fillReducedBuffer (dm->interface->previewSource1, dm->interface->previewWidth, @@ -983,17 +961,19 @@ dialogSource1ChangedCallback (gint32 id, DepthMerge_updatePreview (dm); } -void -dialogSource2ChangedCallback (gint32 id, - gpointer data) +static void +dialogSource2ChangedCallback (GtkWidget *widget, + DepthMerge *dm) { - DepthMerge *dm = (DepthMerge *)data; - - if (dm->source2Drawable != NULL) + if (dm->source2Drawable) gimp_drawable_detach (dm->source2Drawable); - dm->params.source2 = id; - dm->source2Drawable = (dm->params.source2 == -1) ? NULL : - gimp_drawable_get (dm->params.source2); + + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), + &dm->params.source2); + + dm->source2Drawable = ((dm->params.source2 == -1) ? + NULL : + gimp_drawable_get (dm->params.source2)); util_fillReducedBuffer (dm->interface->previewSource2, dm->interface->previewWidth, @@ -1006,17 +986,19 @@ dialogSource2ChangedCallback (gint32 id, DepthMerge_updatePreview (dm); } -void -dialogDepthMap1ChangedCallback (gint32 id, - gpointer data) +static void +dialogDepthMap1ChangedCallback (GtkWidget *widget, + DepthMerge *dm) { - DepthMerge *dm = (DepthMerge *)data; + if (dm->depthMap1Drawable) + gimp_drawable_detach (dm->depthMap1Drawable); - if (dm->depthMap1Drawable != NULL) - gimp_drawable_detach(dm->depthMap1Drawable); - dm->params.depthMap1 = id; - dm->depthMap1Drawable = (dm->params.depthMap1 == -1) ? NULL : - gimp_drawable_get (dm->params.depthMap1); + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), + &dm->params.depthMap1); + + dm->depthMap1Drawable = ((dm->params.depthMap1 == -1) ? + NULL : + gimp_drawable_get (dm->params.depthMap1)); util_fillReducedBuffer (dm->interface->previewDepthMap1, dm->interface->previewWidth, @@ -1029,17 +1011,19 @@ dialogDepthMap1ChangedCallback (gint32 id, DepthMerge_updatePreview (dm); } -void -dialogDepthMap2ChangedCallback (gint32 id, - gpointer data) +static void +dialogDepthMap2ChangedCallback (GtkWidget *widget, + DepthMerge *dm) { - DepthMerge *dm = (DepthMerge *)data; + if (dm->depthMap2Drawable) + gimp_drawable_detach (dm->depthMap2Drawable); - if (dm->depthMap2Drawable != NULL) - gimp_drawable_detach(dm->depthMap2Drawable); - dm->params.depthMap2 = id; - dm->depthMap2Drawable = (dm->params.depthMap2 == -1) ? NULL : - gimp_drawable_get (dm->params.depthMap2); + gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), + &dm->params.depthMap2); + + dm->depthMap1Drawable = ((dm->params.depthMap2 == -1) ? + NULL : + gimp_drawable_get (dm->params.depthMap2)); util_fillReducedBuffer (dm->interface->previewDepthMap2, dm->interface->previewWidth, diff --git a/plug-ins/common/displace.c b/plug-ins/common/displace.c index 28272a19bc..c7ebbbbeb2 100644 --- a/plug-ins/common/displace.c +++ b/plug-ins/common/displace.c @@ -86,13 +86,9 @@ static void run (const gchar *name, static void displace (GimpDrawable *drawable); static gint displace_dialog (GimpDrawable *drawable); -static gint displace_map_constrain (gint32 image_id, +static gboolean displace_map_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -static void displace_map_x_callback (gint32 id, - gpointer data); -static void displace_map_y_callback (gint32 id, - gpointer data); static gdouble displace_map_give_value (guchar *ptr, gint alpha, gint bytes); @@ -256,8 +252,7 @@ displace_dialog (GimpDrawable *drawable) GtkWidget *table; GtkWidget *spinbutton; GtkObject *adj; - GtkWidget *option_menu; - GtkWidget *menu; + GtkWidget *combo; GtkWidget *sep; GSList *group = NULL; gboolean run; @@ -310,16 +305,17 @@ displace_dialog (GimpDrawable *drawable) g_object_set_data (G_OBJECT (toggle), "set_sensitive", spinbutton); gtk_widget_show (spinbutton); - option_menu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - menu = gimp_drawable_menu_new (displace_map_constrain, displace_map_x_callback, - drawable, dvals.displace_map_x); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); + combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_x, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.displace_map_x); - gtk_widget_set_sensitive (option_menu, dvals.do_x); - g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", option_menu); - gtk_widget_show (option_menu); + gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (combo); + + gtk_widget_set_sensitive (combo, dvals.do_x); + g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo); /* Y Options */ toggle = gtk_check_button_new_with_mnemonic (_("_Y Displacement:")); @@ -347,16 +343,17 @@ displace_dialog (GimpDrawable *drawable) g_object_set_data (G_OBJECT (toggle), "set_sensitive", spinbutton); gtk_widget_show (spinbutton); - option_menu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - menu = gimp_drawable_menu_new (displace_map_constrain, displace_map_y_callback, - drawable, dvals.displace_map_y); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); + combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_y, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.displace_map_y); - gtk_widget_set_sensitive (option_menu, dvals.do_y); - g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", option_menu); - gtk_widget_show (option_menu); + gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (combo); + + gtk_widget_set_sensitive (combo, dvals.do_y); + g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo); /* Displacement Type */ sep = gtk_hseparator_new (); @@ -644,32 +641,13 @@ displace_map_give_value (guchar *pt, /* Displace interface functions */ -static gint +static gboolean displace_map_constrain (gint32 image_id, gint32 drawable_id, gpointer data) { - GimpDrawable *drawable; + GimpDrawable *drawable = data; - drawable = (GimpDrawable *) data; - - if (drawable_id == -1) - return TRUE; - - return (gimp_drawable_width (drawable_id) == drawable->width && + return (gimp_drawable_width (drawable_id) == drawable->width && gimp_drawable_height (drawable_id) == drawable->height); } - -static void -displace_map_x_callback (gint32 id, - gpointer data) -{ - dvals.displace_map_x = id; -} - -static void -displace_map_y_callback (gint32 id, - gpointer data) -{ - dvals.displace_map_y = id; -} diff --git a/plug-ins/common/lic.c b/plug-ins/common/lic.c index 55939e9c32..fc2bcce58c 100644 --- a/plug-ins/common/lic.c +++ b/plug-ins/common/lic.c @@ -126,9 +126,9 @@ poke (GimpPixelRgn *dest_rgn, } static gint -peekmap (guchar *image, - gint x, - gint y) +peekmap (const guchar *image, + gint x, + gint y) { while (x < 0) x += effect_width; @@ -155,11 +155,11 @@ peekmap (guchar *image, /***************************************************/ static gint -gradx (guchar *image, - gint x, - gint y) +gradx (const guchar *image, + gint x, + gint y) { - gint val=0; + gint val = 0; val = val + peekmap (image, x-1, y-1); val = val - peekmap (image, x+1, y-1); @@ -174,9 +174,9 @@ gradx (guchar *image, } static gint -grady (guchar *image, - gint x, - gint y) +grady (const guchar *image, + gint x, + gint y) { gint val = 0; @@ -414,16 +414,16 @@ static guchar* rgb_to_hsl (GimpDrawable *drawable, LICEffectChannel effect_channel) { - guchar *themap, data[4]; - gint x, y; - GimpRGB color; - GimpHSL color_hsl; - gdouble val; - glong maxc, index = 0; - GimpPixelRgn region; - GRand *gr; + guchar *themap, data[4]; + gint x, y; + GimpRGB color; + GimpHSL color_hsl; + gdouble val = 0.0; + glong maxc, index = 0; + GimpPixelRgn region; + GRand *gr; - gr = g_rand_new(); + gr = g_rand_new (); maxc = drawable->width * drawable->height; @@ -443,17 +443,17 @@ rgb_to_hsl (GimpDrawable *drawable, gimp_rgb_to_hsl (&color, &color_hsl); switch (effect_channel) - { + { case LIC_HUE: - val = color_hsl.h * 255; - break; + val = color_hsl.h * 255; + break; case LIC_SATURATION: - val = color_hsl.s * 255; - break; + val = color_hsl.s * 255; + break; case LIC_BRIGHTNESS: - val = color_hsl.l * 255; - break; - } + val = color_hsl.l * 255; + break; + } /* add some random to avoid unstructured areas. */ val += g_rand_double_range (gr, -1.0, 1.0); @@ -470,7 +470,7 @@ rgb_to_hsl (GimpDrawable *drawable, static void compute_lic (GimpDrawable *drawable, - guchar *scalarfield, + const guchar *scalarfield, gboolean rotate) { gint xcount, ycount; @@ -537,7 +537,7 @@ static void compute_image (GimpDrawable *drawable) { GimpDrawable *effect; - guchar *scalarfield; + guchar *scalarfield = NULL; /* Get some useful info on the input drawable */ /* ========================================== */ @@ -593,24 +593,14 @@ compute_image (GimpDrawable *drawable) /* Below is only UI stuff */ /**************************/ -static gint -effect_image_constrain (gint32 image_id, - gint32 drawable_id, - gpointer data) +static gboolean +effect_image_constrain (gint32 image_id, + gint32 drawable_id, + gpointer data) { - if (drawable_id == -1) - return TRUE; - return gimp_drawable_is_rgb (drawable_id); } -static void -effect_image_callback (gint32 id, - gpointer data) -{ - licvals.effect_image_id = id; -} - static gboolean create_main_dialog (void) { @@ -620,8 +610,7 @@ create_main_dialog (void) GtkWidget *hbox; GtkWidget *frame; GtkWidget *table; - GtkWidget *option_menu; - GtkWidget *menu; + GtkWidget *combo; GtkObject *scale_data; gint row; gboolean run; @@ -698,15 +687,14 @@ create_main_dialog (void) gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_widget_show (table); - option_menu = gtk_option_menu_new (); - menu = gimp_drawable_menu_new (effect_image_constrain, - effect_image_callback, - NULL, - licvals.effect_image_id); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); + combo = gimp_drawable_combo_box_new (effect_image_constrain, NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), + licvals.effect_image_id, + G_CALLBACK (gimp_int_combo_box_get_active), + &licvals.effect_image_id); + gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, - _("_Effect Image:"), 1.0, 0.5, - option_menu, 2, TRUE); + _("_Effect Image:"), 1.0, 0.5, combo, 2, TRUE); sep = gtk_hseparator_new (); gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); diff --git a/plug-ins/common/sample_colorize.c b/plug-ins/common/sample_colorize.c index 99b7e38a9e..5090dd1366 100644 --- a/plug-ins/common/sample_colorize.c +++ b/plug-ins/common/sample_colorize.c @@ -1400,11 +1400,9 @@ p_smp_dialog (void) gtk_widget_show (label); combo = gimp_layer_combo_box_new (p_smp_constrain, NULL); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), g_values.dst_id); - - g_signal_connect (combo, "changed", - G_CALLBACK (p_smp_dest_combo_callback), - NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), g_values.dst_id, + G_CALLBACK (p_smp_dest_combo_callback), + NULL); gtk_table_attach (GTK_TABLE (table), combo, 1, 2, l_ty, l_ty + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); @@ -1430,12 +1428,9 @@ p_smp_dialog (void) GIMP_INT_STORE_STOCK_ID, GIMP_STOCK_GRADIENT, -1); - gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), - g_values.sample_id); - - g_signal_connect (combo, "changed", - G_CALLBACK (p_smp_sample_combo_callback), - NULL); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), g_values.sample_id, + G_CALLBACK (p_smp_sample_combo_callback), + NULL); gtk_table_attach (GTK_TABLE (table), combo, 4, 5, l_ty, l_ty + 1, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); diff --git a/plug-ins/common/warp.c b/plug-ins/common/warp.c index 75e2e24144..b1fe2f1484 100644 --- a/plug-ins/common/warp.c +++ b/plug-ins/common/warp.c @@ -144,7 +144,7 @@ static void warp (GimpDrawable *drawable, GimpDrawable **map_x_p, GimpDrawable **map_y_p); -static gint warp_dialog (GimpDrawable *drawable); +static gboolean warp_dialog (GimpDrawable *drawable); static GimpTile *warp_pixel (GimpDrawable *drawable, GimpTile *tile, gint width, @@ -159,18 +159,9 @@ static GimpTile *warp_pixel (GimpDrawable *drawable, gint *col, guchar *pixel); -static gint warp_map_constrain (gint32 image_id, +static gboolean warp_map_constrain (gint32 image_id, gint32 drawable_id, gpointer data); -static void warp_map_callback (gint32 id, - gpointer data); -static void warp_map_mag_callback (gint32 id, - gpointer data); -static void warp_map_grad_callback (gint32 id, - gpointer data); -static void warp_map_vector_callback (gint32 id, - gpointer data); - static gdouble warp_map_mag_give_value (guchar *pt, gint alpha, gint bytes); @@ -373,7 +364,7 @@ run (const gchar *name, gimp_displays_flush (); } -static int +static gboolean warp_dialog (GimpDrawable *drawable) { GtkWidget *dlg; @@ -386,14 +377,7 @@ warp_dialog (GimpDrawable *drawable) GtkWidget *otable; GtkWidget *spinbutton; GtkObject *adj; - GtkWidget *option_menu; - GtkWidget *option_menu_mag; - GtkWidget *option_menu_grad; - GtkWidget *option_menu_vector; - GtkWidget *menu; - GtkWidget *magmenu; - GtkWidget *gradmenu; - GtkWidget *vectormenu; + GtkWidget *combo; GSList *group = NULL; gboolean run; @@ -448,13 +432,14 @@ warp_dialog (GimpDrawable *drawable) GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); - option_menu = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 1, 2, + combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.warp_map, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.warp_map); + + gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - menu = gimp_drawable_menu_new (warp_map_constrain, warp_map_callback, - drawable, dvals.warp_map); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - gtk_widget_show (option_menu); + gtk_widget_show (combo); /* ======================================================================= */ @@ -579,13 +564,14 @@ warp_dialog (GimpDrawable *drawable) GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show (label); - option_menu_mag = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (table), option_menu_mag, 2, 3, 1, 2, + combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.mag_map, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.mag_map); + + gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - magmenu = gimp_drawable_menu_new (warp_map_constrain, warp_map_mag_callback, - drawable, dvals.mag_map); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu_mag), magmenu); - gtk_widget_show (option_menu_mag); + gtk_widget_show (combo); /* Magnitude Usage */ toggle_hbox = gtk_hbox_new (FALSE, 4); @@ -631,16 +617,16 @@ warp_dialog (GimpDrawable *drawable) /* --------- Gradient map menu ---------------- */ - option_menu_grad = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (otable), option_menu_grad, 2, 3, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - gradmenu = gimp_drawable_menu_new (warp_map_constrain, warp_map_grad_callback, - drawable, dvals.grad_map); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu_grad), gradmenu); - gimp_help_set_help_data (option_menu_grad, - _("Gradient map selection menu"), NULL); + combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.grad_map, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.grad_map); - gtk_widget_show (option_menu_grad); + gtk_table_attach (GTK_TABLE (otable), combo, 2, 3, 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + gtk_widget_show (combo); + + gimp_help_set_help_data (combo, _("Gradient map selection menu"), NULL); /* ---------------------------------------------- */ @@ -666,19 +652,19 @@ warp_dialog (GimpDrawable *drawable) &dvals.vector_angle); /* --------- Vector map menu ---------------- */ - option_menu_vector = gtk_option_menu_new (); - gtk_table_attach (GTK_TABLE (otable), option_menu_vector, 2, 3, 1, 2, + combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable); + gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.vector_map, + G_CALLBACK (gimp_int_combo_box_get_active), + &dvals.vector_map); + + gtk_table_attach (GTK_TABLE (otable), combo, 2, 3, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - vectormenu = gimp_drawable_menu_new (warp_map_constrain, - warp_map_vector_callback, - drawable, dvals.vector_map); - gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu_vector), vectormenu); - gimp_help_set_help_data (option_menu_vector, + gtk_widget_show (combo); + + gimp_help_set_help_data (combo, _("Fixed-direction-vector map selection menu"), NULL); - gtk_widget_show (option_menu_vector); - gtk_widget_show (otable); gtk_widget_show (frame); @@ -1619,46 +1605,13 @@ warp_pixel (GimpDrawable *drawable, /* Warp interface functions */ -static gint +static gboolean warp_map_constrain (gint32 image_id, gint32 drawable_id, gpointer data) { - GimpDrawable *drawable; + GimpDrawable *drawable = data; - drawable = (GimpDrawable *) data; - - if (drawable_id == -1) - return TRUE; - - return (gimp_drawable_width (drawable_id) == drawable->width && + return (gimp_drawable_width (drawable_id) == drawable->width && gimp_drawable_height (drawable_id) == drawable->height); } - -static void -warp_map_callback (gint32 id, - gpointer data) -{ - dvals.warp_map = id; -} - -static void -warp_map_mag_callback (gint32 id, - gpointer data) -{ - dvals.mag_map = id; -} - -static void -warp_map_grad_callback (gint32 id, - gpointer data) -{ - dvals.grad_map = id; -} - -static void -warp_map_vector_callback (gint32 id, - gpointer data) -{ - dvals.vector_map = id; -}