Commit 6c1d7329 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

plug-ins/winicon/icodialog.c ported GtkOptionMenu to GtkComboBox.

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

	* plug-ins/winicon/icodialog.c
	* plug-ins/winicon/icosave.c: ported GtkOptionMenu to GtkComboBox.
parent 947d6559
2004-04-18 Sven Neumann <sven@gimp.org>
* plug-ins/winicon/icodialog.c
* plug-ins/winicon/icosave.c: ported GtkOptionMenu to GtkComboBox.
2004-04-17 Sven Neumann <sven@gimp.org>
* app/widgets/gimpwidgets-constructors.[ch]:
......
......@@ -44,14 +44,8 @@
static GtkWidget *ico_preview_new (gint32 layer);
static void ico_fill_preview_with_thumb (GtkWidget *widget,
gint32 drawable_ID);
static void on_1bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox);
static void on_4bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox);
static void on_8bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox);
static void on_32bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox);
static void combo_bpp_changed (GtkWidget *combo,
GObject *hbox);
static GtkWidget *
......@@ -176,9 +170,7 @@ ico_create_icon_hbox (GtkWidget *icon_preview,
gint layer_num)
{
GtkWidget *hbox;
GtkWidget *optionmenu;
GtkWidget *optionmenu_menu;
GtkWidget *menuitem;
GtkWidget *combo;
hbox = gtk_hbox_new (FALSE, 0);
......@@ -194,47 +186,25 @@ ico_create_icon_hbox (GtkWidget *icon_preview,
gtk_widget_show (icon_preview);
gtk_box_pack_start (GTK_BOX (hbox), icon_preview, TRUE, TRUE, 0);
optionmenu = gtk_option_menu_new ();
g_object_set_data (G_OBJECT (hbox), "icon_optionmenu", optionmenu);
gtk_widget_show (optionmenu);
gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0);
optionmenu_menu = gtk_menu_new ();
menuitem =
gtk_menu_item_new_with_label (_("1 bpp, 1-bit alpha, 2-slot palette"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (on_1bpp_menu_selected),
hbox);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (optionmenu_menu), menuitem);
menuitem =
gtk_menu_item_new_with_label (_("4 bpp, 1-bit alpha, 16-slot palette"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (on_4bpp_menu_selected),
hbox);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (optionmenu_menu), menuitem);
menuitem =
gtk_menu_item_new_with_label (_("8 bpp, 1-bit alpha, 256-slot palette"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (on_8bpp_menu_selected),
hbox);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (optionmenu_menu), menuitem);
menuitem =
gtk_menu_item_new_with_label (_("32 bpp, 8-bit alpha, no palette"));
g_signal_connect (menuitem, "activate",
G_CALLBACK (on_32bpp_menu_selected),
combo = gtk_combo_box_new ();
g_object_set_data (G_OBJECT (hbox), "icon_menu", combo);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
gtk_widget_show (combo);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo),
_("1 bpp, 1-bit alpha, 2-slot palette"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo),
_("4 bpp, 1-bit alpha, 16-slot palette"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo),
_("8 bpp, 1-bit alpha, 256-slot palette"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo),
_("32 bpp, 8-bit alpha, no palette"));
g_signal_connect (combo, "changed",
G_CALLBACK (combo_bpp_changed),
hbox);
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (optionmenu_menu), menuitem);
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu),
optionmenu_menu);
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), 3);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 3);
return hbox;
}
......@@ -400,65 +370,38 @@ ico_specs_dialog_update_icon_preview (GtkWidget *dialog,
g_free (buffer);
}
/* meta-callback for color depth changes in an icon */
static void
on_bpp_change (GtkWidget *icon_hbox,
gint bpp)
combo_bpp_changed (GtkWidget *combo,
GObject *hbox)
{
GtkWidget *dialog;
GtkWidget *dialog = gtk_widget_get_toplevel (combo);
gint32 layer;
gint layer_num;
gint bpp;
gint *icon_depths;
dialog = gtk_widget_get_toplevel (icon_hbox);
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo)))
{
case 0: bpp = 1; break;
case 1: bpp = 4; break;
case 2: bpp = 8; break;
case 3: bpp = 32; break;
default:
return;
}
layer = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (icon_hbox),
"icon_layer"));
layer_num = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (icon_hbox),
"icon_layer_num"));
icon_depths = g_object_get_data (G_OBJECT (dialog), "icon_depths");
if (! icon_depths)
{
D(("Something's wrong -- can't get icon_depths array from dialog ...\n"));
D(("Something's wrong -- can't get icon_depths array from dialog\n"));
return;
}
layer = GPOINTER_TO_INT (g_object_get_data (hbox, "icon_layer"));
layer_num = GPOINTER_TO_INT (g_object_get_data (hbox, "icon_layer_num"));
/* Update vector entry for later when we're actually saving,
and update the preview right away ... */
icon_depths[layer_num] = bpp;
ico_specs_dialog_update_icon_preview (dialog, layer, bpp);
}
static void
on_1bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox)
{
on_bpp_change (icon_hbox, 1);
item = NULL;
}
static void
on_4bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox)
{
on_bpp_change (icon_hbox, 4);
item = NULL;
}
static void
on_8bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox)
{
on_bpp_change (icon_hbox, 8);
item = NULL;
}
static void
on_32bpp_menu_selected (GtkWidget *item,
GtkWidget *icon_hbox)
{
on_bpp_change (icon_hbox, 32);
item = NULL;
}
......@@ -122,7 +122,7 @@ ico_show_icon_dialog (gint32 image_ID,
gint *num_icons)
{
GtkWidget *dialog, *hbox;
GtkWidget *icon_optionmenu;
GtkWidget *icon_menu;
gint *layers, *icon_depths = NULL;
gint num_layers, i, num_colors;
gboolean uses_alpha_values;
......@@ -158,7 +158,7 @@ ico_show_icon_dialog (gint32 image_ID,
g_snprintf (key, MAXLEN, "layer_%i_hbox", layers[i]);
hbox = g_object_get_data (G_OBJECT (dialog), key);
icon_optionmenu = g_object_get_data (G_OBJECT(hbox), "icon_optionmenu");
icon_menu = g_object_get_data (G_OBJECT (hbox), "icon_menu");
if (!uses_alpha_values)
{
......@@ -168,7 +168,7 @@ ico_show_icon_dialog (gint32 image_ID,
icon_depths[i] = 1;
icon_depths[num_layers + i] = 1;
ico_specs_dialog_update_icon_preview (dialog, layers[i], 2);
gtk_option_menu_set_history (GTK_OPTION_MENU (icon_optionmenu), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (icon_menu), 0);
}
else if (num_colors <= 16)
{
......@@ -176,7 +176,7 @@ ico_show_icon_dialog (gint32 image_ID,
icon_depths[i] = 4;
icon_depths[num_layers + i] = 4;
ico_specs_dialog_update_icon_preview (dialog, layers[i], 4);
gtk_option_menu_set_history (GTK_OPTION_MENU (icon_optionmenu), 1);
gtk_combo_box_set_active (GTK_COMBO_BOX (icon_menu), 1);
}
else if (num_colors <= 256)
{
......@@ -184,7 +184,7 @@ ico_show_icon_dialog (gint32 image_ID,
icon_depths[i] = 8;
icon_depths[num_layers + i] = 8;
ico_specs_dialog_update_icon_preview (dialog, layers[i], 8);
gtk_option_menu_set_history (GTK_OPTION_MENU (icon_optionmenu), 2);
gtk_combo_box_set_active (GTK_COMBO_BOX (icon_menu), 2);
}
}
......
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