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-12-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
1999-10-03 21:50:19 +08:00
|
|
|
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
#include "libgimpbase/gimpwin32-io.h"
|
|
|
|
#endif
|
|
|
|
|
2004-05-06 15:41:53 +08:00
|
|
|
#include "menus-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-11-19 04:50:31 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2004-09-20 22:41:54 +08:00
|
|
|
#include "widgets/gimpactionfactory.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "widgets/gimpmenufactory.h"
|
|
|
|
|
2003-01-13 22:08:10 +08:00
|
|
|
#include "image-menu.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "menus.h"
|
2003-09-30 04:26:09 +08:00
|
|
|
#include "tool-options-menu.h"
|
2003-01-13 22:08:10 +08:00
|
|
|
#include "toolbox-menu.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
static void menu_can_change_accels (GimpGuiConfig *config);
|
2003-04-01 15:47:04 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2003-01-13 22:08:10 +08:00
|
|
|
/* global variables */
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
GimpMenuFactory * global_menu_factory = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
|
|
|
static gboolean menurc_deleted = FALSE;
|
1999-06-07 01:26:51 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
|
|
|
|
/* public functions */
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
void
|
2004-09-20 22:41:54 +08:00
|
|
|
menus_init (Gimp *gimp,
|
|
|
|
GimpActionFactory *action_factory)
|
2003-01-11 01:55:53 +08:00
|
|
|
{
|
2001-10-24 00:23:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2004-09-20 22:41:54 +08:00
|
|
|
g_return_if_fail (GIMP_IS_ACTION_FACTORY (action_factory));
|
2004-07-02 22:08:15 +08:00
|
|
|
g_return_if_fail (global_menu_factory == NULL);
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2003-04-02 08:08:38 +08:00
|
|
|
/* We need to make sure the property is installed before using it */
|
|
|
|
g_type_class_ref (GTK_TYPE_MENU);
|
2003-04-01 15:47:04 +08:00
|
|
|
|
|
|
|
menu_can_change_accels (GIMP_GUI_CONFIG (gimp->config));
|
|
|
|
|
2003-04-02 08:08:38 +08:00
|
|
|
g_signal_connect (gimp->config, "notify::can-change-accels",
|
|
|
|
G_CALLBACK (menu_can_change_accels), NULL);
|
|
|
|
|
2004-09-20 22:41:54 +08:00
|
|
|
global_menu_factory = gimp_menu_factory_new (gimp, action_factory);
|
2001-10-24 00:23:32 +08:00
|
|
|
|
2004-04-21 18:55:45 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Image>",
|
2004-04-22 00:33:17 +08:00
|
|
|
"file",
|
2004-06-15 23:42:50 +08:00
|
|
|
"context",
|
2004-04-23 00:18:40 +08:00
|
|
|
"debug",
|
|
|
|
"help",
|
2004-04-22 00:33:17 +08:00
|
|
|
"edit",
|
|
|
|
"select",
|
|
|
|
"view",
|
|
|
|
"image",
|
|
|
|
"drawable",
|
|
|
|
"layers",
|
2004-05-05 19:40:20 +08:00
|
|
|
"channels",
|
2004-04-22 00:33:17 +08:00
|
|
|
"vectors",
|
|
|
|
"tools",
|
|
|
|
"dialogs",
|
|
|
|
"plug-in",
|
2004-04-23 00:18:40 +08:00
|
|
|
"qmask",
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/toolbox-menubar",
|
2004-04-29 20:52:29 +08:00
|
|
|
"toolbox-menu.xml", toolbox_menu_setup,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/image-menubar",
|
2004-04-29 20:52:29 +08:00
|
|
|
"image-menu.xml", image_menu_setup,
|
2004-05-17 21:38:03 +08:00
|
|
|
"/dummy-menubar",
|
2004-04-29 20:52:29 +08:00
|
|
|
"image-menu.xml", image_menu_setup,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/qmask-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"qmask-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-05-05 05:16:40 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Dock>",
|
|
|
|
"file",
|
2004-06-15 23:42:50 +08:00
|
|
|
"context",
|
2004-05-05 05:16:40 +08:00
|
|
|
"edit",
|
|
|
|
"select",
|
|
|
|
"image",
|
|
|
|
"drawable",
|
|
|
|
"layers",
|
2004-05-05 19:40:20 +08:00
|
|
|
"channels",
|
2004-05-05 05:16:40 +08:00
|
|
|
"vectors",
|
|
|
|
"tools",
|
|
|
|
"dialogs",
|
|
|
|
"plug-in",
|
|
|
|
"qmask",
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Layers>",
|
|
|
|
"layers",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/layers-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"layers-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Channels>",
|
|
|
|
"channels",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/channels-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"channels-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Vectors>",
|
|
|
|
"vectors",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/vectors-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"vectors-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-05-05 19:40:20 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Dockable>",
|
2004-04-22 00:33:17 +08:00
|
|
|
"dockable",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/dockable-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"dockable-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Brushes>",
|
|
|
|
"brushes",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/brushes-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"brushes-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Patterns>",
|
|
|
|
"patterns",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/patterns-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"patterns-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Gradients>",
|
|
|
|
"gradients",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/gradients-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"gradients-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Palettes>",
|
|
|
|
"palettes",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/palettes-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"palettes-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Fonts>",
|
|
|
|
"fonts",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/fonts-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"fonts-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-10-19 00:23:15 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Buffers>",
|
|
|
|
"buffers",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/buffers-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"buffers-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Documents>",
|
|
|
|
"documents",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/documents-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"documents-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Templates>",
|
|
|
|
"templates",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/templates-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"templates-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-04-06 19:21:56 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Images>",
|
|
|
|
"images",
|
|
|
|
NULL,
|
2004-04-23 00:18:40 +08:00
|
|
|
"/images-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"images-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-05-10 08:41:57 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<Tools>",
|
|
|
|
"tools",
|
|
|
|
NULL,
|
|
|
|
"/tools-popup",
|
|
|
|
"tools-menu.xml", NULL,
|
|
|
|
NULL);
|
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<GradientEditor>",
|
|
|
|
"gradient-editor",
|
|
|
|
NULL,
|
|
|
|
"/gradient-editor-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"gradient-editor-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<PaletteEditor>",
|
2004-04-23 00:18:40 +08:00
|
|
|
"palette-editor",
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL,
|
|
|
|
"/palette-editor-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"palette-editor-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<ColormapEditor>",
|
|
|
|
"colormap-editor",
|
|
|
|
NULL,
|
|
|
|
"/colormap-editor-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"colormap-editor-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-13 22:08:10 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<SelectionEditor>",
|
|
|
|
"select",
|
|
|
|
"vectors",
|
|
|
|
NULL,
|
|
|
|
"/selection-editor-popup",
|
|
|
|
"selection-editor-menu.xml", NULL,
|
|
|
|
NULL);
|
|
|
|
|
2004-09-26 23:21:44 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<NavigationEditor>",
|
|
|
|
"view",
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<UndoEditor>",
|
|
|
|
"edit",
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<ErrorConsole>",
|
|
|
|
"error-console",
|
|
|
|
NULL,
|
|
|
|
"/error-console-popup",
|
2004-04-26 23:51:21 +08:00
|
|
|
"error-console-menu.xml", NULL,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-09-30 04:26:09 +08:00
|
|
|
|
2004-04-22 00:33:17 +08:00
|
|
|
gimp_menu_factory_manager_register (global_menu_factory, "<ToolOptions>",
|
|
|
|
"tool-options",
|
|
|
|
NULL,
|
|
|
|
"/tool-options-popup",
|
2004-04-30 23:29:11 +08:00
|
|
|
"tool-options-menu.xml",
|
|
|
|
tool_options_menu_setup,
|
2004-04-22 00:33:17 +08:00
|
|
|
NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
}
|
2002-01-26 02:34:33 +08:00
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
void
|
|
|
|
menus_exit (Gimp *gimp)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2004-07-02 22:08:15 +08:00
|
|
|
g_return_if_fail (global_menu_factory != NULL);
|
|
|
|
g_return_if_fail (global_menu_factory->gimp == gimp);
|
|
|
|
|
2003-01-11 01:55:53 +08:00
|
|
|
g_object_unref (global_menu_factory);
|
|
|
|
global_menu_factory = NULL;
|
2003-04-01 15:47:04 +08:00
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (gimp->config,
|
|
|
|
menu_can_change_accels,
|
|
|
|
NULL);
|
2001-10-24 00:23:32 +08:00
|
|
|
}
|
|
|
|
|
2003-04-08 18:02:42 +08:00
|
|
|
void
|
|
|
|
menus_restore (Gimp *gimp)
|
|
|
|
{
|
2003-09-22 23:31:54 +08:00
|
|
|
gchar *filename;
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
filename = gimp_personal_rc_file ("menurc");
|
|
|
|
gtk_accel_map_load (filename);
|
|
|
|
g_free (filename);
|
2003-04-08 18:02:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-22 00:11:31 +08:00
|
|
|
menus_save (Gimp *gimp,
|
|
|
|
gboolean always_save)
|
2003-04-08 18:02:42 +08:00
|
|
|
{
|
2003-09-22 23:31:54 +08:00
|
|
|
gchar *filename;
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
if (menurc_deleted && ! always_save)
|
|
|
|
return;
|
|
|
|
|
2003-09-22 23:31:54 +08:00
|
|
|
filename = gimp_personal_rc_file ("menurc");
|
|
|
|
gtk_accel_map_save (filename);
|
|
|
|
g_free (filename);
|
2004-07-22 00:11:31 +08:00
|
|
|
|
|
|
|
menurc_deleted = FALSE;
|
2003-04-08 18:02:42 +08:00
|
|
|
}
|
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
gboolean
|
|
|
|
menus_clear (Gimp *gimp,
|
|
|
|
GError **error)
|
2003-04-08 18:02:42 +08:00
|
|
|
{
|
2004-07-22 00:11:31 +08:00
|
|
|
gchar *filename;
|
|
|
|
gboolean success = TRUE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
|
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("menurc");
|
|
|
|
|
|
|
|
if (unlink (filename) != 0 && errno != ENOENT)
|
|
|
|
{
|
|
|
|
g_set_error (error, 0, 0, _("Deleting \"%s\" failed: %s"),
|
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menurc_deleted = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
2003-04-08 18:02:42 +08:00
|
|
|
|
2004-07-22 00:11:31 +08:00
|
|
|
return success;
|
2003-04-08 18:02:42 +08:00
|
|
|
}
|
|
|
|
|
2003-01-13 22:08:10 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2003-04-01 15:47:04 +08:00
|
|
|
static void
|
|
|
|
menu_can_change_accels (GimpGuiConfig *config)
|
|
|
|
{
|
2003-11-02 04:06:01 +08:00
|
|
|
g_object_set (gtk_settings_get_for_screen (gdk_screen_get_default ()),
|
2003-04-02 08:08:38 +08:00
|
|
|
"gtk-can-change-accels", config->can_change_accels,
|
|
|
|
NULL);
|
2003-04-01 15:47:04 +08:00
|
|
|
}
|