Skip to content

Commit

Permalink
Systray zone is now an applet
Browse files Browse the repository at this point in the history
  • Loading branch information
clefebvre committed Feb 16, 2012
1 parent a84a24a commit 18f07df
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 6 deletions.
2 changes: 1 addition & 1 deletion data/org.cinnamon.gschema.xml
Expand Up @@ -13,7 +13,7 @@
</key>

<key type="as" name="enabled-applets">
<default>['panel1:left:0:menu@cinnamon.org', 'panel1:left:1:show-desktop@cinnamon.org', 'panel1:left:2:panel-launchers@cinnamon.org', 'panel1:left:3:window-list@cinnamon.org', 'panel1:center:0:keyboard@cinnamon.org', 'panel1:center:1:bluetooth@cinnamon.org', 'panel1:center:2:network@cinnamon.org', 'panel1:center:3:sound@cinnamon.org', 'panel1:center:4:power@cinnamon.org', 'panel1:right:0:calendar@cinnamon.org']</default>
<default>['panel1:left:0:menu@cinnamon.org', 'panel1:left:1:show-desktop@cinnamon.org', 'panel1:left:2:panel-launchers@cinnamon.org', 'panel1:left:3:window-list@cinnamon.org', 'panel1:center:0:keyboard@cinnamon.org', 'panel1:center:1:bluetooth@cinnamon.org', 'panel1:center:2:network@cinnamon.org', 'panel1:center:3:sound@cinnamon.org', 'panel1:center:4:power@cinnamon.org', 'panel1:right:0:systray@cinnamon.org', 'panel1:right:1:calendar@cinnamon.org']</default>
<summary>Uuids of applets to enable</summary>
<description>Cinnamon applets have a uuid property; this key lists applets which should be loaded.</description>
</key>
Expand Down
2 changes: 1 addition & 1 deletion data/org.cinnamon.gschema.xml.in
Expand Up @@ -22,7 +22,7 @@
</key>

<key name="enabled-applets" type="as">
<default>['panel1:left:0:menu@cinnamon.org', 'panel1:left:1:show-desktop@cinnamon.org', 'panel1:left:2:panel-launchers@cinnamon.org', 'panel1:left:3:window-list@cinnamon.org', 'panel1:center:0:keyboard@cinnamon.org', 'panel1:center:1:bluetooth@cinnamon.org', 'panel1:center:2:network@cinnamon.org', 'panel1:center:3:sound@cinnamon.org', 'panel1:center:4:power@cinnamon.org', 'panel1:right:0:calendar@cinnamon.org']</default>
<default>['panel1:left:0:menu@cinnamon.org', 'panel1:left:1:show-desktop@cinnamon.org', 'panel1:left:2:panel-launchers@cinnamon.org', 'panel1:left:3:window-list@cinnamon.org', 'panel1:center:0:keyboard@cinnamon.org', 'panel1:center:1:bluetooth@cinnamon.org', 'panel1:center:2:network@cinnamon.org', 'panel1:center:3:sound@cinnamon.org', 'panel1:center:4:power@cinnamon.org', 'panel1:right:0:systray@cinnamon.org', 'panel1:right:1:calendar@cinnamon.org']</default>
<_summary>Uuids of applets to enable</_summary>
<_description>
Cinnamon applets have a uuid property; this key lists applets
Expand Down
83 changes: 83 additions & 0 deletions files/usr/share/cinnamon/applets/systray@cinnamon.org/applet.js
@@ -0,0 +1,83 @@
const Applet = imports.ui.applet;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const Lang = imports.lang;

function MyApplet(orientation) {
this._init(orientation);
}

MyApplet.prototype = {
__proto__: Applet.Applet.prototype,

_init: function(orientation) {
Applet.Applet.prototype._init.call(this, orientation);

try {
Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
}
catch (e) {
global.logError(e);
}
},

on_applet_clicked: function(event) {

},

_onTrayIconAdded: function(o, icon, role) {
try {
let hiddenIcons = ["network", "power", "keyboard", "gnome-settings-daemon", "volume", "bluetooth", "battery", "a11y"];

if (hiddenIcons.indexOf(role) != -1 ) {
// We've got an applet for that
return;
}

//icon.height = PANEL_ICON_SIZE;
let buttonBox = new PanelMenu.ButtonBox({ style_class: 'panel-status-button' });
let box = buttonBox.actor;
box.add_actor(icon);

this._insertStatusItem(box, -1);

let themeNode = buttonBox.actor.get_theme_node();
if (!themeNode.get_length('height')) icon.height = PANEL_ICON_DEFAULT_SIZE;
else icon.height = themeNode.get_length('height');
}
catch (e) {
global.logError(e);
}
},

_onTrayIconRemoved: function(o, icon) {
let box = icon.get_parent();
if (box && box._delegate instanceof PanelMenu.ButtonBox)
box.destroy();
},

_insertStatusItem: function(actor, position) {
let children = this.actor.get_children();
let i;
for (i = children.length - 1; i >= 0; i--) {
let rolePosition = children[i]._rolePosition;
if (position > rolePosition) {
this.actor.insert_actor(actor, i + 1);
break;
}
}
if (i == -1) {
// If we didn't find a position, we must be first
this.actor.insert_actor(actor, 0);
}
actor._rolePosition = position;
},


};

function main(metadata, orientation) {
let myApplet = new MyApplet(orientation);
return myApplet;
}
@@ -0,0 +1,6 @@
{
"uuid": "systray@cinnamon.org",
"name": "Systrem Tray",
"description": "An applet which hosts all the system try icons",
"icon": "indicator-applet"
}
4 changes: 2 additions & 2 deletions js/ui/panel.js
Expand Up @@ -720,8 +720,8 @@ Panel.prototype = {
this._status_area_cinnamon_implementation = STANDARD_STATUS_AREA_CINNAMON_IMPLEMENTATION;
}

Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));
//Main.statusIconDispatcher.connect('status-icon-added', Lang.bind(this, this._onTrayIconAdded));
//Main.statusIconDispatcher.connect('status-icon-removed', Lang.bind(this, this._onTrayIconRemoved));

this.actor.connect('leave-event', Lang.bind(this, this._leavePanel));
this.actor.connect('enter-event', Lang.bind(this, this._enterPanel));
Expand Down
3 changes: 1 addition & 2 deletions js/ui/statusIconDispatcher.js
Expand Up @@ -48,8 +48,7 @@ StatusIconDispatcher.prototype = {
_onTrayIconAdded: function(o, icon) {
let wmClass = (icon.wm_class || 'unknown').toLowerCase();
let role = STANDARD_TRAY_ICON_IMPLEMENTATIONS[wmClass];
if (!role) role = wmClass;
global.log("ROLE: " + wmClass + " --> " + role);
if (!role) role = wmClass;
this.emit('status-icon-added', icon, role);
},

Expand Down

0 comments on commit 18f07df

Please sign in to comment.