diff --git a/README.md b/README.md index a71f5ef..060b1d3 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,8 @@ Dependencies: - `gjs (>= 1.70)` - `gtk4` -- `libadwaita` -- `webkit2gtk4`/`webkit2gtk-5.0` +- `libadwaita (>= 1.4)` +- `webkitgtk-6.0` To install, run `meson builddir && sudo meson install -C builddir` diff --git a/com.github.johnfactotum.QuickLookup.appdata.xml b/com.github.johnfactotum.QuickLookup.appdata.xml index c28b9b7..fdd1c27 100644 --- a/com.github.johnfactotum.QuickLookup.appdata.xml +++ b/com.github.johnfactotum.QuickLookup.appdata.xml @@ -26,6 +26,11 @@ + + +

Upgraded to GNOME 45

+
+

Ported to GTK 4

diff --git a/meson.build b/meson.build index db62f0d..e44c22e 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('com.github.johnfactotum.QuickLookup', - version: '2.0.0', + version: '2.1.0', meson_version: '>=0.49' ) @@ -16,8 +16,8 @@ glib2_dep = dependency('glib-2.0') gio2_dep = dependency('gio-2.0') gjs_dep = dependency('gjs-1.0', version: '>=1.70') gtk4_dep = dependency('gtk4') -webkit_dep = dependency('webkit2gtk-5.0') -libadwaita_dep = dependency('libadwaita-1') +webkit_dep = dependency('webkitgtk-6.0') +libadwaita_dep = dependency('libadwaita-1', version: '>=1.4') bin_conf = configuration_data() bin_conf.set('PACKAGE_VERSION', meson.project_version()) diff --git a/quick-lookup.js b/quick-lookup.js index 3c54425..c1ec463 100644 --- a/quick-lookup.js +++ b/quick-lookup.js @@ -16,9 +16,9 @@ imports.gi.versions.Gio = '2.0' imports.gi.versions.Gtk = '4.0' -imports.gi.versions.WebKit2 = '5.0' +imports.gi.versions.WebKit = '6.0' imports.gi.versions.Adw = '1' -const { GLib, Gio, Gtk, Gdk, WebKit2, Adw } = imports.gi +const { GLib, Gio, Gtk, Gdk, WebKit, Adw } = imports.gi const System = imports.system const pkg = { @@ -72,10 +72,10 @@ const scriptRunner = webView => { } const manager = webView.get_user_content_manager() manager.connect(`script-message-received::handler`, (_, result) => { - try { handler(JSON.parse(result.get_js_value().to_string())) } + try { handler(JSON.parse(result.to_string())) } catch (e) { log(e) } }) - const success = manager.register_script_message_handler('handler') + const success = manager.register_script_message_handler('handler', null) if (!success) throw new Error('failed to register message handler') const exec = (func, params) => { @@ -88,14 +88,14 @@ const scriptRunner = webView => { .catch(e => globalThis.webkit.messageHandlers.handler.postMessage( JSON.stringify({ token: "${token}", ok: false, payload: e.message })))` const promise = makePromise(token) - webView.run_javascript(script, null, () => {}) + webView.evaluate_javascript(script, -1, null, null, null, () => {}) return promise } const eval = exp => new Promise((resolve, reject) => - webView.run_javascript(`JSON.stringify(${exp})`, null, (_, result) => { + webView.evaluate_javascript(`JSON.stringify(${exp})`, -1, null, null, null, (_, result) => { try { - const jsResult = webView.run_javascript_finish(result) - const str = jsResult.get_js_value().to_string() + const jscValue = webView.evaluate_javascript_finish(result) + const str = jscValue.to_string() const value = str !== 'undefined' ? JSON.parse(str) : null resolve(value) } catch (e) { @@ -159,8 +159,8 @@ const wiktionary = ({ word, language }) => fetch('${apiURL}' + word) globalThis.wiktionary = wiktionary })()` -const webView = new WebKit2.WebView({ - settings: new WebKit2.Settings({ +const webView = new WebKit.WebView({ + settings: new WebKit.Settings({ enable_javascript_markup: false, enable_write_console_messages_to_stdout: true, allow_universal_access_from_file_urls: true, @@ -300,9 +300,8 @@ const applicationWindowXml = ` 480 Quick Lookup - - vertical - + + @@ -313,7 +312,7 @@ const applicationWindowXml = ` go-previous-symbolic - Go back + Back win.go-back @@ -372,7 +371,7 @@ const applicationWindowXml = ` - + diff --git a/screenshot.png b/screenshot.png index e9dc5de..55b4a3b 100644 Binary files a/screenshot.png and b/screenshot.png differ