cally: Refactoring "window:create" and "window:destroy" emission code
authorAlejandro Piñeiro <apinheiro@igalia.com>
Tue, 6 Jul 2010 11:25:44 +0000 (13:25 +0200)
committerAlejandro Piñeiro <apinheiro@igalia.com>
Wed, 7 Jul 2010 13:47:56 +0000 (15:47 +0200)
Previously "window:create" and "window:destroy" were emitted on
CallyUtil. Although it works, and CallyUtil already have callbacks to
stage_added/removed signals, I think that it is more tidy/clear to do
that on CallyRoot:

  * CallyRoot already has code to manage ClutterStage addition/removal

  * In fact, we can see CallyRoot as the object exposing the a11y
    information from ClutterStageManager, so it fits better here.

  * CallyUtil callbacks these signals are related to key event
    listeners (key snooper simulation). One of the main CallyUtil
    responsabilities is managing event (connecting, emitting), so I
    would prefer to not start to add/mix more functionalities here.

Ideally it would be better to emit all CallyStage methods from
CallyStage, but it is clear that "create" and "destroy" are more easy
to emit from a external object

clutter/cally/cally-root.c
clutter/cally/cally-util.c

index f919c85..aaad2f8 100644 (file)
@@ -248,6 +248,7 @@ cally_util_stage_added_cb (ClutterStageManager *stage_manager,
   index = g_slist_index (root->priv->stage_list, cally_stage);
   g_signal_emit_by_name (root, "children_changed::add",
                          index, cally_stage, NULL);
+  g_signal_emit_by_name (cally_stage, "create", 0);
 }
 
 static void
@@ -269,4 +270,5 @@ cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
   index = g_slist_index (root->priv->stage_list, cally_stage);
   g_signal_emit_by_name (root, "children_changed::remove",
                          index, cally_stage, NULL);
+  g_signal_emit_by_name (cally_stage, "destroy", 0);
 }
index 40396fd..fd0b43a 100644 (file)
@@ -535,13 +535,8 @@ cally_util_stage_added_cb (ClutterStageManager *stage_manager,
                            gpointer data)
 {
   GCallback cally_key_snooper_cb = G_CALLBACK (data);
-  AtkObject *cally_stage = NULL;
 
   g_signal_connect (G_OBJECT (stage), "captured-event", cally_key_snooper_cb, NULL);
-
-  cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
-  if (cally_stage != NULL)
-    g_signal_emit_by_name (G_OBJECT(cally_stage), "create", 0);
 }
 
 static void
@@ -551,13 +546,8 @@ cally_util_stage_removed_cb (ClutterStageManager *stage_manager,
 {
   GCallback cally_key_snooper_cb = G_CALLBACK (data);
   gint num = 0;
-  AtkObject *cally_stage = NULL;
 
   num = g_signal_handlers_disconnect_by_func (stage, cally_key_snooper_cb, NULL);
-
-  cally_stage = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
-  if (cally_stage != NULL)
-    g_signal_emit_by_name (G_OBJECT(cally_stage), "destroy", 0);
 }
 
 static void