Skip to content

Commit

Permalink
GWL: add custom labeled button width
Browse files Browse the repository at this point in the history
  • Loading branch information
expiredhotdog committed Jan 1, 2025
1 parent 09b9d13 commit 2510456
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ class GroupedWindowListApplet extends Applet.Applet {
{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},
{key: 'set-labeled-button-width', value: 'setLabeledButtonWidth', cb: this.refreshAllWorkspaces},
{key: 'labeled-button-width', value: 'labeledButtonWidth', cb: this.refreshAllWorkspaces},
{key: 'thumbnail-scroll-behavior', value: 'thumbnailScrollBehavior', cb: null},
{key: 'show-thumbnails', value: 'showThumbs', cb: this.updateVerticalThumbnailState},
{key: 'animate-thumbnails', value: 'animateThumbs', cb: null},
Expand Down Expand Up @@ -613,10 +615,7 @@ class GroupedWindowListApplet extends Applet.Applet {
}

updateTitleDisplay(titleDisplay) {
if (titleDisplay === TitleDisplay.None
|| this.state.lastTitleDisplay === TitleDisplay.None) {
this.refreshCurrentWorkspace();
}
this.refreshAllWorkspaces();

this.workspaces.forEach( workspace => {
workspace.appGroups.forEach( appGroup => {
Expand Down Expand Up @@ -699,8 +698,8 @@ class GroupedWindowListApplet extends Applet.Applet {
if( (this.state.settings.thumbnailScrollBehavior) || (this.state.settings.scrollBehavior === 2) ||
(this.state.settings.leftClickAction === 3 && this.state.settings.scrollBehavior !== 3
&& !e && sourceFromAppGroup) ||
(this.state.settings.leftClickAction !== 3 && this.state.settings.scrollBehavior === 3
&& e && !sourceFromAppGroup) ||
(this.state.settings.leftClickAction !== 3 && this.state.settings.scrollBehavior === 3
&& e && !sourceFromAppGroup) ||
(this.state.settings.leftClickAction === 3 && this.state.settings.scrollBehavior === 3)) {

this.state.set({scrollActive: true});
Expand Down Expand Up @@ -808,7 +807,7 @@ class GroupedWindowListApplet extends Applet.Applet {
let pos = 0;
while(pos < this.state.dragging.posList.length && axis[0] > this.state.dragging.posList[pos])
pos++;

let favLength = 0;
for (const appGroup of currentWorkspace.appGroups) {
if(appGroup.groupState.isFavoriteApp)
Expand Down Expand Up @@ -925,15 +924,15 @@ class GroupedWindowListApplet extends Applet.Applet {
favorite => favorite.id === source.groupState.appId
);
if (refFav > -1) {

const pinned = []; //pinned apps found before source
for (const appGroup of currentWorkspace.appGroups) {
if(appGroup.groupState.appId == source.groupState.appId)
break;
if(!pinned.includes(appGroup.groupState.appId))
pinned.push(appGroup.groupState.appId);
}

const opts = {
appId: source.groupState.appId,
app: source.groupState.app,
Expand Down Expand Up @@ -1014,7 +1013,7 @@ class GroupedWindowListApplet extends Applet.Applet {
currentWorkspace.windowRemoved(currentWorkspace.metaWorkspace, metaWindow);
return;
}

currentWorkspace.windowAdded(currentWorkspace.metaWorkspace, metaWindow);
}

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 2510456

Please sign in to comment.