Commit 53b00093 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

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.
parent e72a0256
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>
* plug-ins/flame/flame.c
......
......@@ -112,8 +112,6 @@ gimp_int_combo_box_new (const gchar *first_label,
GtkWidget *combo_box;
va_list args;
g_return_val_if_fail (first_label != NULL, NULL);
va_start (args, first_value);
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;
gint value;
g_return_val_if_fail (first_label != NULL, NULL);
store = gimp_int_store_new ();
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,
......
......@@ -90,7 +90,6 @@ static char rcsid[] = "$Id$";
#define ISNEG(x) (((x) < 0)? 1 : 0)
#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))
......@@ -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 THRESH(x,y) (thresh[(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 */
preview_st prev[3]; /* state for 3 preview widgets */
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 *ch_menuitem; /* menuitem for the channel selector */
gint ch_menu_num; /* this channel's position in the selector */
......@@ -795,9 +794,9 @@ static void
newsprint_menu_callback (GtkWidget *widget,
gpointer data)
{
channel_st *st = data;
gint menufn;
static gint in_progress = FALSE;
channel_st *st = data;
gint value;
static gboolean in_progress = FALSE;
/* we shouldn't need recursion protection, but if lock_channels is
* set, and gtk_option_menu_set_history ever generates an
......@@ -810,10 +809,9 @@ newsprint_menu_callback (GtkWidget *widget,
in_progress = TRUE;
menufn = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
"gimp-item-data"));
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value);
*(st->spotfn_num) = menufn;
*(st->spotfn_num) = value;
preview_update (st);
......@@ -822,15 +820,15 @@ newsprint_menu_callback (GtkWidget *widget,
if (pvals_ui.lock_channels)
{
channel_st *c = st->next;
gint oldfn;
gint old_value;
while (c != st)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (c->option_menu),
menufn);
oldfn = *(c->spotfn_num);
*(c->spotfn_num) = menufn;
if (oldfn != menufn)
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (c->combo), value);
old_value = *(c->spotfn_num);
*(c->spotfn_num) = value;
if (old_value != value)
preview_update (c);
c = c->next;
}
......@@ -965,9 +963,8 @@ newsprint_defaults_callback (GtkWidget *widget,
* question, in order to run the handler that re-computes
* the preview area */
spotfn = *(ct->factory_spotfn);
gtk_option_menu_set_history (GTK_OPTION_MENU (chst[c]->option_menu),
spotfn);
gtk_menu_item_activate (GTK_MENU_ITEM (chst[c]->menuitem[spotfn]));
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (chst[c]->combo),
spotfn);
c++;
ct++;
......@@ -988,7 +985,6 @@ new_channel (const chan_tmpl *ct)
GtkWidget *hbox2;
GtkWidget *abox;
GtkWidget *label;
GtkWidget *menu;
spot_info_t *sf;
channel_st *chst;
gint i;
......@@ -1035,36 +1031,23 @@ new_channel (const chan_tmpl *ct)
gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
gtk_widget_show (label);
chst->option_menu = gtk_option_menu_new ();
gtk_box_pack_start (GTK_BOX (hbox2), chst->option_menu, FALSE, FALSE, 0);
gtk_widget_show (chst->option_menu);
menu = gtk_menu_new ();
sf = spotfn_list;
i = 0;
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]);
chst->combo = gimp_int_combo_box_new (NULL, 0);
g_signal_connect (chst->menuitem[i], "activate",
G_CALLBACK (newsprint_menu_callback),
chst);
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);
g_object_set_data (G_OBJECT (chst->menuitem[i]), "gimp-item-data",
GINT_TO_POINTER (i));
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (chst->combo),
*ct->spotfn);
sf++;
i++;
}
gtk_menu_set_active (GTK_MENU (menu), *ct->spotfn);
g_signal_connect (chst->combo, "changed",
G_CALLBACK (newsprint_menu_callback),
chst);
gtk_option_menu_set_menu (GTK_OPTION_MENU (chst->option_menu), menu);
gtk_widget_show (chst->option_menu);
gtk_box_pack_start (GTK_BOX (hbox2), chst->combo, FALSE, FALSE, 0);
gtk_widget_show (chst->combo);
/* spot function previews */
{
......
......@@ -328,8 +328,6 @@ static GtkObject *scalescale;
static GtkObject *turbulencescale;
static GtkObject *amountscale;
static GtkObject *expscale;
static GtkWidget *typemenu_menu;
static GtkWidget *texturemenu_menu;
static GtkWidget *typemenu;
static GtkWidget *texturemenu;
......@@ -1844,13 +1842,14 @@ setvals (texture * t)
{
if (l->n == t->type)
{
gtk_option_menu_set_history (GTK_OPTION_MENU (texturemenu),
l->index);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (texturemenu),
l->index);
break;
}
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;
}
......@@ -2281,33 +2280,39 @@ restartrender (void)
}
static void
selecttexture (GtkWidget * wg, gpointer data)
selecttexture (GtkWidget *widget,
gpointer data)
{
texture *t;
gint n = GPOINTER_TO_INT (data);
if (noupdate)
return;
t = currenttexture ();
if (!t)
return;
t->type = n;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &t->type);
relabel ();
restartrender ();
}
static void
selecttype (GtkWidget * wg, gpointer data)
selecttype (GtkWidget *widget,
gpointer data)
{
texture *t;
gint n = GPOINTER_TO_INT (data);
if (noupdate)
return;
t = currenttexture ();
if (!t)
return;
t->majtype = n;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &t->majtype);
relabel ();
restartrender ();
}
......@@ -2343,23 +2348,6 @@ getscales (GtkWidget *widget,
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
color1_changed (GimpColorButton *button,
......@@ -2475,7 +2463,6 @@ makewindow (void)
GtkWidget *button;
GtkWidget *label;
GtkWidget *list;
GtkWidget *item;
GtkWidget *_scalescale;
GtkWidget *_rotscale;
GtkWidget *_turbulencescale;
......@@ -2851,41 +2838,37 @@ makewindow (void)
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
g_signal_connect (poszscale, "value_changed", G_CALLBACK (getscales), NULL);
typemenu = gtk_option_menu_new ();
gtk_widget_show (typemenu);
typemenu = gimp_int_combo_box_new (_("Texture"), 0,
_("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_FILL | GTK_EXPAND, GTK_EXPAND, 0, 0);
typemenu_menu = gtk_menu_new ();
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"));
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);
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);
texturemenu = gtk_option_menu_new ();
gtk_widget_show (texturemenu);
gtk_table_attach (GTK_TABLE (table), texturemenu, 1, 2, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
gtk_widget_show (typemenu);
texturemenu_menu = gtk_menu_new ();
mktexturemenu (texturemenu_menu);
texturemenu = gimp_int_combo_box_new (NULL, 0);
gtk_option_menu_set_menu (GTK_OPTION_MENU (texturemenu), texturemenu_menu);
{
struct textures_t *t;
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);
gtk_table_attach (GTK_TABLE (table), texturemenu, 1, 2, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
gtk_widget_show (texturemenu);
label = gtk_label_new (_("Amount:"));
gtk_widget_show (label);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment