[gimp] app: add a small delay when applying a GUI change in GimpImageMapTool



commit d46a8335e6b853e3700e22cc5a9711830a80cb9b
Author: Michael Natterer <mitch gimp org>
Date:   Thu May 22 00:50:21 2014 +0200

    app: add a small delay when applying a GUI change in GimpImageMapTool
    
    This keeps the tool more responsive for expensive ops, since multiple
    fast changes are compressed into one call to gimp_image_map_tool_preview().

 app/tools/gimpimagemaptool.c |   34 +++++++++++++++++++++++++++++++++-
 app/tools/gimpimagemaptool.h |    2 ++
 2 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index b16e448..b496ebb 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -602,6 +602,12 @@ gimp_image_map_tool_halt (GimpImageMapTool *im_tool)
   if (im_tool->gui)
     gimp_tool_gui_hide (im_tool->gui);
 
+  if (im_tool->notify_timeout_id)
+    {
+      g_source_remove (im_tool->notify_timeout_id);
+      im_tool->notify_timeout_id = 0;
+    }
+
   if (im_tool->image_map)
     {
       gimp_tool_control_push_preserve (tool->control, TRUE);
@@ -624,6 +630,12 @@ gimp_image_map_tool_commit (GimpImageMapTool *im_tool)
   if (im_tool->gui)
     gimp_tool_gui_hide (im_tool->gui);
 
+  if (im_tool->notify_timeout_id)
+    {
+      g_source_remove (im_tool->notify_timeout_id);
+      im_tool->notify_timeout_id = 0;
+    }
+
   if (im_tool->image_map)
     {
       GimpImageMapOptions *options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
@@ -732,12 +744,26 @@ gimp_image_map_tool_flush (GimpImageMap     *image_map,
   gimp_projection_flush (gimp_image_get_projection (image));
 }
 
+static gboolean
+gimp_image_map_tool_config_notify_timeout (GimpImageMapTool *image_map_tool)
+{
+  gimp_image_map_tool_preview (image_map_tool);
+
+  return FALSE;
+}
+
 static void
 gimp_image_map_tool_config_notify (GObject          *object,
                                    const GParamSpec *pspec,
                                    GimpImageMapTool *image_map_tool)
 {
-  gimp_image_map_tool_preview (image_map_tool);
+  if (image_map_tool->notify_timeout_id)
+    g_source_remove (image_map_tool->notify_timeout_id);
+
+  image_map_tool->notify_timeout_id =
+    g_timeout_add (150,
+                   (GSourceFunc) gimp_image_map_tool_config_notify_timeout,
+                   image_map_tool);
 }
 
 static void
@@ -830,6 +856,12 @@ gimp_image_map_tool_preview (GimpImageMapTool *image_map_tool)
   tool    = GIMP_TOOL (image_map_tool);
   options = GIMP_IMAGE_MAP_TOOL_GET_OPTIONS (tool);
 
+  if (image_map_tool->notify_timeout_id)
+    {
+      g_source_remove (image_map_tool->notify_timeout_id);
+      image_map_tool->notify_timeout_id = 0;
+    }
+
   if (image_map_tool->image_map && options->preview)
     {
       gimp_tool_control_push_preserve (tool->control, TRUE);
diff --git a/app/tools/gimpimagemaptool.h b/app/tools/gimpimagemaptool.h
index 53c37b7..0b9f12f 100644
--- a/app/tools/gimpimagemaptool.h
+++ b/app/tools/gimpimagemaptool.h
@@ -47,6 +47,8 @@ struct _GimpImageMapTool
 
   GimpImageMap          *image_map;
 
+  guint                  notify_timeout_id;
+
   /* dialog */
   gboolean               overlay;
   GimpToolGui           *gui;


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