[gimp] app: add a read-only "buffer" property to GimpPickableInterface



commit a4dd86fcdabeec988a62d219f47e4cf6e7bea589
Author: Michael Natterer <mitch gimp org>
Date:   Thu Sep 5 10:37:09 2013 +0200

    app: add a read-only "buffer" property to GimpPickableInterface
    
    and implement it in GimpDrawable and GimpProjection. Will need this
    later.

 app/core/gimpdrawable.c   |   14 ++++++++++-
 app/core/gimppickable.c   |   22 +++++++++++++++++-
 app/core/gimpprojection.c |   55 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 89 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index ef55cc3..61c7d93 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -65,7 +65,8 @@ enum
 
 enum
 {
-  PROP_0
+  PROP_0,
+  PROP_BUFFER
 };
 
 
@@ -266,6 +267,8 @@ gimp_drawable_class_init (GimpDrawableClass *klass)
   klass->push_undo                   = gimp_drawable_real_push_undo;
   klass->swap_pixels                 = gimp_drawable_real_swap_pixels;
 
+  g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
+
   g_type_class_add_private (klass, sizeof (GimpDrawablePrivate));
 }
 
@@ -338,6 +341,7 @@ gimp_drawable_set_property (GObject      *object,
 {
   switch (property_id)
     {
+    case PROP_BUFFER:
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -350,8 +354,14 @@ gimp_drawable_get_property (GObject    *object,
                             GValue     *value,
                             GParamSpec *pspec)
 {
+  GimpDrawable *drawable = GIMP_DRAWABLE (object);
+
   switch (property_id)
     {
+    case PROP_BUFFER:
+      g_value_set_object (value, drawable->private->buffer);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -835,6 +845,8 @@ gimp_drawable_real_set_buffer (GimpDrawable *drawable,
     gegl_node_set (drawable->private->buffer_source_node,
                    "buffer", gimp_drawable_get_buffer (drawable),
                    NULL);
+
+  g_object_notify (G_OBJECT (drawable), "buffer");
 }
 
 static void
diff --git a/app/core/gimppickable.c b/app/core/gimppickable.c
index 3e83b35..392b097 100644
--- a/app/core/gimppickable.c
+++ b/app/core/gimppickable.c
@@ -39,6 +39,9 @@
 #include "gimppickable.h"
 
 
+static void   gimp_pickable_interface_base_init (GimpPickableInterface *iface);
+
+
 GType
 gimp_pickable_interface_get_type (void)
 {
@@ -49,7 +52,7 @@ gimp_pickable_interface_get_type (void)
       const GTypeInfo pickable_iface_info =
       {
         sizeof (GimpPickableInterface),
-        (GBaseInitFunc)     NULL,
+        (GBaseInitFunc)     gimp_pickable_interface_base_init,
         (GBaseFinalizeFunc) NULL,
       };
 
@@ -64,6 +67,23 @@ gimp_pickable_interface_get_type (void)
   return pickable_iface_type;
 }
 
+static void
+gimp_pickable_interface_base_init (GimpPickableInterface *iface)
+{
+  static gboolean initialized = FALSE;
+
+  if (! initialized)
+    {
+      g_object_interface_install_property (iface,
+                                           g_param_spec_object ("buffer",
+                                                                NULL, NULL,
+                                                                GEGL_TYPE_BUFFER,
+                                                                GIMP_PARAM_READABLE));
+
+      initialized = TRUE;
+    }
+}
+
 void
 gimp_pickable_flush (GimpPickable *pickable)
 {
diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c
index cfe1907..5b895cc 100644
--- a/app/core/gimpprojection.c
+++ b/app/core/gimpprojection.c
@@ -55,12 +55,26 @@ enum
   LAST_SIGNAL
 };
 
+enum
+{
+  PROP_0,
+  PROP_BUFFER
+};
+
 
 /*  local function prototypes  */
 
 static void   gimp_projection_pickable_iface_init (GimpPickableInterface  *iface);
 
 static void        gimp_projection_finalize              (GObject         *object);
+static void        gimp_projection_set_property          (GObject         *object,
+                                                          guint            property_id,
+                                                          const GValue    *value,
+                                                          GParamSpec      *pspec);
+static void        gimp_projection_get_property          (GObject         *object,
+                                                          guint            property_id,
+                                                          GValue          *value,
+                                                          GParamSpec      *pspec);
 
 static gint64      gimp_projection_get_memsize           (GimpObject      *object,
                                                           gint64          *gui_size);
@@ -142,8 +156,12 @@ gimp_projection_class_init (GimpProjectionClass *klass)
                   G_TYPE_INT);
 
   object_class->finalize         = gimp_projection_finalize;
+  object_class->set_property     = gimp_projection_set_property;
+  object_class->get_property     = gimp_projection_get_property;
 
   gimp_object_class->get_memsize = gimp_projection_get_memsize;
+
+  g_object_class_override_property (object_class, PROP_BUFFER, "buffer");
 }
 
 static void
@@ -182,6 +200,41 @@ gimp_projection_finalize (GObject *object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static void
+gimp_projection_set_property (GObject      *object,
+                              guint         property_id,
+                              const GValue *value,
+                              GParamSpec   *pspec)
+{
+  switch (property_id)
+    {
+    case PROP_BUFFER:
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_projection_get_property (GObject    *object,
+                              guint       property_id,
+                              GValue     *value,
+                              GParamSpec *pspec)
+{
+  GimpProjection *projection = GIMP_PROJECTION (object);
+
+  switch (property_id)
+    {
+    case PROP_BUFFER:
+      g_value_set_object (value, projection->buffer);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
 static gint64
 gimp_projection_get_memsize (GimpObject *object,
                              gint64     *gui_size)
@@ -298,6 +351,8 @@ gimp_projection_get_buffer (GimpPickable *pickable)
       gimp_projection_add_update_area (proj, 0, 0, width, height);
       proj->invalidate_preview = TRUE;
       gimp_projection_flush (proj);
+
+      g_object_notify (G_OBJECT (pickable), "buffer");
     }
 
   return proj->buffer;


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