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 f6e8879..40b568e 100644
--- a/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml
+++ b/schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml
@@ -92,7 +92,7 @@
'{}'
- Percentages of screen edge for panel to span
+ Percentages of screen edge for panel to span, -1 for dynamic length (dock mode)
Length of the panels, in percent (JSON).
diff --git a/src/panel.js b/src/panel.js
index 8de680e..4d947fc 100644
--- a/src/panel.js
+++ b/src/panel.js
@@ -518,7 +518,9 @@ export const Panel = GObject.registerClass(
return
}
- let currentPosition = pos.position
+ // if the panel length is dynamic, get all visible
+ // elements as a single group
+ let currentPosition = this.geom.dynamic || pos.position
let isCentered = Pos.checkIfCentered(currentPosition)
if (
@@ -702,9 +704,13 @@ export const Panel = GObject.registerClass(
let topPadding = panelBoxTheme.get_padding(St.Side.TOP)
let tbPadding = topPadding + panelBoxTheme.get_padding(St.Side.BOTTOM)
let position = this.getPosition()
- let length =
- PanelSettings.getPanelLength(SETTINGS, this.monitor.index) / 100
+ let panelLength = PanelSettings.getPanelLength(
+ SETTINGS,
+ this.monitor.index,
+ )
let anchor = PanelSettings.getPanelAnchor(SETTINGS, this.monitor.index)
+ let dynamic = panelLength == -1 ? Pos.anchorToPosition[anchor] : 0
+ let length = (dynamic ? 100 : panelLength) / 100
let anchorPlaceOnMonitor = 0
let gsTopPanelOffset = 0
let x = 0,
@@ -792,6 +798,7 @@ export const Panel = GObject.registerClass(
lrPadding,
tbPadding,
position,
+ dynamic,
}
}
@@ -825,14 +832,12 @@ export const Panel = GObject.registerClass(
}
vfunc_allocate(box) {
- this.set_allocation(box)
-
let fixed = 0
let centeredMonitorGroup
let panelAlloc = new Clutter.ActorBox({
x1: 0,
- y1: 0,
x2: this.geom.w,
+ y1: 0,
y2: this.geom.h,
})
let assignGroupSize = (group, update) => {
@@ -945,8 +950,6 @@ export const Panel = GObject.registerClass(
++fixed
}
- this.panel.allocate(panelAlloc)
-
this._elementGroups.forEach((group) => {
group.fixed = 0
@@ -957,6 +960,39 @@ export const Panel = GObject.registerClass(
}
})
+ if (this.geom.dynamic && this._elementGroups.length == 1) {
+ let dynamicGroup = this._elementGroups[0] // only one group if dynamic
+ let tl = 0
+ let br = 0
+
+ if (this.geom.dynamic == Pos.STACKED_TL) {
+ br = Math.min(box[this.varCoord.c2], dynamicGroup.size)
+ } else if (this.geom.dynamic == Pos.STACKED_BR) {
+ tl = Math.max(box[this.varCoord.c2] - dynamicGroup.size, 0)
+ br = box[this.varCoord.c2]
+ } else {
+ // CENTERED_MONITOR
+ let half = Math.max(
+ 0,
+ (box[this.varCoord.c2] - dynamicGroup.size) * 0.5,
+ )
+
+ tl = box[this.varCoord.c1] + half
+ br = box[this.varCoord.c2] - half
+ }
+
+ box[this.varCoord.c1] = tl
+ box[this.varCoord.c2] = br
+
+ panelAlloc[this.varCoord.c2] = Math.min(
+ dynamicGroup.size,
+ panelAlloc[this.varCoord.c2],
+ )
+ }
+
+ this.set_allocation(box)
+ this.panel.allocate(panelAlloc)
+
if (centeredMonitorGroup) {
allocateGroup(
centeredMonitorGroup,
diff --git a/src/panelPositions.js b/src/panelPositions.js
index bf39133..3a9119d 100644
--- a/src/panelPositions.js
+++ b/src/panelPositions.js
@@ -51,6 +51,12 @@ export const defaults = [
{ element: DESKTOP_BTN, visible: true, position: STACKED_BR },
]
+export const anchorToPosition = {
+ [START]: STACKED_TL,
+ [MIDDLE]: CENTERED_MONITOR,
+ [END]: STACKED_BR,
+}
+
export const optionDialogFunctions = {}
optionDialogFunctions[SHOW_APPS_BTN] = '_showShowAppsButtonOptions'
diff --git a/src/panelSettings.js b/src/panelSettings.js
index 0c913f4..86f4094 100644
--- a/src/panelSettings.js
+++ b/src/panelSettings.js
@@ -142,15 +142,17 @@ export function setPanelSize(settings, monitorIndex, value) {
/**
* Returns length of panel on a specific monitor, as a whole number percent,
- * from settings. e.g. 100
+ * from settings. e.g. 100, or -1 for a dynamic panel length
*/
export function getPanelLength(settings, monitorIndex) {
return getMonitorSetting(settings, 'panel-lengths', monitorIndex, 100)
}
export function setPanelLength(settings, monitorIndex, value) {
- if (!(Number.isInteger(value) && value <= 100 && value >= 0)) {
- console.log('Not setting invalid panel length: ' + value)
+ if (
+ !(Number.isInteger(value) && ((value <= 100 && value >= 20) || value == -1))
+ ) {
+ console.log('Not setting invalid panel length: ' + value, new Error().stack)
return
}
diff --git a/src/prefs.js b/src/prefs.js
index 1257b71..bca7d90 100644
--- a/src/prefs.js
+++ b/src/prefs.js
@@ -43,7 +43,7 @@ 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 LENGTH_MARKS = [100, 90, 80, 70, 60, 50, 40, 30, 20]
const MAX_WINDOW_INDICATOR = 4
const SCHEMA_PATH = '/org/gnome/shell/extensions/dash-to-panel/'
@@ -427,28 +427,50 @@ const Preferences = class {
panel_size_scale.set_value(size)
const panel_length_scale = this._builder.get_object('panel_length_scale')
+ const dynamicLengthButton = this._builder.get_object(
+ 'panel_length_dynamic_button',
+ )
const length = PanelSettings.getPanelLength(this._settings, monitorIndex)
- panel_length_scale.set_value(length)
- this._setAnchorWidgetSensitivity(length)
+ const isDynamicLength = length == -1
+
+ dynamicLengthButton.set_active(isDynamicLength)
+ panel_length_scale.set_value(isDynamicLength ? 100 : length)
this._setAnchorLabels(monitorIndex)
// Update display of panel content settings
this._displayPanelPositionsForMonitor(monitorIndex)
+
+ this._setPanelLenghtWidgetSensitivity(length)
}
/**
* Anchor is only relevant if panel length is less than 100%. Enable or disable
* anchor widget sensitivity accordingly.
*/
- _setAnchorWidgetSensitivity(panelLength) {
+ _setPanelLenghtWidgetSensitivity(panelLength) {
+ const taskbarListBox = this._builder.get_object('taskbar_display_listbox')
+ let i = 0
+ let row
+ const isDynamicLength = panelLength == -1
const isPartialLength = panelLength < 100
+
+ this._builder
+ .get_object('panel_length_scale')
+ .set_sensitive(!isDynamicLength)
this._builder
.get_object('panel_anchor_label')
.set_sensitive(isPartialLength)
this._builder
.get_object('panel_anchor_combo')
.set_sensitive(isPartialLength)
+
+ while ((row = taskbarListBox.get_row_at_index(i++)) != null) {
+ let grid = row.get_child()
+ let positionCombo = grid.get_child_at(4, 0)
+
+ positionCombo.set_sensitive(!isDynamicLength)
+ }
}
_displayPanelPositionsForMonitor(monitorIndex) {
@@ -1349,9 +1371,7 @@ const Preferences = class {
this._builder.get_object('multimon_multi_switch').set_sensitive(false)
}
- const panel_length_scale = this._builder.get_object('panel_length_scale')
- panel_length_scale.connect('value-changed', (widget) => {
- const value = widget.get_value()
+ let setPanelLength = (value) => {
const monitorSync = this._settings.get_boolean(
'panel-element-positions-monitors-sync',
)
@@ -1362,7 +1382,31 @@ const Preferences = class {
PanelSettings.setPanelLength(this._settings, monitorIndex, value)
})
- this._setAnchorWidgetSensitivity(value)
+ maybeSetPanelLengthScaleValueChange(value)
+ this._setPanelLenghtWidgetSensitivity(value)
+ }
+ let panelLengthScaleValueChangeId = 0
+ let maybeSetPanelLengthScaleValueChange = (value) => {
+ const panel_length_scale = this._builder.get_object('panel_length_scale')
+
+ if (panelLengthScaleValueChangeId) {
+ panel_length_scale.disconnect(panelLengthScaleValueChangeId)
+ panelLengthScaleValueChangeId = 0
+ }
+
+ if (value != -1) {
+ panelLengthScaleValueChangeId = panel_length_scale.connect(
+ 'value-changed',
+ () => setPanelLength(panel_length_scale.get_value()),
+ )
+ } else panel_length_scale.set_value(100)
+ }
+
+ const dynamicLengthButton = this._builder.get_object(
+ 'panel_length_dynamic_button',
+ )
+ dynamicLengthButton.connect('notify::active', () => {
+ setPanelLength(dynamicLengthButton.get_active() ? -1 : 100)
})
this._builder
@@ -3114,10 +3158,12 @@ const Preferences = class {
size_scale.set_range(range[range.length - 1], range[0])
let value
if (sizeScales[idx].objectName === 'panel_length_scale') {
- value = PanelSettings.getPanelLength(
+ let length = PanelSettings.getPanelLength(
this._settings,
this._currentMonitorIndex,
)
+
+ value = length == -1 ? 100 : length
} else {
value = this._settings.get_int(sizeScales[idx].valueName)
}
@@ -3143,6 +3189,10 @@ const Preferences = class {
}
}
+ maybeSetPanelLengthScaleValueChange(
+ PanelSettings.getPanelLength(this._settings, this._currentMonitorIndex),
+ )
+
this._settings.bind(
'animate-app-switch',
this._builder.get_object('animate_app_switch_switch'),
diff --git a/ui/SettingsPosition.ui b/ui/SettingsPosition.ui
index 24c53ee..c02a88a 100644
--- a/ui/SettingsPosition.ui
+++ b/ui/SettingsPosition.ui
@@ -1,243 +1,226 @@
-
+
+
-
+
-
-
-
\ No newline at end of file
+