Commit 36dc39be authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

libgimp/gimpdrawablecombobox.c libgimp/gimpimagecombobox.c changed the

2004-04-21  Sven Neumann  <sven@gimp.org>

	* 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.
parent 0b8c4b3e
2004-04-21 Sven Neumann <sven@gimp.org>
* 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 <mitch@gimp.org>
* app/widgets/Makefile.am
......
2004-04-21 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/tmpl/gimpintcombobox.sgml: updated.
2004-04-21 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-docs.sgml
......
......@@ -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
<SUBSECTION Standard>
GimpIntComboBoxClass
GIMP_INT_COMBO_BOX
......
......@@ -90,3 +90,15 @@ GimpIntComboBox
@Returns:
<!-- ##### FUNCTION gimp_int_combo_box_connect ##### -->
<para>
</para>
@combo_box:
@value:
@callback:
@data:
@Returns:
......@@ -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);
}
......@@ -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);
}
......@@ -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);
}
......@@ -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);
......
......@@ -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;
}
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
......@@ -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 ();
}
......
......@@ -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,
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);
gtk_widget_show (image_option_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu),
image_menu);
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)
......
......@@ -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);