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.
This commit is contained in:
Sven Neumann 2004-04-21 16:50:13 +00:00 committed by Sven Neumann
parent 0b8c4b3ec9
commit 36dc39becb
19 changed files with 394 additions and 431 deletions

View File

@ -1,3 +1,27 @@
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> 2004-04-21 Michael Natterer <mitch@gimp.org>
* app/widgets/Makefile.am * app/widgets/Makefile.am

View File

@ -1,3 +1,8 @@
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> 2004-04-21 Sven Neumann <sven@gimp.org>
* libgimp/libgimp-docs.sgml * libgimp/libgimp-docs.sgml

View File

@ -189,6 +189,7 @@ gimp_int_combo_box_prepend
gimp_int_combo_box_append gimp_int_combo_box_append
gimp_int_combo_box_set_active gimp_int_combo_box_set_active
gimp_int_combo_box_get_active gimp_int_combo_box_get_active
gimp_int_combo_box_connect
<SUBSECTION Standard> <SUBSECTION Standard>
GimpIntComboBoxClass GimpIntComboBoxClass
GIMP_INT_COMBO_BOX GIMP_INT_COMBO_BOX

View File

@ -90,3 +90,15 @@ GimpIntComboBox
@Returns: @Returns:
<!-- ##### FUNCTION gimp_int_combo_box_connect ##### -->
<para>
</para>
@combo_box:
@value:
@callback:
@data:
@Returns:

View File

@ -37,13 +37,13 @@
#define MENU_THUMBNAIL_SIZE 24 #define MENU_THUMBNAIL_SIZE 24
static gint gimp_drawable_combo_box_model_add (GtkListStore *store, static gint gimp_drawable_combo_box_model_add (GtkListStore *store,
gint32 image, gint32 image,
gint num_drawables, gint num_drawables,
gint32 *drawables, gint32 *drawables,
GimpDrawableConstraintFunc constraint, GimpDrawableConstraintFunc constraint,
gpointer data); gpointer data);
static void gimp_drawable_combo_box_model_add_none (GtkListStore *store); 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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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 static void
gimp_drawable_combo_box_model_add_none (GtkListStore *store) gimp_drawable_combo_box_model_add_empty (GtkListStore *store)
{ {
GtkTreeIter iter; GtkTreeIter iter;
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, gtk_list_store_set (store, &iter,
GIMP_INT_STORE_VALUE, -1, GIMP_INT_STORE_VALUE, -1,
GIMP_INT_STORE_LABEL, _("(None)"), GIMP_INT_STORE_LABEL, _("(Empty)"),
-1); -1);
} }

View File

@ -37,12 +37,12 @@
#define MENU_THUMBNAIL_SIZE 24 #define MENU_THUMBNAIL_SIZE 24
static void gimp_image_combo_box_model_add (GtkListStore *store, static void gimp_image_combo_box_model_add (GtkListStore *store,
gint num_images, gint num_images,
gint32 *images, gint32 *images,
GimpImageConstraintFunc constraint, GimpImageConstraintFunc constraint,
gpointer data); gpointer data);
static void gimp_image_combo_box_model_add_none (GtkListStore *store); 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, num_images, images,
constraint, data); constraint, data);
else 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); g_free (images);
@ -137,13 +137,13 @@ gimp_image_combo_box_model_add (GtkListStore *store,
} }
static void static void
gimp_image_combo_box_model_add_none (GtkListStore *store) gimp_image_combo_box_model_add_empty (GtkListStore *store)
{ {
GtkTreeIter iter; GtkTreeIter iter;
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, gtk_list_store_set (store, &iter,
GIMP_INT_STORE_VALUE, -1, GIMP_INT_STORE_VALUE, -1,
GIMP_INT_STORE_LABEL, _("(None)"), GIMP_INT_STORE_LABEL, _("(Empty)"),
-1); -1);
} }

View File

@ -37,13 +37,13 @@
#define MENU_THUMBNAIL_SIZE 24 #define MENU_THUMBNAIL_SIZE 24
static gint gimp_drawable_combo_box_model_add (GtkListStore *store, static gint gimp_drawable_combo_box_model_add (GtkListStore *store,
gint32 image, gint32 image,
gint num_drawables, gint num_drawables,
gint32 *drawables, gint32 *drawables,
GimpDrawableConstraintFunc constraint, GimpDrawableConstraintFunc constraint,
gpointer data); gpointer data);
static void gimp_drawable_combo_box_model_add_none (GtkListStore *store); 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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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); g_free (images);
if (! added) 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)) if (gtk_tree_model_get_iter_first (model, &iter))
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &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 static void
gimp_drawable_combo_box_model_add_none (GtkListStore *store) gimp_drawable_combo_box_model_add_empty (GtkListStore *store)
{ {
GtkTreeIter iter; GtkTreeIter iter;
gtk_list_store_append (store, &iter); gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, gtk_list_store_set (store, &iter,
GIMP_INT_STORE_VALUE, -1, GIMP_INT_STORE_VALUE, -1,
GIMP_INT_STORE_LABEL, _("(None)"), GIMP_INT_STORE_LABEL, _("(Empty)"),
-1); -1);
} }

