From e6bc9fc2fc13ad14590cd81c21e0d2e51da52727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 15 Oct 2024 23:21:40 +0200 Subject: [PATCH] workspace-indicator: Use Adw.ButtonRow for new-item row libadwaita added a dedicated widget for button rows, so let's use that instead of rolling our own. While at it, promote the accessible label to the (visible) title to be more in line with current design patterns. Part-of: --- .../workspace-indicator/workspacePrefs.js | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/extensions/workspace-indicator/workspacePrefs.js b/extensions/workspace-indicator/workspacePrefs.js index 39cd2666..63a54a0a 100644 --- a/extensions/workspace-indicator/workspacePrefs.js +++ b/extensions/workspace-indicator/workspacePrefs.js @@ -169,9 +169,15 @@ class WorkspacesGroup extends Adw.PreferencesGroup { this._list.connect('row-activated', (l, row) => row.edit()); this.add(this._list); + const newRowProps = { + title: _('Add Workspace'), + action_name: 'workspaces.add', + start_icon_name: 'list-add-symbolic', + }; + this._list.bind_model(listModel, item => { return item instanceof NewItem - ? new NewWorkspaceRow() + ? new Adw.ButtonRow({...newRowProps}) : new WorkspaceRow(item.string); }); } @@ -260,28 +266,6 @@ class WorkspaceRow extends Adw.PreferencesRow { } } -class NewWorkspaceRow extends Adw.PreferencesRow { - static { - GObject.registerClass(this); - } - - constructor() { - super({ - action_name: 'workspaces.add', - child: new Gtk.Image({ - icon_name: 'list-add-symbolic', - pixel_size: 16, - margin_top: 12, - margin_bottom: 12, - margin_start: 12, - margin_end: 12, - }), - }); - this.update_property( - [Gtk.AccessibleProperty.LABEL], [_('Add Workspace')]); - } -} - export class WorkspacesPage extends Adw.PreferencesPage { static { GObject.registerClass(this);