[clutter/wip/apocalypses/apocalypse-3: 7/35] content: Make vfuncs optional



commit 6da0eb42a588ddddcc5afe38bf48443569ffa4ac
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Sat Feb 4 12:49:49 2012 +0000

    content: Make vfuncs optional
    
    The virtual functions on the ClutterContent interface should provide
    hooks for application code, not be the actual implementation.

 clutter/clutter-content.c |   83 +++++++++++++++++++++++---------------------
 clutter/clutter-content.h |   11 ++----
 2 files changed, 47 insertions(+), 47 deletions(-)
---
diff --git a/clutter/clutter-content.c b/clutter/clutter-content.c
index b1db4a2..2e38516 100644
--- a/clutter/clutter-content.c
+++ b/clutter/clutter-content.c
@@ -70,57 +70,17 @@ static void
 clutter_content_real_attached (ClutterContent *content,
                                ClutterActor   *actor)
 {
-  GObject *obj = G_OBJECT (content);
-  GHashTable *actors;
-
-  actors = g_object_get_qdata (obj, quark_content_actors);
-  if (actors == NULL)
-    {
-      actors = g_hash_table_new (NULL, NULL);
-      g_object_set_qdata_full (obj, quark_content_actors,
-                               actors,
-                               (GDestroyNotify) g_hash_table_unref);
-    }
-
-  g_hash_table_insert (actors, actor, actor);
 }
 
 static void
 clutter_content_real_detached (ClutterContent *content,
                                ClutterActor   *actor)
 {
-  GObject *obj = G_OBJECT (content);
-  GHashTable *actors;
-
-  actors = g_object_get_qdata (obj, quark_content_actors);
-  g_assert (actors != NULL);
-
-  g_hash_table_remove (actors, actor);
-
-  if (g_hash_table_size (actors) == 0)
-    g_object_set_qdata (obj, quark_content_actors, NULL);
 }
 
 static void
 clutter_content_real_invalidate (ClutterContent *content)
 {
-  GHashTable *actors;
-  GHashTableIter iter;
-  gpointer key_p, value_p;
-
-  actors = g_object_get_qdata (G_OBJECT (content), quark_content_actors);
-  if (actors == NULL)
-    return;
-
-  g_hash_table_iter_init (&iter, actors);
-  while (g_hash_table_iter_next (&iter, &key_p, &value_p))
-    {
-      ClutterActor *actor = key_p;
-
-      g_assert (actor != NULL);
-
-      clutter_actor_queue_redraw (actor);
-    }
 }
 
 static void
@@ -157,8 +117,26 @@ clutter_content_default_init (ClutterContentInterface *iface)
 void
 clutter_content_invalidate (ClutterContent *content)
 {
+  GHashTable *actors;
+  GHashTableIter iter;
+  gpointer key_p, value_p;
+
   g_return_if_fail (CLUTTER_IS_CONTENT (content));
 
+  actors = g_object_get_qdata (G_OBJECT (content), quark_content_actors);
+  if (actors == NULL)
+    return;
+
+  g_hash_table_iter_init (&iter, actors);
+  while (g_hash_table_iter_next (&iter, &key_p, &value_p))
+    {
+      ClutterActor *actor = key_p;
+
+      g_assert (actor != NULL);
+
+      clutter_actor_queue_redraw (actor);
+    }
+
   CLUTTER_CONTENT_GET_IFACE (content)->invalidate (content);
 }
 
@@ -180,6 +158,20 @@ void
 _clutter_content_attached (ClutterContent *content,
                            ClutterActor   *actor)
 {
+  GObject *obj = G_OBJECT (content);
+  GHashTable *actors;
+
+  actors = g_object_get_qdata (obj, quark_content_actors);
+  if (actors == NULL)
+    {
+      actors = g_hash_table_new (NULL, NULL);
+      g_object_set_qdata_full (obj, quark_content_actors,
+                               actors,
+                               (GDestroyNotify) g_hash_table_unref);
+    }
+
+  g_hash_table_insert (actors, actor, actor);
+
   CLUTTER_CONTENT_GET_IFACE (content)->attached (content, actor);
 }
 
@@ -200,6 +192,17 @@ void
 _clutter_content_detached (ClutterContent *content,
                            ClutterActor   *actor)
 {
+  GObject *obj = G_OBJECT (content);
+  GHashTable *actors;
+
+  actors = g_object_get_qdata (obj, quark_content_actors);
+  g_assert (actors != NULL);
+
+  g_hash_table_remove (actors, actor);
+
+  if (g_hash_table_size (actors) == 0)
+    g_object_set_qdata (obj, quark_content_actors, NULL);
+
   CLUTTER_CONTENT_GET_IFACE (content)->detached (content, actor);
 }
 
diff --git a/clutter/clutter-content.h b/clutter/clutter-content.h
index 0f91fa2..2a5b01e 100644
--- a/clutter/clutter-content.h
+++ b/clutter/clutter-content.h
@@ -3,7 +3,7 @@
  *
  * An OpenGL based 'interactive canvas' library.
  *
- * Copyright (C) 2011  Intel Corporation.
+ * Copyright (C) 2012  Intel Corporation.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -56,14 +56,11 @@ typedef struct _ClutterContentIface     ClutterContentIface;
  * @paint_content: virtual function; called each time the content needs to
  *   paint itself
  * @attached: virtual function; called each time a #ClutterContent is attached
- *   to a #ClutterActor. If overridden, the subclass must chain up to the
- *   parent class implementation.
+ *   to a #ClutterActor.
  * @detached: virtual function; called each time a #ClutterContent is detached
- *   from a #ClutterActor. If overridden, the subclass must chain up to the
- *   parent class implementation.
+ *   from a #ClutterActor.
  * @invalidate: virtual function; called each time a #ClutterContent state
- *   is changed. If overridden, the subclass must chain up to the parent
- *   class implementation.
+ *   is changed.
  *
  * The <structname>ClutterContentIface</structname> structure contains only
  * private data.



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