Commit 8439ecb6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/actions/tools-actions.c app/actions/tools-commands.[ch] applied a

2004-12-31  Michael Natterer  <mitch@gimp.org>

	* app/actions/tools-actions.c
	* app/actions/tools-commands.[ch]
	* app/widgets/gimptoolview.[ch]: applied a (modified) patch from
	Joao S. O. Bueno which adds "raise" and "lower" actions and
	their buttons in the tool dialog. Fixes bug #158666.
	Cleaned up the tool action callbacks.
parent 4df339c0
2004-12-31 Michael Natterer <mitch@gimp.org>
* app/actions/tools-actions.c
* app/actions/tools-commands.[ch]
* app/widgets/gimptoolview.[ch]: applied a (modified) patch from
Joao S. O. Bueno which adds "raise" and "lower" actions and
their buttons in the tool dialog. Fixes bug #158666.
Cleaned up the tool action callbacks.
2004-12-31 Sven Neumann <sven@gimp.org>
* plug-ins/imagemap/imap_preview.c (render_rgb_image): use the proper
......
......@@ -53,6 +53,30 @@ static GimpActionEntry tools_actions[] =
{ "tools-transform-menu", NULL, N_("_Transform Tools") },
{ "tools-color-menu", NULL, N_("_Color Tools") },
{ "tools-raise", GTK_STOCK_GO_UP,
N_("R_aise Tool"), NULL,
N_("Raise tool"),
G_CALLBACK (tools_raise_cmd_callback),
NULL },
{ "tools-raise-to-top", GTK_STOCK_GOTO_TOP,
N_("Ra_ise to Top"), NULL,
N_("Raise tool to top"),
G_CALLBACK (tools_raise_to_top_cmd_callback),
NULL },
{ "tools-lower", GTK_STOCK_GO_DOWN,
N_("L_ower Tool"), NULL,
N_("Lower tool"),
G_CALLBACK (tools_lower_cmd_callback),
NULL },
{ "tools-lower-to-bottom", GTK_STOCK_GOTO_BOTTOM,
N_("Lo_wer to Bottom"), NULL,
N_("Lower tool to bottom"),
G_CALLBACK (tools_lower_to_bottom_cmd_callback),
NULL },
{ "tools-reset", GIMP_STOCK_RESET,
N_("_Reset Order & Visibility"), NULL,
N_("Reset tool order and visibility"),
......@@ -165,8 +189,11 @@ void
tools_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpContext *context = gimp_get_user_context (group->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
GimpContext *context = gimp_get_user_context (group->gimp);
GimpToolInfo *tool_info = gimp_context_get_tool (context);
GimpContainer *container = context->gimp->tool_info_list;
gboolean raise = FALSE;
gboolean lower = FALSE;
#define SET_SENSITIVE(action,condition) \
gimp_action_group_set_action_sensitive (group, action, (condition) != 0)
......@@ -176,7 +203,24 @@ tools_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("tools-visibility", tool_info);
if (tool_info)
SET_ACTIVE ("tools-visibility", tool_info->visible);
{
gint last_index;
gint index;
SET_ACTIVE ("tools-visibility", tool_info->visible);
last_index = gimp_container_num_children (container) -1;
index = gimp_container_get_child_index (container,
GIMP_OBJECT (tool_info));
raise = index != 0;
lower = index != last_index;
}
SET_SENSITIVE ("tools-raise", raise);
SET_SENSITIVE ("tools-raise-to-top", raise);
SET_SENSITIVE ("tools-lower", lower);
SET_SENSITIVE ("tools-lower-to-bottom", lower);
#undef SET_SENSITIVE
#undef SET_ACTIVE
......
......@@ -25,15 +25,8 @@
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimptoolinfo.h"
#include "widgets/gimpcontainereditor.h"
#include "widgets/gimpcontainerview.h"
#include "widgets/gimptoolview.h"
#include "display/gimpdisplay.h"
#include "tools/gimp-tools.h"
#include "tools/gimpimagemaptool.h"
#include "tools/tool_manager.h"
......@@ -81,29 +74,127 @@ tools_toggle_visibility_cmd_callback (GtkAction *action,
{
GimpContext *context;
GimpToolInfo *tool_info;
gboolean active;
return_if_no_context (context, data);
tool_info = gimp_context_get_tool (context);
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
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;
if (active != tool_info->visible)
g_object_set (tool_info, "visible", active, NULL);
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);
}
}
void
tools_reset_cmd_callback (GtkAction *action,
gpointer data)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
GimpContainer *container;
GimpContext *context;
GList *list;
gint i = 0;
container = gimp_container_view_get_container (editor->view);
context = gimp_container_view_get_context (editor->view);
GimpContext *context;
GimpContainer *container;
GList *list;
gint i = 0;
return_if_no_context (context, data);
container = context->gimp->tool_info_list;
for (list = gimp_tools_get_default_order (context->gimp);
list;
......
......@@ -25,6 +25,16 @@ void tools_select_cmd_callback (GtkAction *action,
gpointer data);
void tools_toggle_visibility_cmd_callback (GtkAction *action,
gpointer data);
void tools_raise_cmd_callback (GtkAction *action,
gpointer data);
void tools_raise_to_top_cmd_callback (GtkAction *action,
gpointer data);
void tools_lower_cmd_callback (GtkAction *action,
gpointer data);
void tools_lower_to_bottom_cmd_callback (GtkAction *action,
gpointer data);
void tools_reset_cmd_callback (GtkAction *action,
gpointer data);
......
......@@ -116,6 +116,8 @@ static void
gimp_tool_view_init (GimpToolView *view)
{
view->visible_handler_id = 0;
view->raise_button = NULL;
view->lower_button = NULL;
view->reset_button = NULL;
}
......@@ -163,6 +165,18 @@ gimp_tool_view_new (GimpViewType view_type,
editor = GIMP_CONTAINER_EDITOR (tool_view);
tool_view->raise_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
"tools-raise",
"tools-raise-to-top", GDK_SHIFT_MASK,
NULL);
tool_view->lower_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
"tools-lower",
"tools-lower-to-bottom", GDK_SHIFT_MASK,
NULL);
tool_view->reset_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "tools",
"tools-reset", NULL);
......
......@@ -42,6 +42,8 @@ struct _GimpToolView
GQuark visible_handler_id;
GtkWidget *raise_button;
GtkWidget *lower_button;
GtkWidget *reset_button;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment