Configure panel thickness, length, and anchor per-monitor

Settings.ui:
- Move thickness, length, and anchor from Style tab to Position tab.
Group together with position in the same frame.

schema:
- Remove unpublished panel-length and panel-anchor settings, replacing
them with panel-lengths and panel-anchors JSON objects (like
panel-positions).
- Remove unpublished anchor enum, since panel-anchors is being managed
by the extension in JSON, not typed by the schema.
- Deprecate panel-size in favour of new panel-sizes JSON, storing
per-monitor panel sizes.
- Mention that panel-position is deprecated.

Introduce panelSettings.js:
- Functions to fetch or set panel settings that are stored as JSON.
Grown from now-removed getSettingsPositions() in panelPositions.js.

prefs.js:
- Group together the different UI widget label and value refreshing
into method _updateWidgetSettingsForMonitor().
- Change multi-panel behaviour of _setAnchorLabels(). Previously, all
panels shared the same anchor setting, and so setAnchorLabels
considered all monitors. Now, panels are configured either
independently, or sometimes all together; set labels according to
orientation(s) of panel(s) being configured.
- Omitting preventTop handling in refactored _setPanelPosition()
method. Previously, it was written to set the first monitor's panel to
Pos.BOTTOM if the user clicked the Top position radio button, if
stockgs-keep-top-panel was also set. But the user can't activate the
Top button anyway if stockgs is set (likely implemented later).

panelManager.js:
- Removing panelPositions, as it is not needed any more.
This commit is contained in:
MarkS
2020-10-27 16:04:19 -06:00
parent 29c107041b
commit a57058661a
12 changed files with 527 additions and 396 deletions

View File

@@ -2,7 +2,7 @@
UUID = dash-to-panel@jderose9.github.com
BASE_MODULES = extension.js stylesheet.css metadata.json COPYING README.md
EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui
EXTRA_MODULES = appIcons.js convenience.js panel.js panelManager.js proximity.js intellihide.js progress.js panelPositions.js panelSettings.js panelStyle.js overview.js taskbar.js transparency.js windowPreview.js prefs.js update.js utils.js Settings.ui
EXTRA_IMAGES = highlight_stacked_bg.svg highlight_stacked_bg_2.svg highlight_stacked_bg_3.svg
TOLOCALIZE = prefs.js appIcons.js update.js

View File

@@ -2765,44 +2765,45 @@
<property name="margin_top">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkBox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<child>
<object class="GtkSwitch" id="preview_custom_icon_size_switch">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
<child>
<object class="GtkSwitch" id="preview_custom_icon_size_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>
<child>
<object class="GtkSpinButton" id="preview_custom_icon_size_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="width_chars">4</property>
<property name="text">6</property>
<property name="adjustment">preview_custom_icon_size_adjustment</property>
<property name="numeric">True</property>
<property name="value">6</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
</packing>
<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>
<child>
<object class="GtkSpinButton" id="preview_custom_icon_size_spinbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="width_chars">4</property>
<property name="text">6</property>
<property name="adjustment">preview_custom_icon_size_adjustment</property>
<property name="numeric">True</property>
<property name="value">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="preview_custom_icon_size_label">
@@ -4147,9 +4148,8 @@
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="top_attach">1</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
@@ -4826,124 +4826,240 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_start">12</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="panel_position_box">
<object class="GtkFrame" id="panel_size_frame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">18</property>
<property name="margin_bottom">6</property>
<property name="spacing">32</property>
<property name="margin_top">6</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkLabel" id="panel_position_label">
<object class="GtkListBox" id="panel_size_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Panel screen position</property>
<property name="xalign">0</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="panel_size_listboxrow">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="panel_size_grid">
<property name="visible">True</property>
<property name="can_focus">False</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="GtkScale" id="panel_size_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_size_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_size_scale_format_value_cb" swapped="no"/>
<signal name="value-changed" handler="panel_size_scale_value_changed_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</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">1</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">2</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>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</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">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="label" translatable="yes">Anchor</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="GtkLabel" id="panel_position_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Panel screen position</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="GtkBox" id="panel_position_butttons_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkRadioButton" id="position_bottom_button">
<property name="label" translatable="yes">Bottom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="clicked" handler="position_bottom_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_top_button">
<property name="label" translatable="yes">Top</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_top_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_left_button">
<property name="label" translatable="yes">Left</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_left_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_right_button">
<property name="label" translatable="yes">Right</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_right_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="panel_position_butttons_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">32</property>
<child>
<object class="GtkRadioButton" id="position_bottom_button">
<property name="label" translatable="yes">Bottom</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="clicked" handler="position_bottom_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_top_button">
<property name="label" translatable="yes">Top</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_top_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_left_button">
<property name="label" translatable="yes">Left</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_left_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="position_right_button">
<property name="label" translatable="yes">Right</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<property name="image_position">bottom</property>
<property name="draw_indicator">True</property>
<property name="group">position_bottom_button</property>
<signal name="clicked" handler="position_right_button_clicked_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
<child type="label_item">
<placeholder/>
</child>
</object>
<packing>
@@ -4952,9 +5068,6 @@
<property name="width">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
@@ -5009,137 +5122,6 @@
<property name="margin_bottom">24</property>
<property name="orientation">vertical</property>
<property name="spacing">24</property>
<child>
<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_size_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
<child>
<object class="GtkListBoxRow" id="panel_size_listboxrow">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="panel_size_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">6</property>
<property name="margin_bottom">6</property>
<property name="row_spacing">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkScale" id="panel_size_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_size_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_size_scale_format_value_cb" swapped="no"/>
<signal name="value-changed" handler="panel_size_scale_value_changed_cb" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<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>
@@ -5259,7 +5241,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@@ -5538,7 +5520,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -5982,7 +5964,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
</object>

