Moved window preview options to separate dialog, disabled advanced options

This commit is contained in:
dziku1337
2017-04-15 15:20:56 +02:00
parent 0b9e653525
commit ef0418669c
2 changed files with 253 additions and 112 deletions

View File

@@ -896,24 +896,69 @@
<object class="GtkAdjustment" id="peek_mode_opacity_adjustment">
<property name="upper">255</property>
<property name="lower">0</property>
<property name="step_increment">1</property>
<property name="page_increment">5</property>
<property name="step_increment">10</property>
<property name="page_increment">25</property>
</object>
<object class="GtkBox" id="box_advanced_options">
<object class="GtkBox" id="box_window_preview_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkFrame" id="frame_advanced_options">
<object class="GtkFrame" id="frame_window_preview_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="listbox_advanced_options">
<object class="GtkListBox" id="listbox_window_preview_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="listbox_preview_timeout">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_preview_timeout">
<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="GtkSpinButton" id="preview_timeout_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">preview_timeout_adjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="preview_timeout_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Time (ms) before showing (100 is default)</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="listboxrow_leave_timeout">
<property name="width_request">100</property>
@@ -978,6 +1023,70 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listbox_peek_mode">
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_peek_mode">
<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="peek_mode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Enable window peeking</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="peek_mode_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="peek_mode_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">When hovering over a window preview for some time, the window gets distinguished.</property>
<property name="wrap">True</property>
<property name="max_width_chars">40</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</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>
<child>
<object class="GtkListBoxRow" id="listboxrow_enter_peek_mode_timeout">
<property name="width_request">100</property>
@@ -1042,7 +1151,7 @@
</child>
</object>
</child>
<child>
<child>
<object class="GtkListBoxRow" id="listboxrow_peek_mode_opacity">
<property name="width_request">100</property>
<property name="height_request">80</property>
@@ -1116,6 +1225,31 @@
</packing>
</child>
</object>
<object class="GtkBox" id="box_advanced_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkFrame" id="frame_advanced_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkListBox" id="listbox_advanced_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
</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="leftbox_padding_adjustment">
<property name="lower">0.33000000000000002</property>
<property name="upper">1</property>
@@ -2236,15 +2370,53 @@
<property name="row_spacing">4</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkSwitch" id="show_window_previews_switch">
<object class="GtkBox" id="show_window_previews_box">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkButton" id="show_window_previews_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0.46000000834465027</property>
<child>
<object class="GtkImage" id="image_window_previews_options">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">emblem-system-symbolic</property>
</object>
</child>
<style>
<class name="circular"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="show_window_previews_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="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
@@ -2261,62 +2433,6 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="preview_timeout_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">preview_timeout_adjustment</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="preview_timeout_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Time (ms) before showing (100 is default)</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="GtkLabel" id="peek_mode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Enable window peeking</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="peek_mode_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">2</property>
</packing>
</child>
</object>
</child>
</object>

117
prefs.js
View File

