Enable/Disable Show Desktop button for #36

This commit is contained in:
jderose9
2017-02-28 22:50:24 -05:00
parent a457d41d18
commit abc2c2b778
4 changed files with 92 additions and 23 deletions

View File

@@ -1856,6 +1856,50 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="show_showdesktop_row">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="show_showdesktop_button_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSwitch" id="show_showdesktop_button_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="show_showdesktop_button_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Show Desktop Button</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="show_appmenu_row">
<property name="width_request">100</property>

View File

@@ -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);

View File

@@ -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',

View File

@@ -142,6 +142,11 @@
<summary>Show activities button</summary>
<description>Show activities button on the left hand side of the taskbar</description>
</key>
<key type="b" name="show-showdesktop-button">
<default>true</default>
<summary>Show desktop button</summary>
<description>Show button on right side of bar that minimizes/restores all visible windows on current workspace</description>
</key>
<key type="b" name="show-appmenu">
<default>false</default>
<summary>Show appMenu</summary>