Skip to content
Browse files

"everything's an applet" megacommit, expect bugs :))

  • Loading branch information...
1 parent c234d41 commit 30d1c580e2de79eaeb7f5da69193898b7df838a5 @clefebvre clefebvre committed Feb 14, 2012
View
4 data/org.cinnamon.gschema.xml
@@ -13,7 +13,7 @@
</key>
<key type="as" name="enabled-applets">
- <default>[]</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: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>
@@ -253,4 +253,4 @@
<description>The filename for recorded screencasts will be a unique filename based on the current date, and use this extension. It should be changed when recording to a different container format.</description>
</key>
</schema>
-</schemalist>
+</schemalist>
View
2 data/org.cinnamon.gschema.xml.in
@@ -22,7 +22,7 @@
</key>
<key name="enabled-applets" type="as">
- <default>[]</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:calendar@cinnamon.org']</default>
<_summary>Uuids of applets to enable</_summary>
<_description>
Cinnamon applets have a uuid property; this key lists applets
View
14 data/theme/cinnamon.css
@@ -1850,20 +1850,19 @@ StTooltip StLabel {
.applet-box {
margin: 1px;
- padding: 1px;
+ padding: 1px;
+ color: #ccc;
}
.applet-box:hover {
-
+ color: #fff;
}
.applet-label {
padding-left: 4px;
padding-right: 4px;
font-weight: bold;
- color: #ccc;
-
-
+ color: #ccc;
}
.applet-label:hover,
@@ -1873,11 +1872,12 @@ StTooltip StLabel {
}
.applet-icon {
-
+ color: #ccc;
}
.applet-icon:hover,
.applet-box:hover > .applet-icon {
- icon-shadow: white 0px 0px 3px;
+ color: #fff;
+ icon-shadow: white 0px 0px 3px;
}
View
499 js/ui/status/bluetooth.js → .../applets/bluetooth@cinnamon.org/applet.js
@@ -1,5 +1,4 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
+const Applet = imports.ui.applet;
const Clutter = imports.gi.Clutter;
const Gdk = imports.gi.Gdk;
const GLib = imports.gi.GLib;
@@ -23,79 +22,283 @@ const ConnectionState = {
CONNECTING: 3
}
-function Indicator() {
+function Source() {
this._init.apply(this, arguments);
}
-Indicator.prototype = {
- __proto__: PanelMenu.SystemStatusButton.prototype,
+Source.prototype = {
+ __proto__: MessageTray.Source.prototype,
_init: function() {
- PanelMenu.SystemStatusButton.prototype._init.call(this, 'bluetooth-disabled', null);
-
- GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
- this._applet = new GnomeBluetoothApplet.Applet();
-
- this._killswitch = new PopupMenu.PopupSwitchMenuItem(_("Bluetooth"), false);
- this._applet.connect('notify::killswitch-state', Lang.bind(this, this._updateKillswitch));
- this._killswitch.connect('toggled', Lang.bind(this, function() {
- let current_state = this._applet.killswitch_state;
- if (current_state != GnomeBluetoothApplet.KillswitchState.HARD_BLOCKED &&
- current_state != GnomeBluetoothApplet.KillswitchState.NO_ADAPTER) {
- this._applet.killswitch_state = this._killswitch.state ?
- GnomeBluetoothApplet.KillswitchState.UNBLOCKED:
- GnomeBluetoothApplet.KillswitchState.SOFT_BLOCKED;
- } else
- this._killswitch.setToggleState(false);
+ MessageTray.Source.prototype._init.call(this, _("Bluetooth"));
+
+ this._setSummaryIcon(this.createNotificationIcon());
+ },
+
+ notify: function(notification) {
+ this._private_destroyId = notification.connect('destroy', Lang.bind(this, function(notification) {
+ if (this.notification == notification) {
+ // the destroyed notification is the last for this source
+ this.notification.disconnect(this._private_destroyId);
+ this.destroy();
+ }
}));
- this._discoverable = new PopupMenu.PopupSwitchMenuItem(_("Visibility"), this._applet.discoverable);
- this._applet.connect('notify::discoverable', Lang.bind(this, function() {
- this._discoverable.setToggleState(this._applet.discoverable);
+ MessageTray.Source.prototype.notify.call(this, notification);
+ },
+
+ createNotificationIcon: function() {
+ return new St.Icon({ icon_name: 'bluetooth-active',
+ icon_type: St.IconType.SYMBOLIC,
+ icon_size: this.ICON_SIZE });
+ }
+}
+
+function AuthNotification() {
+ this._init.apply(this, arguments);
+}
+
+AuthNotification.prototype = {
+ __proto__: MessageTray.Notification.prototype,
+
+ _init: function(source, applet, device_path, name, long_name, uuid) {
+ MessageTray.Notification.prototype._init.call(this,
+ source,
+ _("Bluetooth"),
+ _("Authorization request from %s").format(name),
+ { customContent: true });
+ this.setResident(true);
+
+ this._applet = applet;
+ this._devicePath = device_path;
+ this.addBody(_("Device %s wants access to the service '%s'").format(long_name, uuid));
+
+ this.addButton('always-grant', _("Always grant access"));
+ this.addButton('grant', _("Grant this time only"));
+ this.addButton('reject', _("Reject"));
+
+ this.connect('action-invoked', Lang.bind(this, function(self, action) {
+ switch (action) {
+ case 'always-grant':
+ this._applet.agent_reply_auth(this._devicePath, true, true);
+ break;
+ case 'grant':
+ this._applet.agent_reply_auth(this._devicePath, true, false);
+ break;
+ case 'reject':
+ default:
+ this._applet.agent_reply_auth(this._devicePath, false, false);
+ }
+ this.destroy();
}));
- this._discoverable.connect('toggled', Lang.bind(this, function() {
- this._applet.discoverable = this._discoverable.state;
+ }
+}
+
+function ConfirmNotification() {
+ this._init.apply(this, arguments);
+}
+
+ConfirmNotification.prototype = {
+ __proto__: MessageTray.Notification.prototype,
+
+ _init: function(source, applet, device_path, name, long_name, pin) {
+ MessageTray.Notification.prototype._init.call(this,
+ source,
+ _("Bluetooth"),
+ _("Pairing confirmation for %s").format(name),
+ { customContent: true });
+ this.setResident(true);
+
+ this._applet = applet;
+ this._devicePath = device_path;
+ this.addBody(_("Device %s wants to pair with this computer").format(long_name));
+ this.addBody(_("Please confirm whether the PIN '%s' matches the one on the device.").format(pin));
+
+ this.addButton('matches', _("Matches"));
+ this.addButton('does-not-match', _("Does not match"));
+
+ this.connect('action-invoked', Lang.bind(this, function(self, action) {
+ if (action == 'matches')
+ this._applet.agent_reply_confirm(this._devicePath, true);
+ else
+ this._applet.agent_reply_confirm(this._devicePath, false);
+ this.destroy();
}));
+ }
+}
- this._updateKillswitch();
- this.menu.addMenuItem(this._killswitch);
- this.menu.addMenuItem(this._discoverable);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
-
- this._fullMenuItems = [new PopupMenu.PopupSeparatorMenuItem(),
- new PopupMenu.PopupMenuItem(_("Send Files to Device...")),
- new PopupMenu.PopupMenuItem(_("Set up a New Device...")),
- new PopupMenu.PopupSeparatorMenuItem()];
- this._hasDevices = false;
-
- this._fullMenuItems[1].connect('activate', function() {
- GLib.spawn_command_line_async('bluetooth-sendto');
- });
- this._fullMenuItems[2].connect('activate', function() {
- GLib.spawn_command_line_async('bluetooth-wizard');
- });
-
- for (let i = 0; i < this._fullMenuItems.length; i++) {
- let item = this._fullMenuItems[i];
- this.menu.addMenuItem(item);
- }
+function PinNotification() {
+ this._init.apply(this, arguments);
+}
+
+PinNotification.prototype = {
+ __proto__: MessageTray.Notification.prototype,
+
+ _init: function(source, applet, device_path, name, long_name, numeric) {
+ MessageTray.Notification.prototype._init.call(this,
+ source,
+ _("Bluetooth"),
+ _("Pairing request for %s").format(name),
+ { customContent: true });
+ this.setResident(true);
- this._deviceItemPosition = 3;
- this._deviceItems = [];
- this._applet.connect('devices-changed', Lang.bind(this, this._updateDevices));
- this._updateDevices();
+ this._applet = applet;
+ this._devicePath = device_path;
+ this._numeric = numeric;
+ this.addBody(_("Device %s wants to pair with this computer").format(long_name));
+ this.addBody(_("Please enter the PIN mentioned on the device."));
- this._applet.connect('notify::show-full-menu', Lang.bind(this, this._updateFullMenu));
- this._updateFullMenu();
+ this._entry = new St.Entry();
+ this._entry.connect('key-release-event', Lang.bind(this, function(entry, event) {
+ let key = event.get_key_symbol();
+ if (key == Clutter.KEY_Return) {
+ this.emit('action-invoked', 'ok');
+ return true;
+ } else if (key == Clutter.KEY_Escape) {
+ this.emit('action-invoked', 'cancel');
+ return true;
+ }
+ return false;
+ }));
+ this.addActor(this._entry);
- this.menu.addSettingsAction(_("Bluetooth Settings"), 'bluetooth-properties.desktop');
+ this.addButton('ok', _("OK"));
+ this.addButton('cancel', _("Cancel"));
- this._applet.connect('pincode-request', Lang.bind(this, this._pinRequest));
- this._applet.connect('confirm-request', Lang.bind(this, this._confirmRequest));
- this._applet.connect('auth-request', Lang.bind(this, this._authRequest));
- this._applet.connect('cancel-request', Lang.bind(this, this._cancelRequest));
+ this.connect('action-invoked', Lang.bind(this, function(self, action) {
+ if (action == 'ok') {
+ if (this._numeric) {
+ let num = parseInt(this._entry.text);
+ if (isNaN(num)) {
+ // user reply was empty, or was invalid
+ // cancel the operation
+ num = -1;
+ }
+ this._applet.agent_reply_passkey(this._devicePath, num);
+ } else
+ this._applet.agent_reply_pincode(this._devicePath, this._entry.text);
+ } else {
+ if (this._numeric)
+ this._applet.agent_reply_passkey(this._devicePath, -1);
+ else
+ this._applet.agent_reply_pincode(this._devicePath, null);
+ }
+ this.destroy();
+ }));
},
+ grabFocus: function(lockTray) {
+ MessageTray.Notification.prototype.grabFocus.call(this, lockTray);
+ global.stage.set_key_focus(this._entry);
+ }
+}
+
+function MyMenu(launcher, orientation) {
+ this._init(launcher, orientation);
+}
+
+MyMenu.prototype = {
+ __proto__: PopupMenu.PopupMenu.prototype,
+
+ _init: function(launcher, orientation) {
+ this._launcher = launcher;
+
+ PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, 0.0, orientation, 0);
+ Main.uiGroup.add_actor(this.actor);
+ this.actor.hide();
+ }
+}
+
+function MyApplet(orientation) {
+ this._init(orientation);
+}
+
+MyApplet.prototype = {
+ __proto__: Applet.TextIconApplet.prototype,
+
+ _init: function(orientation) {
+ Applet.TextIconApplet.prototype._init.call(this, orientation);
+
+ try {
+ this.menuManager = new PopupMenu.PopupMenuManager(this);
+ this.menu = new MyMenu(this, orientation);
+ this.menuManager.addMenu(this.menu);
+
+ this.set_applet_icon_symbolic_name('bluetooth-disabled');
+
+ GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
+ this._applet = new GnomeBluetoothApplet.Applet();
+
+ this._killswitch = new PopupMenu.PopupSwitchMenuItem(_("Bluetooth"), false);
+ this._applet.connect('notify::killswitch-state', Lang.bind(this, this._updateKillswitch));
+ this._killswitch.connect('toggled', Lang.bind(this, function() {
+ let current_state = this._applet.killswitch_state;
+ if (current_state != GnomeBluetoothApplet.KillswitchState.HARD_BLOCKED &&
+ current_state != GnomeBluetoothApplet.KillswitchState.NO_ADAPTER) {
+ this._applet.killswitch_state = this._killswitch.state ?
+ GnomeBluetoothApplet.KillswitchState.UNBLOCKED:
+ GnomeBluetoothApplet.KillswitchState.SOFT_BLOCKED;
+ } else
+ this._killswitch.setToggleState(false);
+ }));
+
+ this._discoverable = new PopupMenu.PopupSwitchMenuItem(_("Visibility"), this._applet.discoverable);
+ this._applet.connect('notify::discoverable', Lang.bind(this, function() {
+ this._discoverable.setToggleState(this._applet.discoverable);
+ }));
+ this._discoverable.connect('toggled', Lang.bind(this, function() {
+ this._applet.discoverable = this._discoverable.state;
+ }));
+
+ this._updateKillswitch();
+ this.menu.addMenuItem(this._killswitch);
+ this.menu.addMenuItem(this._discoverable);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+
+ this._fullMenuItems = [new PopupMenu.PopupSeparatorMenuItem(),
+ new PopupMenu.PopupMenuItem(_("Send Files to Device...")),
+ new PopupMenu.PopupMenuItem(_("Set up a New Device...")),
+ new PopupMenu.PopupSeparatorMenuItem()];
+ this._hasDevices = false;
+
+ this._fullMenuItems[1].connect('activate', function() {
+ GLib.spawn_command_line_async('bluetooth-sendto');
+ });
+ this._fullMenuItems[2].connect('activate', function() {
+ GLib.spawn_command_line_async('bluetooth-wizard');
+ });
+
+ for (let i = 0; i < this._fullMenuItems.length; i++) {
+ let item = this._fullMenuItems[i];
+ this.menu.addMenuItem(item);
+ }
+
+ this._deviceItemPosition = 3;
+ this._deviceItems = [];
+ this._applet.connect('devices-changed', Lang.bind(this, this._updateDevices));
+ this._updateDevices();
+
+ this._applet.connect('notify::show-full-menu', Lang.bind(this, this._updateFullMenu));
+ this._updateFullMenu();
+
+ this.menu.addSettingsAction(_("Bluetooth Settings"), 'bluetooth-properties.desktop');
+
+ this._applet.connect('pincode-request', Lang.bind(this, this._pinRequest));
+ this._applet.connect('confirm-request', Lang.bind(this, this._confirmRequest));
+ this._applet.connect('auth-request', Lang.bind(this, this._authRequest));
+ this._applet.connect('cancel-request', Lang.bind(this, this._cancelRequest));
+
+ }
+ catch (e) {
+ global.logError(e);
+ }
+ },
+
+ on_applet_clicked: function(event) {
+ this.menu.toggle();
+ },
+
+
_updateKillswitch: function() {
let current_state = this._applet.killswitch_state;
let on = current_state == GnomeBluetoothApplet.KillswitchState.UNBLOCKED;
@@ -117,10 +320,10 @@ Indicator.prototype = {
if (on) {
this._discoverable.actor.show();
- this.setIcon('bluetooth-active');
+ this.set_applet_icon_symbolic_name('bluetooth-active');
} else {
this._discoverable.actor.hide();
- this.setIcon('bluetooth-disabled');
+ this.set_applet_icon_symbolic_name('bluetooth-disabled');
}
},
@@ -334,175 +537,9 @@ Indicator.prototype = {
_cancelRequest: function() {
this._source.destroy();
}
-}
-
-function Source() {
- this._init.apply(this, arguments);
-}
-
-Source.prototype = {
- __proto__: MessageTray.Source.prototype,
-
- _init: function() {
- MessageTray.Source.prototype._init.call(this, _("Bluetooth"));
-
- this._setSummaryIcon(this.createNotificationIcon());
- },
-
- notify: function(notification) {
- this._private_destroyId = notification.connect('destroy', Lang.bind(this, function(notification) {
- if (this.notification == notification) {
- // the destroyed notification is the last for this source
- this.notification.disconnect(this._private_destroyId);
- this.destroy();
- }
- }));
-
- MessageTray.Source.prototype.notify.call(this, notification);
- },
-
- createNotificationIcon: function() {
- return new St.Icon({ icon_name: 'bluetooth-active',
- icon_type: St.IconType.SYMBOLIC,
- icon_size: this.ICON_SIZE });
- }
-}
-
-function AuthNotification() {
- this._init.apply(this, arguments);
-}
-
-AuthNotification.prototype = {
- __proto__: MessageTray.Notification.prototype,
-
- _init: function(source, applet, device_path, name, long_name, uuid) {
- MessageTray.Notification.prototype._init.call(this,
- source,
- _("Bluetooth"),
- _("Authorization request from %s").format(name),
- { customContent: true });
- this.setResident(true);
-
- this._applet = applet;
- this._devicePath = device_path;
- this.addBody(_("Device %s wants access to the service '%s'").format(long_name, uuid));
-
- this.addButton('always-grant', _("Always grant access"));
- this.addButton('grant', _("Grant this time only"));
- this.addButton('reject', _("Reject"));
-
- this.connect('action-invoked', Lang.bind(this, function(self, action) {
- switch (action) {
- case 'always-grant':
- this._applet.agent_reply_auth(this._devicePath, true, true);
- break;
- case 'grant':
- this._applet.agent_reply_auth(this._devicePath, true, false);
- break;
- case 'reject':
- default:
- this._applet.agent_reply_auth(this._devicePath, false, false);
- }
- this.destroy();
- }));
- }
-}
-
-function ConfirmNotification() {
- this._init.apply(this, arguments);
-}
-
-ConfirmNotification.prototype = {
- __proto__: MessageTray.Notification.prototype,
-
- _init: function(source, applet, device_path, name, long_name, pin) {
- MessageTray.Notification.prototype._init.call(this,
- source,
- _("Bluetooth"),
- _("Pairing confirmation for %s").format(name),
- { customContent: true });
- this.setResident(true);
-
- this._applet = applet;
- this._devicePath = device_path;
- this.addBody(_("Device %s wants to pair with this computer").format(long_name));
- this.addBody(_("Please confirm whether the PIN '%s' matches the one on the device.").format(pin));
-
- this.addButton('matches', _("Matches"));
- this.addButton('does-not-match', _("Does not match"));
-
- this.connect('action-invoked', Lang.bind(this, function(self, action) {
- if (action == 'matches')
- this._applet.agent_reply_confirm(this._devicePath, true);
- else
- this._applet.agent_reply_confirm(this._devicePath, false);
- this.destroy();
- }));
- }
-}
-
-function PinNotification() {
- this._init.apply(this, arguments);
-}
-
-PinNotification.prototype = {
- __proto__: MessageTray.Notification.prototype,
-
- _init: function(source, applet, device_path, name, long_name, numeric) {
- MessageTray.Notification.prototype._init.call(this,
- source,
- _("Bluetooth"),
- _("Pairing request for %s").format(name),
- { customContent: true });
- this.setResident(true);
-
- this._applet = applet;
- this._devicePath = device_path;
- this._numeric = numeric;
- this.addBody(_("Device %s wants to pair with this computer").format(long_name));
- this.addBody(_("Please enter the PIN mentioned on the device."));
+};
- this._entry = new St.Entry();
- this._entry.connect('key-release-event', Lang.bind(this, function(entry, event) {
- let key = event.get_key_symbol();
- if (key == Clutter.KEY_Return) {
- this.emit('action-invoked', 'ok');
- return true;
- } else if (key == Clutter.KEY_Escape) {
- this.emit('action-invoked', 'cancel');
- return true;
- }
- return false;
- }));
- this.addActor(this._entry);
-
- this.addButton('ok', _("OK"));
- this.addButton('cancel', _("Cancel"));
-
- this.connect('action-invoked', Lang.bind(this, function(self, action) {
- if (action == 'ok') {
- if (this._numeric) {
- let num = parseInt(this._entry.text);
- if (isNaN(num)) {
- // user reply was empty, or was invalid
- // cancel the operation
- num = -1;
- }
- this._applet.agent_reply_passkey(this._devicePath, num);
- } else
- this._applet.agent_reply_pincode(this._devicePath, this._entry.text);
- } else {
- if (this._numeric)
- this._applet.agent_reply_passkey(this._devicePath, -1);
- else
- this._applet.agent_reply_pincode(this._devicePath, null);
- }
- this.destroy();
- }));
- },
-
- grabFocus: function(lockTray) {
- MessageTray.Notification.prototype.grabFocus.call(this, lockTray);
- global.stage.set_key_focus(this._entry);
- }
+function main(metadata, orientation) {
+ let myApplet = new MyApplet(orientation);
+ return myApplet;
}
View
6 files/usr/share/cinnamon/applets/bluetooth@cinnamon.org/metadata.json
@@ -0,0 +1,6 @@
+{
+ "uuid": "bluetooth@cinnamon.org",
+ "name": "Bluetooth",
+ "description": "Cinnamon bluetooth management applet",
+ "icon": "bluetooth"
+}
View
107 js/ui/status/keyboard.js → ...n/applets/keyboard@cinnamon.org/applet.js
@@ -1,5 +1,4 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
+const Applet = imports.ui.applet;
const Clutter = imports.gi.Clutter;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gkbd = imports.gi.Gkbd;
@@ -38,47 +37,77 @@ LayoutMenuItem.prototype = {
}
};
-function XKBIndicator() {
- this._init.call(this);
+function MyMenu(launcher, orientation) {
+ this._init(launcher, orientation);
}
-XKBIndicator.prototype = {
- __proto__: PanelMenu.Button.prototype,
-
- _init: function() {
- PanelMenu.Button.prototype._init.call(this, St.Align.START);
-
- this._container = new Cinnamon.GenericContainer();
- this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
- this._container.connect('get-preferred-height', Lang.bind(this, this._containerGetPreferredHeight));
- this._container.connect('allocate', Lang.bind(this, this._containerAllocate));
- this.actor.add_actor(this._container);
- this.actor.add_style_class_name('panel-status-button');
-
- this._iconActor = new St.Icon({ icon_name: 'keyboard', icon_type: St.IconType.SYMBOLIC, style_class: 'system-status-icon' });
- this._container.add_actor(this._iconActor);
- this._labelActors = [ ];
- this._layoutItems = [ ];
+MyMenu.prototype = {
+ __proto__: PopupMenu.PopupMenu.prototype,
+
+ _init: function(launcher, orientation) {
+ this._launcher = launcher;
+
+ PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, 0.0, orientation, 0);
+ Main.uiGroup.add_actor(this.actor);
+ this.actor.hide();
+ }
+}
- this._showFlags = false;
- this._config = Gkbd.Configuration.get();
- this._config.connect('changed', Lang.bind(this, this._syncConfig));
- this._config.connect('group-changed', Lang.bind(this, this._syncGroup));
- this._config.start_listen();
+function MyApplet(orientation) {
+ this._init(orientation);
+}
- this._syncConfig();
+MyApplet.prototype = {
+ __proto__: Applet.Applet.prototype,
- if (global.session_type == Cinnamon.SessionType.USER) {
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, function() {
- Main.overview.hide();
- Util.spawn(['gkbd-keyboard-display', '-g', String(this._config.get_current_group() + 1)]);
- }));
+ _init: function(orientation) {
+ Applet.Applet.prototype._init.call(this, orientation);
+
+ try {
+ this.menuManager = new PopupMenu.PopupMenuManager(this);
+ this.menu = new MyMenu(this, orientation);
+ this.menuManager.addMenu(this.menu);
+
+ this._container = new Cinnamon.GenericContainer();
+ this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
+ this._container.connect('get-preferred-height', Lang.bind(this, this._containerGetPreferredHeight));
+ this._container.connect('allocate', Lang.bind(this, this._containerAllocate));
+ this.actor.add_actor(this._container);
+ this.actor.add_style_class_name('panel-status-button');
+
+ this._iconActor = new St.Icon({ icon_name: 'keyboard', icon_type: St.IconType.SYMBOLIC, style_class: 'system-status-icon' });
+ this._container.add_actor(this._iconActor);
+ this._labelActors = [ ];
+ this._layoutItems = [ ];
+
+ this._showFlags = false;
+ this._config = Gkbd.Configuration.get();
+ this._config.connect('changed', Lang.bind(this, this._syncConfig));
+ this._config.connect('group-changed', Lang.bind(this, this._syncGroup));
+ this._config.start_listen();
+
+ this._syncConfig();
+
+ if (global.session_type == Cinnamon.SessionType.USER) {
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, function() {
+ Main.overview.hide();
+ Util.spawn(['gkbd-keyboard-display', '-g', String(this._config.get_current_group() + 1)]);
+ }));
+ }
+ this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
+
+ }
+ catch (e) {
+ global.logError(e);
}
- this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop');
},
-
- _adjustGroupNames: function(names) {
+
+ on_applet_clicked: function(event) {
+ this.menu.toggle();
+ },
+
+ _adjustGroupNames: function(names) {
// Disambiguate duplicate names with a subscript
// This is O(N^2) to avoid sorting names
// but N <= 4 so who cares?
@@ -221,4 +250,10 @@ XKBIndicator.prototype = {
for (let i = 0; i < this._labelActors.length; i++)
this._labelActors[i].allocate_align_fill(box, 0.5, 0, false, false, flags);
}
+
};
+
+function main(metadata, orientation) {
+ let myApplet = new MyApplet(orientation);
+ return myApplet;
+}
View
6 files/usr/share/cinnamon/applets/keyboard@cinnamon.org/metadata.json
@@ -0,0 +1,6 @@
+{
+ "uuid": "keyboard@cinnamon.org",
+ "name": "Keyboard",
+ "description": "Keyboard layout",
+ "icon": "keyboard"
+}
View
320 js/ui/status/network.js → ...on/applets/network@cinnamon.org/applet.js
@@ -1,4 +1,4 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+const Applet = imports.ui.applet;
const ByteArray = imports.byteArray;
const DBus = imports.dbus;
const GLib = imports.gi.GLib;
@@ -1572,125 +1572,177 @@ NMDeviceWireless.prototype = {
},
};
-function NMApplet() {
- this._init.apply(this, arguments);
+function NMMessageTraySource() {
+ this._init();
}
-NMApplet.prototype = {
- __proto__: PanelMenu.SystemStatusButton.prototype,
+
+NMMessageTraySource.prototype = {
+ __proto__: MessageTray.Source.prototype,
_init: function() {
- PanelMenu.SystemStatusButton.prototype._init.call(this, 'network-error');
+ MessageTray.Source.prototype._init.call(this, _("Network Manager"));
- this._client = NMClient.Client.new();
+ let icon = new St.Icon({ icon_name: 'network-transmit-receive',
+ icon_type: St.IconType.SYMBOLIC,
+ icon_size: this.ICON_SIZE
+ });
+ this._setSummaryIcon(icon);
+ }
+};
- this._statusSection = new PopupMenu.PopupMenuSection();
- this._statusItem = new PopupMenu.PopupMenuItem('', { style_class: 'popup-inactive-menu-item', reactive: false });
- this._statusSection.addMenuItem(this._statusItem);
- this._statusSection.addAction(_("Enable networking"), Lang.bind(this, function() {
- this._client.networking_enabled = true;
- }));
- this._statusSection.actor.hide();
- this.menu.addMenuItem(this._statusSection);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this._devices = { };
+function MyMenu(launcher, orientation) {
+ this._init(launcher, orientation);
+}
- this._devices.wired = {
- section: new PopupMenu.PopupMenuSection(),
- devices: [ ],
- item: new NMWiredSectionTitleMenuItem(_("Wired"))
- };
+MyMenu.prototype = {
+ __proto__: PopupMenu.PopupMenu.prototype,
+
+ _init: function(launcher, orientation) {
+ this._launcher = launcher;
+
+ PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, 0.0, orientation, 0);
+ Main.uiGroup.add_actor(this.actor);
+ this.actor.hide();
+ }
+}
- this._devices.wired.section.addMenuItem(this._devices.wired.item);
- this._devices.wired.section.actor.hide();
- this.menu.addMenuItem(this._devices.wired.section);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+function MyApplet(orientation) {
+ this._init(orientation);
+}
- this._devices.wireless = {
- section: new PopupMenu.PopupMenuSection(),
- devices: [ ],
- item: this._makeToggleItem('wireless', _("Wireless"))
- };
- this._devices.wireless.section.addMenuItem(this._devices.wireless.item);
- this._devices.wireless.section.actor.hide();
- this.menu.addMenuItem(this._devices.wireless.section);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
-
- this._devices.wwan = {
- section: new PopupMenu.PopupMenuSection(),
- devices: [ ],
- item: this._makeToggleItem('wwan', _("Mobile broadband"))
- };
- this._devices.wwan.section.addMenuItem(this._devices.wwan.item);
- this._devices.wwan.section.actor.hide();
- this.menu.addMenuItem(this._devices.wwan.section);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
-
- this._devices.vpn = {
- section: new PopupMenu.PopupMenuSection(),
- device: new NMDeviceVPN(this._client),
- item: new NMWiredSectionTitleMenuItem(_("VPN Connections"))
- };
- this._devices.vpn.device.connect('active-connection-changed', Lang.bind(this, function() {
+MyApplet.prototype = {
+ __proto__: Applet.IconApplet.prototype,
+
+ _init: function(orientation) {
+ Applet.IconApplet.prototype._init.call(this, orientation);
+
+ try {
+ this.menuManager = new PopupMenu.PopupMenuManager(this);
+ this.menu = new MyMenu(this, orientation);
+ this.menuManager.addMenu(this.menu);
+
+ this.set_applet_icon_symbolic_name('network-error');
+
+ this._client = NMClient.Client.new();
+
+ this._statusSection = new PopupMenu.PopupMenuSection();
+ this._statusItem = new PopupMenu.PopupMenuItem('', { style_class: 'popup-inactive-menu-item', reactive: false });
+ this._statusSection.addMenuItem(this._statusItem);
+ this._statusSection.addAction(_("Enable networking"), Lang.bind(this, function() {
+ this._client.networking_enabled = true;
+ }));
+ this._statusSection.actor.hide();
+ this.menu.addMenuItem(this._statusSection);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+
+ this._devices = { };
+
+ this._devices.wired = {
+ section: new PopupMenu.PopupMenuSection(),
+ devices: [ ],
+ item: new NMWiredSectionTitleMenuItem(_("Wired"))
+ };
+
+ this._devices.wired.section.addMenuItem(this._devices.wired.item);
+ this._devices.wired.section.actor.hide();
+ this.menu.addMenuItem(this._devices.wired.section);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+
+ this._devices.wireless = {
+ section: new PopupMenu.PopupMenuSection(),
+ devices: [ ],
+ item: this._makeToggleItem('wireless', _("Wireless"))
+ };
+ this._devices.wireless.section.addMenuItem(this._devices.wireless.item);
+ this._devices.wireless.section.actor.hide();
+ this.menu.addMenuItem(this._devices.wireless.section);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+
+ this._devices.wwan = {
+ section: new PopupMenu.PopupMenuSection(),
+ devices: [ ],
+ item: this._makeToggleItem('wwan', _("Mobile broadband"))
+ };
+ this._devices.wwan.section.addMenuItem(this._devices.wwan.item);
+ this._devices.wwan.section.actor.hide();
+ this.menu.addMenuItem(this._devices.wwan.section);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+
+ this._devices.vpn = {
+ section: new PopupMenu.PopupMenuSection(),
+ device: new NMDeviceVPN(this._client),
+ item: new NMWiredSectionTitleMenuItem(_("VPN Connections"))
+ };
+ this._devices.vpn.device.connect('active-connection-changed', Lang.bind(this, function() {
+ this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
+ }));
this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
- }));
- this._devices.vpn.item.updateForDevice(this._devices.vpn.device);
- this._devices.vpn.section.addMenuItem(this._devices.vpn.item);
- this._devices.vpn.section.addMenuItem(this._devices.vpn.device.section);
- this._devices.vpn.section.actor.hide();
- this.menu.addMenuItem(this._devices.vpn.section);
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
-
- this._activeConnections = [ ];
- this._connections = [ ];
+ this._devices.vpn.section.addMenuItem(this._devices.vpn.item);
+ this._devices.vpn.section.addMenuItem(this._devices.vpn.device.section);
+ this._devices.vpn.section.actor.hide();
+ this.menu.addMenuItem(this._devices.vpn.section);
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this.menu.addSettingsAction(_("Network Settings"), 'gnome-network-panel.desktop');
- this._mainConnection = null;
- this._activeAccessPointUpdateId = 0;
- this._activeAccessPoint = null;
- this._mobileUpdateId = 0;
- this._mobileUpdateDevice = null;
-
- // Device types
- this._dtypes = { };
- this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired;
- this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless;
- this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem;
- this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth;
- // TODO: WiMax support
-
- // Connection types
- this._ctypes = { };
- this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
- this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
- this._ctypes[NetworkManager.SETTING_PPPOE_SETTING_NAME] = NMConnectionCategory.WIRED;
- this._ctypes[NetworkManager.SETTING_PPP_SETTING_NAME] = NMConnectionCategory.WIRED;
- this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
- this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
- this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
- this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
-
- this._settings = NMClient.RemoteSettings.new(null);
- this._connectionsReadId = this._settings.connect('connections-read', Lang.bind(this, function() {
- this._readConnections();
- this._readDevices();
- this._syncNMState();
-
- // Connect to signals late so that early signals don't find in inconsistent state
- // and connect only once (this signal handler can be called again if NetworkManager goes up and down)
- if (!this._inited) {
- this._inited = true;
- this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState));
- this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState));
- this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
- this._client.connect('notify::active-connections', Lang.bind(this, this._updateIcon));
- this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
- this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
- this._settings.connect('new-connection', Lang.bind(this, this._newConnection));
- }
- }));
- },
+ this._activeConnections = [ ];
+ this._connections = [ ];
+
+ this._mainConnection = null;
+ this._activeAccessPointUpdateId = 0;
+ this._activeAccessPoint = null;
+ this._mobileUpdateId = 0;
+ this._mobileUpdateDevice = null;
+ // Device types
+ this._dtypes = { };
+ this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired;
+ this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless;
+ this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem;
+ this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth;
+ // TODO: WiMax support
+
+ // Connection types
+ this._ctypes = { };
+ this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
+ this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
+ this._ctypes[NetworkManager.SETTING_PPPOE_SETTING_NAME] = NMConnectionCategory.WIRED;
+ this._ctypes[NetworkManager.SETTING_PPP_SETTING_NAME] = NMConnectionCategory.WIRED;
+ this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
+ this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
+ this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
+ this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
+
+ this._settings = NMClient.RemoteSettings.new(null);
+ this._connectionsReadId = this._settings.connect('connections-read', Lang.bind(this, function() {
+ this._readConnections();
+ this._readDevices();
+ this._syncNMState();
+
+ // Connect to signals late so that early signals don't find in inconsistent state
+ // and connect only once (this signal handler can be called again if NetworkManager goes up and down)
+ if (!this._inited) {
+ this._inited = true;
+ this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState));
+ this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState));
+ this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
+ this._client.connect('notify::active-connections', Lang.bind(this, this._updateIcon));
+ this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
+ this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
+ this._settings.connect('new-connection', Lang.bind(this, this._newConnection));
+ }
+ }));
+
+ }
+ catch (e) {
+ global.logError(e);
+ }
+ },
+
+ on_applet_clicked: function(event) {
+ this.menu.toggle();
+ },
+
_ensureSource: function() {
if (!this._source) {
this._source = new NMMessageTraySource();
@@ -2026,7 +2078,7 @@ NMApplet.prototype = {
this.actor.show();
if (!this._client.networking_enabled) {
- this.setIcon('network-offline');
+ this.set_applet_icon_symbolic_name('network-offline');
this._hideDevices();
this._statusItem.label.text = _("Networking is disabled");
this._statusSection.actor.show();
@@ -2044,25 +2096,25 @@ NMApplet.prototype = {
let hasMobileIcon = false;
if (!mc) {
- this.setIcon('network-offline');
+ this.set_applet_icon_symbolic_name('network-offline');
} else if (mc.state == NetworkManager.ActiveConnectionState.ACTIVATING) {
switch (mc._section) {
case NMConnectionCategory.WWAN:
- this.setIcon('network-cellular-acquiring');
+ this.set_applet_icon_symbolic_name('network-cellular-acquiring');
break;
case NMConnectionCategory.WIRELESS:
- this.setIcon('network-wireless-acquiring');
+ this.set_applet_icon_symbolic_name('network-wireless-acquiring');
break;
case NMConnectionCategory.WIRED:
- this.setIcon('network-wired-acquiring');
+ this.set_applet_icon_symbolic_name('network-wired-acquiring');
break;
case NMConnectionCategory.VPN:
- this.setIcon('network-vpn-acquiring');
+ this.set_applet_icon_symbolic_name('network-vpn-acquiring');
break;
default:
// fallback to a generic connected icon
// (it could be a private connection of some other user)
- this.setIcon('network-wired-acquiring');
+ this.set_applet_icon_symbolic_name('network-wired-acquiring');
}
} else {
let dev;
@@ -2077,16 +2129,16 @@ NMApplet.prototype = {
log('An active wireless connection, in infrastructure mode, involves no access point?');
break;
}
- this.setIcon('network-wireless-connected');
+ this.set_applet_icon_symbolic_name('network-wireless-connected');
} else {
if (this._accessPointUpdateId && this._activeAccessPoint != ap) {
this._activeAccessPoint.disconnect(this._accessPointUpdateId);
this._activeAccessPoint = ap;
this._activeAccessPointUpdateId = ap.connect('notify::strength', Lang.bind(function() {
- this.setIcon('network-wireless-signal-' + signalToIcon(ap.strength));
+ this.set_applet_icon_symbolic_name('network-wireless-signal-' + signalToIcon(ap.strength));
}));
}
- this.setIcon('network-wireless-signal-' + signalToIcon(ap.strength));
+ this.set_applet_icon_symbolic_name('network-wireless-signal-' + signalToIcon(ap.strength));
hasApIcon = true;
}
break;
@@ -2095,7 +2147,7 @@ NMApplet.prototype = {
break;
}
case NMConnectionCategory.WIRED:
- this.setIcon('network-wired');
+ this.set_applet_icon_symbolic_name('network-wired');
break;
case NMConnectionCategory.WWAN:
dev = mc._primaryDevice;
@@ -2105,27 +2157,27 @@ NMApplet.prototype = {
}
if (!dev.mobileDevice) {
// this can happen for bluetooth in PAN mode
- this.setIcon('network-cellular-connected');
+ this.set_applet_icon_symbolic_name('network-cellular-connected');
break;
}
if (this._mobileUpdateId && this._mobileUpdateDevice != dev) {
this._mobileUpdateDevice.disconnect(this._mobileUpdateId);
this._mobileUpdateDevice = dev.mobileDevice;
this._mobileUpdateId = dev.mobileDevice.connect('notify::signal-quality', Lang.bind(this, function() {
- this.setIcon('network-cellular-signal-' + signalToIcon(dev.mobileDevice.signal_quality));
+ this.set_applet_icon_symbolic_name('network-cellular-signal-' + signalToIcon(dev.mobileDevice.signal_quality));
}));
}
- this.setIcon('network-cellular-signal-' + signalToIcon(dev.mobileDevice.signal_quality));
+ this.set_applet_icon_symbolic_name('network-cellular-signal-' + signalToIcon(dev.mobileDevice.signal_quality));
hasMobileIcon = true;
break;
case NMConnectionCategory.VPN:
- this.setIcon('network-vpn');
+ this.set_applet_icon_symbolic_name('network-vpn');
break;
default:
// fallback to a generic connected icon
// (it could be a private connection of some other user)
- this.setIcon('network-wired');
+ this.set_applet_icon_symbolic_name('network-wired');
break;
}
}
@@ -2143,22 +2195,10 @@ NMApplet.prototype = {
this._mobileUpdateId = 0;
}
}
+
};
-function NMMessageTraySource() {
- this._init();
+function main(metadata, orientation) {
+ let myApplet = new MyApplet(orientation);
+ return myApplet;
}
-
-NMMessageTraySource.prototype = {
- __proto__: MessageTray.Source.prototype,
-
- _init: function() {
- MessageTray.Source.prototype._init.call(this, _("Network Manager"));
-
- let icon = new St.Icon({ icon_name: 'network-transmit-receive',
- icon_type: St.IconType.SYMBOLIC,
- icon_size: this.ICON_SIZE
- });
- this._setSummaryIcon(icon);
- }
-};
View
6 files/usr/share/cinnamon/applets/network@cinnamon.org/metadata.json
@@ -0,0 +1,6 @@
+{
+ "uuid": "network@cinnamon.org",
+ "name": "Network Manager",
+ "description": "Network manager applet",
+ "icon": "network-idle"
+}
View
162 js/ui/status/power.js → ...amon/applets/power@cinnamon.org/applet.js
@@ -1,12 +1,10 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
+const Applet = imports.ui.applet;
const Gio = imports.gi.Gio;
const DBus = imports.dbus;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Cinnamon = imports.gi.Cinnamon;
const St = imports.gi.St;
-
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
@@ -55,46 +53,77 @@ const PowerManagerInterface = {
};
let PowerManagerProxy = DBus.makeProxyClass(PowerManagerInterface);
-function Indicator() {
- this._init.apply(this, arguments);
+function MyMenu(launcher, orientation) {
+ this._init(launcher, orientation);
}
-Indicator.prototype = {
- __proto__: PanelMenu.SystemStatusButton.prototype,
-
- _init: function() {
- PanelMenu.SystemStatusButton.prototype._init.call(this, 'battery-missing');
- this._proxy = new PowerManagerProxy(DBus.session, BUS_NAME, OBJECT_PATH);
-
- let icon = this.actor.get_children()[0];
- this.actor.remove_actor(icon);
- let box = new St.BoxLayout({ name: 'batteryBox' });
- this.actor.add_actor(box);
- let iconBox = new St.Bin();
- box.add(iconBox, { y_align: St.Align.MIDDLE, y_fill: false });
- this._mainLabel = new St.Label();
- box.add(this._mainLabel, { y_align: St.Align.MIDDLE, y_fill: false });
- iconBox.child = icon;
-
- this._deviceItems = [ ];
- this._hasPrimary = false;
- this._primaryDeviceId = null;
-
- this._batteryItem = new PopupMenu.PopupMenuItem('', { reactive: false });
- this._primaryPercentage = new St.Label();
- this._batteryItem.addActor(this._primaryPercentage, { align: St.Align.END });
- this.menu.addMenuItem(this._batteryItem);
+MyMenu.prototype = {
+ __proto__: PopupMenu.PopupMenu.prototype,
+
+ _init: function(launcher, orientation) {
+ this._launcher = launcher;
+
+ PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, 0.0, orientation, 0);
+ Main.uiGroup.add_actor(this.actor);
+ this.actor.hide();
+ }
+}
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this._otherDevicePosition = 2;
+function MyApplet(orientation) {
+ this._init(orientation);
+}
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this.menu.addSettingsAction(_("Power Settings"), 'gnome-power-panel.desktop');
+MyApplet.prototype = {
+ __proto__: Applet.TextIconApplet.prototype,
- this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
- this._devicesChanged();
+ _init: function(orientation) {
+ Applet.TextIconApplet.prototype._init.call(this, orientation);
+
+ try {
+ this.menuManager = new PopupMenu.PopupMenuManager(this);
+ this.menu = new MyMenu(this, orientation);
+ this.menuManager.addMenu(this.menu);
+
+ this.set_applet_icon_symbolic_name('battery-missing');
+ this._proxy = new PowerManagerProxy(DBus.session, BUS_NAME, OBJECT_PATH);
+
+ let icon = this.actor.get_children()[0];
+ this.actor.remove_actor(icon);
+ let box = new St.BoxLayout({ name: 'batteryBox' });
+ this.actor.add_actor(box);
+ let iconBox = new St.Bin();
+ box.add(iconBox, { y_align: St.Align.MIDDLE, y_fill: false });
+ this._mainLabel = new St.Label();
+ box.add(this._mainLabel, { y_align: St.Align.MIDDLE, y_fill: false });
+ iconBox.child = icon;
+
+ this._deviceItems = [ ];
+ this._hasPrimary = false;
+ this._primaryDeviceId = null;
+
+ this._batteryItem = new PopupMenu.PopupMenuItem('', { reactive: false });
+ this._primaryPercentage = new St.Label();
+ this._batteryItem.addActor(this._primaryPercentage, { align: St.Align.END });
+ this.menu.addMenuItem(this._batteryItem);
+
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this._otherDevicePosition = 2;
+
+ this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
+ this.menu.addSettingsAction(_("Power Settings"), 'gnome-power-panel.desktop');
+
+ this._proxy.connect('Changed', Lang.bind(this, this._devicesChanged));
+ this._devicesChanged();
+ }
+ catch (e) {
+ global.logError(e);
+ }
},
-
+
+ on_applet_clicked: function(event) {
+ this.menu.toggle();
+ },
+
_readPrimaryDevice: function() {
this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(device, error) {
if (error) {
@@ -196,61 +225,10 @@ Indicator.prototype = {
this._mainLabel.set_text("");
}));
}
+
};
-function DeviceItem() {
- this._init.apply(this, arguments);
-}
-
-DeviceItem.prototype = {
- __proto__: PopupMenu.PopupBaseMenuItem.prototype,
-
- _init: function(device) {
- PopupMenu.PopupBaseMenuItem.prototype._init.call(this, { reactive: false });
-
- let [device_id, device_type, icon, percentage, state, time] = device;
-
- this._box = new St.BoxLayout({ style_class: 'popup-device-menu-item' });
- this._label = new St.Label({ text: this._deviceTypeToString(device_type) });
-
- this._icon = new St.Icon({ gicon: Gio.icon_new_for_string(icon),
- icon_type: St.IconType.SYMBOLIC,
- style_class: 'popup-menu-icon' });
-
- this._box.add_actor(this._icon);
- this._box.add_actor(this._label);
- this.addActor(this._box);
-
- let percentLabel = new St.Label({ text: C_("percent of battery remaining", "%d%%").format(Math.round(percentage)) });
- this.addActor(percentLabel, { align: St.Align.END });
- },
-
- _deviceTypeToString: function(type) {
- switch (type) {
- case UPDeviceType.AC_POWER:
- return _("AC adapter");
- case UPDeviceType.BATTERY:
- return _("Laptop battery");
- case UPDeviceType.UPS:
- return _("UPS");
- case UPDeviceType.MONITOR:
- return _("Monitor");
- case UPDeviceType.MOUSE:
- return _("Mouse");
- case UPDeviceType.KEYBOARD:
- return _("Keyboard");
- case UPDeviceType.PDA:
- return _("PDA");
- case UPDeviceType.PHONE:
- return _("Cell phone");
- case UPDeviceType.MEDIA_PLAYER:
- return _("Media player");
- case UPDeviceType.TABLET:
- return _("Tablet");
- case UPDeviceType.COMPUTER:
- return _("Computer");
- default:
- return _("Unknown");
- }
- }
+function main(metadata, orientation) {
+ let myApplet = new MyApplet(orientation);
+ return myApplet;
}
View
6 files/usr/share/cinnamon/applets/power@cinnamon.org/metadata.json
@@ -0,0 +1,6 @@
+{
+ "uuid": "power@cinnamon.org",
+ "name": "Power Manager",
+ "description": "Cinnamon power management applet",
+ "icon": "battery-full-charging"
+}
View
129 js/ui/status/volume.js → ...amon/applets/sound@cinnamon.org/applet.js
@@ -1,5 +1,4 @@
-/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
-
+const Applet = imports.ui.applet;
const Mainloop = imports.mainloop;
const Gio = imports.gi.Gio;
const DBus = imports.dbus;
@@ -638,50 +637,84 @@ MediaPlayerLauncher.prototype = {
};
-function Indicator() {
- this._init.apply(this, arguments);
+function MyMenu(launcher, orientation) {
+ this._init(launcher, orientation);
}
-Indicator.prototype = {
- __proto__: PanelMenu.SystemStatusButton.prototype,
-
- _init: function() {
- PanelMenu.SystemStatusButton.prototype._init.call(this, 'audio-x-generic', null);
- // menu not showed by default
- this._players = {};
- // watch players
- for (var p=0; p<compatible_players.length; p++) {
- DBus.session.watch_name('org.mpris.MediaPlayer2.'+compatible_players[p], false,
- Lang.bind(this, this._addPlayer),
- Lang.bind(this, this._removePlayer)
- );
- }
-
- this._control = new Gvc.MixerControl({ name: 'Cinnamon Volume Control' });
- this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));
- this._control.connect('default-sink-changed', Lang.bind(this, this._readOutput));
- this._control.connect('default-source-changed', Lang.bind(this, this._readInput));
- this._control.connect('stream-added', Lang.bind(this, this._maybeShowInput));
- this._control.connect('stream-removed', Lang.bind(this, this._maybeShowInput));
- this._volumeMax = 1.5*this._control.get_vol_max_norm();
-
- this._output = null;
- this._outputVolumeId = 0;
- this._outputMutedId = 0;
+MyMenu.prototype = {
+ __proto__: PopupMenu.PopupMenu.prototype,
+
+ _init: function(launcher, orientation) {
+ this._launcher = launcher;
+
+ PopupMenu.PopupMenu.prototype._init.call(this, launcher.actor, 0.0, orientation, 0);
+ Main.uiGroup.add_actor(this.actor);
+ this.actor.hide();
+ }
+}
- this._input = null;
- this._inputVolumeId = 0;
- this._inputMutedId = 0;
-
- this._icon_name = '';
-
- this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
-
- this._control.open();
-
- this._volumeControlShown = false;
+function MyApplet(orientation) {
+ this._init(orientation);
+}
+
+MyApplet.prototype = {
+ __proto__: Applet.IconApplet.prototype,
+
+ _init: function(orientation) {
+ Applet.IconApplet.prototype._init.call(this, orientation);
- this._showFixedElements();
+ try {
+ this.menuManager = new PopupMenu.PopupMenuManager(this);
+ this.menu = new MyMenu(this, orientation);
+ this.menuManager.addMenu(this.menu);
+
+ this.set_applet_icon_symbolic_name('audio-x-generic');
+
+ // menu not showed by default
+ this._players = {};
+ // watch players
+ for (var p=0; p<compatible_players.length; p++) {
+ DBus.session.watch_name('org.mpris.MediaPlayer2.'+compatible_players[p], false,
+ Lang.bind(this, this._addPlayer),
+ Lang.bind(this, this._removePlayer)
+ );
+ }
+
+ this._control = new Gvc.MixerControl({ name: 'Cinnamon Volume Control' });
+ this._control.connect('state-changed', Lang.bind(this, this._onControlStateChanged));
+ this._control.connect('default-sink-changed', Lang.bind(this, this._readOutput));
+ this._control.connect('default-source-changed', Lang.bind(this, this._readInput));
+ this._control.connect('stream-added', Lang.bind(this, this._maybeShowInput));
+ this._control.connect('stream-removed', Lang.bind(this, this._maybeShowInput));
+ this._volumeMax = 1.5*this._control.get_vol_max_norm();
+
+ this._output = null;
+ this._outputVolumeId = 0;
+ this._outputMutedId = 0;
+
+ this._input = null;
+ this._inputVolumeId = 0;
+ this._inputMutedId = 0;
+
+ this._icon_name = '';
+
+ this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
+
+ this._control.open();
+
+ this._volumeControlShown = false;
+
+ this._showFixedElements();
+
+
+ }
+ catch (e) {
+ global.logError(e);
+ }
+ },
+
+ on_applet_clicked: function(event) {
+ this.menu.toggle();
},
_onScrollEvent: function(actor, event) {
@@ -710,9 +743,9 @@ Indicator.prototype = {
setIconName: function(icon) {
this._icon_name = icon;
if (this._nbPlayers()==0)
- this.setIcon(icon);
+ this.set_applet_icon_symbolic_name(icon);
else
- this.setIcon('audio-x-generic');
+ this.set_applet_icon_symbolic_name('audio-x-generic');
},
_nbPlayers: function() {
@@ -975,5 +1008,11 @@ Indicator.prototype = {
this._inputTitle.actor.hide();
this._inputSlider.actor.hide();
}
- },
+ }
+
};
+
+function main(metadata, orientation) {
+ let myApplet = new MyApplet(orientation);
+ return myApplet;
+}
View
6 files/usr/share/cinnamon/applets/sound@cinnamon.org/metadata.json
@@ -0,0 +1,6 @@
+{
+ "uuid": "sound@cinnamon.org",
+ "name": "Sound",
+ "description": "Cinnamon sound applet",
+ "icon": "stock_volume"
+}
View
6 js/Makefile.am
@@ -57,12 +57,6 @@ nobase_dist_js_DATA = \
ui/search.js \
ui/cinnamonDBus.js \
ui/statusIconDispatcher.js \
- ui/status/accessibility.js \
- ui/status/keyboard.js \
- ui/status/network.js \
- ui/status/power.js \
- ui/status/volume.js \
- ui/status/bluetooth.js \
ui/themeManager.js \
ui/tooltips.js \
ui/tweener.js \
View
6 js/Makefile.in
@@ -348,12 +348,6 @@ nobase_dist_js_DATA = \
ui/search.js \
ui/cinnamonDBus.js \
ui/statusIconDispatcher.js \
- ui/status/accessibility.js \
- ui/status/keyboard.js \
- ui/status/network.js \
- ui/status/power.js \
- ui/status/volume.js \
- ui/status/bluetooth.js \
ui/themeManager.js \
ui/tooltips.js \
ui/tweener.js \
View
5 js/ui/applet.js
@@ -137,6 +137,11 @@ IconApplet.prototype = {
this._applet_icon_box.child = this._applet_icon;
},
+ set_applet_icon_symbolic_name: function (icon_name) {
+ this._applet_icon = new St.Icon({icon_name: icon_name, icon_type: St.IconType.SYMBOLIC, reactive: true, track_hover: true, style_class: 'system-status-icon' });
+ this._applet_icon_box.child = this._applet_icon;
+ },
+
set_applet_icon_path: function (icon_path) {
let file = Gio.file_new_for_path(icon_path);
let icon_uri = file.get_uri();
View
4 js/ui/main.js
@@ -247,9 +247,7 @@ function start() {
_createUserSession();
else if (global.session_type == Cinnamon.SessionType.GDM)
_createGDMSession();
-
- panel.startStatusArea();
-
+
layoutManager.init();
keyboard.init();
overview.init();
View
32 js/ui/panel.js
@@ -19,8 +19,6 @@ const Main = imports.ui.main;
const Tweener = imports.ui.tweener;
const Meta = imports.gi.Meta;
-
-
const PANEL_ICON_SIZE = 24;
const PANEL_ICON_DEFAULT_SIZE = 22;
@@ -29,32 +27,15 @@ const BUTTON_DND_ACTIVATION_TIMEOUT = 250;
const ANIMATED_ICON_UPDATE_TIMEOUT = 100;
const SPINNER_ANIMATION_TIME = 0.2;
-const STANDARD_STATUS_AREA_ORDER = ['keyboard', 'volume', 'bluetooth', 'network', 'battery'];
-const STANDARD_STATUS_AREA_CINNAMON_IMPLEMENTATION = {
- 'volume': imports.ui.status.volume.Indicator,
- 'battery': imports.ui.status.power.Indicator,
- 'keyboard': imports.ui.status.keyboard.XKBIndicator
-};
+const STANDARD_STATUS_AREA_ORDER = [];
+const STANDARD_STATUS_AREA_CINNAMON_IMPLEMENTATION = {};
const PANEL_HEIGHT = 25;
const AUTOHIDE_ANIMATION_TIME = 0.2;
const TIME_DELTA = 1500;
-if (Config.HAVE_BLUETOOTH)
- STANDARD_STATUS_AREA_CINNAMON_IMPLEMENTATION['bluetooth'] = imports.ui.status.bluetooth.Indicator;
-
-try {
- STANDARD_STATUS_AREA_CINNAMON_IMPLEMENTATION['network'] = imports.ui.status.network.NMApplet;
-} catch(e) {
- log('NMApplet is not supported. It is possible that your NetworkManager version is too old');
-}
-
-const GDM_STATUS_AREA_ORDER = ['a11y', 'display', 'keyboard', 'volume', 'battery', 'powerMenu'];
-const GDM_STATUS_AREA_CINNAMON_IMPLEMENTATION = {
- 'a11y': imports.ui.status.accessibility.ATIndicator,
- 'volume': imports.ui.status.volume.Indicator,
- 'battery': imports.ui.status.power.Indicator,
- 'keyboard': imports.ui.status.keyboard.XKBIndicator,
+const GDM_STATUS_AREA_ORDER = ['display', 'powerMenu'];
+const GDM_STATUS_AREA_CINNAMON_IMPLEMENTATION = {
'powerMenu': imports.gdm.powerMenu.PowerMenuButton
};
@@ -665,6 +646,11 @@ Panel.prototype = {
// Hide it
return;
}
+
+ if (role == "network") {
+ // We've got an applet for that
+ return;
+ }
//icon.height = PANEL_ICON_SIZE;
let buttonBox = new PanelMenu.ButtonBox({ style_class: 'panel-status-button' });
View
200 js/ui/status/accessibility.js
@@ -1,200 +0,0 @@
-// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-
-const DBus = imports.dbus;
-const GConf = imports.gi.GConf;
-const Gio = imports.gi.Gio;
-const Gtk = imports.gi.Gtk;
-const Lang = imports.lang;
-const Mainloop = imports.mainloop;
-const Cinnamon = imports.gi.Cinnamon;
-const Signals = imports.signals;
-const St = imports.gi.St;
-
-const Main = imports.ui.main;
-const PanelMenu = imports.ui.panelMenu;
-const PopupMenu = imports.ui.popupMenu;
-const Util = imports.misc.util;
-
-const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
-const KEY_STICKY_KEYS_ENABLED = 'stickykeys-enable';
-const KEY_BOUNCE_KEYS_ENABLED = 'bouncekeys-enable';
-const KEY_SLOW_KEYS_ENABLED = 'slowkeys-enable';
-const KEY_MOUSE_KEYS_ENABLED = 'mousekeys-enable';
-
-const APPLICATIONS_SCHEMA = 'org.gnome.desktop.a11y.applications';
-
-const DPI_LOW_REASONABLE_VALUE = 50;
-const DPI_HIGH_REASONABLE_VALUE = 500;
-
-const DPI_FACTOR_LARGE = 1.25;
-const DPI_FACTOR_LARGER = 1.5;
-const DPI_FACTOR_LARGEST = 2.0;
-
-const KEY_META_DIR = '/apps/metacity/general';
-const KEY_VISUAL_BELL = KEY_META_DIR + '/visual_bell';
-
-const DESKTOP_INTERFACE_SCHEMA = 'org.gnome.desktop.interface';
-const KEY_GTK_THEME = 'gtk-theme';
-const KEY_ICON_THEME = 'icon-theme';
-const KEY_TEXT_SCALING_FACTOR = 'text-scaling-factor';
-
-const HIGH_CONTRAST_THEME = 'HighContrast';
-
-function ATIndicator() {
- this._init.apply(this, arguments);
-}
-
-ATIndicator.prototype = {
- __proto__: PanelMenu.SystemStatusButton.prototype,
-
- _init: function() {
- PanelMenu.SystemStatusButton.prototype._init.call(this, 'preferences-desktop-accessibility', null);
-
- let client = GConf.Client.get_default();
- client.add_dir(KEY_META_DIR, GConf.ClientPreloadType.PRELOAD_ONELEVEL, null);
- client.notify_add(KEY_META_DIR, Lang.bind(this, this._keyChanged), null, null);
-
- let highContrast = this._buildHCItem();
- this.menu.addMenuItem(highContrast);
-
- let magnifier = this._buildItem(_("Zoom"), APPLICATIONS_SCHEMA,
- 'screen-magnifier-enabled');
- this.menu.addMenuItem(magnifier);
-
- let textZoom = this._buildFontItem();
- this.menu.addMenuItem(textZoom);
-
-// let screenReader = this._buildItem(_("Screen Reader"), APPLICATIONS_SCHEMA,
-// 'screen-reader-enabled');
-// this.menu.addMenuItem(screenReader);
-
- let screenKeyboard = this._buildItem(_("Screen Keyboard"), APPLICATIONS_SCHEMA,
- 'screen-keyboard-enabled');
- this.menu.addMenuItem(screenKeyboard);
-
- let visualBell = this._buildItemGConf(_("Visual Alerts"), client, KEY_VISUAL_BELL);
- this.menu.addMenuItem(visualBell);
-
- let stickyKeys = this._buildItem(_("Sticky Keys"), A11Y_SCHEMA, KEY_STICKY_KEYS_ENABLED);
- this.menu.addMenuItem(stickyKeys);
-
- let slowKeys = this._buildItem(_("Slow Keys"), A11Y_SCHEMA, KEY_SLOW_KEYS_ENABLED);
- this.menu.addMenuItem(slowKeys);
-
- let bounceKeys = this._buildItem(_("Bounce Keys"), A11Y_SCHEMA, KEY_BOUNCE_KEYS_ENABLED);
- this.menu.addMenuItem(bounceKeys);
-
- let mouseKeys = this._buildItem(_("Mouse Keys"), A11Y_SCHEMA, KEY_MOUSE_KEYS_ENABLED);
- this.menu.addMenuItem(mouseKeys);
-
- this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
- this.menu.addSettingsAction(_("Universal Access Settings"), 'gnome-universal-access-panel.desktop');
- },
-
- _buildItemExtended: function(string, initial_value, writable, on_set) {
- let widget = new PopupMenu.PopupSwitchMenuItem(string, initial_value);
- if (!writable)
- widget.actor.reactive = false;
- else
- widget.connect('toggled', function(item) {
- on_set(item.state);
- });
- return widget;
- },
-
- _buildItemGConf: function(string, client, key) {
- function on_get() {
- return client.get_bool(key);
- }
- let widget = this._buildItemExtended(string,
- client.get_bool(key),
- client.key_is_writable(key),
- function(enabled) {
- client.set_bool(key, enabled);
- });
- this.connect('gconf-changed', function() {
- widget.setToggleState(client.get_bool(key));
- });
- return widget;
- },
-
- _buildItem: function(string, schema, key) {
- let settings = new Gio.Settings({ schema: schema });
- let widget = this._buildItemExtended(string,
- settings.get_boolean(key),
- settings.is_writable(key),
- function(enabled) {
- return settings.set_boolean(key, enabled);
- });
- settings.connect('changed::'+key, function() {
- widget.setToggleState(settings.get_boolean(key));
- });
- return widget;
- },
-
- _buildHCItem: function() {
- let settings = new Gio.Settings({ schema: DESKTOP_INTERFACE_SCHEMA });
- let gtkTheme = settings.get_string(KEY_GTK_THEME);
- let iconTheme = settings.get_string(KEY_ICON_THEME);
- let hasHC = (gtkTheme == HIGH_CONTRAST_THEME);
- let highContrast = this._buildItemExtended(
- _("High Contrast"),
- hasHC,
- settings.is_writable(KEY_GTK_THEME) && settings.is_writable(KEY_ICON_THEME),
- function (enabled) {
- if (enabled) {
- settings.set_string(KEY_GTK_THEME, HIGH_CONTRAST_THEME);
- settings.set_string(KEY_ICON_THEME, HIGH_CONTRAST_THEME);
- } else if(!hasHC) {
- settings.set_string(KEY_GTK_THEME, gtkTheme);
- settings.set_string(KEY_ICON_THEME, iconTheme);
- } else {
- settings.reset(KEY_GTK_THEME);
- settings.reset(KEY_ICON_THEME);
- }
- });
- settings.connect('changed::' + KEY_GTK_THEME, function() {
- let value = settings.get_string(KEY_GTK_THEME);
- if (value == HIGH_CONTRAST_THEME) {
- highContrast.setToggleState(true);
- } else {
- highContrast.setToggleState(false);
- gtkTheme = value;
- }
- });
- settings.connect('changed::' + KEY_ICON_THEME, function() {
- let value = settings.get_string(KEY_ICON_THEME);
- if (value != HIGH_CONTRAST_THEME)
- iconTheme = value;
- });
- return highContrast;
- },
-
- _buildFontItem: function() {
- let settings = new Gio.Settings({ schema: DESKTOP_INTERFACE_SCHEMA });
-
- let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
- let initial_setting = (factor > 1.0);
- let widget = this._buildItemExtended(_("Large Text"),
- initial_setting,
- settings.is_writable(KEY_TEXT_SCALING_FACTOR),
- function (enabled) {
- if (enabled)
- settings.set_double(KEY_TEXT_SCALING_FACTOR,
- DPI_FACTOR_LARGE);
- else
- settings.reset(KEY_TEXT_SCALING_FACTOR);
- });
- settings.connect('changed::' + KEY_TEXT_SCALING_FACTOR, function() {
- let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
- let active = (factor > 1.0);
- widget.setToggleState(active);
- });
- return widget;
- },
-
- _keyChanged: function() {
- this.emit('gconf-changed');
- }
-};
-Signals.addSignalMethods(ATIndicator.prototype);

0 comments on commit 30d1c58

Please sign in to comment.
Something went wrong with that request. Please try again.