[gimp/gimp-2-10] app: add gimp_tool_widget_message[_literal]()



commit 38c74c2809df94af7906260483b321c9eeba77ed
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 13 03:28:39 2019 -0500

    app: add gimp_tool_widget_message[_literal]()
    
    Add a GimpToolWidget::message signal, which can be emitted by tool
    widgets to display a message, instead of using the ::status signal.
    
    Add corresponding gimp_tool_widget_message[_literal]() functions.
    
    (cherry picked from commit 1ac4b85ce058f2a50462517b2012673601752f17)

 app/display/gimptoolwidget.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
 app/display/gimptoolwidget.h |  8 ++++++++
 2 files changed, 54 insertions(+)
---
diff --git a/app/display/gimptoolwidget.c b/app/display/gimptoolwidget.c
index d54c5dd2a3..c3cb74e2e3 100644
--- a/app/display/gimptoolwidget.c
+++ b/app/display/gimptoolwidget.c
@@ -20,6 +20,8 @@
 
 #include "config.h"
 
+#include <stdarg.h>
+
 #include <gegl.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
@@ -56,6 +58,7 @@ enum
   SNAP_OFFSETS,
   STATUS,
   STATUS_COORDS,
+  MESSAGE,
   FOCUS_CHANGED,
   LAST_SIGNAL
 };
@@ -173,6 +176,16 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
                   G_TYPE_DOUBLE,
                   G_TYPE_STRING);
 
+  widget_signals[MESSAGE] =
+    g_signal_new ("message",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpToolWidgetClass, message),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__STRING,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_STRING);
+
   widget_signals[FOCUS_CHANGED] =
     g_signal_new ("focus-changed",
                   G_TYPE_FROM_CLASS (klass),
@@ -449,6 +462,39 @@ gimp_tool_widget_set_status_coords (GimpToolWidget *widget,
                  title, x, separator, y, help);
 }
 
+void
+gimp_tool_widget_message (GimpToolWidget *widget,
+                          const gchar    *format,
+                          ...)
+{
+  va_list  args;
+  gchar   *message;
+
+  g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
+  g_return_if_fail (format != NULL);
+
+  va_start (args, format);
+
+  message = g_strdup_vprintf (format, args);
+
+  va_end (args);
+
+  gimp_tool_widget_message_literal (widget, message);
+
+  g_free (message);
+}
+
+void
+gimp_tool_widget_message_literal (GimpToolWidget *widget,
+                                  const gchar    *message)
+{
+  g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
+  g_return_if_fail (message != NULL);
+
+  g_signal_emit (widget, widget_signals[MESSAGE], 0,
+                 message);
+}
+
 void
 gimp_tool_widget_add_item (GimpToolWidget *widget,
                            GimpCanvasItem *item)
diff --git a/app/display/gimptoolwidget.h b/app/display/gimptoolwidget.h
index 68437ee64a..d72a672ef8 100644
--- a/app/display/gimptoolwidget.h
+++ b/app/display/gimptoolwidget.h
@@ -69,6 +69,8 @@ struct _GimpToolWidgetClass
                                 const gchar           *separator,
                                 gdouble                y,
                                 const gchar           *help);
+  void     (* message)         (GimpToolWidget        *widget,
+                                const gchar           *message);
   void     (* focus_changed)   (GimpToolWidget        *widget);
 
   /*  virtual functions  */
@@ -156,6 +158,12 @@ void               gimp_tool_widget_set_status_coords (GimpToolWidget  *widget,
                                                        gdouble          y,
                                                        const gchar     *help);
 
+void               gimp_tool_widget_message           (GimpToolWidget  *widget,
+                                                       const gchar     *format,
+                                                       ...) G_GNUC_PRINTF (2, 3);
+void               gimp_tool_widget_message_literal   (GimpToolWidget  *widget,
+                                                       const gchar     *message);
+
 /*  for subclasses, to add and manage their items
  */
 void               gimp_tool_widget_add_item         (GimpToolWidget  *widget,


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