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.
This commit is contained in:
MarkS
2020-08-03 20:10:00 -06:00
parent 0a066890cb
commit bbd3a20fe5
3 changed files with 171 additions and 94 deletions

View File

@@ -2,7 +2,7 @@
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="adjustment1">
<object class="GtkAdjustment" id="panel_length_adjustment">
<property name="upper">100</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
@@ -4806,69 +4806,6 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="panel_length_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">Length along screen edge, in percent</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="panel_length_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="width_chars">5</property>
<property name="text">100</property>
<property name="adjustment">adjustment1</property>
<property name="numeric">True</property>
<property name="value">100</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="panel_anchor_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">Position along screen edge</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="panel_anchor_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<items>
<item id="START" translatable="yes">Start</item>
<item id="MIDDLE" translatable="yes">Middle</item>
<item id="END" translatable="yes">End</item>
</items>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<placeholder/>
</child>
@@ -4927,13 +4864,13 @@
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<object class="GtkFrame" id="panel_style">
<object class="GtkFrame" id="panel_size_frame">
<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="panel_style_listbox">
<object class="GtkListBox" id="panel_size_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
@@ -4950,20 +4887,8 @@
<property name="margin_right">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="row_spacing">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkLabel" id="panel_size_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Panel Size
(default is 48)</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="GtkScale" id="panel_size_scale">
<property name="visible">True</property>
@@ -4982,10 +4907,104 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="panel_size_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Panel thickness
(default is 48)</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="GtkLabel" id="panel_length_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Panel length (%)
(default is 100)</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="GtkScale" id="panel_length_scale">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="valign">baseline</property>
<property name="hexpand">True</property>
<property name="adjustment">panel_length_adjustment</property>
<property name="round_digits">0</property>
<property name="digits">0</property>
<property name="value_pos">right</property>
<signal name="format-value" handler="panel_length_scale_format_value_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="panel_anchor_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<items>
<item id="START" translatable="yes">Start</item>
<item id="MIDDLE" translatable="yes">Middle</item>
<item id="END" translatable="yes">End</item>
</items>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="panel_anchor_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Anchor</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="panel_style">
<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="panel_style_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="margin_listboxrow">
<property name="width_request">100</property>
@@ -5094,7 +5113,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -5373,7 +5392,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
@@ -5817,7 +5836,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>

View File

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

View File

@@ -95,7 +95,7 @@
<key type="i" name="panel-length">
<default>100</default>
<summary>Percentage of screen edge for panel to span</summary>
<description>Set the length of the panel, in percent. Horizontal or vertical, according to panel orientation.</description>
<description>Length of the panel, in percent.</description>
</key>
<key name="panel-anchor" enum="org.gnome.shell.extensions.dash-to-panel.anchor">
<default>'MIDDLE'</default>