2004-04-20 21:25:55 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-04-21 18:55:45 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "actions-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2004-05-10 08:41:57 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "core/gimplist.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "widgets/gimpactiongroup.h"
|
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
#include "actions.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions/tools-actions.h"
|
|
|
|
#include "actions/tools-commands.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
static GimpActionEntry tools_actions[] =
|
|
|
|
{
|
2004-05-10 08:41:57 +08:00
|
|
|
{ "tools-popup", GIMP_STOCK_TOOLS, N_("Tools Menu"), NULL, NULL, NULL,
|
|
|
|
GIMP_HELP_TOOLS_DIALOG },
|
|
|
|
|
2004-04-21 18:55:45 +08:00
|
|
|
{ "tools-menu", NULL, N_("_Tools") },
|
|
|
|
{ "tools-select-menu", NULL, N_("_Selection Tools") },
|
|
|
|
{ "tools-paint-menu", NULL, N_("_Paint Tools") },
|
|
|
|
{ "tools-transform-menu", NULL, N_("_Transform Tools") },
|
|
|
|
{ "tools-color-menu", NULL, N_("_Color Tools") },
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-10 08:41:57 +08:00
|
|
|
{ "tools-reset", GIMP_STOCK_RESET,
|
2004-05-12 00:05:21 +08:00
|
|
|
N_("_Reset Order & Visibility"), NULL,
|
|
|
|
N_("Reset tool order and visibility"),
|
2004-05-10 08:41:57 +08:00
|
|
|
G_CALLBACK (tools_reset_cmd_callback),
|
|
|
|
NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static GimpToggleActionEntry tools_toggle_actions[] =
|
|
|
|
{
|
2004-07-21 02:13:49 +08:00
|
|
|
{ "tools-visibility", GIMP_STOCK_VISIBLE,
|
2004-05-10 08:41:57 +08:00
|
|
|
N_("Show in Toolbox"), NULL, NULL,
|
|
|
|
G_CALLBACK (tools_toggle_visibility_cmd_callback),
|
|
|
|
TRUE,
|
|
|
|
NULL /* FIXME */ }
|
2004-04-20 21:25:55 +08:00
|
|
|
};
|
|
|
|
|
2004-05-05 09:17:23 +08:00
|
|
|
static GimpStringActionEntry tools_alternative_actions[] =
|
|
|
|
{
|
|
|
|
{ "tools-by-color-select-short", GIMP_STOCK_TOOL_BY_COLOR_SELECT,
|
|
|
|
N_("_By Color"), NULL, NULL,
|
|
|
|
"gimp-by-color-select-tool",
|
|
|
|
GIMP_HELP_TOOL_BY_COLOR_SELECT },
|
|
|
|
|
|
|
|
{ "tools-rotate-arbitrary", GIMP_STOCK_TOOL_ROTATE,
|
|
|
|
N_("_Arbitrary Rotation..."), NULL, NULL,
|
|
|
|
"gimp-rotate-tool",
|
|
|
|
GIMP_HELP_TOOL_ROTATE }
|
|
|
|
};
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
|
|
|
|
void
|
2004-04-27 21:55:26 +08:00
|
|
|
tools_actions_setup (GimpActionGroup *group)
|
2004-04-20 21:25:55 +08:00
|
|
|
{
|
2004-05-05 09:17:23 +08:00
|
|
|
GtkAction *action;
|
|
|
|
GList *list;
|
2004-04-20 21:25:55 +08:00
|
|
|
|
|
|
|
gimp_action_group_add_actions (group,
|
|
|
|
tools_actions,
|
2004-04-27 21:55:26 +08:00
|
|
|
G_N_ELEMENTS (tools_actions));
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-10 08:41:57 +08:00
|
|
|
gimp_action_group_add_toggle_actions (group,
|
|
|
|
tools_toggle_actions,
|
|
|
|
G_N_ELEMENTS (tools_toggle_actions));
|
|
|
|
|
2004-05-05 09:17:23 +08:00
|
|
|
gimp_action_group_add_string_actions (group,
|
|
|
|
tools_alternative_actions,
|
|
|
|
G_N_ELEMENTS (tools_alternative_actions),
|
|
|
|
G_CALLBACK (tools_select_cmd_callback));
|
|
|
|
|
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
"tools-by-color-select-short");
|
|
|
|
gtk_action_set_accel_path (action, "<Actions>/tools/tools-by-color-select");
|
|
|
|
|
2004-07-21 08:39:46 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: remove accel_path hack
|
|
|
|
#endif
|
|
|
|
g_object_set_data (G_OBJECT (action), "gimp-accel-path",
|
|
|
|
"<Actions>/tools/tools-by-color-select");
|
|
|
|
|
2004-05-05 09:17:23 +08:00
|
|
|
action = gtk_action_group_get_action (GTK_ACTION_GROUP (group),
|
|
|
|
"tools-rotate-arbitrary");
|
|
|
|
gtk_action_set_accel_path (action, "<Actions>/tools/tools-rotate");
|
2004-07-21 08:39:46 +08:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: remove accel_path hack
|
|
|
|
#endif
|
|
|
|
g_object_set_data (G_OBJECT (action), "gimp-accel-path",
|
|
|
|
"<Actions>/tools/tools-rotate");
|
2004-05-05 09:17:23 +08:00
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
for (list = GIMP_LIST (group->gimp->tool_info_list)->list;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info = list->data;
|
|
|
|
|
|
|
|
if (tool_info->menu_path)
|
|
|
|
{
|
|
|
|
GimpStringActionEntry entry;
|
|
|
|
const gchar *stock_id;
|
|
|
|
const gchar *identifier;
|
2004-04-21 18:55:45 +08:00
|
|
|
gchar *tmp;
|
|
|
|
gchar *name;
|
2004-04-20 21:25:55 +08:00
|
|
|
|
|
|
|
stock_id = gimp_viewable_get_stock_id (GIMP_VIEWABLE (tool_info));
|
|
|
|
identifier = gimp_object_get_name (GIMP_OBJECT (tool_info));
|
|
|
|
|
2004-04-21 18:55:45 +08:00
|
|
|
tmp = g_strndup (identifier + strlen ("gimp-"),
|
|
|
|
strlen (identifier) - strlen ("gimp--tool"));
|
|
|
|
name = g_strdup_printf ("tools-%s", tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
entry.name = name;
|
2004-04-20 21:25:55 +08:00
|
|
|
entry.stock_id = stock_id;
|
|
|
|
entry.label = tool_info->menu_path;
|
|
|
|
entry.accelerator = tool_info->menu_accel;
|
|
|
|
entry.tooltip = tool_info->blurb;
|
2004-05-04 06:36:59 +08:00
|
|
|
entry.help_id = tool_info->help_id;
|
2004-04-20 21:25:55 +08:00
|
|
|
entry.value = identifier;
|
|
|
|
|
|
|
|
gimp_action_group_add_string_actions (group,
|
|
|
|
&entry, 1,
|
2004-04-27 21:55:26 +08:00
|
|
|
G_CALLBACK (tools_select_cmd_callback));
|
2004-04-21 18:55:45 +08:00
|
|
|
|
|
|
|
g_free (name);
|
2004-04-20 21:25:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_actions_update (GimpActionGroup *group,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-12 00:05:21 +08:00
|
|
|
GimpContext *context;
|
2004-05-10 08:41:57 +08:00
|
|
|
GimpToolInfo *tool_info = NULL;
|
|
|
|
|
2004-05-13 21:52:18 +08:00
|
|
|
context = gimp_get_user_context (group->gimp);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
if (context)
|
|
|
|
tool_info = gimp_context_get_tool (context);
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
#define SET_SENSITIVE(action,condition) \
|
|
|
|
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
|
2004-05-10 08:41:57 +08:00
|
|
|
#define SET_ACTIVE(action,condition) \
|
|
|
|
gimp_action_group_set_action_active (group, action, (condition) != 0)
|
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
SET_SENSITIVE ("tools-visibility", tool_info);
|
2004-05-13 21:52:18 +08:00
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
SET_ACTIVE ("tools-visibility", tool_info->visible);
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
#undef SET_SENSITIVE
|
2004-05-10 08:41:57 +08:00
|
|
|
#undef SET_ACTIVE
|
2004-04-20 21:25:55 +08:00
|
|
|
}
|