[gnome-shell/wip/re-search: 120/151] centerLayout: Add some utilities to connect us up to CSS



commit 1d7c2b1c2643428898ab084279ed64b678613422
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Oct 12 14:08:38 2012 -0400

    centerLayout: Add some utilities to connect us up to CSS
    
    This allows us to automatically adjust the "spacing" property of the
    layout manager whenever the CSS changes.

 js/ui/centerLayout.js |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/centerLayout.js b/js/ui/centerLayout.js
index 38574fb..eef124b 100644
--- a/js/ui/centerLayout.js
+++ b/js/ui/centerLayout.js
@@ -2,6 +2,39 @@
 
 const Lang = imports.lang;
 const Clutter = imports.gi.Clutter;
+const St = imports.gi.St;
+
+function connectLayoutManager(layoutManager, styleChanged) {
+    let widget, styleChangedId;
+
+    function _styleChanged() {
+        let themeNode = widget.get_theme_node();
+        styleChanged(themeNode, widget);
+    }
+
+    function actorChanged() {
+        if (widget) {
+            widget.disconnect(styleChangedId);
+            styleChangedId = 0;
+        }
+
+        let actor = layoutManager.get_actor();
+        if (actor && actor instanceof St.Widget) {
+            widget = actor;
+            styleChangedId = widget.connect('style-changed', _styleChanged);
+            _styleChanged();
+        }
+    }
+
+    layoutManager.connect('notify::actor', actorChanged);
+    return layoutManager;
+}
+
+function connectSpacing(layoutManager) {
+    return connectLayoutManager(layoutManager, function(themeNode, widget) {
+        layoutManager.spacing = themeNode.get_length('spacing');
+    });
+}
 
 const CenterLayout = new Lang.Class({
     Name: 'CenterLayout',



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