[clutter] stage-window: Add :backend and :wrapper properties



commit 9c038ebefb88cd052c1dc9448c58d2d5a9a9bfc7
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Nov 4 18:50:46 2011 +0000

    stage-window: Add :backend and :wrapper properties
    
    All StageWindow implementation already have back pointers, but we need a
    unified API to actually set them from the generic code path; we can use
    properties on the StageWindow interface â though this requires fixing
    all backends at the same time, to avoid GObject complaining.

 clutter/clutter-stage-window.c          |   19 +++++++++++++
 clutter/cogl/clutter-stage-cogl.c       |   15 +---------
 clutter/osx/clutter-stage-osx.c         |   46 ++++++++++++++++++++++++++++---
 clutter/wayland/clutter-stage-wayland.c |   37 +++++++++++++++++++++++++
 clutter/win32/clutter-stage-win32.c     |   35 +++++++++++++++++++++++
 5 files changed, 135 insertions(+), 17 deletions(-)
---
diff --git a/clutter/clutter-stage-window.c b/clutter/clutter-stage-window.c
index 7ca171e..1b35103 100644
--- a/clutter/clutter-stage-window.c
+++ b/clutter/clutter-stage-window.c
@@ -15,6 +15,25 @@ G_DEFINE_INTERFACE (ClutterStageWindow, clutter_stage_window, G_TYPE_OBJECT);
 static void
 clutter_stage_window_default_init (ClutterStageWindowInterface *iface)
 {
+  GParamSpec *pspec;
+
+  pspec = g_param_spec_object ("backend",
+                               "Backend",
+                               "Back pointer to the Backend instance",
+                               CLUTTER_TYPE_BACKEND,
+                               G_PARAM_WRITABLE |
+                               G_PARAM_CONSTRUCT_ONLY |
+                               G_PARAM_STATIC_STRINGS);
+  g_object_interface_install_property (iface, pspec);
+
+  pspec = g_param_spec_object ("wrapper",
+                               "Wrapper",
+                               "Back pointer to the Stage actor",
+                               CLUTTER_TYPE_STAGE,
+                               G_PARAM_WRITABLE |
+                               G_PARAM_CONSTRUCT_ONLY |
+                               G_PARAM_STATIC_STRINGS);
+  g_object_interface_install_property (iface, pspec);
 }
 
 ClutterActor *
diff --git a/clutter/cogl/clutter-stage-cogl.c b/clutter/cogl/clutter-stage-cogl.c
index 98af269..87b6035 100644
--- a/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/cogl/clutter-stage-cogl.c
@@ -565,19 +565,8 @@ _clutter_stage_cogl_class_init (ClutterStageCoglClass *klass)
 
   gobject_class->set_property = clutter_stage_cogl_set_property;
 
