2001-06-30 03:25:03 +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"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2003-06-10 22:31:53 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-10-29 19:47:11 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
#include "tools/gimp-tools.h"
|
|
|
|
#include "tools/gimpimagemaptool.h"
|
2001-06-30 03:25:03 +08:00
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "tools-commands.h"
|
|
|
|
|
2001-06-30 03:25:03 +08:00
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
tools_select_cmd_callback (GtkAction *action,
|
|
|
|
const gchar *value,
|
|
|
|
gpointer data)
|
2001-06-30 03:25:03 +08:00
|
|
|
{
|
2003-06-10 22:31:53 +08:00
|
|
|
Gimp *gimp;
|
2001-06-30 03:25:03 +08:00
|
|
|
GimpToolInfo *tool_info;
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpContext *context;
|
2003-11-10 19:33:35 +08:00
|
|
|
GimpDisplay *gdisp;
|
2004-05-12 00:05:21 +08:00
|
|
|
return_if_no_gimp (gimp, data);
|
2003-06-10 22:31:53 +08:00
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *)
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_container_get_child_by_name (gimp->tool_info_list, value);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2003-06-10 22:31:53 +08:00
|
|
|
context = gimp_get_user_context (gimp);
|
2001-06-30 03:25:03 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
/* always allocate a new tool when selected from the image menu
|
2001-06-30 03:25:03 +08:00
|
|
|
*/
|
2001-11-09 03:14:51 +08:00
|
|
|
if (gimp_context_get_tool (context) != tool_info)
|
2001-06-30 03:25:03 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_context_set_tool (context, tool_info);
|
2001-06-30 03:25:03 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_context_tool_changed (context);
|
|
|
|
}
|
|
|
|
|
2003-11-10 19:33:35 +08:00
|
|
|
gdisp = gimp_context_get_display (context);
|
|
|
|
|
|
|
|
if (gdisp)
|
|
|
|
tool_manager_initialize_active (gimp, gdisp);
|
2001-06-30 03:25:03 +08:00
|
|
|
}
|
2004-05-10 08:41:57 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
tools_toggle_visibility_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-05-12 00:05:21 +08:00
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
return_if_no_context (context, data);
|
2004-05-11 01:16:50 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
tool_info = gimp_context_get_tool (context);
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2004-12-31 21:29:39 +08:00
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
gboolean active =
|
|
|
|
gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (active != tool_info->visible)
|
|
|
|
g_object_set (tool_info, "visible", active, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_raise_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
return_if_no_context (context, data);
|
|
|
|
|
|
|
|
tool_info = gimp_context_get_tool (context);
|
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
GimpContainer *container;
|
|
|
|
gint index;
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2004-12-31 21:29:39 +08:00
|
|
|
container = context->gimp->tool_info_list;
|
|
|
|
index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (tool_info));
|
|
|
|
|
|
|
|
if (index > 0)
|
|
|
|
gimp_container_reorder (container, GIMP_OBJECT (tool_info), index - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_raise_to_top_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
return_if_no_context (context, data);
|
|
|
|
|
|
|
|
tool_info = gimp_context_get_tool (context);
|
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
GimpContainer *container;
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
container = context->gimp->tool_info_list;
|
|
|
|
index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (tool_info));
|
|
|
|
|
|
|
|
if (index > 0)
|
|
|
|
gimp_container_reorder (container, GIMP_OBJECT (tool_info), 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_lower_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
return_if_no_context (context, data);
|
|
|
|
|
|
|
|
tool_info = gimp_context_get_tool (context);
|
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
GimpContainer *container;
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
container = context->gimp->tool_info_list;
|
|
|
|
index = gimp_container_get_child_index (container,
|
|
|
|
GIMP_OBJECT (tool_info));
|
|
|
|
|
|
|
|
if (index + 1 < gimp_container_num_children (container))
|
|
|
|
gimp_container_reorder (container, GIMP_OBJECT (tool_info), index + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_lower_to_bottom_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpContext *context;
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
return_if_no_context (context, data);
|
|
|
|
|
|
|
|
tool_info = gimp_context_get_tool (context);
|
|
|
|
|
|
|
|
if (tool_info)
|
|
|
|
{
|
|
|
|
GimpContainer *container;
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
container = context->gimp->tool_info_list;
|
|
|
|
index = gimp_container_num_children (container) - 1;
|
|
|
|
|
|
|
|
index = index >= 0 ? index : 0;
|
|
|
|
|
|
|
|
gimp_container_reorder (container, GIMP_OBJECT (tool_info), index);
|
|
|
|
}
|
2004-05-10 08:41:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_reset_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-12-31 21:29:39 +08:00
|
|
|
GimpContext *context;
|
|
|
|
GimpContainer *container;
|
|
|
|
GList *list;
|
|
|
|
gint i = 0;
|
|
|
|
return_if_no_context (context, data);
|
|
|
|
|
|
|
|
container = context->gimp->tool_info_list;
|
2004-05-12 00:05:21 +08:00
|
|
|
|
|
|
|
for (list = gimp_tools_get_default_order (context->gimp);
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpObject *object = gimp_container_get_child_by_name (container,
|
|
|
|
list->data);
|
|
|
|
|
|
|
|
if (object)
|
|
|
|
{
|
|
|
|
gimp_container_reorder (container, object, i);
|
2004-05-10 08:41:57 +08:00
|
|
|
|
2004-05-12 00:05:21 +08:00
|
|
|
g_object_set (object, "visible",
|
|
|
|
! g_type_is_a (GIMP_TOOL_INFO (object)->tool_type,
|
|
|
|
GIMP_TYPE_IMAGE_MAP_TOOL),
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2004-05-10 08:41:57 +08:00
|
|
|
}
|