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: - files:
- js/ui/init.js - js/ui/init.js
- js/dbusServices/** - js/dbusServices/**
- js/portalHelper/**
- subprojects/extensions-app/** - subprojects/extensions-app/**
parserOptions: parserOptions:
sourceType: module sourceType: module

View File

@ -1,10 +1,12 @@
/* exported main */ import Adw from 'gi://Adw?version=1';
imports.gi.versions.Adw = '1'; import Gio from 'gi://Gio';
imports.gi.versions.Gtk = '4.0'; import GLib from 'gi://GLib';
imports.gi.versions.WebKit = '6.0'; 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; import * as Gettext from 'gettext';
const {Adw, Gio, GLib, GObject, Gtk, WebKit} = imports.gi; import {programInvocationName, programArgs} from 'system';
const _ = Gettext.gettext; const _ = Gettext.gettext;
@ -360,13 +362,8 @@ class WebPortalHelper extends Adw.Application {
} }
}); });
/** Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
* @param {string[]} argv - command line arguments Gettext.textdomain(Config.GETTEXT_PACKAGE);
*/
function main(argv) {
Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Gettext.textdomain(Config.GETTEXT_PACKAGE);
let app = new WebPortalHelper(); const app = new WebPortalHelper();
return app.run(argv); 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 }; const char *search_path[] = { "resource:///org/gnome/shell", NULL };
GError *error = NULL; GError *error = NULL;
GjsContext *context; GjsContext *context;
int status; uint8_t status;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); 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); gjs_context_set_argv(context, argc - 1, (const char**)argv + 1);
if (!gjs_context_eval (context, if (!gjs_context_eval_module_file (context,
"const Main = imports.portalHelper.main;" "resource:///org/gnome/shell/portalHelper/main.js",
"const {programInvocationName, programArgs} = imports.system;" &status,
"Main.main([programInvocationName, ...programArgs]);", &error))
-1,
"<main>",
&status,
&error))
{ {
g_message ("Execution of main.js threw exception: %s", error->message); g_message ("Execution of main.js threw exception: %s", error->message);
g_error_free (error); g_error_free (error);