app/actions/Makefile.am app/actions/file-open-actions.[ch] actions for the

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

	* app/actions/Makefile.am
	* app/actions/file-open-actions.[ch]
	* app/actions/file-save-actions.[ch]: actions for the <Load> and
	<Save> menus...

	* menus/Makefile.am
	* menus/file-open-menu.xml
	* menus/file-save-menu.xml: ...and the menus.

	* app/gui/file-open-menu.[ch]
	* app/gui/file-save-menu.[ch]: ported to UI Manager.

	* app/widgets/gimpfiledialog.[ch]: ditto.

	* app/actions/actions.c
	* app/gui/menus.c
	* app/gui/file-open-dialog.c
	* app/gui/file-save-dialog.c: changed accordingly.

	* app/widgets/gimpuimanager.c: removed debugging code which
	automatically loaded all registered menus. They are now loaded on
This commit is contained in:
Michael Natterer 2004-04-29 17:47:53 +00:00 committed by Michael Natterer
parent d79ed2a040
commit 0e1af3ee5a
28 changed files with 499 additions and 427 deletions

View File

@ -1,3 +1,28 @@
2004-04-29 Michael Natterer <mitch@gimp.org>
* app/actions/Makefile.am
* app/actions/file-open-actions.[ch]
* app/actions/file-save-actions.[ch]: actions for the <Load> and
<Save> menus...
* menus/Makefile.am
* menus/file-open-menu.xml
* menus/file-save-menu.xml: ...and the menus.
* app/gui/file-open-menu.[ch]
* app/gui/file-save-menu.[ch]: ported to UI Manager.
* app/widgets/gimpfiledialog.[ch]: ditto.
* app/actions/actions.c
* app/gui/menus.c
* app/gui/file-open-dialog.c
* app/gui/file-save-dialog.c: changed accordingly.
* app/widgets/gimpuimanager.c: removed debugging code which
automatically loaded all registered menus. They are now loaded on
demand only.
2004-04-29 Michael Natterer <mitch@gimp.org>
* libgimpbase/gimputils.[ch] (gimp_escape_uline): new function

View File

@ -55,6 +55,12 @@ libappactions_a_SOURCES = \
file-actions.h \
file-commands.c \
file-commands.h \
file-open-actions.c \
file-open-actions.h \
file-save-actions.c \
file-save-actions.h \
file-commands.c \
file-commands.h \
fonts-actions.c \
fonts-actions.h \
fonts-commands.c \

View File

@ -40,6 +40,8 @@
#include "edit-actions.h"
#include "error-console-actions.h"
#include "file-actions.h"
#include "file-open-actions.h"
#include "file-save-actions.h"
#include "fonts-actions.h"
#include "gradient-editor-actions.h"
#include "gradients-actions.h"
@ -105,6 +107,12 @@ static GimpActionFactoryEntry action_groups[] =
{ "file",
file_actions_setup,
file_actions_update },
{ "file-open",
file_open_actions_setup,
file_open_actions_update },
{ "file-save",
file_save_actions_setup,
file_save_actions_update },
{ "fonts",
fonts_actions_setup,
fonts_actions_update },

View File

@ -0,0 +1,119 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "file-commands.h"
#include "file-open-actions.h"
#include "gimp-intl.h"
static GimpActionEntry file_open_actions[] =
{
{ "file-open-popup", NULL, N_("File Open Menu") },
{ "file-open-automatic", NULL,
N_("Automatic"), NULL, NULL,
G_CALLBACK (file_type_cmd_callback),
GIMP_HELP_FILE_OPEN_BY_EXTENSION }
};
void
file_open_actions_setup (GimpActionGroup *group)
{
GSList *list;
gimp_action_group_add_actions (group,
file_open_actions,
G_N_ELEMENTS (file_open_actions));
for (list = group->gimp->load_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpActionEntry entry;
gboolean is_xcf;
GtkAction *action;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_load") == 0);
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_OPEN_XCF);
}
else
{
const gchar *progname;
const gchar *help_domain;
progname = plug_in_proc_def_get_progname (file_proc);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (file_type_cmd_callback);
entry.help_id = help_id;
gimp_action_group_add_actions (group, &entry, 1);
g_free (help_id);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
file_proc->db_info.name);
g_object_set_data (G_OBJECT (action), "file-proc", file_proc);
}
}
void
file_open_actions_update (GimpActionGroup *group,
gpointer data)
{
}

