After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 653205 - panel: Add an easier way of adding items to the system status area
panel: Add an easier way of adding items to the system status area
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2011-06-23 02:35 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2011-08-25 17:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
panel: Add an easier way of adding items to the system status area (1.84 KB, patch)
2011-06-23 02:35 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
panel: Add an easier way of adding items to the system status area (1.91 KB, patch)
2011-07-13 18:16 UTC, Jasper St. Pierre (not reading bugmail)
none Details | Review
panel: Add an easier way of adding items to the system status area (4.13 KB, patch)
2011-08-22 21:25 UTC, Giovanni Campagna
reviewed Details | Review
Panel: remove 'display' from the standard icons. (1.14 KB, patch)
2011-08-22 21:45 UTC, Giovanni Campagna
committed Details | Review
Panel: start the status area before extensions are loaded (1.10 KB, patch)
2011-08-22 21:50 UTC, Giovanni Campagna
committed Details | Review
panel: Add an easier way of adding items to the system status area (3.05 KB, patch)
2011-08-24 18:17 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2011-06-23 02:35:21 UTC
Just a random idea to help with extensions and demos involving them.
Comment 1 Jasper St. Pierre (not reading bugmail) 2011-06-23 02:35:24 UTC
Created attachment 190484 [details] [review]
panel: Add an easier way of adding items to the system status area

Extensions often want to add items to the system status area, so let's give
them a bit of a hand, shall we?
Comment 2 Giovanni Campagna 2011-07-13 17:46:51 UTC
Review of attachment 190484 [details] [review]:

::: js/ui/panel.js
@@ +1061,3 @@
     },
 
+    addToStatusArea: function(role, constructor) {

1) Why the constructor? Can't you pass a new SystemStatusButton object?
2) If we keep role, we should at least check that two extensions don't try to register for the same role

@@ +1064,3 @@
+        let indicator = new constructor();
+
+        this._statusBox.insert_actor(indicator.actor, 0);

This is ok when called from an extension, but it is wrong at gnome-shell startup (icons are reversed).

@@ +1075,3 @@
+        let indicator = this._statusArea[role];
+
+        this._statusBox.remove_actor(indicator.actor);

Why not indicator.destroy()?
Comment 3 Jasper St. Pierre (not reading bugmail) 2011-07-13 18:16:43 UTC
Created attachment 191905 [details] [review]
panel: Add an easier way of adding items to the system status area

Extensions often want to add items to the system status area, so let's give
them a bit of a hand, shall we?



> 1) Why the constructor? Can't you pass a new SystemStatusButton object?

I had a reason, but I don't remember it now. Dropped.

> 2) If we keep role, we should at least check that two extensions don't try to
> register for the same role

And what happens if they do? Should we drop the "role" thing and just make them
pass the same indicator back?

> This is ok when called from an extension, but it is wrong at gnome-shell
> startup (icons are reversed).

Fixed.

> Why not indicator.destroy()?

Will actor.destroy() remove it from its parent? Never knew that.
Comment 4 Giovanni Campagna 2011-08-22 21:25:06 UTC
Created attachment 194432 [details] [review]
panel: Add an easier way of adding items to the system status area

Extensions often want to add items to the system status area, so it
is useful to add a convenience API for it. Also, we now allow
for cleaner destruction of panel objects, by just calling destroy()
on it.
Based on a patch by Jasper St. Pierre.

-----

Reworked to have clean destroy(). I dropped "removeFromStatusArea",
so now extensions cannot remove indicators from outside (whitout
resorting to private API)
Comment 5 Colin Walters 2011-08-22 21:37:57 UTC
Review of attachment 194432 [details] [review]:

::: js/ui/panelMenu.js
@@ +24,3 @@
         this.actor._delegate = this;
+        this._buttonPressId = this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
+        this._keyPressId = this.actor.connect('key-press-event', Lang.bind(this, this._onSourceKeyPress));

You shouldn't need this part - when calling actor.destroy(), it will call g_object_run_dispose() which removes all signal handlers presently on the object.

@@ +95,3 @@
+            this.actor.disconnect(this._keyPressId);
+            this._keyPressId = 0;
+        }

That means this part is unnecessary too.
Comment 6 Giovanni Campagna 2011-08-22 21:45:12 UTC
Created attachment 194434 [details] [review]
Panel: remove 'display' from the standard icons.

This way all standard indicators have a shell implementation
provided, which prevents issues with extensions enabling/disabling
(in particular with xrandr-indicator)
Comment 7 Colin Walters 2011-08-22 21:46:13 UTC
Review of attachment 194434 [details] [review]:

Sure.
Comment 8 Giovanni Campagna 2011-08-22 21:50:13 UTC
Created attachment 194435 [details] [review]
Panel: start the status area before extensions are loaded

The order of indicators depends on the order of calls to
Panel.addToStatusArea. To have it consistent across enabling and
disabling of extensions, we need to place the core ones first.
Comment 9 Colin Walters 2011-08-22 21:57:27 UTC
Review of attachment 194435 [details] [review]:

Looks fine.
Comment 10 Jasper St. Pierre (not reading bugmail) 2011-08-24 18:17:40 UTC
Created attachment 194649 [details] [review]
panel: Add an easier way of adding items to the system status area

Extensions often want to add items to the system status area, so it
is useful to add a convenience API for it. Also, we now allow
for cleaner destruction of panel objects, by just calling destroy()
on it.
Based on a patch by Jasper St. Pierre.
Comment 11 Colin Walters 2011-08-25 17:28:08 UTC
Review of attachment 194649 [details] [review]:

Looks good.
Comment 12 Jasper St. Pierre (not reading bugmail) 2011-08-25 17:36:32 UTC
Attachment 194649 [details] pushed as 08126e5 - panel: Add an easier way of adding items to the system status area