View File

@ -46,7 +46,7 @@ static GtkWidget * gimp_menu_add_item (GtkWidget *menu,
const gchar *image_name, const gchar *image_name,
const gchar *drawable_name, const gchar *drawable_name,
gint32 any_ID); 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, static GtkWidget * gimp_menu_make_preview (gint32 any_ID,
gboolean is_image, gboolean is_image,
gint width, gint width,
@ -102,7 +102,7 @@ gimp_image_menu_new (GimpConstraintFunc constraint,
} }
if (k == 0) if (k == 0)
gimp_menu_add_none (menu); gimp_menu_add_empty (menu);
(* callback) (image, data); (* callback) (image, data);
@ -170,7 +170,7 @@ gimp_layer_menu_new (GimpConstraintFunc constraint,
g_free (images); g_free (images);
if (k == 0) if (k == 0)
gimp_menu_add_none (menu); gimp_menu_add_empty (menu);
(* callback) (layer, data); (* callback) (layer, data);
@ -238,7 +238,7 @@ gimp_channel_menu_new (GimpConstraintFunc constraint,
g_free (images); g_free (images);
if (k == 0) if (k == 0)
gimp_menu_add_none (menu); gimp_menu_add_empty (menu);
(* callback) (channel, data); (* callback) (channel, data);
@ -327,7 +327,7 @@ gimp_drawable_menu_new (GimpConstraintFunc constraint,
g_free (images); g_free (images);
if (k == 0) if (k == 0)
gimp_menu_add_none (menu); gimp_menu_add_empty (menu);
(* callback) (drawable, data); (* callback) (drawable, data);
@ -400,11 +400,11 @@ gimp_menu_add_item (GtkWidget *menu,
} }
static GtkWidget * static GtkWidget *
gimp_menu_add_none (GtkWidget *menu) gimp_menu_add_empty (GtkWidget *menu)
{ {
GtkWidget *menuitem; 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_widget_set_sensitive (menuitem, FALSE);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem); gtk_widget_show (menuitem);

View File

@ -349,3 +349,43 @@ gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
return FALSE; 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;
}

View File

@ -71,6 +71,11 @@ gboolean gimp_int_combo_box_set_active (GimpIntComboBox *combo_box,
gboolean gimp_int_combo_box_get_active (GimpIntComboBox *combo_box, gboolean gimp_int_combo_box_get_active (GimpIntComboBox *combo_box,
gint *value); gint *value);
gulong gimp_int_combo_box_connect (GimpIntComboBox *combo_box,
gint value,
GCallback callback,
gpointer data);
G_END_DECLS G_END_DECLS

View File

@ -898,12 +898,9 @@ create_bump_page (void)
g_object_set_data (G_OBJECT (toggle), "set_sensitive", table); g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
combo = gimp_drawable_combo_box_new (bumpmap_constrain, NULL); combo = gimp_drawable_combo_box_new (bumpmap_constrain, NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.bumpmap_id,
mapvals.bumpmap_id); G_CALLBACK (gimp_int_combo_box_get_active),
&mapvals.bumpmap_id);
g_signal_connect (combo, "changed",
G_CALLBACK (gimp_int_combo_box_get_active),
&mapvals.bumpmap_id);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Bumpm_ap Image:"), 1.0, 0.5, _("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); g_object_set_data (G_OBJECT (toggle), "set_sensitive", table);
combo = gimp_drawable_combo_box_new (envmap_constrain, NULL); combo = gimp_drawable_combo_box_new (envmap_constrain, NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), mapvals.envmap_id,
mapvals.envmap_id); G_CALLBACK (envmap_combo_callback),
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (envmap_combo_callback),
NULL);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("En_vironment Image:"), 1.0, 0.5, _("En_vironment Image:"), 1.0, 0.5,

View File

