added _with_range variants for all enum menu widgets that limit the range

2002-05-13  Sven Neumann  <sven@gimp.org>

	* app/widgets/gimpenummenu.[ch]: added _with_range variants for all
	enum menu widgets that limit the range of choices.

	* app/gui/file-new-dialog.c
	* app/gui/layers-commands.c
	* app/gui/preferences-dialog.c: use GimpEnumMenus with ranges.
This commit is contained in:
Sven Neumann 2002-05-13 17:15:17 +00:00 committed by Sven Neumann
parent 0172411138
commit a663c855ce
9 changed files with 230 additions and 72 deletions

View File

@ -1,3 +1,12 @@
2002-05-13 Sven Neumann <sven@gimp.org>
* app/widgets/gimpenummenu.[ch]: added _with_range variants for all
enum menu widgets that limit the range of choices.
* app/gui/file-new-dialog.c
* app/gui/layers-commands.c
* app/gui/preferences-dialog.c: use GimpEnumMenus with ranges.
2002-05-13 Sven Neumann <sven@gimp.org>
* app/core/core-enums.[ch]: uhh, skipping values used in the PDB

View File

@ -680,12 +680,14 @@ layers_new_layer_query (GimpImage *gimage,
gtk_widget_show (table);
/* The radio frame */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_FILL_TYPE,
gtk_label_new (_("Layer Fill Type")),
2,
G_CALLBACK (gimp_radio_button_update),
&options->fill_type,
&button);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
GIMP_FOREGROUND_FILL,
GIMP_TRANSPARENT_FILL,
gtk_label_new (_("Layer Fill Type")),
2,
G_CALLBACK (gimp_radio_button_update),
&options->fill_type,
&button);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
GINT_TO_POINTER (options->fill_type));

View File

@ -359,12 +359,13 @@ file_new_dialog_create (Gimp *gimp,
gtk_widget_show (hbox);
/* frame for Image Type */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_IMAGE_BASE_TYPE,
gtk_label_new (_("Image Type")),
2,
G_CALLBACK (file_new_image_type_callback),
info,
&info->type_w);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_IMAGE_BASE_TYPE,
GIMP_RGB, GIMP_GRAY,
gtk_label_new (_("Image Type")),
2,
G_CALLBACK (file_new_image_type_callback),
info,
&info->type_w);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->type_w),
GINT_TO_POINTER (info->values->type));
@ -372,12 +373,14 @@ file_new_dialog_create (Gimp *gimp,
gtk_widget_show (frame);
/* frame for Fill Type */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_FILL_TYPE,
gtk_label_new (_("Fill Type")),
2,
G_CALLBACK (file_new_fill_type_callback),
info,
&info->fill_type_w);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
GIMP_FOREGROUND_FILL,
GIMP_TRANSPARENT_FILL,
gtk_label_new (_("Fill Type")),
2,
G_CALLBACK (file_new_fill_type_callback),
info,
&info->fill_type_w);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->fill_type_w),
GINT_TO_POINTER (info->values->fill_type));

View File

@ -1962,15 +1962,12 @@ preferences_dialog_create (Gimp *gimp)
table = prefs_table_new (2, GTK_CONTAINER (vbox), TRUE);
optionmenu =
gimp_option_menu_new2 (FALSE,
G_CALLBACK (prefs_toggle_callback),
&gimp->config->default_type,
GINT_TO_POINTER (gimp->config->default_type),
_("RGB"), GINT_TO_POINTER (GIMP_RGB), NULL,
_("Grayscale"), GINT_TO_POINTER (GIMP_GRAY), NULL,
NULL);
gimp_enum_option_menu_new_with_range (GIMP_TYPE_IMAGE_BASE_TYPE,
GIMP_RGB, GIMP_GRAY,
G_CALLBACK (prefs_toggle_callback),
&gimp->config->default_type);
gimp_option_menu_set_history (GTK_OPTION_MENU (optionmenu),
GINT_TO_POINTER (gimp->config->default_type));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Default Image Type:"), 1.0, 0.5,