View File

@@ -47,6 +47,7 @@ const Workspace = imports.ui.workspace;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Me.imports.utils;
const Panel = Me.imports.panel;
const PanelSettings = Me.imports.panelSettings;
const Taskbar = Me.imports.taskbar;
const Progress = Me.imports.progress;
const _ = imports.gettext.domain(Utils.TRANSLATION_DOMAIN).gettext;
@@ -573,9 +574,9 @@ var taskbarAppIcon = Utils.defineClass({
},
_setAppIconPadding: function() {
let padding = getIconPadding();
let padding = getIconPadding(this.dtpPanel.monitor.index);
let margin = Me.settings.get_int('appicon-margin');
this.actor.set_style('padding:' + (this.dtpPanel.checkIfVertical() ? margin + 'px 0' : '0 ' + margin + 'px;'));
this._iconContainer.set_style('padding: ' + padding + 'px;');
},
@@ -1365,8 +1366,8 @@ function cssHexTocssRgba(cssHex, opacity) {
return 'rgba(' + [r, g, b].join(',') + ',' + opacity + ')';
}
function getIconPadding() {
let panelSize = Me.settings.get_int('panel-size');
function getIconPadding(monitorIndex) {
let panelSize = PanelSettings.getPanelSize(Me.settings, monitorIndex);
let padding = Me.settings.get_int('appicon-padding');
let availSize = panelSize - Taskbar.MIN_ICON_SIZE - panelSize % 2;
@@ -1684,7 +1685,7 @@ var ShowAppsIconWrapper = Utils.defineClass({
},
setShowAppsPadding: function() {
let padding = getIconPadding();
let padding = getIconPadding(this.realShowAppsIcon._dtpPanel.monitor.index);
let sidePadding = Me.settings.get_int('show-apps-icon-side-padding');
let isVertical = this.realShowAppsIcon._dtpPanel.checkIfVertical();

View File

@@ -36,6 +36,7 @@ const AppIcons = Me.imports.appIcons;
const Utils = Me.imports.utils;
const Taskbar = Me.imports.taskbar;
const Pos = Me.imports.panelPositions;
const PanelSettings = Me.imports.panelSettings;
const PanelStyle = Me.imports.panelStyle;
const Lang = imports.lang;
const Main = imports.ui.main;
@@ -535,8 +536,7 @@ var dtpPanel = Utils.defineClass({
},
getPosition: function() {
//for now, use the previous "global" position setting as default. The 'panel-position' should be deleted in the future
let position = this.panelManager.panelPositions[this.monitor.index] || Me.settings.get_string('panel-position');
let position = PanelSettings.getPanelPosition(Me.settings, this.monitor.index);
if (position == Pos.TOP) {
return St.Side.TOP;
@@ -652,12 +652,12 @@ var dtpPanel = Utils.defineClass({
_bindSettingsChanges: function() {
let isVertical = this.checkIfVertical();
this._signalsHandler.add(
[
Me.settings,
[
'changed::panel-size',
'changed::panel-sizes',
'changed::group-apps'
],
() => this._resetGeometry()
@@ -814,14 +814,15 @@ var dtpPanel = Utils.defineClass({
let topPadding = panelBoxTheme.get_padding(St.Side.TOP);
let tbPadding = topPadding + panelBoxTheme.get_padding(St.Side.BOTTOM);
let position = this.getPosition();
let length = Me.settings.get_int('panel-length') / 100;
let anchor = Me.settings.get_string('panel-anchor');
let length = PanelSettings.getPanelLength(Me.settings, this.monitor.index) / 100;
let anchor = PanelSettings.getPanelAnchor(Me.settings, this.monitor.index);
let anchorPlaceOnMonitor = 0;
let gsTopPanelOffset = 0;
let x = 0, y = 0;
let w = 0, h = 0;
this.dtpSize = Me.settings.get_int('panel-size') * scaleFactor;
const panelSize = PanelSettings.getPanelSize(Me.settings, this.monitor.index);
this.dtpSize = panelSize * scaleFactor;
if (Me.settings.get_boolean('stockgs-keep-top-panel') && Main.layoutManager.primaryMonitor == this.monitor) {
gsTopPanelOffset = Main.layoutManager.panelBox.height - topPadding;

View File

@@ -30,7 +30,7 @@
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Overview = Me.imports.overview;
const Panel = Me.imports.panel;
const Pos = Me.imports.panelPositions;
const PanelSettings = Me.imports.panelSettings;
const Proximity = Me.imports.proximity;
const Taskbar = Me.imports.taskbar;
const Utils = Me.imports.utils;
@@ -72,8 +72,7 @@ var dtpPanelManager = Utils.defineClass({
enable: function(reset) {
let dtpPrimaryIndex = Me.settings.get_int('primary-monitor');
this.panelPositions = Pos.getSettingsPositions(Me.settings, 'panel-positions');
this.dtpPrimaryMonitor = Main.layoutManager.monitors[dtpPrimaryIndex] || Main.layoutManager.primaryMonitor;
this.proximityManager = new Proximity.ProximityManager();
@@ -240,8 +239,8 @@ var dtpPanelManager = Utils.defineClass({
'changed::multi-monitors',
'changed::isolate-monitors',
'changed::panel-positions',
'changed::panel-length',
'changed::panel-anchor',
'changed::panel-lengths',
'changed::panel-anchors',
'changed::stockgs-keep-top-panel'
],
() => this._reset()
@@ -437,7 +436,7 @@ var dtpPanelManager = Utils.defineClass({
},
_updatePanelElementPositions: function() {
this.panelsElementPositions = Pos.getSettingsPositions(Me.settings, 'panel-element-positions');
this.panelsElementPositions = PanelSettings.getSettingsJson(Me.settings, 'panel-element-positions');
this.allPanels.forEach(p => p.updateElementPositions());
},

View File

@@ -56,18 +56,6 @@ var optionDialogFunctions = {};
optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions';
optionDialogFunctions[DESKTOP_BTN] = '_showDesktopButtonOptions';
function getSettingsPositions(settings, setting) {
var positions = null;
try {
positions = JSON.parse(settings.get_string(setting));
} catch(e) {
log('Error parsing positions: ' + e.message);
}
return positions;
}
function checkIfCentered(position) {
return position == CENTERED || position == CENTERED_MONITOR;
}

112
panelSettings.js Normal file
View File

@@ -0,0 +1,112 @@
/*
* This file is part of the Dash-To-Panel extension for Gnome 3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Pos = Me.imports.panelPositions;
/** Return object representing a settings value that is stored as JSON. */
function getSettingsJson(settings, setting) {
try {
return JSON.parse(settings.get_string(setting));
} catch(e) {
log('Error parsing positions: ' + e.message);
}
}
/** Write value object as JSON to setting in settings. */
function setSettingsJson(settings, setting, value) {
try {
const json = JSON.stringify(value);
settings.set_string(setting, json);
} catch(e) {
log('Error serializing setting: ' + e.message);
}
}
/** Returns size of panel on a specific monitor, in pixels. */
function getPanelSize(settings, monitorIndex) {
const sizes = getSettingsJson(settings, 'panel-sizes');
// Pull in deprecated setting if panel-sizes does not have setting for monitor.
const fallbackSize = settings.get_int('panel-size');
const theDefault = 48;
return sizes[monitorIndex] || fallbackSize || theDefault;
}
function setPanelSize(settings, monitorIndex, value) {
if (!(Number.isInteger(value) && value <= 128 && value >= 16)) {
log(`Not setting invalid panel size: ${value}`);
return;
}
let sizes = getSettingsJson(settings, 'panel-sizes');
sizes[monitorIndex] = value;
setSettingsJson(settings, 'panel-sizes', sizes);
}
/**
* Returns length of panel on a specific monitor, as a whole number percent,
* from settings. e.g. 100
*/
function getPanelLength(settings, monitorIndex) {
const lengths = getSettingsJson(settings, 'panel-lengths');
const theDefault = 100;
return lengths[monitorIndex] || theDefault;
}
function setPanelLength(settings, monitorIndex, value) {
if (!(Number.isInteger(value) && value <= 100 && value >= 0)) {
log(`Not setting invalid panel length: ${value}`);
return;
}
let lengths = getSettingsJson(settings, 'panel-lengths');
lengths[monitorIndex] = value;
setSettingsJson(settings, 'panel-lengths', lengths);
}
/** Returns position of panel on a specific monitor. */
function getPanelPosition(settings, monitorIndex) {
const positions = getSettingsJson(settings, 'panel-positions');
const fallbackPosition = settings.get_string('panel-position');
const theDefault = Pos.BOTTOM;
return positions[monitorIndex] || fallbackPosition || theDefault;
}
function setPanelPosition(settings, monitorIndex, value) {
if (!(value === Pos.TOP || value === Pos.BOTTOM || value === Pos.LEFT
|| value === Pos.RIGHT)) {
log(`Not setting invalid panel position: ${value}`);
return;
}
const positions = getSettingsJson(settings, 'panel-positions');
positions[monitorIndex] = value;
setSettingsJson(settings, 'panel-positions', positions);
}
/** Returns anchor location of panel on a specific monitor. */
function getPanelAnchor(settings, monitorIndex) {
const anchors = getSettingsJson(settings, 'panel-anchors');
const theDefault = Pos.MIDDLE;
return anchors[monitorIndex] || theDefault;
}
function setPanelAnchor(settings, monitorIndex, value) {
if (!(value === Pos.START || value === Pos.MIDDLE || value === Pos.END)) {
log(`Not setting invalid panel anchor: ${value}`);
return;
}
const anchors = getSettingsJson(settings, 'panel-anchors');
anchors[monitorIndex] = value;
setSettingsJson(settings, 'panel-anchors', anchors);
}

180
prefs.js
View File

@@ -35,6 +35,7 @@ const Gettext = imports.gettext.domain(Me.metadata['gettext-domain']);
const _ = Gettext.gettext;
const N_ = function(e) { return e };
const Update = Me.imports.update;
const PanelSettings = Me.imports.panelSettings;
const Pos = Me.imports.panelPositions;
const SCALE_UPDATE_TIMEOUT = 500;
@@ -220,35 +221,22 @@ 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');
},
_getPanelPosition: function(monitorIndex) {
let panelPositionsSettings = this._getPanelPositions();
return panelPositionsSettings[monitorIndex] || this._settings.get_string('panel-position');
return PanelSettings.getPanelPosition(this._settings, monitorIndex);
},
_setPanelPosition: function(position) {
let panelPositionsSettings = this._getPanelPositions();
let preventTop = this._settings.get_boolean('stockgs-keep-top-panel') && position == Pos.TOP;
let monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
let monitors = monitorSync ? this.monitors : [this._currentMonitorIndex];
monitors.forEach(m => panelPositionsSettings[m] = preventTop && this.monitors[0] == m ? Pos.BOTTOM : position);
this._settings.set_string('panel-positions', JSON.stringify(panelPositionsSettings));
this._setAnchorLabels();
const monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
const monitorsToSetFor = monitorSync ? this.monitors : [this._currentMonitorIndex];
monitorsToSetFor.forEach(monitorIndex => {
PanelSettings.setPanelPosition(this._settings, monitorIndex, position);
});
this._setAnchorLabels(this._currentMonitorIndex);
},
_setPositionRadios: function(position) {
this._ignorePositionRadios = true;
switch (position) {
case Pos.BOTTOM:
this._builder.get_object('position_bottom_button').set_active(true);
@@ -268,16 +256,23 @@ const Settings = new Lang.Class({
},
/**
* Set panel anchor combo labels according to whether panel is vertical, horizontal, or a mix.
* Set panel anchor combo labels according to whether the monitor's panel is vertical
* or horizontal, or if all monitors' panels are being configured and they are a mix
* of vertical and horizontal.
*/
_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);
_setAnchorLabels: function(currentMonitorIndex) {
const monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
const monitorsToSetFor = monitorSync ? this.monitors : [currentMonitorIndex];
const allVertical = monitorsToSetFor.every(i => {
const position = PanelSettings.getPanelPosition(this._settings, i);
return position === Pos.LEFT || position === Pos.RIGHT
});
const allHorizontal = monitorsToSetFor.every(i => {
const position = PanelSettings.getPanelPosition(this._settings, i);
return position === Pos.TOP || position === 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) {
@@ -289,24 +284,69 @@ const Settings = new Lang.Class({
anchor_combo.append(Pos.MIDDLE, _('Middle'));
anchor_combo.append(Pos.END, _('Bottom'));
} else {
// Mix of horizontal and vertical panels on different monitors.
// Setting for a 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);
// Set combo box after re-populating its options. But only if it's for a single-panel
// configuration, or a multi-panel configuration where they all have the same anchor
// setting. So don't set the combo box if there is a multi-panel configuration with
// different anchor settings.
const someAnchor = PanelSettings.getPanelAnchor(this._settings, currentMonitorIndex);
if (monitorsToSetFor.every(i =>
PanelSettings.getPanelAnchor(this._settings, i) === someAnchor)) {
const panel_anchor = PanelSettings.getPanelAnchor(this._settings, currentMonitorIndex);
this._builder.get_object('panel_anchor_combo').set_active_id(panel_anchor);
}
},
/**
* When a monitor is selected, update the widgets for panel position, size, anchoring,
* and contents so they accurately show the settings for the panel on that monitor.
*/
_updateWidgetSettingsForMonitor: function(monitorIndex) {
// Update display of panel screen position setting
this._maybeDisableTopPosition();
const panelPosition = this._getPanelPosition(monitorIndex);
this._setPositionRadios(panelPosition);
// Update display of thickness, length, and anchor settings
const panel_size_scale = this._builder.get_object('panel_size_scale');
const size = PanelSettings.getPanelSize(this._settings, monitorIndex);
panel_size_scale.set_value(size);
const panel_length_scale = this._builder.get_object('panel_length_scale');
const length = PanelSettings.getPanelLength(this._settings, monitorIndex);
panel_length_scale.set_value(length);
this._setAnchorWidgetSensitivity(length);
this._setAnchorLabels(monitorIndex);
// Update display of panel content settings
this._displayPanelPositionsForMonitor(monitorIndex);
},
/**
* Anchor is only relevant if panel length is less than 100%. Enable or disable
* anchor widget sensitivity accordingly.
*/
_setAnchorWidgetSensitivity: function(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);
},
_displayPanelPositionsForMonitor: function(monitorIndex) {
let taskbarListBox = this._builder.get_object('taskbar_display_listbox');
taskbarListBox.get_children().forEach(c => c.destroy());
let labels = {};
let panelPosition = this._getPanelPosition(monitorIndex);
let isVertical = panelPosition == Pos.LEFT || panelPosition == Pos.RIGHT;
let panelElementPositionsSettings = Pos.getSettingsPositions(this._settings, 'panel-element-positions');
let panelElementPositionsSettings = PanelSettings.getSettingsJson(this._settings, 'panel-element-positions');
let panelElementPositions = panelElementPositionsSettings[monitorIndex] || Pos.defaults;
let updateElementsSettings = () => {
let newPanelElementPositions = [];
@@ -320,14 +360,12 @@ const Settings = new Lang.Class({
position: c.positionCombo.get_active_id()
});
});
monitors.forEach(m => panelElementPositionsSettings[m] = newPanelElementPositions);
this._settings.set_string('panel-element-positions', JSON.stringify(panelElementPositionsSettings));
};
this._maybeDisableTopPosition();
this._setPositionRadios(panelPosition);
labels[Pos.SHOW_APPS_BTN] = _('Show Applications button');
labels[Pos.ACTIVITIES_BTN] = _('Activities button');
labels[Pos.TASKBAR] = _('Taskbar');
@@ -515,13 +553,12 @@ const Settings = new Lang.Class({
_bindSettings: function() {
// size options
let panel_size_scale = this._builder.get_object('panel_size_scale');
panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length-1], DEFAULT_PANEL_SIZES[0]);
panel_size_scale.set_value(this._settings.get_int('panel-size'));
panel_size_scale.set_range(DEFAULT_PANEL_SIZES[DEFAULT_PANEL_SIZES.length - 1], DEFAULT_PANEL_SIZES[0]);
DEFAULT_PANEL_SIZES.slice(1, -1).forEach(function(val) {
panel_size_scale.add_mark(val, Gtk.PositionType.TOP, val.toString());
});
// Corrent for rtl languages
// Correct for rtl languages
if (this._rtl) {
// Flip value position: this is not done automatically
panel_size_scale.set_value_pos(Gtk.PositionType.LEFT);
@@ -786,7 +823,11 @@ const Settings = new Lang.Class({
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.connect('changed::panel-element-positions-monitors-sync', () => this._maybeDisableTopPosition());
this._settings.connect('changed::panel-element-positions-monitors-sync', () => {
this._maybeDisableTopPosition();
// The anchor combo box may has different labels for single- or all-monitor configuration.
this._setAnchorLabels(this._currentMonitorIndex);
});
this._builder.get_object('multimon_primary_combo').connect('changed', Lang.bind (this, function(widget) {
this._settings.set_int('primary-monitor', this.monitors[widget.get_active()]);
@@ -794,12 +835,9 @@ const Settings = new Lang.Class({
this._builder.get_object('taskbar_position_monitor_combo').connect('changed', Lang.bind (this, function(widget) {
this._currentMonitorIndex = this.monitors[widget.get_active()];
this._displayPanelPositionsForMonitor(this._currentMonitorIndex);
this._updateWidgetSettingsForMonitor(this._currentMonitorIndex);
}));
//panel positions
this._displayPanelPositionsForMonitor(this._currentMonitorIndex);
this._settings.bind('multi-monitors',
this._builder.get_object('multimon_multi_switch'),
'active',
@@ -809,35 +847,31 @@ const Settings = new Lang.Class({
this._builder.get_object('multimon_multi_switch').set_sensitive(false);
}
// Length and anchoring along screen edge
// 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);
const monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
const monitorsToSetFor = monitorSync ? this.monitors : [this._currentMonitorIndex];
monitorsToSetFor.forEach(monitorIndex => {
PanelSettings.setPanelLength(this._settings, monitorIndex, value);
});
this._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) {
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);
const monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
const monitorsToSetFor = monitorSync ? this.monitors : [this._currentMonitorIndex];
monitorsToSetFor.forEach(monitorIndex => {
PanelSettings.setPanelAnchor(this._settings, monitorIndex, value);
});
}
}));
this._setAnchorLabels();
this._updateWidgetSettingsForMonitor(this._currentMonitorIndex);
//dynamic opacity
this._settings.bind('trans-use-custom-bg',
@@ -1922,14 +1956,20 @@ const Settings = new Lang.Class({
{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: 'panel_length_scale', valueName: 'panel-length', range: LENGTH_MARKS }
{objectName: 'panel_length_scale', valueName: '', range: LENGTH_MARKS }
];
for(var idx in sizeScales) {
let size_scale = this._builder.get_object(sizeScales[idx].objectName);
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));
size_scale.set_range(range[range.length - 1], range[0]);
let value;
if (sizeScales[idx].objectName === 'panel_length_scale') {
value = PanelSettings.getPanelLength(this._settings, this._currentMonitorIndex);
} else {
value = this._settings.get_int(sizeScales[idx].valueName);
}
size_scale.set_value(value);
// 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());
@@ -2141,12 +2181,18 @@ const Settings = new Lang.Class({
},
panel_size_scale_value_changed_cb: function(scale) {
// Avoid settings the size consinuosly
// Avoid settings the size continuously
if (this._panel_size_timeout > 0)
Mainloop.source_remove(this._panel_size_timeout);
this._panel_size_timeout = Mainloop.timeout_add(SCALE_UPDATE_TIMEOUT, Lang.bind(this, function() {
this._settings.set_int('panel-size', scale.get_value());
const value = scale.get_value();
const monitorSync = this._settings.get_boolean('panel-element-positions-monitors-sync');
const monitorsToSetFor = monitorSync ? this.monitors : [this._currentMonitorIndex];
monitorsToSetFor.forEach(monitorIndex => {
PanelSettings.setPanelSize(this._settings, monitorIndex, value);
});
this._panel_size_timeout = 0;
return GLib.SOURCE_REMOVE;
}));

View File

@@ -40,11 +40,6 @@
<value value='2' nick='LEFT'/>
<value value='3' nick='RIGHT'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.anchor'>
<value value='0' nick='START'/>
<value value='1' nick='MIDDLE'/>
<value value='2' nick='END'/>
</enum>
<enum id='org.gnome.shell.extensions.dash-to-panel.proximityBehavior'>
<value value='0' nick='ALL_WINDOWS'/>
<value value='1' nick='FOCUSED_WINDOWS'/>
@@ -74,7 +69,7 @@
</key>
<key name="panel-position" enum="org.gnome.shell.extensions.dash-to-panel.position">
<default>'BOTTOM'</default>
<summary>Panel position</summary>
<summary>Panel position (Deprecated)</summary>
<description>Panel is shown on the Bottom or Top of the screen.</description>
</key>
<key name="panel-element-positions-monitors-sync" type="b">
@@ -92,19 +87,24 @@
<summary>Panel element positions</summary>
<description>Panel element positions (JSON).</description>
</key>
<key type="i" name="panel-length">
<default>100</default>
<summary>Percentage of screen edge for panel to span</summary>
<description>Length of the panel, in percent.</description>
<key type="s" name="panel-lengths">
<default>'{}'</default>
<summary>Percentages of screen edge for panel to span</summary>
<description>Length of the panels, in percent (JSON).</description>
</key>
<key name="panel-anchor" enum="org.gnome.shell.extensions.dash-to-panel.anchor">
<default>'MIDDLE'</default>
<summary>Position along screen edge</summary>
<description>Where to show the panel if it is not the full length of the screen edge.</description>
<key type="s" name="panel-anchors">
<default>'{}'</default>
<summary>Positions along screen edge</summary>
<description>Where to show the panels if it is not the full length of the screen edge (JSON).</description>
</key>
<key type="s" name="panel-sizes">
<default>'{}'</default>
<summary>Panel sizes</summary>
<description>Sizes of panels, in pixels.</description>
</key>
<key type="i" name="panel-size">
<default>48</default>
<summary>Panel size</summary>
<summary>Panel size (Deprecated)</summary>
<description>Set the size of the panel.</description>
</key>
<key type="b" name="desktop-line-use-custom-color">

View File

@@ -46,6 +46,7 @@ const Workspace = imports.ui.workspace;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const AppIcons = Me.imports.appIcons;
const Panel = Me.imports.panel;
const PanelSettings = Me.imports.panelSettings;
const Utils = Me.imports.utils;
const WindowPreview = Me.imports.windowPreview;
@@ -700,7 +701,8 @@ var taskbar = Utils.defineClass({
},
_adjustIconSize: function() {
let panelSize = Me.settings.get_int('panel-size');
const thisMonitorIndex = this.dtpPanel.monitor.index;
let panelSize = PanelSettings.getPanelSize(Me.settings, thisMonitorIndex);
let availSize = panelSize - Me.settings.get_int('appicon-padding') * 2;
let minIconSize = MIN_ICON_SIZE + panelSize % 2;

View File

@@ -23,7 +23,7 @@
const Clutter = imports.gi.Clutter;
const Config = imports.misc.config;
const GdkPixbuf = imports.gi.GdkPixbuf
const GdkPixbuf = imports.gi.GdkPixbuf;
const Gi = imports._gi;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;

View File

@@ -144,7 +144,7 @@ var PreviewMenu = Utils.defineClass({
[
Me.settings,
[
'changed::panel-size',
'changed::panel-sizes',
'changed::window-preview-size',
'changed::window-preview-padding',
'changed::window-preview-show-title'