Commit 2426755b authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added function gimp_get_tool_info().

2006-09-08  Sven Neumann  <sven@gimp.org>

	* app/core/gimp.[ch]: added function gimp_get_tool_info().

	* app/actions/tools-commands.c
	* app/actions/vectors-commands.c
	* app/tools/gimppainttool.c
	* app/widgets/gimpdrawabletreeview.c
	* app/widgets/gimpselectioneditor.c
	* app/widgets/gimptoolbox.c: use the new function instead of poking
	into gimp->tool_info_list.

	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell.[ch]: moved code that deals with
	the space key into separate functions. Added space_shaded_tool
	to GimpDisplayShell instead of using a static variable for it.

	* app/tools/tool_manager.c: removed unused include.
parent 13a2beb5
2006-09-08 Sven Neumann <sven@gimp.org>
* app/core/gimp.[ch]: added function gimp_get_tool_info().
* app/actions/tools-commands.c
* app/actions/vectors-commands.c
* app/tools/gimppainttool.c
* app/widgets/gimpdrawabletreeview.c
* app/widgets/gimpselectioneditor.c
* app/widgets/gimptoolbox.c: use the new function instead of poking
into gimp->tool_info_list.
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell.[ch]: moved code that deals with
the space key into separate functions. Added space_shaded_tool
to GimpDisplayShell instead of using a static variable for it.
* app/tools/tool_manager.c: removed unused include.
2006-09-08 Sven Neumann <sven@gimp.org>
* app/widgets/gimpwidgets-utils.c: mark "Space" and "Backslash"
......
......@@ -41,7 +41,6 @@
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
#include "core/gimpundostack.h"
#include "core/gimpprogress.h"
......@@ -166,10 +165,7 @@ layers_text_tool_cmd_callback (GtkAction *action,
if (! GIMP_IS_TEXT_TOOL (active_tool))
{
GimpToolInfo *tool_info;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (image->gimp->tool_info_list,
GimpToolInfo *tool_info = gimp_get_tool_info (image->gimp,
"gimp-text-tool");
if (GIMP_IS_TOOL_INFO (tool_info))
......
......@@ -71,8 +71,7 @@ tools_select_cmd_callback (GtkAction *action,
value = "gimp-rotate-tool";
}
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list, value);
tool_info = gimp_get_tool_info (gimp, value);
context = gimp_get_user_context (gimp);
......
......@@ -30,7 +30,6 @@
#include "core/gimp-utils.h"
#include "core/gimpchannel.h"
#include "core/gimpchannel-select.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-merge.h"
......@@ -107,10 +106,7 @@ vectors_vectors_tool_cmd_callback (GtkAction *action,
if (! GIMP_IS_VECTOR_TOOL (active_tool))
{
GimpToolInfo *tool_info;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (image->gimp->tool_info_list,
GimpToolInfo *tool_info = gimp_get_tool_info (image->gimp,
"gimp-vector-tool");
if (GIMP_IS_TOOL_INFO (tool_info))
......
......@@ -977,6 +977,20 @@ gimp_get_user_context (Gimp *gimp)
return gimp->user_context;
}
GimpToolInfo *
gimp_get_tool_info (Gimp *gimp,
const gchar *tool_id)
{
gpointer info;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
g_return_val_if_fail (tool_id != NULL, NULL);
info = gimp_container_get_child_by_name (gimp->tool_info_list, tool_id);
return (GimpToolInfo *) info;
}
void
gimp_message (Gimp *gimp,
GimpProgress *progress,
......
......@@ -171,6 +171,9 @@ void gimp_set_user_context (Gimp *gimp,
GimpContext *context);
GimpContext * gimp_get_user_context (Gimp *gimp);
GimpToolInfo * gimp_get_tool_info (Gimp *gimp,
const gchar *tool_name);
void gimp_message (Gimp *gimp,
GimpProgress *progress,
const gchar *format,
......
......@@ -32,7 +32,6 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-guides.h"
......@@ -451,6 +450,78 @@ gimp_display_shell_check_device_cursor (GimpDisplayShell *shell)
shell->draw_cursor = ! current_device->has_cursor;
}
static void
gimp_display_shell_space_pressed (GimpDisplayShell *shell,
GdkModifierType state,
guint32 time)
{
if (! shell->space_pressed)
{
GimpDisplay *display = shell->display;
Gimp *gimp = display->image->gimp;
GimpTool *active_tool = tool_manager_get_active (gimp);
if (active_tool && ! GIMP_IS_MOVE_TOOL (active_tool))
{
GimpToolInfo *move_tool_info;
move_tool_info = gimp_get_tool_info (gimp, "gimp-move-tool");
if (GIMP_IS_TOOL_INFO (move_tool_info))
{
#ifdef DEBUG_MOVE_PUSH
g_printerr ("%s: pushing move tool\n", G_STRFUNC);
#endif
shell->space_shaded_tool =
gimp_object_get_name (GIMP_OBJECT (active_tool->tool_info));
gdk_keyboard_grab (shell->canvas->window, FALSE, time);
gimp_context_set_tool (gimp_get_user_context (gimp),
move_tool_info);
tool_manager_focus_display_active (gimp, display);
tool_manager_modifier_state_active (gimp, state, display);
shell->space_pressed = TRUE;
}
}
}
}
static void
gimp_display_shell_space_released (GimpDisplayShell *shell,
GdkModifierType state,
guint32 time)
{
if (shell->space_pressed)
{
GimpDisplay *display = shell->display;
Gimp *gimp = display->image->gimp;
#ifdef DEBUG_MOVE_PUSH
g_printerr ("%s: popping move tool\n", G_STRFUNC);
#endif
gimp_context_set_tool (gimp_get_user_context (gimp),
gimp_get_tool_info (gimp,
shell->space_shaded_tool));
shell->space_shaded_tool = NULL;
tool_manager_focus_display_active (gimp, display);
tool_manager_modifier_state_active (gimp, state, display);
shell->space_pressed = FALSE;
gdk_display_keyboard_ungrab (gtk_widget_get_display (shell->canvas),
time);
}
}
gboolean
gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
GdkEvent *event,
......@@ -468,8 +539,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gboolean return_val = FALSE;
gboolean update_sw_cursor = FALSE;
static GimpToolInfo *space_shaded_tool = NULL;
g_return_val_if_fail (GTK_WIDGET_REALIZED (canvas), FALSE);
/* are we in destruction? */
......@@ -828,27 +897,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gtk_grab_remove (canvas);
if (shell->space_release_pending)
{
#ifdef DEBUG_MOVE_PUSH
g_printerr ("%s: popping move tool\n", G_STRFUNC);
#endif
gimp_context_set_tool (gimp_get_user_context (gimp),
space_shaded_tool);
space_shaded_tool = NULL;
tool_manager_focus_display_active (gimp, display);
tool_manager_modifier_state_active (gimp, state, display);
tool_manager_oper_update_active (gimp,
&image_coords, state,
shell->proximity,
display);
shell->space_release_pending = FALSE;
gdk_display_keyboard_ungrab (gdk_display, time);
}
gimp_display_shell_space_released (shell, state, time);
break;
case 2:
......@@ -1163,9 +1212,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
kevent,
display))
{
GimpController *keyboard;
keyboard = gimp_controllers_get_keyboard (gimp);
GimpController *keyboard = gimp_controllers_get_keyboard (gimp);
if (keyboard)
gimp_controller_keyboard_key_press (GIMP_CONTROLLER_KEYBOARD (keyboard),
......@@ -1176,39 +1223,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
break;
case GDK_space:
{
active_tool = tool_manager_get_active (gimp);
if (active_tool &&
! shell->space_pressed && ! GIMP_IS_MOVE_TOOL (active_tool))
{
GimpToolInfo *move_tool_info;
move_tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-move-tool");
if (GIMP_IS_TOOL_INFO (move_tool_info))
{
#ifdef DEBUG_MOVE_PUSH
g_printerr ("%s: pushing move tool\n", G_STRFUNC);
#endif
space_shaded_tool = active_tool->tool_info;
gdk_keyboard_grab (canvas->window, FALSE, time);
gimp_context_set_tool (gimp_get_user_context (gimp),
move_tool_info);
tool_manager_focus_display_active (gimp, display);
tool_manager_modifier_state_active (gimp, state, display);
shell->space_pressed = TRUE;
}
}
}
gimp_display_shell_space_pressed (shell, state, time);
return_val = TRUE;
break;
......@@ -1271,24 +1286,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
switch (kevent->keyval)
{
case GDK_space:
if (shell->space_pressed)
{
#ifdef DEBUG_MOVE_PUSH
g_printerr ("%s: popping move tool\n", G_STRFUNC);
#endif
gimp_context_set_tool (gimp_get_user_context (gimp),
space_shaded_tool);
space_shaded_tool = NULL;
tool_manager_focus_display_active (gimp, display);
tool_manager_modifier_state_active (gimp, state, display);
shell->space_pressed = FALSE;
gdk_display_keyboard_ungrab (gdk_display, time);
}
gimp_display_shell_space_released (shell, state, time);
return_val = TRUE;
break;
......@@ -1398,8 +1396,7 @@ gimp_display_shell_ruler_button_press (GtkWidget *widget,
{
GimpToolInfo *tool_info;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (display->image->gimp->tool_info_list,
tool_info = gimp_get_tool_info (display->image->gimp,
sample_point ?
"gimp-color-picker-tool" :
"gimp-move-tool");
......
......@@ -290,6 +290,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->space_pressed = FALSE;
shell->space_release_pending = FALSE;
shell->space_shaded_tool = NULL;
shell->scrolling = FALSE;
shell->scroll_start_x = 0;
shell->scroll_start_y = 0;
......
......@@ -161,6 +161,7 @@ struct _GimpDisplayShell
/* the state of gimp_display_shell_tool_events() */
gboolean space_pressed;
gboolean space_release_pending;
const gchar *space_shaded_tool;
gboolean scrolling;
gint scroll_start_x;
gint scroll_start_y;
......
......@@ -24,7 +24,6 @@
#include "tools-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimppaintinfo.h"
......@@ -464,13 +463,7 @@ gimp_paint_tool_modifier_key (GimpTool *tool,
{
if (press)
{
GimpContainer *tool_info_list;
GimpToolInfo *info;
tool_info_list = display->image->gimp->tool_info_list;
info = (GimpToolInfo *)
gimp_container_get_child_by_name (tool_info_list,
GimpToolInfo *info = gimp_get_tool_info (display->image->gimp,
"gimp-color-picker-tool");
if (GIMP_IS_TOOL_INFO (info))
......
......@@ -39,8 +39,6 @@
#include "gimptoolcontrol.h"
#include "tool_manager.h"
#include "gimp-intl.h"
typedef struct _GimpToolManager GimpToolManager;
......@@ -504,7 +502,8 @@ tool_manager_tool_changed (GimpContext *user_context,
{
GimpToolInfo *old_tool_info = tool_manager->active_tool->tool_info;
gimp_context_set_parent (GIMP_CONTEXT (old_tool_info->tool_options), NULL);
gimp_context_set_parent (GIMP_CONTEXT (old_tool_info->tool_options),
NULL);
}
/* connect the new tool's context */
......@@ -551,9 +550,7 @@ tool_manager_image_clean_dirty (GimpImage *image,
! gimp_tool_control_get_preserve (tool->control) &&
(gimp_tool_control_get_dirty_mask (tool->control) & dirty_mask))
{
GimpDisplay *display;
display = gimp_tool_has_image (tool, image);
GimpDisplay *display = gimp_tool_has_image (tool, image);
if (display)
tool_manager_control_active (image->gimp, GIMP_TOOL_ACTION_HALT,
......
......@@ -26,7 +26,6 @@
#include "widgets-types.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-bucket-fill.h"
......@@ -330,13 +329,9 @@ gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
if (item)
{
GimpDrawable *drawable = GIMP_DRAWABLE (item);
GimpToolInfo *tool_info;
GimpContext *context;
/* Get the bucket fill context */
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (view->image->gimp->tool_info_list,
GimpContext *context;
GimpToolInfo *tool_info = gimp_get_tool_info (view->image->gimp,
"gimp-bucket-fill-tool");
if (tool_info && tool_info->tool_options)
......@@ -344,7 +339,7 @@ gimp_drawable_tree_view_new_dropped (GimpItemTreeView *view,
else
context = gimp_container_view_get_context (GIMP_CONTAINER_VIEW (view));
gimp_drawable_bucket_fill_full (drawable,
gimp_drawable_bucket_fill_full (GIMP_DRAWABLE (item),
fill_mode,
gimp_context_get_paint_mode (context),
gimp_context_get_opacity (context),
......
......@@ -265,8 +265,7 @@ gimp_selection_view_button_press (GtkWidget *widget,
renderer = GIMP_VIEW (editor->view)->renderer;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (image_editor->image->gimp->tool_info_list,
tool_info = gimp_get_tool_info (image_editor->image->gimp,
"gimp-by-color-select-tool");
if (! tool_info)
......@@ -337,10 +336,8 @@ gimp_selection_editor_drop_color (GtkWidget *widget,
if (! editor->image)
return;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (editor->image->gimp->tool_info_list,
tool_info = gimp_get_tool_info (editor->image->gimp,
"gimp-by-color-select-tool");
if (! tool_info)
return;
......
......@@ -335,9 +335,7 @@ gimp_toolbox_size_allocate (GtkWidget *widget,
config = GIMP_GUI_CONFIG (gimp->config);
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-rect-select-tool");
tool_info = gimp_get_tool_info (gimp, "gimp-rect-select-tool");
tool_button = g_object_get_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY);
if (tool_button)
......@@ -501,9 +499,7 @@ gimp_toolbox_set_geometry (GimpToolbox *toolbox)
gimp = GIMP_DOCK (toolbox)->context->gimp;
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-rect-select-tool");
tool_info = gimp_get_tool_info (gimp, "gimp-rect-select-tool");
tool_button = g_object_get_data (G_OBJECT (tool_info), TOOL_BUTTON_DATA_KEY);
if (tool_button)
......
......@@ -323,7 +323,6 @@ app/tools/gimptransformoptions.c
app/tools/gimptransformtool.c
app/tools/gimpvectoroptions.c
app/tools/gimpvectortool.c
app/tools/tool_manager.c
app/tools/tools-enums.c
app/vectors/gimpvectors.c
......
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