@@ -385,30 +385,77 @@ const Settings = new Lang.Class({
this._builder.get_object('show_window_previews_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-window-previews',
this._builder.get_object('preview_timeout_spinbutton'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-window-previews',
this._builder.get_object('preview_timeout_label'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('peek-mode',
this._builder.get_object('peek_mode_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-window-previews',
this._builder.get_object('peek_mode_switch'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('show-window-previews',
this._builder.get_object('peek_mode_label'),
this._settings.bind('show-window-previews',
this._builder.get_object('show_window_previews_button'),
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._builder.get_object('preview_timeout_spinbutton').set_value(this._settings.get_int('show-window-previews-timeout'));
this._builder.get_object('preview_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('show-window-previews-timeout', widget.get_value());
this._builder.get_object('show_window_previews_button').connect('clicked', Lang.bind(this, function() {
let dialog = new Gtk.Dialog({ title: _('Window preview options'),
transient_for: this.widget.get_toplevel(),
use_header_bar: true,
modal: true });
// GTK+ leaves positive values for application-defined response ids.
// Use +1 for the reset action
dialog.add_button(_('Reset to defaults'), 1);
let box = this._builder.get_object('box_window_preview_options');
dialog.get_content_area().add(box);
this._builder.get_object('preview_timeout_spinbutton').set_value(this._settings.get_int('show-window-previews-timeout'));
this._builder.get_object('preview_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('show-window-previews-timeout', widget.get_value());
}));
this._builder.get_object('leave_timeout_spinbutton').set_value(this._settings.get_int('leave-timeout'));
this._builder.get_object('leave_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('leave-timeout', widget.get_value());
}));
this._settings.bind('peek-mode',
this._builder.get_object('peek_mode_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._builder.get_object('enter_peek_mode_timeout_spinbutton').set_value(this._settings.get_int('enter-peek-mode-timeout'));
this._builder.get_object('enter_peek_mode_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('enter-peek-mode-timeout', widget.get_value());
}));
this._builder.get_object('peek_mode_opacity_spinbutton').set_value(this._settings.get_int('peek-mode-opacity'));
this._builder.get_object('peek_mode_opacity_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('peek-mode-opacity', widget.get_value());
}));
dialog.connect('response', Lang.bind(this, function(dialog, id) {
if (id == 1) {
// restore default settings
this._settings.set_value('show-window-previews-timeout', this._settings.get_default_value('show-window-previews-timeout'));
this._builder.get_object('preview_timeout_spinbutton').set_value(this._settings.get_int('show-window-previews-timeout'));
this._settings.set_value('leave-timeout', this._settings.get_default_value('leave-timeout'));
this._builder.get_object('leave_timeout_spinbutton').set_value(this._settings.get_int('leave-timeout'));
this._settings.set_value('peek-mode', this._settings.get_default_value('peek-mode'));
this._settings.set_value('enter-peek-mode-timeout', this._settings.get_default_value('enter-peek-mode-timeout'));
this._builder.get_object('enter_peek_mode_timeout_spinbutton').set_value(this._settings.get_int('enter-peek-mode-timeout'));
this._settings.set_value('peek-mode-opacity', this._settings.get_default_value('peek-mode-opacity'));
this._builder.get_object('peek_mode_opacity_spinbutton').set_value(this._settings.get_int('peek-mode-opacity'));
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
}
return;
}));
dialog.show_all();
}));
this._settings.bind('isolate-workspaces',
@@ -607,6 +654,8 @@ const Settings = new Lang.Class({
}));
// Since there are no advanced options, the button is disabled
this._builder.get_object('button_advanced_options').set_sensitive(false);
// setup dialog for advanced options
this._builder.get_object('button_advanced_options').connect('clicked', Lang.bind(this, function() {
@@ -622,33 +671,9 @@ const Settings = new Lang.Class({
let box = this._builder.get_object('box_advanced_options');
dialog.get_content_area().add(box);
this._builder.get_object('leave_timeout_spinbutton').set_value(this._settings.get_int('leave-timeout'));
this._builder.get_object('leave_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('leave-timeout', widget.get_value());
}));
this._builder.get_object('enter_peek_mode_timeout_spinbutton').set_value(this._settings.get_int('enter-peek-mode-timeout'));
this._builder.get_object('enter_peek_mode_timeout_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('enter-peek-mode-timeout', widget.get_value());
}));
this._builder.get_object('peek_mode_opacity_spinbutton').set_value(this._settings.get_int('peek-mode-opacity'));
this._builder.get_object('peek_mode_opacity_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('peek-mode-opacity', widget.get_value());
}));
dialog.connect('response', Lang.bind(this, function(dialog, id) {
if (id == 1) {
// restore default settings
this._settings.set_value('leave-timeout', this._settings.get_default_value('leave-timeout'));
this._builder.get_object('leave_timeout_spinbutton').set_value(this._settings.get_int('leave-timeout'));
this._settings.set_value('enter-peek-mode-timeout', this._settings.get_default_value('enter-peek-mode-timeout'));
this._builder.get_object('enter_peek_mode_timeout_spinbutton').set_value(this._settings.get_int('enter-peek-mode-timeout'));
this._settings.set_value('peek-mode-opacity', this._settings.get_default_value('peek-mode-opacity'));
this._builder.get_object('peek_mode_opacity_spinbutton').set_value(this._settings.get_int('peek-mode-opacity'));
// restore default settings
} else {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);