[gimp] app: add signal GimpToolWidget::status() and API to emit it



commit e05ba83453bb402be8bbf1daf7b2ef6955c4efdf
Author: Michael Natterer <mitch gimp org>
Date:   Sun Jun 11 23:18:47 2017 +0200

    app: add signal GimpToolWidget::status() and API to emit it
    
    for subclasses to set status messages.

 app/display/gimptoolwidget.c |   21 +++++++++++++++++++++
 app/display/gimptoolwidget.h |   11 +++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/app/display/gimptoolwidget.c b/app/display/gimptoolwidget.c
index dfa262e..30a87f4 100644
--- a/app/display/gimptoolwidget.c
+++ b/app/display/gimptoolwidget.c
@@ -42,6 +42,7 @@ enum
 enum
 {
   CHANGED,
+  STATUS,
   LAST_SIGNAL
 };
 
@@ -97,6 +98,16 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
+  widget_signals[STATUS] =
+    g_signal_new ("status",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpToolWidgetClass, status),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__STRING,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_STRING);
+
   g_object_class_install_property (object_class, PROP_SHELL,
                                    g_param_spec_object ("shell",
                                                         NULL, NULL,
@@ -223,6 +234,16 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
 }
 
 void
+gimp_tool_widget_status (GimpToolWidget *widget,
+                         const gchar    *status)
+{
+  g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
+
+  g_signal_emit (widget, widget_signals[STATUS], 0,
+                 status);
+}
+
+void
 gimp_tool_widget_add_item (GimpToolWidget *widget,
                            GimpCanvasItem *item)
 {
diff --git a/app/display/gimptoolwidget.h b/app/display/gimptoolwidget.h
index cc8ad66..d6d7ac4 100644
--- a/app/display/gimptoolwidget.h
+++ b/app/display/gimptoolwidget.h
@@ -48,7 +48,9 @@ struct _GimpToolWidgetClass
   GimpObjectClass  parent_class;
 
   /*  signals  */
-  void     (* changed)        (GimpToolWidget        *widget);
+  void     (* changed)         (GimpToolWidget        *widget);
+  void     (* status)          (GimpToolWidget        *widget,
+                                const gchar           *status);
 
   /*  virtual functions  */
   gboolean (* button_press)    (GimpToolWidget        *widget,
@@ -94,6 +96,11 @@ GType              gimp_tool_widget_get_type         (void) G_GNUC_CONST;
 GimpDisplayShell * gimp_tool_widget_get_shell        (GimpToolWidget  *widget);
 GimpCanvasItem   * gimp_tool_widget_get_item         (GimpToolWidget  *widget);
 
+/*  for subclasses, to add emit status messages
+ */
+void               gimp_tool_widget_status           (GimpToolWidget  *widget,
+                                                      const gchar     *status);
+
 /*  for subclasses, to add and manage their items
  */
 void               gimp_tool_widget_add_item         (GimpToolWidget  *widget,
@@ -108,7 +115,7 @@ void               gimp_tool_widget_push_group       (GimpToolWidget  *widget,
                                                       GimpCanvasGroup *group);
 void               gimp_tool_widget_pop_group        (GimpToolWidget  *widget);
 
-/*  convenience functions to add specific items
+/*  for subclasses, convenience functions to add specific items
  */
 GimpCanvasItem * gimp_tool_widget_add_line   (GimpToolWidget   *widget,
                                               gdouble           x1,


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