@ -1136,12 +1136,10 @@ create_box_page (void)
GtkWidget *combo; GtkWidget *combo;
combo = gimp_drawable_combo_box_new (box_constrain, NULL); combo = gimp_drawable_combo_box_new (box_constrain, NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
mapvals.boxmap_id[i]); mapvals.boxmap_id[i],
G_CALLBACK (gimp_int_combo_box_get_active),
g_signal_connect (combo, "changed", &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, gimp_table_attach_aligned (GTK_TABLE (table), 0, i,
gettext (labels[i]), 1.0, 0.5, gettext (labels[i]), 1.0, 0.5,
@ -1229,12 +1227,10 @@ create_cylinder_page (void)
GtkWidget *combo; GtkWidget *combo;
combo = gimp_drawable_combo_box_new (cylinder_constrain, NULL); combo = gimp_drawable_combo_box_new (cylinder_constrain, NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
mapvals.cylindermap_id[i]); mapvals.cylindermap_id[i],
G_CALLBACK (gimp_int_combo_box_get_active),
g_signal_connect (combo, "changed", &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, gimp_table_attach_aligned (GTK_TABLE (table), 0, i,
gettext (labels[i]), 1.0, 0.5, gettext (labels[i]), 1.0, 0.5,

View File

@ -257,7 +257,7 @@ static void dialog_tiled_callback (GtkWidget *widget, gpointer data);
static void dialog_map_type_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, static gint dialog_constrain (gint32 image_id, gint32 drawable_id,
gpointer data); 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, static void dialog_dscale_update (GtkAdjustment *adjustment,
gdouble *value); gdouble *value);
static void dialog_iscale_update_normal (GtkAdjustment *adjustment, gint *value); static void dialog_iscale_update_normal (GtkAdjustment *adjustment, gint *value);
@ -862,8 +862,7 @@ bumpmap_dialog (void)
GtkWidget *scrollbar; GtkWidget *scrollbar;
GtkWidget *table; GtkWidget *table;
GtkWidget *right_vbox; GtkWidget *right_vbox;
GtkWidget *option_menu; GtkWidget *combo;
GtkWidget *menu;
GtkWidget *button; GtkWidget *button;
GtkObject *adj; GtkObject *adj;
gint i; gint i;
@ -1023,15 +1022,13 @@ bumpmap_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table); gtk_widget_show (table);
option_menu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (dialog_constrain, NULL);
menu = gimp_drawable_menu_new (dialog_constrain, gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), bmvals.bumpmap_id,
dialog_bumpmap_callback, G_CALLBACK (dialog_bumpmap_callback),
NULL, NULL);
bmvals.bumpmap_id);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Bump Map:"), 1.0, 0.5, _("_Bump Map:"), 1.0, 0.5, combo, 2, TRUE);
option_menu, 2, TRUE);
sep = gtk_hseparator_new (); sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); 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, dialog_constrain (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data) gpointer data)
{ {
if (drawable_id == -1)
return TRUE;
return (gimp_drawable_is_rgb (drawable_id) || return (gimp_drawable_is_rgb (drawable_id) ||
gimp_drawable_is_gray (drawable_id)); gimp_drawable_is_gray (drawable_id));
} }
static void static void
dialog_bumpmap_callback (gint32 id, dialog_bumpmap_callback (GtkWidget *widget,
gpointer data) 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); dialog_new_bumpmap (FALSE);
} }
else else
{ {
bmvals.bumpmap_id = id; bmvals.bumpmap_id = value;
dialog_new_bumpmap (TRUE); dialog_new_bumpmap (TRUE);
} }
dialog_update_preview (); dialog_update_preview ();
} }

View File

