extensionPrefs: Use imports.package.start()
We want to make the extensions app code more self-contained to make it easier to build separately, and ultimately make it available on flathub. One complication we are facing is that it is currently all over the source tree: - js/extensionPrefs for the main code - src for the launcher process - data for .desktop file and icons Switching from a C launcher to the imports.package module allows us to consolidate the first two, and will also take care of the annoying setup bits (defining JS search path, extending GI lookup, loading resources). https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081
This commit is contained in:
parent
9829d56bfa
commit
e572d5d08c
2
js/extensionPrefs/gnome-shell-extension-prefs.in
Normal file
2
js/extensionPrefs/gnome-shell-extension-prefs.in
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
@gjs@ @pkgdatadir@/@app_id@ "$@"
|
@ -2,13 +2,13 @@
|
||||
imports.gi.versions.Gdk = '3.0';
|
||||
imports.gi.versions.Gtk = '3.0';
|
||||
|
||||
imports.package.initFormat();
|
||||
|
||||
const Gettext = imports.gettext;
|
||||
const { Gdk, GLib, Gio, GObject, Gtk } = imports.gi;
|
||||
const Format = imports.format;
|
||||
|
||||
const _ = Gettext.gettext;
|
||||
|
||||
const Config = imports.misc.config;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||
|
||||
@ -46,7 +46,7 @@ class Application extends Gtk.Application {
|
||||
super.vfunc_startup();
|
||||
|
||||
let provider = new Gtk.CssProvider();
|
||||
let uri = 'resource:///org/gnome/shell/css/application.css';
|
||||
let uri = 'resource:///org/gnome/Extensions/css/application.css';
|
||||
try {
|
||||
provider.load_from_file(Gio.File.new_for_uri(uri));
|
||||
} catch (e) {
|
||||
@ -61,11 +61,9 @@ class Application extends Gtk.Application {
|
||||
}
|
||||
|
||||
vfunc_command_line(commandLine) {
|
||||
let args = commandLine.get_arguments();
|
||||
|
||||
if (args.length) {
|
||||
let uuid = args[0];
|
||||
let [prgName_, uuid] = commandLine.get_arguments();
|
||||
|
||||
if (uuid) {
|
||||
// Strip off "extension:///" prefix which fakes a URI, if it exists
|
||||
uuid = stripPrefix(uuid, 'extension:///');
|
||||
|
||||
@ -79,7 +77,7 @@ class Application extends Gtk.Application {
|
||||
|
||||
var ExtensionsWindow = GObject.registerClass({
|
||||
GTypeName: 'ExtensionsWindow',
|
||||
Template: 'resource:///org/gnome/shell/ui/extensions-window.ui',
|
||||
Template: 'resource:///org/gnome/Extensions/ui/extensions-window.ui',
|
||||
InternalChildren: [
|
||||
'userList',
|
||||
'systemList',
|
||||
@ -219,7 +217,7 @@ var ExtensionsWindow = GObject.registerClass({
|
||||
comments: _('Manage your GNOME Extensions'),
|
||||
license_type: Gtk.License.GPL_2_0,
|
||||
logo_icon_name: 'org.gnome.Extensions',
|
||||
version: Config.PACKAGE_VERSION,
|
||||
version: imports.package.version,
|
||||
|
||||
transient_for: this,
|
||||
modal: true,
|
||||
@ -571,7 +569,7 @@ var Expander = GObject.registerClass({
|
||||
|
||||
var ExtensionRow = GObject.registerClass({
|
||||
GTypeName: 'ExtensionRow',
|
||||
Template: 'resource:///org/gnome/shell/ui/extension-row.ui',
|
||||
Template: 'resource:///org/gnome/Extensions/ui/extension-row.ui',
|
||||
InternalChildren: [
|
||||
'nameLabel',
|
||||
'descriptionLabel',
|
||||
@ -751,8 +749,6 @@ function initEnvironment() {
|
||||
|
||||
userdatadir: GLib.build_filenamev([GLib.get_user_data_dir(), 'gnome-shell']),
|
||||
};
|
||||
|
||||
String.prototype.format = Format.format;
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
|
46
js/extensionPrefs/meson.build
Normal file
46
js/extensionPrefs/meson.build
Normal file
@ -0,0 +1,46 @@
|
||||
app_id = 'org.gnome.Extensions'
|
||||
prgname = 'gnome-shell-extension-prefs'
|
||||
|
||||
launcherconf = configuration_data()
|
||||
launcherconf.set('app_id', app_id)
|
||||
launcherconf.set('PACKAGE_NAME', meson.project_name())
|
||||
launcherconf.set('PACKAGE_VERSION', meson.project_version())
|
||||
launcherconf.set('prefix', prefix)
|
||||
launcherconf.set('libdir', libdir)
|
||||
launcherconf.set('pkgdatadir', pkgdatadir)
|
||||
launcherconf.set('gjs', gjs.path())
|
||||
|
||||
configure_file(
|
||||
input: prgname + '.in',
|
||||
output: prgname,
|
||||
configuration: launcherconf,
|
||||
install_dir: bindir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
)
|
||||
|
||||
configure_file(
|
||||
input: app_id + '.in',
|
||||
output: app_id,
|
||||
configuration: launcherconf,
|
||||
install_dir: pkgdatadir,
|
||||
)
|
||||
|
||||
config_dir = '@0@/..'.format(meson.current_build_dir())
|
||||
|
||||
gnome.compile_resources(
|
||||
app_id + '.src',
|
||||
app_id + '.src.gresource.xml',
|
||||
dependencies: [config_js],
|
||||
source_dir: ['.', '..', config_dir],
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: pkgdatadir
|
||||
)
|
||||
|
||||
gnome.compile_resources(
|
||||
app_id + '.data',
|
||||
app_id + '.data.gresource.xml',
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: pkgdatadir
|
||||
)
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/Extensions">
|
||||
<file>css/application.css</file>
|
||||
|
||||
<file>ui/extension-row.ui</file>
|
||||
<file>ui/extensions-window.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
6
js/extensionPrefs/org.gnome.Extensions.in
Normal file
6
js/extensionPrefs/org.gnome.Extensions.in
Normal file
@ -0,0 +1,6 @@
|
||||
imports.package.start({
|
||||
name: '@PACKAGE_NAME@',
|
||||
version: '@PACKAGE_VERSION@',
|
||||
prefix: '@prefix@',
|
||||
libdir: '@libdir@',
|
||||
});
|
10
js/extensionPrefs/org.gnome.Extensions.src.gresource.xml
Normal file
10
js/extensionPrefs/org.gnome.Extensions.src.gresource.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/Extensions/js">
|
||||
<file>main.js</file>
|
||||
|
||||
<file>misc/config.js</file>
|
||||
<file>misc/extensionUtils.js</file>
|
||||
<file>misc/fileUtils.js</file>
|
||||
</gresource>
|
||||
</gresources>
|
@ -1,5 +1,6 @@
|
||||
subdir('misc')
|
||||
subdir('dbusServices')
|
||||
subdir('extensionPrefs')
|
||||
|
||||
js_resources = gnome.compile_resources(
|
||||
'js-resources', 'js-resources.gresource.xml',
|
||||
@ -14,10 +15,3 @@ portal_resources = gnome.compile_resources(
|
||||
c_name: 'portal_js_resources',
|
||||
dependencies: [config_js]
|
||||
)
|
||||
|
||||
prefs_resources = gnome.compile_resources(
|
||||
'prefs-resources', 'prefs-resources.gresource.xml',
|
||||
source_dir: ['.', meson.current_build_dir()],
|
||||
c_name: 'prefs_js_resources',
|
||||
dependencies: [config_js]
|
||||
)
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/gnome/shell">
|
||||
<file>extensionPrefs/main.js</file>
|
||||
|
||||
<file>misc/config.js</file>
|
||||
<file>misc/extensionUtils.js</file>
|
||||
<file>misc/fileUtils.js</file>
|
||||
|
||||
<file alias="css/application.css">extensionPrefs/css/application.css</file>
|
||||
|
||||
<file alias="ui/extension-row.ui">extensionPrefs/ui/extension-row.ui</file>
|
||||
<file alias="ui/extensions-window.ui">extensionPrefs/ui/extensions-window.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
@ -1,51 +0,0 @@
|
||||
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gjs/gjs.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
const char *search_path[] = { "resource:///org/gnome/shell", NULL };
|
||||
GError *error = NULL;
|
||||
GjsContext *context;
|
||||
int status;
|
||||
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
context = g_object_new (GJS_TYPE_CONTEXT,
|
||||
"search-path", search_path,
|
||||
NULL);
|
||||
|
||||
if (!gjs_context_define_string_array(context, "ARGV",
|
||||
argc - 1, (const char**)argv + 1,
|
||||
&error))
|
||||
{
|
||||
g_message("Failed to defined ARGV: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (context);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!gjs_context_eval (context,
|
||||
"const Main = imports.extensionPrefs.main; Main.main(ARGV);",
|
||||
-1,
|
||||
"<main>",
|
||||
&status,
|
||||
&error))
|
||||
{
|
||||
g_message ("Execution of main.js threw exception: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (context);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
g_object_unref (context);
|
||||
return 0;
|
||||
}
|
@ -249,15 +249,6 @@ executable('gnome-shell', 'main.c',
|
||||
install: true
|
||||
)
|
||||
|
||||
executable('gnome-shell-extension-prefs',
|
||||
'gnome-shell-extension-prefs.c', prefs_resources,
|
||||
c_args: tools_cflags,
|
||||
dependencies: tools_deps,
|
||||
include_directories: [conf_inc],
|
||||
install: true
|
||||
)
|
||||
|
||||
|
||||
if have_networkmanager
|
||||
executable('gnome-shell-portal-helper',
|
||||
'gnome-shell-portal-helper.c', portal_resources,
|
||||
|
Loading…
Reference in New Issue
Block a user