gimp/app/widgets/gimpitemfactory.c

965 lines
24 KiB
C
Raw Normal View History

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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#include "string.h"
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
The GIMP Help System part II: press "F1" while browsing a menu to show the 1999-10-03 Michael Natterer <mitch@gimp.org> The GIMP Help System part II: press "F1" while browsing a menu to show the help page for the menu entry you're currently over with the mouse. * app/color_notebook.c: all color selectors have to register with a help page now. * app/color_select.[ch]: register with a help string. Removed the dialog part of the files because it's use was deprecated anyway (use color notebooks instead). * app/colormap_dialog.i.c * app/colormap_dialog.p.h * app/palette.c * app/palette_select.c: use a color notebook instead of a color selector. * app/gimphelp.c * app/gimpui.c: minor changes. * app/gimprc.c: "use help" defaults to TRUE now. * app/lc_dialog.c * app/lc_dialogP.h: a special help function which shows the help for the currently selected notebook page. * app/menus.c: some weird code which catches "key_press_event" in all menu shells and pops up the corresp. help page for the selected item. Embedded the GtkItemFactoryEntry in a new GimpItemFactoryEntry to allow a help path to be stored. Will be partially exported and moved to gimphelp.[ch] later to catch key_press for plug-in menu items (don't try this now ;-) * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/channel_ops.c * app/channels_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/file_new_dialog.c * app/fileops.c * app/gdisplay.c * app/gdisplay_color.c * app/gdisplay_color_ui.c * app/gdisplay_ops.c * app/global_edit.c * app/gradient.c * app/gradient_select.c * app/interface.c * app/layers_dialog.c * app/module_db.c * app/paths_dialog.c * app/pattern_select.c * app/preferences_dialog.c * app/qmask.c * app/resize.c * app/undo_history.c: changed all dialog constructors to point to the right place in the new help file structure. * configure.in * help/*: the basic new help file structure. * modules/colorsel_gtk.c * modules/colorsel_triangle.c * modules/colorsel_water.c: register a help page. * plug-ins/helpbrowser/helpbrowser.c: load the help files according to the new help file structure.
1999-10-03 21:50:19 +08:00
#include "libgimpbase/gimpbase.h"
Makefile.am configure.in added the new library below. 2001-01-24 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added the new library below. * libgimpwidgets/Makefile.am * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.[ch] * libgimpwidgets/gimpcolorbutton.[ch] * libgimpwidgets/gimpdialog.[ch] * libgimpwidgets/gimpfileselection.[ch] * libgimpwidgets/gimphelpui.[ch] * libgimpwidgets/gimppatheditor.[ch] * libgimpwidgets/gimppixmap.[ch] * libgimpwidgets/gimpquerybox.[ch] * libgimpwidgets/gimpsizeentry.[ch] * libgimpwidgets/gimpunitmenu.[ch] * libgimpwidgets/gimpwidgets.[ch] * libgimpwidgets/gimpwidgets.def * libgimpwidgets/gimpwidgetstypes.h: new shared library. Currently there are some ugly dependencies into libgimp. These will be removed and go to a "libgimpglue" library which will be a library for functions which share a common interface between plug-ins and the app but have different implementations. Include "libgimp/gimpunit.h" from "libgimpwidgets/gimpwidgetstypes.h" to simulate this upcoming separation. * libgimp/Makefile.am * libgimp/gimpchainbutton.[ch] * libgimp/gimpcolorarea.[ch] * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimpfileselection.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimppixmap.[ch] * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: removed from here. * libgimp/gimpui.h * libgimp/gimpuitypes.h * libgimp/makefile.mingw.in * libgimp/makefile.msc: changed accordingly. * app/[all ui files] * app/pdb/palette_cmds.c * app/pdb/tools_cmds.c * tools/pdbgen/pdb/palette.pdb * tools/pdbgen/pdb/tools.pdb: #include "libgimpwidgets/gimpwidgets.h" and removed useless includes. * app/apptypes.h: #include "libgimpwidgets/gimpwidgetstypes.h" * app/Makefile.am * plug-ins/[all makefiles which link against libgimpui]: link against libgimpwidgets.la * po-libgimp/POTFILES.in: changed file locations.
2001-01-25 06:36:18 +08:00
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
#include "gimpitemfactory.h"
app/Makefile.am app/gui/Makefile.am app/about_dialog.[ch] 2001-04-17 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gui/Makefile.am * app/about_dialog.[ch] * app/brush_edit.[ch] * app/brush_select.[ch] * app/channels_dialog.[ch] * app/color_area.[ch] * app/color_notebook.[ch] * app/color_select.[ch] * app/colormap_dialog.[ch] * app/commands.[ch] * app/file_new_dialog.[ch] * app/gradient_editor.[ch] * app/gradient_select.[ch] * app/indicator_area.[ch] * app/info_dialog.[ch] * app/info_window.[ch] * app/layer_select.[ch] * app/layers_dialog.[ch] * app/menus.[ch] * app/palette.[ch] * app/palette_import.[ch] * app/palette_select.[ch] * app/paths_dialog.[ch] * app/pattern_select.[ch] * app/preferences_dialog.[ch] * app/session.[ch] * app/test_commands.[ch] * app/tips_dialog.[ch] * app/toolbox.[ch]: moved to gui/ (s/_/-/ and some more useful filenames on the way). * app/app_procs.c * app/context_manager.c * app/convert.c * app/disp_callbacks.c * app/errorconsole.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/gdisplay.c * app/gimage.c * app/gimprc.c * app/image_new.c * app/interface.c * app/nav_window.c * app/path.c * app/plug_in.c * app/gui/dialogs-constructors.c * app/pdb/brush_select_cmds.c * app/pdb/convert_cmds.c * app/pdb/gradient_select_cmds.c * app/pdb/pattern_select_cmds.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpscaletool.c * app/tools/gimptransformtool.c * app/widgets/gimpcolorpanel.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/pattern_select.pdb * po/POTFILES.in: changed accordingly.
2001-04-18 05:43:29 +08:00
app/Makefile.am app/channel_pvt.h app/drawable_pvt.h app/gdisplayF.h 2000-12-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/channel_pvt.h * app/drawable_pvt.h * app/gdisplayF.h * app/gimpdrawableP.h * app/gimpimageP.h * app/layer_pvt.h * app/toolsF.h: removed these files. * app/apptypes.h * tools/pdbgen/enums.pl: added tons of opaque typedefs and enums. * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/convert.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/help.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb * tools/pdbgen/pdb/patterns.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb * app/*: chainsaw #include cleanup: - Never (never!!) include stuff in header files except where we need access to structures' contents (like derived objects). - Added prototypes and proper formating in many files. - The #include order in *all* *.c files is as follows: #include "config.h" #include <system stuff> #include <gtk/gtk.h> #include "apptypes.h" #include "gimp stuff" #include "libgimp stuff" #include "libgimp/gimpintl.h" By following this scheme we can easily see a file's dependencies from it's #include's and can grep for the inclusion to find out where a file is used. * tools/pdbgen/app.pl: changed to follow the include scheme above. * libgimp/Makefile.am * libgimp/gimpuitypes.h: new file, included from libgimp/gimpui.h and from app/apptypes.h. * libgimp/gimpcolorbutton.[ch] * libgimp/gimpdialog.[ch] * libgimp/gimphelpui.[ch] * libgimp/gimpparasite.[ch] * libgimp/gimppatheditor.[ch] * libgimp/gimpprotocol.c * libgimp/gimpquerybox.[ch] * libgimp/gimpsizeentry.[ch] * libgimp/gimptypes.h * libgimp/gimpui.h * libgimp/gimpunit.h * libgimp/gimpunitmenu.[ch] * libgimp/gimpwidgets.[ch]: changed accordingly. * plug-ins/FractalExplorer/Dialogs.c * plug-ins/gdyntext/message_window.c * plug-ins/imagemap/imap_default_dialog.c * plug-ins/imagemap/imap_file.c: these files used to include "libgimp/gimpui.h" without including "libgimp/gimp.h". This is no longer possible because the libgimpui headers don't inlcude "libgimp/gimpunit.h" any more.
2000-12-29 23:22:01 +08:00
#include "gimphelp.h"
1997-11-25 06:05:25 +08:00
#include "gimprc.h"
#include "libgimp/gimpintl.h"
/* local function prototypes */
static void gimp_item_factory_create_branches (GtkItemFactory *factory,
GimpItemFactoryEntry *entry);
static void gimp_item_factory_item_realize (GtkWidget *widget,
gpointer data);
static gboolean gimp_item_factory_item_key_press (GtkWidget *widget,
GdkEventKey *kevent,
gpointer data);
#ifdef ENABLE_NLS
static gchar * gimp_item_factory_translate_func (const gchar *path,
gpointer data);
#else
#define gimp_item_factory_translate_func (NULL)
#endif
/* public functions */
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
void
gimp_menu_item_create (GimpItemFactoryEntry *entry,
gchar *domain_name,
gpointer callback_data)
The GIMP Help System part II: press "F1" while browsing a menu to show the 1999-10-03 Michael Natterer <mitch@gimp.org> The GIMP Help System part II: press "F1" while browsing a menu to show the help page for the menu entry you're currently over with the mouse. * app/color_notebook.c: all color selectors have to register with a help page now. * app/color_select.[ch]: register with a help string. Removed the dialog part of the files because it's use was deprecated anyway (use color notebooks instead). * app/colormap_dialog.i.c * app/colormap_dialog.p.h * app/palette.c * app/palette_select.c: use a color notebook instead of a color selector. * app/gimphelp.c * app/gimpui.c: minor changes. * app/gimprc.c: "use help" defaults to TRUE now. * app/lc_dialog.c * app/lc_dialogP.h: a special help function which shows the help for the currently selected notebook page. * app/menus.c: some weird code which catches "key_press_event" in all menu shells and pops up the corresp. help page for the selected item. Embedded the GtkItemFactoryEntry in a new GimpItemFactoryEntry to allow a help path to be stored. Will be partially exported and moved to gimphelp.[ch] later to catch key_press for plug-in menu items (don't try this now ;-) * app/app_procs.c * app/brush_edit.c * app/brush_select.c * app/channel_ops.c * app/channels_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/file_new_dialog.c * app/fileops.c * app/gdisplay.c * app/gdisplay_color.c * app/gdisplay_color_ui.c * app/gdisplay_ops.c * app/global_edit.c * app/gradient.c * app/gradient_select.c * app/interface.c * app/layers_dialog.c * app/module_db.c * app/paths_dialog.c * app/pattern_select.c * app/preferences_dialog.c * app/qmask.c * app/resize.c * app/undo_history.c: changed all dialog constructors to point to the right place in the new help file structure. * configure.in * help/*: the basic new help file structure. * modules/colorsel_gtk.c * modules/colorsel_triangle.c * modules/colorsel_water.c: register a help page. * plug-ins/helpbrowser/helpbrowser.c: load the help files according to the new help file structure.
1999-10-03 21:50:19 +08:00
{
GtkItemFactory *item_factory;
gchar *path;
g_return_if_fail (entry != NULL);
path = entry->entry.path;
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
if (!path)
return;
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
item_factory = gtk_item_factory_from_path (path);
if (!item_factory)
{
g_warning ("entry refers to unknown item factory: \"%s\"", path);
return;
}
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
g_object_set_data (G_OBJECT (item_factory), "textdomain", domain_name);
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
while (*path != '>')
path++;
path++;
1997-11-25 06:05:25 +08:00
entry->entry.path = path;
gimp_item_factory_create_item (item_factory,
entry,
callback_data, 2,
TRUE, FALSE);
}
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
void
gimp_menu_item_destroy (gchar *path)
{
g_return_if_fail (path != NULL);
gtk_item_factories_path_delete (NULL, path);
}
void
gimp_menu_item_set_active (gchar *path,
gboolean active)
1997-11-25 06:05:25 +08:00
{
GtkItemFactory *factory;
g_return_if_fail (path != NULL);
factory = gtk_item_factory_from_path (path);
if (factory)
{
gimp_item_factory_set_active (factory, path, active);
}
else if (! strstr (path, "Script-Fu"))
{
g_warning ("%s: Could not find item factory for path \"%s\"",
G_STRLOC, path);
}
1997-11-25 06:05:25 +08:00
}
void
gimp_menu_item_set_color (gchar *path,
const GimpRGB *color,
gboolean set_label)
1997-11-25 06:05:25 +08:00
{
GtkItemFactory *factory;
g_return_if_fail (path != NULL);
g_return_if_fail (color != NULL);
factory = gtk_item_factory_from_path (path);
if (factory)
{
gimp_item_factory_set_color (factory, path, color, set_label);
}
else
{
g_warning ("%s: Could not find item factory for path \"%s\"",
G_STRLOC, path);
}
}
void
gimp_menu_item_set_label (gchar *path,
const gchar *label)
{
GtkItemFactory *factory;
g_return_if_fail (path != NULL);
g_return_if_fail (label != NULL);
1997-11-25 06:05:25 +08:00
factory = gtk_item_factory_from_path (path);
if (factory)
{
gimp_item_factory_set_label (factory, path, label);
}
else
{
g_warning ("%s: Could not find item factory for path \"%s\"",
G_STRLOC, path);
}
}
1997-11-25 06:05:25 +08:00
void
gimp_menu_item_set_sensitive (gchar *path,
gboolean sensitive)
{
GtkItemFactory *factory;
g_return_if_fail (path != NULL);
factory = gtk_item_factory_from_path (path);
if (factory)
{
gimp_item_factory_set_sensitive (factory, path, sensitive);
}
else if (! strstr (path, "Script-Fu"))
{
g_warning ("%s: Could not find item factory for path \"%s\"",
G_STRLOC, path);
}
}
void
gimp_menu_item_set_visible (gchar *path,
gboolean visible)
{
GtkItemFactory *factory;
g_return_if_fail (path != NULL);
1997-11-25 06:05:25 +08:00
factory = gtk_item_factory_from_path (path);
if (factory)
{
gimp_item_factory_set_visible (factory, path, visible);
}
else
{
g_warning ("%s: Could not find item factory for path \"%s\"",
G_STRLOC, path);
}
}
GtkItemFactory *
gimp_item_factory_new (GType container_type,
const gchar *path,
const gchar *factory_path,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
gboolean create_tearoff)
{
GtkItemFactory *factory;
factory = gtk_item_factory_new (container_type, path, NULL);
gtk_item_factory_set_translate_func (factory,
gimp_item_factory_translate_func,
(gpointer) path,
NULL);
g_object_set_data (G_OBJECT (factory), "factory_path",
(gpointer) factory_path);
gimp_item_factory_create_items (factory,
n_entries,
entries,
callback_data,
2,
create_tearoff,
TRUE);
return factory;
}
void
gimp_item_factory_create_item (GtkItemFactory *item_factory,
GimpItemFactoryEntry *entry,
gpointer callback_data,
guint callback_type,
gboolean create_tearoff,
gboolean static_entry)
{
GtkWidget *menu_item;
g_return_if_fail (GTK_IS_ITEM_FACTORY (item_factory));
g_return_if_fail (entry != NULL);
if (! (strstr (entry->entry.path, "tearoff1")))
{
if (! gimprc.disable_tearoff_menus && create_tearoff)
{
gimp_item_factory_create_branches (item_factory, entry);
}
}
else if (gimprc.disable_tearoff_menus || ! create_tearoff)
{
return;
}
if (entry->quark_string)
{
GQuark quark;
if (static_entry)
quark = g_quark_from_static_string (entry->quark_string);
else
quark = g_quark_from_string (entry->quark_string);
entry->entry.callback_action = (guint) quark;
}
gtk_item_factory_create_item (item_factory,
(GtkItemFactoryEntry *) entry,
callback_data,
callback_type);
menu_item = gtk_item_factory_get_item (item_factory,
((GtkItemFactoryEntry *) entry)->path);
if (menu_item)
{
g_signal_connect_after (G_OBJECT (menu_item), "realize",
G_CALLBACK (gimp_item_factory_item_realize),
item_factory);
g_object_set_data (G_OBJECT (menu_item), "help_page",
(gpointer) entry->help_page);
}
}
void
gimp_item_factory_create_items (GtkItemFactory *item_factory,
guint n_entries,
GimpItemFactoryEntry *entries,
gpointer callback_data,
guint callback_type,
gboolean create_tearoff,
gboolean static_entries)
{
gint i;
for (i = 0; i < n_entries; i++)
{
gimp_item_factory_create_item (item_factory,
entries + i,
callback_data,
callback_type,
create_tearoff,
static_entries);
}
}
void
gimp_item_factory_set_active (GtkItemFactory *factory,
gchar *path,
gboolean active)
{
GtkWidget *widget;
g_return_if_fail (GTK_IS_ITEM_FACTORY (factory));
g_return_if_fail (path != NULL);
widget = gtk_item_factory_get_widget (factory, path);
if (widget)
{
if (GTK_IS_CHECK_MENU_ITEM (widget))
{
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (widget), active);
}
else
{
}
}
else if (! strstr (path, "Script-Fu"))
{
g_warning ("%s: Unable to set \"active\" for menu item "
"which doesn't exist:\n%s",
G_STRLOC, path);
}
}
void
gimp_item_factory_set_color (GtkItemFactory *factory,
gchar *path,
const GimpRGB *color,
gboolean set_label)
{
GtkWidget *widget;
GtkWidget *preview = NULL;
GtkWidget *label = NULL;
g_return_if_fail (GTK_IS_ITEM_FACTORY (factory));
g_return_if_fail (path != NULL);
g_return_if_fail (color != NULL);
widget = gtk_item_factory_get_widget (factory, path);
if (! widget)
{
g_warning ("%s: Unable to set color of menu item "
"which doesn't exist:\n%s",
G_STRLOC, path);
return;
}
#define COLOR_BOX_WIDTH 16
#define COLOR_BOX_HEIGHT 16
if (GTK_IS_HBOX (GTK_BIN (widget)->child))
{
preview = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"preview");
label = g_object_get_data (G_OBJECT (GTK_BIN (widget)->child),
"label");
}
else if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
GtkWidget *hbox;
label = GTK_BIN (widget)->child;
g_object_ref (G_OBJECT (label));
gtk_container_remove (GTK_CONTAINER (widget), label);
hbox = gtk_hbox_new (FALSE, 4);
gtk_container_add (GTK_CONTAINER (widget), hbox);
gtk_widget_show (hbox);
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview),
COLOR_BOX_WIDTH, COLOR_BOX_HEIGHT);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_unref (G_OBJECT (label));
g_object_set_data (G_OBJECT (hbox), "preview", preview);
g_object_set_data (G_OBJECT (hbox), "label", label);
}
if (preview)
{
guchar rows[3][COLOR_BOX_WIDTH * 3];
gint x, y;
gint r0, g0, b0;
gint r1, g1, b1;
guchar *p0, *p1, *p2;
/* Fill rows */
r0 = (GIMP_CHECK_DARK + (color->r - GIMP_CHECK_DARK) * color->a) * 255.0;
r1 = (GIMP_CHECK_LIGHT + (color->r - GIMP_CHECK_LIGHT) * color->a) * 255.0;
g0 = (GIMP_CHECK_DARK + (color->g - GIMP_CHECK_DARK) * color->a) * 255.0;
g1 = (GIMP_CHECK_LIGHT + (color->g - GIMP_CHECK_LIGHT) * color->a) * 255.0;
b0 = (GIMP_CHECK_DARK + (color->b - GIMP_CHECK_DARK) * color->a) * 255.0;
b1 = (GIMP_CHECK_LIGHT + (color->b - GIMP_CHECK_LIGHT) * color->a) * 255.0;
p0 = rows[0];
p1 = rows[1];
p2 = rows[2];
for (x = 0; x < COLOR_BOX_WIDTH; x++)
{
if ((x == 0) || (x == (COLOR_BOX_WIDTH - 1)))
{
*p0++ = 0;
*p0++ = 0;
*p0++ = 0;
*p1++ = 0;
*p1++ = 0;
*p1++ = 0;
}
else if ((x / GIMP_CHECK_SIZE) & 1)
{
*p0++ = r1;
*p0++ = g1;
*p0++ = b1;
*p1++ = r0;
*p1++ = g0;
*p1++ = b0;
}
else
{
*p0++ = r0;
*p0++ = g0;
*p0++ = b0;
*p1++ = r1;
*p1++ = g1;
*p1++ = b1;
}
*p2++ = 0;
*p2++ = 0;
*p2++ = 0;
}
/* Fill preview */
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, 0, COLOR_BOX_WIDTH);
for (y = 1; y < (COLOR_BOX_HEIGHT - 1); y++)
if ((y / GIMP_CHECK_SIZE) & 1)
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[1],
0, y, COLOR_BOX_WIDTH);
else
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[0],
0, y, COLOR_BOX_WIDTH);
gtk_preview_draw_row (GTK_PREVIEW (preview), rows[2],
0, y, COLOR_BOX_WIDTH);
gtk_widget_queue_draw (preview);
}
if (label && set_label)
{
gchar *str;
str = g_strdup_printf (_("RGBA (%0.3f, %0.3f, %0.3f, %0.3f)"),
color->r, color->g, color->b, color->a);
gtk_label_set_text (GTK_LABEL (label), str);
g_free (str);
}
#undef COLOR_BOX_WIDTH
#undef COLOR_BOX_HEIGHT
}
void
gimp_item_factory_set_label (GtkItemFactory *factory,
gchar *path,
const gchar *label)
{
GtkWidget *widget;
g_return_if_fail (GTK_IS_ITEM_FACTORY (factory));
g_return_if_fail (path != NULL);
g_return_if_fail (label != NULL);
widget = gtk_item_factory_get_widget (factory, path);
if (widget)
{
if (GTK_IS_MENU (widget))
{
widget = gtk_menu_get_attach_widget (GTK_MENU (widget));
}
if (GTK_IS_LABEL (GTK_BIN (widget)->child))
{
gtk_label_set_text (GTK_LABEL (GTK_BIN (widget)->child), label);
}
}
else
{
g_warning ("%s: Unable to set label of menu item "
"which doesn't exist:\n%s",
G_STRLOC, path);
}
}
void
gimp_item_factory_set_sensitive (GtkItemFactory *factory,
gchar *path,
gboolean sensitive)
{
GtkWidget *widget;
g_return_if_fail (GTK_IS_ITEM_FACTORY (factory));
g_return_if_fail (path != NULL);
widget = gtk_item_factory_get_widget (factory, path);
if (widget)
{
gtk_widget_set_sensitive (widget, sensitive);
}
else if (! strstr (path, "Script-Fu"))
{
g_warning ("%s: Unable to set sensitivity of menu item"
"which doesn't exist:\n%s",
G_STRLOC, path);
}
}
void
gimp_item_factory_set_visible (GtkItemFactory *factory,
gchar *path,
gboolean visible)
{
GtkWidget *widget;
g_return_if_fail (GTK_IS_ITEM_FACTORY (factory));
g_return_if_fail (path != NULL);
widget = gtk_item_factory_get_widget (factory, path);
if (widget)
{
if (visible)
gtk_widget_show (widget);
else
gtk_widget_hide (widget);
}
else
{
g_warning ("%s: Unable to set visibility of menu item"
"which doesn't exist:\n%s",
G_STRLOC, path);
}
}
void
gimp_item_factory_tearoff_callback (GtkWidget *widget,
gpointer data,
guint action)
{
if (GTK_IS_TEAROFF_MENU_ITEM (widget))
{
GtkTearoffMenuItem *tomi = (GtkTearoffMenuItem *) widget;
if (tomi->torn_off)
{
GtkWidget *toplevel;
toplevel = gtk_widget_get_toplevel (widget);
if (! GTK_IS_WINDOW (toplevel))
{
g_warning ("%s: tearoff menu not in top level window",
G_STRLOC);
}
else
{
#ifdef __GNUC__
#warning FIXME: register tearoffs
#endif
g_object_set_data (G_OBJECT (widget), "tearoff-menu-toplevel",
toplevel);
}
}
else
{
GtkWidget *toplevel;
toplevel = (GtkWidget *) g_object_get_data (G_OBJECT (widget),
"tearoff-menu-toplevel");
if (! toplevel)
{
g_warning ("%s: can't unregister tearoff menu top level window",
G_STRLOC);
}
else
{
#ifdef __GNUC__
#warning FIXME: unregister tearoffs
#endif
}
}
}
}
/* private functions */
static void
gimp_item_factory_create_branches (GtkItemFactory *factory,
GimpItemFactoryEntry *entry)
{
GString *tearoff_path;
gint factory_length;
gchar *p;
gchar *path;
if (! entry->entry.path)
return;
tearoff_path = g_string_new ("");
path = entry->entry.path;
p = strchr (path, '/');
factory_length = p - path;
/* skip the first slash */
if (p)
p = strchr (p + 1, '/');
while (p)
{
g_string_assign (tearoff_path, path + factory_length);
g_string_truncate (tearoff_path, p - path - factory_length);
if (!gtk_item_factory_get_widget (factory, tearoff_path->str))
{
GimpItemFactoryEntry branch_entry =
{
{ NULL, NULL, NULL, 0, "<Branch>" },
NULL,
NULL
};
branch_entry.entry.path = tearoff_path->str;
g_object_set_data (G_OBJECT (factory), "complete", path);
gimp_item_factory_create_item (factory,
&branch_entry,
NULL, 2, TRUE, FALSE);
g_object_set_data (G_OBJECT (factory), "complete", NULL);
}
g_string_append (tearoff_path, "/tearoff1");
if (! gtk_item_factory_get_widget (factory, tearoff_path->str))
{
GimpItemFactoryEntry tearoff_entry =
{
{ NULL, NULL, gimp_item_factory_tearoff_callback, 0, "<Tearoff>" },
NULL,
NULL, NULL
};
tearoff_entry.entry.path = tearoff_path->str;
gimp_item_factory_create_item (factory,
&tearoff_entry,
NULL, 2, TRUE, FALSE);
}
p = strchr (p + 1, '/');
}
g_string_free (tearoff_path, TRUE);
}
static void
gimp_item_factory_item_realize (GtkWidget *widget,
gpointer data)
{
if (GTK_IS_MENU_SHELL (widget->parent))
{
if (! g_object_get_data (G_OBJECT (widget->parent),
"menus_key_press_connected"))
{
g_signal_connect (G_OBJECT (widget->parent), "key_press_event",
G_CALLBACK (gimp_item_factory_item_key_press),
data);
g_object_set_data (G_OBJECT (widget->parent),
"menus_key_press_connected",
(gpointer) TRUE);
}
}
}
static gboolean
gimp_item_factory_item_key_press (GtkWidget *widget,
GdkEventKey *kevent,
gpointer data)
the active_tool may change in the middle of gdisplay_canvas_events(), so 2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
2001-07-09 05:44:52 +08:00
{
GtkItemFactory *item_factory = NULL;
GtkWidget *active_menu_item = NULL;
gchar *factory_path = NULL;
gchar *help_path = NULL;
gchar *help_page = NULL;
the active_tool may change in the middle of gdisplay_canvas_events(), so 2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
2001-07-09 05:44:52 +08:00
item_factory = (GtkItemFactory *) data;
active_menu_item = GTK_MENU_SHELL (widget)->active_menu_item;
the active_tool may change in the middle of gdisplay_canvas_events(), so 2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
2001-07-09 05:44:52 +08:00
/* first, get the help page from the item
*/
if (active_menu_item)
{
help_page = (gchar *) g_object_get_data (G_OBJECT (active_menu_item),
"help_page");
}
the active_tool may change in the middle of gdisplay_canvas_events(), so 2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
2001-07-09 05:44:52 +08:00
/* For any key except F1, continue with the standard
* GtkItemFactory callback and assign a new shortcut, but don't
* assign a shortcut to the help menu entries...
*/
if (kevent->keyval != GDK_F1)
{
if (help_page &&
*help_page &&
item_factory == gtk_item_factory_from_path ("<Toolbox>") &&
(strcmp (help_page, "help/dialogs/help.html") == 0 ||
strcmp (help_page, "help/context_help.html") == 0))
{
return TRUE;
}
else
{
return FALSE;
}
}
the active_tool may change in the middle of gdisplay_canvas_events(), so 2001-07-08 Michael Natterer <mitch@gimp.org> * app/disp_callbacks.c: the active_tool may change in the middle of gdisplay_canvas_events(), so re-get it after using it for cursor_update. * app/base/boundary.c: made some global variables local. * app/core/gimpdrawable.c: don't call gimp_drawable_set_visible() in gimp_drawable_configure() because we don't want signal emissions while configuring the drawable. * app/gui/Makefile.am * app/gui/brushes-commands.[ch] * app/gui/data-commands.[ch] * app/gui/gradients-commands.[ch] * app/gui/palettes-commands.[ch] * app/gui/patterns-commands.[ch]: new files for new new item factories' callbacks. * app/gui/menus.[ch]: added context menus for brushes, patterns, ... * app/gui/gradient-editor.c * app/gui/palette-editor.c: removed the "Save as POV", "Import Palette" and "Merge Palattes" buttons as they are item factory callbacks now. * app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbufferview.[ch] * app/widgets/gimpcontainereditor.[ch] * app/widgets/gimpdatafactoryview.[ch]: pass a "GimpContainerContextFunc" pointer to all GimpContainerEditor subclasses' constructors. Use the function to show the context menu. * app/widgets/gimpcontainergridview.c: dispatch the previews' "context" signal. * app/widgets/gimppreview.[ch]: new signal "context" which is emitted on right-click. * app/gui/brush-select.c * app/gui/dialogs-constructors.c * app/gui/gradient-select.c * app/gui/layers-commands.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/test-commands.c: changed accordingly.
2001-07-09 05:44:52 +08:00
/* ...finally, if F1 was pressed over any menu, show it's help page... */
factory_path = (gchar *) g_object_get_data (G_OBJECT (item_factory),
"factory_path");
if (! help_page ||
! *help_page)
help_page = "index.html";
if (factory_path && help_page)
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
{
gchar *help_string;
gchar *at;
help_page = g_strdup (help_page);
at = strchr (help_page, '@'); /* HACK: locale subdir */
if (at)
{
*at = '\0';
help_path = g_strdup (help_page);
help_string = g_strdup (at + 1);
}
else
{
help_string = g_strdup_printf ("%s/%s", factory_path, help_page);
}
1999-04-21 07:36:59 +08:00
gimp_help (help_path, help_string);
g_free (help_string);
g_free (help_page);
}
else
{
gimp_standard_help_func (NULL);
}
return TRUE;
}
#ifdef ENABLE_NLS
static gchar *
gimp_item_factory_translate_func (const gchar *path,
gpointer data)
{
static gchar *menupath = NULL;
GtkItemFactory *item_factory = NULL;
gchar *retval;
gchar *factory;
gchar *translation;
gchar *domain = NULL;
gchar *complete = NULL;
gchar *p, *t;
factory = (gchar *) data;
if (menupath)
g_free (menupath);
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
retval = menupath = g_strdup (path);
if ((strstr (path, "/tearoff1") != NULL) ||
(strstr (path, "/---") != NULL) ||
(strstr (path, "/MRU") != NULL))
return retval;
if (factory)
item_factory = gtk_item_factory_from_path (factory);
if (item_factory)
{
domain = g_object_get_data (G_OBJECT (item_factory), "textdomain");
complete = g_object_get_data (G_OBJECT (item_factory), "complete");
}
if (domain) /* use the plugin textdomain */
{
g_free (menupath);
menupath = g_strconcat (factory, path, NULL);
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
while (complete && *complete &&
translation && *translation &&
strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
{
translation = dgettext (domain, menupath);
}
/*
* Work around a bug in GTK+ prior to 1.2.7 (similar workaround below)
*/
if (strncmp (factory, translation, strlen (factory)) == 0)
{
retval = translation + strlen (factory);
if (complete)
{
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
retval = menupath + strlen (factory);
if (complete)
g_free (translation);
}
}
else /* use the gimp textdomain */
{
if (complete)
{
/*
* This is a branch, use the complete path for translation,
* then strip off entries from the end until it matches.
*/
complete = g_strdup (complete);
translation = g_strdup (gettext (complete));
while (*complete && *translation && strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
if (p && t)
{
*p = '\0';
*t = '\0';
}
else
break;
}
g_free (complete);
}
else
translation = gettext (menupath);
if (*translation == '/')
{
retval = translation;
if (complete)
{
g_free (menupath);
menupath = translation;
}
}
else
{
g_warning ("bad translation for menupath: %s", menupath);
if (complete)
g_free (translation);
}
}
return retval;
Reorganized the core menu items (everything except <Image>/Filters). 1999-11-20 Michael Natterer <mitch@gimp.org> Reorganized the core menu items (everything except <Image>/Filters). Everything is of course trivial to change again, so please comment on the new "menu feeling" ;-) * app/menus.[ch]: - Applied the suggestions collected by Olof. - Added "..." to all items which open a dialog. - Introduced some additional separators (e.g. in "Dialogs"). - Reorder some plugins and the color correct tools after initialisation. - A menu entry to invoke the tooltips inspector. - A debugging menu entry which dumps the menu paths and their help pages (will of course go away when the help sys is consistent). There are currently two identical "Help" menus because <Toolbox>/Help trashes the menu bar if the toolbox is too narrow (gtk doesn't seem to support multi-line menubars, any idea?) * app/app_procs.c: call menus_reorder_plugins() after loading the plugins to beautify the "Xtns" menu. * app/commands.[ch]: reordered some functions to match the new menu structure (for easier source navigation) and renamed some to be consistent (e.g. all help functions are now called help_*). Show/Hide the rulers with ordinary gtk_widget_[show|hide]() commands. I've tested it several times and it looks exactly the same as the old code which used internal gtk knowledge. * app/gdisplay.c: applied the menu changes to gdisplay_set_menu_sensitivity(). * app/gimphelp.[ch]: new public function gimp_context_help() which invokes the tooltips inspector. Code cleanup. * app/resize.c: changed the dialogs' titles to match the menu entries. * app/session.c: renamed the gradient selection cmd callback to be consistent with brushes/patterns. * app/tools.c: added "..." to the menu paths of the tools which have dialogs. * app/fileops.c * app/channels_dialog.c * app/layers_dialog.c * app/paths_dialog.c: added some "...". * plug-ins/common/align_layers.c * plug-ins/common/autostretch_hsv.c * plug-ins/common/c_astretch.c * plug-ins/common/color_enhance.c * plug-ins/common/compose.c * plug-ins/common/decompose.c * plug-ins/common/mail.c * plug-ins/common/normalize.c * plug-ins/common/threshold_alpha.c * plug-ins/dbbrowser/dbbrowser.c * plug-ins/fp/fp.c * plug-ins/print/print.c * plug-ins/rcm/rcm.c: changed the menu paths and added "...".
1999-11-20 20:12:41 +08:00
}
removed GimpFillType. 2001-06-29 Michael Natterer <mitch@gimp.org> * app/appenums.h: removed GimpFillType. * app/gimprc.c: parse the session-info's new "aux-info" field. * app/global_edit.[ch]: removed the old "Paste Named" dialog and prefixed all functions with "gimp_". * app/core/core-types.h: added GimpFillType. * app/core/gimpbrush.[ch]: new signal "spacing_changed". * app/gui/Makefile.am * app/gui/tools-commands.[ch]: one more file cut out of commands.[ch]. * app/gui/commands.[ch]: removed the tools stuff here. * app/gui/brush-select.[ch] * app/gui/dialogs-constructors.c: use the new GimpBrushFactoryView (see below). * app/gui/dialogs-commands.[ch] * app/gui/menus.[ch]: - Made it 64bit safe again by passing the dialog factory's identifiers as GQuarks, not as guints created by GPOINTER_TO_UINT(). - Added a "gchar *quark_string" field to GimpItemFactoryEntry which gets transformed into a GQuark by menus_create_item(). - Added SEPARATOR() and BRANCH() macros which make the *_entries[] arrays more readable. - Added a menu item to show/hide GimpImageDock's image menu. - Removed file_last_opened_cmd_callback(). * app/gui/edit-commands.c: the global_edit functions are "gimp_" prefixed now. * app/gui/file-commands.[ch]: added file_last_opened_cmd_callback() here. * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimpbrushfactoryview.[ch]: new widget: a GimpDataFactory subclass with a "spacing" scale. * app/widgets/gimpcontainereditor.[ch]: - Connect to the GimpContainerView's "select_item", "activate_item" and "context_item" signals here once instead of in each subclass and dispatch them via new virtual functions. - Added a convenience function which makes DND to the buttons much less painful for subclasses. * app/widgets/gimpbufferview.c * app/widgets/gimpdatafactoryview.[ch]: changed accordingly. * app/widgets/gimpdialogfactory.[ch]: - Added gimp_dialog_factory_dialog_raise() which can raise toplevel dialogs _and_ dockables (and creates them if they are not open yet). - Keep track of all created dialogs (not only toplevels). - Added an "aux_info" field to GimpSessionInfo which is a GList of gchar* and is saved in sessionrc. - Remember if GimpImageDock's image menu is visible by using an aux_info string. - The code did not become nicer with all those new constraints. I have to add comments before I forget how it works. * app/widgets/gimpdockbook.c: set the state of the "Show Image Menu" menu item before popping up the item factory. * app/widgets/gimpimagedock.[ch]: added gimp_image_dock_set_show_image_meu(). * plug-ins/gdyntext/gdyntext.c * plug-ins/perl/examples/fit-text * plug-ins/perl/examples/terral_text * plug-ins/perl/examples/tex-to-float: register all text rendering plug-ins under <Image>/Filters/Text * app/pdb/brush_select_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/enums.pl * po/POTFILES.in: changed according to all the stuff above.
2001-06-30 03:25:03 +08:00
#endif /* ENABLE_NLS */