From bbd3a20fe506c383fa8c780d3638f85138e4ed62 Mon Sep 17 00:00:00 2001 From: MarkS Date: Mon, 3 Aug 2020 20:10:00 -0600 Subject: [PATCH] Move length and anchor to Styles tab * Moved length and anchor setting to Styles tab, as it is an all-monitor setting currently. * Changed length from spinbox to slider, and shortened label. * Turned off anchor combobox sensitivity if length is 100%. * Set anchor labels to the more intuitive "Left, Center, Right" and "Top, Middle, Bottom" if all monitor panels are horizontal or vertical. If monitors have panels in a mix of orientations, use "Start, Middle, End". The schema retains the generic START, MIDDLE, END. * Changed "Panel Size" label to "Panel thickness" to more precisely describe what is being set now that the panel can be changed in two dimensions. "Panel thickness" and "Panel length" can describe the sizing of the panel for either horizontal or vertical orientations. * Changed now-shortened Position label to "Anchor", to reduce confusion with other Position setting, regarding which edge of the screen. --- Settings.ui | 183 ++++++++++-------- prefs.js | 80 ++++++-- ...shell.extensions.dash-to-panel.gschema.xml | 2 +- 3 files changed, 171 insertions(+), 94 deletions(-) diff --git a/Settings.ui b/Settings.ui index a92d065..b3bb98d 100644 --- a/Settings.ui +++ b/Settings.ui @@ -2,7 +2,7 @@ - + 100 1 10 @@ -4806,69 +4806,6 @@ 2 - - - True - False - 12 - 12 - False - Length along screen edge, in percent - 0 - - - 0 - 3 - - - - - True - True - 12 - 12 - 5 - 100 - adjustment1 - True - 100 - - - 1 - 3 - - - - - True - False - 12 - 12 - False - Position along screen edge - 0 - - - 0 - 4 - - - - - True - False - center - - Start - Middle - End - - - - 1 - 4 - - @@ -4927,13 +4864,13 @@ vertical 24 - + True False 0 in - + True False none @@ -4950,20 +4887,8 @@ 12 6 6 + 12 32 - - - True - False - Panel Size -(default is 48) - 0 - - - 0 - 0 - - True @@ -4982,10 +4907,104 @@ 0 + + + True + False + Panel thickness +(default is 48) + 0 + + + 0 + 0 + + + + + True + False + Panel length (%) +(default is 100) + 0 + + + 0 + 1 + + + + + True + True + baseline + True + panel_length_adjustment + 0 + 0 + right + + + + 1 + 1 + + + + + True + False + center + + Start + Middle + End + + + + 1 + 2 + + + + + True + False + Anchor + 0 + + + 0 + 2 + + + + + + + + + + False + True + 0 + + + + + True + False + 0 + in + + + True + False + none 100 @@ -5094,7 +5113,7 @@ False True - 0 + 1 @@ -5373,7 +5392,7 @@ False True - 1 + 2 @@ -5817,7 +5836,7 @@ False True - 2 + 3 diff --git a/prefs.js b/prefs.js index 8f9b3d5..3d7a783 100644 --- a/prefs.js +++ b/prefs.js @@ -42,6 +42,8 @@ const DEFAULT_PANEL_SIZES = [ 128, 96, 64, 48, 32, 24, 16 ]; const DEFAULT_FONT_SIZES = [ 96, 64, 48, 32, 24, 16, 0 ]; const DEFAULT_MARGIN_SIZES = [ 32, 24, 16, 12, 8, 4, 0 ]; const DEFAULT_PADDING_SIZES = [ 32, 24, 16, 12, 8, 4, 0, -1 ]; +// Minimum length could be 0, but a higher value may help prevent confusion about where the panel went. +const LENGTH_MARKS = [ 100, 90, 80, 70, 60, 50, 40, 30, 20, 10 ]; const MAX_WINDOW_INDICATOR = 4; const SCHEMA_PATH = '/org/gnome/shell/extensions/dash-to-panel/'; @@ -218,6 +220,10 @@ const Settings = new Lang.Class({ topRadio.set_tooltip_text(!topAvailable ? _('Unavailable when gnome-shell top panel is present') : ''); }, + /** + * Returns an object, with monitor index string keys to values that are Pos.TOP, Pos.BOTTOM, Pos.LEFT, + * or Pos.RIGHT. + */ _getPanelPositions: function() { return Pos.getSettingsPositions(this._settings, 'panel-positions'); }, @@ -237,6 +243,7 @@ const Settings = new Lang.Class({ monitors.forEach(m => panelPositionsSettings[m] = preventTop && this.monitors[0] == m ? Pos.BOTTOM : position); this._settings.set_string('panel-positions', JSON.stringify(panelPositionsSettings)); + this._setAnchorLabels(); }, _setPositionRadios: function(position) { @@ -260,6 +267,37 @@ const Settings = new Lang.Class({ this._ignorePositionRadios = false; }, + /** + * Set panel anchor combo labels according to whether panel is vertical, horizontal, or a mix. + */ + _setAnchorLabels: function() { + const positions = this._getPanelPositions(); + const monitorIndices = Object.getOwnPropertyNames(positions); + const allVertical = monitorIndices.every(i => positions[i] === Pos.LEFT || positions[i] === Pos.RIGHT); + const allHorizontal = monitorIndices.every(i => positions[i] === Pos.TOP || positions[i] === Pos.BOTTOM); + + const anchor_combo = this._builder.get_object('panel_anchor_combo'); + const anchor = this._settings.get_string('panel-anchor'); + anchor_combo.remove_all(); + + if (allHorizontal) { + anchor_combo.append(Pos.START, _('Left')); + anchor_combo.append(Pos.MIDDLE, _('Center')); + anchor_combo.append(Pos.END, _('Right')); + } else if (allVertical) { + anchor_combo.append(Pos.START, _('Top')); + anchor_combo.append(Pos.MIDDLE, _('Middle')); + anchor_combo.append(Pos.END, _('Bottom')); + } else { + // Mix of horizontal and vertical panels on different monitors. + anchor_combo.append(Pos.START, _('Start')); + anchor_combo.append(Pos.MIDDLE, _('Middle')); + anchor_combo.append(Pos.END, _('End')); + } + + anchor_combo.set_active_id(anchor); + }, + _displayPanelPositionsForMonitor: function(monitorIndex) { let taskbarListBox = this._builder.get_object('taskbar_display_listbox'); @@ -771,23 +809,36 @@ const Settings = new Lang.Class({ this._builder.get_object('multimon_multi_switch').set_sensitive(false); } - // Length and position along screen edge + // Length and anchoring along screen edge - // Minimum length could be 0, but a higher value may help prevent confusion about where the panel went. - let panel_length_min=10 - let panel_length_max=100 - let panel_length_spinbutton = this._builder.get_object('panel_length_spinbutton'); - panel_length_spinbutton.set_range(panel_length_min, panel_length_max); - panel_length_spinbutton.set_value(this._settings.get_int('panel-length')); - this._builder.get_object('panel_length_spinbutton').connect('value-changed', Lang.bind (this, function(widget) { - this._settings.set_int('panel-length', widget.get_value()); + // Anchor is only relevant if panel length is less than 100%. + const setAnchorWidgetSensitivity = (panelLength) => { + const isPartialLength = panelLength < 100; + this._builder.get_object('panel_anchor_label').set_sensitive(isPartialLength); + this._builder.get_object('panel_anchor_combo').set_sensitive(isPartialLength); + } + + const panel_length_scale = this._builder.get_object('panel_length_scale'); + const length = this._settings.get_int('panel-length'); + panel_length_scale.set_value(length); + setAnchorWidgetSensitivity(length); + panel_length_scale.connect('value-changed', Lang.bind (this, function(widget) { + const value = widget.get_value(); + this._settings.set_int('panel-length', value); + setAnchorWidgetSensitivity(value); })); this._builder.get_object('panel_anchor_combo').set_active_id(this._settings.get_string('panel-anchor')); this._builder.get_object('panel_anchor_combo').connect('changed', Lang.bind (this, function(widget) { - this._settings.set_string('panel-anchor', widget.get_active_id()); + const value = widget.get_active_id(); + // Value can be null while anchor labels are being swapped out + if (value !== null) { + this._settings.set_string('panel-anchor', value); + } })); + this._setAnchorLabels(); + //dynamic opacity this._settings.bind('trans-use-custom-bg', this._builder.get_object('trans_bg_switch'), @@ -1825,7 +1876,8 @@ const Settings = new Lang.Class({ {objectName: 'appicon_padding_scale', valueName: 'appicon-padding', range: DEFAULT_MARGIN_SIZES }, {objectName: 'tray_padding_scale', valueName: 'tray-padding', range: DEFAULT_PADDING_SIZES }, {objectName: 'leftbox_padding_scale', valueName: 'leftbox-padding', range: DEFAULT_PADDING_SIZES }, - {objectName: 'statusicon_padding_scale', valueName: 'status-icon-padding', range: DEFAULT_PADDING_SIZES } + {objectName: 'statusicon_padding_scale', valueName: 'status-icon-padding', range: DEFAULT_PADDING_SIZES }, + {objectName: 'panel_length_scale', valueName: 'panel-length', range: LENGTH_MARKS } ]; for(var idx in sizeScales) { @@ -1833,6 +1885,7 @@ const Settings = new Lang.Class({ let range = sizeScales[idx].range; size_scale.set_range(range[range.length-1], range[0]); size_scale.set_value(this._settings.get_int(sizeScales[idx].valueName)); + // Add marks from range arrays, omitting the first and last values. range.slice(1, -1).forEach(function(val) { size_scale.add_mark(val, Gtk.PositionType.TOP, val.toString()); }); @@ -2033,6 +2086,11 @@ const Settings = new Lang.Class({ this._settings.set_string('window-preview-title-position', 'TOP'); }, + + panel_length_scale_format_value_cb: function(scale, value) { + return value+ '%'; + }, + panel_size_scale_format_value_cb: function(scale, value) { return value+ ' px'; }, 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 b6f7257..7441df8 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -95,7 +95,7 @@ 100 Percentage of screen edge for panel to span - Set the length of the panel, in percent. Horizontal or vertical, according to panel orientation. + Length of the panel, in percent. 'MIDDLE'