View File

@ -359,12 +359,13 @@ file_new_dialog_create (Gimp *gimp,
gtk_widget_show (hbox);
/* frame for Image Type */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_IMAGE_BASE_TYPE,
gtk_label_new (_("Image Type")),
2,
G_CALLBACK (file_new_image_type_callback),
info,
&info->type_w);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_IMAGE_BASE_TYPE,
GIMP_RGB, GIMP_GRAY,
gtk_label_new (_("Image Type")),
2,
G_CALLBACK (file_new_image_type_callback),
info,
&info->type_w);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->type_w),
GINT_TO_POINTER (info->values->type));
@ -372,12 +373,14 @@ file_new_dialog_create (Gimp *gimp,
gtk_widget_show (frame);
/* frame for Fill Type */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_FILL_TYPE,
gtk_label_new (_("Fill Type")),
2,
G_CALLBACK (file_new_fill_type_callback),
info,
&info->fill_type_w);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
GIMP_FOREGROUND_FILL,
GIMP_TRANSPARENT_FILL,
gtk_label_new (_("Fill Type")),
2,
G_CALLBACK (file_new_fill_type_callback),
info,
&info->fill_type_w);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (info->fill_type_w),
GINT_TO_POINTER (info->values->fill_type));

View File

@ -680,12 +680,14 @@ layers_new_layer_query (GimpImage *gimage,
gtk_widget_show (table);
/* The radio frame */
frame = gimp_enum_radio_frame_new (GIMP_TYPE_FILL_TYPE,
gtk_label_new (_("Layer Fill Type")),
2,
G_CALLBACK (gimp_radio_button_update),
&options->fill_type,
&button);
frame = gimp_enum_radio_frame_new_with_range (GIMP_TYPE_FILL_TYPE,
GIMP_FOREGROUND_FILL,
GIMP_TRANSPARENT_FILL,
gtk_label_new (_("Layer Fill Type")),
2,
G_CALLBACK (gimp_radio_button_update),
&options->fill_type,
&button);
gimp_radio_group_set_active (GTK_RADIO_BUTTON (button),
GINT_TO_POINTER (options->fill_type));

View File

@ -1962,15 +1962,12 @@ preferences_dialog_create (Gimp *gimp)
table = prefs_table_new (2, GTK_CONTAINER (vbox), TRUE);
optionmenu =
gimp_option_menu_new2 (FALSE,
G_CALLBACK (prefs_toggle_callback),
&gimp->config->default_type,
GINT_TO_POINTER (gimp->config->default_type),
_("RGB"), GINT_TO_POINTER (GIMP_RGB), NULL,
_("Grayscale"), GINT_TO_POINTER (GIMP_GRAY), NULL,
NULL);
gimp_enum_option_menu_new_with_range (GIMP_TYPE_IMAGE_BASE_TYPE,
GIMP_RGB, GIMP_GRAY,
G_CALLBACK (prefs_toggle_callback),
&gimp->config->default_type);
gimp_option_menu_set_history (GTK_OPTION_MENU (optionmenu),
GINT_TO_POINTER (gimp->config->default_type));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Default Image Type:"), 1.0, 0.5,

View File

@ -116,6 +116,30 @@ GtkWidget *
gimp_enum_menu_new (GType enum_type,
GCallback callback,
gpointer callback_data)
{
GEnumClass *enum_class;
GtkWidget *menu;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
enum_class = g_type_class_ref (enum_type);
menu = gimp_enum_menu_new_with_range (enum_type,
enum_class->minimum,
enum_class->maximum,
callback, callback_data);
g_type_class_unref (enum_class);
return menu;
}
GtkWidget *
gimp_enum_menu_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data)
{
GimpEnumMenu *menu;
GtkWidget *menu_item;
@ -129,6 +153,9 @@ gimp_enum_menu_new (GType enum_type,
for (value = menu->enum_class->values; value->value_name; value++)
{
if (value->value < minimum || value->value > maximum)
continue;
menu_item = gtk_menu_item_new_with_label (gettext (value->value_name));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
gtk_widget_show (menu_item);
@ -175,6 +202,28 @@ gimp_enum_option_menu_new (GType enum_type,
return option_menu;
}
GtkWidget *
gimp_enum_option_menu_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data)
{
GtkWidget *option_menu;
GtkWidget *menu;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
menu = gimp_enum_menu_new_with_range (enum_type,
minimum, maximum,
callback, callback_data);
option_menu = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
return option_menu;
}
/**
* gimp_enum_radio_box_new:
* @enum_type: the #GType of an enum.
@ -193,6 +242,32 @@ gimp_enum_radio_box_new (GType enum_type,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button)
{
GEnumClass *enum_class;
GtkWidget *vbox;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
enum_class = g_type_class_ref (enum_type);
vbox = gimp_enum_radio_box_new_with_range (enum_type,
enum_class->minimum,
enum_class->maximum,
callback, callback_data,
first_button);
g_type_class_unref (enum_class);
return vbox;
}
GtkWidget *
gimp_enum_radio_box_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button)
{
GtkWidget *vbox;
GtkWidget *button;
@ -208,12 +283,18 @@ gimp_enum_radio_box_new (GType enum_type,
g_object_weak_ref (G_OBJECT (vbox),
(GWeakNotify) g_type_class_unref, enum_class);
if (first_button)
*first_button = NULL;
for (value = enum_class->values; value->value_name; value++)
{
if (value->value < minimum || value->value > maximum)
continue;
button = gtk_radio_button_new_with_label (group,
gettext (value->value_name));
if (first_button && value == enum_class->values)
if (first_button && *first_button == NULL)
*first_button = button;
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
@ -280,3 +361,41 @@ gimp_enum_radio_frame_new (GType enum_type,
return frame;
}
GtkWidget *
gimp_enum_radio_frame_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GtkWidget *label_widget,
gint border_width,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button)
{
GtkWidget *frame;
GtkWidget *radio_box;
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
g_return_val_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget),
NULL);
frame = gtk_frame_new (NULL);
if (label_widget)
{
gtk_frame_set_label_widget (GTK_FRAME (frame), label_widget);
gtk_widget_show (label_widget);
}
radio_box = gimp_enum_radio_box_new_with_range (enum_type,
minimum,
maximum,
callback, callback_data,
first_button);
gtk_container_set_border_width (GTK_CONTAINER (radio_box), border_width);
gtk_container_add (GTK_CONTAINER (frame), radio_box);
gtk_widget_show (radio_box);
return frame;
}

View File

@ -48,25 +48,51 @@ struct _GimpEnumMenu
};
GType gimp_enum_menu_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_menu_new (GType enum_type,
GCallback callback,
gpointer callback_data);
GType gimp_enum_menu_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_enum_option_menu_new (GType enum_type,
GCallback callback,
gpointer callback_data);
GtkWidget * gimp_enum_menu_new (GType enum_type,
GCallback callback,
gpointer callback_data);
GtkWidget * gimp_enum_menu_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data);
GtkWidget * gimp_enum_radio_box_new (GType enum_type,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
GtkWidget * gimp_enum_radio_frame_new (GType enum_type,
GtkWidget *label_widget,
gint border_width,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
GtkWidget * gimp_enum_option_menu_new (GType enum_type,
GCallback callback,
gpointer callback_data);
GtkWidget * gimp_enum_option_menu_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data);
GtkWidget * gimp_enum_radio_box_new (GType enum_type,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
GtkWidget * gimp_enum_radio_box_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
GtkWidget * gimp_enum_radio_frame_new (GType enum_type,
GtkWidget *label_widget,
gint border_width,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
GtkWidget * gimp_enum_radio_frame_new_with_range (GType enum_type,
gint minimum,
gint maximum,
GtkWidget *label_widget,
gint border_width,
GCallback callback,
gpointer callback_data,
GtkWidget **first_button);
#endif /* __GIMP_ENUM_MENU_H__ */