added GimpUIManagerSetupFunc typedef.

2004-04-26  Michael Natterer  <mitch@gimp.org>

	* app/widgets/widgets-types.h: added GimpUIManagerSetupFunc typedef.

	* app/widgets/gimpuimanager.[ch]: added the setup_func to the
	GimpUIManagerUIEntry struct and to gimp_ui_manager_ui_register().
	Call the setup_func after creating the UI. Replaced the term
	"identifier" by "ui_path".

	* app/widgets/gimpmenufactory.c: ditto.

	* app/gui/menus.c (menus_init): register the new setup_funcs below.

	* app/gui/menus.[ch] (menus_open_recent_add)
	* app/gui/image-menu.[ch] (image_menu_setup2)
	* app/gui/toolbox-menu.[ch] (toolbox_menu_setup2): new setup_funcs
	which add the "Open Recent" menu items.

	* app/actions/file-actions.c: removed "file-open-recent-empty"
	action because it's not needed.

	* menus/image-menu.xml
	* menus/toolbox-menu.xml: removed "file-open-recent-empty" menu
	items and added <placeholder>s for the "Open Recent" menu items.
This commit is contained in:
Michael Natterer
2004-04-26 15:51:21 +00:00
committed by Michael Natterer
parent b69ddb3993
commit bb0f359ac4
20 changed files with 250 additions and 105 deletions

View File

@ -1,3 +1,28 @@
2004-04-26 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-types.h: added GimpUIManagerSetupFunc typedef.
* app/widgets/gimpuimanager.[ch]: added the setup_func to the
GimpUIManagerUIEntry struct and to gimp_ui_manager_ui_register().
Call the setup_func after creating the UI. Replaced the term
"identifier" by "ui_path".
* app/widgets/gimpmenufactory.c: ditto.
* app/gui/menus.c (menus_init): register the new setup_funcs below.
* app/gui/menus.[ch] (menus_open_recent_add)
* app/gui/image-menu.[ch] (image_menu_setup2)
* app/gui/toolbox-menu.[ch] (toolbox_menu_setup2): new setup_funcs
which add the "Open Recent" menu items.
* app/actions/file-actions.c: removed "file-open-recent-empty"
action because it's not needed.
* menus/image-menu.xml
* menus/toolbox-menu.xml: removed "file-open-recent-empty" menu
items and added <placeholder>s for the "Open Recent" menu items.
2004-04-26 Michael Natterer <mitch@gimp.org> 2004-04-26 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: removed "locale_domain" and "help_domain" * app/core/gimp.[ch]: removed "locale_domain" and "help_domain"

View File

