Skip to content

Commit d60cdac

Browse files
committed
Add settings option for vertical panel width
1 parent 1c0c1f1 commit d60cdac

6 files changed

Lines changed: 106 additions & 8 deletions

File tree

DEVELOPMENT.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Development Notes
2+
3+
## Applying changes without logout (GNOME 46 Wayland)
4+
5+
On GNOME 46 Wayland, `gnome-extensions disable/enable` does **not** reload
6+
extension JS — GNOME Shell caches ESM modules for the lifetime of the process.
7+
8+
**`prefs.js` changes** take effect immediately — the prefs dialog runs in a
9+
separate process and is freshly spawned each time.
10+
11+
**All other JS changes** (`panel.js`, `appIcons.js`, `taskbar.js`, etc.) require
12+
a shell restart to clear the module cache.
13+
14+
### Restarting the shell without logging out
15+
16+
Use **Looking Glass** (`Alt+F2` → type `lg` → Enter), go to the **Console** tab,
17+
and run:
18+
19+
```js
20+
Meta.restart("Restarting...", global.context)
21+
```
22+
23+
This restarts the GNOME Shell process in-place. Wayland clients (apps) survive and
24+
reconnect; the shell reloads all extension JS from disk.
25+
26+
> Note: `Alt+F2 → r` (the classic X11 shortcut) is **disabled** on Wayland.
27+
> `Meta.restart()` with two arguments is required on GNOME 46+.
28+
29+
### Looking Glass inspector
30+
31+
Looking Glass also has an **Inspector** (pick-icon in the toolbar): click it, then
32+
click any shell actor on screen to inspect its properties, style, children, and
33+
allocation in real time. Useful for diagnosing layout/centering issues without
34+
adding `log()` calls.
35+
36+
## Clutter BoxLayout: x_expand vs x_align
37+
38+
When a child of `St.BoxLayout` / `Clutter.BoxLayout` has `x_expand: true`, the
39+
layout gives it a larger **slot** (natural size + extra space). However, `x_align`
40+
controls how the child uses that slot:
41+
42+
- `x_align = START` / `CENTER` / `END`: actor uses only its **natural width** within
43+
the slot, positioned accordingly. Extra space is wasted. ClutterText inside will
44+
ellipsize at its natural width even though the slot is bigger.
45+
- `x_align = FILL`: actor **fills the entire slot**. ClutterText gets the full width
46+
and only ellipsizes when text genuinely doesn't fit.
47+
48+
So for a label that should fill available horizontal space, always pair
49+
`x_expand: true` with `x_align: Clutter.ActorAlign.FILL`. The text inside will
50+
still render left-to-right (left-aligned) naturally.
51+
52+
### Evaluating JS against live shell objects
53+
54+
```js
55+
// Get the DTP panel actor
56+
Main.layoutManager.panelBox
57+
// Inspect an actor's allocation
58+
let a = Main.panel._leftBox; a.get_allocation_box()
59+
```

schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@
110110
<summary>Panel size (Deprecated)</summary>
111111
<description>Set the size of the panel.</description>
112112
</key>
113+
<key type="i" name="panel-vertical-width">
114+
<default>0</default>
115+
<summary>Vertical panel width override</summary>
116+
<description>Override total panel width when in vertical (left/right) mode. 0 = automatic (panel-size + label width).</description>
117+
</key>
113118
<key type="b" name="desktop-line-use-custom-color">
114119
<default>false</default>
115120
<summary>Override Show Desktop line color</summary>

