-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathquickSettingsMenu.js
55 lines (42 loc) · 1.79 KB
/
quickSettingsMenu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const GObject = imports.gi.GObject;
const Gio = imports.gi.Gio;
const Main = imports.ui.main;
const Config = imports.misc.config;
const [major] = Config.PACKAGE_VERSION.split(".");
const shellVersion = Number.parseInt(major);
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Common = Me.imports.common;
const UIQuickSettings = imports.ui.quickSettings;
const QuickSettingsMenu = Main.panel.statusArea.quickSettings; // GNOME 43 System Menu
var SystemMenu = GObject.registerClass(
class QSystemMenu extends UIQuickSettings.SystemIndicator {
_init() {
super._init();
const toggleTitle = shellVersion == 43 ?
{ label: "IdeaPad" } : // GNOME 43
{ title: "IdeaPad" } // GNOME 44
// Create extension's sub menu
this.toggleMenu = new UIQuickSettings.QuickMenuToggle({
...toggleTitle,
gicon: Common.getIcon()
});
this.toggleMenu.menu.setHeader(Common.getIcon(), Me.metadata.name);
// Since this "toggle" menu isn't being used as a toggle button
// clicking should just open the menu.
this.toggleMenu.connect("clicked", () => {
this.toggleMenu.menu.open();
})
QuickSettingsMenu.menu.addItem(this.toggleMenu);
if (shellVersion >= 44) {
// Move toggleMenu above Background Apps item. (GNOME 44)
QuickSettingsMenu.menu._grid.set_child_below_sibling(this.toggleMenu, QuickSettingsMenu._backgroundApps.quickSettingsItems[0]);
}
Common.addOptionsToMenu(this.toggleMenu.menu);
}
destroy() {
this.toggleMenu.destroy();
super.destroy();
}
}
);