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: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/344>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user