prefs: add preference button to workspace menu

This commit is contained in:
Tor Hedin Brønner
2019-01-13 15:08:27 +01:00
parent fc399526ff
commit 3ed41c0942
+30
View File
@@ -6,6 +6,7 @@ var Extension = imports.misc.extensionUtils.extensions['paperwm@hedning:matrix.o
var Meta = imports.gi.Meta;
var St = imports.gi.St;
var Gio = imports.gi.Gio;
var GLib = imports.gi.GLib;
var PanelMenu = imports.ui.panelMenu;
var PopupMenu = imports.ui.popupMenu;
var Clutter = imports.gi.Clutter;
@@ -144,6 +145,35 @@ class WorkspaceMenu extends PanelMenu.Button {
this.contentBox.add_actor(this.colors.actor);
this.menu.box.add_actor(this.contentBox);
const Shell = imports.gi.Shell;
let app = this._settingsApp = Shell.AppSystem.get_default().lookup_app(
'gnome-control-center.desktop'
);
let [iconName, name] = [app.app_info.get_icon().names[0],
app.get_name()];
this.prefsIcon = new St.Button({ reactive: true,
can_focus: true,
track_hover: true,
accessible_name: name,
style_class: 'system-menu-action' });
this.prefsIcon.child = new St.Icon({ icon_name: iconName });
this.prefsIcon.connect('clicked', () => {
this.menu.close(true);
let wi = workspaceManager.get_active_workspace_index();
let env = GLib.get_environ();
env.push(`PAPERWM_PREFS_SELECTED_WORKSPACE=${wi}`);
try {
GLib.spawn_async(null, ['gnome-shell-extension-prefs', 'paperwm@hedning:matrix.org'],
env, GLib.SpawnFlags.SEARCH_PATH | GLib.SpawnFlags.DO_NOT_REAP_CHILD, null);
} catch(e) {
}
});
this.menu.box.add(this.prefsIcon, { expand: true, x_fill: false });
this.entry.actor.width = this.colors.actor.width;
this.colors.entry.actor.width = this.colors.actor.width;
this.state = "NORMAL";