From 5b73960f34ada5e93d6cd4b670e509a0bd5248ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 01/11] extensions: Stop using :margin shortcut The property has been removed in GTK4, so prepare for a port by setting the four individual margin properties instead. Part-of: --- extensions/user-theme/prefs.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js index 241e3c98..029483ce 100644 --- a/extensions/user-theme/prefs.js +++ b/extensions/user-theme/prefs.js @@ -33,7 +33,10 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { halign: Gtk.Align.CENTER, valign: Gtk.Align.START, hexpand: true, - margin: 60, + margin_start: 60, + margin_end: 60, + margin_top: 60, + margin_bottom: 60, }); this._list.get_style_context().add_class('frame'); this._list.set_header_func(this._updateHeader.bind(this)); @@ -141,7 +144,10 @@ class ThemeRow extends Gtk.ListBoxRow { const box = new Gtk.Box({ spacing: 12, - margin: 12, + margin_start: 12, + margin_end: 12, + margin_top: 12, + margin_bottom: 12, }); this.add(box); -- GitLab From b83d38a72e70d149907c0eb1b392266c9b29446a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 02/11] user-theme: Track GSettings to sync checkmark GTK4 removes the generic GtkWidget API for accessing an inserted action group, so we need an alternative for tracking the currently selected theme. Using the underlying GSettings object looks like the easiest option, so do that. Part-of: --- extensions/user-theme/prefs.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js index 029483ce..a92be0c8 100644 --- a/extensions/user-theme/prefs.js +++ b/extensions/user-theme/prefs.js @@ -93,7 +93,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { } _addTheme(name) { - const row = new ThemeRow(name); + const row = new ThemeRow(name, this._settings); this._rows.set(name, row); this._list.add(row); @@ -134,12 +134,13 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { const ThemeRow = GObject.registerClass( class ThemeRow extends Gtk.ListBoxRow { - _init(name) { - this._name = new GLib.Variant('s', name); + _init(name, settings) { + this._name = name; + this._settings = settings; super._init({ action_name: 'theme.name', - action_target: this._name, + action_target: new GLib.Variant('s', name), }); const box = new Gtk.Box({ @@ -167,20 +168,19 @@ class ThemeRow extends Gtk.ListBoxRow { box.show_all(); - const id = this.connect('parent-set', () => { - this.disconnect(id); + const id = this._settings.connect('changed::name', + this._syncCheckmark.bind(this)); + this._syncCheckmark(); - const actionGroup = this.get_action_group('theme'); - actionGroup.connect('action-state-changed::name', - this._syncCheckmark.bind(this)); - this._syncCheckmark(); + this.connect('destroy', () => { + this._settings.disconnect(id); + this._settings = null; }); } _syncCheckmark() { - const actionGroup = this.get_action_group('theme'); - const state = actionGroup.get_action_state('name'); - this._checkmark.opacity = this._name.equal(state); + const visible = this._name === this._settings.get_string('name'); + this._checkmark.opacity = visible ? 1. : 0; } }); -- GitLab From 3bef6be7c1d2d9884baf65f3ac993fa55dfbb405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 03/11] user-theme: Port to GTK4 With the previous preparations in place, the actual GTK4 port is now trivial: - replace Gtk.Container methods with widget-specific methods - stop using show_all() Part-of: --- extensions/user-theme/prefs.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js index a92be0c8..a36be263 100644 --- a/extensions/user-theme/prefs.js +++ b/extensions/user-theme/prefs.js @@ -26,7 +26,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { }); const box = new Gtk.Box(); - this.add(box); + this.set_child(box); this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.NONE, @@ -40,7 +40,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { }); this._list.get_style_context().add_class('frame'); this._list.set_header_func(this._updateHeader.bind(this)); - box.add(this._list); + box.append(this._list); this._actionGroup = new Gio.SimpleActionGroup(); this._list.insert_action_group('theme', this._actionGroup); @@ -96,8 +96,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { const row = new ThemeRow(name, this._settings); this._rows.set(name, row); - this._list.add(row); - row.show_all(); + this._list.append(row); } async _enumerateDir(dir) { @@ -138,11 +137,6 @@ class ThemeRow extends Gtk.ListBoxRow { this._name = name; this._settings = settings; - super._init({ - action_name: 'theme.name', - action_target: new GLib.Variant('s', name), - }); - const box = new Gtk.Box({ spacing: 12, margin_start: 12, @@ -150,9 +144,13 @@ class ThemeRow extends Gtk.ListBoxRow { margin_top: 12, margin_bottom: 12, }); - this.add(box); + super._init({ + action_name: 'theme.name', + action_target: new GLib.Variant('s', name), + child: box, + }); - box.add(new Gtk.Label({ + box.append(new Gtk.Label({ label: name || 'Default', hexpand: true, xalign: 0, @@ -164,9 +162,7 @@ class ThemeRow extends Gtk.ListBoxRow { icon_name: 'emblem-ok-symbolic', pixel_size: 16, }); - box.add(this._checkmark); - - box.show_all(); + box.append(this._checkmark); const id = this._settings.connect('changed::name', this._syncCheckmark.bind(this)); @@ -188,8 +184,5 @@ function init() { } function buildPrefsWidget() { - let widget = new UserThemePrefsWidget(); - widget.show_all(); - - return widget; + return new UserThemePrefsWidget(); } -- GitLab From 96dd4f9835d7e7b09616109ec05b8fdc3b1ac6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 04/11] window-list: Port to GTK4 Another easy port: - replace Gtk.Container methods - stop using show_all() - Gtk.CheckButton now provides the Gtk.RadioButton functionality as well Part-of: --- extensions/window-list/prefs.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/extensions/window-list/prefs.js b/extensions/window-list/prefs.js index 58ebf2a6..217c2224 100644 --- a/extensions/window-list/prefs.js +++ b/extensions/window-list/prefs.js @@ -27,7 +27,7 @@ class WindowListPrefsWidget extends Gtk.Box { }); let groupingLabel = '%s'.format(_('Window Grouping')); - this.add(new Gtk.Label({ + this.append(new Gtk.Label({ label: groupingLabel, use_markup: true, halign: Gtk.Align.START, })); @@ -37,7 +37,7 @@ class WindowListPrefsWidget extends Gtk.Box { spacing: 12, margin_bottom: 12, }); - this.add(box); + this.append(box); const context = box.get_style_context(); const cssProvider = new Gtk.CssProvider(); @@ -70,13 +70,13 @@ class WindowListPrefsWidget extends Gtk.Box { continue; } - radio = new Gtk.RadioButton({ + radio = new Gtk.CheckButton({ active: !i, label, group: radio, margin_end: 12, }); - box.add(radio); + box.append(radio); if (currentMode === mode) currentRadio = radio; @@ -94,15 +94,13 @@ class WindowListPrefsWidget extends Gtk.Box { label: _('Show on all monitors'), }); this._settings.bind('show-on-all-monitors', check, 'active', Gio.SettingsBindFlags.DEFAULT); - this.add(check); + this.append(check); check = new Gtk.CheckButton({ label: _('Show windows from all workspaces'), }); this._settings.bind('display-all-workspaces', check, 'active', Gio.SettingsBindFlags.DEFAULT); - this.add(check); - - this.show_all(); + this.append(check); } }); -- GitLab From 67d96993ce8cffaab23c9c06c510ede42fc527be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 05/11] auto-move-windows: Port to GTK4 Just like the previous ports, this consists mostly of replacing the old Gtk.Container methods. Part-of: --- extensions/auto-move-windows/prefs.js | 74 ++++++++++++--------------- 1 file changed, 32 insertions(+), 42 deletions(-) diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js index 13244515..5db6c858 100644 --- a/extensions/auto-move-windows/prefs.js +++ b/extensions/auto-move-windows/prefs.js @@ -29,9 +29,9 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { margin_start: 36, margin_end: 36, }); - this.add(box); + this.set_child(box); - box.add(new Gtk.Label({ + box.append(new Gtk.Label({ label: '%s'.format(_('Workspace Rules')), use_markup: true, halign: Gtk.Align.START, @@ -42,7 +42,7 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { valign: Gtk.Align.START, }); this._list.set_header_func(this._updateHeader.bind(this)); - box.add(this._list); + box.append(this._list); const context = this._list.get_style_context(); const cssProvider = new Gtk.CssProvider(); @@ -53,7 +53,7 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_class('frame'); - this._list.add(new NewRuleRow()); + this._list.append(new NewRuleRow()); this._actionGroup = new Gio.SimpleActionGroup(); this._list.insert_action_group('rules', this._actionGroup); @@ -84,12 +84,10 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { this._sync(); this.connect('destroy', () => this._settings.run_dispose()); - - this.show_all(); } _onAddActivated() { - const dialog = new NewRuleDialog(this.get_toplevel()); + const dialog = new NewRuleDialog(this.get_root()); dialog.connect('response', (dlg, id) => { const appInfo = id === Gtk.ResponseType.OK ? dialog.get_widget().get_app_info() : null; @@ -101,6 +99,7 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { } dialog.destroy(); }); + dialog.show(); } _onRemoveActivated(action, param) { @@ -113,7 +112,7 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { } _getRuleRows() { - return this._list.get_children().filter(row => !!row.id); + return [...this._list].filter(row => !!row.id); } _sync() { @@ -139,7 +138,7 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { const removed = oldRules.filter( ({ id }) => !newRules.find(r => r.id === id)); - removed.forEach(r => r.destroy()); + removed.forEach(r => this._list.remove(r)); this._settings.unblock_signal_handler(this._changedId); this._updateAction.enabled = true; @@ -165,12 +164,6 @@ const RuleRow = GObject.registerClass({ }, }, class RuleRow extends Gtk.ListBoxRow { _init(appInfo, value) { - super._init({ - activatable: false, - value, - }); - this._appInfo = appInfo; - const box = new Gtk.Box({ spacing: 6, margin_top: 6, @@ -179,12 +172,19 @@ const RuleRow = GObject.registerClass({ margin_end: 6, }); + super._init({ + activatable: false, + value, + child: box, + }); + this._appInfo = appInfo; + const icon = new Gtk.Image({ gicon: appInfo.get_icon(), pixel_size: 32, }); icon.get_style_context().add_class('icon-dropshadow'); - box.add(icon); + box.append(icon); const label = new Gtk.Label({ label: appInfo.get_display_name(), @@ -193,7 +193,7 @@ const RuleRow = GObject.registerClass({ max_width_chars: 20, ellipsize: Pango.EllipsizeMode.END, }); - box.add(label); + box.append(label); const spinButton = new Gtk.SpinButton({ adjustment: new Gtk.Adjustment({ @@ -207,26 +207,20 @@ const RuleRow = GObject.registerClass({ this.bind_property('value', spinButton, 'value', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.BIDIRECTIONAL); - box.add(spinButton); + box.append(spinButton); const button = new Gtk.Button({ action_name: 'rules.remove', action_target: new GLib.Variant('s', this.id), - image: new Gtk.Image({ + child: new Gtk.Image({ icon_name: 'edit-delete-symbolic', pixel_size: 16, }), }); - box.add(button); - - this.add(box); - - this.connect('notify::value', () => { - const actionGroup = this.get_action_group('rules'); - actionGroup.activate_action('update', null); - }); + box.append(button); - this.show_all(); + this.connect('notify::value', + () => this.activate_action('rules.update', null)); } get id() { @@ -239,19 +233,17 @@ class NewRuleRow extends Gtk.ListBoxRow { _init() { super._init({ action_name: 'rules.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.get_accessible().set_name(_('Add Rule')); - - this.add(new Gtk.Image({ - icon_name: 'list-add-symbolic', - pixel_size: 16, - margin_top: 12, - margin_bottom: 12, - margin_start: 12, - margin_end: 12, - })); - - this.show_all(); + this.update_property( + [Gtk.AccessibleProperty.LABEL], [_('Add Rule')]); } }); @@ -273,8 +265,6 @@ class NewRuleDialog extends Gtk.AppChooserDialog { this.get_widget().connect('application-selected', this._updateSensitivity.bind(this)); this._updateSensitivity(); - - this.show(); } _updateSensitivity() { -- GitLab From 22ea58a849e057e152ceb54347813726dc022ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 06/11] workspace-indicator: Port to GTK4 With this port, all extensions now use GTK4 for their preferences. Part-of: --- extensions/workspace-indicator/prefs.js | 71 +++++++++++-------------- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js index 011953be..5d781620 100644 --- a/extensions/workspace-indicator/prefs.js +++ b/extensions/workspace-indicator/prefs.js @@ -1,7 +1,7 @@ // -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- /* exported init buildPrefsWidget */ -const { Gdk, Gio, GLib, GObject, Gtk, Pango } = imports.gi; +const { Gio, GLib, GObject, Gtk, Pango } = imports.gi; const Gettext = imports.gettext.domain('gnome-shell-extensions'); const _ = Gettext.gettext; @@ -28,9 +28,9 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { margin_start: 36, margin_end: 36, }); - this.add(box); + this.set_child(box); - box.add(new Gtk.Label({ + box.append(new Gtk.Label({ label: '%s'.format(_('Workspace Names')), use_markup: true, halign: Gtk.Align.START, @@ -42,7 +42,7 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { }); this._list.set_header_func(this._updateHeader.bind(this)); this._list.connect('row-activated', (l, row) => row.edit()); - box.add(this._list); + box.append(this._list); const context = this._list.get_style_context(); const cssProvider = new Gtk.CssProvider(); @@ -53,7 +53,7 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); context.add_class('frame'); - this._list.add(new NewWorkspaceRow()); + this._list.append(new NewWorkspaceRow()); this._actionGroup = new Gio.SimpleActionGroup(); this._list.insert_action_group('workspaces', this._actionGroup); @@ -94,12 +94,10 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { this._settings.connect(`changed::${WORKSPACE_KEY}`, this._sync.bind(this)); this._sync(); - - this.show_all(); } _getWorkspaceRows() { - return this._list.get_children().filter(row => row.name); + return [...this._list].filter(row => row.name); } _sync() { @@ -111,7 +109,7 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { const removed = oldNames.filter(n => !newNames.includes(n)); const added = newNames.filter(n => !oldNames.includes(n)); - removed.forEach(n => rows.find(r => r.name === n).destroy()); + removed.forEach(n => this._list.remove(rows.find(r => r.name === n))); added.forEach(n => { this._list.insert(new WorkspaceRow(n), newNames.indexOf(n)); }); @@ -129,6 +127,13 @@ class WorkspaceRow extends Gtk.ListBoxRow { _init(name) { super._init({ name }); + const controller = new Gtk.ShortcutController(); + controller.add_shortcut(new Gtk.Shortcut({ + trigger: Gtk.ShortcutTrigger.parse_string('Escape'), + action: Gtk.CallbackAction.new(this._stopEdit.bind(this)), + })); + this.add_controller(controller); + const box = new Gtk.Box({ spacing: 12, margin_top: 6, @@ -145,7 +150,7 @@ class WorkspaceRow extends Gtk.ListBoxRow { }); this.bind_property('name', label, 'label', GObject.BindingFlags.SYNC_CREATE); - box.add(label); + box.append(label); const image = new Gtk.Image({ icon_name: 'edit-delete-symbolic', @@ -154,9 +159,9 @@ class WorkspaceRow extends Gtk.ListBoxRow { const button = new Gtk.Button({ action_name: 'workspaces.remove', action_target: new GLib.Variant('s', name), - image, + child: image, }); - box.add(button); + box.append(button); this._entry = new Gtk.Entry({ max_width_chars: 25, @@ -165,7 +170,7 @@ class WorkspaceRow extends Gtk.ListBoxRow { this._stack = new Gtk.Stack(); this._stack.add_named(box, 'display'); this._stack.add_named(this._entry, 'edit'); - this.add(this._stack); + this.child = this._stack; this._entry.connect('activate', () => { this.name = this._entry.text; @@ -176,17 +181,11 @@ class WorkspaceRow extends Gtk.ListBoxRow { return; this._stopEdit(); }); - this._entry.connect('key-press-event', - this._onEntryKeyPress.bind(this)); this.connect('notify::name', () => { button.action_target = new GLib.Variant('s', this.name); - - const actionGroup = this.get_action_group('workspaces'); - actionGroup.activate_action('update', null); + this.activate_action('workspaces.update', null); }); - - this.show_all(); } edit() { @@ -199,14 +198,6 @@ class WorkspaceRow extends Gtk.ListBoxRow { this.grab_focus(); this._stack.visible_child_name = 'display'; } - - _onEntryKeyPress(entry, event) { - const [, keyval] = event.get_keyval(); - if (keyval !== Gdk.KEY_Escape) - return Gdk.EVENT_PROPAGATE; - this._stopEdit(); - return Gdk.EVENT_STOP; - } }); const NewWorkspaceRow = GObject.registerClass( @@ -214,19 +205,17 @@ class NewWorkspaceRow extends Gtk.ListBoxRow { _init() { super._init({ action_name: 'workspaces.add', - }); - this.get_accessible().set_name(_('Add Workspace')); - - this.add(new Gtk.Image({ - icon_name: 'list-add-symbolic', - pixel_size: 16, - margin_top: 12, - margin_bottom: 12, - margin_start: 12, - margin_end: 12, - })); - - this.show_all(); + 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')]); } }); -- GitLab From d5c31273ee50bb3436a471cca26f7b0cc71e9b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 07/11] auto-move-windows: Stop using header func for separators GTK4 added built-in support for this common pattern, so use that instead. Part-of: --- extensions/auto-move-windows/prefs.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js index 5db6c858..3b7e1332 100644 --- a/extensions/auto-move-windows/prefs.js +++ b/extensions/auto-move-windows/prefs.js @@ -40,8 +40,8 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.NONE, valign: Gtk.Align.START, + show_separators: true, }); - this._list.set_header_func(this._updateHeader.bind(this)); box.append(this._list); const context = this._list.get_style_context(); @@ -143,12 +143,6 @@ class AutoMoveSettingsWidget extends Gtk.ScrolledWindow { this._settings.unblock_signal_handler(this._changedId); this._updateAction.enabled = true; } - - _updateHeader(row, before) { - if (!before || row.get_header()) - return; - row.set_header(new Gtk.Separator()); - } }); const RuleRow = GObject.registerClass({ -- GitLab From 53f5a92dc8de814d97f7970af05ce675a6bd7350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 08/11] user-theme: Stop using header func for separators GTK4 provides built-in support for this common pattern, so use that instead. Part-of: --- extensions/user-theme/prefs.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/extensions/user-theme/prefs.js b/extensions/user-theme/prefs.js index a36be263..b9c12fa0 100644 --- a/extensions/user-theme/prefs.js +++ b/extensions/user-theme/prefs.js @@ -30,6 +30,7 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.NONE, + show_separators: true, halign: Gtk.Align.CENTER, valign: Gtk.Align.START, hexpand: true, @@ -39,7 +40,6 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { margin_bottom: 60, }); this._list.get_style_context().add_class('frame'); - this._list.set_header_func(this._updateHeader.bind(this)); box.append(this._list); this._actionGroup = new Gio.SimpleActionGroup(); @@ -123,12 +123,6 @@ class UserThemePrefsWidget extends Gtk.ScrolledWindow { return fileInfos.map(info => info.get_name()); } - - _updateHeader(row, before) { - if (!before || row.get_header()) - return; - row.set_header(new Gtk.Separator()); - } }); const ThemeRow = GObject.registerClass( -- GitLab From f0ff0e14007144ec3f0e694c125bdb9352a42ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 09/11] workspace-indicator: Stop using header func for separators GTK4 added built-in support for this common pattern, so use that instead. Part-of: --- extensions/workspace-indicator/prefs.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js index 5d781620..374c14f6 100644 --- a/extensions/workspace-indicator/prefs.js +++ b/extensions/workspace-indicator/prefs.js @@ -39,8 +39,8 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { this._list = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.NONE, valign: Gtk.Align.START, + show_separators: true, }); - this._list.set_header_func(this._updateHeader.bind(this)); this._list.connect('row-activated', (l, row) => row.edit()); box.append(this._list); @@ -114,12 +114,6 @@ class WorkspaceSettingsWidget extends Gtk.ScrolledWindow { this._list.insert(new WorkspaceRow(n), newNames.indexOf(n)); }); } - - _updateHeader(row, before) { - if (!before || row.get_header()) - return; - row.set_header(new Gtk.Separator()); - } }); const WorkspaceRow = GObject.registerClass( -- GitLab From 5df0fa145bc797fc1d51ca653683ab7d9d453a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 10/11] workspace-indicator: Use Gtk.Button.icon_name property Image buttons are a very common pattern, so GTK4 added some convenience API we can use to construct them. Part-of: --- extensions/workspace-indicator/prefs.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extensions/workspace-indicator/prefs.js b/extensions/workspace-indicator/prefs.js index 374c14f6..d45d1e81 100644 --- a/extensions/workspace-indicator/prefs.js +++ b/extensions/workspace-indicator/prefs.js @@ -146,14 +146,10 @@ class WorkspaceRow extends Gtk.ListBoxRow { GObject.BindingFlags.SYNC_CREATE); box.append(label); - const image = new Gtk.Image({ - icon_name: 'edit-delete-symbolic', - pixel_size: 16, - }); const button = new Gtk.Button({ action_name: 'workspaces.remove', action_target: new GLib.Variant('s', name), - child: image, + icon_name: 'edit-delete-symbolic', }); box.append(button); -- GitLab From d381a0b89b845b58200c2c9d55b41e071678584f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 23:32:20 +0200 Subject: [PATCH 11/11] auto-move-windows: Use Gtk.Button.icon_name property Image buttons are a very common pattern, so GTK4 added some convenience API we can use to construct them. Part-of: --- extensions/auto-move-windows/prefs.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/auto-move-windows/prefs.js b/extensions/auto-move-windows/prefs.js index 3b7e1332..c5504584 100644 --- a/extensions/auto-move-windows/prefs.js +++ b/extensions/auto-move-windows/prefs.js @@ -206,10 +206,7 @@ const RuleRow = GObject.registerClass({ const button = new Gtk.Button({ action_name: 'rules.remove', action_target: new GLib.Variant('s', this.id), - child: new Gtk.Image({ - icon_name: 'edit-delete-symbolic', - pixel_size: 16, - }), + icon_name: 'edit-delete-symbolic', }); box.append(button); -- GitLab