[gnome-shell] environment: Add some convenience LayoutManager monkey-patching
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] environment: Add some convenience LayoutManager monkey-patching
- Date: Wed, 24 Jul 2013 13:25:27 +0000 (UTC)
commit 6fd3c0fbb4a9b0f59903599564947f313379bcfb
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Jul 9 23:04:45 2013 +0200
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
js/ui/environment.js | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/environment.js b/js/ui/environment.js
index aa7a4bd..3d6ba69 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);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]