2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-07-16 20:49:04 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "config.h"
|
1999-03-07 20:56:03 +08:00
|
|
|
|
2006-04-06 18:01:30 +08:00
|
|
|
#include <string.h>
|
1999-06-22 04:04:04 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
1999-06-15 06:18:02 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2004-05-06 15:41:53 +08:00
|
|
|
#include "menus-types.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
|
2006-02-21 00:38:09 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2003-02-11 20:07:31 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2006-04-29 06:26:51 +08:00
|
|
|
#include "plug-in/gimppluginmanager.h"
|
|
|
|
#include "plug-in/gimppluginmanager-locale-domain.h"
|
2006-08-06 05:21:01 +08:00
|
|
|
#include "plug-in/gimppluginprocedure.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2004-04-27 20:28:27 +08:00
|
|
|
#include "widgets/gimpuimanager.h"
|
2001-11-28 03:27:55 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in-menus.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
typedef struct _PlugInMenuEntry PlugInMenuEntry;
|
|
|
|
|
|
|
|
struct _PlugInMenuEntry
|
|
|
|
{
|
2006-04-05 16:38:33 +08:00
|
|
|
GimpPlugInProcedure *proc;
|
|
|
|
const gchar *menu_path;
|
2004-05-15 19:26:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
static void plug_in_menus_register_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpUIManager *manager);
|
|
|
|
static void plug_in_menus_unregister_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpUIManager *manager);
|
|
|
|
static void plug_in_menus_menu_path_added (GimpPlugInProcedure *plug_in_proc,
|
|
|
|
const gchar *menu_path,
|
|
|
|
GimpUIManager *manager);
|
|
|
|
static void plug_in_menus_add_proc (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
GimpPlugInProcedure *proc,
|
|
|
|
const gchar *menu_path);
|
2007-05-23 16:57:53 +08:00
|
|
|
static void plug_in_menus_tree_insert (GTree *entries,
|
2006-06-28 20:04:29 +08:00
|
|
|
const gchar * path,
|
|
|
|
PlugInMenuEntry *entry);
|
2006-04-28 03:36:13 +08:00
|
|
|
static gboolean plug_in_menus_tree_traverse (gpointer key,
|
|
|
|
PlugInMenuEntry *entry,
|
|
|
|
GimpUIManager *manager);
|
|
|
|
static gchar * plug_in_menus_build_path (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
guint merge_id,
|
|
|
|
const gchar *menu_path,
|
|
|
|
gboolean for_menu);
|
2007-05-23 16:57:53 +08:00
|
|
|
static void plug_in_menu_entry_free (PlugInMenuEntry *entry);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2004-04-27 20:28:27 +08:00
|
|
|
void
|
2004-04-27 21:55:26 +08:00
|
|
|
plug_in_menus_setup (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2006-06-28 20:04:29 +08:00
|
|
|
GimpPlugInManager *plug_in_manager;
|
|
|
|
GTree *menu_entries;
|
|
|
|
GSList *list;
|
|
|
|
guint merge_id;
|
|
|
|
gint i;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
|
|
|
|
g_return_if_fail (ui_path != NULL);
|
|
|
|
|
2006-06-28 20:04:29 +08:00
|
|
|
plug_in_manager = manager->gimp->plug_in_manager;
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
|
2006-02-21 00:38:09 +08:00
|
|
|
|
|
|
|
for (i = 0; i < manager->gimp->config->plug_in_history_size; i++)
|
|
|
|
{
|
|
|
|
gchar *action_name;
|
|
|
|
gchar *action_path;
|
|
|
|
|
|
|
|
action_name = g_strdup_printf ("plug-in-recent-%02d", i + 1);
|
|
|
|
action_path = g_strdup_printf ("%s/Filters/Recently Used/Plug-Ins",
|
|
|
|
ui_path);
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
2006-02-21 00:38:09 +08:00
|
|
|
action_path, action_name, action_name,
|
|
|
|
GTK_UI_MANAGER_MENUITEM,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
g_free (action_name);
|
|
|
|
g_free (action_path);
|
|
|
|
}
|
|
|
|
|
2004-06-04 19:47:15 +08:00
|
|
|
menu_entries = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
|
2007-05-23 16:57:53 +08:00
|
|
|
g_free,
|
|
|
|
(GDestroyNotify) plug_in_menu_entry_free);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2006-06-28 20:04:29 +08:00
|
|
|
for (list = plug_in_manager->plug_in_procedures;
|
2004-04-27 20:28:27 +08:00
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
2006-04-28 03:36:13 +08:00
|
|
|
GimpPlugInProcedure *plug_in_proc = list->data;
|
|
|
|
|
|
|
|
if (! plug_in_proc->prog)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
g_signal_connect_object (plug_in_proc, "menu-path-added",
|
|
|
|
G_CALLBACK (plug_in_menus_menu_path_added),
|
|
|
|
manager, 0);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2007-03-20 18:41:35 +08:00
|
|
|
if (plug_in_proc->menu_paths &&
|
|
|
|
! plug_in_proc->file_proc)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2004-05-06 21:51:56 +08:00
|
|
|
GList *path;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
for (path = plug_in_proc->menu_paths; path; path = g_list_next (path))
|
2004-05-06 21:51:56 +08:00
|
|
|
{
|
2006-11-13 04:30:50 +08:00
|
|
|
if (g_str_has_prefix (path->data, manager->name))
|
2004-05-06 21:51:56 +08:00
|
|
|
{
|
2007-05-23 16:57:53 +08:00
|
|
|
PlugInMenuEntry *entry = g_slice_new0 (PlugInMenuEntry);
|
2004-05-15 19:26:59 +08:00
|
|
|
const gchar *progname;
|
|
|
|
const gchar *locale_domain;
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
entry->proc = plug_in_proc;
|
2004-05-15 19:26:59 +08:00
|
|
|
entry->menu_path = path->data;
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
progname = gimp_plug_in_procedure_get_progname (plug_in_proc);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2006-06-28 20:04:29 +08:00
|
|
|
locale_domain =
|
|
|
|
gimp_plug_in_manager_get_locale_domain (plug_in_manager,
|
|
|
|
progname, NULL);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
if (plug_in_proc->menu_label)
|
2004-06-04 19:47:15 +08:00
|
|
|
{
|
2004-06-07 18:45:05 +08:00
|
|
|
gchar *menu;
|
|
|
|
|
|
|
|
menu = g_strconcat (dgettext (locale_domain,
|
|
|
|
path->data),
|
|
|
|
"/",
|
|
|
|
dgettext (locale_domain,
|
2006-04-28 03:36:13 +08:00
|
|
|
plug_in_proc->menu_label),
|
2004-06-07 18:45:05 +08:00
|
|
|
NULL);
|
|
|
|
|
2006-06-28 20:04:29 +08:00
|
|
|
plug_in_menus_tree_insert (menu_entries, menu, entry);
|
2004-06-07 18:45:05 +08:00
|
|
|
g_free (menu);
|
2004-06-04 19:47:15 +08:00
|
|
|
}
|
2004-05-07 08:30:24 +08:00
|
|
|
else
|
2004-06-04 19:47:15 +08:00
|
|
|
{
|
2006-06-28 20:04:29 +08:00
|
|
|
plug_in_menus_tree_insert (menu_entries,
|
|
|
|
dgettext (locale_domain,
|
|
|
|
path->data),
|
|
|
|
entry);
|
2004-06-07 18:45:05 +08:00
|
|
|
}
|
2004-05-06 21:51:56 +08:00
|
|
|
}
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (manager), "ui-path", (gpointer) ui_path);
|
|
|
|
|
|
|
|
g_tree_foreach (menu_entries,
|
|
|
|
(GTraverseFunc) plug_in_menus_tree_traverse,
|
|
|
|
manager);
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (manager), "ui-path", NULL);
|
|
|
|
|
|
|
|
g_tree_destroy (menu_entries);
|
2006-04-28 03:36:13 +08:00
|
|
|
|
|
|
|
g_signal_connect_object (manager->gimp->pdb, "register-procedure",
|
|
|
|
G_CALLBACK (plug_in_menus_register_procedure),
|
|
|
|
manager, 0);
|
|
|
|
g_signal_connect_object (manager->gimp->pdb, "unregister-procedure",
|
|
|
|
G_CALLBACK (plug_in_menus_unregister_procedure),
|
|
|
|
manager, 0);
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|
|
|
|
|
2006-04-28 03:36:13 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_menus_register_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpUIManager *manager)
|
|
|
|
{
|
|
|
|
if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
|
|
|
|
|
|
|
|
g_signal_connect_object (plug_in_proc, "menu-path-added",
|
|
|
|
G_CALLBACK (plug_in_menus_menu_path_added),
|
|
|
|
manager, 0);
|
|
|
|
|
2007-03-20 18:41:35 +08:00
|
|
|
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
|
|
|
|
! plug_in_proc->file_proc)
|
2006-04-28 03:36:13 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
g_print ("%s: %s\n", G_STRFUNC,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (procedure)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (list = plug_in_proc->menu_paths; list; list = g_list_next (list))
|
|
|
|
plug_in_menus_menu_path_added (plug_in_proc, list->data, manager);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_menus_unregister_procedure (GimpPDB *pdb,
|
|
|
|
GimpProcedure *procedure,
|
|
|
|
GimpUIManager *manager)
|
|
|
|
{
|
|
|
|
if (GIMP_IS_PLUG_IN_PROCEDURE (procedure))
|
|
|
|
{
|
|
|
|
GimpPlugInProcedure *plug_in_proc = GIMP_PLUG_IN_PROCEDURE (procedure);
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (plug_in_proc,
|
|
|
|
plug_in_menus_menu_path_added,
|
|
|
|
manager);
|
|
|
|
|
2007-03-20 18:41:35 +08:00
|
|
|
if ((plug_in_proc->menu_label || plug_in_proc->menu_paths) &&
|
|
|
|
! plug_in_proc->file_proc)
|
2006-04-28 03:36:13 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
g_print ("%s: %s\n", G_STRFUNC,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (procedure)));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
for (list = plug_in_proc->menu_paths; list; list = g_list_next (list))
|
|
|
|
{
|
2006-11-13 04:30:50 +08:00
|
|
|
if (g_str_has_prefix (list->data, manager->name))
|
2006-04-28 03:36:13 +08:00
|
|
|
{
|
|
|
|
gchar *merge_key;
|
|
|
|
guint merge_id;
|
|
|
|
|
|
|
|
merge_key = g_strdup_printf ("%s-merge-id",
|
|
|
|
GIMP_OBJECT (plug_in_proc)->name);
|
|
|
|
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
|
|
|
|
merge_key));
|
|
|
|
g_free (merge_key);
|
|
|
|
|
|
|
|
if (merge_id)
|
|
|
|
gtk_ui_manager_remove_ui (GTK_UI_MANAGER (manager),
|
|
|
|
merge_id);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_menus_menu_path_added (GimpPlugInProcedure *plug_in_proc,
|
|
|
|
const gchar *menu_path,
|
|
|
|
GimpUIManager *manager)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
g_print ("%s: %s (%s)\n", G_STRFUNC,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (plug_in_proc)), menu_path);
|
|
|
|
#endif
|
|
|
|
|
2006-11-13 04:30:50 +08:00
|
|
|
if (g_str_has_prefix (menu_path, manager->name))
|
2006-04-28 03:36:13 +08:00
|
|
|
{
|
|
|
|
if (! strcmp (manager->name, "<Image>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/image-menubar",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
plug_in_menus_add_proc (manager, "/dummy-menubar/image-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Toolbox>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/toolbox-menubar",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
2006-06-17 01:02:14 +08:00
|
|
|
else if (! strcmp (manager->name, "<Layers>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/layers-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Channels>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/channels-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Vectors>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/vectors-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
2006-11-18 06:07:07 +08:00
|
|
|
else if (! strcmp (manager->name, "<Colormap>"))
|
2006-06-17 01:02:14 +08:00
|
|
|
{
|
2006-11-18 06:07:07 +08:00
|
|
|
plug_in_menus_add_proc (manager, "/colormap-popup",
|
2006-06-17 01:02:14 +08:00
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
2006-04-28 03:36:13 +08:00
|
|
|
else if (! strcmp (manager->name, "<Brushes>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/brushes-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Gradients>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/gradients-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Palettes>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/palettes-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Patterns>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/patterns-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Fonts>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/fonts-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
else if (! strcmp (manager->name, "<Buffers>"))
|
|
|
|
{
|
|
|
|
plug_in_menus_add_proc (manager, "/buffers-popup",
|
|
|
|
plug_in_proc, menu_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-05 16:38:33 +08:00
|
|
|
plug_in_menus_add_proc (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
GimpPlugInProcedure *proc,
|
|
|
|
const gchar *menu_path)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
|
|
|
gchar *path;
|
2004-05-07 08:30:24 +08:00
|
|
|
gchar *merge_key;
|
2005-03-25 00:08:04 +08:00
|
|
|
gchar *stripped_path;
|
2004-05-15 19:26:59 +08:00
|
|
|
gchar *action_path;
|
2004-05-07 08:30:24 +08:00
|
|
|
guint merge_id;
|
2004-11-23 22:35:45 +08:00
|
|
|
guint menu_merge_id;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
|
|
|
|
g_return_if_fail (ui_path != NULL);
|
2006-04-05 16:38:33 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc));
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-06 21:51:56 +08:00
|
|
|
path = g_strdup (menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
if (! proc->menu_label)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2005-01-04 05:02:38 +08:00
|
|
|
gchar *p;
|
2004-05-15 19:26:59 +08:00
|
|
|
|
2005-01-04 05:02:38 +08:00
|
|
|
if (! path)
|
|
|
|
return;
|
|
|
|
|
|
|
|
p = strrchr (path, '/');
|
2004-05-15 19:26:59 +08:00
|
|
|
if (! p)
|
|
|
|
{
|
|
|
|
g_free (path);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-04-27 20:28:27 +08:00
|
|
|
*p = '\0';
|
2004-05-07 08:30:24 +08:00
|
|
|
}
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2006-04-07 18:04:27 +08:00
|
|
|
merge_key = g_strdup_printf ("%s-merge-id", GIMP_OBJECT (proc)->name);
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
|
|
|
|
merge_key));
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
if (! merge_id)
|
|
|
|
{
|
|
|
|
merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
|
|
|
|
g_object_set_data (G_OBJECT (manager), merge_key,
|
|
|
|
GUINT_TO_POINTER (merge_id));
|
|
|
|
}
|
2004-05-06 21:51:56 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
g_free (merge_key);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-11-23 22:35:45 +08:00
|
|
|
menu_merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
|
|
|
|
"plug-in-menu-merge-id"));
|
|
|
|
|
|
|
|
if (! menu_merge_id)
|
|
|
|
{
|
|
|
|
menu_merge_id = gtk_ui_manager_new_merge_id (GTK_UI_MANAGER (manager));
|
|
|
|
g_object_set_data (G_OBJECT (manager), "plug-in-menu-merge-id",
|
|
|
|
GUINT_TO_POINTER (menu_merge_id));
|
|
|
|
}
|
|
|
|
|
2005-03-25 00:08:04 +08:00
|
|
|
stripped_path = gimp_strip_uline (path);
|
2004-11-23 22:35:45 +08:00
|
|
|
action_path = plug_in_menus_build_path (manager, ui_path, menu_merge_id,
|
2005-03-25 00:08:04 +08:00
|
|
|
stripped_path, FALSE);
|
|
|
|
g_free (stripped_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
if (! action_path)
|
2004-05-15 19:26:59 +08:00
|
|
|
{
|
2004-08-11 18:45:47 +08:00
|
|
|
g_free (path);
|
|
|
|
return;
|
2004-05-15 19:26:59 +08:00
|
|
|
}
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
#if 0
|
2004-05-15 19:26:59 +08:00
|
|
|
g_print ("adding menu item for '%s' (@ %s)\n",
|
2006-04-07 18:04:27 +08:00
|
|
|
GIMP_OBJECT (proc)->name, action_path);
|
2004-04-29 20:52:29 +08:00
|
|
|
#endif
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
|
|
|
action_path,
|
2006-04-07 18:04:27 +08:00
|
|
|
GIMP_OBJECT (proc)->name,
|
|
|
|
GIMP_OBJECT (proc)->name,
|
2004-05-07 08:30:24 +08:00
|
|
|
GTK_UI_MANAGER_MENUITEM,
|
|
|
|
FALSE);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
g_free (action_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
2006-06-28 20:04:29 +08:00
|
|
|
static void
|
|
|
|
plug_in_menus_tree_insert (GTree *entries,
|
|
|
|
const gchar *path,
|
|
|
|
PlugInMenuEntry *entry)
|
|
|
|
{
|
|
|
|
gchar *strip = gimp_strip_uline (path);
|
|
|
|
gchar *key;
|
|
|
|
|
|
|
|
/* Append the procedure name to the menu path in order to get a unique
|
|
|
|
* key even if two procedures are installed to the same menu entry.
|
|
|
|
*/
|
|
|
|
key = g_strconcat (strip,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (entry->proc)),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_tree_insert (entries, g_utf8_collate_key (key, -1), entry);
|
|
|
|
|
|
|
|
g_free (key);
|
|
|
|
g_free (strip);
|
|
|
|
}
|
|
|
|
|
2004-04-27 20:28:27 +08:00
|
|
|
static gboolean
|
2004-05-15 19:26:59 +08:00
|
|
|
plug_in_menus_tree_traverse (gpointer key,
|
|
|
|
PlugInMenuEntry *entry,
|
|
|
|
GimpUIManager *manager)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
|
|
|
const gchar *ui_path = g_object_get_data (G_OBJECT (manager), "ui-path");
|
|
|
|
|
2006-04-05 16:38:33 +08:00
|
|
|
plug_in_menus_add_proc (manager, ui_path, entry->proc, entry->menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
static gchar *
|
2004-04-27 20:28:27 +08:00
|
|
|
plug_in_menus_build_path (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
guint merge_id,
|
2004-08-11 18:45:47 +08:00
|
|
|
const gchar *menu_path,
|
|
|
|
gboolean for_menu)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2004-08-11 18:45:47 +08:00
|
|
|
gchar *action_path;
|
2004-05-15 19:26:59 +08:00
|
|
|
|
|
|
|
if (! strchr (menu_path, '/'))
|
2004-08-11 18:45:47 +08:00
|
|
|
{
|
|
|
|
action_path = g_strdup (ui_path);
|
|
|
|
goto make_placeholder;
|
|
|
|
}
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
action_path = g_strdup_printf ("%s%s", ui_path, strchr (menu_path, '/'));
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
if (! gtk_ui_manager_get_widget (GTK_UI_MANAGER (manager), action_path))
|
|
|
|
{
|
2005-01-04 05:02:38 +08:00
|
|
|
gchar *parent_menu_path = g_strdup (menu_path);
|
|
|
|
gchar *parent_action_path = NULL;
|
2004-08-11 18:45:47 +08:00
|
|
|
gchar *menu_item_name;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
menu_item_name = strrchr (parent_menu_path, '/');
|
|
|
|
*menu_item_name++ = '\0';
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2005-01-04 05:02:38 +08:00
|
|
|
if (menu_item_name)
|
|
|
|
parent_action_path = plug_in_menus_build_path (manager,
|
|
|
|
ui_path, merge_id,
|
|
|
|
parent_menu_path, TRUE);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
if (parent_action_path)
|
|
|
|
{
|
|
|
|
g_free (action_path);
|
|
|
|
action_path = g_strdup_printf ("%s/%s",
|
|
|
|
parent_action_path, menu_item_name);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
if (! gtk_ui_manager_get_widget (GTK_UI_MANAGER (manager),
|
|
|
|
action_path))
|
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
#if 0
|
2004-08-11 18:45:47 +08:00
|
|
|
g_print ("adding menu '%s' at path '%s' for action '%s'\n",
|
|
|
|
menu_item_name, action_path, menu_path);
|
2004-04-29 20:52:29 +08:00
|
|
|
#endif
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
|
|
|
parent_action_path, menu_item_name,
|
|
|
|
menu_path,
|
|
|
|
GTK_UI_MANAGER_MENU,
|
|
|
|
FALSE);
|
|
|
|
|
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
|
|
|
action_path, "Menus", NULL,
|
|
|
|
GTK_UI_MANAGER_PLACEHOLDER,
|
|
|
|
FALSE);
|
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
|
|
|
action_path, "Separator", NULL,
|
|
|
|
GTK_UI_MANAGER_SEPARATOR,
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (parent_action_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|
2004-05-15 19:26:59 +08:00
|
|
|
else
|
|
|
|
{
|
2004-08-11 18:45:47 +08:00
|
|
|
g_free (action_path);
|
|
|
|
action_path = NULL;
|
2004-05-15 19:26:59 +08:00
|
|
|
}
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
g_free (parent_menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
make_placeholder:
|
|
|
|
|
|
|
|
if (action_path && for_menu)
|
|
|
|
{
|
2005-01-04 05:02:38 +08:00
|
|
|
gchar *placeholder_path = g_strdup_printf ("%s/%s", action_path, "Menus");
|
2004-08-11 18:45:47 +08:00
|
|
|
|
|
|
|
if (gtk_ui_manager_get_widget (GTK_UI_MANAGER (manager),
|
|
|
|
placeholder_path))
|
|
|
|
{
|
|
|
|
g_free (action_path);
|
|
|
|
|
|
|
|
return placeholder_path;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (placeholder_path);
|
|
|
|
}
|
2004-05-15 19:26:59 +08:00
|
|
|
|
2004-08-11 18:45:47 +08:00
|
|
|
return action_path;
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|
2007-05-23 16:57:53 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
plug_in_menu_entry_free (PlugInMenuEntry *entry)
|
|
|
|
{
|
|
|
|
g_slice_free (PlugInMenuEntry, entry);
|
|
|
|
}
|