-  g_object_class_install_property (gobject_class, PROP_WRAPPER,
-				   g_param_spec_object ("wrapper",
-							"Wrapper",
-							"ClutterStage wrapping this native stage",
-							CLUTTER_TYPE_STAGE,
-							CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
-
-  g_object_class_install_property (gobject_class, PROP_BACKEND,
-				   g_param_spec_object ("backend",
-							"ClutterBackend",
-							"The Clutter backend singleton",
-							CLUTTER_TYPE_BACKEND,
-							CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper");
+  g_object_class_override_property (gobject_class, PROP_BACKEND, "backend");
 }
 
 static void
diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c
index f19dbfc..8c56e3d 100644
--- a/clutter/osx/clutter-stage-osx.c
+++ b/clutter/osx/clutter-stage-osx.c
@@ -32,6 +32,14 @@
 
 #import <AppKit/AppKit.h>
 
+enum
+{
+  PROP_0,
+
+  PROP_BACKEND,
+  PROP_WRAPPER
+};
+
 static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
 
 #define clutter_stage_osx_get_type      _clutter_stage_osx_get_type
@@ -608,15 +616,17 @@ _clutter_stage_osx_new (ClutterBackend *backend,
 {
   ClutterStageOSX *self;
 
-  self = g_object_new (CLUTTER_TYPE_STAGE_OSX, NULL);
-  self->backend = backend;
-  self->wrapper = wrapper;
+  self = g_object_new (CLUTTER_TYPE_STAGE_OSX,
+                       "backend", backend,
+                       "wrapper", wrapper,
+                       NULL);
+
   self->isHiding = false;
   self->haveRealized = false;
   self->view = NULL;
   self->window = NULL;
 
-  return CLUTTER_STAGE_WINDOW(self);
+  return CLUTTER_STAGE_WINDOW (self);
 }
 
 /*************************************************************************/
@@ -629,6 +639,30 @@ clutter_stage_osx_init (ClutterStageOSX *self)
 }
 
 static void
+clutter_stage_osx_set_property (GObject      *gobject,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  ClutterStageOSX *self = CLUTTER_STAGE_OSX (gobject);
+
+  switch (prop_id)
+    {
+    case PROP_BACKEND:
+      self->backend = g_value_get_object (value);
+      break;
+
+    case PROP_WRAPPER:
+      self->wrapper = g_value_get_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+      break;
+    }
+}
+
+static void
 clutter_stage_osx_finalize (GObject *gobject)
 {
   G_OBJECT_CLASS (clutter_stage_osx_parent_class)->finalize (gobject);
@@ -645,6 +679,10 @@ clutter_stage_osx_class_init (ClutterStageOSXClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
+  gobject_class->set_property = clutter_stage_osx_set_property;
   gobject_class->finalize = clutter_stage_osx_finalize;
   gobject_class->dispose = clutter_stage_osx_dispose;
+
+  g_object_class_override_property (gobject_class, PROP_BACKEND, "backend");
+  g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper");
 }
diff --git a/clutter/wayland/clutter-stage-wayland.c b/clutter/wayland/clutter-stage-wayland.c
index 4276851..022745a 100644
--- a/clutter/wayland/clutter-stage-wayland.c
+++ b/clutter/wayland/clutter-stage-wayland.c
@@ -58,6 +58,14 @@ wayland_swap_buffers (ClutterStageWayland *stage_wayland);
 
 static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
 
+enum
+{
+  PROP_0,
+
+  PROP_BACKEND,
+  PROP_WRAPPER
+};
+
 G_DEFINE_TYPE_WITH_CODE (ClutterStageWayland,
                          _clutter_stage_wayland,
                          G_TYPE_OBJECT,
@@ -428,8 +436,37 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
 }
 
 static void
+clutter_stage_wayland_set_property (GObject      *gobject,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+  ClutterStageWayland *self = CLUTTER_STAGE_WAYLAND (gobject);
+
+  switch (prop_id)
+    {
+    case PROP_BACKEND:
+      self->backend = g_value_get_object (value);
+      break;
+
+    case PROP_WRAPPER:
+      self->wrapper = g_value_get_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+    }
+}
+
+static void
 _clutter_stage_wayland_class_init (ClutterStageWaylandClass *klass)
 {
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->set_property = clutter_stage_wayland_set_property;
+
+  g_object_class_override_property (gobject_class, PROP_BACKEND, "backend");
+  g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper");
 }
 
 static void
diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c
index f57f73b..e89c817 100644
--- a/clutter/win32/clutter-stage-win32.c
+++ b/clutter/win32/clutter-stage-win32.c
@@ -42,6 +42,14 @@
 
 static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
 
+enum
+{
+  PROP_0,
+
+  PROP_BACKEND,
+  PROP_WRAPPER
+};
+
 G_DEFINE_TYPE_WITH_CODE (ClutterStageWin32,
 			 clutter_stage_win32,
 			 G_TYPE_OBJECT,
@@ -545,6 +553,29 @@ clutter_stage_win32_get_active_framebuffer (ClutterStageWindow *stage_window)
 }
 
 static void
+clutter_stage_win32_set_property (GObject      *gobject,
+                                  guint         prop_id,
+                                  const GValue *value,
+                                  GParamSpec   *pspec)
+{
+  ClutterStageWin32 *self = CLUTTER_STAGE_WIN32 (gobject);
+
+  switch (prop_id)
+    {
+    case PROP_BACKEND:
+      self->backend = g_value_get_object (value);
+      break;
+
+    case PROP_WRAPPER:
+      self->wrapper = g_value_get_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
+    }
+}
+
+static void
 clutter_stage_win32_dispose (GObject *gobject)
 {
   ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (gobject);
@@ -569,7 +600,11 @@ clutter_stage_win32_class_init (ClutterStageWin32Class *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
+  gobject_class->set_property = clutter_stage_win32_set_property;
   gobject_class->dispose = clutter_stage_win32_dispose;
+
+  g_object_class_override_property (gobject_class, PROP_BACKEND, "backend");
+  g_object_class_override_property (gobject_class, PROP_WRAPPER, "wrapper");
 }
 
 static void



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