From edd34c50d9d247f55267006068cf2305a83edba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Apr 2020 20:27:15 +0200 Subject: [PATCH] Port extensions app and portal to GTK4 With the previous preparations in place, it is time to take the plunge. As both the app and the portal use the same small library for handling external windows, port everything at once to avoid the hassle of building and installing two versions of the library. With the portal using GTK4 now, all extensions must port their preference widgets as well. Part-of: --- .../extensions/extensionsService.js | 12 +- js/dbusServices/extensions/main.js | 6 +- .../extensions/ui/extension-prefs-dialog.ui | 43 +-- .../extensions-app/data/ui/extension-row.ui | 131 +++---- .../data/ui/extensions-window.ui | 327 ++++++++---------- subprojects/extensions-app/js/main.js | 56 +-- subprojects/shew/meson.build | 2 +- subprojects/shew/src/meson.build | 2 +- .../shew/src/shew-external-window-wayland.c | 6 +- .../shew/src/shew-external-window-x11.c | 8 +- subprojects/shew/src/shew-external-window.c | 4 +- subprojects/shew/src/shew-external-window.h | 4 +- subprojects/shew/src/shew-window-exporter.c | 25 +- 13 files changed, 249 insertions(+), 377 deletions(-) diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index 34107cdb3..8217675b0 100644 --- a/js/dbusServices/extensions/extensionsService.js +++ b/js/dbusServices/extensions/extensionsService.js @@ -128,7 +128,7 @@ var ExtensionsService = class extends ServiceImplementation { externalWindow = Shew.ExternalWindow.new_from_handle(parentWindow); if (externalWindow) - externalWindow.set_parent_of(window.window); + externalWindow.set_parent_of(window.get_surface()); if (options.modal) window.modal = options.modal.get_boolean(); @@ -177,11 +177,11 @@ var ExtensionPrefsDialog = GObject.registerClass({ this._initActions(); this._addCustomStylesheet(); - this._gesture = new Gtk.GestureMultiPress({ - widget: this._expander, + this._gesture = new Gtk.GestureClick({ button: 0, exclusive: true, }); + this._expander.add_controller(this._gesture); this._gesture.connect('released', (gesture, nPress) => { if (nPress === 1) @@ -216,9 +216,9 @@ var ExtensionPrefsDialog = GObject.registerClass({ _syncExpandedStyle() { if (this._revealer.reveal_child) - this._expander.get_style_context().add_class('expanded'); + this._expander.add_css_class('expanded'); else if (!this._revealer.child_revealed) - this._expander.get_style_context().remove_class('expanded'); + this._expander.remove_css_class('expanded'); } _setError(exc) { @@ -276,7 +276,7 @@ var ExtensionPrefsDialog = GObject.registerClass({ } catch (e) { logError(e, 'Failed to add application style'); } - Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), + Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); } diff --git a/js/dbusServices/extensions/main.js b/js/dbusServices/extensions/main.js index 9cc4bc5e3..0b6521e9e 100644 --- a/js/dbusServices/extensions/main.js +++ b/js/dbusServices/extensions/main.js @@ -1,7 +1,7 @@ /* exported main */ -imports.gi.versions.Gdk = '3.0'; -imports.gi.versions.Gtk = '3.0'; +imports.gi.versions.Gdk = '4.0'; +imports.gi.versions.Gtk = '4.0'; const { Gtk } = imports.gi; const pkg = imports.package; @@ -10,7 +10,7 @@ const { DBusService } = imports.dbusService; const { ExtensionsService } = imports.extensionsService; function main() { - Gtk.init(null); + Gtk.init(); pkg.initFormat(); const service = new DBusService( diff --git a/js/dbusServices/extensions/ui/extension-prefs-dialog.ui b/js/dbusServices/extensions/ui/extension-prefs-dialog.ui index 851adbf76..c03dc24b9 100644 --- a/js/dbusServices/extensions/ui/extension-prefs-dialog.ui +++ b/js/dbusServices/extensions/ui/extension-prefs-dialog.ui @@ -1,31 +1,22 @@ -