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
This commit is contained in:
Florian Müllner 2020-05-19 20:59:36 +02:00
parent 82fd68b985
commit 8d4e650a95

View File

@ -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);
};