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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2786>
This commit is contained in:
Florian Müllner 2023-05-25 22:22:09 +02:00
parent 38c9364acc
commit 8d562ff71c
3 changed files with 18 additions and 24 deletions

View File

@ -5,6 +5,7 @@ overrides:
- files:
- js/ui/init.js
- js/dbusServices/**
- js/portalHelper/**
- subprojects/extensions-app/**
parserOptions:
sourceType: module

View File

@ -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]);

View File

@ -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,
"<main>",
&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);