diff --git a/js/ui/environment.js b/js/ui/environment.js index aa7a4bd07..3d6ba694b 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -10,6 +10,7 @@ const Clutter = imports.gi.Clutter;; const Gettext = imports.gettext; const GLib = imports.gi.GLib; const Gtk = imports.gi.Gtk; +const Lang = imports.lang; const Shell = imports.gi.Shell; const St = imports.gi.St; @@ -39,6 +40,22 @@ function _patchContainerClass(containerClass) { }; } +function _patchLayoutClass(layoutClass, styleProps) { + if (styleProps) + layoutClass.prototype.hookup_style = function(container) { + container.connect('style-changed', Lang.bind(this, function() { + let node = container.get_theme_node(); + for (let prop in styleProps) + this[prop] = node.get_length(styleProps[prop]); + })); + }; + layoutClass.prototype.child_set = function(actor, props) { + let meta = this.get_child_meta(actor.get_parent(), actor); + for (let prop in props) + meta[prop] = props[prop]; + }; +} + function _makeLoggingFunc(func) { return function() { return func([].join.call(arguments, ', ')); @@ -60,6 +77,12 @@ function init() { _patchContainerClass(St.BoxLayout); _patchContainerClass(St.Table); + _patchLayoutClass(Clutter.TableLayout, { row_spacing: 'spacing-rows', + column_spacing: 'spacing-columns' }); + _patchLayoutClass(Clutter.GridLayout, { row_spacing: 'spacing-rows', + column_spacing: 'spacing-columns' }); + _patchLayoutClass(Clutter.BoxLayout, { spacing: 'spacing' }); + Clutter.Actor.prototype.toString = function() { return St.describe_actor(this); };