From 3ed41c0942da40052250d32e350ba07d42cc09ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Sun, 13 Jan 2019 14:39:43 +0100 Subject: [PATCH] prefs: add preference button to workspace menu --- topbar.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/topbar.js b/topbar.js index e6b1799..38849a5 100644 --- a/topbar.js +++ b/topbar.js @@ -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";