environment: Add some convenience LayoutManager monkey-patching
Similar to our ClutterContainer monkey-patching, we can add some convenience to existing ClutterLayoutManagers: - hookup_style() to bind layoutManager properties to CSS properties - child_set() to set child properties https://bugzilla.gnome.org/show_bug.cgi?id=703905
This commit is contained in:
parent
13170fbb3c
commit
6fd3c0fbb4
@ -10,6 +10,7 @@ const Clutter = imports.gi.Clutter;;
|
|||||||
const Gettext = imports.gettext;
|
const Gettext = imports.gettext;
|
||||||
const GLib = imports.gi.GLib;
|
const GLib = imports.gi.GLib;
|
||||||
const Gtk = imports.gi.Gtk;
|
const Gtk = imports.gi.Gtk;
|
||||||
|
const Lang = imports.lang;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
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) {
|
function _makeLoggingFunc(func) {
|
||||||
return function() {
|
return function() {
|
||||||
return func([].join.call(arguments, ', '));
|
return func([].join.call(arguments, ', '));
|
||||||
@ -60,6 +77,12 @@ function init() {
|
|||||||
_patchContainerClass(St.BoxLayout);
|
_patchContainerClass(St.BoxLayout);
|
||||||
_patchContainerClass(St.Table);
|
_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() {
|
Clutter.Actor.prototype.toString = function() {
|
||||||
return St.describe_actor(this);
|
return St.describe_actor(this);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user