Add option to reveal the desktop on hover

This commit is contained in:
Charles Gagnon
2019-02-04 21:59:37 -05:00
parent 60656d7547
commit e306dc2650
4 changed files with 263 additions and 58 deletions

View File

@@ -575,6 +575,182 @@
</packing>
</child>
</object>
<object class="GtkBox" id="box_show_showdesktop_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkListBox" id="listbox_show_showdesktop_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="listboxrow_show_showdesktop_width">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_show_showdesktop_width">
<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="GtkLabel" id="show_showdesktop_width_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 width (px)</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="show_showdesktop_width_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text">1</property>
<property name="adjustment">show_showdesktop_width_adjustment</property>
<property name="numeric">True</property>
<property name="value">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listboxrow_show_showdesktop_hide">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_show_showdesktop_hide">
<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="row_spacing">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel" id="show_showdesktop_hide_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Reveal the desktop when hovering the 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>
<child>
<object class="GtkSwitch" id="show_showdesktop_hide_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="GtkGrid" id="grid_show_showdesktop_hide_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">4</property>
<child>
<object class="GtkLabel" id="show_showdesktop_delay_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Delay before revealing the desktop (ms)</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>
<child>
<object class="GtkSpinButton" id="show_showdesktop_delay_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text">1</property>
<property name="adjustment">show_showdesktop_delay_adjustment</property>
<property name="numeric">True</property>
<property name="value">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="show_showdesktop_time_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Fade duration (ms)</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="show_showdesktop_time_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text">1</property>
<property name="adjustment">show_showdesktop_time_adjustment</property>
<property name="numeric">True</property>
<property name="value">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="dot_border_width_adjustment">
<property name="upper">10</property>
<property name="step_increment">1</property>
@@ -3139,66 +3315,22 @@
</packing>
</child>
</object>
<object class="GtkAdjustment" id="show_showdesktop_delay_adjustment">
<property name="upper">5000</property>
<property name="step_increment">10</property>
<property name="page_increment">100</property>
</object>
<object class="GtkAdjustment" id="show_showdesktop_time_adjustment">
<property name="upper">5000</property>
<property name="step_increment">10</property>
<property name="page_increment">100</property>
</object>
<object class="GtkAdjustment" id="show_showdesktop_width_adjustment">
<property name="lower">1</property>
<property name="upper">40</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkBox" id="box_show_showdesktop_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkListBoxRow" id="listboxrow_show_showdesktop_width">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_show_showdesktop_width">
<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="GtkLabel" id="show_showdesktop_width_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 width (px)</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="show_showdesktop_width_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text">0</property>
<property name="adjustment">show_showdesktop_width_adjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<object class="GtkAdjustment" id="statusicon_padding_adjustment">
<property name="lower">0.33000000000000002</property>
<property name="upper">1</property>

View File

