diff --git a/Makefile b/Makefile index 334f60f..b29aff1 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Settings.ui b/Settings.ui index a2a1941..9f945c4 100644 --- a/Settings.ui +++ b/Settings.ui @@ -2765,44 +2765,45 @@ 12 32 - + + True + False + 8 + + True - False - 8 - - - True - True - end - center - - - False - True - 1 - - - - - True - True - end - 4 - 6 - preview_custom_icon_size_adjustment - True - 6 - - - 1 - 0 - 2 - - - - - 1 - + True + end + center + + + False + True + 1 + + + + + True + True + end + 4 + 6 + preview_custom_icon_size_adjustment + True + 6 + + + False + True + 2 + + + + + 1 + 0 + @@ -4147,9 +4148,8 @@ - 1 - 0 - 1 + 1 + 1 @@ -4826,124 +4826,240 @@ True False 12 + 4 + 4 True 0 1 + 2 - + True False - 18 - 6 - 32 + 6 + 0 + none - + True False - True - Panel screen position - 0 + none + + + 100 + True + True + + + True + False + 6 + 6 + 12 + 32 + + + True + True + baseline + True + panel_size_adjustment + 0 + 0 + right + + + + + 1 + 1 + + + + + True + False + Panel thickness +(default is 48) + 0 + + + 0 + 1 + + + + + True + False + Panel length (%) +(default is 100) + 0 + + + 0 + 2 + + + + + True + True + baseline + True + panel_length_adjustment + 0 + 0 + right + + + 1 + 2 + + + + + True + False + center + + Start + Middle + End + + + + 1 + 3 + + + + + True + False + Anchor + 0 + + + 0 + 3 + + + + + True + False + True + Panel screen position + 0 + + + 0 + 0 + + + + + True + False + 32 + + + Bottom + True + True + False + center + center + 0 + True + True + + + + False + True + 0 + + + + + Top + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 1 + + + + + Left + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 2 + + + + + Right + True + True + False + center + center + 0 + bottom + True + position_bottom_button + + + + False + True + 3 + + + + + 1 + 0 + + + + + + - - False - True - 0 - - - - True - False - 32 - - - Bottom - True - True - False - center - center - 0 - True - True - - - - False - True - 0 - - - - - Top - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 1 - - - - - Left - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 2 - - - - - Right - True - True - False - center - center - 0 - bottom - True - position_bottom_button - - - - False - True - 3 - - - - - False - True - 1 - + + @@ -4952,9 +5068,6 @@ 2 - - - False @@ -5009,137 +5122,6 @@ 24 vertical 24 - - - True - False - 0 - in - - - True - False - none - - - 100 - True - True - - - True - False - 12 - 12 - 6 - 6 - 12 - 32 - - - True - True - baseline - True - panel_size_adjustment - 0 - 0 - right - - - - - 1 - 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 @@ -5259,7 +5241,7 @@ False True - 1 + 0 @@ -5538,7 +5520,7 @@ False True - 2 + 1 @@ -5982,7 +5964,7 @@ False True - 3 + 2 diff --git a/appIcons.js b/appIcons.js index 1ccfbd6..05c2921 100644 --- a/appIcons.js +++ b/appIcons.js @@ -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(); diff --git a/panel.js b/panel.js index 94ba6c6..7c00aa5 100644 --- a/panel.js +++ b/panel.js @@ -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; diff --git a/panelManager.js b/panelManager.js index 539f721..ba9efeb 100755 --- a/panelManager.js +++ b/panelManager.js @@ -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()); }, diff --git a/panelPositions.js b/panelPositions.js index 3197d27..52458bb 100644 --- a/panelPositions.js +++ b/panelPositions.js @@ -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; } \ No newline at end of file diff --git a/panelSettings.js b/panelSettings.js new file mode 100644 index 0000000..3eeac9b --- /dev/null +++ b/panelSettings.js @@ -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 . + */ + +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); +} diff --git a/prefs.js b/prefs.js index 7c575ec..76b3149 100644 --- a/prefs.js +++ b/prefs.js @@ -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; })); 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 30967cf..728c520 100644 --- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml +++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml @@ -40,11 +40,6 @@ - - - - - @@ -74,7 +69,7 @@ 'BOTTOM' - Panel position + Panel position (Deprecated) Panel is shown on the Bottom or Top of the screen. @@ -92,19 +87,24 @@ Panel element positions Panel element positions (JSON). - - 100 - Percentage of screen edge for panel to span - Length of the panel, in percent. + + '{}' + Percentages of screen edge for panel to span + Length of the panels, in percent (JSON). - - 'MIDDLE' - Position along screen edge - Where to show the panel if it is not the full length of the screen edge. + + '{}' + Positions along screen edge + Where to show the panels if it is not the full length of the screen edge (JSON). + + + '{}' + Panel sizes + Sizes of panels, in pixels. 48 - Panel size + Panel size (Deprecated) Set the size of the panel. diff --git a/taskbar.js b/taskbar.js index 60bcb17..89849d3 100644 --- a/taskbar.js +++ b/taskbar.js @@ -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; diff --git a/utils.js b/utils.js index 8081fca..c2469b3 100644 --- a/utils.js +++ b/utils.js @@ -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; diff --git a/windowPreview.js b/windowPreview.js index ab35af9..0464c87 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -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'