[gnome-shell] environment: improve Object.toString for delegate objects
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] environment: improve Object.toString for delegate objects
- Date: Tue, 26 Apr 2011 12:20:24 +0000 (UTC)
commit 07a0960265e4bbb1222f386bf07343331bb77129
Author: Dan Winship <danw gnome org>
Date: Wed Apr 6 10:40:01 2011 -0400
environment: improve Object.toString for delegate objects
If a JS object has an 'actor' property pointing to a ClutterActor,
include the actor's toString() output in the delegate's toString()
output. Eg:
js>>> Main.panel
[object Object delegate for 0xff6080 StBoxLayout.menu-bar "panel" ("Activities")]
https://bugzilla.gnome.org/show_bug.cgi?id=646919
js/ui/environment.js | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/environment.js b/js/ui/environment.js
index 9061a77..758a2cb 100644
--- a/js/ui/environment.js
+++ b/js/ui/environment.js
@@ -88,6 +88,15 @@ function init() {
return St.describe_actor(this);
};
+ let origToString = Object.prototype.toString;
+ Object.prototype.toString = function() {
+ let base = origToString.call(this);
+ if ('actor' in this && this.actor instanceof Clutter.Actor)
+ return base.replace(/\]$/, ' delegate for ' + this.actor.toString().substring(1));
+ else
+ return base;
+ };
+
if (window.global === undefined) // test environment
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]