Skip to content

Commit

Permalink
GWL: add custom width for labeled buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
expiredhotdog committed Jan 2, 2025
1 parent cce5d78 commit e22d393
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
18 changes: 13 additions & 5 deletions files/usr/share/cinnamon/applets/[email protected]/appGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions files/usr/share/cinnamon/applets/[email protected]/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit e22d393

Please sign in to comment.