From 545e65dda6a25f9042d3820ba5d13accfad52207 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 9 Oct 2010 14:26:33 +0200 Subject: [PATCH] app: add gimp_display_shell_selection_pause() and _resume() and use them instead of gimp_display_shell_selection_control() with the resp. enum values. Remove the GIMP_SELECTION_PAUSE and _RESUME enums values and thus the presence of this concept in the core. --- app/core/core-enums.c | 4 -- app/core/core-enums.h | 4 +- app/display/gimpdisplayshell-handlers.c | 4 +- app/display/gimpdisplayshell-selection.c | 57 ++++++++++++------------ app/display/gimpdisplayshell-selection.h | 3 ++ app/tools/gimpcolortool.c | 9 ++-- app/tools/gimpeditselectiontool.c | 4 +- app/tools/gimpmovetool.c | 10 ++--- app/tools/gimppainttool.c | 4 +- 9 files changed, 46 insertions(+), 53 deletions(-) diff --git a/app/core/core-enums.c b/app/core/core-enums.c index 2b271a1d0d..1a0500c958 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -645,8 +645,6 @@ gimp_selection_control_get_type (void) { { GIMP_SELECTION_OFF, "GIMP_SELECTION_OFF", "off" }, { GIMP_SELECTION_ON, "GIMP_SELECTION_ON", "on" }, - { GIMP_SELECTION_PAUSE, "GIMP_SELECTION_PAUSE", "pause" }, - { GIMP_SELECTION_RESUME, "GIMP_SELECTION_RESUME", "resume" }, { 0, NULL, NULL } }; @@ -654,8 +652,6 @@ gimp_selection_control_get_type (void) { { GIMP_SELECTION_OFF, "GIMP_SELECTION_OFF", NULL }, { GIMP_SELECTION_ON, "GIMP_SELECTION_ON", NULL }, - { GIMP_SELECTION_PAUSE, "GIMP_SELECTION_PAUSE", NULL }, - { GIMP_SELECTION_RESUME, "GIMP_SELECTION_RESUME", NULL }, { 0, NULL, NULL } }; diff --git a/app/core/core-enums.h b/app/core/core-enums.h index 6fa4cba560..6394f1c2e8 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -297,9 +297,7 @@ GType gimp_selection_control_get_type (void) G_GNUC_CONST; typedef enum /*< pdb-skip >*/ { GIMP_SELECTION_OFF, - GIMP_SELECTION_ON, - GIMP_SELECTION_PAUSE, - GIMP_SELECTION_RESUME + GIMP_SELECTION_ON } GimpSelectionControl; diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index ac333ef61f..649c63e54c 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -1044,8 +1044,8 @@ gimp_display_shell_ants_speed_notify_handler (GObject *config, GParamSpec *param_spec, GimpDisplayShell *shell) { - gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE); - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_pause (shell); + gimp_display_shell_selection_resume (shell); } static void diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 72533a88c6..271b0d2543 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -65,9 +65,6 @@ struct _Selection static void selection_start (Selection *selection); static void selection_stop (Selection *selection); -static void selection_pause (Selection *selection); -static void selection_resume (Selection *selection); - static void selection_draw (Selection *selection); static void selection_undraw (Selection *selection); @@ -162,14 +159,6 @@ gimp_display_shell_selection_control (GimpDisplayShell *shell, case GIMP_SELECTION_ON: selection_start (selection); break; - - case GIMP_SELECTION_PAUSE: - selection_pause (selection); - break; - - case GIMP_SELECTION_RESUME: - selection_resume (selection); - break; } } else if (shell->selection) @@ -179,6 +168,34 @@ gimp_display_shell_selection_control (GimpDisplayShell *shell, } } +void +gimp_display_shell_selection_pause (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + if (shell->selection && gimp_display_get_image (shell->display)) + { + if (shell->selection->paused == 0) + selection_stop (shell->selection); + + shell->selection->paused++; + } +} + +void +gimp_display_shell_selection_resume (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + if (shell->selection && gimp_display_get_image (shell->display)) + { + shell->selection->paused--; + + if (shell->selection->paused == 0) + selection_start (shell->selection); + } +} + void gimp_display_shell_selection_set_show (GimpDisplayShell *shell, gboolean show) @@ -226,24 +243,6 @@ selection_stop (Selection *selection) } } -static void -selection_pause (Selection *selection) -{ - if (selection->paused == 0) - selection_stop (selection); - - selection->paused++; -} - -static void -selection_resume (Selection *selection) -{ - selection->paused--; - - if (selection->paused == 0) - selection_start (selection); -} - static void selection_draw (Selection *selection) { diff --git a/app/display/gimpdisplayshell-selection.h b/app/display/gimpdisplayshell-selection.h index f1bcb35185..235293a57a 100644 --- a/app/display/gimpdisplayshell-selection.h +++ b/app/display/gimpdisplayshell-selection.h @@ -25,6 +25,9 @@ void gimp_display_shell_selection_free (GimpDisplayShell *shell); void gimp_display_shell_selection_control (GimpDisplayShell *shell, GimpSelectionControl control); +void gimp_display_shell_selection_pause (GimpDisplayShell *shell); +void gimp_display_shell_selection_resume (GimpDisplayShell *shell); + void gimp_display_shell_selection_set_show (GimpDisplayShell *shell, gboolean show); diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c index 1bdbdae90c..bf9abef763 100644 --- a/app/tools/gimpcolortool.c +++ b/app/tools/gimpcolortool.c @@ -219,7 +219,7 @@ gimp_color_tool_button_press (GimpTool *tool, gimp_tool_control_set_scroll_lock (tool->control, TRUE); - gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (shell); gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display); @@ -277,7 +277,7 @@ gimp_color_tool_button_release (GimpTool *tool, color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID; color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID; - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); return; } @@ -315,7 +315,7 @@ gimp_color_tool_button_release (GimpTool *tool, } } - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); gimp_image_flush (image); color_tool->moving_sample_point = FALSE; @@ -784,8 +784,7 @@ gimp_color_tool_start_sample_point (GimpTool *tool, color_tool = GIMP_COLOR_TOOL (tool); - gimp_display_shell_selection_control (gimp_display_get_shell (display), - GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (gimp_display_get_shell (display)); tool->display = display; gimp_tool_control_activate (tool->control); diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index b1cfbfcad9..72413193c3 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -445,7 +445,7 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool, tool_manager_push_tool (display->gimp, tool); /* pause the current selection */ - gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (shell); /* initialize the statusbar display */ gimp_tool_push_status_coords (tool, display, @@ -470,7 +470,7 @@ gimp_edit_selection_tool_button_release (GimpTool *tool, GimpItem *active_item; /* resume the current selection */ - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); gimp_tool_pop_status (tool, display); diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index d38ee2870e..b03321a004 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -239,8 +239,7 @@ gimp_move_tool_button_press (GimpTool *tool, gimp_tool_control_activate (tool->control); - gimp_display_shell_selection_control (shell, - GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (shell); gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display); @@ -352,7 +351,7 @@ gimp_move_tool_button_release (GimpTool *tool, move->guide_position = GUIDE_POSITION_INVALID; move->guide_orientation = GIMP_ORIENTATION_UNKNOWN; - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); return; } @@ -413,7 +412,7 @@ gimp_move_tool_button_release (GimpTool *tool, } } - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); gimp_image_flush (image); move->moving_guide = FALSE; @@ -802,8 +801,7 @@ gimp_move_tool_start_guide (GimpMoveTool *move, { GimpTool *tool = GIMP_TOOL (move); - gimp_display_shell_selection_control (gimp_display_get_shell (display), - GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (gimp_display_get_shell (display)); tool->display = display; gimp_tool_control_activate (tool->control); diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index 23e6266256..81c4db9ab4 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -346,7 +346,7 @@ gimp_paint_tool_button_press (GimpTool *tool, press_type, display); /* pause the current selection */ - gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE); + gimp_display_shell_selection_pause (shell); /* Let the specific painting function initialize itself */ gimp_paint_core_paint (core, drawable, paint_options, @@ -400,7 +400,7 @@ gimp_paint_tool_button_release (GimpTool *tool, GIMP_PAINT_STATE_FINISH, time); /* resume the current selection */ - gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); + gimp_display_shell_selection_resume (shell); /* chain up to halt the tool */ GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,