@ -51,9 +51,9 @@ static void run (const gchar *name,
gint *nreturn_vals, gint *nreturn_vals,
GimpParam **return_vals); GimpParam **return_vals);
static gint32 compose (const gchar *compose_type, static gint32 compose (const gchar *compose_type,
gint32 *compose_ID, gint32 *compose_ID,
gboolean compose_by_drawable); gboolean compose_by_drawable);
static gint32 create_new_image (const gchar *filename, static gint32 create_new_image (const gchar *filename,
guint width, guint width,
@ -91,9 +91,6 @@ static gboolean check_gray (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data); gpointer data);
static void image_menu_callback (gint32 id,
gpointer data);
static void compose_type_toggle_update (GtkWidget *widget, static void compose_type_toggle_update (GtkWidget *widget,
gpointer data); gpointer data);
@ -1067,7 +1064,6 @@ compose_dialog (const gchar *compose_type,
GtkWidget *label; GtkWidget *label;
GtkWidget *table; GtkWidget *table;
GtkWidget *image; GtkWidget *image;
GtkWidget *image_option_menu, *image_menu;
GSList *group; GSList *group;
gint j, compose_idx; gint j, compose_idx;
gboolean run; gboolean run;
@ -1130,6 +1126,7 @@ compose_dialog (const gchar *compose_type,
for (j = 0; j < MAX_COMPOSE_IMAGES; j++) for (j = 0; j < MAX_COMPOSE_IMAGES; j++)
{ {
GtkWidget *combo;
const gchar *text; const gchar *text;
image = gtk_image_new_from_stock (compose_dsc[compose_idx].channel_icon[j], 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); gtk_widget_show (label);
composeint.select_ID[j] = drawable_ID; 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); combo = gimp_drawable_combo_box_new (check_gray, NULL);
gtk_option_menu_set_menu (GTK_OPTION_MENU (image_option_menu), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
image_menu); 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 */ /* Set sensitivity of last menu */
@ -1224,19 +1222,10 @@ check_gray (gint32 image_id,
{ {
return ((gimp_image_base_type (image_id) == GIMP_GRAY) && 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)); (gimp_image_height (image_id) == composeint.height));
} }
static void
image_menu_callback (gint32 id,
gpointer data)
{
*(gint32 *) data = id;
}
static void static void
compose_type_toggle_update (GtkWidget *widget, compose_type_toggle_update (GtkWidget *widget,
gpointer data) gpointer data)

View File

@ -95,11 +95,11 @@ typedef struct _DepthMerge
DepthMergeInterface *interface; DepthMergeInterface *interface;
DepthMergeParams params; DepthMergeParams params;
GimpDrawable *resultDrawable; GimpDrawable *resultDrawable;
GimpDrawable *source1Drawable; GimpDrawable *source1Drawable;
GimpDrawable *source2Drawable; GimpDrawable *source2Drawable;
GimpDrawable *depthMap1Drawable; GimpDrawable *depthMap1Drawable;
GimpDrawable *depthMap2Drawable; GimpDrawable *depthMap2Drawable;
gint selectionX0; gint selectionX0;
gint selectionY0; gint selectionY0;
gint selectionX1; gint selectionX1;
@ -119,21 +119,21 @@ void DepthMerge_executeRegion (DepthMerge *dm,
guchar *depthMap1Row, guchar *depthMap1Row,
guchar *depthMap2Row, guchar *depthMap2Row,
guchar *resultRow, guchar *resultRow,
gint length); gint length);
gint32 DepthMerge_dialog (DepthMerge *dm); gint32 DepthMerge_dialog (DepthMerge *dm);
void DepthMerge_buildPreviewSourceImage(DepthMerge *dm); void DepthMerge_buildPreviewSourceImage(DepthMerge *dm);
void DepthMerge_updatePreview (DepthMerge *dm); void DepthMerge_updatePreview (DepthMerge *dm);
gint constraintResultSizeAndResultColorOrGray(gint32 imageId, static gboolean dm_constraint (gint32 imageId,
gint32 drawableId, gpointer data); gint32 drawableId,
gint constraintResultSizeAndGray(gint32 imageId, gpointer data);
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 dialogValueScaleUpdateCallback (GtkAdjustment *adjustment, gpointer data);
void dialogValueEntryUpdateCallback (GtkWidget *widget, gpointer data); void dialogValueEntryUpdateCallback (GtkWidget *widget, gpointer data);
@ -624,9 +624,8 @@ DepthMerge_dialog (DepthMerge *dm)
GtkWidget *topTable; GtkWidget *topTable;
GtkWidget *previewFrame; GtkWidget *previewFrame;
GtkWidget *sourceTable; GtkWidget *sourceTable;
GtkWidget *tempLabel; GtkWidget *label;
GtkWidget *tempOptionMenu; GtkWidget *combo;
GtkWidget *tempMenu;
GtkWidget *numericParameterTable; GtkWidget *numericParameterTable;
GtkObject *adj; GtkObject *adj;
gboolean run; gboolean run;
@ -679,73 +678,65 @@ DepthMerge_dialog (DepthMerge *dm)
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
gtk_widget_show (sourceTable); gtk_widget_show (sourceTable);
tempLabel = gtk_label_new (_("Source 1:")); label = gtk_label_new (_("Source 1:"));
gtk_misc_set_alignment (GTK_MISC (tempLabel), 1.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 0, 1, 0, 1, gtk_table_attach (GTK_TABLE (sourceTable), label, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (tempLabel); gtk_widget_show (label);
tempOptionMenu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (dm_constraint, dm);
gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 1, 2, 0, 1, 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_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (tempOptionMenu); gtk_widget_show (combo);
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);
tempLabel = gtk_label_new(_("Depth Map:")); label = gtk_label_new(_("Depth Map:"));
gtk_misc_set_alignment(GTK_MISC(tempLabel), 1.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 2, 3, 0, 1, gtk_table_attach (GTK_TABLE (sourceTable), label, 2, 3, 0, 1,
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (tempLabel); gtk_widget_show (label);
tempOptionMenu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (dm_constraint, dm);
gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 3, 4, 0, 1, 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_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (tempOptionMenu); gtk_widget_show (combo);
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);
tempLabel = gtk_label_new (_("Source 2:")); label = gtk_label_new (_("Source 2:"));
gtk_misc_set_alignment (GTK_MISC (tempLabel), 1.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 0, 1, 1, 2, gtk_table_attach (GTK_TABLE (sourceTable), label, 0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (tempLabel); gtk_widget_show (label);
tempOptionMenu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (dm_constraint, dm);
gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 1, 2, 1, 2, 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_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (tempOptionMenu); gtk_widget_show (combo);
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);
tempLabel = gtk_label_new (_("Depth Map:")); label = gtk_label_new (_("Depth Map:"));
gtk_misc_set_alignment(GTK_MISC(tempLabel), 1.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (sourceTable), tempLabel, 2, 3, 1, 2, gtk_table_attach (GTK_TABLE (sourceTable), label, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (tempLabel); gtk_widget_show (label);
tempOptionMenu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (dm_constraint, dm);
gtk_table_attach (GTK_TABLE (sourceTable), tempOptionMenu, 3, 4, 1, 2, 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_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (tempOptionMenu); gtk_widget_show (combo);
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);
/* Numeric parameters */ /* Numeric parameters */
numericParameterTable = gtk_table_new(4, 3, FALSE); numericParameterTable = gtk_table_new(4, 3, FALSE);
@ -928,10 +919,10 @@ DepthMerge_updatePreview (DepthMerge *dm)
/* ----- Callbacks ----- */ /* ----- Callbacks ----- */
gint static gboolean
constraintResultSizeAndResultColorOrGray (gint32 imageId, dm_constraint (gint32 imageId,
gint32 drawableId, gint32 drawableId,
gpointer data) gpointer data)
{ {
DepthMerge *dm = (DepthMerge *)data; DepthMerge *dm = (DepthMerge *)data;
@ -945,32 +936,19 @@ constraintResultSizeAndResultColorOrGray (gint32 imageId,
gimp_drawable_is_gray (drawableId)))); gimp_drawable_is_gray (drawableId))));
} }
gint static void
constraintResultSizeAndGray (gint32 imageId, dialogSource1ChangedCallback (GtkWidget *widget,
gint32 drawableId, DepthMerge *dm)
gpointer data)
{ {
DepthMerge *dm = (DepthMerge *)data; if (dm->source1Drawable)
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)
gimp_drawable_detach (dm->source1Drawable); gimp_drawable_detach (dm->source1Drawable);
dm->params.source1 = id;
dm->source1Drawable = (dm->params.source1 == -1) ? NULL : gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
gimp_drawable_get (dm->params.source1); &dm->params.source1);
dm->source1Drawable = ((dm->params.source1 == -1) ?
NULL :
gimp_drawable_get (dm->params.source1));
util_fillReducedBuffer (dm->interface->previewSource1, util_fillReducedBuffer (dm->interface->previewSource1,
dm->interface->previewWidth, dm->interface->previewWidth,
@ -983,17 +961,19 @@ dialogSource1ChangedCallback (gint32 id,
DepthMerge_updatePreview (dm); DepthMerge_updatePreview (dm);
} }
void static void
dialogSource2ChangedCallback (gint32 id, dialogSource2ChangedCallback (GtkWidget *widget,
gpointer data) DepthMerge *dm)
{ {
DepthMerge *dm = (DepthMerge *)data; if (dm->source2Drawable)
if (dm->source2Drawable != NULL)
gimp_drawable_detach (dm->source2Drawable); gimp_drawable_detach (dm->source2Drawable);
dm->params.source2 = id;
dm->source2Drawable = (dm->params.source2 == -1) ? NULL : gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
gimp_drawable_get (dm->params.source2); &dm->params.source2);
dm->source2Drawable = ((dm->params.source2 == -1) ?
NULL :
gimp_drawable_get (dm->params.source2));
util_fillReducedBuffer (dm->interface->previewSource2, util_fillReducedBuffer (dm->interface->previewSource2,
dm->interface->previewWidth, dm->interface->previewWidth,
@ -1006,17 +986,19 @@ dialogSource2ChangedCallback (gint32 id,
DepthMerge_updatePreview (dm); DepthMerge_updatePreview (dm);
} }
void static void
dialogDepthMap1ChangedCallback (gint32 id, dialogDepthMap1ChangedCallback (GtkWidget *widget,
gpointer data) DepthMerge *dm)
{ {
DepthMerge *dm = (DepthMerge *)data; if (dm->depthMap1Drawable)
gimp_drawable_detach (dm->depthMap1Drawable);
if (dm->depthMap1Drawable != NULL) gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
gimp_drawable_detach(dm->depthMap1Drawable); &dm->params.depthMap1);
dm->params.depthMap1 = id;
dm->depthMap1Drawable = (dm->params.depthMap1 == -1) ? NULL : dm->depthMap1Drawable = ((dm->params.depthMap1 == -1) ?
gimp_drawable_get (dm->params.depthMap1); NULL :
gimp_drawable_get (dm->params.depthMap1));
util_fillReducedBuffer (dm->interface->previewDepthMap1, util_fillReducedBuffer (dm->interface->previewDepthMap1,
dm->interface->previewWidth, dm->interface->previewWidth,
@ -1029,17 +1011,19 @@ dialogDepthMap1ChangedCallback (gint32 id,
DepthMerge_updatePreview (dm); DepthMerge_updatePreview (dm);
} }
void static void
dialogDepthMap2ChangedCallback (gint32 id, dialogDepthMap2ChangedCallback (GtkWidget *widget,
gpointer data) DepthMerge *dm)
{ {
DepthMerge *dm = (DepthMerge *)data; if (dm->depthMap2Drawable)
gimp_drawable_detach (dm->depthMap2Drawable);
if (dm->depthMap2Drawable != NULL) gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
gimp_drawable_detach(dm->depthMap2Drawable); &dm->params.depthMap2);
dm->params.depthMap2 = id;
dm->depthMap2Drawable = (dm->params.depthMap2 == -1) ? NULL : dm->depthMap1Drawable = ((dm->params.depthMap2 == -1) ?
gimp_drawable_get (dm->params.depthMap2); NULL :
gimp_drawable_get (dm->params.depthMap2));
util_fillReducedBuffer (dm->interface->previewDepthMap2, util_fillReducedBuffer (dm->interface->previewDepthMap2,
dm->interface->previewWidth, dm->interface->previewWidth,

View File

@ -86,13 +86,9 @@ static void run (const gchar *name,
static void displace (GimpDrawable *drawable); static void displace (GimpDrawable *drawable);
static gint displace_dialog (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, gint32 drawable_id,
gpointer data); 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, static gdouble displace_map_give_value (guchar *ptr,
gint alpha, gint alpha,
gint bytes); gint bytes);
@ -256,8 +252,7 @@ displace_dialog (GimpDrawable *drawable)
GtkWidget *table; GtkWidget *table;
GtkWidget *spinbutton; GtkWidget *spinbutton;
GtkObject *adj; GtkObject *adj;
GtkWidget *option_menu; GtkWidget *combo;
GtkWidget *menu;
GtkWidget *sep; GtkWidget *sep;
GSList *group = NULL; GSList *group = NULL;
gboolean run; gboolean run;
@ -310,16 +305,17 @@ displace_dialog (GimpDrawable *drawable)
g_object_set_data (G_OBJECT (toggle), "set_sensitive", spinbutton); g_object_set_data (G_OBJECT (toggle), "set_sensitive", spinbutton);
gtk_widget_show (spinbutton); gtk_widget_show (spinbutton);
option_menu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 0, 1, gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_x,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); G_CALLBACK (gimp_int_combo_box_get_active),
menu = gimp_drawable_menu_new (displace_map_constrain, displace_map_x_callback, &dvals.displace_map_x);
drawable, dvals.displace_map_x);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
gtk_widget_set_sensitive (option_menu, dvals.do_x); gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 0, 1,
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", option_menu); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (option_menu); gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, dvals.do_x);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);
/* Y Options */ /* Y Options */
toggle = gtk_check_button_new_with_mnemonic (_("_Y Displacement:")); 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); g_object_set_data (G_OBJECT (toggle), "set_sensitive", spinbutton);
gtk_widget_show (spinbutton); gtk_widget_show (spinbutton);
option_menu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (displace_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 1, 2, gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.displace_map_y,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); G_CALLBACK (gimp_int_combo_box_get_active),
menu = gimp_drawable_menu_new (displace_map_constrain, displace_map_y_callback, &dvals.displace_map_y);
drawable, dvals.displace_map_y);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
gtk_widget_set_sensitive (option_menu, dvals.do_y); gtk_table_attach (GTK_TABLE (table), combo, 2, 3, 1, 2,
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", option_menu); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show (option_menu); gtk_widget_show (combo);
gtk_widget_set_sensitive (combo, dvals.do_y);
g_object_set_data (G_OBJECT (spinbutton), "set_sensitive", combo);
/* Displacement Type */ /* Displacement Type */
sep = gtk_hseparator_new (); sep = gtk_hseparator_new ();
@ -644,32 +641,13 @@ displace_map_give_value (guchar *pt,
/* Displace interface functions */ /* Displace interface functions */
static gint static gboolean
displace_map_constrain (gint32 image_id, displace_map_constrain (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data) gpointer data)
{ {
GimpDrawable *drawable; GimpDrawable *drawable = data;
drawable = (GimpDrawable *) data; return (gimp_drawable_width (drawable_id) == drawable->width &&
if (drawable_id == -1)
return TRUE;
return (gimp_drawable_width (drawable_id) == drawable->width &&
gimp_drawable_height (drawable_id) == drawable->height); 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;
}

View File

@ -126,9 +126,9 @@ poke (GimpPixelRgn *dest_rgn,
} }
static gint static gint
peekmap (guchar *image, peekmap (const guchar *image,
gint x, gint x,
gint y) gint y)
{ {
while (x < 0) while (x < 0)
x += effect_width; x += effect_width;
@ -155,11 +155,11 @@ peekmap (guchar *image,
/***************************************************/ /***************************************************/
static gint static gint
gradx (guchar *image, gradx (const guchar *image,
gint x, gint x,
gint y) gint y)
{ {
gint val=0; gint val = 0;
val = val + peekmap (image, x-1, y-1); val = val + peekmap (image, x-1, y-1);
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 static gint
grady (guchar *image, grady (const guchar *image,
gint x, gint x,
gint y) gint y)
{ {
gint val = 0; gint val = 0;
@ -414,16 +414,16 @@ static guchar*
rgb_to_hsl (GimpDrawable *drawable, rgb_to_hsl (GimpDrawable *drawable,
LICEffectChannel effect_channel) LICEffectChannel effect_channel)
{ {
guchar *themap, data[4]; guchar *themap, data[4];
gint x, y; gint x, y;
GimpRGB color; GimpRGB color;
GimpHSL color_hsl; GimpHSL color_hsl;
gdouble val; gdouble val = 0.0;
glong maxc, index = 0; glong maxc, index = 0;
GimpPixelRgn region; GimpPixelRgn region;
GRand *gr; GRand *gr;
gr = g_rand_new(); gr = g_rand_new ();
maxc = drawable->width * drawable->height; maxc = drawable->width * drawable->height;
@ -443,17 +443,17 @@ rgb_to_hsl (GimpDrawable *drawable,
gimp_rgb_to_hsl (&color, &color_hsl); gimp_rgb_to_hsl (&color, &color_hsl);
switch (effect_channel) switch (effect_channel)
{ {
case LIC_HUE: case LIC_HUE:
val = color_hsl.h * 255; val = color_hsl.h * 255;
break; break;
case LIC_SATURATION: case LIC_SATURATION:
val = color_hsl.s * 255; val = color_hsl.s * 255;
break; break;
case LIC_BRIGHTNESS: case LIC_BRIGHTNESS:
val = color_hsl.l * 255; val = color_hsl.l * 255;
break; break;
} }
/* add some random to avoid unstructured areas. */ /* add some random to avoid unstructured areas. */
val += g_rand_double_range (gr, -1.0, 1.0); val += g_rand_double_range (gr, -1.0, 1.0);
@ -470,7 +470,7 @@ rgb_to_hsl (GimpDrawable *drawable,
static void static void
compute_lic (GimpDrawable *drawable, compute_lic (GimpDrawable *drawable,
guchar *scalarfield, const guchar *scalarfield,
gboolean rotate) gboolean rotate)
{ {
gint xcount, ycount; gint xcount, ycount;
@ -537,7 +537,7 @@ static void
compute_image (GimpDrawable *drawable) compute_image (GimpDrawable *drawable)
{ {
GimpDrawable *effect; GimpDrawable *effect;
guchar *scalarfield; guchar *scalarfield = NULL;
/* Get some useful info on the input drawable */ /* Get some useful info on the input drawable */
/* ========================================== */ /* ========================================== */
@ -593,24 +593,14 @@ compute_image (GimpDrawable *drawable)
/* Below is only UI stuff */ /* Below is only UI stuff */
/**************************/ /**************************/
static gint static gboolean
effect_image_constrain (gint32 image_id, effect_image_constrain (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data) gpointer data)
{ {
if (drawable_id == -1)
return TRUE;
return gimp_drawable_is_rgb (drawable_id); return gimp_drawable_is_rgb (drawable_id);
} }
static void
effect_image_callback (gint32 id,
gpointer data)
{
licvals.effect_image_id = id;
}
static gboolean static gboolean
create_main_dialog (void) create_main_dialog (void)
{ {
@ -620,8 +610,7 @@ create_main_dialog (void)
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table; GtkWidget *table;
GtkWidget *option_menu; GtkWidget *combo;
GtkWidget *menu;
GtkObject *scale_data; GtkObject *scale_data;
gint row; gint row;
gboolean run; gboolean run;
@ -698,15 +687,14 @@ create_main_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table); gtk_widget_show (table);
option_menu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (effect_image_constrain, NULL);
menu = gimp_drawable_menu_new (effect_image_constrain, gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
effect_image_callback, licvals.effect_image_id,
NULL, G_CALLBACK (gimp_int_combo_box_get_active),
licvals.effect_image_id); &licvals.effect_image_id);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("_Effect Image:"), 1.0, 0.5, _("_Effect Image:"), 1.0, 0.5, combo, 2, TRUE);
option_menu, 2, TRUE);
sep = gtk_hseparator_new (); sep = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);

View File

@ -1400,11 +1400,9 @@ p_smp_dialog (void)
gtk_widget_show (label); gtk_widget_show (label);
combo = gimp_layer_combo_box_new (p_smp_constrain, NULL); 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); gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), g_values.dst_id,
G_CALLBACK (p_smp_dest_combo_callback),
g_signal_connect (combo, "changed", NULL);
G_CALLBACK (p_smp_dest_combo_callback),
NULL);
gtk_table_attach (GTK_TABLE (table), combo, 1, 2, l_ty, l_ty + 1, gtk_table_attach (GTK_TABLE (table), combo, 1, 2, l_ty, l_ty + 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); 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, GIMP_INT_STORE_STOCK_ID, GIMP_STOCK_GRADIENT,
-1); -1);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), g_values.sample_id,
g_values.sample_id); G_CALLBACK (p_smp_sample_combo_callback),
NULL);
g_signal_connect (combo, "changed",
G_CALLBACK (p_smp_sample_combo_callback),
NULL);
gtk_table_attach (GTK_TABLE (table), combo, 4, 5, l_ty, l_ty + 1, gtk_table_attach (GTK_TABLE (table), combo, 4, 5, l_ty, l_ty + 1,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);

View File

@ -144,7 +144,7 @@ static void warp (GimpDrawable *drawable,
GimpDrawable **map_x_p, GimpDrawable **map_x_p,
GimpDrawable **map_y_p); GimpDrawable **map_y_p);
static gint warp_dialog (GimpDrawable *drawable); static gboolean warp_dialog (GimpDrawable *drawable);
static GimpTile *warp_pixel (GimpDrawable *drawable, static GimpTile *warp_pixel (GimpDrawable *drawable,
GimpTile *tile, GimpTile *tile,
gint width, gint width,
@ -159,18 +159,9 @@ static GimpTile *warp_pixel (GimpDrawable *drawable,
gint *col, gint *col,
guchar *pixel); guchar *pixel);
static gint warp_map_constrain (gint32 image_id, static gboolean warp_map_constrain (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data); 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, static gdouble warp_map_mag_give_value (guchar *pt,
gint alpha, gint alpha,
gint bytes); gint bytes);
@ -373,7 +364,7 @@ run (const gchar *name,
gimp_displays_flush (); gimp_displays_flush ();
} }
static int static gboolean
warp_dialog (GimpDrawable *drawable) warp_dialog (GimpDrawable *drawable)
{ {
GtkWidget *dlg; GtkWidget *dlg;
@ -386,14 +377,7 @@ warp_dialog (GimpDrawable *drawable)
GtkWidget *otable; GtkWidget *otable;
GtkWidget *spinbutton; GtkWidget *spinbutton;
GtkObject *adj; GtkObject *adj;
GtkWidget *option_menu; GtkWidget *combo;
GtkWidget *option_menu_mag;
GtkWidget *option_menu_grad;
GtkWidget *option_menu_vector;
GtkWidget *menu;
GtkWidget *magmenu;
GtkWidget *gradmenu;
GtkWidget *vectormenu;
GSList *group = NULL; GSList *group = NULL;
gboolean run; gboolean run;
@ -448,13 +432,14 @@ warp_dialog (GimpDrawable *drawable)
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label); gtk_widget_show (label);
option_menu = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (table), option_menu, 2, 3, 1, 2, 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); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
menu = gimp_drawable_menu_new (warp_map_constrain, warp_map_callback, gtk_widget_show (combo);
drawable, dvals.warp_map);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
gtk_widget_show (option_menu);
/* ======================================================================= */ /* ======================================================================= */
@ -579,13 +564,14 @@ warp_dialog (GimpDrawable *drawable)
GTK_FILL, GTK_FILL, 0, 0); GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label); gtk_widget_show (label);
option_menu_mag = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (table), option_menu_mag, 2, 3, 1, 2, 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); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
magmenu = gimp_drawable_menu_new (warp_map_constrain, warp_map_mag_callback, gtk_widget_show (combo);
drawable, dvals.mag_map);
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu_mag), magmenu);
gtk_widget_show (option_menu_mag);
/* Magnitude Usage */ /* Magnitude Usage */
toggle_hbox = gtk_hbox_new (FALSE, 4); toggle_hbox = gtk_hbox_new (FALSE, 4);
@ -631,16 +617,16 @@ warp_dialog (GimpDrawable *drawable)
/* --------- Gradient map menu ---------------- */ /* --------- Gradient map menu ---------------- */
option_menu_grad = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (otable), option_menu_grad, 2, 3, 0, 1, gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo), dvals.grad_map,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); G_CALLBACK (gimp_int_combo_box_get_active),
gradmenu = gimp_drawable_menu_new (warp_map_constrain, warp_map_grad_callback, &dvals.grad_map);
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);
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); &dvals.vector_angle);
/* --------- Vector map menu ---------------- */ /* --------- Vector map menu ---------------- */
option_menu_vector = gtk_option_menu_new (); combo = gimp_drawable_combo_box_new (warp_map_constrain, drawable);
gtk_table_attach (GTK_TABLE (otable), option_menu_vector, 2, 3, 1, 2, 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); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
vectormenu = gimp_drawable_menu_new (warp_map_constrain, gtk_widget_show (combo);
warp_map_vector_callback,
drawable, dvals.vector_map); gimp_help_set_help_data (combo,
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu_vector), vectormenu);
gimp_help_set_help_data (option_menu_vector,
_("Fixed-direction-vector map selection menu"), _("Fixed-direction-vector map selection menu"),
NULL); NULL);
gtk_widget_show (option_menu_vector);
gtk_widget_show (otable); gtk_widget_show (otable);
gtk_widget_show (frame); gtk_widget_show (frame);
@ -1619,46 +1605,13 @@ warp_pixel (GimpDrawable *drawable,
/* Warp interface functions */ /* Warp interface functions */
static gint static gboolean
warp_map_constrain (gint32 image_id, warp_map_constrain (gint32 image_id,
gint32 drawable_id, gint32 drawable_id,
gpointer data) gpointer data)
{ {
GimpDrawable *drawable; GimpDrawable *drawable = data;
drawable = (GimpDrawable *) data; return (gimp_drawable_width (drawable_id) == drawable->width &&
if (drawable_id == -1)
return TRUE;
return (gimp_drawable_width (drawable_id) == drawable->width &&
gimp_drawable_height (drawable_id) == drawable->height); 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;
}