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



commit 013bb4d81f99a5f31f2ffd2699060b2e73d057aa
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jun 13 23:17:30 2017 +0200

    app: add signal GimpToolWidget::snap_offsets() and API to emit it
    
    so widgets can notify their handling tool of snap offsets.

 app/display/gimptoolwidget.c |   29 +++++++++++++++++++++++++++++
 app/display/gimptoolwidget.h |   12 +++++++++++-
 2 files changed, 40 insertions(+), 1 deletions(-)
---
diff --git a/app/display/gimptoolwidget.c b/app/display/gimptoolwidget.c
index 6cb9fe6..fd6fbe4 100644
--- a/app/display/gimptoolwidget.c
+++ b/app/display/gimptoolwidget.c
@@ -25,6 +25,8 @@
 
 #include "display-types.h"
 
+#include "core/gimpmarshal.h"
+
 #include "gimpcanvasgroup.h"
 #include "gimpcanvashandle.h"
 #include "gimpcanvasline.h"
@@ -43,6 +45,7 @@ enum
 enum
 {
   CHANGED,
+  SNAP_OFFSETS,
   STATUS,
   LAST_SIGNAL
 };
@@ -99,6 +102,19 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
+  widget_signals[SNAP_OFFSETS] =
+    g_signal_new ("snap-offsets",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpToolWidgetClass, snap_offsets),
+                  NULL, NULL,
+                  gimp_marshal_VOID__INT_INT_INT_INT,
+                  G_TYPE_NONE, 4,
+                  G_TYPE_INT,
+                  G_TYPE_INT,
+                  G_TYPE_INT,
+                  G_TYPE_INT);
+
   widget_signals[STATUS] =
     g_signal_new ("status",
                   G_TYPE_FROM_CLASS (klass),
@@ -235,6 +251,19 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
 }
 
 void
+gimp_tool_widget_snap_offsets (GimpToolWidget *widget,
+                               gint            offset_x,
+                               gint            offset_y,
+                               gint            width,
+                               gint            height)
+{
+  g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
+
+  g_signal_emit (widget, widget_signals[SNAP_OFFSETS], 0,
+                 offset_x, offset_y, width, height);
+}
+
+void
 gimp_tool_widget_status (GimpToolWidget *widget,
                          const gchar    *status)
 {
diff --git a/app/display/gimptoolwidget.h b/app/display/gimptoolwidget.h
index b93d9ed..31f1ba0 100644
--- a/app/display/gimptoolwidget.h
+++ b/app/display/gimptoolwidget.h
@@ -49,6 +49,11 @@ struct _GimpToolWidgetClass
 
   /*  signals  */
   void     (* changed)         (GimpToolWidget        *widget);
+  void     (* snap_offsets)    (GimpToolWidget        *widget,
+                                gint                   offset_x,
+                                gint                   offset_y,
+                                gint                   width,
+                                gint                   height);
   void     (* status)          (GimpToolWidget        *widget,
                                 const gchar           *status);
 
@@ -96,8 +101,13 @@ 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
+/*  for subclasses, to notify the handling tool
  */
+void               gimp_tool_widget_snap_offsets     (GimpToolWidget  *widget,
+                                                      gint             offset_x,
+                                                      gint             offset_y,
+                                                      gint             width,
+                                                      gint             height);
 void               gimp_tool_widget_status           (GimpToolWidget  *widget,
                                                       const gchar     *status);
 


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