@ -59,7 +59,6 @@ static GimpActionEntry file_actions[] =
{ {
{ "file-menu", NULL, N_("_File") }, { "file-menu", NULL, N_("_File") },
{ "file-open-recent-menu", NULL, N_("Open _Recent") }, { "file-open-recent-menu", NULL, N_("Open _Recent") },
{ "file-open-recent-empty", NULL, N_("(Empty)") },
{ "file-acquire-menu", NULL, N_("_Acquire") }, { "file-acquire-menu", NULL, N_("_Acquire") },
{ "file-new", GTK_STOCK_NEW, { "file-new", GTK_STOCK_NEW,
@ -147,9 +146,6 @@ file_actions_setup (GimpActionGroup *group,
G_CALLBACK (file_last_opened_cmd_callback), G_CALLBACK (file_last_opened_cmd_callback),
data); data);
gimp_action_group_set_action_sensitive (group, "file-open-recent-empty",
FALSE);
for (i = 0; i < n_entries; i++) for (i = 0; i < n_entries; i++)
{ {
gimp_action_group_set_action_visible (group, entries[i].name, FALSE); gimp_action_group_set_action_visible (group, entries[i].name, FALSE);
@ -229,10 +225,6 @@ file_actions_last_opened_update (GimpContainer *container,
num_documents = gimp_container_num_children (container); num_documents = gimp_container_num_children (container);
gimp_action_group_set_action_visible (group,
"file-open-recent-empty",
num_documents == 0);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
GtkAction *action; GtkAction *action;
@ -263,10 +255,6 @@ file_actions_last_opened_update (GimpContainer *container,
"visible", TRUE, "visible", TRUE,
NULL); NULL);
#if 0
gimp_help_set_help_data (widget, filename, NULL);
#endif
g_free (filename); g_free (filename);
g_free (basename); g_free (basename);

View File

@ -1135,6 +1135,13 @@ GimpItemFactoryEntry image_menu_entries[] =
gint n_image_menu_entries = G_N_ELEMENTS (image_menu_entries); gint n_image_menu_entries = G_N_ELEMENTS (image_menu_entries);
void
image_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path)
{
menus_open_recent_add (manager, ui_path);
}
void void
image_menu_setup (GimpItemFactory *factory, image_menu_setup (GimpItemFactory *factory,
gpointer setup_data) gpointer setup_data)

View File

@ -24,6 +24,9 @@ extern GimpItemFactoryEntry image_menu_entries[];
extern gint n_image_menu_entries; extern gint n_image_menu_entries;
void image_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path);
void image_menu_setup (GimpItemFactory *factory, void image_menu_setup (GimpItemFactory *factory,
gpointer callback_data); gpointer callback_data);
void image_menu_update (GtkItemFactory *factory, void image_menu_update (GtkItemFactory *factory,

View File

@ -36,6 +36,7 @@
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h" #include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h" #include "widgets/gimpmenufactory.h"
#include "widgets/gimpuimanager.h"
#include "actions/actions.h" #include "actions/actions.h"
#include "actions/file-commands.h" #include "actions/file-commands.h"
@ -143,11 +144,11 @@ menus_init (Gimp *gimp)
"qmask", "qmask",
NULL, NULL,
"/toolbox-menubar", "/toolbox-menubar",
"toolbox-menu.xml", "toolbox-menu.xml", toolbox_menu_setup2,
"/image-menubar", "/image-menubar",
"image-menu.xml", "image-menu.xml", image_menu_setup2,
"/qmask-popup", "/qmask-popup",
"qmask-menu.xml", "qmask-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Load>", gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
@ -175,7 +176,7 @@ menus_init (Gimp *gimp)
"layers", "layers",
NULL, NULL,
"/layers-popup", "/layers-popup",
"layers-menu.xml", "layers-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Channels>", gimp_menu_factory_menu_register (global_menu_factory, "<Channels>",
@ -188,7 +189,7 @@ menus_init (Gimp *gimp)
"channels", "channels",
NULL, NULL,
"/channels-popup", "/channels-popup",
"channels-menu.xml", "channels-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>", gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>",
@ -201,7 +202,7 @@ menus_init (Gimp *gimp)
"vectors", "vectors",
NULL, NULL,
"/vectors-popup", "/vectors-popup",
"vectors-menu.xml", "vectors-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>", gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>",
@ -214,7 +215,7 @@ menus_init (Gimp *gimp)
"dockable", "dockable",
NULL, NULL,
"/dockable-popup", "/dockable-popup",
"dockable-menu.xml", "dockable-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>", gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>",
@ -227,7 +228,7 @@ menus_init (Gimp *gimp)
"brushes", "brushes",
NULL, NULL,
"/brushes-popup", "/brushes-popup",
"brushes-menu.xml", "brushes-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>", gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>",
@ -240,7 +241,7 @@ menus_init (Gimp *gimp)
"patterns", "patterns",
NULL, NULL,
"/patterns-popup", "/patterns-popup",
"patterns-menu.xml", "patterns-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>", gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>",
@ -253,7 +254,7 @@ menus_init (Gimp *gimp)
"gradients", "gradients",
NULL, NULL,
"/gradients-popup", "/gradients-popup",
"gradients-menu.xml", "gradients-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>", gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>",
@ -266,7 +267,7 @@ menus_init (Gimp *gimp)
"palettes", "palettes",
NULL, NULL,
"/palettes-popup", "/palettes-popup",
"palettes-menu.xml", "palettes-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Fonts>", gimp_menu_factory_menu_register (global_menu_factory, "<Fonts>",
@ -279,7 +280,7 @@ menus_init (Gimp *gimp)
"fonts", "fonts",
NULL, NULL,
"/fonts-popup", "/fonts-popup",
"fonts-menu.xml", "fonts-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>", gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>",
@ -292,7 +293,7 @@ menus_init (Gimp *gimp)
"buffers", "buffers",
NULL, NULL,
"/buffers-popup", "/buffers-popup",
"buffers-menu.xml", "buffers-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Documents>", gimp_menu_factory_menu_register (global_menu_factory, "<Documents>",
@ -305,7 +306,7 @@ menus_init (Gimp *gimp)
"documents", "documents",
NULL, NULL,
"/documents-popup", "/documents-popup",
"documents-menu.xml", "documents-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Templates>", gimp_menu_factory_menu_register (global_menu_factory, "<Templates>",
@ -318,7 +319,7 @@ menus_init (Gimp *gimp)
"templates", "templates",
NULL, NULL,
"/templates-popup", "/templates-popup",
"templates-menu.xml", "templates-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Images>", gimp_menu_factory_menu_register (global_menu_factory, "<Images>",
@ -331,7 +332,7 @@ menus_init (Gimp *gimp)
"images", "images",
NULL, NULL,
"/images-popup", "/images-popup",
"images-menu.xml", "images-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>",
@ -344,7 +345,7 @@ menus_init (Gimp *gimp)
"gradient-editor", "gradient-editor",
NULL, NULL,
"/gradient-editor-popup", "/gradient-editor-popup",
"gradient-editor-menu.xml", "gradient-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>",
@ -357,7 +358,7 @@ menus_init (Gimp *gimp)
"palette-editor", "palette-editor",
NULL, NULL,
"/palette-editor-popup", "/palette-editor-popup",
"palette-editor-menu.xml", "palette-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>",
@ -370,7 +371,7 @@ menus_init (Gimp *gimp)
"colormap-editor", "colormap-editor",
NULL, NULL,
"/colormap-editor-popup", "/colormap-editor-popup",
"colormap-editor-menu.xml", "colormap-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<QMask>", gimp_menu_factory_menu_register (global_menu_factory, "<QMask>",
@ -383,7 +384,7 @@ menus_init (Gimp *gimp)
"qmask", "qmask",
NULL, NULL,
"/qmask-popup", "/qmask-popup",
"qmask-menu.xml", "qmask-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>", gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>",
@ -396,7 +397,7 @@ menus_init (Gimp *gimp)
"error-console", "error-console",
NULL, NULL,
"/error-console-popup", "/error-console-popup",
"error-console-menu.xml", "error-console-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>", gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>",
@ -410,7 +411,7 @@ menus_init (Gimp *gimp)
"tool-options", "tool-options",
NULL, NULL,
"/tool-options-popup", "/tool-options-popup",
"tool-options-menu.xml", "tool-options-menu.xml", NULL,
NULL); NULL);
} }
@ -461,6 +462,40 @@ menus_clear (Gimp *gimp)
g_print ("TODO: implement menus_clear()\n"); g_print ("TODO: implement menus_clear()\n");
} }
void
menus_open_recent_add (GimpUIManager *manager,
const gchar *ui_path)
{
gint n_entries;
gint merge_id;
gint i;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
n_entries = GIMP_GUI_CONFIG (manager->gimp->config)->last_opened_size;
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (i = 0; i < n_entries; i++)
{
gchar *action_name;
gchar *action_path;
action_name = g_strdup_printf ("file-open-recent-%02d", i + 1);
action_path = g_strdup_printf ("%s/file-menu/file-open-recent-menu/file-open-recent-placeholder",
ui_path);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
action_path, action_name, action_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
g_free (action_name);
g_free (action_path);
}
}
void void
menus_last_opened_add (GimpItemFactory *item_factory) menus_last_opened_add (GimpItemFactory *item_factory)
{ {

View File

@ -36,6 +36,9 @@ void menus_restore (Gimp *gimp);
void menus_save (Gimp *gimp); void menus_save (Gimp *gimp);
void menus_clear (Gimp *gimp); void menus_clear (Gimp *gimp);
void menus_open_recent_add (GimpUIManager *manager,
const gchar *ui_path);
void menus_last_opened_add (GimpItemFactory *item_factory); void menus_last_opened_add (GimpItemFactory *item_factory);
void menus_filters_subdirs_to_top (GtkMenu *menu); void menus_filters_subdirs_to_top (GtkMenu *menu);

View File

@ -285,6 +285,13 @@ GimpItemFactoryEntry toolbox_menu_entries[] =
gint n_toolbox_menu_entries = G_N_ELEMENTS (toolbox_menu_entries); gint n_toolbox_menu_entries = G_N_ELEMENTS (toolbox_menu_entries);
void
toolbox_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path)
{
menus_open_recent_add (manager, ui_path);
}
void void
toolbox_menu_setup (GimpItemFactory *factory, toolbox_menu_setup (GimpItemFactory *factory,
gpointer callback_data) gpointer callback_data)

View File

@ -24,6 +24,9 @@ extern GimpItemFactoryEntry toolbox_menu_entries[];
extern gint n_toolbox_menu_entries; extern gint n_toolbox_menu_entries;
void toolbox_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path);
void toolbox_menu_setup (GimpItemFactory *factory, void toolbox_menu_setup (GimpItemFactory *factory,
gpointer callback_data); gpointer callback_data);

View File

@ -1135,6 +1135,13 @@ GimpItemFactoryEntry image_menu_entries[] =
gint n_image_menu_entries = G_N_ELEMENTS (image_menu_entries); gint n_image_menu_entries = G_N_ELEMENTS (image_menu_entries);
void
image_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path)
{
menus_open_recent_add (manager, ui_path);
}
void void
image_menu_setup (GimpItemFactory *factory, image_menu_setup (GimpItemFactory *factory,
gpointer setup_data) gpointer setup_data)

View File

@ -24,6 +24,9 @@ extern GimpItemFactoryEntry image_menu_entries[];
extern gint n_image_menu_entries; extern gint n_image_menu_entries;
void image_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path);
void image_menu_setup (GimpItemFactory *factory, void image_menu_setup (GimpItemFactory *factory,
gpointer callback_data); gpointer callback_data);
void image_menu_update (GtkItemFactory *factory, void image_menu_update (GtkItemFactory *factory,

View File

@ -36,6 +36,7 @@
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h" #include "widgets/gimpitemfactory.h"
#include "widgets/gimpmenufactory.h" #include "widgets/gimpmenufactory.h"
#include "widgets/gimpuimanager.h"
#include "actions/actions.h" #include "actions/actions.h"
#include "actions/file-commands.h" #include "actions/file-commands.h"
@ -143,11 +144,11 @@ menus_init (Gimp *gimp)
"qmask", "qmask",
NULL, NULL,
"/toolbox-menubar", "/toolbox-menubar",
"toolbox-menu.xml", "toolbox-menu.xml", toolbox_menu_setup2,
"/image-menubar", "/image-menubar",
"image-menu.xml", "image-menu.xml", image_menu_setup2,
"/qmask-popup", "/qmask-popup",
"qmask-menu.xml", "qmask-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Load>", gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
@ -175,7 +176,7 @@ menus_init (Gimp *gimp)
"layers", "layers",
NULL, NULL,
"/layers-popup", "/layers-popup",
"layers-menu.xml", "layers-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Channels>", gimp_menu_factory_menu_register (global_menu_factory, "<Channels>",
@ -188,7 +189,7 @@ menus_init (Gimp *gimp)
"channels", "channels",
NULL, NULL,
"/channels-popup", "/channels-popup",
"channels-menu.xml", "channels-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>", gimp_menu_factory_menu_register (global_menu_factory, "<Vectors>",
@ -201,7 +202,7 @@ menus_init (Gimp *gimp)
"vectors", "vectors",
NULL, NULL,
"/vectors-popup", "/vectors-popup",
"vectors-menu.xml", "vectors-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>", gimp_menu_factory_menu_register (global_menu_factory, "<Dialogs>",
@ -214,7 +215,7 @@ menus_init (Gimp *gimp)
"dockable", "dockable",
NULL, NULL,
"/dockable-popup", "/dockable-popup",
"dockable-menu.xml", "dockable-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>", gimp_menu_factory_menu_register (global_menu_factory, "<Brushes>",
@ -227,7 +228,7 @@ menus_init (Gimp *gimp)
"brushes", "brushes",
NULL, NULL,
"/brushes-popup", "/brushes-popup",
"brushes-menu.xml", "brushes-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>", gimp_menu_factory_menu_register (global_menu_factory, "<Patterns>",
@ -240,7 +241,7 @@ menus_init (Gimp *gimp)
"patterns", "patterns",
NULL, NULL,
"/patterns-popup", "/patterns-popup",
"patterns-menu.xml", "patterns-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>", gimp_menu_factory_menu_register (global_menu_factory, "<Gradients>",
@ -253,7 +254,7 @@ menus_init (Gimp *gimp)
"gradients", "gradients",
NULL, NULL,
"/gradients-popup", "/gradients-popup",
"gradients-menu.xml", "gradients-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>", gimp_menu_factory_menu_register (global_menu_factory, "<Palettes>",
@ -266,7 +267,7 @@ menus_init (Gimp *gimp)
"palettes", "palettes",
NULL, NULL,
"/palettes-popup", "/palettes-popup",
"palettes-menu.xml", "palettes-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Fonts>", gimp_menu_factory_menu_register (global_menu_factory, "<Fonts>",
@ -279,7 +280,7 @@ menus_init (Gimp *gimp)
"fonts", "fonts",
NULL, NULL,
"/fonts-popup", "/fonts-popup",
"fonts-menu.xml", "fonts-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>", gimp_menu_factory_menu_register (global_menu_factory, "<Buffers>",
@ -292,7 +293,7 @@ menus_init (Gimp *gimp)
"buffers", "buffers",
NULL, NULL,
"/buffers-popup", "/buffers-popup",
"buffers-menu.xml", "buffers-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Documents>", gimp_menu_factory_menu_register (global_menu_factory, "<Documents>",
@ -305,7 +306,7 @@ menus_init (Gimp *gimp)
"documents", "documents",
NULL, NULL,
"/documents-popup", "/documents-popup",
"documents-menu.xml", "documents-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Templates>", gimp_menu_factory_menu_register (global_menu_factory, "<Templates>",
@ -318,7 +319,7 @@ menus_init (Gimp *gimp)
"templates", "templates",
NULL, NULL,
"/templates-popup", "/templates-popup",
"templates-menu.xml", "templates-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Images>", gimp_menu_factory_menu_register (global_menu_factory, "<Images>",
@ -331,7 +332,7 @@ menus_init (Gimp *gimp)
"images", "images",
NULL, NULL,
"/images-popup", "/images-popup",
"images-menu.xml", "images-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<GradientEditor>",
@ -344,7 +345,7 @@ menus_init (Gimp *gimp)
"gradient-editor", "gradient-editor",
NULL, NULL,
"/gradient-editor-popup", "/gradient-editor-popup",
"gradient-editor-menu.xml", "gradient-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<PaletteEditor>",
@ -357,7 +358,7 @@ menus_init (Gimp *gimp)
"palette-editor", "palette-editor",
NULL, NULL,
"/palette-editor-popup", "/palette-editor-popup",
"palette-editor-menu.xml", "palette-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>", gimp_menu_factory_menu_register (global_menu_factory, "<ColormapEditor>",
@ -370,7 +371,7 @@ menus_init (Gimp *gimp)
"colormap-editor", "colormap-editor",
NULL, NULL,
"/colormap-editor-popup", "/colormap-editor-popup",
"colormap-editor-menu.xml", "colormap-editor-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<QMask>", gimp_menu_factory_menu_register (global_menu_factory, "<QMask>",
@ -383,7 +384,7 @@ menus_init (Gimp *gimp)
"qmask", "qmask",
NULL, NULL,
"/qmask-popup", "/qmask-popup",
"qmask-menu.xml", "qmask-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>", gimp_menu_factory_menu_register (global_menu_factory, "<ErrorConsole>",
@ -396,7 +397,7 @@ menus_init (Gimp *gimp)
"error-console", "error-console",
NULL, NULL,
"/error-console-popup", "/error-console-popup",
"error-console-menu.xml", "error-console-menu.xml", NULL,
NULL); NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>", gimp_menu_factory_menu_register (global_menu_factory, "<ToolOptions>",
@ -410,7 +411,7 @@ menus_init (Gimp *gimp)
"tool-options", "tool-options",
NULL, NULL,
"/tool-options-popup", "/tool-options-popup",
"tool-options-menu.xml", "tool-options-menu.xml", NULL,
NULL); NULL);
} }
@ -461,6 +462,40 @@ menus_clear (Gimp *gimp)
g_print ("TODO: implement menus_clear()\n"); g_print ("TODO: implement menus_clear()\n");
} }
void
menus_open_recent_add (GimpUIManager *manager,
const gchar *ui_path)
{
gint n_entries;
gint merge_id;
gint i;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (ui_path != NULL);
n_entries = GIMP_GUI_CONFIG (manager->gimp->config)->last_opened_size;
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (i = 0; i < n_entries; i++)
{
gchar *action_name;
gchar *action_path;
action_name = g_strdup_printf ("file-open-recent-%02d", i + 1);
action_path = g_strdup_printf ("%s/file-menu/file-open-recent-menu/file-open-recent-placeholder",
ui_path);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
action_path, action_name, action_name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
g_free (action_name);
g_free (action_path);
}
}
void void
menus_last_opened_add (GimpItemFactory *item_factory) menus_last_opened_add (GimpItemFactory *item_factory)
{ {

View File

@ -36,6 +36,9 @@ void menus_restore (Gimp *gimp);
void menus_save (Gimp *gimp); void menus_save (Gimp *gimp);
void menus_clear (Gimp *gimp); void menus_clear (Gimp *gimp);
void menus_open_recent_add (GimpUIManager *manager,
const gchar *ui_path);
void menus_last_opened_add (GimpItemFactory *item_factory); void menus_last_opened_add (GimpItemFactory *item_factory);
void menus_filters_subdirs_to_top (GtkMenu *menu); void menus_filters_subdirs_to_top (GtkMenu *menu);

View File

@ -285,6 +285,13 @@ GimpItemFactoryEntry toolbox_menu_entries[] =
gint n_toolbox_menu_entries = G_N_ELEMENTS (toolbox_menu_entries); gint n_toolbox_menu_entries = G_N_ELEMENTS (toolbox_menu_entries);
void
toolbox_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path)
{
menus_open_recent_add (manager, ui_path);
}
void void
toolbox_menu_setup (GimpItemFactory *factory, toolbox_menu_setup (GimpItemFactory *factory,
gpointer callback_data) gpointer callback_data)

View File

@ -24,6 +24,9 @@ extern GimpItemFactoryEntry toolbox_menu_entries[];
extern gint n_toolbox_menu_entries; extern gint n_toolbox_menu_entries;
void toolbox_menu_setup2 (GimpUIManager *manager,
const gchar *ui_path);
void toolbox_menu_setup (GimpItemFactory *factory, void toolbox_menu_setup (GimpItemFactory *factory,
gpointer callback_data); gpointer callback_data);

View File

@ -113,7 +113,7 @@ gimp_menu_factory_finalize (GObject *object)
{ {
GimpUIManagerUIEntry *ui_entry = uis->data; GimpUIManagerUIEntry *ui_entry = uis->data;
g_free (ui_entry->identifier); g_free (ui_entry->ui_path);
g_free (ui_entry->basename); g_free (ui_entry->basename);
g_free (ui_entry); g_free (ui_entry);
} }
@ -244,8 +244,9 @@ gimp_menu_factory_manager_register (GimpMenuFactory *factory,
if (! strcmp (entry->identifier, identifier)) if (! strcmp (entry->identifier, identifier))
{ {
const gchar *group; const gchar *group;
const gchar *ui_identifier; const gchar *ui_path;
const gchar *ui_basename; const gchar *ui_basename;
GimpUIManagerSetupFunc setup_func;
va_list args; va_list args;
g_return_if_fail (entry->action_groups == NULL); g_return_if_fail (entry->action_groups == NULL);
@ -262,25 +263,27 @@ gimp_menu_factory_manager_register (GimpMenuFactory *factory,
entry->action_groups = g_list_reverse (entry->action_groups); entry->action_groups = g_list_reverse (entry->action_groups);
ui_identifier = va_arg (args, const gchar *); ui_path = va_arg (args, const gchar *);
while (ui_identifier) while (ui_path)
{ {
GimpUIManagerUIEntry *ui_entry; GimpUIManagerUIEntry *ui_entry;
ui_basename = va_arg (args, const gchar *); ui_basename = va_arg (args, const gchar *);
setup_func = va_arg (args, GimpUIManagerSetupFunc);
ui_entry = g_new0 (GimpUIManagerUIEntry, 1); ui_entry = g_new0 (GimpUIManagerUIEntry, 1);
ui_entry->identifier = g_strdup (ui_identifier); ui_entry->ui_path = g_strdup (ui_path);
ui_entry->basename = g_strdup (ui_basename); ui_entry->basename = g_strdup (ui_basename);
ui_entry->setup_func = setup_func;
ui_entry->merge_id = 0; ui_entry->merge_id = 0;
ui_entry->widget = NULL; ui_entry->widget = NULL;
entry->managed_uis = g_list_prepend (entry->managed_uis, entry->managed_uis = g_list_prepend (entry->managed_uis,
ui_entry); ui_entry);
ui_identifier = va_arg (args, const gchar *); ui_path = va_arg (args, const gchar *);
} }
entry->managed_uis = g_list_reverse (entry->managed_uis); entry->managed_uis = g_list_reverse (entry->managed_uis);
@ -337,8 +340,9 @@ gimp_menu_factory_manager_new (GimpMenuFactory *factory,
GimpUIManagerUIEntry *ui_entry = list->data; GimpUIManagerUIEntry *ui_entry = list->data;
gimp_ui_manager_ui_register (manager, gimp_ui_manager_ui_register (manager,
ui_entry->identifier, ui_entry->ui_path,
ui_entry->basename); ui_entry->basename,
ui_entry->setup_func);
} }
return manager; return manager;

View File

@ -122,7 +122,7 @@ gimp_ui_manager_finalize (GObject *object)
{ {
GimpUIManagerUIEntry *entry = list->data; GimpUIManagerUIEntry *entry = list->data;
g_free (entry->identifier); g_free (entry->ui_path);
g_free (entry->basename); g_free (entry->basename);
if (entry->widget) if (entry->widget)
@ -215,19 +215,21 @@ gimp_ui_manager_update (GimpUIManager *manager,
void void
gimp_ui_manager_ui_register (GimpUIManager *manager, gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *identifier, const gchar *ui_path,
const gchar *basename) const gchar *basename,
GimpUIManagerSetupFunc setup_func)
{ {
GimpUIManagerUIEntry *entry; GimpUIManagerUIEntry *entry;
g_return_if_fail (GIMP_IS_UI_MANAGER (manager)); g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
g_return_if_fail (identifier != NULL); g_return_if_fail (ui_path != NULL);
g_return_if_fail (basename != NULL); g_return_if_fail (basename != NULL);
entry = g_new0 (GimpUIManagerUIEntry, 1); entry = g_new0 (GimpUIManagerUIEntry, 1);
entry->identifier = g_strdup (identifier); entry->ui_path = g_strdup (ui_path);
entry->basename = g_strdup (basename); entry->basename = g_strdup (basename);
entry->setup_func = setup_func;
entry->merge_id = 0; entry->merge_id = 0;
entry->widget = NULL; entry->widget = NULL;
@ -241,7 +243,7 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
entry->basename, NULL); entry->basename, NULL);
g_print ("loading menu: %s for %s\n", filename, g_print ("loading menu: %s for %s\n", filename,
entry->identifier); entry->ui_path);
entry->merge_id = entry->merge_id =
gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager), gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager),
@ -259,18 +261,18 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
GtkWidget * GtkWidget *
gimp_ui_manager_ui_get (GimpUIManager *manager, gimp_ui_manager_ui_get (GimpUIManager *manager,
const gchar *identifier) const gchar *ui_path)
{ {
GList *list; GList *list;
g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL); g_return_val_if_fail (GIMP_IS_UI_MANAGER (manager), NULL);
g_return_val_if_fail (identifier != NULL, NULL); g_return_val_if_fail (ui_path != NULL, NULL);
for (list = manager->registered_uis; list; list = g_list_next (list)) for (list = manager->registered_uis; list; list = g_list_next (list))
{ {
GimpUIManagerUIEntry *entry = list->data; GimpUIManagerUIEntry *entry = list->data;
if (! strcmp (entry->identifier, identifier)) if (! strcmp (entry->ui_path, ui_path))
{ {
if (! entry->merge_id) if (! entry->merge_id)
{ {
@ -281,7 +283,7 @@ gimp_ui_manager_ui_get (GimpUIManager *manager,
entry->basename, NULL); entry->basename, NULL);
g_print ("loading menu: %s for %s\n", filename, g_print ("loading menu: %s for %s\n", filename,
entry->identifier); entry->ui_path);
entry->merge_id = entry->merge_id =
gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager), gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager),
@ -302,10 +304,15 @@ gimp_ui_manager_ui_get (GimpUIManager *manager,
{ {
entry->widget = entry->widget =
gtk_ui_manager_get_widget (GTK_UI_MANAGER (manager), gtk_ui_manager_get_widget (GTK_UI_MANAGER (manager),
entry->identifier); entry->ui_path);
if (entry->widget) if (entry->widget)
{
g_object_ref (entry->widget); g_object_ref (entry->widget);
if (entry->setup_func)
entry->setup_func (manager, entry->ui_path);
}
} }
return entry->widget; return entry->widget;
@ -313,7 +320,7 @@ gimp_ui_manager_ui_get (GimpUIManager *manager,
} }
g_warning ("%s: no entry registered for \"%s\"", g_warning ("%s: no entry registered for \"%s\"",
G_STRFUNC, identifier); G_STRFUNC, ui_path);
return NULL; return NULL;
} }

View File

@ -29,8 +29,9 @@ typedef struct _GimpUIManagerUIEntry GimpUIManagerUIEntry;
struct _GimpUIManagerUIEntry struct _GimpUIManagerUIEntry
{ {
gchar *identifier; gchar *ui_path;
gchar *basename; gchar *basename;
GimpUIManagerSetupFunc setup_func;
guint merge_id; guint merge_id;
GtkWidget *widget; GtkWidget *widget;
}; };
@ -67,10 +68,11 @@ void gimp_ui_manager_update (GimpUIManager *manager,
gpointer update_data); gpointer update_data);
void gimp_ui_manager_ui_register (GimpUIManager *manager, void gimp_ui_manager_ui_register (GimpUIManager *manager,
const gchar *identifier, const gchar *ui_path,
const gchar *basename); const gchar *basename,
GimpUIManagerSetupFunc setup_func);
GtkWidget * gimp_ui_manager_ui_get (GimpUIManager *manager, GtkWidget * gimp_ui_manager_ui_get (GimpUIManager *manager,
const gchar *identifier); const gchar *ui_path);
void gimp_ui_manager_ui_popup (GimpUIManager *manager, void gimp_ui_manager_ui_popup (GimpUIManager *manager,
const gchar *ui_path, const gchar *ui_path,

View File

@ -150,6 +150,9 @@ typedef void (* GimpActionGroupSetupFunc) (GimpActionGroup *factory,
typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *factory, typedef void (* GimpActionGroupUpdateFunc) (GimpActionGroup *factory,
gpointer data); gpointer data);
typedef void (* GimpUIManagerSetupFunc) (GimpUIManager *manager,
const gchar *ui_path);
typedef void (* GimpMenuPositionFunc) (GtkMenu *menu, typedef void (* GimpMenuPositionFunc) (GtkMenu *menu,
gint *x, gint *x,
gint *y, gint *y,

View File

@ -8,7 +8,7 @@
<menuitem action="file-new" /> <menuitem action="file-new" />
<menuitem action="file-open" /> <menuitem action="file-open" />
<menu action="file-open-recent-menu"> <menu action="file-open-recent-menu">
<menuitem action="file-open-recent-empty" /> <placeholder name="file-open-recent-placeholder" />
<separator /> <separator />
<menuitem action="dialogs-document-history" /> <menuitem action="dialogs-document-history" />
</menu> </menu>

View File

@ -8,7 +8,7 @@
<menuitem action="file-new" /> <menuitem action="file-new" />
<menuitem action="file-open" /> <menuitem action="file-open" />
<menu action="file-open-recent-menu"> <menu action="file-open-recent-menu">
<menuitem action="file-open-recent-empty" /> <placeholder name="file-open-recent-placeholder" />
<separator /> <separator />
<menuitem action="dialogs-document-history" /> <menuitem action="dialogs-document-history" />
</menu> </menu>