From 8d4e650a95a0fb0a3552ec316270185a84864c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 19 May 2020 20:59:36 +0200 Subject: [PATCH] environment: Monkey-patch iterate_children() generator This is a small convenience method for using ClutterActor's iterator API with javascript's built-in iterator protocol, for example as: for (let child of container.iterate_children()) doStuff(child); https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1268 --- js/ui/environment.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/ui/environment.js b/js/ui/environment.js index 4a1231402..44a92db36 100644 --- a/js/ui/environment.js +++ b/js/ui/environment.js @@ -285,6 +285,11 @@ function init() { _easeActorProperty(this, 'value', target, params); }; + Clutter.Actor.prototype.iterate_children = function* () { + for (let c = this.get_first_child(); c; c = c.get_next_sibling()) + yield c; + }; + Clutter.Actor.prototype.toString = function () { return St.describe_actor(this); };