[gnome-shell/shell-toolkit: 10/32] Monkey-patch in ClutterContainer methods for StBoxLayout
- From: Owen Taylor <otaylor src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell/shell-toolkit: 10/32] Monkey-patch in ClutterContainer methods for StBoxLayout
- Date: Wed, 30 Sep 2009 00:01:56 +0000 (UTC)
commit ed07413c208e774c947e85c452bed0ed460a0ccb
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Wed Sep 16 19:53:55 2009 -0400
Monkey-patch in ClutterContainer methods for StBoxLayout
Setting options for children added to StBoxLayout is not convenient
since we are missing the varargs methods of clutter_container.
Patch in:
child_set() - set properties of a child
add() - add a child and set properties (this is different from
clutter_container_add()! I think the deviation is
with avoiding the awkward name add_with_properties()
which is what might be expected. ClutterContainer
currently doesn't have a method like this at all.)
The code is written to allow patching into multiple ClutterContainer
classes but for now only StBoxLayout is patched, since it's the only
container we are using where we need to set options as properties.
https://bugzilla.gnome.org/show_bug.cgi?id=595419
js/ui/main.js | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/main.js b/js/ui/main.js
index 140062b..f6a3c19 100644
--- a/js/ui/main.js
+++ b/js/ui/main.js
@@ -37,6 +37,28 @@ let shellDBusService = null;
let modalCount = 0;
let modalActorFocusStack = [];
+// "monkey patch" in some varargs ClutterContainer methods; we need
+// to do this per-container class since there is no representation
+// of interfaces in Javascript
+function _patchContainerClass(containerClass) {
+ // This one is a straightforward mapping of the C method
+ containerClass.prototype.child_set = function(actor, props) {
+ let meta = this.get_child_meta(actor);
+ for (prop in props)
+ meta[prop] = props[prop];
+ };
+
+ // clutter_container_add() actually is a an add-many-actors
+ // method. We conveniently, but somewhat dubiously, take the
+ // this opportunity to make it do something more useful.
+ containerClass.prototype.add = function(actor, props) {
+ this.add_actor(actor);
+ if (props)
+ this.child_set(actor, props);
+ };
+}
+_patchContainerClass(St.BoxLayout);
+
function start() {
// Add a binding for "global" in the global JS namespace; (gjs
// keeps the web browser convention of having that namespace be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]