use GtkAccelLabel when creating a menuitems label seperatedly.

Sun Jun  7 11:04:38 1998  Tim Janik  <timj@gtk.org>

        * app/gradient.c (cpopup_create_menu_item_with_label): use GtkAccelLabel
        when creating a menuitems label seperatedly.

        * app/commands.h:
        * app/commands.c:
        (tips_dialog_cmd_callback):
        (filters_repeat_cmd_callback):
        (tools_select_cmd_callback): make use of the callback_action argument.

        * app/main.c (main): removed gtk_accelerator_table_set_mod_mask(),
        since gtk provides decent default values now.

        * app/layers_dialog.c:
        * app/interface.c:
        * app/indexed_palette.c:
        * app/channels_dialog.c:
        * app/buildmenu.c:
        conversions for use of GtkAccelGroup.

        * app/buildmenu.c:
        * app/gradient.c:
        installed accelerators are locked, because these code portions don't
        support accelerator saving.

        * ChangeLog:
        * ChangeLog.pre-1-0: ChangeLog split up.
This commit is contained in:
Tim Janik 1998-06-07 13:55:36 +00:00 committed by Tim Janik
parent 0a2b3a44aa
commit 11269e1e69
33 changed files with 1627 additions and 5101 deletions

3354
ChangeLog

File diff suppressed because it is too large Load Diff

View File

@ -373,7 +373,6 @@ file_new_resolution_callback (GtkWidget *widget,
gchar *newvalue;
NewImageValues *vals;
float new_resolution;
float temp_units;
float temp_pixels;
char buffer[12];
@ -406,8 +405,9 @@ file_new_resolution_callback (GtkWidget *widget,
}
void
file_new_cmd_callback (GtkWidget *widget,
gpointer client_data)
file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay *gdisp;
NewImageValues *vals;
@ -418,7 +418,6 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *table;
GtkWidget *frame;
GtkWidget *radio_box;
GtkWidget *units_box;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *optionmenu;
@ -439,7 +438,7 @@ file_new_cmd_callback (GtkWidget *widget,
/* Before we try to determine the responsible gdisplay,
* make sure this wasn't called from the toolbox
*/
if ((long) client_data)
if (callback_action)
gdisp = gdisplay_active ();
else
gdisp = NULL;
@ -2621,13 +2620,14 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer client_data)
tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay * gdisp;
/* Activate the approriate widget */
gtk_widget_activate (tool_widgets[tool_info[(long) client_data].toolbar_position]);
gtk_widget_activate (tool_widgets[tool_info[callback_action].toolbar_position]);
gdisp = gdisplay_active ();
@ -2635,10 +2635,11 @@ tools_select_cmd_callback (GtkWidget *widget,
}
void
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer client_data)
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
plug_in_repeat ((long) client_data);
plug_in_repeat (callback_action);
}
void

View File

@ -4,7 +4,9 @@
#include "gtk/gtk.h"
void file_new_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
@ -80,8 +82,12 @@ void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *, gpointer);
void filters_repeat_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);

View File

@ -21,13 +21,13 @@
GtkWidget *
build_menu (MenuItem *items,
GtkAcceleratorTable *table)
GtkAccelGroup *accel_group)
{
GtkWidget *menu;
GtkWidget *menu_item;
menu = gtk_menu_new ();
gtk_menu_set_accelerator_table (GTK_MENU (menu), table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
while (items->label)
{
@ -41,12 +41,13 @@ build_menu (MenuItem *items,
menu_item = gtk_menu_item_new_with_label (items->label);
gtk_container_add (GTK_CONTAINER (menu), menu_item);
if (items->accelerator_key && table)
gtk_widget_install_accelerator (menu_item,
table,
"activate",
items->accelerator_key,
items->accelerator_mods);
if (items->accelerator_key && accel_group)
gtk_widget_add_accelerator (menu_item,
"activate",
accel_group,
items->accelerator_key,
items->accelerator_mods,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
}
if (items->callback)
@ -55,7 +56,7 @@ build_menu (MenuItem *items,
items->user_data);
if (items->subitems)
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), build_menu (items->subitems, table));
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_item), build_menu (items->subitems, accel_group));
gtk_widget_show (menu_item);
items->widget = menu_item;

View File

