From abc2c2b77823808d5d437221b245868bcc16f36c Mon Sep 17 00:00:00 2001 From: jderose9 Date: Tue, 28 Feb 2017 22:50:24 -0500 Subject: [PATCH] Enable/Disable Show Desktop button for #36 --- Settings.ui | 44 +++++++++++++ panel.js | 62 ++++++++++++------- prefs.js | 4 ++ ...shell.extensions.dash-to-panel.gschema.xml | 5 ++ 4 files changed, 92 insertions(+), 23 deletions(-) diff --git a/Settings.ui b/Settings.ui index e55fd2c..d782db4 100644 --- a/Settings.ui +++ b/Settings.ui @@ -1856,6 +1856,50 @@ + + + 100 + True + True + + + True + False + 12 + 12 + 12 + 12 + 32 + + + True + True + end + center + + + 1 + 0 + + + + + True + False + True + Show Desktop Button + True + 0 + + + 0 + 0 + + + + + + 100 diff --git a/panel.js b/panel.js index d86d3c2..4f1d87d 100644 --- a/panel.js +++ b/panel.js @@ -116,6 +116,7 @@ const dtpPanel = new Lang.Class({ this._setActivitiesButtonVisible(this._dtpSettings.get_boolean('show-activities-button')); this._setAppmenuVisible(this._dtpSettings.get_boolean('show-appmenu')); this._setClockLocation(this._dtpSettings.get_string('location-clock')); + this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); this.panel.actor.add_style_class_name('dashtopanelMainPanel'); @@ -158,25 +159,6 @@ const dtpPanel = new Lang.Class({ ] ); - this._showDesktopButton = new St.Bin({ style_class: 'showdesktop-button', - reactive: true, - can_focus: true, - x_fill: true, - y_fill: true, - track_hover: true }); - - this._showDesktopButton.connect('button-press-event', Lang.bind(this, this._onShowDesktopButtonPress)); - - this._showDesktopButton.connect('enter-event', Lang.bind(this, function(){ - this._showDesktopButton.add_style_class_name('showdesktop-button-hovered'); - })); - - this._showDesktopButton.connect('leave-event', Lang.bind(this, function(){ - this._showDesktopButton.remove_style_class_name('showdesktop-button-hovered'); - })); - - this.panel._rightBox.insert_child_at_index(this._showDesktopButton, this.panel._rightBox.get_children().length); - this._bindSettingsChanges(); this.panelStyle.enable(this.panel); @@ -234,10 +216,7 @@ const dtpPanel = new Lang.Class({ Main.overview._panelGhost.set_height(this._oldPanelHeight); this._setActivitiesButtonVisible(true); this._setClockLocation("NATURAL"); - - this.panel.actor.remove_child(this._showDesktopButton); - this._showDesktopButton.destroy(); - this._showDesktopButton = null; + this._displayShowDesktopButton(false); this.appMenu = null; this.container = null; @@ -269,6 +248,10 @@ const dtpPanel = new Lang.Class({ this._dtpSettings.connect('changed::location-clock', Lang.bind(this, function() { this._setClockLocation(this._dtpSettings.get_string('location-clock')); })); + + this._dtpSettings.connect('changed::show-showdesktop-button', Lang.bind(this, function() { + this._displayShowDesktopButton(this._dtpSettings.get_boolean('show-showdesktop-button')); + })); }, _allocate: function(actor, box, flags) { @@ -420,6 +403,39 @@ const dtpPanel = new Lang.Class({ } }, + _displayShowDesktopButton: function (isVisible) { + if(isVisible) { + if(this._showDesktopButton) + return; + + this._showDesktopButton = new St.Bin({ style_class: 'showdesktop-button', + reactive: true, + can_focus: true, + x_fill: true, + y_fill: true, + track_hover: true }); + + this._showDesktopButton.connect('button-press-event', Lang.bind(this, this._onShowDesktopButtonPress)); + + this._showDesktopButton.connect('enter-event', Lang.bind(this, function(){ + this._showDesktopButton.add_style_class_name('showdesktop-button-hovered'); + })); + + this._showDesktopButton.connect('leave-event', Lang.bind(this, function(){ + this._showDesktopButton.remove_style_class_name('showdesktop-button-hovered'); + })); + + this.panel._rightBox.insert_child_at_index(this._showDesktopButton, this.panel._rightBox.get_children().length); + } else { + if(!this._showDesktopButton) + return; + + this.panel._rightBox.remove_child(this._showDesktopButton); + this._showDesktopButton.destroy(); + this._showDesktopButton = null; + } + }, + _onShowDesktopButtonPress: function() { if(this._focusAppChangeId){ tracker.disconnect(this._focusAppChangeId); diff --git a/prefs.js b/prefs.js index 5862e40..60b71ad 100644 --- a/prefs.js +++ b/prefs.js @@ -320,6 +320,10 @@ const Settings = new Lang.Class({ this._builder.get_object('show_activities_button_switch'), 'active', Gio.SettingsBindFlags.DEFAULT); + this._settings.bind('show-showdesktop-button', + this._builder.get_object('show_showdesktop_button_switch'), + 'active', + Gio.SettingsBindFlags.DEFAULT); this._settings.bind('show-appmenu', this._builder.get_object('show_appmenu_switch'), 'active', diff --git a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml index 6af794f..5e87fdb 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -142,6 +142,11 @@ Show activities button Show activities button on the left hand side of the taskbar + + true + Show desktop button + Show button on right side of bar that minimizes/restores all visible windows on current workspace + false Show appMenu