View File

@ -0,0 +1,28 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __FILE_OPEN_ACTIONS_H__
#define __FILE_OPEN_ACTIONS_H__
void file_open_actions_setup (GimpActionGroup *group);
void file_open_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __FILE_OPEN_ACTIONS_H__ */

View File

@ -0,0 +1,119 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
#include "file-commands.h"
#include "file-save-actions.h"
#include "gimp-intl.h"
static GimpActionEntry file_save_actions[] =
{
{ "file-save-popup", NULL, N_("File Save Menu") },
{ "file-save-by-extension", NULL,
N_("By Extension"), NULL, NULL,
G_CALLBACK (file_type_cmd_callback),
GIMP_HELP_FILE_SAVE_BY_EXTENSION }
};
void
file_save_actions_setup (GimpActionGroup *group)
{
GSList *list;
gimp_action_group_add_actions (group,
file_save_actions,
G_N_ELEMENTS (file_save_actions));
for (list = group->gimp->save_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpActionEntry entry;
gboolean is_xcf;
GtkAction *action;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_save") == 0);
if (is_xcf)
{
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
else
{
const gchar *progname;
const gchar *help_domain;
progname = plug_in_proc_def_get_progname (file_proc);
locale_domain = plug_ins_locale_domain (group->gimp, progname, NULL);
help_domain = plug_ins_help_domain (group->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.name = file_proc->db_info.name;
entry.stock_id = stock_id;
entry.label = strstr (file_proc->menu_path, "/") + 1;
entry.tooltip = NULL;
entry.callback = G_CALLBACK (file_type_cmd_callback);
entry.help_id = help_id;
gimp_action_group_add_actions (group, &entry, 1);
g_free (help_id);
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
file_proc->db_info.name);
g_object_set_data (G_OBJECT (action), "file-proc", file_proc);
}
}
void
file_save_actions_update (GimpActionGroup *group,
gpointer data)
{
}

View File

@ -0,0 +1,28 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __FILE_SAVE_ACTIONS_H__
#define __FILE_SAVE_ACTIONS_H__
void file_save_actions_setup (GimpActionGroup *group);
void file_save_actions_update (GimpActionGroup *group,
gpointer data);
#endif /* __FILE_SAVE_ACTIONS_H__ */

View File

@ -100,7 +100,7 @@ file_open_dialog_create (Gimp *gimp,
dialog = gimp_file_dialog_new (gimp, gimp->load_procs,
GTK_FILE_CHOOSER_ACTION_OPEN,
menu_factory, "<Load>",
menu_factory, "<Load>", "/file-open-popup",
_("Open Image"), "gimp-file-open",
GTK_STOCK_OPEN,
GIMP_HELP_FILE_OPEN);

View File

@ -148,7 +148,7 @@ file_save_dialog_create (Gimp *gimp,
save_dialog = gimp_file_dialog_new (gimp, gimp->save_procs,
GTK_FILE_CHOOSER_ACTION_SAVE,
menu_factory, "<Save>",
menu_factory, "<Save>", "/file-save-popup",
_("Save Image"), "gimp-file-save",
GTK_STOCK_SAVE,
GIMP_HELP_FILE_SAVE);

View File

@ -100,7 +100,7 @@ file_open_dialog_create (Gimp *gimp,
dialog = gimp_file_dialog_new (gimp, gimp->load_procs,
GTK_FILE_CHOOSER_ACTION_OPEN,
menu_factory, "<Load>",
menu_factory, "<Load>", "/file-open-popup",
_("Open Image"), "gimp-file-open",
GTK_STOCK_OPEN,
GIMP_HELP_FILE_OPEN);

View File

@ -22,106 +22,43 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h"
#include "actions/file-commands.h"
#include "widgets/gimpuimanager.h"
#include "file-open-menu.h"
#include "gimp-intl.h"
GimpItemFactoryEntry file_open_menu_entries[] =
{
{ { N_("/Automatic"), NULL,
file_type_cmd_callback, 0 },
NULL,
GIMP_HELP_FILE_OPEN_BY_EXTENSION, NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
};
gint n_file_open_menu_entries = G_N_ELEMENTS (file_open_menu_entries);
void
file_open_menu_setup (GimpItemFactory *factory,
gpointer callback_data)
file_open_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GSList *list;
guint merge_id;
for (list = factory->gimp->load_procs; list; list = g_slist_next (list))
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (list = manager->gimp->load_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *item_type = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpItemFactoryEntry entry;
gboolean is_xcf;
GtkWidget *menu_item;
PlugInProcDef *file_proc = list->data;
gchar *path;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_load") == 0);
if (is_xcf)
{
item_type = "<StockItem>";
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_OPEN_XCF);
}
if (! strcmp (file_proc->db_info.name, "gimp_xcf_load"))
path = g_strdup_printf ("%s/%s", ui_path, "Internal");
else
{
const gchar *progname;
const gchar *help_domain;
path = g_strdup (ui_path);
progname = plug_in_proc_def_get_progname (file_proc);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
path,
file_proc->db_info.name,
file_proc->db_info.name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
locale_domain = plug_ins_locale_domain (factory->gimp, progname, NULL);
help_domain = plug_ins_help_domain (factory->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.entry.path = strstr (file_proc->menu_path, "/");
entry.entry.accelerator = NULL;
entry.entry.callback = file_type_cmd_callback;
entry.entry.callback_action = 0;
entry.entry.item_type = (gchar *) item_type;
entry.entry.extra_data = stock_id;
entry.quark_string = NULL;
entry.help_id = help_id;
entry.description = NULL;
gimp_item_factory_create_item (factory,
&entry,
locale_domain,
callback_data, 2, FALSE);
menu_item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY (factory),
entry.entry.path);
if (menu_item)
{
g_object_set_data (G_OBJECT (menu_item), "file-proc", file_proc);
if (is_xcf)
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, 1);
}
g_free (help_id);
g_free (path);
}
}

View File

@ -20,12 +20,8 @@
#define __FILE_OPEN_MENU_H__
extern GimpItemFactoryEntry file_open_menu_entries[];
extern gint n_file_open_menu_entries;
void file_open_menu_setup (GimpItemFactory *factory,
gpointer callback_data);
void file_open_menu_setup (GimpUIManager *manager,
const gchar *ui_path);
#endif /* __FILE_OPEN_MENU_H__ */

View File

@ -148,7 +148,7 @@ file_save_dialog_create (Gimp *gimp,
save_dialog = gimp_file_dialog_new (gimp, gimp->save_procs,
GTK_FILE_CHOOSER_ACTION_SAVE,
menu_factory, "<Save>",
menu_factory, "<Save>", "/file-save-popup",
_("Save Image"), "gimp-file-save",
GTK_STOCK_SAVE,
GIMP_HELP_FILE_SAVE);

View File

@ -22,113 +22,43 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h"
#include "actions/file-commands.h"
#include "widgets/gimpuimanager.h"
#include "file-save-menu.h"
#include "gimp-intl.h"
GimpItemFactoryEntry file_save_menu_entries[] =
{
{ { N_("/By Extension"), NULL,
file_type_cmd_callback, 0 },
NULL,
GIMP_HELP_FILE_SAVE_BY_EXTENSION, NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
};
gint n_file_save_menu_entries = G_N_ELEMENTS (file_save_menu_entries);
void
file_save_menu_setup (GimpItemFactory *factory,
gpointer callback_data)
file_save_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GSList *list;
guint merge_id;
for (list = factory->gimp->save_procs; list; list = g_slist_next (list))
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (list = manager->gimp->save_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *item_type = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpItemFactoryEntry entry;
gboolean is_xcf;
GtkWidget *menu_item;
PlugInProcDef *file_proc = list->data;
gchar *path;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_save") == 0);
if (is_xcf)
{
item_type = "<StockItem>";
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
if (! strcmp (file_proc->db_info.name, "gimp_xcf_save"))
path = g_strdup_printf ("%s/%s", ui_path, "Internal");
else
{
const gchar *progname;
const gchar *help_domain;
path = g_strdup (ui_path);
progname = plug_in_proc_def_get_progname (file_proc);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
path,
file_proc->db_info.name,
file_proc->db_info.name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
locale_domain = plug_ins_locale_domain (factory->gimp, progname, NULL);
help_domain = plug_ins_help_domain (factory->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.entry.path = strstr (file_proc->menu_path, "/");
entry.entry.accelerator = NULL;
entry.entry.callback = file_type_cmd_callback;
entry.entry.callback_action = 0;
entry.entry.item_type = (gchar *) item_type;
entry.entry.extra_data = stock_id;
entry.quark_string = NULL;
entry.help_id = help_id;
entry.description = NULL;
gimp_item_factory_create_item (factory,
&entry,
locale_domain,
callback_data, 2, FALSE);
menu_item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY (factory),
entry.entry.path);
if (menu_item)
{
g_object_set_data (G_OBJECT (menu_item), "file-proc", file_proc);
if (is_xcf)
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, 1);
}
g_free (help_id);
g_free (path);
}
}
void
file_save_menu_update (GtkItemFactory *item_factory,
gpointer data)
{
}

View File

@ -20,14 +20,8 @@
#define __FILE_SAVE_MENU_H__
extern GimpItemFactoryEntry file_save_menu_entries[];
extern gint n_file_save_menu_entries;
void file_save_menu_setup (GimpItemFactory *factory,
gpointer callback_data);
void file_save_menu_update (GtkItemFactory *item_factory,
gpointer update_data);
void file_save_menu_setup (GimpUIManager *manager,
const gchar *ui_path);
#endif /* __FILE_SAVE_MENU_H__ */

View File

@ -119,17 +119,28 @@ menus_init (Gimp *gimp)
gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
_("Open Menu"),
GIMP_HELP_FILE_OPEN,
file_open_menu_setup, NULL, FALSE,
n_file_open_menu_entries,
file_open_menu_entries);
NULL, NULL, FALSE,
0, NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Load>",
"file-open",
NULL,
"/file-open-popup",
"file-open-menu.xml",
file_open_menu_setup,
NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Save>",
_("Save Menu"),
GIMP_HELP_FILE_SAVE,
file_save_menu_setup,
file_save_menu_update, FALSE,
n_file_save_menu_entries,
file_save_menu_entries);
NULL, NULL, FALSE,
0, NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Save>",
"file-save",
NULL,
"/file-save-popup",
"file-save-menu.xml",
file_save_menu_setup,
NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Layers>",
_("Layers Menu"),

View File

@ -22,106 +22,43 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h"
#include "actions/file-commands.h"
#include "widgets/gimpuimanager.h"
#include "file-open-menu.h"
#include "gimp-intl.h"
GimpItemFactoryEntry file_open_menu_entries[] =
{
{ { N_("/Automatic"), NULL,
file_type_cmd_callback, 0 },
NULL,
GIMP_HELP_FILE_OPEN_BY_EXTENSION, NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
};
gint n_file_open_menu_entries = G_N_ELEMENTS (file_open_menu_entries);
void
file_open_menu_setup (GimpItemFactory *factory,
gpointer callback_data)
file_open_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GSList *list;
guint merge_id;
for (list = factory->gimp->load_procs; list; list = g_slist_next (list))
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (list = manager->gimp->load_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *item_type = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpItemFactoryEntry entry;
gboolean is_xcf;
GtkWidget *menu_item;
PlugInProcDef *file_proc = list->data;
gchar *path;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_load") == 0);
if (is_xcf)
{
item_type = "<StockItem>";
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_OPEN_XCF);
}
if (! strcmp (file_proc->db_info.name, "gimp_xcf_load"))
path = g_strdup_printf ("%s/%s", ui_path, "Internal");
else
{
const gchar *progname;
const gchar *help_domain;
path = g_strdup (ui_path);
progname = plug_in_proc_def_get_progname (file_proc);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
path,
file_proc->db_info.name,
file_proc->db_info.name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
locale_domain = plug_ins_locale_domain (factory->gimp, progname, NULL);
help_domain = plug_ins_help_domain (factory->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.entry.path = strstr (file_proc->menu_path, "/");
entry.entry.accelerator = NULL;
entry.entry.callback = file_type_cmd_callback;
entry.entry.callback_action = 0;
entry.entry.item_type = (gchar *) item_type;
entry.entry.extra_data = stock_id;
entry.quark_string = NULL;
entry.help_id = help_id;
entry.description = NULL;
gimp_item_factory_create_item (factory,
&entry,
locale_domain,
callback_data, 2, FALSE);
menu_item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY (factory),
entry.entry.path);
if (menu_item)
{
g_object_set_data (G_OBJECT (menu_item), "file-proc", file_proc);
if (is_xcf)
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, 1);
}
g_free (help_id);
g_free (path);
}
}

View File

@ -20,12 +20,8 @@
#define __FILE_OPEN_MENU_H__
extern GimpItemFactoryEntry file_open_menu_entries[];
extern gint n_file_open_menu_entries;
void file_open_menu_setup (GimpItemFactory *factory,
gpointer callback_data);
void file_open_menu_setup (GimpUIManager *manager,
const gchar *ui_path);
#endif /* __FILE_OPEN_MENU_H__ */

View File

@ -22,113 +22,43 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "plug-in/plug-in-proc.h"
#include "plug-in/plug-ins.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpitemfactory.h"
#include "actions/file-commands.h"
#include "widgets/gimpuimanager.h"
#include "file-save-menu.h"
#include "gimp-intl.h"
GimpItemFactoryEntry file_save_menu_entries[] =
{
{ { N_("/By Extension"), NULL,
file_type_cmd_callback, 0 },
NULL,
GIMP_HELP_FILE_SAVE_BY_EXTENSION, NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" }, NULL, NULL, NULL }
};
gint n_file_save_menu_entries = G_N_ELEMENTS (file_save_menu_entries);
void
file_save_menu_setup (GimpItemFactory *factory,
gpointer callback_data)
file_save_menu_setup (GimpUIManager *manager,
const gchar *ui_path)
{
GSList *list;
guint merge_id;
for (list = factory->gimp->save_procs; list; list = g_slist_next (list))
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
for (list = manager->gimp->save_procs; list; list = g_slist_next (list))
{
PlugInProcDef *file_proc = list->data;
const gchar *locale_domain = NULL;
const gchar *item_type = NULL;
const gchar *stock_id = NULL;
gchar *help_id;
GimpItemFactoryEntry entry;
gboolean is_xcf;
GtkWidget *menu_item;
PlugInProcDef *file_proc = list->data;
gchar *path;
if (! file_proc->menu_path)
continue;
is_xcf = (strcmp (file_proc->db_info.name, "gimp_xcf_save") == 0);
if (is_xcf)
{
item_type = "<StockItem>";
stock_id = GIMP_STOCK_WILBER;
help_id = g_strdup (GIMP_HELP_FILE_SAVE_XCF);
}
if (! strcmp (file_proc->db_info.name, "gimp_xcf_save"))
path = g_strdup_printf ("%s/%s", ui_path, "Internal");
else
{
const gchar *progname;
const gchar *help_domain;
path = g_strdup (ui_path);
progname = plug_in_proc_def_get_progname (file_proc);
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
path,
file_proc->db_info.name,
file_proc->db_info.name,
GTK_UI_MANAGER_MENUITEM,
FALSE);
locale_domain = plug_ins_locale_domain (factory->gimp, progname, NULL);
help_domain = plug_ins_help_domain (factory->gimp, progname, NULL);
help_id = plug_in_proc_def_get_help_id (file_proc, help_domain);
}
entry.entry.path = strstr (file_proc->menu_path, "/");
entry.entry.accelerator = NULL;
entry.entry.callback = file_type_cmd_callback;
entry.entry.callback_action = 0;
entry.entry.item_type = (gchar *) item_type;
entry.entry.extra_data = stock_id;
entry.quark_string = NULL;
entry.help_id = help_id;
entry.description = NULL;
gimp_item_factory_create_item (factory,
&entry,
locale_domain,
callback_data, 2, FALSE);
menu_item = gtk_item_factory_get_widget (GTK_ITEM_FACTORY (factory),
entry.entry.path);
if (menu_item)
{
g_object_set_data (G_OBJECT (menu_item), "file-proc", file_proc);
if (is_xcf)
gtk_menu_reorder_child (GTK_MENU (menu_item->parent),
menu_item, 1);
}
g_free (help_id);
g_free (path);
}
}
void
file_save_menu_update (GtkItemFactory *item_factory,
gpointer data)
{
}

View File

@ -20,14 +20,8 @@
#define __FILE_SAVE_MENU_H__
extern GimpItemFactoryEntry file_save_menu_entries[];
extern gint n_file_save_menu_entries;
void file_save_menu_setup (GimpItemFactory *factory,
gpointer callback_data);
void file_save_menu_update (GtkItemFactory *item_factory,
gpointer update_data);
void file_save_menu_setup (GimpUIManager *manager,
const gchar *ui_path);
#endif /* __FILE_SAVE_MENU_H__ */

View File

@ -119,17 +119,28 @@ menus_init (Gimp *gimp)
gimp_menu_factory_menu_register (global_menu_factory, "<Load>",
_("Open Menu"),
GIMP_HELP_FILE_OPEN,
file_open_menu_setup, NULL, FALSE,
n_file_open_menu_entries,
file_open_menu_entries);
NULL, NULL, FALSE,
0, NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Load>",
"file-open",
NULL,
"/file-open-popup",
"file-open-menu.xml",
file_open_menu_setup,
NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Save>",
_("Save Menu"),
GIMP_HELP_FILE_SAVE,
file_save_menu_setup,
file_save_menu_update, FALSE,
n_file_save_menu_entries,
file_save_menu_entries);
NULL, NULL, FALSE,
0, NULL);
gimp_menu_factory_manager_register (global_menu_factory, "<Save>",
"file-save",
NULL,
"/file-save-popup",
"file-save-menu.xml",
file_save_menu_setup,
NULL);
gimp_menu_factory_menu_register (global_menu_factory, "<Layers>",
_("Layers Menu"),

View File

@ -39,9 +39,9 @@
#include "plug-in/plug-in-proc.h"
#include "gimpfiledialog.h"
#include "gimpitemfactory.h"
#include "gimpmenufactory.h"
#include "gimpthumbbox.h"
#include "gimpuimanager.h"
#include "gimppreviewrendererimagefile.h"
#include "gimppreview.h"
@ -117,10 +117,10 @@ gimp_file_dialog_destroy (GtkObject *object)
{
GimpFileDialog *dialog = GIMP_FILE_DIALOG (object);
if (dialog->item_factory)
if (dialog->manager)
{
g_object_unref (dialog->item_factory);
dialog->item_factory = NULL;
g_object_unref (dialog->manager);
dialog->manager = NULL;
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
@ -142,6 +142,7 @@ gimp_file_dialog_new (Gimp *gimp,
GtkFileChooserAction action,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_path,
const gchar *title,
const gchar *role,
const gchar *stock_id,
@ -158,6 +159,7 @@ gimp_file_dialog_new (Gimp *gimp,
g_return_val_if_fail (file_procs != NULL, NULL);
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
g_return_val_if_fail (menu_identifier != NULL, NULL);
g_return_val_if_fail (ui_path != NULL, NULL);
g_return_val_if_fail (title != NULL, NULL);
g_return_val_if_fail (role != NULL, NULL);
g_return_val_if_fail (stock_id != NULL, NULL);
@ -179,12 +181,11 @@ gimp_file_dialog_new (Gimp *gimp,
gimp_help_connect (GTK_WIDGET (dialog), gimp_standard_help_func,
help_id, NULL);
dialog->gimp = gimp;
dialog->item_factory = gimp_menu_factory_menu_new (menu_factory,
menu_identifier,
GTK_TYPE_MENU,
dialog,
FALSE);
dialog->gimp = gimp;
dialog->manager = gimp_menu_factory_manager_new (menu_factory,
menu_identifier,
dialog,
FALSE);
hbox = gtk_hbox_new (FALSE, 4);
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
@ -192,7 +193,7 @@ gimp_file_dialog_new (Gimp *gimp,
option_menu = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu),
GTK_ITEM_FACTORY (dialog->item_factory)->widget);
gimp_ui_manager_ui_get (dialog->manager, ui_path));
gtk_box_pack_end (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
gtk_widget_show (option_menu);
@ -376,8 +377,8 @@ gimp_file_dialog_set_image (GimpFileDialog *dialog,
if (uri)
gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);
gimp_item_factory_update (dialog->item_factory,
gimp_image_active_drawable (gimage));
gimp_ui_manager_update (dialog->manager,
gimp_image_active_drawable (gimage));
}

View File

@ -40,7 +40,7 @@ struct _GimpFileDialog
GtkFileChooserDialog parent_instance;
Gimp *gimp;
GimpItemFactory *item_factory;
GimpUIManager *manager;
PlugInProcDef *file_proc;
GimpImage *gimage;
@ -63,6 +63,7 @@ GtkWidget * gimp_file_dialog_new (Gimp *gimp,
GtkFileChooserAction action,
GimpMenuFactory *menu_factory,
const gchar *menu_identifier,
const gchar *ui_path,
const gchar *title,
const gchar *role,
const gchar *stock_id,

View File

@ -364,29 +364,6 @@ gimp_ui_manager_ui_register (GimpUIManager *manager,
entry->widget = NULL;
manager->registered_uis = g_list_prepend (manager->registered_uis, entry);
{
gchar *filename;
GError *error = NULL;
filename = g_build_filename (gimp_data_directory (), "menus",
entry->basename, NULL);
g_print ("loading menu: %s for %s\n", filename,
entry->ui_path);
entry->merge_id =
gtk_ui_manager_add_ui_from_file (GTK_UI_MANAGER (manager),
filename, &error);
g_free (filename);
if (! entry->merge_id)
{
g_message (error->message);
g_clear_error (&error);
}
}
}
GtkWidget *

View File

@ -10,6 +10,8 @@ menudata_DATA = \
dockable-menu.xml \
documents-menu.xml \
error-console-menu.xml \
file-open-menu.xml \
file-save-menu.xml \
fonts-menu.xml \
gradient-editor-menu.xml \
gradients-menu.xml \

11
menus/file-open-menu.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup action="file-open-popup">
<placeholder name="Internal">
<menuitem action="file-open-automatic" />
</placeholder>
<separator />
</popup>
</ui>

11
menus/file-save-menu.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ui SYSTEM "gtkuimanager.dtd">
<ui>
<popup action="file-save-popup">
<placeholder name="Internal">
<menuitem action="file-save-by-extension" />
</placeholder>
<separator />
</popup>
</ui>

View File

@ -16,6 +16,8 @@ app/actions/drawable-actions.c
app/actions/edit-actions.c
app/actions/error-console-actions.c
app/actions/file-actions.c
app/actions/file-open-actions.c
app/actions/file-save-actions.c
app/actions/fonts-actions.c
app/actions/gradient-editor-actions.c
app/actions/gradients-actions.c
@ -121,9 +123,7 @@ app/gui/convert-dialog.c
app/gui/dialogs-constructors.c
app/gui/file-new-dialog.c
app/gui/file-open-dialog.c
app/gui/file-open-menu.c
app/gui/file-save-dialog.c
app/gui/file-save-menu.c
app/gui/font-select.c
app/gui/gradient-select.c
app/gui/grid-dialog.c