From 8d562ff71cf6ec10f77de857b4ab95ca34702a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 25 May 2023 22:22:09 +0200 Subject: [PATCH] portalHelper: Port to ESM The helper app that provides the login dialog for network portals is another separate process that can be moved to ESM separately. Part-of: --- .eslintrc.yml | 1 + js/portalHelper/main.js | 27 ++++++++++++--------------- src/gnome-shell-portal-helper.c | 14 +++++--------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 4fdede665..4e857e0e0 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -5,6 +5,7 @@ overrides: - files: - js/ui/init.js - js/dbusServices/** + - js/portalHelper/** - subprojects/extensions-app/** parserOptions: sourceType: module diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js index 186259609..1f16537cd 100644 --- a/js/portalHelper/main.js +++ b/js/portalHelper/main.js @@ -1,10 +1,12 @@ -/* exported main */ -imports.gi.versions.Adw = '1'; -imports.gi.versions.Gtk = '4.0'; -imports.gi.versions.WebKit = '6.0'; +import Adw from 'gi://Adw?version=1'; +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; +import GObject from 'gi://GObject'; +import Gtk from 'gi://Gtk?version=4.0'; +import WebKit from 'gi://WebKit?version=6.0'; -const Gettext = imports.gettext; -const {Adw, Gio, GLib, GObject, Gtk, WebKit} = imports.gi; +import * as Gettext from 'gettext'; +import {programInvocationName, programArgs} from 'system'; const _ = Gettext.gettext; @@ -360,13 +362,8 @@ class WebPortalHelper extends Adw.Application { } }); -/** - * @param {string[]} argv - command line arguments - */ -function main(argv) { - Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR); - Gettext.textdomain(Config.GETTEXT_PACKAGE); +Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR); +Gettext.textdomain(Config.GETTEXT_PACKAGE); - let app = new WebPortalHelper(); - return app.run(argv); -} +const app = new WebPortalHelper(); +await app.runAsync([programInvocationName, ...programArgs]); diff --git a/src/gnome-shell-portal-helper.c b/src/gnome-shell-portal-helper.c index 9e03a482d..5e0fb9955 100644 --- a/src/gnome-shell-portal-helper.c +++ b/src/gnome-shell-portal-helper.c @@ -11,7 +11,7 @@ main (int argc, char *argv[]) const char *search_path[] = { "resource:///org/gnome/shell", NULL }; GError *error = NULL; GjsContext *context; - int status; + uint8_t status; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -24,14 +24,10 @@ main (int argc, char *argv[]) gjs_context_set_argv(context, argc - 1, (const char**)argv + 1); - if (!gjs_context_eval (context, - "const Main = imports.portalHelper.main;" - "const {programInvocationName, programArgs} = imports.system;" - "Main.main([programInvocationName, ...programArgs]);", - -1, - "
", - &status, - &error)) + if (!gjs_context_eval_module_file (context, + "resource:///org/gnome/shell/portalHelper/main.js", + &status, + &error)) { g_message ("Execution of main.js threw exception: %s", error->message); g_error_free (error);