[gnome-shell] extensionPrefs: Use imports.package.start()



commit e572d5d08c8c82818aeba25eda1f327e1a85fef1
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Mar 5 17:44:27 2020 +0100

    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

 js/extensionPrefs/gnome-shell-extension-prefs.in   |  2 +
 js/extensionPrefs/main.js                          | 20 ++++-----
 js/extensionPrefs/meson.build                      | 46 +++++++++++++++++++
 .../org.gnome.Extensions.data.gresource.xml        |  9 ++++
 js/extensionPrefs/org.gnome.Extensions.in          |  6 +++
 .../org.gnome.Extensions.src.gresource.xml         | 10 +++++
 js/meson.build                                     |  8 +---
 js/prefs-resources.gresource.xml                   | 15 -------
 src/gnome-shell-extension-prefs.c                  | 51 ----------------------
 src/meson.build                                    |  9 ----
 10 files changed, 82 insertions(+), 94 deletions(-)
---
diff --git a/js/extensionPrefs/gnome-shell-extension-prefs.in 
b/js/extensionPrefs/gnome-shell-extension-prefs.in
new file mode 100644
index 0000000000..dc6d627601
--- /dev/null
+++ b/js/extensionPrefs/gnome-shell-extension-prefs.in
@@ -0,0 +1,2 @@
+#!/bin/sh
+@gjs@ @pkgdatadir@/@app_id@ "$@"
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 02e68c76d6..936598c054 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -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) {
diff --git a/js/extensionPrefs/meson.build b/js/extensionPrefs/meson.build
new file mode 100644
index 0000000000..97da99714e
--- /dev/null
+++ b/js/extensionPrefs/meson.build
@@ -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
+)
diff --git a/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml 
b/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml
new file mode 100644
index 0000000000..f6fc66b721
--- /dev/null
+++ b/js/extensionPrefs/org.gnome.Extensions.data.gresource.xml
@@ -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>
diff --git a/js/extensionPrefs/org.gnome.Extensions.in b/js/extensionPrefs/org.gnome.Extensions.in
new file mode 100644
index 0000000000..da7ab25129
--- /dev/null
+++ b/js/extensionPrefs/org.gnome.Extensions.in
@@ -0,0 +1,6 @@
+imports.package.start({
+    name: '@PACKAGE_NAME@',
+    version: '@PACKAGE_VERSION@',
+    prefix: '@prefix@',
+    libdir: '@libdir@',
+});
diff --git a/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml 
b/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml
new file mode 100644
index 0000000000..9b0fa09ace
--- /dev/null
+++ b/js/extensionPrefs/org.gnome.Extensions.src.gresource.xml
@@ -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>
diff --git a/js/meson.build b/js/meson.build
index 9a230d65d7..8b131d8dda 100644
--- a/js/meson.build
+++ b/js/meson.build
@@ -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]
-)
diff --git a/src/meson.build b/src/meson.build
index 8e18e30805..05bdb9beab 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]