[gimp] app: add gimp_draw_tool_set_default_status()



commit 8b3be42e42bf0d8a23be2eec1a86223e5260754a
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 26 21:47:54 2017 +0200

    app: add gimp_draw_tool_set_default_status()
    
    which sets a statusbar message to be used if there is no widget set,
    or when hovering another display.

 app/tools/gimpdrawtool.c |   23 +++++++++++++++++++++++
 app/tools/gimpdrawtool.h |    3 +++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index c334c50..5addfe5 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -161,6 +161,9 @@ gimp_draw_tool_dispose (GObject *object)
       draw_tool->draw_timeout = 0;
     }
 
+  gimp_draw_tool_set_widget (draw_tool, NULL);
+  gimp_draw_tool_set_default_status (draw_tool, NULL);
+
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -301,6 +304,14 @@ gimp_draw_tool_oper_update (GimpTool         *tool,
     {
       gimp_tool_widget_hover (draw_tool->widget, coords, state, proximity);
     }
+  else if (proximity && draw_tool->default_status)
+    {
+      gimp_tool_replace_status (tool, display, "%s", draw_tool->default_status);
+    }
+  else if (! proximity)
+    {
+      gimp_tool_pop_status (tool, display);
+    }
   else
     {
       GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state,
@@ -669,6 +680,18 @@ gimp_draw_tool_set_widget (GimpDrawTool   *draw_tool,
 }
 
 void
+gimp_draw_tool_set_default_status (GimpDrawTool *draw_tool,
+                                   const gchar  *status)
+{
+  g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
+
+  if (draw_tool->default_status)
+    g_free (draw_tool->default_status);
+
+  draw_tool->default_status = g_strdup (status);
+}
+
+void
 gimp_draw_tool_add_preview (GimpDrawTool   *draw_tool,
                             GimpCanvasItem *item)
 {
diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h
index aa8fa01..726531e 100644
--- a/app/tools/gimpdrawtool.h
+++ b/app/tools/gimpdrawtool.h
@@ -52,6 +52,7 @@ struct _GimpDrawTool
   guint64         last_draw_time; /*  time of last draw(), monotonically      */
 
   GimpToolWidget *widget;
+  gchar          *default_status;
   GimpCanvasItem *preview;
   GimpCanvasItem *item;
   GList          *group_stack;
@@ -93,6 +94,8 @@ gdouble          gimp_draw_tool_calc_distance_square (GimpDrawTool     *draw_too
 
 void             gimp_draw_tool_set_widget           (GimpDrawTool     *draw_tool,
                                                       GimpToolWidget   *widget);
+void             gimp_draw_tool_set_default_status   (GimpDrawTool     *draw_tool,
+                                                      const gchar      *status);
 
 void             gimp_draw_tool_add_preview          (GimpDrawTool     *draw_tool,
                                                       GimpCanvasItem   *item);


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