From e22d393748793500344c3b527ef196c0b51899d6 Mon Sep 17 00:00:00 2001 From: expiredhotdog Date: Thu, 2 Jan 2025 12:35:18 -0800 Subject: [PATCH] GWL: add custom width for labeled buttons --- .../appGroup.js | 18 +++++++++++++----- .../grouped-window-list@cinnamon.org/applet.js | 2 ++ .../settings-schema.json | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js index 6a0f0990c5..229eb316ec 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/appGroup.js @@ -350,9 +350,16 @@ class AppGroup { if (this.state.orientation === St.Side.TOP || this.state.orientation === St.Side.BOTTOM) { if (allocateForLabel) { - const max = this.labelVisiblePref && this.groupState.metaWindows.length > 0 ? - labelNaturalSize + iconNaturalSize + 6 : 0; - alloc.natural_size = Math.min(iconNaturalSize + Math.max(max, labelNaturalSize), MAX_BUTTON_WIDTH * global.ui_scale); + if (this.state.settings.setLabeledButtonWidth && this.labelVisiblePref) { + alloc.natural_size = this.state.settings.labeledButtonWidth; + } else { + const max = this.labelVisiblePref && this.groupState.metaWindows.length > 0 ? + labelNaturalSize + iconNaturalSize + 6 : 0; + alloc.natural_size = Math.min( + iconNaturalSize + Math.max(max, labelNaturalSize), + MAX_BUTTON_WIDTH * global.ui_scale + ); + } } else { alloc.natural_size = iconNaturalSize + 6 * global.ui_scale; } @@ -459,7 +466,8 @@ class AppGroup { return; } - const width = MAX_BUTTON_WIDTH * global.ui_scale; + const width = this.state.settings.setLabeledButtonWidth ? this.state.settings.labeledButtonWidth : + MAX_BUTTON_WIDTH * global.ui_scale; this.labelVisiblePref = true; if (this.label.text == null) { @@ -609,7 +617,7 @@ class AppGroup { if (!this.groupState || !this.groupState.groupReady || this.groupState.willUnmount) { return; } - + this.groupState.metaWindows.forEach( window => { if (window === metaWindow && !getFocusState(window)) { // Even though this may not be the last focused window, we want it to be diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js index 8a81f4ad1c..d792984712 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/applet.js @@ -306,6 +306,8 @@ class GroupedWindowListApplet extends Applet.Applet { {key: 'show-apps-order-timeout', value: 'showAppsOrderTimeout', cb: null}, {key: 'super-num-hotkeys', value: 'SuperNumHotkeys', cb: this.bindAppKeys}, {key: 'title-display', value: 'titleDisplay', cb: this.updateTitleDisplay}, + {key: 'set-labeled-button-width', value: 'setLabeledButtonWidth', cb: this.refreshAllWorkspaces}, + {key: 'labeled-button-width', value: 'labeledButtonWidth', cb: this.refreshAllWorkspaces}, {key: 'launcher-animation-effect', value: 'launcherAnimationEffect', cb: null}, {key: 'number-display', value: 'numDisplay', cb: this.updateWindowNumberState}, {key: 'enable-app-button-dragging', value: 'enableDragging', cb: this.draggableSettingChanged}, diff --git a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json index b86af45073..f35b9448e0 100644 --- a/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json +++ b/files/usr/share/cinnamon/applets/grouped-window-list@cinnamon.org/settings-schema.json @@ -49,6 +49,8 @@ "title" : "Application Buttons", "keys": [ "title-display", + "set-labeled-button-width", + "labeled-button-width", "launcher-animation-effect", "number-display", "enable-app-button-dragging" @@ -174,6 +176,21 @@ "Window title (only for the focused window)": 4 } }, + "set-labeled-button-width": { + "type": "checkbox", + "default": false, + "description": "Set a custom width for labeled buttons" + }, + "labeled-button-width": { + "dependency": "set-labeled-button-width", + "type": "spinbutton", + "default" : 150, + "min" : 5, + "max" : 4000, + "step" : 5, + "units" : "pixels", + "description" : "Labeled button width" + }, "launcher-animation-effect": { "type": "combobox", "default": 3,