1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
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
|
|
|
|
2002-03-21 01:46:13 +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
|
|
|
|
2003-02-11 20:07:31 +08:00
|
|
|
#include "core/gimp.h"
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in/plug-ins.h"
|
|
|
|
#include "plug-in/plug-in-def.h"
|
|
|
|
#include "plug-in/plug-in-proc.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
|
|
|
|
{
|
|
|
|
PlugInProcDef *proc_def;
|
|
|
|
const gchar *menu_path;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
static gboolean plug_in_menus_tree_traverse (gpointer key,
|
|
|
|
PlugInMenuEntry *entry,
|
|
|
|
GimpUIManager *manager);
|
|
|
|
static gboolean plug_in_menus_build_path (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
guint merge_id,
|
|
|
|
const gchar *menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
void
|
2003-01-18 02:07:37 +08:00
|
|
|
plug_in_menus_init (Gimp *gimp,
|
|
|
|
GSList *plug_in_defs,
|
2002-12-11 00:38:16 +08:00
|
|
|
const gchar *std_plugins_domain)
|
These changes enable help support for 3rd party plug-ins which install
2000-05-21 Michael Natterer <mitch@gimp.org>
These changes enable help support for 3rd party plug-ins which
install their help files outside GIMP's main help dir.
Instead of calling gimp_help(), gimp_plugin_help_func() etc.,
all help callbacks now have to call gimp_standard_help_func()
which has different implementations in the app and in libgimp.
There is a new function gimp_plugin_help_register() which can
be called during plug-in query. plug_in.c keeps a list of
executable_name/help_path pairs. Plug-ins have to pass their
exec. name to gimp_help() which uses the list to find the plug-in's
help directory.
* app/gimphelp.[ch]: gimp_help() now takes a help_path parameter.
help_path == NULL means the standard help directory. Various
changes to pass the help_path to the help browser.
* app/gimprc.c: save the plug-in's help_path in the pluginrc file.
* app/menus.c: ugly hack to enable help_paths in the "F1" callback.
* app/plug_in.[ch]: many help_path related changes. Use g_basename()
instead of strrchr(str,G_DIR_SEPARATOR), cosmetic cleanups.
* app/internal_procs.c
* app/gimphelp_cmds.c
* tools/pdbgen/pdb/gimphelp.pdb: new procedure
gimp_plugin_help_register(). gimp_help() takes a second parameter
which is the executable name (not the help_path).
* app/color_notebook.c
* app/commands.c
* app/lc_dialog.c
* app/preferences_dialog.c
* app/tools.c: call gimp_standard_help_func() instead of gimp_help().
* libgimp/gimp.c: new function gimp_get_progname() which returns
the full path of the plug-in's executable.
* libgimp/gimp.h: export the new function,
removed gimp_plugin_help_func(), gimp_help() takes the executable
name as second parameter.
* libgimp/gimpcompat.h: added gimp_plugin_help_func().
* libgimp/gimphelp.c: a wrapper for gimp_plugin_help_register(),
changed the calls to gimp_help.
* libgimp/gimphelpui.[ch]: call gimp_standard_help_func() instead
of gimp_help().
* plug-ins/helpbrowser/helpbrowser.c: now called with an additional
help_path parameter. Various changes to enable
help_path != gimp_standard_help_path.
Unrelated stuff:
* app/batch.h: added missing GPL header.
* app/gimpunit.c: had a LGPL header, merged some fprintf's into
one call.
* app/procedural_db.[ch]: cosmetic: g* types, s/g_malloc/g_new/,
prototypes, indentation.
* app/resize.c: use less packing widgets. didn't find the "offset"
redraw bug :(
2000-05-22 01:41:02 +08:00
|
|
|
{
|
2003-01-13 22:08:10 +08:00
|
|
|
GSList *domains = NULL;
|
|
|
|
GSList *tmp;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
g_return_if_fail (std_plugins_domain != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
domains = g_slist_append (domains, (gpointer) std_plugins_domain);
|
2000-07-16 20:49:04 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
bindtextdomain (std_plugins_domain, gimp_locale_directory ());
|
2004-01-12 19:33:28 +08:00
|
|
|
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
2002-12-11 00:38:16 +08:00
|
|
|
bind_textdomain_codeset (std_plugins_domain, "UTF-8");
|
2004-01-12 19:33:28 +08:00
|
|
|
#endif
|
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
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
|
2002-03-21 01:46:13 +08:00
|
|
|
{
|
2003-01-13 22:08:10 +08:00
|
|
|
PlugInDef *plug_in_def;
|
2002-12-11 00:38:16 +08:00
|
|
|
const gchar *locale_domain;
|
|
|
|
const gchar *locale_path;
|
|
|
|
GSList *list;
|
|
|
|
|
2003-01-13 22:08:10 +08:00
|
|
|
plug_in_def = (PlugInDef *) tmp->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
if (! plug_in_def->proc_defs)
|
|
|
|
continue;
|
|
|
|
|
2003-01-18 02:07:37 +08:00
|
|
|
locale_domain = plug_ins_locale_domain (gimp,
|
|
|
|
plug_in_def->prog,
|
2002-12-11 00:38:16 +08:00
|
|
|
&locale_path);
|
|
|
|
|
|
|
|
for (list = domains; list; list = list->next)
|
2003-09-16 21:12:50 +08:00
|
|
|
if (! strcmp (locale_domain, (const gchar *) list->data))
|
2003-08-26 00:28:46 +08:00
|
|
|
break;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
if (! list)
|
|
|
|
{
|
|
|
|
domains = g_slist_append (domains, (gpointer) locale_domain);
|
|
|
|
|
|
|
|
bindtextdomain (locale_domain, locale_path);
|
2004-01-12 19:33:28 +08:00
|
|
|
#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
|
2002-12-11 00:38:16 +08:00
|
|
|
bind_textdomain_codeset (locale_domain, "UTF-8");
|
2004-01-12 19:33:28 +08:00
|
|
|
#endif
|
2002-12-11 00:38:16 +08:00
|
|
|
}
|
|
|
|
}
|
1999-05-07 04:56:07 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
g_slist_free (domains);
|
|
|
|
}
|
1999-05-07 04:56:07 +08:00
|
|
|
|
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
|
|
|
{
|
|
|
|
GTree *menu_entries;
|
|
|
|
GSList *list;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
|
|
|
|
g_return_if_fail (ui_path != NULL);
|
|
|
|
|
2004-06-04 19:47:15 +08:00
|
|
|
menu_entries = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
|
2004-05-15 19:26:59 +08:00
|
|
|
g_free, g_free);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
for (list = manager->gimp->plug_in_proc_defs;
|
|
|
|
list;
|
|
|
|
list = g_slist_next (list))
|
|
|
|
{
|
|
|
|
PlugInProcDef *proc_def = list->data;
|
|
|
|
|
|
|
|
if (proc_def->prog &&
|
2004-05-06 21:51:56 +08:00
|
|
|
proc_def->menu_paths &&
|
2004-04-27 20:28:27 +08:00
|
|
|
! proc_def->extensions &&
|
|
|
|
! proc_def->prefixes &&
|
|
|
|
! proc_def->magics)
|
|
|
|
{
|
2004-05-06 21:51:56 +08:00
|
|
|
GList *path;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-06 21:51:56 +08:00
|
|
|
for (path = proc_def->menu_paths; path; path = g_list_next (path))
|
|
|
|
{
|
|
|
|
if ((! strncmp (path->data, "<Toolbox>", 9) &&
|
|
|
|
! strcmp (ui_path, "/toolbox-menubar")) ||
|
|
|
|
(! strncmp (path->data, "<Image>", 7) &&
|
|
|
|
(! strcmp (ui_path, "/image-menubar") ||
|
2004-05-17 21:38:03 +08:00
|
|
|
! strcmp (ui_path, "/dummy-menubar/image-popup"))))
|
2004-05-06 21:51:56 +08:00
|
|
|
{
|
2004-05-15 19:26:59 +08:00
|
|
|
PlugInMenuEntry *entry = g_new0 (PlugInMenuEntry, 1);
|
|
|
|
const gchar *progname;
|
|
|
|
const gchar *locale_domain;
|
|
|
|
gchar *key;
|
|
|
|
|
|
|
|
entry->proc_def = proc_def;
|
|
|
|
entry->menu_path = path->data;
|
2004-05-06 21:51:56 +08:00
|
|
|
|
|
|
|
progname = plug_in_proc_def_get_progname (proc_def);
|
|
|
|
|
|
|
|
locale_domain = plug_ins_locale_domain (manager->gimp,
|
|
|
|
progname, NULL);
|
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
if (proc_def->menu_label)
|
2004-06-04 19:47:15 +08:00
|
|
|
{
|
2004-06-07 18:45:05 +08:00
|
|
|
gchar *menu;
|
|
|
|
gchar *strip;
|
|
|
|
|
|
|
|
menu = g_strconcat (dgettext (locale_domain,
|
|
|
|
path->data),
|
|
|
|
"/",
|
|
|
|
dgettext (locale_domain,
|
|
|
|
proc_def->menu_label),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
strip = gimp_strip_uline (menu);
|
2004-06-04 19:47:15 +08:00
|
|
|
|
2004-06-07 18:45:05 +08:00
|
|
|
key = g_utf8_collate_key (strip, -1);
|
2004-06-04 19:47:15 +08:00
|
|
|
|
2004-06-07 18:45:05 +08:00
|
|
|
g_free (strip);
|
|
|
|
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
|
|
|
{
|
2004-06-07 18:45:05 +08:00
|
|
|
gchar *strip = gimp_strip_uline (dgettext (locale_domain,
|
|
|
|
path->data));
|
|
|
|
|
|
|
|
key = g_utf8_collate_key (strip, -1);
|
2004-05-07 08:30:24 +08:00
|
|
|
|
2004-06-07 18:45:05 +08:00
|
|
|
g_free (strip);
|
|
|
|
}
|
2004-05-07 08:30:24 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
g_tree_insert (menu_entries, key, entry);
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plug_in_menus_add_proc (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
2004-05-06 21:51:56 +08:00
|
|
|
PlugInProcDef *proc_def,
|
|
|
|
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;
|
2004-05-15 19:26:59 +08:00
|
|
|
gchar *action_path;
|
2004-05-07 08:30:24 +08:00
|
|
|
guint 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);
|
|
|
|
g_return_if_fail (proc_def != NULL);
|
|
|
|
|
2004-05-06 21:51:56 +08:00
|
|
|
path = g_strdup (menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
if (! proc_def->menu_label)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2004-05-07 08:30:24 +08:00
|
|
|
gchar *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
|
|
|
|
2004-05-07 08:30:24 +08:00
|
|
|
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.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-05-15 19:26:59 +08:00
|
|
|
if (strchr (path, '/'))
|
|
|
|
{
|
|
|
|
if (! plug_in_menus_build_path (manager, ui_path, merge_id, path))
|
|
|
|
{
|
|
|
|
g_free (path);
|
|
|
|
return;
|
|
|
|
}
|
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 (path, '/'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
action_path = g_strdup (ui_path);
|
|
|
|
}
|
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",
|
2004-05-07 08:30:24 +08:00
|
|
|
proc_def->db_info.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,
|
|
|
|
proc_def->db_info.name,
|
|
|
|
proc_def->db_info.name,
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plug_in_menus_remove_proc (GimpUIManager *manager,
|
|
|
|
PlugInProcDef *proc_def)
|
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
gchar *merge_key;
|
|
|
|
guint merge_id;
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
g_return_if_fail (GIMP_IS_UI_MANAGER (manager));
|
2004-04-25 16:22:22 +08:00
|
|
|
g_return_if_fail (proc_def != NULL);
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
merge_key = g_strdup_printf ("%s-merge-id", proc_def->db_info.name);
|
|
|
|
merge_id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (manager),
|
|
|
|
merge_key));
|
|
|
|
g_free (merge_key);
|
2000-08-15 23:42:14 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
if (merge_id)
|
|
|
|
gtk_ui_manager_remove_ui (GTK_UI_MANAGER (manager), merge_id);
|
2001-05-17 02:09:45 +08:00
|
|
|
}
|
2002-12-11 00:38:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
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");
|
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
plug_in_menus_add_proc (manager, ui_path, entry->proc_def, entry->menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
static gboolean
|
2004-04-27 20:28:27 +08:00
|
|
|
plug_in_menus_build_path (GimpUIManager *manager,
|
|
|
|
const gchar *ui_path,
|
|
|
|
guint merge_id,
|
2004-05-15 19:26:59 +08:00
|
|
|
const gchar *menu_path)
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2004-05-15 19:26:59 +08:00
|
|
|
gchar *action_path;
|
|
|
|
gboolean retval = TRUE;
|
|
|
|
|
|
|
|
if (! strchr (menu_path, '/'))
|
|
|
|
return TRUE;
|
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))
|
|
|
|
{
|
2004-05-15 19:26:59 +08:00
|
|
|
gchar *parent_menu_path = g_strdup (menu_path);
|
2004-04-27 20:28:27 +08:00
|
|
|
gchar *p;
|
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
p = strrchr (parent_menu_path, '/');
|
|
|
|
*p = '\0';
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
if (plug_in_menus_build_path (manager, ui_path, merge_id,
|
|
|
|
parent_menu_path))
|
2004-04-27 20:28:27 +08:00
|
|
|
{
|
2004-05-15 19:26:59 +08:00
|
|
|
gchar *parent_action_path = action_path; /* no strdup() needed */
|
|
|
|
gchar *menu_item_name;
|
2004-04-27 20:28:27 +08:00
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
p = strrchr (parent_action_path, '/');
|
2004-04-27 20:28:27 +08:00
|
|
|
*p = '\0';
|
|
|
|
|
2004-05-15 19:26:59 +08:00
|
|
|
menu_item_name = strrchr (menu_path, '/') + 1;
|
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 '%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
|
|
|
|
|
|
|
gtk_ui_manager_add_ui (GTK_UI_MANAGER (manager), merge_id,
|
2004-05-15 19:26:59 +08:00
|
|
|
parent_action_path, menu_item_name, menu_path,
|
2004-04-27 20:28:27 +08:00
|
|
|
GTK_UI_MANAGER_MENU,
|
|
|
|
FALSE);
|
|
|
|
}
|
2004-05-15 19:26:59 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
retval = FALSE;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
g_free (action_path);
|
2004-05-15 19:26:59 +08:00
|
|
|
|
|
|
|
return retval;
|
2004-04-27 20:28:27 +08:00
|
|
|
}
|