This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
statusMenu.js
81 lines (66 loc) · 2.92 KB
/
statusMenu.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright (C) 2018 O. Alperen Elhan
//
// This file is part of Extensions Sync.
//
// Extensions Sync is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Extensions Sync is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Extensions Sync. If not, see <http:https://www.gnu.org/licenses/>.
//
const St = imports.gi.St;
const Main = imports.ui.main;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const Gtk = imports.gi.Gtk;
const ExtensionUtils = imports.misc.extensionUtils;
const Util = imports.misc.util;
const Gio = imports.gi.Gio;
const Me = ExtensionUtils.getCurrentExtension();
var StatusMenu = class StatusMenu {
constructor() {
this.button = new PanelMenu.Button(1,'StatusMenu',false);
Gtk.IconTheme.get_default().append_search_path(imports.misc.extensionUtils.getCurrentExtension().dir.get_child('icons').get_path());
let box = new St.BoxLayout();
let gSyncedIcon = Gio.icon_new_for_string(Me.path + "/icons/extensions-sync-synced.svg");
let gSyncingIcon = Gio.icon_new_for_string(Me.path + "/icons/extensions-sync-syncing.svg");
let gDownloadIcon = Gio.icon_new_for_string(Me.path + "/icons/extensions-sync-download.svg");
let gUploadIcon = Gio.icon_new_for_string(Me.path + "/icons/extensions-sync-upload.svg");
let icon = new St.Icon({ gicon: gSyncedIcon, style_class: 'system-status-icon' });
box.add(icon);
this.button.actor.add_child(box);
let uploadMenuItem = new PopupMenu.PopupImageMenuItem('Upload', gUploadIcon);
uploadMenuItem.connect('activate',async () => {
icon.set_gicon(gSyncingIcon);
await sync.updateGist();
icon.set_gicon(gSyncedIcon);
});
let downloadMenuItem = new PopupMenu.PopupImageMenuItem('Download', gDownloadIcon);
downloadMenuItem.connect('activate',async () => {
icon.set_gicon(gSyncingIcon);
await sync.updateLocal();
icon.set_gicon(gSyncedIcon);
});
let settingsMenuItem = new PopupMenu.PopupImageMenuItem('Settings','preferences-system-symbolic');
settingsMenuItem.connect('activate',() => {
Util.spawn(['gnome-shell-extension-prefs','[email protected]']);
});
this.button.menu.addMenuItem(uploadMenuItem);
this.button.menu.addMenuItem(downloadMenuItem);
this.button.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.button.menu.addMenuItem(settingsMenuItem);
}
enable() {
Main.panel.addToStatusArea('StatusMenu',this.button,0,'right');
}
disable() {
this.button.destroy();
}
}