@@ -50,6 +50,7 @@ const PopupMenu = imports.ui.popupMenu;
const IconGrid = imports.ui.iconGrid;
const ViewSelector = imports.ui.viewSelector;
const DateMenu = imports.ui.dateMenu;
const Tweener = imports.ui.tweener;
const Intellihide = Me.imports.intellihide;
const Transparency = Me.imports.transparency;
@@ -273,6 +274,11 @@ var dtpPanelWrapper = new Lang.Class({
this.intellihide.destroy();
}
if (this._showDesktopTimeoutId) {
Mainloop.source_remove(this._showDesktopTimeoutId);
this._showDesktopTimeoutId = 0;
}
this.dynamicTransparency.destroy();
// reset stored icon size to the default dash
@@ -606,10 +612,27 @@ var dtpPanelWrapper = new Lang.Class({
this._showDesktopButton.connect('enter-event', Lang.bind(this, function(){
this._showDesktopButton.add_style_class_name('showdesktop-button-hovered');
if (this._dtpSettings.get_boolean('show-showdesktop-hover')) {
this._showDesktopTimeoutId = Mainloop.timeout_add(this._dtpSettings.get_int('show-showdesktop-delay'), () => {
this._hiddenDesktopWorkspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace();
this._toggleWorkspaceWindows(true, this._hiddenDesktopWorkspace);
this._showDesktopTimeoutId = 0;
});
}
}));
this._showDesktopButton.connect('leave-event', Lang.bind(this, function(){
this._showDesktopButton.remove_style_class_name('showdesktop-button-hovered');
if (this._dtpSettings.get_boolean('show-showdesktop-hover')) {
if (this._showDesktopTimeoutId) {
Mainloop.source_remove(this._showDesktopTimeoutId);
this._showDesktopTimeoutId = 0;
} else {
this._toggleWorkspaceWindows(false, this._hiddenDesktopWorkspace);
}
 }
}));
this.panel._rightBox.insert_child_at_index(this._showDesktopButton, this.panel._rightBox.get_children().length);
@@ -629,6 +652,16 @@ var dtpPanelWrapper = new Lang.Class({
}
},
_toggleWorkspaceWindows: function(hide, workspace) {
workspace.list_windows().forEach(w =>
Tweener.addTween(w.get_compositor_private(), {
opacity: hide ? 0 : 255,
time: this._dtpSettings.get_int('show-showdesktop-time') * .001,
transition: 'easeOutQuad'
})
);
},
_onShowDesktopButtonPress: function() {
if(this._focusAppChangeId){
tracker.disconnect(this._focusAppChangeId);
@@ -636,6 +669,11 @@ var dtpPanelWrapper = new Lang.Class({
}
if(this._restoreWindowList && this._restoreWindowList.length) {
if (this._showDesktopTimeoutId) {
Mainloop.source_remove(this._showDesktopTimeoutId);
this._showDesktopTimeoutId = 0;
}
let current_workspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace();
let windows = current_workspace.list_windows();
this._restoreWindowList.forEach(function(w) {
@@ -643,8 +681,6 @@ var dtpPanelWrapper = new Lang.Class({
Main.activateWindow(w);
});
this._restoreWindowList = null;
Main.overview.hide();
} else {
let current_workspace = Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace();
let windows = current_workspace.list_windows().filter(function (w) {
@@ -663,9 +699,9 @@ var dtpPanelWrapper = new Lang.Class({
this._restoreWindowList = null;
}));
}));
Main.overview.hide();
}
Main.overview.hide();
},
});

View File

@@ -879,6 +879,16 @@ const Settings = new Lang.Class({
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-showdesktop-hover',
this._builder.get_object('show_showdesktop_hide_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-showdesktop-hover',
this._builder.get_object('grid_show_showdesktop_hide_options'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._builder.get_object('show_showdesktop_options_button').connect('clicked', Lang.bind(this, function() {
let dialog = new Gtk.Dialog({ title: _('Show Desktop options'),
@@ -898,11 +908,23 @@ const Settings = new Lang.Class({
this._settings.set_int('showdesktop-button-width', widget.get_value());
}));
this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay'));
this._builder.get_object('show_showdesktop_delay_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('show-showdesktop-delay', widget.get_value());
}));
this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time'));
this._builder.get_object('show_showdesktop_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('show-showdesktop-time', widget.get_value());
}));
dialog.connect('response', Lang.bind(this, function(dialog, id) {
if (id == 1) {
// restore default settings
this._settings.set_value('showdesktop-button-width', this._settings.get_default_value('showdesktop-button-width'));
this._builder.get_object('show_showdesktop_width_spinbutton').set_value(this._settings.get_int('showdesktop-button-width'));
this._builder.get_object('show_showdesktop_delay_spinbutton').set_value(this._settings.get_int('show-showdesktop-delay'));
this._builder.get_object('show_showdesktop_time_spinbutton').set_value(this._settings.get_int('show-showdesktop-time'));
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);

View File

@@ -350,6 +350,21 @@
<summary>Width of show Desktop button</summary>
<description>Customize the width of the show Desktop button</description>
</key>
<key type="b" name="show-showdesktop-hover">
<default>false</default>
<summary>Show desktop on hover</summary>
<description>Show the desktop on mouse hover</description>
</key>
<key type="i" name="show-showdesktop-delay">
<default>1000</default>
<summary>Delay show desktop</summary>
<description>Delay before showing the desktop</description>
</key>
<key type="i" name="show-showdesktop-time">
<default>300</default>
<summary>Show desktop animation time</summary>
<description>Window fade animation time when showing the destop</description>
</key>
<key type="b" name="show-appmenu">
<default>false</default>
<summary>Show appMenu button</summary>