@ -31,9 +31,9 @@ typedef void (*MenuItemCallback) (GtkWidget *widget,
struct _MenuItem
{
char *label;
char accelerator_key;
int accelerator_mods;
gchar *label;
guint accelerator_key;
guint accelerator_mods;
MenuItemCallback callback;
gpointer user_data;
MenuItem *subitems;
@ -42,6 +42,6 @@ struct _MenuItem
/* Function declarations */
GtkWidget * build_menu (MenuItem *, GtkAcceleratorTable *);
GtkWidget * build_menu (MenuItem *, GtkAccelGroup *);
#endif /* BUILDMENU_H */

View File

@ -92,7 +92,7 @@ struct _ChannelsDialog {
GtkWidget *channel_list;
GtkWidget *preview;
GtkWidget *ops_menu;
GtkAcceleratorTable *accel_table;
GtkAccelGroup *accel_group;
int num_components;
int base_type;
@ -204,7 +204,7 @@ channels_dialog_create ()
channelsD->active_channel = NULL;
channelsD->floating_sel = NULL;
channelsD->channel_widgets = NULL;
channelsD->accel_table = gtk_accelerator_table_new ();
channelsD->accel_group = gtk_accel_group_new ();
if (preview_size)
{
@ -217,7 +217,7 @@ channels_dialog_create ()
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
/* The layers commands pulldown menu */
channelsD->ops_menu = build_menu (channels_ops, channelsD->accel_table);
channelsD->ops_menu = build_menu (channels_ops, channelsD->accel_group);
/* The channels listbox */
listbox = gtk_scrolled_window_new (NULL, NULL);
@ -830,8 +830,8 @@ channels_dialog_map_callback (GtkWidget *w,
if (!channelsD)
return;
gtk_window_add_accelerator_table (GTK_WINDOW (lc_shell),
channelsD->accel_table);
gtk_window_add_accel_group (GTK_WINDOW (lc_shell),
channelsD->accel_group);
}
static void
@ -841,8 +841,8 @@ channels_dialog_unmap_callback (GtkWidget *w,
if (!channelsD)
return;
gtk_window_remove_accelerator_table (GTK_WINDOW (lc_shell),
channelsD->accel_table);
gtk_window_remove_accel_group (GTK_WINDOW (lc_shell),
channelsD->accel_group);
}
static void

View File

@ -373,7 +373,6 @@ file_new_resolution_callback (GtkWidget *widget,
gchar *newvalue;
NewImageValues *vals;
float new_resolution;
float temp_units;
float temp_pixels;
char buffer[12];
@ -406,8 +405,9 @@ file_new_resolution_callback (GtkWidget *widget,
}
void
file_new_cmd_callback (GtkWidget *widget,
gpointer client_data)
file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay *gdisp;
NewImageValues *vals;
@ -418,7 +418,6 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *table;
GtkWidget *frame;
GtkWidget *radio_box;
GtkWidget *units_box;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *optionmenu;
@ -439,7 +438,7 @@ file_new_cmd_callback (GtkWidget *widget,
/* Before we try to determine the responsible gdisplay,
* make sure this wasn't called from the toolbox
*/
if ((long) client_data)
if (callback_action)
gdisp = gdisplay_active ();
else
gdisp = NULL;
@ -2621,13 +2620,14 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer client_data)
tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay * gdisp;
/* Activate the approriate widget */
gtk_widget_activate (tool_widgets[tool_info[(long) client_data].toolbar_position]);
gtk_widget_activate (tool_widgets[tool_info[callback_action].toolbar_position]);
gdisp = gdisplay_active ();
@ -2635,10 +2635,11 @@ tools_select_cmd_callback (GtkWidget *widget,
}
void
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer client_data)
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
plug_in_repeat ((long) client_data);
plug_in_repeat (callback_action);
}
void

View File

@ -4,7 +4,9 @@
#include "gtk/gtk.h"
void file_new_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
@ -80,8 +82,12 @@ void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *, gpointer);
void filters_repeat_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);

View File

@ -565,7 +565,7 @@ create_toolbox ()
GtkWidget *vbox;
GtkWidget *menubar;
GList *device_list;
GtkAcceleratorTable *table;
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
@ -626,7 +626,7 @@ create_toolbox ()
gtk_widget_show (menubar);
/* Install the accelerator table in the main window */
gtk_window_add_accelerator_table (GTK_WINDOW (window), table);
gtk_window_add_accel_group (GTK_WINDOW (window), table);
vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
@ -673,7 +673,7 @@ create_display_shell (int gdisp_id,
int type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkAcceleratorTable *image_accelerator_table = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *table;
int n_width, n_height;
@ -798,13 +798,13 @@ create_display_shell (int gdisp_id,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accelerator_table);
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* the accelerator table for images */
gtk_window_add_accelerator_table (GTK_WINDOW (gdisp->shell), image_accelerator_table);
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);

View File

@ -565,7 +565,7 @@ create_toolbox ()
GtkWidget *vbox;
GtkWidget *menubar;
GList *device_list;
GtkAcceleratorTable *table;
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
@ -626,7 +626,7 @@ create_toolbox ()
gtk_widget_show (menubar);
/* Install the accelerator table in the main window */
gtk_window_add_accelerator_table (GTK_WINDOW (window), table);
gtk_window_add_accel_group (GTK_WINDOW (window), table);
vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
@ -673,7 +673,7 @@ create_display_shell (int gdisp_id,
int type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkAcceleratorTable *image_accelerator_table = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *table;
int n_width, n_height;
@ -798,13 +798,13 @@ create_display_shell (int gdisp_id,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accelerator_table);
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* the accelerator table for images */
gtk_window_add_accelerator_table (GTK_WINDOW (gdisp->shell), image_accelerator_table);
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);

View File

@ -1339,7 +1339,7 @@ parse_menu_path (gpointer val1p,
goto error;
token = get_next_token ();
menus_add_path (menu_path, accelerator);
// FIXME menus_add_path (menu_path, accelerator);
return OK;

View File

@ -320,7 +320,7 @@ typedef struct {
GtkWidget *control_coloring_popup; /* Coloring type menu */
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
/* Blending and coloring menus */
@ -1015,7 +1015,7 @@ grad_create_gradient_editor(void)
g_editor->control_coloring_popup = NULL;
g_editor->control_sel_ops_popup = NULL;
g_editor->accelerator_table = NULL;
g_editor->accel_group = NULL;
for (i = 0;
i < (sizeof(g_editor->control_blending_items) / sizeof(g_editor->control_blending_items[0]));
@ -2871,16 +2871,15 @@ cpopup_create_main_menu(void)
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *label;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = gtk_accelerator_table_new();
accel_group = gtk_accel_group_new();
g_editor->accelerator_table = acc_table;
g_editor->accel_group = accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_menu_set_accel_group (GTK_MENU(menu), accel_group);
gtk_window_add_accel_group (GTK_WINDOW (g_editor->shell), accel_group);
/* Left endpoint */
@ -2891,7 +2890,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'L', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'L', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_left_load_popup = cpopup_create_load_menu(g_editor->left_load_color_boxes,
@ -2929,7 +2932,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'R', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'R', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_right_load_popup = cpopup_create_load_menu(g_editor->right_load_color_boxes,
@ -2988,7 +2995,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'S', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'S', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Split uniformly */
@ -2998,7 +3009,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'U', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'U', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Delete */
@ -3009,7 +3024,11 @@ cpopup_create_main_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_delete_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'D', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'D', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Recenter */
@ -3019,7 +3038,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Redistribute */
@ -3029,7 +3052,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Selection ops */
@ -3376,17 +3403,18 @@ static GtkWidget *
cpopup_create_menu_item_with_label(char *str, GtkWidget **label)
{
GtkWidget *menuitem;
GtkWidget *wlabel;
GtkWidget *accel_label;
menuitem = gtk_menu_item_new();
wlabel = gtk_label_new(str);
gtk_misc_set_alignment(GTK_MISC(wlabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), wlabel);
gtk_widget_show(wlabel);
accel_label = gtk_accel_label_new(str);
gtk_misc_set_alignment(GTK_MISC(accel_label), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menuitem);
gtk_widget_show(accel_label);
if (label)
*label = wlabel;
*label = accel_label;
return menuitem;
} /* cpopup_create_menu_item_with_label */
@ -3476,13 +3504,13 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
int i;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Create items */
@ -3502,23 +3530,32 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
gtk_widget_show(menuitem);
switch (i) {
case 0:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_0, accel_mods_0);
break;
case 1:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_1, accel_mods_1);
break;
case 2:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_2, accel_mods_2);
break;
default:
break;
case 0:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_0, accel_mods_0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 1:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_1, accel_mods_1,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 2:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_2, accel_mods_2,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
default:
break;
} /* switch */
} /* for */
@ -3886,12 +3923,12 @@ cpopup_create_sel_ops_menu(void)
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Flip */
@ -3901,7 +3938,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'F', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'F', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Replicate */
@ -3911,7 +3952,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'M', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'M', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Blend colors / opacity */
@ -3926,7 +3971,11 @@ cpopup_create_sel_ops_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_blend_colors_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Blend endpoints' opacity");
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
@ -3934,7 +3983,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
g_editor->control_blend_opacity_menu_item = menuitem;
return menu;

View File

@ -320,7 +320,7 @@ typedef struct {
GtkWidget *control_coloring_popup; /* Coloring type menu */
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
/* Blending and coloring menus */
@ -1015,7 +1015,7 @@ grad_create_gradient_editor(void)
g_editor->control_coloring_popup = NULL;
g_editor->control_sel_ops_popup = NULL;
g_editor->accelerator_table = NULL;
g_editor->accel_group = NULL;
for (i = 0;
i < (sizeof(g_editor->control_blending_items) / sizeof(g_editor->control_blending_items[0]));
@ -2871,16 +2871,15 @@ cpopup_create_main_menu(void)
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *label;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = gtk_accelerator_table_new();
accel_group = gtk_accel_group_new();
g_editor->accelerator_table = acc_table;
g_editor->accel_group = accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_menu_set_accel_group (GTK_MENU(menu), accel_group);
gtk_window_add_accel_group (GTK_WINDOW (g_editor->shell), accel_group);
/* Left endpoint */
@ -2891,7 +2890,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'L', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'L', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_left_load_popup = cpopup_create_load_menu(g_editor->left_load_color_boxes,
@ -2929,7 +2932,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'R', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'R', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_right_load_popup = cpopup_create_load_menu(g_editor->right_load_color_boxes,
@ -2988,7 +2995,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'S', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'S', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Split uniformly */
@ -2998,7 +3009,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'U', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'U', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Delete */
@ -3009,7 +3024,11 @@ cpopup_create_main_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_delete_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'D', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'D', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Recenter */
@ -3019,7 +3038,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Redistribute */
@ -3029,7 +3052,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Selection ops */
@ -3376,17 +3403,18 @@ static GtkWidget *
cpopup_create_menu_item_with_label(char *str, GtkWidget **label)
{
GtkWidget *menuitem;
GtkWidget *wlabel;
GtkWidget *accel_label;
menuitem = gtk_menu_item_new();
wlabel = gtk_label_new(str);
gtk_misc_set_alignment(GTK_MISC(wlabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), wlabel);
gtk_widget_show(wlabel);
accel_label = gtk_accel_label_new(str);
gtk_misc_set_alignment(GTK_MISC(accel_label), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menuitem);
gtk_widget_show(accel_label);
if (label)
*label = wlabel;
*label = accel_label;
return menuitem;
} /* cpopup_create_menu_item_with_label */
@ -3476,13 +3504,13 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
int i;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Create items */
@ -3502,23 +3530,32 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
gtk_widget_show(menuitem);
switch (i) {
case 0:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_0, accel_mods_0);
break;
case 1:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_1, accel_mods_1);
break;
case 2:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_2, accel_mods_2);
break;
default:
break;
case 0:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_0, accel_mods_0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 1:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_1, accel_mods_1,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 2:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_2, accel_mods_2,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
default:
break;
} /* switch */
} /* for */
@ -3886,12 +3923,12 @@ cpopup_create_sel_ops_menu(void)
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Flip */
@ -3901,7 +3938,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'F', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'F', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Replicate */
@ -3911,7 +3952,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'M', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'M', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Blend colors / opacity */
@ -3926,7 +3971,11 @@ cpopup_create_sel_ops_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_blend_colors_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Blend endpoints' opacity");
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
@ -3934,7 +3983,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
g_editor->control_blend_opacity_menu_item = menuitem;
return menu;

View File

@ -92,7 +92,7 @@ struct _ChannelsDialog {
GtkWidget *channel_list;
GtkWidget *preview;
GtkWidget *ops_menu;
GtkAcceleratorTable *accel_table;
GtkAccelGroup *accel_group;
int num_components;
int base_type;
@ -204,7 +204,7 @@ channels_dialog_create ()
channelsD->active_channel = NULL;
channelsD->floating_sel = NULL;
channelsD->channel_widgets = NULL;
channelsD->accel_table = gtk_accelerator_table_new ();
channelsD->accel_group = gtk_accel_group_new ();
if (preview_size)
{
@ -217,7 +217,7 @@ channels_dialog_create ()
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
/* The layers commands pulldown menu */
channelsD->ops_menu = build_menu (channels_ops, channelsD->accel_table);
channelsD->ops_menu = build_menu (channels_ops, channelsD->accel_group);
/* The channels listbox */
listbox = gtk_scrolled_window_new (NULL, NULL);
@ -830,8 +830,8 @@ channels_dialog_map_callback (GtkWidget *w,
if (!channelsD)
return;
gtk_window_add_accelerator_table (GTK_WINDOW (lc_shell),
channelsD->accel_table);
gtk_window_add_accel_group (GTK_WINDOW (lc_shell),
channelsD->accel_group);
}
static void
@ -841,8 +841,8 @@ channels_dialog_unmap_callback (GtkWidget *w,
if (!channelsD)
return;
gtk_window_remove_accelerator_table (GTK_WINDOW (lc_shell),
channelsD->accel_table);
gtk_window_remove_accel_group (GTK_WINDOW (lc_shell),
channelsD->accel_group);
}
static void

View File

@ -373,7 +373,6 @@ file_new_resolution_callback (GtkWidget *widget,
gchar *newvalue;
NewImageValues *vals;
float new_resolution;
float temp_units;
float temp_pixels;
char buffer[12];
@ -406,8 +405,9 @@ file_new_resolution_callback (GtkWidget *widget,
}
void
file_new_cmd_callback (GtkWidget *widget,
gpointer client_data)
file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay *gdisp;
NewImageValues *vals;
@ -418,7 +418,6 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *table;
GtkWidget *frame;
GtkWidget *radio_box;
GtkWidget *units_box;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *optionmenu;
@ -439,7 +438,7 @@ file_new_cmd_callback (GtkWidget *widget,
/* Before we try to determine the responsible gdisplay,
* make sure this wasn't called from the toolbox
*/
if ((long) client_data)
if (callback_action)
gdisp = gdisplay_active ();
else
gdisp = NULL;
@ -2621,13 +2620,14 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer client_data)
tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay * gdisp;
/* Activate the approriate widget */
gtk_widget_activate (tool_widgets[tool_info[(long) client_data].toolbar_position]);
gtk_widget_activate (tool_widgets[tool_info[callback_action].toolbar_position]);
gdisp = gdisplay_active ();
@ -2635,10 +2635,11 @@ tools_select_cmd_callback (GtkWidget *widget,
}
void
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer client_data)
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
plug_in_repeat ((long) client_data);
plug_in_repeat (callback_action);
}
void

View File

@ -4,7 +4,9 @@
#include "gtk/gtk.h"
void file_new_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
@ -80,8 +82,12 @@ void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *, gpointer);
void filters_repeat_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);

View File

@ -320,7 +320,7 @@ typedef struct {
GtkWidget *control_coloring_popup; /* Coloring type menu */
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
/* Blending and coloring menus */
@ -1015,7 +1015,7 @@ grad_create_gradient_editor(void)
g_editor->control_coloring_popup = NULL;
g_editor->control_sel_ops_popup = NULL;
g_editor->accelerator_table = NULL;
g_editor->accel_group = NULL;
for (i = 0;
i < (sizeof(g_editor->control_blending_items) / sizeof(g_editor->control_blending_items[0]));
@ -2871,16 +2871,15 @@ cpopup_create_main_menu(void)
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *label;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = gtk_accelerator_table_new();
accel_group = gtk_accel_group_new();
g_editor->accelerator_table = acc_table;
g_editor->accel_group = accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_menu_set_accel_group (GTK_MENU(menu), accel_group);
gtk_window_add_accel_group (GTK_WINDOW (g_editor->shell), accel_group);
/* Left endpoint */
@ -2891,7 +2890,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'L', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'L', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_left_load_popup = cpopup_create_load_menu(g_editor->left_load_color_boxes,
@ -2929,7 +2932,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'R', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'R', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_right_load_popup = cpopup_create_load_menu(g_editor->right_load_color_boxes,
@ -2988,7 +2995,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'S', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'S', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Split uniformly */
@ -2998,7 +3009,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'U', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'U', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Delete */
@ -3009,7 +3024,11 @@ cpopup_create_main_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_delete_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'D', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'D', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Recenter */
@ -3019,7 +3038,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Redistribute */
@ -3029,7 +3052,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Selection ops */
@ -3376,17 +3403,18 @@ static GtkWidget *
cpopup_create_menu_item_with_label(char *str, GtkWidget **label)
{
GtkWidget *menuitem;
GtkWidget *wlabel;
GtkWidget *accel_label;
menuitem = gtk_menu_item_new();
wlabel = gtk_label_new(str);
gtk_misc_set_alignment(GTK_MISC(wlabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), wlabel);
gtk_widget_show(wlabel);
accel_label = gtk_accel_label_new(str);
gtk_misc_set_alignment(GTK_MISC(accel_label), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menuitem);
gtk_widget_show(accel_label);
if (label)
*label = wlabel;
*label = accel_label;
return menuitem;
} /* cpopup_create_menu_item_with_label */
@ -3476,13 +3504,13 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
int i;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Create items */
@ -3502,23 +3530,32 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
gtk_widget_show(menuitem);
switch (i) {
case 0:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_0, accel_mods_0);
break;
case 1:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_1, accel_mods_1);
break;
case 2:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_2, accel_mods_2);
break;
default:
break;
case 0:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_0, accel_mods_0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 1:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_1, accel_mods_1,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 2:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_2, accel_mods_2,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
default:
break;
} /* switch */
} /* for */
@ -3886,12 +3923,12 @@ cpopup_create_sel_ops_menu(void)
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Flip */
@ -3901,7 +3938,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'F', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'F', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Replicate */
@ -3911,7 +3952,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'M', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'M', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Blend colors / opacity */
@ -3926,7 +3971,11 @@ cpopup_create_sel_ops_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_blend_colors_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Blend endpoints' opacity");
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
@ -3934,7 +3983,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
g_editor->control_blend_opacity_menu_item = menuitem;
return menu;

View File

@ -373,7 +373,6 @@ file_new_resolution_callback (GtkWidget *widget,
gchar *newvalue;
NewImageValues *vals;
float new_resolution;
float temp_units;
float temp_pixels;
char buffer[12];
@ -406,8 +405,9 @@ file_new_resolution_callback (GtkWidget *widget,
}
void
file_new_cmd_callback (GtkWidget *widget,
gpointer client_data)
file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay *gdisp;
NewImageValues *vals;
@ -418,7 +418,6 @@ file_new_cmd_callback (GtkWidget *widget,
GtkWidget *table;
GtkWidget *frame;
GtkWidget *radio_box;
GtkWidget *units_box;
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *optionmenu;
@ -439,7 +438,7 @@ file_new_cmd_callback (GtkWidget *widget,
/* Before we try to determine the responsible gdisplay,
* make sure this wasn't called from the toolbox
*/
if ((long) client_data)
if (callback_action)
gdisp = gdisplay_active ();
else
gdisp = NULL;
@ -2621,13 +2620,14 @@ tools_swap_colors_cmd_callback (GtkWidget *widget,
}
void
tools_select_cmd_callback (GtkWidget *widget,
gpointer client_data)
tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
GDisplay * gdisp;
/* Activate the approriate widget */
gtk_widget_activate (tool_widgets[tool_info[(long) client_data].toolbar_position]);
gtk_widget_activate (tool_widgets[tool_info[callback_action].toolbar_position]);
gdisp = gdisplay_active ();
@ -2635,10 +2635,11 @@ tools_select_cmd_callback (GtkWidget *widget,
}
void
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer client_data)
filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action)
{
plug_in_repeat ((long) client_data);
plug_in_repeat (callback_action);
}
void

View File

@ -4,7 +4,9 @@
#include "gtk/gtk.h"
void file_new_cmd_callback (GtkWidget *, gpointer);
void file_new_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void file_open_cmd_callback (GtkWidget *, gpointer);
void file_save_cmd_callback (GtkWidget *, gpointer);
void file_save_as_cmd_callback (GtkWidget *, gpointer);
@ -80,8 +82,12 @@ void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *, gpointer);
void filters_repeat_cmd_callback (GtkWidget *, gpointer);
void tools_select_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void filters_repeat_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
void dialogs_brushes_cmd_callback (GtkWidget *, gpointer);
void dialogs_patterns_cmd_callback (GtkWidget *, gpointer);
void dialogs_palette_cmd_callback (GtkWidget *, gpointer);

View File

@ -87,7 +87,7 @@ struct _LayersDialog {
GtkWidget *mode_box;
GtkWidget *opacity_box;
GtkWidget *ops_menu;
GtkAcceleratorTable *accel_table;
GtkAccelGroup *accel_group;
GtkAdjustment *opacity_data;
GdkGC *red_gc; /* for non-applied layer masks */
GdkGC *green_gc; /* for visible layer masks */
@ -629,7 +629,7 @@ layers_dialog_create ()
layersD->active_channel = NULL;
layersD->floating_sel = NULL;
layersD->layer_widgets = NULL;
layersD->accel_table = gtk_accelerator_table_new ();
layersD->accel_group = gtk_accel_group_new ();
layersD->green_gc = NULL;
layersD->red_gc = NULL;
@ -644,7 +644,7 @@ layers_dialog_create ()
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
/* The layers commands pulldown menu */
layersD->ops_menu = build_menu (layers_ops, layersD->accel_table);
layersD->ops_menu = build_menu (layers_ops, layersD->accel_group);
/* The Mode option menu, and the preserve transparency */
layersD->mode_box = util_box = gtk_hbox_new (FALSE, 1);
@ -1527,9 +1527,9 @@ layers_dialog_map_callback (GtkWidget *w,
{
if (!layersD)
return;
gtk_window_add_accelerator_table (GTK_WINDOW (lc_shell),
layersD->accel_table);
gtk_window_add_accel_group (GTK_WINDOW (lc_shell),
layersD->accel_group);
}
static void
@ -1538,9 +1538,9 @@ layers_dialog_unmap_callback (GtkWidget *w,
{
if (!layersD)
return;
gtk_window_remove_accelerator_table (GTK_WINDOW (lc_shell),
layersD->accel_table);
gtk_window_remove_accel_group (GTK_WINDOW (lc_shell),
layersD->accel_group);
}
static void

View File

@ -32,324 +32,298 @@
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
gpointer value,
gpointer user_data);
static gint menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path);
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static GtkMenuEntry menu_items[] =
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "<Toolbox>/File/New", "<control>N", file_new_cmd_callback, NULL },
{ "<Toolbox>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Toolbox>/File/About...", NULL, about_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Toolbox>/File/Tip of the day", NULL, tips_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>", NULL, NULL, NULL },
{ "<Toolbox>/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>",NULL,NULL,NULL},
{ "<Toolbox>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/New", "<control>N", file_new_cmd_callback, (gpointer) 1 },
{ "<Image>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Image>/File/Save", "<control>S", file_save_cmd_callback, NULL },
{ "<Image>/File/Save as", NULL, file_save_as_cmd_callback, NULL },
{ "<Image>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/File/Close", "<control>W", file_close_cmd_callback, NULL },
{ "<Image>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut", "<control>X", edit_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy", "<control>C", edit_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste", "<control>V", edit_paste_cmd_callback, NULL },
{ "<Image>/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, NULL },
{ "<Image>/Edit/Clear", "<control>K", edit_clear_cmd_callback, NULL },
{ "<Image>/Edit/Fill", "<control>.", edit_fill_cmd_callback, NULL },
{ "<Image>/Edit/Stroke", NULL, edit_stroke_cmd_callback, NULL },
{ "<Image>/Edit/Undo", "<control>Z", edit_undo_cmd_callback, NULL },
{ "<Image>/Edit/Redo", "<control>R", edit_redo_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Select/Toggle", "<control>T", select_toggle_cmd_callback, NULL },
{ "<Image>/Select/Invert", "<control>I", select_invert_cmd_callback, NULL },
{ "<Image>/Select/All", "<control>A", select_all_cmd_callback, NULL },
{ "<Image>/Select/None", "<control><shift>A", select_none_cmd_callback, NULL },
{ "<Image>/Select/Float", "<control><shift>L", select_float_cmd_callback, NULL },
{ "<Image>/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, NULL },
{ "<Image>/Select/Border", "<control><shift>B", select_border_cmd_callback, NULL },
{ "<Image>/Select/Feather", "<control><shift>F", select_feather_cmd_callback, NULL },
{ "<Image>/Select/Grow", NULL, select_grow_cmd_callback, NULL },
{ "<Image>/Select/Shrink", NULL, select_shrink_cmd_callback, NULL },
{ "<Image>/Select/Save To Channel", NULL, select_save_cmd_callback, NULL },
{ "<Image>/Select/By Color...", NULL, select_by_color_cmd_callback, NULL },
{ "<Image>/View/Zoom In", "=", view_zoomin_cmd_callback, NULL },
{ "<Image>/View/Zoom Out", "-", view_zoomout_cmd_callback, NULL },
{ "<Image>/View/Zoom/16:1", NULL, view_zoom_16_1_callback, NULL },
{ "<Image>/View/Zoom/8:1", NULL, view_zoom_8_1_callback, NULL },
{ "<Image>/View/Zoom/4:1", NULL, view_zoom_4_1_callback, NULL },
{ "<Image>/View/Zoom/2:1", NULL, view_zoom_2_1_callback, NULL },
{ "<Image>/View/Zoom/1:1", "1", view_zoom_1_1_callback, NULL },
{ "<Image>/View/Zoom/1:2", NULL, view_zoom_1_2_callback, NULL },
{ "<Image>/View/Zoom/1:4", NULL, view_zoom_1_4_callback, NULL },
{ "<Image>/View/Zoom/1:8", NULL, view_zoom_1_8_callback, NULL },
{ "<Image>/View/Zoom/1:16", NULL, view_zoom_1_16_callback, NULL },
{ "<Image>/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, NULL },
{ "<Image>/View/<check>Snap To Guides", NULL, view_snap_to_guides_cmd_callback, NULL },
{ "<Image>/View/<separator>", NULL, NULL, NULL },
{ "<Image>/View/New View", NULL, view_new_view_cmd_callback, NULL },
{ "<Image>/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, NULL },
{ "<Image>/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Invert", NULL, image_invert_cmd_callback, NULL },
{ "<Image>/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, NULL },
{ "<Image>/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, NULL },
{ "<Image>/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, NULL },
{ "<Image>/Image/Colors/Curves", NULL, image_curves_cmd_callback, NULL },
{ "<Image>/Image/Colors/Levels", NULL, image_levels_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, NULL },
{ "<Image>/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/RGB", NULL, image_convert_rgb_cmd_callback, NULL },
{ "<Image>/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, NULL },
{ "<Image>/Image/Indexed", NULL, image_convert_indexed_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Resize", NULL, image_resize_cmd_callback, NULL },
{ "<Image>/Image/Scale", NULL, image_scale_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Histogram", NULL, image_histogram_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, NULL },
{ "<Image>/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, NULL },
{ "<Image>/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, NULL },
{ "<Image>/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, NULL },
{ "<Image>/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, NULL },
{ "<Image>/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, NULL },
{ "<Image>/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, NULL },
{ "<Image>/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Tools/Rect Select", "R", tools_select_cmd_callback, (gpointer) RECT_SELECT },
{ "<Image>/Tools/Ellipse Select", "E", tools_select_cmd_callback, (gpointer) ELLIPSE_SELECT },
{ "<Image>/Tools/Free Select", "F", tools_select_cmd_callback, (gpointer) FREE_SELECT },
{ "<Image>/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, (gpointer) FUZZY_SELECT },
{ "<Image>/Tools/Bezier Select", "B", tools_select_cmd_callback, (gpointer) BEZIER_SELECT },
{ "<Image>/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, (gpointer) ISCISSORS },
{ "<Image>/Tools/Move", "M", tools_select_cmd_callback, (gpointer) MOVE },
{ "<Image>/Tools/Magnify", "<shift>M", tools_select_cmd_callback, (gpointer) MAGNIFY },
{ "<Image>/Tools/Crop", "<shift>C", tools_select_cmd_callback, (gpointer) CROP },
{ "<Image>/Tools/Transform", "<shift>T", tools_select_cmd_callback, (gpointer) ROTATE },
{ "<Image>/Tools/Flip", "<shift>F", tools_select_cmd_callback, (gpointer) FLIP_HORZ },
{ "<Image>/Tools/Text", "T", tools_select_cmd_callback, (gpointer) TEXT },
{ "<Image>/Tools/Color Picker", "O", tools_select_cmd_callback, (gpointer) COLOR_PICKER },
{ "<Image>/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, (gpointer) BUCKET_FILL },
{ "<Image>/Tools/Blend", "L", tools_select_cmd_callback, (gpointer) BLEND },
{ "<Image>/Tools/Paintbrush", "P", tools_select_cmd_callback, (gpointer) PAINTBRUSH },
{ "<Image>/Tools/Pencil", "<shift>P", tools_select_cmd_callback, (gpointer) PENCIL },
{ "<Image>/Tools/Eraser", "<shift>E", tools_select_cmd_callback, (gpointer) ERASER },
{ "<Image>/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH },
{ "<Image>/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE },
{ "<Image>/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE },
{ "<Image>/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL},
{ "<Image>/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL},
{ "<Image>/Tools/<separator>", NULL, NULL, NULL },
{ "<Image>/Tools/Toolbox", NULL, toolbox_raise_callback, NULL },
{ "<Image>/Filters/", NULL, NULL, NULL },
{ "<Image>/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, (gpointer) 0x0 },
{ "<Image>/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, (gpointer)
0x1 },
{ "<Image>/Filters/<separator>", NULL, NULL, NULL },
{ "<Image>/Script-Fu/", NULL, NULL, NULL },
{ "<Image>/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Image>/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Image>/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Image>/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, NULL },
{ "<Image>/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Image>/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Load>/Automatic", NULL, file_load_by_extension_callback, NULL },
{ "<Load>/<separator>", NULL, NULL, NULL },
{ "<Save>/By extension", NULL, file_save_by_extension_callback, NULL },
{ "<Save>/<separator>", NULL, NULL, NULL },
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/About...", NULL, about_dialog_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/Tip of the day", NULL, tips_dialog_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/Save", "<control>S", file_save_cmd_callback, 0 },
{ "/File/Save as", NULL, file_save_as_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Close", "<control>W", file_close_cmd_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/Edit/Cut", "<control>X", edit_cut_cmd_callback, 0 },
{ "/Edit/Copy", "<control>C", edit_copy_cmd_callback, 0 },
{ "/Edit/Paste", "<control>V", edit_paste_cmd_callback, 0 },
{ "/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, 0 },
{ "/Edit/Clear", "<control>K", edit_clear_cmd_callback, 0 },
{ "/Edit/Fill", "<control>.", edit_fill_cmd_callback, 0 },
{ "/Edit/Stroke", NULL, edit_stroke_cmd_callback, 0 },
{ "/Edit/Undo", "<control>Z", edit_undo_cmd_callback, 0 },
{ "/Edit/Redo", "<control>R", edit_redo_cmd_callback, 0 },
{ "/Edit/<Separator>", NULL, NULL, 0 },
{ "/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, 0 },
{ "/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, 0 },
{ "/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, 0 },
{ "/Edit/---", NULL, NULL, 0, "<Separator>" },
{ "/Select/Toggle", "<control>T", select_toggle_cmd_callback, 0 },
{ "/Select/Invert", "<control>I", select_invert_cmd_callback, 0 },
{ "/Select/All", "<control>A", select_all_cmd_callback, 0 },
{ "/Select/None", "<control><shift>A", select_none_cmd_callback, 0 },
{ "/Select/Float", "<control><shift>L", select_float_cmd_callback, 0 },
{ "/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, 0 },
{ "/Select/Border", "<control><shift>B", select_border_cmd_callback, 0 },
{ "/Select/Feather", "<control><shift>F", select_feather_cmd_callback, 0 },
{ "/Select/Grow", NULL, select_grow_cmd_callback, 0 },
{ "/Select/Shrink", NULL, select_shrink_cmd_callback, 0 },
{ "/Select/Save To Channel", NULL, select_save_cmd_callback, 0 },
{ "/Select/By Color...", NULL, select_by_color_cmd_callback, 0 },
{ "/View/Zoom In", "=", view_zoomin_cmd_callback, 0 },
{ "/View/Zoom Out", "-", view_zoomout_cmd_callback, 0 },
{ "/View/Zoom/16:1", NULL, view_zoom_16_1_callback, 0 },
{ "/View/Zoom/8:1", NULL, view_zoom_8_1_callback, 0 },
{ "/View/Zoom/4:1", NULL, view_zoom_4_1_callback, 0 },
{ "/View/Zoom/2:1", NULL, view_zoom_2_1_callback, 0 },
{ "/View/Zoom/1:1", "1", view_zoom_1_1_callback, 0 },
{ "/View/Zoom/1:2", NULL, view_zoom_1_2_callback, 0 },
{ "/View/Zoom/1:4", NULL, view_zoom_1_4_callback, 0 },
{ "/View/Zoom/1:8", NULL, view_zoom_1_8_callback, 0 },
{ "/View/Zoom/1:16", NULL, view_zoom_1_16_callback, 0 },
{ "/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, 0 },
{ "/View/Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Snap To Guides", NULL, view_snap_to_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/---", NULL, NULL, 0, "<Separator>" },
{ "/View/New View", NULL, view_new_view_cmd_callback, 0 },
{ "/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, 0 },
{ "/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, 0 },
{ "/Image/Colors/Invert", NULL, image_invert_cmd_callback, 0 },
{ "/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, 0 },
{ "/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, 0 },
{ "/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, 0 },
{ "/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, 0 },
{ "/Image/Colors/Curves", NULL, image_curves_cmd_callback, 0 },
{ "/Image/Colors/Levels", NULL, image_levels_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, 0 },
{ "/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, 0 },
{ "/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, 0 },
{ "/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/RGB", NULL, image_convert_rgb_cmd_callback, 0 },
{ "/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, 0 },
{ "/Image/Indexed", NULL, image_convert_indexed_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Resize", NULL, image_resize_cmd_callback, 0 },
{ "/Image/Scale", NULL, image_scale_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Histogram", NULL, image_histogram_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, 0 },
{ "/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, 0 },
{ "/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, 0 },
{ "/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, 0 },
{ "/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, 0 },
{ "/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, 0 },
{ "/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, 0 },
{ "/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Tools/Rect Select", "R", tools_select_cmd_callback, RECT_SELECT },
{ "/Tools/Ellipse Select", "E", tools_select_cmd_callback, ELLIPSE_SELECT },
{ "/Tools/Free Select", "F", tools_select_cmd_callback, FREE_SELECT },
{ "/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, FUZZY_SELECT },
{ "/Tools/Bezier Select", "B", tools_select_cmd_callback, BEZIER_SELECT },
{ "/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, ISCISSORS },
{ "/Tools/Move", "M", tools_select_cmd_callback, MOVE },
{ "/Tools/Magnify", "<shift>M", tools_select_cmd_callback, MAGNIFY },
{ "/Tools/Crop", "<shift>C", tools_select_cmd_callback, CROP },
{ "/Tools/Transform", "<shift>T", tools_select_cmd_callback, ROTATE },
{ "/Tools/Flip", "<shift>F", tools_select_cmd_callback, FLIP_HORZ },
{ "/Tools/Text", "T", tools_select_cmd_callback, TEXT },
{ "/Tools/Color Picker", "O", tools_select_cmd_callback, COLOR_PICKER },
{ "/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, BUCKET_FILL },
{ "/Tools/Blend", "L", tools_select_cmd_callback, BLEND },
{ "/Tools/Paintbrush", "P", tools_select_cmd_callback, PAINTBRUSH },
{ "/Tools/Pencil", "<shift>P", tools_select_cmd_callback, PENCIL },
{ "/Tools/Eraser", "<shift>E", tools_select_cmd_callback, ERASER },
{ "/Tools/Airbrush", "A", tools_select_cmd_callback, AIRBRUSH },
{ "/Tools/Clone", "C", tools_select_cmd_callback, CLONE },
{ "/Tools/Convolve", "V", tools_select_cmd_callback, CONVOLVE },
{ "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, 0 },
{ "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, 0 },
{ "/Tools/---", NULL, NULL, 0, "<Separator>" },
{ "/Tools/Toolbox", NULL, toolbox_raise_callback, 0 },
{ "/Filters/", NULL, NULL, 0 },
{ "/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, 0x0 },
{ "/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
{ "/Filters/---", NULL, NULL, 0, "<Separator>" },
{ "/Script-Fu/", NULL, NULL, 0 },
{ "/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, 0 },
{ "/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, 0 },
{ "/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
};
static guint n_image_entries = sizeof (image_entries) / sizeof (image_entries[0]);
static GtkItemFactory *image_factory = NULL;
static GtkItemFactoryEntry load_entries[] =
{
{ "/Automatic", NULL, file_load_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_load_entries = sizeof (load_entries) / sizeof (load_entries[0]);
static GtkItemFactory *load_factory = NULL;
static GtkItemFactoryEntry save_entries[] =
{
{ "/By extension", NULL, file_save_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_save_entries = sizeof (save_entries) / sizeof (save_entries[0]);
static GtkItemFactory *save_factory = NULL;
static int initialize = TRUE;
static GtkMenuFactory *factory = NULL;
static GtkMenuFactory *subfactories[4];
static GHashTable *entry_ht = NULL;
void
menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menubar)
*menubar = subfactories[0]->widget;
if (table)
*table = subfactories[0]->table;
*menubar = toolbox_factory->widget;
if (accel_group)
*accel_group = toolbox_factory->accel_group;
}
void
menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[1]->widget;
if (table)
*table = subfactories[1]->table;
*menu = image_factory->widget;
if (accel_group)
*accel_group = image_factory->accel_group;
}
void
menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[2]->widget;
if (table)
*table = subfactories[2]->table;
*menu = load_factory->widget;
if (accel_group)
*accel_group = load_factory->accel_group;
}
void
menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[3]->widget;
if (table)
*table = subfactories[3]->table;
*menu = save_factory->widget;
if (accel_group)
*accel_group = save_factory->accel_group;
}
void
menus_create (GtkMenuEntry *entries,
int nmenu_entries)
{
char *accelerator;
int i;
if (initialize)
menus_init ();
if (entry_ht)
for (i = 0; i < nmenu_entries; i++)
{
accelerator = g_hash_table_lookup (entry_ht, entries[i].path);
if (accelerator)
{
if (accelerator[0] == '\0')
entries[i].accelerator = NULL;
else
entries[i].accelerator = accelerator;
}
}
gtk_menu_factory_add_entries (factory, entries, nmenu_entries);
for (i = 0; i < nmenu_entries; i++)
if (entries[i].widget && GTK_BIN (entries[i].widget)->child)
{
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "install_accelerator",
(GtkSignalFunc) menus_install_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
}
gtk_item_factory_create_menu_entries (nmenu_entries, entries);
}
void
menus_set_sensitive (char *path,
int sensitive)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
gtk_widget_set_sensitive (menu_path->widget, sensitive);
else
g_message ("Unable to set sensitivity for menu which doesn't exist: %s", path);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
gtk_widget_set_sensitive (widget, sensitive);
}
if (!ifactory || !widget)
printf ("Unable to set sensitivity for menu which doesn't exist:\n%s", path);
}
void
menus_set_state (char *path,
int state)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
if (GTK_IS_CHECK_MENU_ITEM (menu_path->widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_path->widget), state);
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
}
else
g_message ("Unable to set state for menu which doesn't exist: %s", path);
}
void
menus_add_path (char *path,
char *accelerator)
{
if (!entry_ht)
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, accelerator);
if (!ifactory || !widget)
printf ("Unable to set state for menu which doesn't exist:\n%s", path);
}
void
@ -358,35 +332,24 @@ menus_destroy (char *path)
if (initialize)
menus_init ();
gtk_menu_factory_remove_paths (factory, &path, 1);
gtk_item_factories_path_delete (NULL, path);
}
void
menus_quit ()
{
FILE *fp;
char filename[512];
char *gimp_dir;
gchar *filename;
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_dump_rc (filename, NULL, TRUE);
g_free (filename);
if (entry_ht)
{
gimp_dir = gimp_directory ();
if ('\000' != gimp_dir[0])
{
sprintf (filename, "%s/menurc", gimp_dir);
fp = fopen (filename, "w");
if (fp)
{
g_hash_table_foreach (entry_ht, menus_foreach, fp);
fclose (fp);
}
}
}
if (!initialize)
{
gtk_menu_factory_destroy (factory);
gtk_object_destroy (GTK_OBJECT (toolbox_factory));
gtk_object_destroy (GTK_OBJECT (image_factory));
gtk_object_destroy (GTK_OBJECT (load_factory));
gtk_object_destroy (GTK_OBJECT (save_factory));
}
}
@ -395,101 +358,35 @@ menus_quit ()
static void
menus_init ()
{
char filename[512];
if (initialize)
{
gchar *filename;
initialize = FALSE;
factory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
image_entries,
NULL, 2);
load_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Load>", NULL);
gtk_item_factory_create_items_ac (load_factory,
n_load_entries,
load_entries,
NULL, 2);
save_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Save>", NULL);
gtk_item_factory_create_items_ac (save_factory,
n_save_entries,
save_entries,
NULL, 2);
subfactories[0] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
gtk_menu_factory_add_subfactory (factory, subfactories[0], "<Toolbox>");
subfactories[1] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[1], "<Image>");
subfactories[2] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[2], "<Load>");
subfactories[3] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[3], "<Save>");
sprintf (filename, "%s/menurc", gimp_directory ());
parse_gimprc_file (filename);
menus_create (menu_items, nmenu_items);
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_parse_rc (filename);
g_free (filename);
}
}
static void
menus_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
char accel[64];
int i, j;
for (i = j = 0; ((char*) value)[i] != '\0'; i++, j++)
{
if (((char *) value)[i] == '"' || ((char *) value)[i] == '\\')
accel[j++] = '\\';
accel[j] = ((char *) value)[i];
}
accel[j] = '\0';
fprintf ((FILE*) user_data, "(menu-path \"%s\" \"%s\")\n", (char*) key, accel);
}
static gint
menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path)
{
char accel[64];
char *t1, t2[2];
accel[0] = '\0';
if (modifiers & GDK_CONTROL_MASK)
strcat (accel, "<control>");
if (modifiers & GDK_SHIFT_MASK)
strcat (accel, "<shift>");
if (modifiers & GDK_MOD1_MASK)
strcat (accel, "<alt>");
t2[0] = key;
t2[1] = '\0';
strcat (accel, t2);
if (entry_ht)
{
t1 = g_hash_table_lookup (entry_ht, path);
g_free (t1);
}
else
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, g_strdup (accel));
return TRUE;
}
static void
menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path)
{
char *t;
if (entry_ht)
{
t = g_hash_table_lookup (entry_ht, path);
g_free (t);
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}

View File

@ -23,21 +23,19 @@
void menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_create (GtkMenuEntry *entries,
int nmenu_entries);
void menus_set_sensitive (char *path,
int sensitive);
void menus_set_state (char *path,
int state);
void menus_add_path (char *path,
char *accelerator);
void menus_destroy (char *path);
void menus_quit (void);

View File

@ -119,7 +119,7 @@ indexed_palette_create (int gimage_id)
GtkWidget *menu_bar;
GtkWidget *menu_bar_item;
GtkWidget *hbox;
GtkAcceleratorTable *table;
GtkAccelGroup *accel_group;
int default_index;
if (!indexedP)
@ -127,14 +127,14 @@ indexed_palette_create (int gimage_id)
indexedP = g_malloc (sizeof (IndexedPalette));
indexedP->gimage_id = -1;
table = gtk_accelerator_table_new ();
accel_group = gtk_accel_group_new ();
/* The shell and main vbox */
indexedP->shell = gtk_dialog_new ();
gtk_window_set_wmclass (GTK_WINDOW (indexedP->shell), "indexed_color_palette", "Gimp");
gtk_window_set_policy (GTK_WINDOW (indexedP->shell), FALSE, FALSE, FALSE);
gtk_window_set_title (GTK_WINDOW (indexedP->shell), "Indexed Color Palette");
gtk_window_add_accelerator_table (GTK_WINDOW (indexedP->shell), table);
gtk_window_add_accel_group (GTK_WINDOW (indexedP->shell), accel_group);
gtk_signal_connect (GTK_OBJECT (indexedP->shell), "delete_event",
GTK_SIGNAL_FUNC (gtk_widget_hide_on_delete),
NULL);
@ -161,7 +161,7 @@ indexed_palette_create (int gimage_id)
gtk_widget_show (label);
/* The indexed palette commands pulldown menu */
ops_menu = build_menu (indexed_color_ops, table);
ops_menu = build_menu (indexed_color_ops, accel_group);
menu_bar = gtk_menu_bar_new ();
gtk_box_pack_start (GTK_BOX (util_box), menu_bar, FALSE, FALSE, 2);

View File

@ -565,7 +565,7 @@ create_toolbox ()
GtkWidget *vbox;
GtkWidget *menubar;
GList *device_list;
GtkAcceleratorTable *table;
GtkAccelGroup *table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_wmclass (GTK_WINDOW (window), "toolbox", "Gimp");
@ -626,7 +626,7 @@ create_toolbox ()
gtk_widget_show (menubar);
/* Install the accelerator table in the main window */
gtk_window_add_accelerator_table (GTK_WINDOW (window), table);
gtk_window_add_accel_group (GTK_WINDOW (window), table);
vbox = gtk_vbox_new (FALSE, 1);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, TRUE, TRUE, 0);
@ -673,7 +673,7 @@ create_display_shell (int gdisp_id,
int type)
{
static GtkWidget *image_popup_menu = NULL;
static GtkAcceleratorTable *image_accelerator_table = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *table;
int n_width, n_height;
@ -798,13 +798,13 @@ create_display_shell (int gdisp_id,
GTK_FILL, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
if (! image_popup_menu)
menus_get_image_menu (&image_popup_menu, &image_accelerator_table);
menus_get_image_menu (&image_popup_menu, &image_accel_group);
/* the popup menu */
gdisp->popup = image_popup_menu;
/* the accelerator table for images */
gtk_window_add_accelerator_table (GTK_WINDOW (gdisp->shell), image_accelerator_table);
gtk_window_add_accel_group (GTK_WINDOW (gdisp->shell), image_accel_group);
gtk_widget_show (gdisp->hsb);
gtk_widget_show (gdisp->vsb);

View File

@ -87,7 +87,7 @@ struct _LayersDialog {
GtkWidget *mode_box;
GtkWidget *opacity_box;
GtkWidget *ops_menu;
GtkAcceleratorTable *accel_table;
GtkAccelGroup *accel_group;
GtkAdjustment *opacity_data;
GdkGC *red_gc; /* for non-applied layer masks */
GdkGC *green_gc; /* for visible layer masks */
@ -629,7 +629,7 @@ layers_dialog_create ()
layersD->active_channel = NULL;
layersD->floating_sel = NULL;
layersD->layer_widgets = NULL;
layersD->accel_table = gtk_accelerator_table_new ();
layersD->accel_group = gtk_accel_group_new ();
layersD->green_gc = NULL;
layersD->red_gc = NULL;
@ -644,7 +644,7 @@ layers_dialog_create ()
gtk_container_border_width (GTK_CONTAINER (vbox), 2);
/* The layers commands pulldown menu */
layersD->ops_menu = build_menu (layers_ops, layersD->accel_table);
layersD->ops_menu = build_menu (layers_ops, layersD->accel_group);
/* The Mode option menu, and the preserve transparency */
layersD->mode_box = util_box = gtk_hbox_new (FALSE, 1);
@ -1527,9 +1527,9 @@ layers_dialog_map_callback (GtkWidget *w,
{
if (!layersD)
return;
gtk_window_add_accelerator_table (GTK_WINDOW (lc_shell),
layersD->accel_table);
gtk_window_add_accel_group (GTK_WINDOW (lc_shell),
layersD->accel_group);
}
static void
@ -1538,9 +1538,9 @@ layers_dialog_unmap_callback (GtkWidget *w,
{
if (!layersD)
return;
gtk_window_remove_accelerator_table (GTK_WINDOW (lc_shell),
layersD->accel_table);
gtk_window_remove_accel_group (GTK_WINDOW (lc_shell),
layersD->accel_group);
}
static void

View File

@ -90,9 +90,10 @@ main (int argc, char **argv)
gtk_set_locale ();
setlocale(LC_NUMERIC, "C"); /* must use dot, not comma, as decimal separator */
gtk_init (&argc, &argv);
gtk_accelerator_table_set_mod_mask (NULL, GDK_SHIFT_MASK |
GDK_CONTROL_MASK |
GDK_MOD1_MASK);
#ifdef HAVE_LIBGLE
gle_init (&argc, &argv);
#endif /* !HAVE_LIBGLE */
display_name = gdk_get_display ();
display_env = g_new (gchar, strlen (display_name) + 9);

View File

@ -32,324 +32,298 @@
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
gpointer value,
gpointer user_data);
static gint menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path);
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static GtkMenuEntry menu_items[] =
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "<Toolbox>/File/New", "<control>N", file_new_cmd_callback, NULL },
{ "<Toolbox>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Toolbox>/File/About...", NULL, about_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Toolbox>/File/Tip of the day", NULL, tips_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>", NULL, NULL, NULL },
{ "<Toolbox>/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>",NULL,NULL,NULL},
{ "<Toolbox>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/New", "<control>N", file_new_cmd_callback, (gpointer) 1 },
{ "<Image>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Image>/File/Save", "<control>S", file_save_cmd_callback, NULL },
{ "<Image>/File/Save as", NULL, file_save_as_cmd_callback, NULL },
{ "<Image>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/File/Close", "<control>W", file_close_cmd_callback, NULL },
{ "<Image>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut", "<control>X", edit_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy", "<control>C", edit_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste", "<control>V", edit_paste_cmd_callback, NULL },
{ "<Image>/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, NULL },
{ "<Image>/Edit/Clear", "<control>K", edit_clear_cmd_callback, NULL },
{ "<Image>/Edit/Fill", "<control>.", edit_fill_cmd_callback, NULL },
{ "<Image>/Edit/Stroke", NULL, edit_stroke_cmd_callback, NULL },
{ "<Image>/Edit/Undo", "<control>Z", edit_undo_cmd_callback, NULL },
{ "<Image>/Edit/Redo", "<control>R", edit_redo_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Select/Toggle", "<control>T", select_toggle_cmd_callback, NULL },
{ "<Image>/Select/Invert", "<control>I", select_invert_cmd_callback, NULL },
{ "<Image>/Select/All", "<control>A", select_all_cmd_callback, NULL },
{ "<Image>/Select/None", "<control><shift>A", select_none_cmd_callback, NULL },
{ "<Image>/Select/Float", "<control><shift>L", select_float_cmd_callback, NULL },
{ "<Image>/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, NULL },
{ "<Image>/Select/Border", "<control><shift>B", select_border_cmd_callback, NULL },
{ "<Image>/Select/Feather", "<control><shift>F", select_feather_cmd_callback, NULL },
{ "<Image>/Select/Grow", NULL, select_grow_cmd_callback, NULL },
{ "<Image>/Select/Shrink", NULL, select_shrink_cmd_callback, NULL },
{ "<Image>/Select/Save To Channel", NULL, select_save_cmd_callback, NULL },
{ "<Image>/Select/By Color...", NULL, select_by_color_cmd_callback, NULL },
{ "<Image>/View/Zoom In", "=", view_zoomin_cmd_callback, NULL },
{ "<Image>/View/Zoom Out", "-", view_zoomout_cmd_callback, NULL },
{ "<Image>/View/Zoom/16:1", NULL, view_zoom_16_1_callback, NULL },
{ "<Image>/View/Zoom/8:1", NULL, view_zoom_8_1_callback, NULL },
{ "<Image>/View/Zoom/4:1", NULL, view_zoom_4_1_callback, NULL },
{ "<Image>/View/Zoom/2:1", NULL, view_zoom_2_1_callback, NULL },
{ "<Image>/View/Zoom/1:1", "1", view_zoom_1_1_callback, NULL },
{ "<Image>/View/Zoom/1:2", NULL, view_zoom_1_2_callback, NULL },
{ "<Image>/View/Zoom/1:4", NULL, view_zoom_1_4_callback, NULL },
{ "<Image>/View/Zoom/1:8", NULL, view_zoom_1_8_callback, NULL },
{ "<Image>/View/Zoom/1:16", NULL, view_zoom_1_16_callback, NULL },
{ "<Image>/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, NULL },
{ "<Image>/View/<check>Snap To Guides", NULL, view_snap_to_guides_cmd_callback, NULL },
{ "<Image>/View/<separator>", NULL, NULL, NULL },
{ "<Image>/View/New View", NULL, view_new_view_cmd_callback, NULL },
{ "<Image>/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, NULL },
{ "<Image>/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Invert", NULL, image_invert_cmd_callback, NULL },
{ "<Image>/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, NULL },
{ "<Image>/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, NULL },
{ "<Image>/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, NULL },
{ "<Image>/Image/Colors/Curves", NULL, image_curves_cmd_callback, NULL },
{ "<Image>/Image/Colors/Levels", NULL, image_levels_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, NULL },
{ "<Image>/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/RGB", NULL, image_convert_rgb_cmd_callback, NULL },
{ "<Image>/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, NULL },
{ "<Image>/Image/Indexed", NULL, image_convert_indexed_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Resize", NULL, image_resize_cmd_callback, NULL },
{ "<Image>/Image/Scale", NULL, image_scale_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Histogram", NULL, image_histogram_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, NULL },
{ "<Image>/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, NULL },
{ "<Image>/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, NULL },
{ "<Image>/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, NULL },
{ "<Image>/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, NULL },
{ "<Image>/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, NULL },
{ "<Image>/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, NULL },
{ "<Image>/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Tools/Rect Select", "R", tools_select_cmd_callback, (gpointer) RECT_SELECT },
{ "<Image>/Tools/Ellipse Select", "E", tools_select_cmd_callback, (gpointer) ELLIPSE_SELECT },
{ "<Image>/Tools/Free Select", "F", tools_select_cmd_callback, (gpointer) FREE_SELECT },
{ "<Image>/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, (gpointer) FUZZY_SELECT },
{ "<Image>/Tools/Bezier Select", "B", tools_select_cmd_callback, (gpointer) BEZIER_SELECT },
{ "<Image>/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, (gpointer) ISCISSORS },
{ "<Image>/Tools/Move", "M", tools_select_cmd_callback, (gpointer) MOVE },
{ "<Image>/Tools/Magnify", "<shift>M", tools_select_cmd_callback, (gpointer) MAGNIFY },
{ "<Image>/Tools/Crop", "<shift>C", tools_select_cmd_callback, (gpointer) CROP },
{ "<Image>/Tools/Transform", "<shift>T", tools_select_cmd_callback, (gpointer) ROTATE },
{ "<Image>/Tools/Flip", "<shift>F", tools_select_cmd_callback, (gpointer) FLIP_HORZ },
{ "<Image>/Tools/Text", "T", tools_select_cmd_callback, (gpointer) TEXT },
{ "<Image>/Tools/Color Picker", "O", tools_select_cmd_callback, (gpointer) COLOR_PICKER },
{ "<Image>/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, (gpointer) BUCKET_FILL },
{ "<Image>/Tools/Blend", "L", tools_select_cmd_callback, (gpointer) BLEND },
{ "<Image>/Tools/Paintbrush", "P", tools_select_cmd_callback, (gpointer) PAINTBRUSH },
{ "<Image>/Tools/Pencil", "<shift>P", tools_select_cmd_callback, (gpointer) PENCIL },
{ "<Image>/Tools/Eraser", "<shift>E", tools_select_cmd_callback, (gpointer) ERASER },
{ "<Image>/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH },
{ "<Image>/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE },
{ "<Image>/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE },
{ "<Image>/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL},
{ "<Image>/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL},
{ "<Image>/Tools/<separator>", NULL, NULL, NULL },
{ "<Image>/Tools/Toolbox", NULL, toolbox_raise_callback, NULL },
{ "<Image>/Filters/", NULL, NULL, NULL },
{ "<Image>/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, (gpointer) 0x0 },
{ "<Image>/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, (gpointer)
0x1 },
{ "<Image>/Filters/<separator>", NULL, NULL, NULL },
{ "<Image>/Script-Fu/", NULL, NULL, NULL },
{ "<Image>/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Image>/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Image>/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Image>/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, NULL },
{ "<Image>/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Image>/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Load>/Automatic", NULL, file_load_by_extension_callback, NULL },
{ "<Load>/<separator>", NULL, NULL, NULL },
{ "<Save>/By extension", NULL, file_save_by_extension_callback, NULL },
{ "<Save>/<separator>", NULL, NULL, NULL },
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/About...", NULL, about_dialog_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/Tip of the day", NULL, tips_dialog_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/Save", "<control>S", file_save_cmd_callback, 0 },
{ "/File/Save as", NULL, file_save_as_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Close", "<control>W", file_close_cmd_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/Edit/Cut", "<control>X", edit_cut_cmd_callback, 0 },
{ "/Edit/Copy", "<control>C", edit_copy_cmd_callback, 0 },
{ "/Edit/Paste", "<control>V", edit_paste_cmd_callback, 0 },
{ "/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, 0 },
{ "/Edit/Clear", "<control>K", edit_clear_cmd_callback, 0 },
{ "/Edit/Fill", "<control>.", edit_fill_cmd_callback, 0 },
{ "/Edit/Stroke", NULL, edit_stroke_cmd_callback, 0 },
{ "/Edit/Undo", "<control>Z", edit_undo_cmd_callback, 0 },
{ "/Edit/Redo", "<control>R", edit_redo_cmd_callback, 0 },
{ "/Edit/<Separator>", NULL, NULL, 0 },
{ "/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, 0 },
{ "/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, 0 },
{ "/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, 0 },
{ "/Edit/---", NULL, NULL, 0, "<Separator>" },
{ "/Select/Toggle", "<control>T", select_toggle_cmd_callback, 0 },
{ "/Select/Invert", "<control>I", select_invert_cmd_callback, 0 },
{ "/Select/All", "<control>A", select_all_cmd_callback, 0 },
{ "/Select/None", "<control><shift>A", select_none_cmd_callback, 0 },
{ "/Select/Float", "<control><shift>L", select_float_cmd_callback, 0 },
{ "/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, 0 },
{ "/Select/Border", "<control><shift>B", select_border_cmd_callback, 0 },
{ "/Select/Feather", "<control><shift>F", select_feather_cmd_callback, 0 },
{ "/Select/Grow", NULL, select_grow_cmd_callback, 0 },
{ "/Select/Shrink", NULL, select_shrink_cmd_callback, 0 },
{ "/Select/Save To Channel", NULL, select_save_cmd_callback, 0 },
{ "/Select/By Color...", NULL, select_by_color_cmd_callback, 0 },
{ "/View/Zoom In", "=", view_zoomin_cmd_callback, 0 },
{ "/View/Zoom Out", "-", view_zoomout_cmd_callback, 0 },
{ "/View/Zoom/16:1", NULL, view_zoom_16_1_callback, 0 },
{ "/View/Zoom/8:1", NULL, view_zoom_8_1_callback, 0 },
{ "/View/Zoom/4:1", NULL, view_zoom_4_1_callback, 0 },
{ "/View/Zoom/2:1", NULL, view_zoom_2_1_callback, 0 },
{ "/View/Zoom/1:1", "1", view_zoom_1_1_callback, 0 },
{ "/View/Zoom/1:2", NULL, view_zoom_1_2_callback, 0 },
{ "/View/Zoom/1:4", NULL, view_zoom_1_4_callback, 0 },
{ "/View/Zoom/1:8", NULL, view_zoom_1_8_callback, 0 },
{ "/View/Zoom/1:16", NULL, view_zoom_1_16_callback, 0 },
{ "/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, 0 },
{ "/View/Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Snap To Guides", NULL, view_snap_to_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/---", NULL, NULL, 0, "<Separator>" },
{ "/View/New View", NULL, view_new_view_cmd_callback, 0 },
{ "/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, 0 },
{ "/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, 0 },
{ "/Image/Colors/Invert", NULL, image_invert_cmd_callback, 0 },
{ "/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, 0 },
{ "/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, 0 },
{ "/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, 0 },
{ "/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, 0 },
{ "/Image/Colors/Curves", NULL, image_curves_cmd_callback, 0 },
{ "/Image/Colors/Levels", NULL, image_levels_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, 0 },
{ "/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, 0 },
{ "/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, 0 },
{ "/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/RGB", NULL, image_convert_rgb_cmd_callback, 0 },
{ "/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, 0 },
{ "/Image/Indexed", NULL, image_convert_indexed_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Resize", NULL, image_resize_cmd_callback, 0 },
{ "/Image/Scale", NULL, image_scale_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Histogram", NULL, image_histogram_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, 0 },
{ "/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, 0 },
{ "/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, 0 },
{ "/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, 0 },
{ "/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, 0 },
{ "/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, 0 },
{ "/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, 0 },
{ "/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Tools/Rect Select", "R", tools_select_cmd_callback, RECT_SELECT },
{ "/Tools/Ellipse Select", "E", tools_select_cmd_callback, ELLIPSE_SELECT },
{ "/Tools/Free Select", "F", tools_select_cmd_callback, FREE_SELECT },
{ "/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, FUZZY_SELECT },
{ "/Tools/Bezier Select", "B", tools_select_cmd_callback, BEZIER_SELECT },
{ "/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, ISCISSORS },
{ "/Tools/Move", "M", tools_select_cmd_callback, MOVE },
{ "/Tools/Magnify", "<shift>M", tools_select_cmd_callback, MAGNIFY },
{ "/Tools/Crop", "<shift>C", tools_select_cmd_callback, CROP },
{ "/Tools/Transform", "<shift>T", tools_select_cmd_callback, ROTATE },
{ "/Tools/Flip", "<shift>F", tools_select_cmd_callback, FLIP_HORZ },
{ "/Tools/Text", "T", tools_select_cmd_callback, TEXT },
{ "/Tools/Color Picker", "O", tools_select_cmd_callback, COLOR_PICKER },
{ "/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, BUCKET_FILL },
{ "/Tools/Blend", "L", tools_select_cmd_callback, BLEND },
{ "/Tools/Paintbrush", "P", tools_select_cmd_callback, PAINTBRUSH },
{ "/Tools/Pencil", "<shift>P", tools_select_cmd_callback, PENCIL },
{ "/Tools/Eraser", "<shift>E", tools_select_cmd_callback, ERASER },
{ "/Tools/Airbrush", "A", tools_select_cmd_callback, AIRBRUSH },
{ "/Tools/Clone", "C", tools_select_cmd_callback, CLONE },
{ "/Tools/Convolve", "V", tools_select_cmd_callback, CONVOLVE },
{ "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, 0 },
{ "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, 0 },
{ "/Tools/---", NULL, NULL, 0, "<Separator>" },
{ "/Tools/Toolbox", NULL, toolbox_raise_callback, 0 },
{ "/Filters/", NULL, NULL, 0 },
{ "/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, 0x0 },
{ "/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
{ "/Filters/---", NULL, NULL, 0, "<Separator>" },
{ "/Script-Fu/", NULL, NULL, 0 },
{ "/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, 0 },
{ "/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, 0 },
{ "/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
};
static guint n_image_entries = sizeof (image_entries) / sizeof (image_entries[0]);
static GtkItemFactory *image_factory = NULL;
static GtkItemFactoryEntry load_entries[] =
{
{ "/Automatic", NULL, file_load_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_load_entries = sizeof (load_entries) / sizeof (load_entries[0]);
static GtkItemFactory *load_factory = NULL;
static GtkItemFactoryEntry save_entries[] =
{
{ "/By extension", NULL, file_save_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_save_entries = sizeof (save_entries) / sizeof (save_entries[0]);
static GtkItemFactory *save_factory = NULL;
static int initialize = TRUE;
static GtkMenuFactory *factory = NULL;
static GtkMenuFactory *subfactories[4];
static GHashTable *entry_ht = NULL;
void
menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menubar)
*menubar = subfactories[0]->widget;
if (table)
*table = subfactories[0]->table;
*menubar = toolbox_factory->widget;
if (accel_group)
*accel_group = toolbox_factory->accel_group;
}
void
menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[1]->widget;
if (table)
*table = subfactories[1]->table;
*menu = image_factory->widget;
if (accel_group)
*accel_group = image_factory->accel_group;
}
void
menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[2]->widget;
if (table)
*table = subfactories[2]->table;
*menu = load_factory->widget;
if (accel_group)
*accel_group = load_factory->accel_group;
}
void
menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[3]->widget;
if (table)
*table = subfactories[3]->table;
*menu = save_factory->widget;
if (accel_group)
*accel_group = save_factory->accel_group;
}
void
menus_create (GtkMenuEntry *entries,
int nmenu_entries)
{
char *accelerator;
int i;
if (initialize)
menus_init ();
if (entry_ht)
for (i = 0; i < nmenu_entries; i++)
{
accelerator = g_hash_table_lookup (entry_ht, entries[i].path);
if (accelerator)
{
if (accelerator[0] == '\0')
entries[i].accelerator = NULL;
else
entries[i].accelerator = accelerator;
}
}
gtk_menu_factory_add_entries (factory, entries, nmenu_entries);
for (i = 0; i < nmenu_entries; i++)
if (entries[i].widget && GTK_BIN (entries[i].widget)->child)
{
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "install_accelerator",
(GtkSignalFunc) menus_install_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
}
gtk_item_factory_create_menu_entries (nmenu_entries, entries);
}
void
menus_set_sensitive (char *path,
int sensitive)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
gtk_widget_set_sensitive (menu_path->widget, sensitive);
else
g_message ("Unable to set sensitivity for menu which doesn't exist: %s", path);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
gtk_widget_set_sensitive (widget, sensitive);
}
if (!ifactory || !widget)
printf ("Unable to set sensitivity for menu which doesn't exist:\n%s", path);
}
void
menus_set_state (char *path,
int state)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
if (GTK_IS_CHECK_MENU_ITEM (menu_path->widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_path->widget), state);
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
}
else
g_message ("Unable to set state for menu which doesn't exist: %s", path);
}
void
menus_add_path (char *path,
char *accelerator)
{
if (!entry_ht)
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, accelerator);
if (!ifactory || !widget)
printf ("Unable to set state for menu which doesn't exist:\n%s", path);
}
void
@ -358,35 +332,24 @@ menus_destroy (char *path)
if (initialize)
menus_init ();
gtk_menu_factory_remove_paths (factory, &path, 1);
gtk_item_factories_path_delete (NULL, path);
}
void
menus_quit ()
{
FILE *fp;
char filename[512];
char *gimp_dir;
gchar *filename;
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_dump_rc (filename, NULL, TRUE);
g_free (filename);
if (entry_ht)
{
gimp_dir = gimp_directory ();
if ('\000' != gimp_dir[0])
{
sprintf (filename, "%s/menurc", gimp_dir);
fp = fopen (filename, "w");
if (fp)
{
g_hash_table_foreach (entry_ht, menus_foreach, fp);
fclose (fp);
}
}
}
if (!initialize)
{
gtk_menu_factory_destroy (factory);
gtk_object_destroy (GTK_OBJECT (toolbox_factory));
gtk_object_destroy (GTK_OBJECT (image_factory));
gtk_object_destroy (GTK_OBJECT (load_factory));
gtk_object_destroy (GTK_OBJECT (save_factory));
}
}
@ -395,101 +358,35 @@ menus_quit ()
static void
menus_init ()
{
char filename[512];
if (initialize)
{
gchar *filename;
initialize = FALSE;
factory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
image_entries,
NULL, 2);
load_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Load>", NULL);
gtk_item_factory_create_items_ac (load_factory,
n_load_entries,
load_entries,
NULL, 2);
save_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Save>", NULL);
gtk_item_factory_create_items_ac (save_factory,
n_save_entries,
save_entries,
NULL, 2);
subfactories[0] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
gtk_menu_factory_add_subfactory (factory, subfactories[0], "<Toolbox>");
subfactories[1] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[1], "<Image>");
subfactories[2] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[2], "<Load>");
subfactories[3] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[3], "<Save>");
sprintf (filename, "%s/menurc", gimp_directory ());
parse_gimprc_file (filename);
menus_create (menu_items, nmenu_items);
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_parse_rc (filename);
g_free (filename);
}
}
static void
menus_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
char accel[64];
int i, j;
for (i = j = 0; ((char*) value)[i] != '\0'; i++, j++)
{
if (((char *) value)[i] == '"' || ((char *) value)[i] == '\\')
accel[j++] = '\\';
accel[j] = ((char *) value)[i];
}
accel[j] = '\0';
fprintf ((FILE*) user_data, "(menu-path \"%s\" \"%s\")\n", (char*) key, accel);
}
static gint
menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path)
{
char accel[64];
char *t1, t2[2];
accel[0] = '\0';
if (modifiers & GDK_CONTROL_MASK)
strcat (accel, "<control>");
if (modifiers & GDK_SHIFT_MASK)
strcat (accel, "<shift>");
if (modifiers & GDK_MOD1_MASK)
strcat (accel, "<alt>");
t2[0] = key;
t2[1] = '\0';
strcat (accel, t2);
if (entry_ht)
{
t1 = g_hash_table_lookup (entry_ht, path);
g_free (t1);
}
else
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, g_strdup (accel));
return TRUE;
}
static void
menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path)
{
char *t;
if (entry_ht)
{
t = g_hash_table_lookup (entry_ht, path);
g_free (t);
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}

View File

@ -23,21 +23,19 @@
void menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_create (GtkMenuEntry *entries,
int nmenu_entries);
void menus_set_sensitive (char *path,
int sensitive);
void menus_set_state (char *path,
int state);
void menus_add_path (char *path,
char *accelerator);
void menus_destroy (char *path);
void menus_quit (void);

View File

@ -32,324 +32,298 @@
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
gpointer value,
gpointer user_data);
static gint menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path);
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static GtkMenuEntry menu_items[] =
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "<Toolbox>/File/New", "<control>N", file_new_cmd_callback, NULL },
{ "<Toolbox>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Toolbox>/File/About...", NULL, about_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Toolbox>/File/Tip of the day", NULL, tips_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>", NULL, NULL, NULL },
{ "<Toolbox>/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>",NULL,NULL,NULL},
{ "<Toolbox>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/New", "<control>N", file_new_cmd_callback, (gpointer) 1 },
{ "<Image>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Image>/File/Save", "<control>S", file_save_cmd_callback, NULL },
{ "<Image>/File/Save as", NULL, file_save_as_cmd_callback, NULL },
{ "<Image>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/File/Close", "<control>W", file_close_cmd_callback, NULL },
{ "<Image>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut", "<control>X", edit_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy", "<control>C", edit_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste", "<control>V", edit_paste_cmd_callback, NULL },
{ "<Image>/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, NULL },
{ "<Image>/Edit/Clear", "<control>K", edit_clear_cmd_callback, NULL },
{ "<Image>/Edit/Fill", "<control>.", edit_fill_cmd_callback, NULL },
{ "<Image>/Edit/Stroke", NULL, edit_stroke_cmd_callback, NULL },
{ "<Image>/Edit/Undo", "<control>Z", edit_undo_cmd_callback, NULL },
{ "<Image>/Edit/Redo", "<control>R", edit_redo_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Select/Toggle", "<control>T", select_toggle_cmd_callback, NULL },
{ "<Image>/Select/Invert", "<control>I", select_invert_cmd_callback, NULL },
{ "<Image>/Select/All", "<control>A", select_all_cmd_callback, NULL },
{ "<Image>/Select/None", "<control><shift>A", select_none_cmd_callback, NULL },
{ "<Image>/Select/Float", "<control><shift>L", select_float_cmd_callback, NULL },
{ "<Image>/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, NULL },
{ "<Image>/Select/Border", "<control><shift>B", select_border_cmd_callback, NULL },
{ "<Image>/Select/Feather", "<control><shift>F", select_feather_cmd_callback, NULL },
{ "<Image>/Select/Grow", NULL, select_grow_cmd_callback, NULL },
{ "<Image>/Select/Shrink", NULL, select_shrink_cmd_callback, NULL },
{ "<Image>/Select/Save To Channel", NULL, select_save_cmd_callback, NULL },
{ "<Image>/Select/By Color...", NULL, select_by_color_cmd_callback, NULL },
{ "<Image>/View/Zoom In", "=", view_zoomin_cmd_callback, NULL },
{ "<Image>/View/Zoom Out", "-", view_zoomout_cmd_callback, NULL },
{ "<Image>/View/Zoom/16:1", NULL, view_zoom_16_1_callback, NULL },
{ "<Image>/View/Zoom/8:1", NULL, view_zoom_8_1_callback, NULL },
{ "<Image>/View/Zoom/4:1", NULL, view_zoom_4_1_callback, NULL },
{ "<Image>/View/Zoom/2:1", NULL, view_zoom_2_1_callback, NULL },
{ "<Image>/View/Zoom/1:1", "1", view_zoom_1_1_callback, NULL },
{ "<Image>/View/Zoom/1:2", NULL, view_zoom_1_2_callback, NULL },
{ "<Image>/View/Zoom/1:4", NULL, view_zoom_1_4_callback, NULL },
{ "<Image>/View/Zoom/1:8", NULL, view_zoom_1_8_callback, NULL },
{ "<Image>/View/Zoom/1:16", NULL, view_zoom_1_16_callback, NULL },
{ "<Image>/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, NULL },
{ "<Image>/View/<check>Snap To Guides", NULL, view_snap_to_guides_cmd_callback, NULL },
{ "<Image>/View/<separator>", NULL, NULL, NULL },
{ "<Image>/View/New View", NULL, view_new_view_cmd_callback, NULL },
{ "<Image>/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, NULL },
{ "<Image>/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Invert", NULL, image_invert_cmd_callback, NULL },
{ "<Image>/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, NULL },
{ "<Image>/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, NULL },
{ "<Image>/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, NULL },
{ "<Image>/Image/Colors/Curves", NULL, image_curves_cmd_callback, NULL },
{ "<Image>/Image/Colors/Levels", NULL, image_levels_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, NULL },
{ "<Image>/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/RGB", NULL, image_convert_rgb_cmd_callback, NULL },
{ "<Image>/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, NULL },
{ "<Image>/Image/Indexed", NULL, image_convert_indexed_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Resize", NULL, image_resize_cmd_callback, NULL },
{ "<Image>/Image/Scale", NULL, image_scale_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Histogram", NULL, image_histogram_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, NULL },
{ "<Image>/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, NULL },
{ "<Image>/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, NULL },
{ "<Image>/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, NULL },
{ "<Image>/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, NULL },
{ "<Image>/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, NULL },
{ "<Image>/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, NULL },
{ "<Image>/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Tools/Rect Select", "R", tools_select_cmd_callback, (gpointer) RECT_SELECT },
{ "<Image>/Tools/Ellipse Select", "E", tools_select_cmd_callback, (gpointer) ELLIPSE_SELECT },
{ "<Image>/Tools/Free Select", "F", tools_select_cmd_callback, (gpointer) FREE_SELECT },
{ "<Image>/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, (gpointer) FUZZY_SELECT },
{ "<Image>/Tools/Bezier Select", "B", tools_select_cmd_callback, (gpointer) BEZIER_SELECT },
{ "<Image>/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, (gpointer) ISCISSORS },
{ "<Image>/Tools/Move", "M", tools_select_cmd_callback, (gpointer) MOVE },
{ "<Image>/Tools/Magnify", "<shift>M", tools_select_cmd_callback, (gpointer) MAGNIFY },
{ "<Image>/Tools/Crop", "<shift>C", tools_select_cmd_callback, (gpointer) CROP },
{ "<Image>/Tools/Transform", "<shift>T", tools_select_cmd_callback, (gpointer) ROTATE },
{ "<Image>/Tools/Flip", "<shift>F", tools_select_cmd_callback, (gpointer) FLIP_HORZ },
{ "<Image>/Tools/Text", "T", tools_select_cmd_callback, (gpointer) TEXT },
{ "<Image>/Tools/Color Picker", "O", tools_select_cmd_callback, (gpointer) COLOR_PICKER },
{ "<Image>/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, (gpointer) BUCKET_FILL },
{ "<Image>/Tools/Blend", "L", tools_select_cmd_callback, (gpointer) BLEND },
{ "<Image>/Tools/Paintbrush", "P", tools_select_cmd_callback, (gpointer) PAINTBRUSH },
{ "<Image>/Tools/Pencil", "<shift>P", tools_select_cmd_callback, (gpointer) PENCIL },
{ "<Image>/Tools/Eraser", "<shift>E", tools_select_cmd_callback, (gpointer) ERASER },
{ "<Image>/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH },
{ "<Image>/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE },
{ "<Image>/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE },
{ "<Image>/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL},
{ "<Image>/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL},
{ "<Image>/Tools/<separator>", NULL, NULL, NULL },
{ "<Image>/Tools/Toolbox", NULL, toolbox_raise_callback, NULL },
{ "<Image>/Filters/", NULL, NULL, NULL },
{ "<Image>/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, (gpointer) 0x0 },
{ "<Image>/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, (gpointer)
0x1 },
{ "<Image>/Filters/<separator>", NULL, NULL, NULL },
{ "<Image>/Script-Fu/", NULL, NULL, NULL },
{ "<Image>/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Image>/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Image>/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Image>/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, NULL },
{ "<Image>/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Image>/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Load>/Automatic", NULL, file_load_by_extension_callback, NULL },
{ "<Load>/<separator>", NULL, NULL, NULL },
{ "<Save>/By extension", NULL, file_save_by_extension_callback, NULL },
{ "<Save>/<separator>", NULL, NULL, NULL },
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/About...", NULL, about_dialog_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/Tip of the day", NULL, tips_dialog_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/Save", "<control>S", file_save_cmd_callback, 0 },
{ "/File/Save as", NULL, file_save_as_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Close", "<control>W", file_close_cmd_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/Edit/Cut", "<control>X", edit_cut_cmd_callback, 0 },
{ "/Edit/Copy", "<control>C", edit_copy_cmd_callback, 0 },
{ "/Edit/Paste", "<control>V", edit_paste_cmd_callback, 0 },
{ "/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, 0 },
{ "/Edit/Clear", "<control>K", edit_clear_cmd_callback, 0 },
{ "/Edit/Fill", "<control>.", edit_fill_cmd_callback, 0 },
{ "/Edit/Stroke", NULL, edit_stroke_cmd_callback, 0 },
{ "/Edit/Undo", "<control>Z", edit_undo_cmd_callback, 0 },
{ "/Edit/Redo", "<control>R", edit_redo_cmd_callback, 0 },
{ "/Edit/<Separator>", NULL, NULL, 0 },
{ "/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, 0 },
{ "/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, 0 },
{ "/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, 0 },
{ "/Edit/---", NULL, NULL, 0, "<Separator>" },
{ "/Select/Toggle", "<control>T", select_toggle_cmd_callback, 0 },
{ "/Select/Invert", "<control>I", select_invert_cmd_callback, 0 },
{ "/Select/All", "<control>A", select_all_cmd_callback, 0 },
{ "/Select/None", "<control><shift>A", select_none_cmd_callback, 0 },
{ "/Select/Float", "<control><shift>L", select_float_cmd_callback, 0 },
{ "/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, 0 },
{ "/Select/Border", "<control><shift>B", select_border_cmd_callback, 0 },
{ "/Select/Feather", "<control><shift>F", select_feather_cmd_callback, 0 },
{ "/Select/Grow", NULL, select_grow_cmd_callback, 0 },
{ "/Select/Shrink", NULL, select_shrink_cmd_callback, 0 },
{ "/Select/Save To Channel", NULL, select_save_cmd_callback, 0 },
{ "/Select/By Color...", NULL, select_by_color_cmd_callback, 0 },
{ "/View/Zoom In", "=", view_zoomin_cmd_callback, 0 },
{ "/View/Zoom Out", "-", view_zoomout_cmd_callback, 0 },
{ "/View/Zoom/16:1", NULL, view_zoom_16_1_callback, 0 },
{ "/View/Zoom/8:1", NULL, view_zoom_8_1_callback, 0 },
{ "/View/Zoom/4:1", NULL, view_zoom_4_1_callback, 0 },
{ "/View/Zoom/2:1", NULL, view_zoom_2_1_callback, 0 },
{ "/View/Zoom/1:1", "1", view_zoom_1_1_callback, 0 },
{ "/View/Zoom/1:2", NULL, view_zoom_1_2_callback, 0 },
{ "/View/Zoom/1:4", NULL, view_zoom_1_4_callback, 0 },
{ "/View/Zoom/1:8", NULL, view_zoom_1_8_callback, 0 },
{ "/View/Zoom/1:16", NULL, view_zoom_1_16_callback, 0 },
{ "/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, 0 },
{ "/View/Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Snap To Guides", NULL, view_snap_to_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/---", NULL, NULL, 0, "<Separator>" },
{ "/View/New View", NULL, view_new_view_cmd_callback, 0 },
{ "/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, 0 },
{ "/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, 0 },
{ "/Image/Colors/Invert", NULL, image_invert_cmd_callback, 0 },
{ "/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, 0 },
{ "/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, 0 },
{ "/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, 0 },
{ "/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, 0 },
{ "/Image/Colors/Curves", NULL, image_curves_cmd_callback, 0 },
{ "/Image/Colors/Levels", NULL, image_levels_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, 0 },
{ "/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, 0 },
{ "/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, 0 },
{ "/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/RGB", NULL, image_convert_rgb_cmd_callback, 0 },
{ "/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, 0 },
{ "/Image/Indexed", NULL, image_convert_indexed_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Resize", NULL, image_resize_cmd_callback, 0 },
{ "/Image/Scale", NULL, image_scale_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Histogram", NULL, image_histogram_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, 0 },
{ "/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, 0 },
{ "/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, 0 },
{ "/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, 0 },
{ "/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, 0 },
{ "/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, 0 },
{ "/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, 0 },
{ "/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Tools/Rect Select", "R", tools_select_cmd_callback, RECT_SELECT },
{ "/Tools/Ellipse Select", "E", tools_select_cmd_callback, ELLIPSE_SELECT },
{ "/Tools/Free Select", "F", tools_select_cmd_callback, FREE_SELECT },
{ "/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, FUZZY_SELECT },
{ "/Tools/Bezier Select", "B", tools_select_cmd_callback, BEZIER_SELECT },
{ "/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, ISCISSORS },
{ "/Tools/Move", "M", tools_select_cmd_callback, MOVE },
{ "/Tools/Magnify", "<shift>M", tools_select_cmd_callback, MAGNIFY },
{ "/Tools/Crop", "<shift>C", tools_select_cmd_callback, CROP },
{ "/Tools/Transform", "<shift>T", tools_select_cmd_callback, ROTATE },
{ "/Tools/Flip", "<shift>F", tools_select_cmd_callback, FLIP_HORZ },
{ "/Tools/Text", "T", tools_select_cmd_callback, TEXT },
{ "/Tools/Color Picker", "O", tools_select_cmd_callback, COLOR_PICKER },
{ "/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, BUCKET_FILL },
{ "/Tools/Blend", "L", tools_select_cmd_callback, BLEND },
{ "/Tools/Paintbrush", "P", tools_select_cmd_callback, PAINTBRUSH },
{ "/Tools/Pencil", "<shift>P", tools_select_cmd_callback, PENCIL },
{ "/Tools/Eraser", "<shift>E", tools_select_cmd_callback, ERASER },
{ "/Tools/Airbrush", "A", tools_select_cmd_callback, AIRBRUSH },
{ "/Tools/Clone", "C", tools_select_cmd_callback, CLONE },
{ "/Tools/Convolve", "V", tools_select_cmd_callback, CONVOLVE },
{ "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, 0 },
{ "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, 0 },
{ "/Tools/---", NULL, NULL, 0, "<Separator>" },
{ "/Tools/Toolbox", NULL, toolbox_raise_callback, 0 },
{ "/Filters/", NULL, NULL, 0 },
{ "/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, 0x0 },
{ "/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
{ "/Filters/---", NULL, NULL, 0, "<Separator>" },
{ "/Script-Fu/", NULL, NULL, 0 },
{ "/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, 0 },
{ "/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, 0 },
{ "/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
};
static guint n_image_entries = sizeof (image_entries) / sizeof (image_entries[0]);
static GtkItemFactory *image_factory = NULL;
static GtkItemFactoryEntry load_entries[] =
{
{ "/Automatic", NULL, file_load_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_load_entries = sizeof (load_entries) / sizeof (load_entries[0]);
static GtkItemFactory *load_factory = NULL;
static GtkItemFactoryEntry save_entries[] =
{
{ "/By extension", NULL, file_save_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_save_entries = sizeof (save_entries) / sizeof (save_entries[0]);
static GtkItemFactory *save_factory = NULL;
static int initialize = TRUE;
static GtkMenuFactory *factory = NULL;
static GtkMenuFactory *subfactories[4];
static GHashTable *entry_ht = NULL;
void
menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menubar)
*menubar = subfactories[0]->widget;
if (table)
*table = subfactories[0]->table;
*menubar = toolbox_factory->widget;
if (accel_group)
*accel_group = toolbox_factory->accel_group;
}
void
menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[1]->widget;
if (table)
*table = subfactories[1]->table;
*menu = image_factory->widget;
if (accel_group)
*accel_group = image_factory->accel_group;
}
void
menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[2]->widget;
if (table)
*table = subfactories[2]->table;
*menu = load_factory->widget;
if (accel_group)
*accel_group = load_factory->accel_group;
}
void
menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[3]->widget;
if (table)
*table = subfactories[3]->table;
*menu = save_factory->widget;
if (accel_group)
*accel_group = save_factory->accel_group;
}
void
menus_create (GtkMenuEntry *entries,
int nmenu_entries)
{
char *accelerator;
int i;
if (initialize)
menus_init ();
if (entry_ht)
for (i = 0; i < nmenu_entries; i++)
{
accelerator = g_hash_table_lookup (entry_ht, entries[i].path);
if (accelerator)
{
if (accelerator[0] == '\0')
entries[i].accelerator = NULL;
else
entries[i].accelerator = accelerator;
}
}
gtk_menu_factory_add_entries (factory, entries, nmenu_entries);
for (i = 0; i < nmenu_entries; i++)
if (entries[i].widget && GTK_BIN (entries[i].widget)->child)
{
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "install_accelerator",
(GtkSignalFunc) menus_install_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
}
gtk_item_factory_create_menu_entries (nmenu_entries, entries);
}
void
menus_set_sensitive (char *path,
int sensitive)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
gtk_widget_set_sensitive (menu_path->widget, sensitive);
else
g_message ("Unable to set sensitivity for menu which doesn't exist: %s", path);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
gtk_widget_set_sensitive (widget, sensitive);
}
if (!ifactory || !widget)
printf ("Unable to set sensitivity for menu which doesn't exist:\n%s", path);
}
void
menus_set_state (char *path,
int state)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
if (GTK_IS_CHECK_MENU_ITEM (menu_path->widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_path->widget), state);
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
}
else
g_message ("Unable to set state for menu which doesn't exist: %s", path);
}
void
menus_add_path (char *path,
char *accelerator)
{
if (!entry_ht)
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, accelerator);
if (!ifactory || !widget)
printf ("Unable to set state for menu which doesn't exist:\n%s", path);
}
void
@ -358,35 +332,24 @@ menus_destroy (char *path)
if (initialize)
menus_init ();
gtk_menu_factory_remove_paths (factory, &path, 1);
gtk_item_factories_path_delete (NULL, path);
}
void
menus_quit ()
{
FILE *fp;
char filename[512];
char *gimp_dir;
gchar *filename;
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_dump_rc (filename, NULL, TRUE);
g_free (filename);
if (entry_ht)
{
gimp_dir = gimp_directory ();
if ('\000' != gimp_dir[0])
{
sprintf (filename, "%s/menurc", gimp_dir);
fp = fopen (filename, "w");
if (fp)
{
g_hash_table_foreach (entry_ht, menus_foreach, fp);
fclose (fp);
}
}
}
if (!initialize)
{
gtk_menu_factory_destroy (factory);
gtk_object_destroy (GTK_OBJECT (toolbox_factory));
gtk_object_destroy (GTK_OBJECT (image_factory));
gtk_object_destroy (GTK_OBJECT (load_factory));
gtk_object_destroy (GTK_OBJECT (save_factory));
}
}
@ -395,101 +358,35 @@ menus_quit ()
static void
menus_init ()
{
char filename[512];
if (initialize)
{
gchar *filename;
initialize = FALSE;
factory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
image_entries,
NULL, 2);
load_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Load>", NULL);
gtk_item_factory_create_items_ac (load_factory,
n_load_entries,
load_entries,
NULL, 2);
save_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Save>", NULL);
gtk_item_factory_create_items_ac (save_factory,
n_save_entries,
save_entries,
NULL, 2);
subfactories[0] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
gtk_menu_factory_add_subfactory (factory, subfactories[0], "<Toolbox>");
subfactories[1] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[1], "<Image>");
subfactories[2] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[2], "<Load>");
subfactories[3] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[3], "<Save>");
sprintf (filename, "%s/menurc", gimp_directory ());
parse_gimprc_file (filename);
menus_create (menu_items, nmenu_items);
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_parse_rc (filename);
g_free (filename);
}
}
static void
menus_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
char accel[64];
int i, j;
for (i = j = 0; ((char*) value)[i] != '\0'; i++, j++)
{
if (((char *) value)[i] == '"' || ((char *) value)[i] == '\\')
accel[j++] = '\\';
accel[j] = ((char *) value)[i];
}
accel[j] = '\0';
fprintf ((FILE*) user_data, "(menu-path \"%s\" \"%s\")\n", (char*) key, accel);
}
static gint
menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path)
{
char accel[64];
char *t1, t2[2];
accel[0] = '\0';
if (modifiers & GDK_CONTROL_MASK)
strcat (accel, "<control>");
if (modifiers & GDK_SHIFT_MASK)
strcat (accel, "<shift>");
if (modifiers & GDK_MOD1_MASK)
strcat (accel, "<alt>");
t2[0] = key;
t2[1] = '\0';
strcat (accel, t2);
if (entry_ht)
{
t1 = g_hash_table_lookup (entry_ht, path);
g_free (t1);
}
else
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, g_strdup (accel));
return TRUE;
}
static void
menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path)
{
char *t;
if (entry_ht)
{
t = g_hash_table_lookup (entry_ht, path);
g_free (t);
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}

View File

@ -23,21 +23,19 @@
void menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_create (GtkMenuEntry *entries,
int nmenu_entries);
void menus_set_sensitive (char *path,
int sensitive);
void menus_set_state (char *path,
int state);
void menus_add_path (char *path,
char *accelerator);
void menus_destroy (char *path);
void menus_quit (void);

View File

@ -320,7 +320,7 @@ typedef struct {
GtkWidget *control_coloring_popup; /* Coloring type menu */
GtkWidget *control_sel_ops_popup; /* Selection ops menu */
GtkAcceleratorTable *accelerator_table;
GtkAccelGroup *accel_group;
/* Blending and coloring menus */
@ -1015,7 +1015,7 @@ grad_create_gradient_editor(void)
g_editor->control_coloring_popup = NULL;
g_editor->control_sel_ops_popup = NULL;
g_editor->accelerator_table = NULL;
g_editor->accel_group = NULL;
for (i = 0;
i < (sizeof(g_editor->control_blending_items) / sizeof(g_editor->control_blending_items[0]));
@ -2871,16 +2871,15 @@ cpopup_create_main_menu(void)
GtkWidget *menu;
GtkWidget *menuitem;
GtkWidget *label;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = gtk_accelerator_table_new();
accel_group = gtk_accel_group_new();
g_editor->accelerator_table = acc_table;
g_editor->accel_group = accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_window_add_accelerator_table(GTK_WINDOW(g_editor->shell), acc_table);
gtk_menu_set_accel_group (GTK_MENU(menu), accel_group);
gtk_window_add_accel_group (GTK_WINDOW (g_editor->shell), accel_group);
/* Left endpoint */
@ -2891,7 +2890,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'L', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'L', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_left_load_popup = cpopup_create_load_menu(g_editor->left_load_color_boxes,
@ -2929,7 +2932,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'R', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'R', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Load from");
g_editor->control_right_load_popup = cpopup_create_load_menu(g_editor->right_load_color_boxes,
@ -2988,7 +2995,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'S', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'S', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Split uniformly */
@ -2998,7 +3009,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'U', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'U', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Delete */
@ -3009,7 +3024,11 @@ cpopup_create_main_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_delete_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'D', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'D', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Recenter */
@ -3019,7 +3038,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Redistribute */
@ -3029,7 +3052,11 @@ cpopup_create_main_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'C', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'C', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Selection ops */
@ -3376,17 +3403,18 @@ static GtkWidget *
cpopup_create_menu_item_with_label(char *str, GtkWidget **label)
{
GtkWidget *menuitem;
GtkWidget *wlabel;
GtkWidget *accel_label;
menuitem = gtk_menu_item_new();
wlabel = gtk_label_new(str);
gtk_misc_set_alignment(GTK_MISC(wlabel), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), wlabel);
gtk_widget_show(wlabel);
accel_label = gtk_accel_label_new(str);
gtk_misc_set_alignment(GTK_MISC(accel_label), 0.0, 0.5);
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menuitem);
gtk_widget_show(accel_label);
if (label)
*label = wlabel;
*label = accel_label;
return menuitem;
} /* cpopup_create_menu_item_with_label */
@ -3476,13 +3504,13 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
int i;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Create items */
@ -3502,23 +3530,32 @@ cpopup_create_load_menu(GtkWidget **color_boxes, GtkWidget **labels,
gtk_widget_show(menuitem);
switch (i) {
case 0:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_0, accel_mods_0);
break;
case 1:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_1, accel_mods_1);
break;
case 2:
gtk_widget_install_accelerator(menuitem, acc_table, "activate",
accel_key_2, accel_mods_2);
break;
default:
break;
case 0:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_0, accel_mods_0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 1:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_1, accel_mods_1,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
case 2:
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
accel_key_2, accel_mods_2,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
break;
default:
break;
} /* switch */
} /* for */
@ -3886,12 +3923,12 @@ cpopup_create_sel_ops_menu(void)
{
GtkWidget *menu;
GtkWidget *menuitem;
GtkAcceleratorTable *acc_table;
GtkAccelGroup *accel_group;
menu = gtk_menu_new();
acc_table = g_editor->accelerator_table;
accel_group = g_editor->accel_group;
gtk_menu_set_accelerator_table(GTK_MENU(menu), acc_table);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
/* Flip */
@ -3901,7 +3938,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'F', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'F', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Replicate */
@ -3911,7 +3952,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'M', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'M', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
/* Blend colors / opacity */
@ -3926,7 +3971,11 @@ cpopup_create_sel_ops_menu(void)
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
g_editor->control_blend_colors_menu_item = menuitem;
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', 0);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', 0,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
menuitem = gtk_menu_item_new_with_label("Blend endpoints' opacity");
gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
@ -3934,7 +3983,11 @@ cpopup_create_sel_ops_menu(void)
NULL);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_show(menuitem);
gtk_widget_install_accelerator(menuitem, acc_table, "activate", 'B', GDK_CONTROL_MASK);
gtk_widget_add_accelerator(menuitem,
"activate",
accel_group,
'B', GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE | GTK_ACCEL_LOCKED);
g_editor->control_blend_opacity_menu_item = menuitem;
return menu;

View File

@ -32,324 +32,298 @@
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
gpointer value,
gpointer user_data);
static gint menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path);
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static GtkMenuEntry menu_items[] =
static GtkItemFactoryEntry toolbox_entries[] =
{
{ "<Toolbox>/File/New", "<control>N", file_new_cmd_callback, NULL },
{ "<Toolbox>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Toolbox>/File/About...", NULL, about_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Toolbox>/File/Tip of the day", NULL, tips_dialog_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>", NULL, NULL, NULL },
{ "<Toolbox>/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Toolbox>/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Toolbox>/File/<separator>",NULL,NULL,NULL},
{ "<Toolbox>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/New", "<control>N", file_new_cmd_callback, (gpointer) 1 },
{ "<Image>/File/Open", "<control>O", file_open_cmd_callback, NULL },
{ "<Image>/File/Save", "<control>S", file_save_cmd_callback, NULL },
{ "<Image>/File/Save as", NULL, file_save_as_cmd_callback, NULL },
{ "<Image>/File/Preferences...", NULL, file_pref_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/File/Close", "<control>W", file_close_cmd_callback, NULL },
{ "<Image>/File/Quit", "<control>Q", file_quit_cmd_callback, NULL },
{ "<Image>/File/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut", "<control>X", edit_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy", "<control>C", edit_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste", "<control>V", edit_paste_cmd_callback, NULL },
{ "<Image>/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, NULL },
{ "<Image>/Edit/Clear", "<control>K", edit_clear_cmd_callback, NULL },
{ "<Image>/Edit/Fill", "<control>.", edit_fill_cmd_callback, NULL },
{ "<Image>/Edit/Stroke", NULL, edit_stroke_cmd_callback, NULL },
{ "<Image>/Edit/Undo", "<control>Z", edit_undo_cmd_callback, NULL },
{ "<Image>/Edit/Redo", "<control>R", edit_redo_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, NULL },
{ "<Image>/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, NULL },
{ "<Image>/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, NULL },
{ "<Image>/Edit/<separator>", NULL, NULL, NULL },
{ "<Image>/Select/Toggle", "<control>T", select_toggle_cmd_callback, NULL },
{ "<Image>/Select/Invert", "<control>I", select_invert_cmd_callback, NULL },
{ "<Image>/Select/All", "<control>A", select_all_cmd_callback, NULL },
{ "<Image>/Select/None", "<control><shift>A", select_none_cmd_callback, NULL },
{ "<Image>/Select/Float", "<control><shift>L", select_float_cmd_callback, NULL },
{ "<Image>/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, NULL },
{ "<Image>/Select/Border", "<control><shift>B", select_border_cmd_callback, NULL },
{ "<Image>/Select/Feather", "<control><shift>F", select_feather_cmd_callback, NULL },
{ "<Image>/Select/Grow", NULL, select_grow_cmd_callback, NULL },
{ "<Image>/Select/Shrink", NULL, select_shrink_cmd_callback, NULL },
{ "<Image>/Select/Save To Channel", NULL, select_save_cmd_callback, NULL },
{ "<Image>/Select/By Color...", NULL, select_by_color_cmd_callback, NULL },
{ "<Image>/View/Zoom In", "=", view_zoomin_cmd_callback, NULL },
{ "<Image>/View/Zoom Out", "-", view_zoomout_cmd_callback, NULL },
{ "<Image>/View/Zoom/16:1", NULL, view_zoom_16_1_callback, NULL },
{ "<Image>/View/Zoom/8:1", NULL, view_zoom_8_1_callback, NULL },
{ "<Image>/View/Zoom/4:1", NULL, view_zoom_4_1_callback, NULL },
{ "<Image>/View/Zoom/2:1", NULL, view_zoom_2_1_callback, NULL },
{ "<Image>/View/Zoom/1:1", "1", view_zoom_1_1_callback, NULL },
{ "<Image>/View/Zoom/1:2", NULL, view_zoom_1_2_callback, NULL },
{ "<Image>/View/Zoom/1:4", NULL, view_zoom_1_4_callback, NULL },
{ "<Image>/View/Zoom/1:8", NULL, view_zoom_1_8_callback, NULL },
{ "<Image>/View/Zoom/1:16", NULL, view_zoom_1_16_callback, NULL },
{ "<Image>/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, NULL },
{ "<Image>/View/<check>Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, NULL },
{ "<Image>/View/<check>Snap To Guides", NULL, view_snap_to_guides_cmd_callback, NULL },
{ "<Image>/View/<separator>", NULL, NULL, NULL },
{ "<Image>/View/New View", NULL, view_new_view_cmd_callback, NULL },
{ "<Image>/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, NULL },
{ "<Image>/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Invert", NULL, image_invert_cmd_callback, NULL },
{ "<Image>/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, NULL },
{ "<Image>/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, NULL },
{ "<Image>/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, NULL },
{ "<Image>/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, NULL },
{ "<Image>/Image/Colors/Curves", NULL, image_curves_cmd_callback, NULL },
{ "<Image>/Image/Colors/Levels", NULL, image_levels_cmd_callback, NULL },
{ "<Image>/Image/Colors/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, NULL },
{ "<Image>/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, NULL },
{ "<Image>/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/RGB", NULL, image_convert_rgb_cmd_callback, NULL },
{ "<Image>/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, NULL },
{ "<Image>/Image/Indexed", NULL, image_convert_indexed_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Resize", NULL, image_resize_cmd_callback, NULL },
{ "<Image>/Image/Scale", NULL, image_scale_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Image/Histogram", NULL, image_histogram_cmd_callback, NULL },
{ "<Image>/Image/<separator>", NULL, NULL, NULL },
{ "<Image>/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, NULL },
{ "<Image>/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, NULL },
{ "<Image>/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, NULL },
{ "<Image>/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, NULL },
{ "<Image>/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, NULL },
{ "<Image>/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, NULL },
{ "<Image>/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, NULL },
{ "<Image>/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, NULL },
{ "<Image>/Tools/Rect Select", "R", tools_select_cmd_callback, (gpointer) RECT_SELECT },
{ "<Image>/Tools/Ellipse Select", "E", tools_select_cmd_callback, (gpointer) ELLIPSE_SELECT },
{ "<Image>/Tools/Free Select", "F", tools_select_cmd_callback, (gpointer) FREE_SELECT },
{ "<Image>/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, (gpointer) FUZZY_SELECT },
{ "<Image>/Tools/Bezier Select", "B", tools_select_cmd_callback, (gpointer) BEZIER_SELECT },
{ "<Image>/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, (gpointer) ISCISSORS },
{ "<Image>/Tools/Move", "M", tools_select_cmd_callback, (gpointer) MOVE },
{ "<Image>/Tools/Magnify", "<shift>M", tools_select_cmd_callback, (gpointer) MAGNIFY },
{ "<Image>/Tools/Crop", "<shift>C", tools_select_cmd_callback, (gpointer) CROP },
{ "<Image>/Tools/Transform", "<shift>T", tools_select_cmd_callback, (gpointer) ROTATE },
{ "<Image>/Tools/Flip", "<shift>F", tools_select_cmd_callback, (gpointer) FLIP_HORZ },
{ "<Image>/Tools/Text", "T", tools_select_cmd_callback, (gpointer) TEXT },
{ "<Image>/Tools/Color Picker", "O", tools_select_cmd_callback, (gpointer) COLOR_PICKER },
{ "<Image>/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, (gpointer) BUCKET_FILL },
{ "<Image>/Tools/Blend", "L", tools_select_cmd_callback, (gpointer) BLEND },
{ "<Image>/Tools/Paintbrush", "P", tools_select_cmd_callback, (gpointer) PAINTBRUSH },
{ "<Image>/Tools/Pencil", "<shift>P", tools_select_cmd_callback, (gpointer) PENCIL },
{ "<Image>/Tools/Eraser", "<shift>E", tools_select_cmd_callback, (gpointer) ERASER },
{ "<Image>/Tools/Airbrush", "A", tools_select_cmd_callback, (gpointer) AIRBRUSH },
{ "<Image>/Tools/Clone", "C", tools_select_cmd_callback, (gpointer) CLONE },
{ "<Image>/Tools/Convolve", "V", tools_select_cmd_callback, (gpointer) CONVOLVE },
{ "<Image>/Tools/Default Colors", "D", tools_default_colors_cmd_callback, NULL},
{ "<Image>/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, NULL},
{ "<Image>/Tools/<separator>", NULL, NULL, NULL },
{ "<Image>/Tools/Toolbox", NULL, toolbox_raise_callback, NULL },
{ "<Image>/Filters/", NULL, NULL, NULL },
{ "<Image>/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, (gpointer) 0x0 },
{ "<Image>/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, (gpointer)
0x1 },
{ "<Image>/Filters/<separator>", NULL, NULL, NULL },
{ "<Image>/Script-Fu/", NULL, NULL, NULL },
{ "<Image>/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, NULL },
{ "<Image>/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, NULL },
{ "<Image>/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, NULL },
{ "<Image>/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, NULL },
{ "<Image>/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, NULL },
{ "<Image>/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, NULL },
{ "<Image>/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, NULL },
{ "<Image>/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, NULL },
{ "<Load>/Automatic", NULL, file_load_by_extension_callback, NULL },
{ "<Load>/<separator>", NULL, NULL, NULL },
{ "<Save>/By extension", NULL, file_save_by_extension_callback, NULL },
{ "<Save>/<separator>", NULL, NULL, NULL },
{ "/File/New", "<control>N", file_new_cmd_callback, 0 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/About...", NULL, about_dialog_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/Tip of the day", NULL, tips_dialog_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/File/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/File/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/File/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/File/Dialogs/Tool Options...", "<control><shift>T", dialogs_tools_options_cmd_callback, 0 },
{ "/File/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/File/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
};
static int nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
static guint n_toolbox_entries = sizeof (toolbox_entries) / sizeof (toolbox_entries[0]);
static GtkItemFactory *toolbox_factory = NULL;
static GtkItemFactoryEntry image_entries[] =
{
{ "/File/New", "<control>N", file_new_cmd_callback, 1 },
{ "/File/Open", "<control>O", file_open_cmd_callback, 0 },
{ "/File/Save", "<control>S", file_save_cmd_callback, 0 },
{ "/File/Save as", NULL, file_save_as_cmd_callback, 0 },
{ "/File/Preferences...", NULL, file_pref_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/File/Close", "<control>W", file_close_cmd_callback, 0 },
{ "/File/Quit", "<control>Q", file_quit_cmd_callback, 0 },
{ "/File/---", NULL, NULL, 0, "<Separator>" },
{ "/Edit/Cut", "<control>X", edit_cut_cmd_callback, 0 },
{ "/Edit/Copy", "<control>C", edit_copy_cmd_callback, 0 },
{ "/Edit/Paste", "<control>V", edit_paste_cmd_callback, 0 },
{ "/Edit/Paste Into", NULL, edit_paste_into_cmd_callback, 0 },
{ "/Edit/Clear", "<control>K", edit_clear_cmd_callback, 0 },
{ "/Edit/Fill", "<control>.", edit_fill_cmd_callback, 0 },
{ "/Edit/Stroke", NULL, edit_stroke_cmd_callback, 0 },
{ "/Edit/Undo", "<control>Z", edit_undo_cmd_callback, 0 },
{ "/Edit/Redo", "<control>R", edit_redo_cmd_callback, 0 },
{ "/Edit/<Separator>", NULL, NULL, 0 },
{ "/Edit/Cut Named", "<control><shift>X", edit_named_cut_cmd_callback, 0 },
{ "/Edit/Copy Named", "<control><shift>C", edit_named_copy_cmd_callback, 0 },
{ "/Edit/Paste Named", "<control><shift>V", edit_named_paste_cmd_callback, 0 },
{ "/Edit/---", NULL, NULL, 0, "<Separator>" },
{ "/Select/Toggle", "<control>T", select_toggle_cmd_callback, 0 },
{ "/Select/Invert", "<control>I", select_invert_cmd_callback, 0 },
{ "/Select/All", "<control>A", select_all_cmd_callback, 0 },
{ "/Select/None", "<control><shift>A", select_none_cmd_callback, 0 },
{ "/Select/Float", "<control><shift>L", select_float_cmd_callback, 0 },
{ "/Select/Sharpen", "<control><shift>H", select_sharpen_cmd_callback, 0 },
{ "/Select/Border", "<control><shift>B", select_border_cmd_callback, 0 },
{ "/Select/Feather", "<control><shift>F", select_feather_cmd_callback, 0 },
{ "/Select/Grow", NULL, select_grow_cmd_callback, 0 },
{ "/Select/Shrink", NULL, select_shrink_cmd_callback, 0 },
{ "/Select/Save To Channel", NULL, select_save_cmd_callback, 0 },
{ "/Select/By Color...", NULL, select_by_color_cmd_callback, 0 },
{ "/View/Zoom In", "=", view_zoomin_cmd_callback, 0 },
{ "/View/Zoom Out", "-", view_zoomout_cmd_callback, 0 },
{ "/View/Zoom/16:1", NULL, view_zoom_16_1_callback, 0 },
{ "/View/Zoom/8:1", NULL, view_zoom_8_1_callback, 0 },
{ "/View/Zoom/4:1", NULL, view_zoom_4_1_callback, 0 },
{ "/View/Zoom/2:1", NULL, view_zoom_2_1_callback, 0 },
{ "/View/Zoom/1:1", "1", view_zoom_1_1_callback, 0 },
{ "/View/Zoom/1:2", NULL, view_zoom_1_2_callback, 0 },
{ "/View/Zoom/1:4", NULL, view_zoom_1_4_callback, 0 },
{ "/View/Zoom/1:8", NULL, view_zoom_1_8_callback, 0 },
{ "/View/Zoom/1:16", NULL, view_zoom_1_16_callback, 0 },
{ "/View/Window Info...", "<control><shift>I", view_window_info_cmd_callback, 0 },
{ "/View/Toggle Rulers", "<control><shift>R", view_toggle_rulers_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Toggle Guides", "<control><shift>T", view_toggle_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/Snap To Guides", NULL, view_snap_to_guides_cmd_callback, 0, "<ToggleItem>" },
{ "/View/---", NULL, NULL, 0, "<Separator>" },
{ "/View/New View", NULL, view_new_view_cmd_callback, 0 },
{ "/View/Shrink Wrap", "<control>E", view_shrink_wrap_cmd_callback, 0 },
{ "/Image/Colors/Equalize", NULL, image_equalize_cmd_callback, 0 },
{ "/Image/Colors/Invert", NULL, image_invert_cmd_callback, 0 },
{ "/Image/Colors/Posterize", NULL, image_posterize_cmd_callback, 0 },
{ "/Image/Colors/Threshold", NULL, image_threshold_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Color Balance", NULL, image_color_balance_cmd_callback, 0 },
{ "/Image/Colors/Brightness-Contrast", NULL, image_brightness_contrast_cmd_callback, 0 },
{ "/Image/Colors/Hue-Saturation", NULL, image_hue_saturation_cmd_callback, 0 },
{ "/Image/Colors/Curves", NULL, image_curves_cmd_callback, 0 },
{ "/Image/Colors/Levels", NULL, image_levels_cmd_callback, 0 },
{ "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Colors/Desaturate", NULL, image_desaturate_cmd_callback, 0 },
{ "/Image/Channel Ops/Duplicate", "<control>D", channel_ops_duplicate_cmd_callback, 0 },
{ "/Image/Channel Ops/Offset", "<control><shift>O", channel_ops_offset_cmd_callback, 0 },
{ "/Image/Alpha/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/RGB", NULL, image_convert_rgb_cmd_callback, 0 },
{ "/Image/Grayscale", NULL, image_convert_grayscale_cmd_callback, 0 },
{ "/Image/Indexed", NULL, image_convert_indexed_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Resize", NULL, image_resize_cmd_callback, 0 },
{ "/Image/Scale", NULL, image_scale_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Image/Histogram", NULL, image_histogram_cmd_callback, 0 },
{ "/Image/---", NULL, NULL, 0, "<Separator>" },
{ "/Layers/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Layers/Raise Layer", "<control>F", layers_raise_cmd_callback, 0 },
{ "/Layers/Lower Layer", "<control>B", layers_lower_cmd_callback, 0 },
{ "/Layers/Anchor Layer", "<control>H", layers_anchor_cmd_callback, 0 },
{ "/Layers/Merge Visible Layers", "<control>M", layers_merge_cmd_callback, 0 },
{ "/Layers/Flatten Image", NULL, layers_flatten_cmd_callback, 0 },
{ "/Layers/Alpha To Selection", NULL, layers_alpha_select_cmd_callback, 0 },
{ "/Layers/Mask To Selection", NULL, layers_mask_select_cmd_callback, 0 },
{ "/Layers/Add Alpha Channel", NULL, layers_add_alpha_channel_cmd_callback, 0 },
{ "/Tools/Rect Select", "R", tools_select_cmd_callback, RECT_SELECT },
{ "/Tools/Ellipse Select", "E", tools_select_cmd_callback, ELLIPSE_SELECT },
{ "/Tools/Free Select", "F", tools_select_cmd_callback, FREE_SELECT },
{ "/Tools/Fuzzy Select", "Z", tools_select_cmd_callback, FUZZY_SELECT },
{ "/Tools/Bezier Select", "B", tools_select_cmd_callback, BEZIER_SELECT },
{ "/Tools/Intelligent Scissors", "I", tools_select_cmd_callback, ISCISSORS },
{ "/Tools/Move", "M", tools_select_cmd_callback, MOVE },
{ "/Tools/Magnify", "<shift>M", tools_select_cmd_callback, MAGNIFY },
{ "/Tools/Crop", "<shift>C", tools_select_cmd_callback, CROP },
{ "/Tools/Transform", "<shift>T", tools_select_cmd_callback, ROTATE },
{ "/Tools/Flip", "<shift>F", tools_select_cmd_callback, FLIP_HORZ },
{ "/Tools/Text", "T", tools_select_cmd_callback, TEXT },
{ "/Tools/Color Picker", "O", tools_select_cmd_callback, COLOR_PICKER },
{ "/Tools/Bucket Fill", "<shift>B", tools_select_cmd_callback, BUCKET_FILL },
{ "/Tools/Blend", "L", tools_select_cmd_callback, BLEND },
{ "/Tools/Paintbrush", "P", tools_select_cmd_callback, PAINTBRUSH },
{ "/Tools/Pencil", "<shift>P", tools_select_cmd_callback, PENCIL },
{ "/Tools/Eraser", "<shift>E", tools_select_cmd_callback, ERASER },
{ "/Tools/Airbrush", "A", tools_select_cmd_callback, AIRBRUSH },
{ "/Tools/Clone", "C", tools_select_cmd_callback, CLONE },
{ "/Tools/Convolve", "V", tools_select_cmd_callback, CONVOLVE },
{ "/Tools/Default Colors", "D", tools_default_colors_cmd_callback, 0 },
{ "/Tools/Swap Colors", "X", tools_swap_colors_cmd_callback, 0 },
{ "/Tools/---", NULL, NULL, 0, "<Separator>" },
{ "/Tools/Toolbox", NULL, toolbox_raise_callback, 0 },
{ "/Filters/", NULL, NULL, 0 },
{ "/Filters/Repeat last", "<alt>F", filters_repeat_cmd_callback, 0x0 },
{ "/Filters/Re-show last", "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
{ "/Filters/---", NULL, NULL, 0, "<Separator>" },
{ "/Script-Fu/", NULL, NULL, 0 },
{ "/Dialogs/Brushes...", "<control><shift>B", dialogs_brushes_cmd_callback, 0 },
{ "/Dialogs/Patterns...", "<control><shift>P", dialogs_patterns_cmd_callback, 0 },
{ "/Dialogs/Palette...", "<control>P", dialogs_palette_cmd_callback, 0 },
{ "/Dialogs/Gradient Editor...", "<control>G", dialogs_gradient_editor_cmd_callback, 0 },
{ "/Dialogs/Layers & Channels...", "<control>L", dialogs_lc_cmd_callback, 0 },
{ "/Dialogs/Indexed Palette...", NULL, dialogs_indexed_palette_cmd_callback, 0 },
{ "/Dialogs/Tool Options...", NULL, dialogs_tools_options_cmd_callback, 0 },
{ "/Dialogs/Input Devices...", NULL, dialogs_input_devices_cmd_callback, 0 },
{ "/Dialogs/Device Status...", NULL, dialogs_device_status_cmd_callback, 0 },
};
static guint n_image_entries = sizeof (image_entries) / sizeof (image_entries[0]);
static GtkItemFactory *image_factory = NULL;
static GtkItemFactoryEntry load_entries[] =
{
{ "/Automatic", NULL, file_load_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_load_entries = sizeof (load_entries) / sizeof (load_entries[0]);
static GtkItemFactory *load_factory = NULL;
static GtkItemFactoryEntry save_entries[] =
{
{ "/By extension", NULL, file_save_by_extension_callback, 0 },
{ "/---", NULL, NULL, 0, "<Separator>" },
};
static guint n_save_entries = sizeof (save_entries) / sizeof (save_entries[0]);
static GtkItemFactory *save_factory = NULL;
static int initialize = TRUE;
static GtkMenuFactory *factory = NULL;
static GtkMenuFactory *subfactories[4];
static GHashTable *entry_ht = NULL;
void
menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menubar)
*menubar = subfactories[0]->widget;
if (table)
*table = subfactories[0]->table;
*menubar = toolbox_factory->widget;
if (accel_group)
*accel_group = toolbox_factory->accel_group;
}
void
menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[1]->widget;
if (table)
*table = subfactories[1]->table;
*menu = image_factory->widget;
if (accel_group)
*accel_group = image_factory->accel_group;
}
void
menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[2]->widget;
if (table)
*table = subfactories[2]->table;
*menu = load_factory->widget;
if (accel_group)
*accel_group = load_factory->accel_group;
}
void
menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table)
GtkAccelGroup **accel_group)
{
if (initialize)
menus_init ();
if (menu)
*menu = subfactories[3]->widget;
if (table)
*table = subfactories[3]->table;
*menu = save_factory->widget;
if (accel_group)
*accel_group = save_factory->accel_group;
}
void
menus_create (GtkMenuEntry *entries,
int nmenu_entries)
{
char *accelerator;
int i;
if (initialize)
menus_init ();
if (entry_ht)
for (i = 0; i < nmenu_entries; i++)
{
accelerator = g_hash_table_lookup (entry_ht, entries[i].path);
if (accelerator)
{
if (accelerator[0] == '\0')
entries[i].accelerator = NULL;
else
entries[i].accelerator = accelerator;
}
}
gtk_menu_factory_add_entries (factory, entries, nmenu_entries);
for (i = 0; i < nmenu_entries; i++)
if (entries[i].widget && GTK_BIN (entries[i].widget)->child)
{
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "install_accelerator",
(GtkSignalFunc) menus_install_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
}
gtk_item_factory_create_menu_entries (nmenu_entries, entries);
}
void
menus_set_sensitive (char *path,
int sensitive)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
gtk_widget_set_sensitive (menu_path->widget, sensitive);
else
g_message ("Unable to set sensitivity for menu which doesn't exist: %s", path);
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
widget = gtk_item_factory_get_widget (ifactory, path);
gtk_widget_set_sensitive (widget, sensitive);
}
if (!ifactory || !widget)
printf ("Unable to set sensitivity for menu which doesn't exist:\n%s", path);
}
void
menus_set_state (char *path,
int state)
{
GtkMenuPath *menu_path;
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (initialize)
menus_init ();
menu_path = gtk_menu_factory_find (factory, path);
if (menu_path)
ifactory = gtk_item_factory_from_path (path);
if (ifactory)
{
if (GTK_IS_CHECK_MENU_ITEM (menu_path->widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (menu_path->widget), state);
widget = gtk_item_factory_get_widget (ifactory, path);
if (widget && GTK_IS_CHECK_MENU_ITEM (widget))
gtk_check_menu_item_set_state (GTK_CHECK_MENU_ITEM (widget), state);
else
widget = NULL;
}
else
g_message ("Unable to set state for menu which doesn't exist: %s", path);
}
void
menus_add_path (char *path,
char *accelerator)
{
if (!entry_ht)
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, accelerator);
if (!ifactory || !widget)
printf ("Unable to set state for menu which doesn't exist:\n%s", path);
}
void
@ -358,35 +332,24 @@ menus_destroy (char *path)
if (initialize)
menus_init ();
gtk_menu_factory_remove_paths (factory, &path, 1);
gtk_item_factories_path_delete (NULL, path);
}
void
menus_quit ()
{
FILE *fp;
char filename[512];
char *gimp_dir;
gchar *filename;
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_dump_rc (filename, NULL, TRUE);
g_free (filename);
if (entry_ht)
{
gimp_dir = gimp_directory ();
if ('\000' != gimp_dir[0])
{
sprintf (filename, "%s/menurc", gimp_dir);
fp = fopen (filename, "w");
if (fp)
{
g_hash_table_foreach (entry_ht, menus_foreach, fp);
fclose (fp);
}
}
}
if (!initialize)
{
gtk_menu_factory_destroy (factory);
gtk_object_destroy (GTK_OBJECT (toolbox_factory));
gtk_object_destroy (GTK_OBJECT (image_factory));
gtk_object_destroy (GTK_OBJECT (load_factory));
gtk_object_destroy (GTK_OBJECT (save_factory));
}
}
@ -395,101 +358,35 @@ menus_quit ()
static void
menus_init ()
{
char filename[512];
if (initialize)
{
gchar *filename;
initialize = FALSE;
factory = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
toolbox_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<Toolbox>", NULL);
gtk_item_factory_create_items_ac (toolbox_factory,
n_toolbox_entries,
toolbox_entries,
NULL, 2);
image_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Image>", NULL);
gtk_item_factory_create_items_ac (image_factory,
n_image_entries,
image_entries,
NULL, 2);
load_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Load>", NULL);
gtk_item_factory_create_items_ac (load_factory,
n_load_entries,
load_entries,
NULL, 2);
save_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<Save>", NULL);
gtk_item_factory_create_items_ac (save_factory,
n_save_entries,
save_entries,
NULL, 2);
subfactories[0] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU_BAR);
gtk_menu_factory_add_subfactory (factory, subfactories[0], "<Toolbox>");
subfactories[1] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[1], "<Image>");
subfactories[2] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[2], "<Load>");
subfactories[3] = gtk_menu_factory_new (GTK_MENU_FACTORY_MENU);
gtk_menu_factory_add_subfactory (factory, subfactories[3], "<Save>");
sprintf (filename, "%s/menurc", gimp_directory ());
parse_gimprc_file (filename);
menus_create (menu_items, nmenu_items);
filename = g_strconcat (gimp_directory (), "/menurc", NULL);
gtk_item_factory_parse_rc (filename);
g_free (filename);
}
}
static void
menus_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
char accel[64];
int i, j;
for (i = j = 0; ((char*) value)[i] != '\0'; i++, j++)
{
if (((char *) value)[i] == '"' || ((char *) value)[i] == '\\')
accel[j++] = '\\';
accel[j] = ((char *) value)[i];
}
accel[j] = '\0';
fprintf ((FILE*) user_data, "(menu-path \"%s\" \"%s\")\n", (char*) key, accel);
}
static gint
menus_install_accel (GtkWidget *widget,
gchar *signal_name,
gchar key,
gchar modifiers,
gchar *path)
{
char accel[64];
char *t1, t2[2];
accel[0] = '\0';
if (modifiers & GDK_CONTROL_MASK)
strcat (accel, "<control>");
if (modifiers & GDK_SHIFT_MASK)
strcat (accel, "<shift>");
if (modifiers & GDK_MOD1_MASK)
strcat (accel, "<alt>");
t2[0] = key;
t2[1] = '\0';
strcat (accel, t2);
if (entry_ht)
{
t1 = g_hash_table_lookup (entry_ht, path);
g_free (t1);
}
else
entry_ht = g_hash_table_new (g_str_hash, g_str_equal);
g_hash_table_insert (entry_ht, path, g_strdup (accel));
return TRUE;
}
static void
menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path)
{
char *t;
if (entry_ht)
{
t = g_hash_table_lookup (entry_ht, path);
g_free (t);
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}

View File

@ -23,21 +23,19 @@
void menus_get_toolbox_menubar (GtkWidget **menubar,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_image_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_load_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_get_save_menu (GtkWidget **menu,
GtkAcceleratorTable **table);
GtkAccelGroup **accel_group);
void menus_create (GtkMenuEntry *entries,
int nmenu_entries);
void menus_set_sensitive (char *path,
int sensitive);
void menus_set_state (char *path,
int state);
void menus_add_path (char *path,
char *accelerator);
void menus_destroy (char *path);
void menus_quit (void);