[gimp] app: add gimp_display_shell_selection_pause() and _resume()



commit 545e65dda6a25f9042d3820ba5d13accfad52207
Author: Michael Natterer <mitch gimp org>
Date:   Sat Oct 9 14:26:33 2010 +0200

    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 2b271a1..1a0500c 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 6fa4cba..6394f1c 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 ac333ef..649c63e 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 72533a8..271b0d2 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)
@@ -180,6 +169,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)
 {
@@ -227,24 +244,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)
 {
   if (selection->segs_in)
diff --git a/app/display/gimpdisplayshell-selection.h b/app/display/gimpdisplayshell-selection.h
index f1bcb35..235293a 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 1bdbdae..bf9abef 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 b1cfbfc..7241319 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 d38ee28..b03321a 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 23e6266..81c4db9 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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]