Skip to content

Commit 7be781a

Browse files
committed
applets: Use new keybinding api for xlets.
1 parent 40e360d commit 7be781a

File tree

8 files changed

+23
-18
lines changed

8 files changed

+23
-18
lines changed

docs/applets-examples/[email protected]/applet.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,11 @@ MyApplet.prototype =
289289

290290
on_launch_shortcut_changed: function()
291291
{
292-
Main.keybindingManager.addHotKey("finder_launch", this.launch_shortcut, Lang.bind(this, this.launch));
292+
Main.keybindingManager.addXletHotKey(this, "finder_launch", this.launch_shortcut, Lang.bind(this, this.launch));
293+
},
294+
295+
on_applet_removed_from_panel () {
296+
Main.keybindingManager.removeXletHotKey(this, "finder_launch");
293297
},
294298

295299
_onSearchTextChanged: function(se, prop)

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class CinnamonCalendarApplet extends Applet.TextApplet {
174174
}
175175

176176
_setKeybinding() {
177-
Main.keybindingManager.addHotKey("calendar-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
177+
Main.keybindingManager.addXletHotKey(this, "calendar-open", this.keyOpen, Lang.bind(this, this._openMenu));
178178
}
179179

180180
_clockNotify(obj, pspec, data) {
@@ -307,7 +307,7 @@ class CinnamonCalendarApplet extends Applet.TextApplet {
307307
}
308308

309309
on_applet_removed_from_panel() {
310-
Main.keybindingManager.removeHotKey("calendar-open-" + this.instance_id);
310+
Main.keybindingManager.removeXletHotKey(this, "calendar-open");
311311
if (this.clock_notify_id > 0) {
312312
this.clock.disconnect(this.clock_notify_id);
313313
this.clock_notify_id = 0;

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,10 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
434434
}
435435

436436
_setKeybinding() {
437-
Main.keybindingManager.addHotKey("inhibit-power-" + this.instance_id,
437+
Main.keybindingManager.addXletHotKey(this, "inhibit-power",
438438
this.keyPower,
439439
Lang.bind(this, this.toggle_inhibit_power));
440-
Main.keybindingManager.addHotKey("inhibit-notifications-" + this.instance_id,
440+
Main.keybindingManager.addXletHotKey(this, "inhibit-notifications",
441441
this.keyNotifications,
442442
Lang.bind(this, this.toggle_inhibit_notifications));
443443
}
@@ -455,8 +455,8 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
455455
}
456456

457457
on_applet_removed_from_panel() {
458-
Main.keybindingManager.removeHotKey("inhibit-power-" + this.instance_id);
459-
Main.keybindingManager.removeHotKey("inhibit-notifications-" + this.instance_id);
458+
Main.keybindingManager.removeXletHotKey(this, "inhibit-power");
459+
Main.keybindingManager.removeXletHotKey(this, "inhibit-notifications");
460460
this.inhibitSwitch.kill();
461461
}
462462

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
12361236
}
12371237

12381238
_updateKeybinding() {
1239-
Main.keybindingManager.addHotKey("overlay-key-" + this.instance_id, this.overlayKey, () => {
1239+
Main.keybindingManager.addXletHotKey(this, "overlay-key", this.overlayKey, () => {
12401240
if (!Main.overview.visible && !Main.expo.visible) {
12411241
if (this.forceShowPanel && !this.isOpen) {
12421242
this.panel.peekPanel();
@@ -1359,7 +1359,7 @@ class CinnamonMenuApplet extends Applet.TextIconApplet {
13591359
}
13601360

13611361
on_applet_removed_from_panel () {
1362-
Main.keybindingManager.removeHotKey("overlay-key-" + this.instance_id);
1362+
Main.keybindingManager.removeXletHotKey(this, "overlay-key");
13631363
}
13641364

13651365
// settings button callbacks

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ CinnamonNetworkApplet.prototype = {
18251825
},
18261826

18271827
_setKeybinding() {
1828-
Main.keybindingManager.addHotKey("network-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
1828+
Main.keybindingManager.addXletHotKey(this, "network-open", this.keyOpen, Lang.bind(this, this._openMenu));
18291829
},
18301830

18311831
_clientGot: function(obj, result) {
@@ -2670,7 +2670,7 @@ CinnamonNetworkApplet.prototype = {
26702670

26712671
on_applet_removed_from_panel: function() {
26722672
Main.systrayManager.unregisterTrayIconReplacement(this.metadata.uuid);
2673-
Main.keybindingManager.removeHotKey("network-open-" + this.instance_id);
2673+
Main.keybindingManager.removeXletHotKey(this, "network-open");
26742674
if (this._periodicTimeoutId){
26752675
Mainloop.source_remove(this._periodicTimeoutId);
26762676
}

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ class CinnamonNotificationsApplet extends Applet.TextIconApplet {
4747
}
4848

4949
_setKeybinding() {
50-
Main.keybindingManager.addHotKey("notification-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
51-
Main.keybindingManager.addHotKey("notification-clear-" + this.instance_id, this.keyClear, Lang.bind(this, this._clear_all));
50+
Main.keybindingManager.addXletHotKey(this, "notification-open", this.keyOpen, Lang.bind(this, this._openMenu));
51+
Main.keybindingManager.addXletHotKey(this, "notification-clear", this.keyClear, Lang.bind(this, this._clear_all));
5252
}
5353

5454
on_applet_removed_from_panel () {
55-
Main.keybindingManager.removeHotKey("notification-open-" + this.instance_id);
56-
Main.keybindingManager.removeHotKey("notification-clear-" + this.instance_id);
55+
Main.keybindingManager.removeXletHotKey(this, "notification-open");
56+
Main.keybindingManager.removeXletHotKey(this, "notification-clear");
5757
global.settings.disconnect(this.panelEditModeHandler);
5858
}
5959

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class CinnamonSettingsExampleApplet extends Applet.TextIconApplet {
5353
}
5454

5555
on_keybinding_changed() {
56-
Main.keybindingManager.addHotKey("must-be-unique-id", this.keybinding, Lang.bind(this, this.on_hotkey_triggered));
56+
Main.keybindingManager.addXletHotKey(this, "must-be-unique-id", this.keybinding, Lang.bind(this, this.on_hotkey_triggered));
5757
}
5858

5959
on_settings_changed() {
@@ -129,6 +129,7 @@ class CinnamonSettingsExampleApplet extends Applet.TextIconApplet {
129129
this.settings.finalize(); // This is called when a user removes the applet from the panel.. we want to
130130
// Remove any connections and file listeners here, which our settings object
131131
// has a few of
132+
Main.keybindingManager.removeXletHotKey(this, "must-be-unique-id");
132133
}
133134
}
134135

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
11111111
}
11121112

11131113
_setKeybinding() {
1114-
Main.keybindingManager.addHotKey("sound-open-" + this.instance_id, this.keyOpen, Lang.bind(this, this._openMenu));
1114+
Main.keybindingManager.addXletHotKey(this, "sound-open", this.keyOpen, Lang.bind(this, this._openMenu));
11151115
}
11161116

11171117
_on_overamplification_change () {
@@ -1141,7 +1141,7 @@ class CinnamonSoundApplet extends Applet.TextIconApplet {
11411141
}
11421142

11431143
on_applet_removed_from_panel () {
1144-
Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
1144+
Main.keybindingManager.removeXletHotKey(this, "sound-open");
11451145
if (this.hideSystray)
11461146
this.unregisterSystrayIcons();
11471147
if (this._iconTimeoutId) {

0 commit comments

Comments
 (0)