src/appIcons.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,12 @@ export const TaskbarAppIcon = GObject.registerClass(
164164
this._container = new St.Widget({
165165
style_class: 'dtp-container',
166166
layout_manager: new Clutter.BinLayout(),
167+
x_expand: true,
167168
})
168169
this._dotsContainer = new St.Widget({
169170
style_class: 'dtp-dots-container',
170171
layout_manager: new Clutter.BinLayout(),
172+
x_expand: true,
171173
})
172174
this._dtpIconContainer = new St.Widget({
173175
layout_manager: new Clutter.BinLayout(),
@@ -180,11 +182,12 @@ export const TaskbarAppIcon = GObject.registerClass(
180182
this._dtpIconContainer.add_child(this._iconContainer)
181183

182184
if (appInfo.window) {
183-
let box = Utils.createBoxLayout()
185+
let box = Utils.createBoxLayout({ x_expand: true })
184186

185187
this._windowTitle = new St.Label({
186188
y_align: Clutter.ActorAlign.CENTER,
187-
x_align: Clutter.ActorAlign.START,
189+
x_align: Clutter.ActorAlign.FILL,
190+
x_expand: true,
188191
style_class: 'overview-label',
189192
})
190193

@@ -751,7 +754,7 @@ export const TaskbarAppIcon = GObject.registerClass(
751754
'font-weight: ' +
752755
fontWeight +
753756
';' +
754-
(useFixedWidth ? '' : 'max-width: ' + maxLabelWidth + 'px;') +
757+
(useFixedWidth || this.dtpPanel.geom.vertical ? '' : 'max-width: ' + maxLabelWidth + 'px;') +
755758
'color: ' +
756759
fontColor,
757760
)

src/panel.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ export const Panel = GObject.registerClass(
683683
if (isVertical) {
684684
this._signalsHandler.add([
685685
SETTINGS,
686-
'changed::group-apps-label-max-width',
686+
['changed::group-apps-label-max-width', 'changed::panel-vertical-width'],
687687
() => this._resetGeometry(),
688688
])
689689
}
@@ -822,6 +822,10 @@ export const Panel = GObject.registerClass(
822822
this.fixedCoord = { c1: 'x1', c2: 'x2' }
823823
this.varCoord = { c1: 'y1', c2: 'y2' }
824824

825+
const panelVerticalWidth = SETTINGS.get_int('panel-vertical-width')
826+
if (panelVerticalWidth > 0) {
827+
innerSize = outerSize = panelVerticalWidth * scaleFactor
828+
}
825829
w = innerSize
826830
h = this.monitor.height * length - topBottomMargins - gsTopPanelHeight
827831
dockMode = !!dynamic || topBottomMargins > 0 || h < this.monitor.height
@@ -1142,10 +1146,10 @@ export const Panel = GObject.registerClass(
11421146

11431147
// add existing theme padding to dtp panel margins
11441148
this.panelBox.set_style(
1145-
`padding:
1146-
${this.geom.topOffset + topBottomMargins + padding[St.Side.TOP]}px
1147-
${sideMargins + padding[St.Side.RIGHT]}px
1148-
${topBottomMargins + padding[St.Side.BOTTOM]}px
1149+
`padding:
1150+
${this.geom.topOffset + topBottomMargins + padding[St.Side.TOP]}px
1151+
${sideMargins + padding[St.Side.RIGHT]}px
1152+
${topBottomMargins + padding[St.Side.BOTTOM]}px
11491153
${sideMargins + padding[St.Side.LEFT]}px;`,
11501154
)
11511155
}

src/prefs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,6 +3346,11 @@ const Preferences = class {
33463346
},
33473347
},
33483348
panelLengthScale,
3349+
{
3350+
objectName: 'panel_vertical_width_scale',
3351+
valueName: 'panel-vertical-width',
3352+
range: [800, 0],
3353+
},
33493354
{
33503355
objectName: 'tray_size_scale',
33513356
valueName: 'tray-size',

ui/SettingsStyle.ui

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
<!-- interface-name SettingsStyle.ui -->
44
<requires lib="gtk" version="4.0"/>
55
<requires lib="libadwaita" version="1.6"/>
6+
<object class="GtkAdjustment" id="panel_vertical_width_adjustment">
7+
<property name="lower">0</property>
8+
<property name="upper">800</property>
9+
<property name="step-increment">1</property>
10+
<property name="page-increment">10</property>
11+
</object>
612
<object class="GtkAdjustment" id="appicon_margin_adjustment">
713
<property name="lower">0.33</property>
814
<property name="page-increment">0.1</property>
@@ -286,6 +292,22 @@
286292
<child>
287293
<object class="AdwPreferencesGroup" id="style_group_dynamic_trans">
288294
<property name="title" translatable="yes">Panel style</property>
295+
<child>
296+
<object class="AdwActionRow" id="panel_vertical_width_row">
297+
<property name="subtitle" translatable="yes">(vertical mode only, 0 = auto)</property>
298+
<property name="title" translatable="yes">Vertical panel width</property>
299+
<child>
300+
<object class="GtkScale" id="panel_vertical_width_scale">
301+
<property name="adjustment">panel_vertical_width_adjustment</property>
302+
<property name="digits">0</property>
303+
<property name="draw-value">True</property>
304+
<property name="round-digits">0</property>
305+
<property name="value-pos">right</property>
306+
<property name="width-request">300</property>
307+
</object>
308+
</child>
309+
</object>
310+
</child>
289311
<child>
290312
<object class="AdwActionRow">
291313
<property name="subtitle" translatable="yes">(default is 0)</property>

0 commit comments

Comments
 (0)