[gnome-shell] environment: Monkey-patch iterate_children() generator
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] environment: Monkey-patch iterate_children() generator
- Date: Tue, 19 May 2020 19:21:57 +0000 (UTC)
commit 8d4e650a95a0fb0a3552ec316270185a84864c5a
Author: Florian Müllner <fmuellner gnome org>
Date: Tue May 19 20:59:36 2020 +0200
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 4a12314024..44a92db361 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);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]