From e7a502e5c34041b2fbd3e17be928b07f7efaba45 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] wip: Port extensions app/portal to GTK4 --- .../extensions/css/application.css | 6 +- .../extensions/extensionsService.js | 17 +- js/dbusServices/extensions/main.js | 6 +- .../extensions/ui/extension-prefs-dialog.ui | 128 +++----- .../extensions-app/data/ui/extension-row.ui | 143 ++++---- .../data/ui/extensions-window.ui | 306 ++++++++---------- subprojects/extensions-app/js/main.js | 45 +-- subprojects/shew/meson.build | 3 +- subprojects/shew/src/meson.build | 4 +- .../shew/src/shew-external-window-wayland.c | 6 +- .../shew/src/shew-external-window-x11.c | 55 ++-- subprojects/shew/src/shew-external-window.c | 4 +- subprojects/shew/src/shew-external-window.h | 4 +- subprojects/shew/src/shew-window-exporter.c | 20 +- 14 files changed, 314 insertions(+), 433 deletions(-) diff --git a/js/dbusServices/extensions/css/application.css b/js/dbusServices/extensions/css/application.css index 06914ea3c..1acbf36c8 100644 --- a/js/dbusServices/extensions/css/application.css +++ b/js/dbusServices/extensions/css/application.css @@ -1,2 +1,6 @@ .expander-frame > * { border-top-width: 0; } -.expander-toolbar { border: 0 solid @borders; border-top-width: 1px; } +.expander-toolbar { + border: 0 solid @borders; + border-top-width: 1px; + padding: 3px; +} diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index 9d444c551..3f94b22de 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(); @@ -156,7 +156,6 @@ var ExtensionPrefsDialog = GObject.registerClass({ GTypeName: 'ExtensionPrefsDialog', Template: 'resource:///org/gnome/Shell/Extensions/ui/extension-prefs-dialog.ui', InternalChildren: [ - 'headerBar', 'stack', 'expander', 'expanderArrow', @@ -165,24 +164,24 @@ var ExtensionPrefsDialog = GObject.registerClass({ ], }, class ExtensionPrefsDialog extends Gtk.Window { _init(extension) { - super._init(); + super._init({ + title: extension.metadata.name, + }); this._uuid = extension.uuid; this._url = extension.metadata.url || ''; - this._headerBar.title = extension.metadata.name; - this._actionGroup = new Gio.SimpleActionGroup(); this.insert_action_group('win', this._actionGroup); 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) @@ -205,7 +204,7 @@ var ExtensionPrefsDialog = GObject.registerClass({ prefsModule.init(extension.metadata); const widget = prefsModule.buildPrefsWidget(); - this._stack.add(widget); + this._stack.add_named(widget, 'prefs'); this._stack.visible_child = widget; } catch (e) { this._setError(e); @@ -267,7 +266,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 fc08eae3c..d21842374 100644 --- a/js/dbusServices/extensions/ui/extension-prefs-dialog.ui +++ b/js/dbusServices/extensions/ui/extension-prefs-dialog.ui @@ -1,38 +1,32 @@ -