removed the check for first_label != NULL. Passing a NULL label makes a

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

	* libgimpwidgets/gimpintcombobox.c (gimp_int_combo_box_new):
	removed the check for first_label != NULL. Passing a NULL label
	makes a perfect empty combo_box.

	* plug-ins/common/newsprint.c
	* plug-ins/common/spheredesigner.c: ported from GtkOptioMenu to
	GimpIntComboBox.
This commit is contained in:
Sven Neumann 2004-04-22 01:27:30 +00:00 committed by Sven Neumann
parent e72a025671
commit 53b00093cb
4 changed files with 77 additions and 105 deletions

View File

@ -1,3 +1,13 @@
2004-04-22 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpintcombobox.c (gimp_int_combo_box_new):
removed the check for first_label != NULL. Passing a NULL label
makes a perfect empty combo_box.
* plug-ins/common/newsprint.c
* plug-ins/common/spheredesigner.c: ported from GtkOptioMenu to
GimpIntComboBox.
2004-04-22 Sven Neumann <sven@gimp.org> 2004-04-22 Sven Neumann <sven@gimp.org>
* plug-ins/flame/flame.c * plug-ins/flame/flame.c

View File

@ -112,8 +112,6 @@ gimp_int_combo_box_new (const gchar *first_label,
GtkWidget *combo_box; GtkWidget *combo_box;
va_list args; va_list args;
g_return_val_if_fail (first_label != NULL, NULL);
va_start (args, first_value); va_start (args, first_value);
combo_box = gimp_int_combo_box_new_valist (first_label, first_value, args); combo_box = gimp_int_combo_box_new_valist (first_label, first_value, args);
@ -146,8 +144,6 @@ gimp_int_combo_box_new_valist (const gchar *first_label,
const gchar *label; const gchar *label;
gint value; gint value;
g_return_val_if_fail (first_label != NULL, NULL);
store = gimp_int_store_new (); store = gimp_int_store_new ();
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX, combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,

View File

@ -90,7 +90,6 @@ static char rcsid[] = "$Id$";
#define ISNEG(x) (((x) < 0)? 1 : 0) #define ISNEG(x) (((x) < 0)? 1 : 0)
#define DEG2RAD(d) ((d) * G_PI / 180) #define DEG2RAD(d) ((d) * G_PI / 180)
#define VALID_BOOL(x) ((x) == TRUE || (x) == FALSE)
#define CLAMPED_ADD(a, b) (((a)+(b) > 0xff)? 0xff : (a) + (b)) #define CLAMPED_ADD(a, b) (((a)+(b) > 0xff)? 0xff : (a) + (b))
@ -190,7 +189,7 @@ static spot_info_t spotfn_list[] =
} }
}; };
#define NUM_SPOTFN ((sizeof(spotfn_list) / sizeof(spot_info_t)) - 1) #define NUM_SPOTFN (G_N_ELEMENTS (spotfn_list))
#define VALID_SPOTFN(x) ((x) >= 0 && (x) < NUM_SPOTFN) #define VALID_SPOTFN(x) ((x) >= 0 && (x) < NUM_SPOTFN)
#define THRESH(x,y) (thresh[(y)*width + (x)]) #define THRESH(x,y) (thresh[(y)*width + (x)])
#define THRESHn(n,x,y) ((thresh[n])[(y)*width + (x)]) #define THRESHn(n,x,y) ((thresh[n])[(y)*width + (x)])
@ -254,7 +253,7 @@ struct _channel_st
gint *spotfn_num; /* which spotfn the menu is controlling */ gint *spotfn_num; /* which spotfn the menu is controlling */
preview_st prev[3]; /* state for 3 preview widgets */ preview_st prev[3]; /* state for 3 preview widgets */
GtkObject *angle_adj; /* angle adjustment */ GtkObject *angle_adj; /* angle adjustment */
GtkWidget *option_menu; /* popup for spot function */ GtkWidget *combo; /* popup for spot function */
GtkWidget *menuitem[NUM_SPOTFN]; /* menuitems for each spot function */ GtkWidget *menuitem[NUM_SPOTFN]; /* menuitems for each spot function */
GtkWidget *ch_menuitem; /* menuitem for the channel selector */ GtkWidget *ch_menuitem; /* menuitem for the channel selector */
gint ch_menu_num; /* this channel's position in the selector */ gint ch_menu_num; /* this channel's position in the selector */
@ -795,9 +794,9 @@ static void
newsprint_menu_callback (GtkWidget *widget, newsprint_menu_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
channel_st *st = data; channel_st *st = data;
gint menufn; gint value;
static gint in_progress = FALSE; static gboolean in_progress = FALSE;
/* we shouldn't need recursion protection, but if lock_channels is /* we shouldn't need recursion protection, but if lock_channels is
* set, and gtk_option_menu_set_history ever generates an * set, and gtk_option_menu_set_history ever generates an
@ -810,10 +809,9 @@ newsprint_menu_callback (GtkWidget *widget,
in_progress = TRUE; in_progress = TRUE;
menufn = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value);
"gimp-item-data"));
*(st->spotfn_num) = menufn; *(st->spotfn_num) = value;
preview_update (st); preview_update (st);
@ -822,15 +820,15 @@ newsprint_menu_callback (GtkWidget *widget,
if (pvals_ui.lock_channels) if (pvals_ui.lock_channels)
{ {
channel_st *c = st->next; channel_st *c = st->next;
gint oldfn; gint old_value;
while (c != st) while (c != st)
{ {
gtk_option_menu_set_history (GTK_OPTION_MENU (c->option_menu), gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (c->combo), value);
menufn);
oldfn = *(c->spotfn_num); old_value = *(c->spotfn_num);
*(c->spotfn_num) = menufn; *(c->spotfn_num) = value;
if (oldfn != menufn) if (old_value != value)
preview_update (c); preview_update (c);
c = c->next; c = c->next;
} }
@ -965,9 +963,8 @@ newsprint_defaults_callback (GtkWidget *widget,
* question, in order to run the handler that re-computes * question, in order to run the handler that re-computes
* the preview area */ * the preview area */
spotfn = *(ct->factory_spotfn); spotfn = *(ct->factory_spotfn);
gtk_option_menu_set_history (GTK_OPTION_MENU (chst[c]->option_menu), gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (chst[c]->combo),
spotfn); spotfn);
gtk_menu_item_activate (GTK_MENU_ITEM (chst[c]->menuitem[spotfn]));
c++; c++;
ct++; ct++;
@ -988,7 +985,6 @@ new_channel (const chan_tmpl *ct)
GtkWidget *hbox2; GtkWidget *hbox2;
GtkWidget *abox; GtkWidget *abox;
GtkWidget *label; GtkWidget *label;
GtkWidget *menu;
spot_info_t *sf; spot_info_t *sf;
channel_st *chst; channel_st *chst;
gint i; gint i;
@ -1035,36 +1031,23 @@ new_channel (const chan_tmpl *ct)
gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
gtk_widget_show (label); gtk_widget_show (label);
chst->option_menu = gtk_option_menu_new (); chst->combo = gimp_int_combo_box_new (NULL, 0);
gtk_box_pack_start (GTK_BOX (hbox2), chst->option_menu, FALSE, FALSE, 0);
gtk_widget_show (chst->option_menu);
menu = gtk_menu_new (); for (sf = spotfn_list, i = 0; sf->name; sf++, i++)
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (chst->combo),
GIMP_INT_STORE_VALUE, i,
GIMP_INT_STORE_LABEL, gettext (sf->name),
-1);
sf = spotfn_list; gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (chst->combo),
i = 0; *ct->spotfn);
while (sf->name)
{
chst->menuitem[i] = gtk_menu_item_new_with_label (gettext (sf->name));
gtk_menu_shell_append (GTK_MENU_SHELL (menu),
GTK_WIDGET (chst->menuitem[i]));
gtk_widget_show (chst->menuitem[i]);
g_signal_connect (chst->menuitem[i], "activate", g_signal_connect (chst->combo, "changed",
G_CALLBACK (newsprint_menu_callback), G_CALLBACK (newsprint_menu_callback),
chst); chst);
g_object_set_data (G_OBJECT (chst->menuitem[i]), "gimp-item-data", gtk_box_pack_start (GTK_BOX (hbox2), chst->combo, FALSE, FALSE, 0);
GINT_TO_POINTER (i)); gtk_widget_show (chst->combo);
sf++;
i++;
}
gtk_menu_set_active (GTK_MENU (menu), *ct->spotfn);
gtk_option_menu_set_menu (GTK_OPTION_MENU (chst->option_menu), menu);
gtk_widget_show (chst->option_menu);
/* spot function previews */ /* spot function previews */
{ {

View File

@ -328,8 +328,6 @@ static GtkObject *scalescale;
static GtkObject *turbulencescale; static GtkObject *turbulencescale;
static GtkObject *amountscale; static GtkObject *amountscale;
static GtkObject *expscale; static GtkObject *expscale;
static GtkWidget *typemenu_menu;
static GtkWidget *texturemenu_menu;
static GtkWidget *typemenu; static GtkWidget *typemenu;
static GtkWidget *texturemenu; static GtkWidget *texturemenu;
@ -1844,13 +1842,14 @@ setvals (texture * t)
{ {
if (l->n == t->type) if (l->n == t->type)
{ {
gtk_option_menu_set_history (GTK_OPTION_MENU (texturemenu), gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (texturemenu),
l->index); l->index);
break; break;
} }
l++; l++;
} }
gtk_option_menu_set_history (GTK_OPTION_MENU (typemenu), t->majtype);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (typemenu), t->majtype);
noupdate = FALSE; noupdate = FALSE;
} }
@ -2281,33 +2280,39 @@ restartrender (void)
} }
static void static void
selecttexture (GtkWidget * wg, gpointer data) selecttexture (GtkWidget *widget,
gpointer data)
{ {
texture *t; texture *t;
gint n = GPOINTER_TO_INT (data);
if (noupdate) if (noupdate)
return; return;
t = currenttexture (); t = currenttexture ();
if (!t) if (!t)
return; return;
t->type = n;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &t->type);
relabel (); relabel ();
restartrender (); restartrender ();
} }
static void static void
selecttype (GtkWidget * wg, gpointer data) selecttype (GtkWidget *widget,
gpointer data)
{ {
texture *t; texture *t;
gint n = GPOINTER_TO_INT (data);
if (noupdate) if (noupdate)
return; return;
t = currenttexture (); t = currenttexture ();
if (!t) if (!t)
return; return;
t->majtype = n;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &t->majtype);
relabel (); relabel ();
restartrender (); restartrender ();
} }
@ -2343,23 +2348,6 @@ getscales (GtkWidget *widget,
t->translate.z = GTK_ADJUSTMENT (poszscale)->value; t->translate.z = GTK_ADJUSTMENT (poszscale)->value;
} }
static void
mktexturemenu (GtkWidget *texturemenu_menu)
{
GtkWidget *item;
struct textures_t *t;
t = textures;
while (t->s)
{
item = gtk_menu_item_new_with_label (gettext (t->s));
gtk_widget_show (item);
gtk_menu_shell_append (GTK_MENU_SHELL (texturemenu_menu), item);
g_signal_connect (item, "activate",
G_CALLBACK (selecttexture), GINT_TO_POINTER (t->n));
t++;
}
}
static void static void
color1_changed (GimpColorButton *button, color1_changed (GimpColorButton *button,
@ -2475,7 +2463,6 @@ makewindow (void)
GtkWidget *button; GtkWidget *button;
GtkWidget *label; GtkWidget *label;
GtkWidget *list; GtkWidget *list;
GtkWidget *item;
GtkWidget *_scalescale; GtkWidget *_scalescale;
GtkWidget *_rotscale; GtkWidget *_rotscale;
GtkWidget *_turbulencescale; GtkWidget *_turbulencescale;
@ -2851,41 +2838,37 @@ makewindow (void)
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0); GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
g_signal_connect (poszscale, "value_changed", G_CALLBACK (getscales), NULL); g_signal_connect (poszscale, "value_changed", G_CALLBACK (getscales), NULL);
typemenu = gtk_option_menu_new (); typemenu = gimp_int_combo_box_new (_("Texture"), 0,
gtk_widget_show (typemenu); _("Bump"), 1,
_("Light"), 2,
NULL);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (typemenu), 0,
G_CALLBACK (selecttype),
NULL);
gtk_table_attach (GTK_TABLE (table), typemenu, 1, 2, 0, 1, gtk_table_attach (GTK_TABLE (table), typemenu, 1, 2, 0, 1,
GTK_FILL | GTK_EXPAND, GTK_EXPAND, 0, 0); GTK_FILL | GTK_EXPAND, GTK_EXPAND, 0, 0);
typemenu_menu = gtk_menu_new (); gtk_widget_show (typemenu);
item = gtk_menu_item_new_with_label (_("Texture"));
gtk_widget_show (item);
g_signal_connect (item, "activate", G_CALLBACK (selecttype), NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (typemenu_menu), item);
item = gtk_menu_item_new_with_label (_("Bump")); texturemenu = gimp_int_combo_box_new (NULL, 0);
gtk_widget_show (item);
g_signal_connect (item, "activate",
G_CALLBACK (selecttype),
GINT_TO_POINTER (1));
gtk_menu_shell_append (GTK_MENU_SHELL (typemenu_menu), item);
item = gtk_menu_item_new_with_label (_("Light")); {
gtk_widget_show (item); struct textures_t *t;
g_signal_connect (item, "activate",
G_CALLBACK (selecttype),
GINT_TO_POINTER (2));
gtk_menu_shell_append (GTK_MENU_SHELL (typemenu_menu), item);
gtk_option_menu_set_menu (GTK_OPTION_MENU (typemenu), typemenu_menu); for (t = textures; t->s; t++)
gimp_int_combo_box_append (GIMP_INT_COMBO_BOX (texturemenu),
GIMP_INT_STORE_VALUE, t->n,
GIMP_INT_STORE_LABEL, gettext (t->s),
-1);
}
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (texturemenu), 0,
G_CALLBACK (selecttexture),
NULL);
texturemenu = gtk_option_menu_new ();
gtk_widget_show (texturemenu);
gtk_table_attach (GTK_TABLE (table), texturemenu, 1, 2, 1, 2, gtk_table_attach (GTK_TABLE (table), texturemenu, 1, 2, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0); GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
gtk_widget_show (texturemenu);
texturemenu_menu = gtk_menu_new ();
mktexturemenu (texturemenu_menu);
gtk_option_menu_set_menu (GTK_OPTION_MENU (texturemenu), texturemenu_menu);
label = gtk_label_new (_("Amount:")); label = gtk_label_new (_("Amount:"));
gtk_widget_show (label); gtk_widget_show (label);