[gimp] app: add back the draw timeout



commit 11bc11d2f70467e47bf2de4d4bdbb89daffbb3a2
Author: Michael Natterer <mitch gimp org>
Date:   Mon Oct 11 22:27:32 2010 +0200

    app: add back the draw timeout

 app/tools/gimpdrawtool.c |   49 +++++++++++++++++++++++++++++++++++++++++++++-
 app/tools/gimpdrawtool.h |    1 +
 2 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 7e0aeee..915771b 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -55,6 +55,10 @@
 #include "gimpdrawtool.h"
 
 
+#define DRAW_TIMEOUT 4
+#define USE_TIMEOUT  1
+
+
 static void          gimp_draw_tool_dispose      (GObject        *object);
 
 static gboolean      gimp_draw_tool_has_display  (GimpTool       *tool,
@@ -118,6 +122,14 @@ gimp_draw_tool_init (GimpDrawTool *draw_tool)
 static void
 gimp_draw_tool_dispose (GObject *object)
 {
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (object);
+
+  if (draw_tool->draw_timeout)
+    {
+      g_source_remove (draw_tool->draw_timeout);
+      draw_tool->draw_timeout = 0;
+    }
+
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -174,10 +186,24 @@ gimp_draw_tool_control (GimpTool       *tool,
   GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
 }
 
+#ifdef USE_TIMEOUT
+static gboolean
+gimp_draw_tool_draw_timeout (GimpDrawTool *draw_tool)
+{
+  draw_tool->draw_timeout = 0;
+
+  gimp_draw_tool_draw (draw_tool);
+
+  return FALSE;
+}
+#endif
+
 static void
 gimp_draw_tool_draw (GimpDrawTool *draw_tool)
 {
-  if (draw_tool->display && draw_tool->paused_count == 0)
+  if (draw_tool->display &&
+      draw_tool->paused_count == 0 &&
+      ! draw_tool->draw_timeout)
     {
       gimp_draw_tool_undraw (draw_tool);
 
@@ -243,6 +269,12 @@ gimp_draw_tool_stop (GimpDrawTool *draw_tool)
 
   gimp_draw_tool_undraw (draw_tool);
 
+  if (draw_tool->draw_timeout)
+    {
+      g_source_remove (draw_tool->draw_timeout);
+      draw_tool->draw_timeout = 0;
+    }
+
   draw_tool->display = NULL;
 }
 
@@ -260,6 +292,12 @@ gimp_draw_tool_pause (GimpDrawTool *draw_tool)
   g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
 
   draw_tool->paused_count++;
+
+  if (draw_tool->draw_timeout)
+    {
+      g_source_remove (draw_tool->draw_timeout);
+      draw_tool->draw_timeout = 0;
+    }
 }
 
 void
@@ -270,7 +308,16 @@ gimp_draw_tool_resume (GimpDrawTool *draw_tool)
 
   draw_tool->paused_count--;
 
+#ifdef USE_TIMEOUT
+  if (draw_tool->paused_count == 0 && ! draw_tool->draw_timeout)
+    draw_tool->draw_timeout =
+      gdk_threads_add_timeout_full (G_PRIORITY_HIGH_IDLE,
+                                    DRAW_TIMEOUT,
+                                    (GSourceFunc) gimp_draw_tool_draw_timeout,
+                                    draw_tool, NULL);
+#else
   gimp_draw_tool_draw (draw_tool);
+#endif
 }
 
 /**
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index 753acb5..481efc3 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -41,6 +41,7 @@ struct _GimpDrawTool
                                  */
 
   gint            paused_count; /*  count to keep track of multiple pauses  */
+  guint           draw_timeout; /*  draw delay timeout ID                   */
 
   GimpCanvasItem *item;
   GList          *group_stack;



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