[gimp] app: add virtual function GimpTool::options_notify()



commit 9e5eca8fd1c5317b08c5e9d5b061451854a582d1
Author: Michael Natterer <mitch gimp org>
Date:   Wed Nov 10 14:18:33 2010 +0100

    app: add virtual function GimpTool::options_notify()
    
    which gets called on each "notify" from the tool options. This way
    tool can simply implement this method instead of connecting to
    "notify" themselves individually.

 app/tools/gimptool.c |   39 +++++++++++++++++++++++++++++++++++++++
 app/tools/gimptool.h |    4 ++++
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptool.c b/app/tools/gimptool.c
index c9d59b8..e8b19fc 100644
--- a/app/tools/gimptool.c
+++ b/app/tools/gimptool.c
@@ -48,6 +48,7 @@ enum
 };
 
 
+static void       gimp_tool_constructed         (GObject               *object);
 static void       gimp_tool_finalize            (GObject               *object);
 static void       gimp_tool_set_property        (GObject               *object,
                                                  guint                  property_id,
@@ -115,7 +116,13 @@ static GimpUIManager * gimp_tool_real_get_popup (GimpTool              *tool,
                                                  GdkModifierType        state,
                                                  GimpDisplay           *display,
                                                  const gchar          **ui_path);
+static void       gimp_tool_real_options_notify (GimpTool              *tool,
+                                                 GimpToolOptions       *options,
+                                                 const GParamSpec      *pspec);
 
+static void       gimp_tool_options_notify      (GimpToolOptions       *options,
+                                                 const GParamSpec      *pspec,
+                                                 GimpTool              *tool);
 static void       gimp_tool_clear_status        (GimpTool              *tool);
 
 
@@ -131,6 +138,7 @@ gimp_tool_class_init (GimpToolClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  object_class->constructed  = gimp_tool_constructed;
   object_class->finalize     = gimp_tool_finalize;
   object_class->set_property = gimp_tool_set_property;
   object_class->get_property = gimp_tool_get_property;
@@ -149,6 +157,7 @@ gimp_tool_class_init (GimpToolClass *klass)
   klass->oper_update         = gimp_tool_real_oper_update;
   klass->cursor_update       = gimp_tool_real_cursor_update;
   klass->get_popup           = gimp_tool_real_get_popup;
+  klass->options_notify      = gimp_tool_real_options_notify;
 
   g_object_class_install_property (object_class, PROP_TOOL_INFO,
                                    g_param_spec_object ("tool-info",
@@ -174,6 +183,21 @@ gimp_tool_init (GimpTool *tool)
 }
 
 static void
+gimp_tool_constructed (GObject *object)
+{
+  GimpTool *tool = GIMP_TOOL (object);
+
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
+
+  g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
+
+  g_signal_connect_object (gimp_tool_get_options (tool), "notify",
+                           G_CALLBACK (gimp_tool_options_notify),
+                           tool, 0);
+}
+
+static void
 gimp_tool_finalize (GObject *object)
 {
   GimpTool *tool = GIMP_TOOL (object);
@@ -398,6 +422,13 @@ gimp_tool_real_get_popup (GimpTool         *tool,
   return NULL;
 }
 
+static void
+gimp_tool_real_options_notify (GimpTool         *tool,
+                               GimpToolOptions  *options,
+                               const GParamSpec *pspec)
+{
+}
+
 
 /*  public functions  */
 
@@ -1100,6 +1131,14 @@ gimp_tool_set_cursor (GimpTool           *tool,
 /*  private functions  */
 
 static void
+gimp_tool_options_notify (GimpToolOptions  *options,
+                          const GParamSpec *pspec,
+                          GimpTool         *tool)
+{
+  GIMP_TOOL_GET_CLASS (tool)->options_notify (tool, options, pspec);
+}
+
+static void
 gimp_tool_clear_status (GimpTool *tool)
 {
   GList *list;
diff --git a/app/tools/gimptool.h b/app/tools/gimptool.h
index 4b4c594..b7d932b 100644
--- a/app/tools/gimptool.h
+++ b/app/tools/gimptool.h
@@ -137,6 +137,10 @@ struct _GimpToolClass
                                            GdkModifierType        state,
                                            GimpDisplay           *display,
                                            const gchar          **ui_path);
+
+  void            (* options_notify)      (GimpTool              *tool,
+                                           GimpToolOptions       *options,
+                                           const GParamSpec      *pspec);
 };
 
 



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