Skip to content

GWL: add custom labeled button width #12602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 9 additions & 10 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 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