[gnome-shell] Make St aware of the UI group.



commit afffa76c1726158397013e3261876cf003574d1d
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Jan 11 16:38:55 2011 +0100

    Make St aware of the UI group.
    
    Inside the Shell, all the UI (including chrome, the overview, and
    the actual windows) is not a child of the stage but of a special
    ClutterGroup, which is cloned inside the magnifier.
    Add function for setting this special actor so that actors added by
    St are visible in the magnifier. Nothing yet uses this, but the
    tooltip will soon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=635100

 js/ui/main.js      |    1 +
 src/st/st-widget.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/st/st-widget.h |    4 +++
 3 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 155cdb2..603f485 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -136,6 +136,7 @@ function start() {
 
     // Set up stage hierarchy to group all UI actors under one container.
     uiGroup = new Clutter.Group();
+    St.set_ui_root(global.stage, uiGroup);
     global.window_group.reparent(uiGroup);
     global.overlay_group.reparent(uiGroup);
     global.stage.add_actor(uiGroup);
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 45b3f8d..fe5d1b0 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -2222,3 +2222,71 @@ on_can_focus_notify (GObject    *gobject,
   atk_object_notify_state_change (ATK_OBJECT (data),
                                   ATK_STATE_FOCUSABLE, can_focus);
 }
+
+static GQuark
+st_ui_root_quark (void)
+{
+  static GQuark value = 0;
+  if (G_UNLIKELY (value == 0))
+    value = g_quark_from_static_string ("st-ui-root");
+  return value;
+}
+
+static void
+st_ui_root_destroyed (ClutterActor *actor,
+                      ClutterStage *stage)
+{
+  st_set_ui_root (stage, NULL);
+  g_signal_handlers_disconnect_by_func (actor, st_ui_root_destroyed, stage);
+}
+
+/**
+ * st_get_ui_root:
+ * @stage: a #ClutterStage
+ * @container: (allow-none): the new UI root
+ *
+ * Sets a #ClutterContainer to be the parent of all UI in the program.
+ * This container is used when St needs to add new content outside the
+ * widget hierarchy, for example, when it shows a tooltip over a widget.
+ */
+void
+st_set_ui_root (ClutterStage     *stage,
+                ClutterContainer *container)
+{
+  ClutterContainer *previous;
+
+  g_return_if_fail (CLUTTER_IS_STAGE (stage));
+  g_return_if_fail (CLUTTER_IS_CONTAINER (container));
+
+  previous = st_get_ui_root (stage);
+  if (previous)
+    g_signal_handlers_disconnect_by_func (container, st_ui_root_destroyed, stage);
+
+  if (container)
+    {
+      g_signal_connect (container, "destroy", G_CALLBACK (st_ui_root_destroyed), stage);
+      g_object_set_qdata_full (G_OBJECT (stage), st_ui_root_quark (), g_object_ref (container), g_object_unref);
+    }
+}
+
+/**
+ * st_get_ui_root:
+ * @stage: a #ClutterStage
+ *
+ * Returns: (transfer none): the container which should be the parent of all user interface,
+ *   which can be set with st_set_ui_root(). If not set, returns @stage
+ */
+ClutterContainer *
+st_get_ui_root (ClutterStage *stage)
+{
+  ClutterContainer *root;
+
+  g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
+
+  root = g_object_get_qdata (G_OBJECT (stage), st_ui_root_quark ());
+
+  if (root != NULL)
+    return root;
+  else
+    return CLUTTER_CONTAINER (stage);
+}
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index 7f5efec..d38eb68 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -162,6 +162,10 @@ char  *st_describe_actor       (ClutterActor *actor);
 void   st_set_slow_down_factor (gfloat factor);
 gfloat st_get_slow_down_factor (void);
 
+void              st_set_ui_root (ClutterStage     *stage,
+                                  ClutterContainer *container);
+ClutterContainer *st_get_ui_root (ClutterStage     *stage);
+
 G_END_DECLS
 
 #endif /* __ST_WIDGET_H__ */



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