applied and heavily modified a patch from Daniel Egger.

* app/menus.c: applied and heavily modified a patch from Daniel Egger.

 There's not any more the need to declare menu branches unless we
 want to create empty submenus (to be filled in by plug-ins). Removes
 a bunch of messages from the catalogs.
 We do not longer put a seperator after submenus if the menu contains
 nothing but submenus.


--Sven
This commit is contained in:
Sven Neumann 2000-03-08 20:57:49 +00:00
parent 6d98023b8e
commit 7a263f3f89
8 changed files with 681 additions and 1013 deletions

View File

@ -1,3 +1,13 @@
Wed Mar 8 21:52:51 CET 2000 Sven Neumann <sven@gimp.org>
* app/menus.c: applied and heavily modified a patch from Daniel Egger.
There's not any more the need to declare menu branches unless we
want to create empty submenus (to be filled in by plug-ins). Removes
a bunch of messages from the catalogs.
We do not longer put a seperator after submenus if the menu contains
nothing but submenus.
2000-03-08 Tor Lillqvist <tml@iki.fi>
* app/cursorutil.c (gtkutil_compress_motion)

View File

@ -45,27 +45,29 @@
#define MRU_MENU_ENTRY_SIZE (strlen ("/File/MRU00 ") + 1)
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_init (void);
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry);
static void menus_init (void);
#ifdef ENABLE_NLS
static gchar *menu_translate (const gchar *path,
gpointer data);
static gchar *menu_translate (const gchar *path,
gpointer data);
#else
#define menu_translate NULL
#endif
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data,
@ -79,6 +81,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{
/* <Toolbox>/File */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 0 },
@ -102,8 +105,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T", dialogs_tool_options_cmd_callback, 0 },
@ -122,8 +123,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { "/File/Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs/Input Devices..."), NULL, dialogs_input_devices_cmd_callback, 0 },
"file/dialogs/input_devices.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL, dialogs_device_status_cmd_callback, 0 },
@ -150,6 +149,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Xtns */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Xtns"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Xtns/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 },
@ -160,6 +160,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Help */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Help/Help..."), "F1", help_help_cmd_callback, 0 },
@ -173,6 +174,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Dump Items (Debug)"), NULL, help_debug_cmd_callback, 0 },
NULL, NULL }
};
static guint n_toolbox_entries = (sizeof (toolbox_entries) /
sizeof (toolbox_entries[0]));
static GtkItemFactory *toolbox_factory = NULL;
@ -186,8 +188,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/File */
{ { N_("/File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 1 },
"file/dialogs/file_new.html", NULL },
{ { N_("/File/Open..."), "<control>O", file_open_cmd_callback, 0 },
@ -211,8 +211,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit */
{ { N_("/Edit"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Undo"), "<control>Z", edit_undo_cmd_callback, 0 },
"edit/undo.html", NULL },
{ { N_("/Edit/Redo"), "<control>R", edit_redo_cmd_callback, 0 },
@ -233,8 +231,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit/Buffer */
{ { N_("/Edit/Buffer"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Buffer/Cut Named..."), "<control><shift>X", edit_named_cut_cmd_callback, 0 },
"edit/dialogs/cut_named.html", NULL },
{ { N_("/Edit/Buffer/Copy Named..."), "<control><shift>C", edit_named_copy_cmd_callback, 0 },
@ -256,8 +252,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Select */
{ { N_("/Select"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Select/Invert"), "<control>I", select_invert_cmd_callback, 0 },
"select/invert.html", NULL },
{ { N_("/Select/All"), "<control>A", select_all_cmd_callback, 0 },
@ -287,8 +281,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom In"), "equal", view_zoomin_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus", view_zoomout_cmd_callback, 0 },
@ -296,8 +288,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View/Zoom */
{ { N_("/View/Zoom"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom/16:1"), NULL, view_zoom_16_1_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom/8:1"), NULL, view_zoom_8_1_cmd_callback, 0 },
@ -352,15 +342,8 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/View/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
/* <Image>/Image */
{ { N_("/Image"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Image/Mode */
{ { N_("/Image/Mode"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Mode/RGB"), "<alt>R", image_convert_rgb_cmd_callback, 0 },
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G", image_convert_grayscale_cmd_callback, 0 },
@ -373,9 +356,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors */
{ { N_("/Image/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
@ -388,8 +368,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors/Auto */
{ { N_("/Image/Colors/Auto"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Colors/Auto/Equalize"), NULL, image_equalize_cmd_callback, 0 },
"image/colors/auto/equalize.html", NULL },
@ -398,15 +376,11 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Alpha */
{ { N_("/Image/Alpha"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Alpha/Add Alpha Channel"), NULL, layers_add_alpha_channel_cmd_callback, 0 },
"layers/add_alpha_channel.html", NULL },
/* <Image>/Image/Transforms */
{ { N_("/Image/Transforms"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Transforms/Offset..."), "<control><shift>O", image_offset_cmd_callback, 0 },
"image/transforms/dialogs/offset.html", NULL },
{ { N_("/Image/Transforms/Rotate"), NULL, NULL, 0, "<Branch>" },
@ -428,15 +402,15 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Layers */
{ { N_("/Layers"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Stack/Previous Layer"), "Prior", layers_previous_cmd_callback, 0 },
"layers/stack/stack.html#previous_layer", NULL },
{ { N_("/Layers/Stack/Next Layer"), "Next", layers_next_cmd_callback, 0 },
@ -457,9 +431,6 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
@ -486,8 +457,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Tools */
{ { N_("/Tools"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Tools/Toolbox"), NULL, toolbox_raise_callback, 0 },
"toolbox/toolbox.html", NULL },
{ { N_("/Tools/Default Colors"), "D", tools_default_colors_cmd_callback, 0 },
@ -507,8 +476,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Dialogs */
{ { N_("/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { N_("/Dialogs/Tool Options..."), NULL, dialogs_tool_options_cmd_callback, 0 },
@ -548,8 +515,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Filters */
{ { N_("/Filters"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Repeat Last"), "<alt>F", filters_repeat_cmd_callback, 0x0 },
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
@ -557,12 +522,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/Filters/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Filters/Blur"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Filters/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
@ -603,11 +565,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL, NULL },
{ { N_("/Filters/Toys"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Script-Fu */
{ { N_("/Script-Fu"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
};
static guint n_image_entries = (sizeof (image_entries) /
sizeof (image_entries[0]));
@ -650,8 +609,6 @@ static GimpItemFactoryEntry layers_entries[] =
/* <Layers>/Stack */
{ { N_("/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Stack/Raise Layer"), "<control>F", layers_dialog_raise_layer_callback, 0 },
"stack/stack.html#raise_layer", NULL },
{ { N_("/Stack/Lower Layer"), "<control>B", layers_dialog_lower_layer_callback, 0 },
@ -887,7 +844,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
GString *tearoff_path;
gchar *path;
if (initialize)
@ -904,58 +860,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gtk_object_set_data (GTK_OBJECT (item_factory), "textdomain", domain_name);
if ((item_factory == image_factory) ||
(item_factory == toolbox_factory))
{
gint factory_length;
gchar *p;
tearoff_path = g_string_new ("");
p = strchr (entry->entry.path, '/');
factory_length = p - entry->entry.path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
while (*path != '>')
path++;
path++;
@ -965,6 +869,60 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2);
}
static void
menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry)
{
GString *tearoff_path;
gint factory_length;
gchar *p;
gchar *path = entry->entry.path;
tearoff_path = g_string_new ("");
p = strchr (path, '/');
factory_length = p - path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (!gtk_item_factory_get_widget (item_factory, tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry = {
{NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>"}
,
NULL,
NULL
};
GimpItemFactoryEntry branch_entry = {
{NULL, NULL, NULL, 0, "<Branch>"}
,
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
static void
menus_filters_subdirs_to_top (GtkMenu *menu)
{
@ -973,22 +931,23 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
gboolean submenus_passed = FALSE;
gboolean separator_found = FALSE;
gint pos;
gint items;
pos = 1;
items = 0;
for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list))
{
menu_item = GTK_MENU_ITEM (list->data);
items++;
if (menu_item->submenu)
{
if (submenus_passed)
{
menus_filters_subdirs_to_top (GTK_MENU (menu_item->submenu));
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos);
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos++);
}
pos++;
}
else
{
@ -1000,7 +959,7 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
separator_found = TRUE;
}
if ((pos > 1) && !separator_found)
if (pos > 1 && !separator_found && items > pos)
{
GtkWidget *separator;
@ -1546,6 +1505,9 @@ menus_create_item (GtkItemFactory *item_factory,
{
GtkWidget *menu_item;
if (!(strstr (entry->entry.path, "tearoff1")))
menus_create_branches (item_factory, entry);
gtk_item_factory_create_item (item_factory,
(GtkItemFactoryEntry *) entry,
callback_data,
@ -1580,30 +1542,6 @@ menus_create_items (GtkItemFactory *item_factory,
entries + i,
callback_data,
callback_type);
if (((item_factory == toolbox_factory) ||
(item_factory == image_factory)) &&
entries[i].entry.item_type &&
strstr (entries[i].entry.item_type, "Branch>"))
{
gchar *tearoff_path;
tearoff_path = g_strconcat (entries[i].entry.path, "/tearoff1", NULL);
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
tearoff_entry.entry.path = tearoff_path;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
g_free (tearoff_path);
}
}
}
@ -1746,8 +1684,8 @@ menu_translate (const gchar *path,
static gchar *menupath = NULL;
GtkItemFactory *item_factory = NULL;
gchar *retval;
gchar *factory;
gchar *fullpath;
gchar *translation;
gchar *domain = NULL;
gchar *complete = NULL;
@ -1758,12 +1696,12 @@ menu_translate (const gchar *path,
if (menupath)
g_free (menupath);
retval = menupath = g_strdup (path);
menupath = g_strdup (path);
if ((strstr (path, "/tearoff1") != NULL) ||
(strstr (path, "/---") != NULL) ||
(strstr (path, "/MRU") != NULL))
return retval;
return menupath;
if (factory)
item_factory = gtk_item_factory_from_path (factory);
@ -1772,21 +1710,19 @@ menu_translate (const gchar *path,
if (domain) /* use the plugin textdomain */
{
g_free (menupath);
menupath = g_strconcat (factory, path, NULL);
fullpath = g_strconcat (factory, path, NULL);
complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
while (*complete && *translation && strcmp (complete, fullpath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
@ -1802,38 +1738,41 @@ menu_translate (const gchar *path,
}
else
{
translation = dgettext (domain, menupath);
translation = dgettext (domain, fullpath);
}
/*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/
if (strncmp (factory, translation, strlen (factory)) == 0)
{
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
g_free (menupath);
menupath = g_strdup (translation + strlen (factory));
if (complete)
g_free (translation);
}
else
{
g_warning ("bad translation for menupath: %s (%s)", fullpath, translation);
if (complete)
g_free (translation);
}
g_free (fullpath);
}
else
{
translation = gettext (menupath);
if (*translation == '/')
retval = translation;
{
g_free (menupath);
menupath = g_strdup (translation);
}
else
g_warning ("bad translation for menupath: %s", menupath);
}
return retval;
return menupath;
}
#endif /* ENABLE_NLS */

View File

@ -45,27 +45,29 @@
#define MRU_MENU_ENTRY_SIZE (strlen ("/File/MRU00 ") + 1)
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_init (void);
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry);
static void menus_init (void);
#ifdef ENABLE_NLS
static gchar *menu_translate (const gchar *path,
gpointer data);
static gchar *menu_translate (const gchar *path,
gpointer data);
#else
#define menu_translate NULL
#endif
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data,
@ -79,6 +81,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{
/* <Toolbox>/File */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 0 },
@ -102,8 +105,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T", dialogs_tool_options_cmd_callback, 0 },
@ -122,8 +123,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { "/File/Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs/Input Devices..."), NULL, dialogs_input_devices_cmd_callback, 0 },
"file/dialogs/input_devices.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL, dialogs_device_status_cmd_callback, 0 },
@ -150,6 +149,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Xtns */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Xtns"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Xtns/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 },
@ -160,6 +160,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Help */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Help/Help..."), "F1", help_help_cmd_callback, 0 },
@ -173,6 +174,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Dump Items (Debug)"), NULL, help_debug_cmd_callback, 0 },
NULL, NULL }
};
static guint n_toolbox_entries = (sizeof (toolbox_entries) /
sizeof (toolbox_entries[0]));
static GtkItemFactory *toolbox_factory = NULL;
@ -186,8 +188,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/File */
{ { N_("/File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 1 },
"file/dialogs/file_new.html", NULL },
{ { N_("/File/Open..."), "<control>O", file_open_cmd_callback, 0 },
@ -211,8 +211,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit */
{ { N_("/Edit"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Undo"), "<control>Z", edit_undo_cmd_callback, 0 },
"edit/undo.html", NULL },
{ { N_("/Edit/Redo"), "<control>R", edit_redo_cmd_callback, 0 },
@ -233,8 +231,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit/Buffer */
{ { N_("/Edit/Buffer"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Buffer/Cut Named..."), "<control><shift>X", edit_named_cut_cmd_callback, 0 },
"edit/dialogs/cut_named.html", NULL },
{ { N_("/Edit/Buffer/Copy Named..."), "<control><shift>C", edit_named_copy_cmd_callback, 0 },
@ -256,8 +252,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Select */
{ { N_("/Select"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Select/Invert"), "<control>I", select_invert_cmd_callback, 0 },
"select/invert.html", NULL },
{ { N_("/Select/All"), "<control>A", select_all_cmd_callback, 0 },
@ -287,8 +281,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom In"), "equal", view_zoomin_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus", view_zoomout_cmd_callback, 0 },
@ -296,8 +288,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View/Zoom */
{ { N_("/View/Zoom"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom/16:1"), NULL, view_zoom_16_1_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom/8:1"), NULL, view_zoom_8_1_cmd_callback, 0 },
@ -352,15 +342,8 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/View/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
/* <Image>/Image */
{ { N_("/Image"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Image/Mode */
{ { N_("/Image/Mode"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Mode/RGB"), "<alt>R", image_convert_rgb_cmd_callback, 0 },
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G", image_convert_grayscale_cmd_callback, 0 },
@ -373,9 +356,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors */
{ { N_("/Image/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
@ -388,8 +368,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors/Auto */
{ { N_("/Image/Colors/Auto"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Colors/Auto/Equalize"), NULL, image_equalize_cmd_callback, 0 },
"image/colors/auto/equalize.html", NULL },
@ -398,15 +376,11 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Alpha */
{ { N_("/Image/Alpha"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Alpha/Add Alpha Channel"), NULL, layers_add_alpha_channel_cmd_callback, 0 },
"layers/add_alpha_channel.html", NULL },
/* <Image>/Image/Transforms */
{ { N_("/Image/Transforms"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Transforms/Offset..."), "<control><shift>O", image_offset_cmd_callback, 0 },
"image/transforms/dialogs/offset.html", NULL },
{ { N_("/Image/Transforms/Rotate"), NULL, NULL, 0, "<Branch>" },
@ -428,15 +402,15 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Layers */
{ { N_("/Layers"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Stack/Previous Layer"), "Prior", layers_previous_cmd_callback, 0 },
"layers/stack/stack.html#previous_layer", NULL },
{ { N_("/Layers/Stack/Next Layer"), "Next", layers_next_cmd_callback, 0 },
@ -457,9 +431,6 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
@ -486,8 +457,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Tools */
{ { N_("/Tools"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Tools/Toolbox"), NULL, toolbox_raise_callback, 0 },
"toolbox/toolbox.html", NULL },
{ { N_("/Tools/Default Colors"), "D", tools_default_colors_cmd_callback, 0 },
@ -507,8 +476,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Dialogs */
{ { N_("/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { N_("/Dialogs/Tool Options..."), NULL, dialogs_tool_options_cmd_callback, 0 },
@ -548,8 +515,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Filters */
{ { N_("/Filters"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Repeat Last"), "<alt>F", filters_repeat_cmd_callback, 0x0 },
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
@ -557,12 +522,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/Filters/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Filters/Blur"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Filters/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
@ -603,11 +565,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL, NULL },
{ { N_("/Filters/Toys"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Script-Fu */
{ { N_("/Script-Fu"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
};
static guint n_image_entries = (sizeof (image_entries) /
sizeof (image_entries[0]));
@ -650,8 +609,6 @@ static GimpItemFactoryEntry layers_entries[] =
/* <Layers>/Stack */
{ { N_("/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Stack/Raise Layer"), "<control>F", layers_dialog_raise_layer_callback, 0 },
"stack/stack.html#raise_layer", NULL },
{ { N_("/Stack/Lower Layer"), "<control>B", layers_dialog_lower_layer_callback, 0 },
@ -887,7 +844,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
GString *tearoff_path;
gchar *path;
if (initialize)
@ -904,58 +860,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gtk_object_set_data (GTK_OBJECT (item_factory), "textdomain", domain_name);
if ((item_factory == image_factory) ||
(item_factory == toolbox_factory))
{
gint factory_length;
gchar *p;
tearoff_path = g_string_new ("");
p = strchr (entry->entry.path, '/');
factory_length = p - entry->entry.path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
while (*path != '>')
path++;
path++;
@ -965,6 +869,60 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2);
}
static void
menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry)
{
GString *tearoff_path;
gint factory_length;
gchar *p;
gchar *path = entry->entry.path;
tearoff_path = g_string_new ("");
p = strchr (path, '/');
factory_length = p - path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (!gtk_item_factory_get_widget (item_factory, tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry = {
{NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>"}
,
NULL,
NULL
};
GimpItemFactoryEntry branch_entry = {
{NULL, NULL, NULL, 0, "<Branch>"}
,
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
static void
menus_filters_subdirs_to_top (GtkMenu *menu)
{
@ -973,22 +931,23 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
gboolean submenus_passed = FALSE;
gboolean separator_found = FALSE;
gint pos;
gint items;
pos = 1;
items = 0;
for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list))
{
menu_item = GTK_MENU_ITEM (list->data);
items++;
if (menu_item->submenu)
{
if (submenus_passed)
{
menus_filters_subdirs_to_top (GTK_MENU (menu_item->submenu));
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos);
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos++);
}
pos++;
}
else
{
@ -1000,7 +959,7 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
separator_found = TRUE;
}
if ((pos > 1) && !separator_found)
if (pos > 1 && !separator_found && items > pos)
{
GtkWidget *separator;
@ -1546,6 +1505,9 @@ menus_create_item (GtkItemFactory *item_factory,
{
GtkWidget *menu_item;
if (!(strstr (entry->entry.path, "tearoff1")))
menus_create_branches (item_factory, entry);
gtk_item_factory_create_item (item_factory,
(GtkItemFactoryEntry *) entry,
callback_data,
@ -1580,30 +1542,6 @@ menus_create_items (GtkItemFactory *item_factory,
entries + i,
callback_data,
callback_type);
if (((item_factory == toolbox_factory) ||
(item_factory == image_factory)) &&
entries[i].entry.item_type &&
strstr (entries[i].entry.item_type, "Branch>"))
{
gchar *tearoff_path;
tearoff_path = g_strconcat (entries[i].entry.path, "/tearoff1", NULL);
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
tearoff_entry.entry.path = tearoff_path;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
g_free (tearoff_path);
}
}
}
@ -1746,8 +1684,8 @@ menu_translate (const gchar *path,
static gchar *menupath = NULL;
GtkItemFactory *item_factory = NULL;
gchar *retval;
gchar *factory;
gchar *fullpath;
gchar *translation;
gchar *domain = NULL;
gchar *complete = NULL;
@ -1758,12 +1696,12 @@ menu_translate (const gchar *path,
if (menupath)
g_free (menupath);
retval = menupath = g_strdup (path);
menupath = g_strdup (path);
if ((strstr (path, "/tearoff1") != NULL) ||
(strstr (path, "/---") != NULL) ||
(strstr (path, "/MRU") != NULL))
return retval;
return menupath;
if (factory)
item_factory = gtk_item_factory_from_path (factory);
@ -1772,21 +1710,19 @@ menu_translate (const gchar *path,
if (domain) /* use the plugin textdomain */
{
g_free (menupath);
menupath = g_strconcat (factory, path, NULL);
fullpath = g_strconcat (factory, path, NULL);
complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
while (*complete && *translation && strcmp (complete, fullpath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
@ -1802,38 +1738,41 @@ menu_translate (const gchar *path,
}
else
{
translation = dgettext (domain, menupath);
translation = dgettext (domain, fullpath);
}
/*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/
if (strncmp (factory, translation, strlen (factory)) == 0)
{
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
g_free (menupath);
menupath = g_strdup (translation + strlen (factory));
if (complete)
g_free (translation);
}
else
{
g_warning ("bad translation for menupath: %s (%s)", fullpath, translation);
if (complete)
g_free (translation);
}
g_free (fullpath);
}
else
{
translation = gettext (menupath);
if (*translation == '/')
retval = translation;
{
g_free (menupath);
menupath = g_strdup (translation);
}
else
g_warning ("bad translation for menupath: %s", menupath);
}
return retval;
return menupath;
}
#endif /* ENABLE_NLS */

View File

@ -45,27 +45,29 @@
#define MRU_MENU_ENTRY_SIZE (strlen ("/File/MRU00 ") + 1)
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_init (void);
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry);
static void menus_init (void);
#ifdef ENABLE_NLS
static gchar *menu_translate (const gchar *path,
gpointer data);
static gchar *menu_translate (const gchar *path,
gpointer data);
#else
#define menu_translate NULL
#endif
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data,
@ -79,6 +81,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{
/* <Toolbox>/File */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 0 },
@ -102,8 +105,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T", dialogs_tool_options_cmd_callback, 0 },
@ -122,8 +123,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { "/File/Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs/Input Devices..."), NULL, dialogs_input_devices_cmd_callback, 0 },
"file/dialogs/input_devices.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL, dialogs_device_status_cmd_callback, 0 },
@ -150,6 +149,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Xtns */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Xtns"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Xtns/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 },
@ -160,6 +160,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Help */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Help/Help..."), "F1", help_help_cmd_callback, 0 },
@ -173,6 +174,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Dump Items (Debug)"), NULL, help_debug_cmd_callback, 0 },
NULL, NULL }
};
static guint n_toolbox_entries = (sizeof (toolbox_entries) /
sizeof (toolbox_entries[0]));
static GtkItemFactory *toolbox_factory = NULL;
@ -186,8 +188,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/File */
{ { N_("/File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 1 },
"file/dialogs/file_new.html", NULL },
{ { N_("/File/Open..."), "<control>O", file_open_cmd_callback, 0 },
@ -211,8 +211,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit */
{ { N_("/Edit"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Undo"), "<control>Z", edit_undo_cmd_callback, 0 },
"edit/undo.html", NULL },
{ { N_("/Edit/Redo"), "<control>R", edit_redo_cmd_callback, 0 },
@ -233,8 +231,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit/Buffer */
{ { N_("/Edit/Buffer"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Buffer/Cut Named..."), "<control><shift>X", edit_named_cut_cmd_callback, 0 },
"edit/dialogs/cut_named.html", NULL },
{ { N_("/Edit/Buffer/Copy Named..."), "<control><shift>C", edit_named_copy_cmd_callback, 0 },
@ -256,8 +252,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Select */
{ { N_("/Select"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Select/Invert"), "<control>I", select_invert_cmd_callback, 0 },
"select/invert.html", NULL },
{ { N_("/Select/All"), "<control>A", select_all_cmd_callback, 0 },
@ -287,8 +281,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom In"), "equal", view_zoomin_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus", view_zoomout_cmd_callback, 0 },
@ -296,8 +288,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View/Zoom */
{ { N_("/View/Zoom"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom/16:1"), NULL, view_zoom_16_1_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom/8:1"), NULL, view_zoom_8_1_cmd_callback, 0 },
@ -352,15 +342,8 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/View/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
/* <Image>/Image */
{ { N_("/Image"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Image/Mode */
{ { N_("/Image/Mode"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Mode/RGB"), "<alt>R", image_convert_rgb_cmd_callback, 0 },
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G", image_convert_grayscale_cmd_callback, 0 },
@ -373,9 +356,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors */
{ { N_("/Image/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
@ -388,8 +368,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors/Auto */
{ { N_("/Image/Colors/Auto"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Colors/Auto/Equalize"), NULL, image_equalize_cmd_callback, 0 },
"image/colors/auto/equalize.html", NULL },
@ -398,15 +376,11 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Alpha */
{ { N_("/Image/Alpha"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Alpha/Add Alpha Channel"), NULL, layers_add_alpha_channel_cmd_callback, 0 },
"layers/add_alpha_channel.html", NULL },
/* <Image>/Image/Transforms */
{ { N_("/Image/Transforms"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Transforms/Offset..."), "<control><shift>O", image_offset_cmd_callback, 0 },
"image/transforms/dialogs/offset.html", NULL },
{ { N_("/Image/Transforms/Rotate"), NULL, NULL, 0, "<Branch>" },
@ -428,15 +402,15 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Layers */
{ { N_("/Layers"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Stack/Previous Layer"), "Prior", layers_previous_cmd_callback, 0 },
"layers/stack/stack.html#previous_layer", NULL },
{ { N_("/Layers/Stack/Next Layer"), "Next", layers_next_cmd_callback, 0 },
@ -457,9 +431,6 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
@ -486,8 +457,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Tools */
{ { N_("/Tools"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Tools/Toolbox"), NULL, toolbox_raise_callback, 0 },
"toolbox/toolbox.html", NULL },
{ { N_("/Tools/Default Colors"), "D", tools_default_colors_cmd_callback, 0 },
@ -507,8 +476,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Dialogs */
{ { N_("/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { N_("/Dialogs/Tool Options..."), NULL, dialogs_tool_options_cmd_callback, 0 },
@ -548,8 +515,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Filters */
{ { N_("/Filters"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Repeat Last"), "<alt>F", filters_repeat_cmd_callback, 0x0 },
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
@ -557,12 +522,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/Filters/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Filters/Blur"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Filters/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
@ -603,11 +565,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL, NULL },
{ { N_("/Filters/Toys"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Script-Fu */
{ { N_("/Script-Fu"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
};
static guint n_image_entries = (sizeof (image_entries) /
sizeof (image_entries[0]));
@ -650,8 +609,6 @@ static GimpItemFactoryEntry layers_entries[] =
/* <Layers>/Stack */
{ { N_("/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Stack/Raise Layer"), "<control>F", layers_dialog_raise_layer_callback, 0 },
"stack/stack.html#raise_layer", NULL },
{ { N_("/Stack/Lower Layer"), "<control>B", layers_dialog_lower_layer_callback, 0 },
@ -887,7 +844,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
GString *tearoff_path;
gchar *path;
if (initialize)
@ -904,58 +860,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gtk_object_set_data (GTK_OBJECT (item_factory), "textdomain", domain_name);
if ((item_factory == image_factory) ||
(item_factory == toolbox_factory))
{
gint factory_length;
gchar *p;
tearoff_path = g_string_new ("");
p = strchr (entry->entry.path, '/');
factory_length = p - entry->entry.path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
while (*path != '>')
path++;
path++;
@ -965,6 +869,60 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2);
}
static void
menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry)
{
GString *tearoff_path;
gint factory_length;
gchar *p;
gchar *path = entry->entry.path;
tearoff_path = g_string_new ("");
p = strchr (path, '/');
factory_length = p - path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (!gtk_item_factory_get_widget (item_factory, tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry = {
{NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>"}
,
NULL,
NULL
};
GimpItemFactoryEntry branch_entry = {
{NULL, NULL, NULL, 0, "<Branch>"}
,
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
static void
menus_filters_subdirs_to_top (GtkMenu *menu)
{
@ -973,22 +931,23 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
gboolean submenus_passed = FALSE;
gboolean separator_found = FALSE;
gint pos;
gint items;
pos = 1;
items = 0;
for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list))
{
menu_item = GTK_MENU_ITEM (list->data);
items++;
if (menu_item->submenu)
{
if (submenus_passed)
{
menus_filters_subdirs_to_top (GTK_MENU (menu_item->submenu));
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos);
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos++);
}
pos++;
}
else
{
@ -1000,7 +959,7 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
separator_found = TRUE;
}
if ((pos > 1) && !separator_found)
if (pos > 1 && !separator_found && items > pos)
{
GtkWidget *separator;
@ -1546,6 +1505,9 @@ menus_create_item (GtkItemFactory *item_factory,
{
GtkWidget *menu_item;
if (!(strstr (entry->entry.path, "tearoff1")))
menus_create_branches (item_factory, entry);
gtk_item_factory_create_item (item_factory,
(GtkItemFactoryEntry *) entry,
callback_data,
@ -1580,30 +1542,6 @@ menus_create_items (GtkItemFactory *item_factory,
entries + i,
callback_data,
callback_type);
if (((item_factory == toolbox_factory) ||
(item_factory == image_factory)) &&
entries[i].entry.item_type &&
strstr (entries[i].entry.item_type, "Branch>"))
{
gchar *tearoff_path;
tearoff_path = g_strconcat (entries[i].entry.path, "/tearoff1", NULL);
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
tearoff_entry.entry.path = tearoff_path;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
g_free (tearoff_path);
}
}
}
@ -1746,8 +1684,8 @@ menu_translate (const gchar *path,
static gchar *menupath = NULL;
GtkItemFactory *item_factory = NULL;
gchar *retval;
gchar *factory;
gchar *fullpath;
gchar *translation;
gchar *domain = NULL;
gchar *complete = NULL;
@ -1758,12 +1696,12 @@ menu_translate (const gchar *path,
if (menupath)
g_free (menupath);
retval = menupath = g_strdup (path);
menupath = g_strdup (path);
if ((strstr (path, "/tearoff1") != NULL) ||
(strstr (path, "/---") != NULL) ||
(strstr (path, "/MRU") != NULL))
return retval;
return menupath;
if (factory)
item_factory = gtk_item_factory_from_path (factory);
@ -1772,21 +1710,19 @@ menu_translate (const gchar *path,
if (domain) /* use the plugin textdomain */
{
g_free (menupath);
menupath = g_strconcat (factory, path, NULL);
fullpath = g_strconcat (factory, path, NULL);
complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
while (*complete && *translation && strcmp (complete, fullpath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
@ -1802,38 +1738,41 @@ menu_translate (const gchar *path,
}
else
{
translation = dgettext (domain, menupath);
translation = dgettext (domain, fullpath);
}
/*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/
if (strncmp (factory, translation, strlen (factory)) == 0)
{
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
g_free (menupath);
menupath = g_strdup (translation + strlen (factory));
if (complete)
g_free (translation);
}
else
{
g_warning ("bad translation for menupath: %s (%s)", fullpath, translation);
if (complete)
g_free (translation);
}
g_free (fullpath);
}
else
{
translation = gettext (menupath);
if (*translation == '/')
retval = translation;
{
g_free (menupath);
menupath = g_strdup (translation);
}
else
g_warning ("bad translation for menupath: %s", menupath);
}
return retval;
return menupath;
}
#endif /* ENABLE_NLS */

View File

@ -45,27 +45,29 @@
#define MRU_MENU_ENTRY_SIZE (strlen ("/File/MRU00 ") + 1)
#define MRU_MENU_ACCEL_SIZE sizeof ("<control>0")
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_init (void);
static void menus_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type);
static void menus_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type);
static void menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry);
static void menus_init (void);
#ifdef ENABLE_NLS
static gchar *menu_translate (const gchar *path,
gpointer data);
static gchar *menu_translate (const gchar *path,
gpointer data);
#else
#define menu_translate NULL
#endif
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void tearoff_cmd_callback (GtkWidget *widget,
gpointer callback_data,
guint callback_action);
static void help_debug_cmd_callback (GtkWidget *widget,
gpointer callback_data,
@ -79,6 +81,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{
/* <Toolbox>/File */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 0 },
@ -102,8 +105,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { "/File/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"file/dialogs/layers_and_channels.html", NULL },
{ { N_("/File/Dialogs/Tool Options..."), "<control><shift>T", dialogs_tool_options_cmd_callback, 0 },
@ -122,8 +123,6 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/File/Dialogs/Indexed Palette..."), NULL, dialogs_indexed_palette_cmd_callback, 0 },
"file/dialogs/indexed_palette.html", NULL },
{ { "/File/Dialogs/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/File/Dialogs/Input Devices..."), NULL, dialogs_input_devices_cmd_callback, 0 },
"file/dialogs/input_devices.html", NULL },
{ { N_("/File/Dialogs/Device Status..."), NULL, dialogs_device_status_cmd_callback, 0 },
@ -150,6 +149,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Xtns */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Xtns"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Xtns/Module Browser..."), NULL, dialogs_module_browser_cmd_callback, 0 },
@ -160,6 +160,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
/* <Toolbox>/Help */
/* the underscore installs an accelerator using the character that follows */
{ { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Help/Help..."), "F1", help_help_cmd_callback, 0 },
@ -173,6 +174,7 @@ static GimpItemFactoryEntry toolbox_entries[] =
{ { N_("/Help/Dump Items (Debug)"), NULL, help_debug_cmd_callback, 0 },
NULL, NULL }
};
static guint n_toolbox_entries = (sizeof (toolbox_entries) /
sizeof (toolbox_entries[0]));
static GtkItemFactory *toolbox_factory = NULL;
@ -186,8 +188,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/File */
{ { N_("/File"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/File/New..."), "<control>N", file_new_cmd_callback, 1 },
"file/dialogs/file_new.html", NULL },
{ { N_("/File/Open..."), "<control>O", file_open_cmd_callback, 0 },
@ -211,8 +211,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit */
{ { N_("/Edit"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Undo"), "<control>Z", edit_undo_cmd_callback, 0 },
"edit/undo.html", NULL },
{ { N_("/Edit/Redo"), "<control>R", edit_redo_cmd_callback, 0 },
@ -233,8 +231,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Edit/Buffer */
{ { N_("/Edit/Buffer"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Edit/Buffer/Cut Named..."), "<control><shift>X", edit_named_cut_cmd_callback, 0 },
"edit/dialogs/cut_named.html", NULL },
{ { N_("/Edit/Buffer/Copy Named..."), "<control><shift>C", edit_named_copy_cmd_callback, 0 },
@ -256,8 +252,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Select */
{ { N_("/Select"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Select/Invert"), "<control>I", select_invert_cmd_callback, 0 },
"select/invert.html", NULL },
{ { N_("/Select/All"), "<control>A", select_all_cmd_callback, 0 },
@ -287,8 +281,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View */
{ { N_("/View"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom In"), "equal", view_zoomin_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom Out"), "minus", view_zoomout_cmd_callback, 0 },
@ -296,8 +288,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/View/Zoom */
{ { N_("/View/Zoom"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/View/Zoom/16:1"), NULL, view_zoom_16_1_cmd_callback, 0 },
"view/zoom.html", NULL },
{ { N_("/View/Zoom/8:1"), NULL, view_zoom_8_1_cmd_callback, 0 },
@ -352,15 +342,8 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/View/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
/* <Image>/Image */
{ { N_("/Image"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Image/Mode */
{ { N_("/Image/Mode"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Mode/RGB"), "<alt>R", image_convert_rgb_cmd_callback, 0 },
"image/mode/convert_to_rgb.html", NULL },
{ { N_("/Image/Mode/Grayscale"), "<alt>G", image_convert_grayscale_cmd_callback, 0 },
@ -373,9 +356,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors */
{ { N_("/Image/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Image/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Image/Colors/Desaturate"), NULL, image_desaturate_cmd_callback, 0 },
@ -388,8 +368,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Colors/Auto */
{ { N_("/Image/Colors/Auto"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Colors/Auto/Equalize"), NULL, image_equalize_cmd_callback, 0 },
"image/colors/auto/equalize.html", NULL },
@ -398,15 +376,11 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Image/Alpha */
{ { N_("/Image/Alpha"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Alpha/Add Alpha Channel"), NULL, layers_add_alpha_channel_cmd_callback, 0 },
"layers/add_alpha_channel.html", NULL },
/* <Image>/Image/Transforms */
{ { N_("/Image/Transforms"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Image/Transforms/Offset..."), "<control><shift>O", image_offset_cmd_callback, 0 },
"image/transforms/dialogs/offset.html", NULL },
{ { N_("/Image/Transforms/Rotate"), NULL, NULL, 0, "<Branch>" },
@ -428,15 +402,15 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Layers */
{ { N_("/Layers"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
/* <Image>/Layers/Stack */
{ { N_("/Layers/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Stack/Previous Layer"), "Prior", layers_previous_cmd_callback, 0 },
"layers/stack/stack.html#previous_layer", NULL },
{ { N_("/Layers/Stack/Next Layer"), "Next", layers_next_cmd_callback, 0 },
@ -457,9 +431,6 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Layer to Imagesize"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/layer_to_image_size.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
@ -486,8 +457,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Tools */
{ { N_("/Tools"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Tools/Toolbox"), NULL, toolbox_raise_callback, 0 },
"toolbox/toolbox.html", NULL },
{ { N_("/Tools/Default Colors"), "D", tools_default_colors_cmd_callback, 0 },
@ -507,8 +476,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Dialogs */
{ { N_("/Dialogs"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Dialogs/Layers, Channels & Paths..."), "<control>L", dialogs_lc_cmd_callback, 0 },
"dialogs/layers_and_channels.html", NULL },
{ { N_("/Dialogs/Tool Options..."), NULL, dialogs_tool_options_cmd_callback, 0 },
@ -548,8 +515,6 @@ static GimpItemFactoryEntry image_entries[] =
/* <Image>/Filters */
{ { N_("/Filters"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Repeat Last"), "<alt>F", filters_repeat_cmd_callback, 0x0 },
"filters/repeat_last.html", NULL },
{ { N_("/Filters/Re-Show Last"), "<alt><shift>F", filters_repeat_cmd_callback, 0x1 },
@ -557,12 +522,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { "/Filters/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Filters/Blur"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Filters/Colors"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { "/Filters/Colors/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
@ -603,11 +565,8 @@ static GimpItemFactoryEntry image_entries[] =
NULL, NULL },
{ { N_("/Filters/Toys"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
/* <Image>/Script-Fu */
{ { N_("/Script-Fu"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
};
static guint n_image_entries = (sizeof (image_entries) /
sizeof (image_entries[0]));
@ -650,8 +609,6 @@ static GimpItemFactoryEntry layers_entries[] =
/* <Layers>/Stack */
{ { N_("/Stack"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Stack/Raise Layer"), "<control>F", layers_dialog_raise_layer_callback, 0 },
"stack/stack.html#raise_layer", NULL },
{ { N_("/Stack/Lower Layer"), "<control>B", layers_dialog_lower_layer_callback, 0 },
@ -887,7 +844,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
GString *tearoff_path;
gchar *path;
if (initialize)
@ -904,58 +860,6 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gtk_object_set_data (GTK_OBJECT (item_factory), "textdomain", domain_name);
if ((item_factory == image_factory) ||
(item_factory == toolbox_factory))
{
gint factory_length;
gchar *p;
tearoff_path = g_string_new ("");
p = strchr (entry->entry.path, '/');
factory_length = p - entry->entry.path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (! gtk_item_factory_get_widget (item_factory,
tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
while (*path != '>')
path++;
path++;
@ -965,6 +869,60 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
menus_create_item (item_factory, entry, callback_data, 2);
}
static void
menus_create_branches (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry)
{
GString *tearoff_path;
gint factory_length;
gchar *p;
gchar *path = entry->entry.path;
tearoff_path = g_string_new ("");
p = strchr (path, '/');
factory_length = p - path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (!gtk_item_factory_get_widget (item_factory, tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry = {
{NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>"}
,
NULL,
NULL
};
GimpItemFactoryEntry branch_entry = {
{NULL, NULL, NULL, 0, "<Branch>"}
,
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
gtk_object_set_data (GTK_OBJECT (item_factory), "complete", path);
menus_create_item (item_factory, &branch_entry, NULL, 2);
gtk_object_remove_data (GTK_OBJECT (item_factory), "complete");
g_string_append (tearoff_path, "/tearoff1");
tearoff_entry.entry.path = tearoff_path->str;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
static void
menus_filters_subdirs_to_top (GtkMenu *menu)
{
@ -973,22 +931,23 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
gboolean submenus_passed = FALSE;
gboolean separator_found = FALSE;
gint pos;
gint items;
pos = 1;
items = 0;
for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list))
{
menu_item = GTK_MENU_ITEM (list->data);
items++;
if (menu_item->submenu)
{
if (submenus_passed)
{
menus_filters_subdirs_to_top (GTK_MENU (menu_item->submenu));
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos);
gtk_menu_reorder_child (menu, GTK_WIDGET (menu_item), pos++);
}
pos++;
}
else
{
@ -1000,7 +959,7 @@ menus_filters_subdirs_to_top (GtkMenu *menu)
separator_found = TRUE;
}
if ((pos > 1) && !separator_found)
if (pos > 1 && !separator_found && items > pos)
{
GtkWidget *separator;
@ -1546,6 +1505,9 @@ menus_create_item (GtkItemFactory *item_factory,
{
GtkWidget *menu_item;
if (!(strstr (entry->entry.path, "tearoff1")))
menus_create_branches (item_factory, entry);
gtk_item_factory_create_item (item_factory,
(GtkItemFactoryEntry *) entry,
callback_data,
@ -1580,30 +1542,6 @@ menus_create_items (GtkItemFactory *item_factory,
entries + i,
callback_data,
callback_type);
if (((item_factory == toolbox_factory) ||
(item_factory == image_factory)) &&
entries[i].entry.item_type &&
strstr (entries[i].entry.item_type, "Branch>"))
{
gchar *tearoff_path;
tearoff_path = g_strconcat (entries[i].entry.path, "/tearoff1", NULL);
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, tearoff_cmd_callback, 0, "<Tearoff>" },
NULL,
NULL
};
tearoff_entry.entry.path = tearoff_path;
menus_create_item (item_factory, &tearoff_entry, NULL, 2);
}
g_free (tearoff_path);
}
}
}
@ -1746,8 +1684,8 @@ menu_translate (const gchar *path,
static gchar *menupath = NULL;
GtkItemFactory *item_factory = NULL;
gchar *retval;
gchar *factory;
gchar *fullpath;
gchar *translation;
gchar *domain = NULL;
gchar *complete = NULL;
@ -1758,12 +1696,12 @@ menu_translate (const gchar *path,
if (menupath)
g_free (menupath);
retval = menupath = g_strdup (path);
menupath = g_strdup (path);
if ((strstr (path, "/tearoff1") != NULL) ||
(strstr (path, "/---") != NULL) ||
(strstr (path, "/MRU") != NULL))
return retval;
return menupath;
if (factory)
item_factory = gtk_item_factory_from_path (factory);
@ -1772,21 +1710,19 @@ menu_translate (const gchar *path,
if (domain) /* use the plugin textdomain */
{
g_free (menupath);
menupath = g_strconcat (factory, path, NULL);
fullpath = g_strconcat (factory, path, NULL);
complete = gtk_object_get_data (GTK_OBJECT (item_factory), "complete");
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
complete = g_strdup (complete);
while (*complete && *translation && strcmp (complete, menupath))
while (*complete && *translation && strcmp (complete, fullpath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
@ -1802,38 +1738,41 @@ menu_translate (const gchar *path,
}
else
{
translation = dgettext (domain, menupath);
translation = dgettext (domain, fullpath);
}
/*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/
if (strncmp (factory, translation, strlen (factory)) == 0)
{
retval = translation + strlen (factory);
if (complete)
{
/* assign the result to menu_path, so it gets freed on next call */
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
g_free (menupath);
menupath = g_strdup (translation + strlen (factory));
if (complete)
g_free (translation);
}
else
{
g_warning ("bad translation for menupath: %s (%s)", fullpath, translation);
if (complete)
g_free (translation);
}
g_free (fullpath);
}
else
{
translation = gettext (menupath);
if (*translation == '/')
retval = translation;
{
g_free (menupath);
menupath = g_strdup (translation);
}
else
g_warning ("bad translation for menupath: %s", menupath);
}
return retval;
return menupath;
}
#endif /* ENABLE_NLS */

View File

@ -5599,16 +5599,16 @@ msgstr "Suchzeit:"
#: plug-ins/common/snoise.c:193
msgid "<Image>/Filters/Render/Clouds/Solid Noise..."
msgstr "<Image>/Filter/Render/Wolken/Plastisches rauschen..."
msgstr "<Image>/Filter/Render/Wolken/Plastisches Rauschen..."
#: plug-ins/common/snoise.c:318
msgid "Solid Noise..."
msgstr "Plastisches rauschen..."
msgstr "Plastisches Rauschen..."
#. Dialog initialization
#: plug-ins/common/snoise.c:521
msgid "Solid Noise"
msgstr "Plastisches rauschen"
msgstr "Plastisches Rauschen"
#: plug-ins/common/snoise.c:563
msgid "Detail:"

View File

@ -1,3 +1,7 @@
Wed Mar 8 21:52:01 CET 2000 Sven Neumann <sven@gimp.org>
* de.po: updated german translation
2000-03-08 Tor Lillqvist <tml@iki.fi>
* fi.po: Remove a bogus fuzzy indicator.

534
po/de.po

File diff suppressed because it is too large Load Diff