[gnome-shell/wip/gresource] Load JS from GResource



commit c312402f825a54c27f1ffc9f6504cf2e66e06c54
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jul 1 23:54:53 2013 -0700

    Load JS from GResource
    
    Since gjs can now load JS from a GResource, compile it in the
    gnome-shell binary. This should be a bit faster, and make life easier
    with JHBuild.

 configure.ac                  |    3 +
 js/Makefile.am                |  119 +++++------------------------------------
 js/js-resources.gresource.xml |  106 ++++++++++++++++++++++++++++++++++++
 src/Makefile.am               |    6 ++-
 src/shell-global.c            |   13 ++++-
 5 files changed, 136 insertions(+), 111 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 48ab6ac..a2a7598 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,6 +139,9 @@ AC_SUBST(MUTTER_TYPELIB_DIR)
 GJS_CONSOLE=`$PKG_CONFIG --variable=gjs_console gjs-1.0`
 AC_SUBST(GJS_CONSOLE)
 
+GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
+AC_SUBST(GLIB_COMPILE_RESOURCES)
+
 AC_CHECK_FUNCS(fdwalk)
 AC_CHECK_FUNCS(mallinfo)
 AC_CHECK_HEADERS([sys/resource.h])
diff --git a/js/Makefile.am b/js/Makefile.am
index 86fa470..6fbb8d1 100644
--- a/js/Makefile.am
+++ b/js/Makefile.am
@@ -1,8 +1,5 @@
 NULL =
 
-EXTRA_DIST = misc/config.js.in
-CLEANFILES = misc/config.js
-
 misc/config.js: misc/config.js.in Makefile
        [ -d $(@D) ] || $(mkdir_p) $(@D) ; \
        sed -e "s|[ ]PACKAGE_NAME@|$(PACKAGE_NAME)|g" \
@@ -14,108 +11,18 @@ misc/config.js: misc/config.js.in Makefile
            -e "s|[ ]sysconfdir@|$(sysconfdir)|g" \
                $< > $@
 
-jsdir = $(pkgdatadir)/js
+js_resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies 
$(srcdir)/js-resources.gresource.xml)
+js-resources.h: js-resources.gresource.xml $(js_resource_files) misc/config.js
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name 
shell_js_resources $<
+js-resources.c: js-resources.gresource.xml $(js_resource_files) misc/config.js
+       $(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name 
shell_js_resources $<
+
+js_resource_dist_files = $(filter-out misc/config.js, $(js_resource_files))
+
+all: js-resources.h js-resources.c misc/config.js
 
-nobase_dist_js_DATA =  \
-       gdm/authPrompt.js       \
-       gdm/batch.js            \
-       gdm/fingerprint.js      \
-       gdm/loginDialog.js      \
-       gdm/powerMenu.js        \
-       gdm/realmd.js           \
-       gdm/util.js             \
-       extensionPrefs/main.js  \
-       misc/config.js          \
-       misc/extensionUtils.js  \
-       misc/fileUtils.js       \
-       misc/gnomeSession.js    \
-       misc/hash.js            \
-       misc/history.js         \
-       misc/jsParse.js         \
-       misc/loginManager.js    \
-       misc/modemManager.js    \
-       misc/params.js          \
-       misc/util.js            \
-       perf/core.js            \
-       ui/altTab.js            \
-       ui/animation.js         \
-       ui/appDisplay.js        \
-       ui/appFavorites.js      \
-       ui/backgroundMenu.js    \
-       ui/background.js        \
-       ui/boxpointer.js        \
-       ui/calendar.js          \
-       ui/checkBox.js          \
-       ui/ctrlAltTab.js        \
-       ui/dash.js              \
-       ui/dateMenu.js          \
-       ui/dnd.js               \
-       ui/endSessionDialog.js  \
-       ui/extensionSystem.js   \
-       ui/extensionDownloader.js \
-       ui/environment.js       \
-       ui/ibusCandidatePopup.js\
-       ui/grabHelper.js        \
-       ui/iconGrid.js          \
-       ui/keyboard.js          \
-       ui/layout.js            \
-       ui/lightbox.js          \
-       ui/lookingGlass.js      \
-       ui/magnifier.js         \
-       ui/magnifierDBus.js     \
-       ui/main.js              \
-       ui/messageTray.js       \
-       ui/modalDialog.js       \
-       ui/separator.js         \
-       ui/sessionMode.js       \
-       ui/shellEntry.js        \
-       ui/shellMountOperation.js \
-       ui/slider.js            \
-       ui/notificationDaemon.js \
-       ui/osdWindow.js         \
-       ui/overview.js          \
-       ui/overviewControls.js  \
-       ui/panel.js             \
-       ui/panelMenu.js         \
-       ui/pointerWatcher.js    \
-       ui/popupMenu.js         \
-       ui/remoteSearch.js      \
-       ui/remoteMenu.js        \
-       ui/runDialog.js         \
-       ui/screencast.js        \
-       ui/screenshot.js        \
-        ui/screenShield.js     \
-       ui/scripting.js         \
-       ui/search.js            \
-       ui/searchDisplay.js     \
-       ui/shellDBus.js         \
-       ui/status/accessibility.js      \
-       ui/status/keyboard.js   \
-       ui/status/lockScreenMenu.js     \
-       ui/status/network.js    \
-       ui/status/power.js      \
-       ui/status/volume.js     \
-       ui/status/bluetooth.js  \
-       ui/status/system.js     \
-       ui/switcherPopup.js     \
-       ui/tweener.js           \
-       ui/unlockDialog.js      \
-       ui/userWidget.js        \
-       ui/viewSelector.js      \
-       ui/wanda.js             \
-       ui/windowAttentionHandler.js    \
-       ui/windowManager.js     \
-       ui/workspace.js         \
-       ui/workspaceThumbnail.js        \
-       ui/workspacesView.js    \
-       ui/workspaceSwitcherPopup.js    \
-       ui/xdndHandler.js       \
-       ui/components/__init__.js               \
-       ui/components/autorunManager.js         \
-       ui/components/automountManager.js       \
-       ui/components/networkAgent.js           \
-       ui/components/polkitAgent.js            \
-       ui/components/recorder.js               \
-       ui/components/telepathyClient.js        \
-       ui/components/keyring.js                \
+EXTRA_DIST = \
+       $(js_resource_dist_files) \
+       js-resources.gresource.xml \
+       misc/config.js.in \
        $(NULL)
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
new file mode 100644
index 0000000..0cb5dbb
--- /dev/null
+++ b/js/js-resources.gresource.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/shell">
+    <file>gdm/authPrompt.js</file>
+    <file>gdm/batch.js</file>
+    <file>gdm/fingerprint.js</file>
+    <file>gdm/loginDialog.js</file>
+    <file>gdm/powerMenu.js</file>
+    <file>gdm/realmd.js</file>
+    <file>gdm/util.js</file>
+    <file>extensionPrefs/main.js</file>
+    <file>misc/config.js</file>
+    <file>misc/extensionUtils.js</file>
+    <file>misc/fileUtils.js</file>
+    <file>misc/gnomeSession.js</file>
+    <file>misc/hash.js</file>
+    <file>misc/history.js</file>
+    <file>misc/jsParse.js</file>
+    <file>misc/loginManager.js</file>
+    <file>misc/modemManager.js</file>
+    <file>misc/params.js</file>
+    <file>misc/util.js</file>
+    <file>perf/core.js</file>
+    <file>ui/altTab.js</file>
+    <file>ui/animation.js</file>
+    <file>ui/appDisplay.js</file>
+    <file>ui/appFavorites.js</file>
+    <file>ui/backgroundMenu.js</file>
+    <file>ui/background.js</file>
+    <file>ui/boxpointer.js</file>
+    <file>ui/calendar.js</file>
+    <file>ui/checkBox.js</file>
+    <file>ui/ctrlAltTab.js</file>
+    <file>ui/dash.js</file>
+    <file>ui/dateMenu.js</file>
+    <file>ui/dnd.js</file>
+    <file>ui/endSessionDialog.js</file>
+    <file>ui/extensionSystem.js</file>
+    <file>ui/extensionDownloader.js</file>
+    <file>ui/environment.js</file>
+    <file>ui/ibusCandidatePopup.js</file>
+    <file>ui/grabHelper.js</file>
+    <file>ui/iconGrid.js</file>
+    <file>ui/keyboard.js</file>
+    <file>ui/layout.js</file>
+    <file>ui/lightbox.js</file>
+    <file>ui/lookingGlass.js</file>
+    <file>ui/magnifier.js</file>
+    <file>ui/magnifierDBus.js</file>
+    <file>ui/main.js</file>
+    <file>ui/messageTray.js</file>
+    <file>ui/modalDialog.js</file>
+    <file>ui/separator.js</file>
+    <file>ui/sessionMode.js</file>
+    <file>ui/shellEntry.js</file>
+    <file>ui/shellMountOperation.js</file>
+    <file>ui/slider.js</file>
+    <file>ui/notificationDaemon.js</file>
+    <file>ui/osdWindow.js</file>
+    <file>ui/overview.js</file>
+    <file>ui/overviewControls.js</file>
+    <file>ui/panel.js</file>
+    <file>ui/panelMenu.js</file>
+    <file>ui/pointerWatcher.js</file>
+    <file>ui/popupMenu.js</file>
+    <file>ui/remoteSearch.js</file>
+    <file>ui/remoteMenu.js</file>
+    <file>ui/runDialog.js</file>
+    <file>ui/screencast.js</file>
+    <file>ui/screenshot.js</file>
+    <file>ui/screenShield.js</file>
+    <file>ui/scripting.js</file>
+    <file>ui/search.js</file>
+    <file>ui/searchDisplay.js</file>
+    <file>ui/shellDBus.js</file>
+    <file>ui/status/accessibility.js</file>
+    <file>ui/status/keyboard.js</file>
+    <file>ui/status/lockScreenMenu.js</file>
+    <file>ui/status/network.js</file>
+    <file>ui/status/power.js</file>
+    <file>ui/status/volume.js</file>
+    <file>ui/status/bluetooth.js</file>
+    <file>ui/switcherPopup.js</file>
+    <file>ui/tweener.js</file>
+    <file>ui/unlockDialog.js</file>
+    <file>ui/userMenu.js</file>
+    <file>ui/userWidget.js</file>
+    <file>ui/viewSelector.js</file>
+    <file>ui/wanda.js</file>
+    <file>ui/windowAttentionHandler.js</file>
+    <file>ui/windowManager.js</file>
+    <file>ui/workspace.js</file>
+    <file>ui/workspaceThumbnail.js</file>
+    <file>ui/workspacesView.js</file>
+    <file>ui/workspaceSwitcherPopup.js</file>
+    <file>ui/xdndHandler.js</file>
+    <file>ui/components/__init__.js</file>
+    <file>ui/components/autorunManager.js</file>
+    <file>ui/components/automountManager.js</file>
+    <file>ui/components/networkAgent.js</file>
+    <file>ui/components/polkitAgent.js</file>
+    <file>ui/components/recorder.js</file>
+    <file>ui/components/telepathyClient.js</file>
+    <file>ui/components/keyring.js</file>
+  </gresource>
+</gresources>
diff --git a/src/Makefile.am b/src/Makefile.am
index 13e0cbb..d925c2a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -93,7 +93,6 @@ gnome_shell_cflags =                          \
        -DGNOME_SHELL_LIBEXECDIR=\"$(libexecdir)\"      \
        -DGNOME_SHELL_DATADIR=\"$(pkgdatadir)\" \
        -DGNOME_SHELL_PKGLIBDIR=\"$(pkglibdir)\" \
-       -DJSDIR=\"$(pkgdatadir)/js\"            \
        -DMUTTER_TYPELIB_DIR=\"$(MUTTER_TYPELIB_DIR)\"
 
 privlibdir = $(pkglibdir)
@@ -188,7 +187,10 @@ libgnome_shell_la_gir_sources = \
        $(filter-out %-private.h $(shell_private_sources), $(shell_public_headers_h) 
$(libgnome_shell_la_SOURCES))
 
 gnome_shell_real_SOURCES =             \
-       main.c
+       main.c                          \
+       $(top_srcdir)/js/js-resources.c \
+       $(top_srcdir)/js/js-resources.h \
+       $(NULL)
 gnome_shell_real_CPPFLAGS = $(gnome_shell_cflags)
 gnome_shell_real_LDADD = libgnome-shell.la libgnome-shell-js.la $(libgnome_shell_la_LIBADD)
 gnome_shell_real_DEPENDENCIES = libgnome-shell.la
diff --git a/src/shell-global.c b/src/shell-global.c
index c3ff531..d56bd26 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -281,9 +281,16 @@ shell_global_init (ShellGlobal *global)
                            NULL);
   ca_context_open (global->sound_context);
 
-  if (!shell_js)
-    shell_js = JSDIR;
-  search_path = g_strsplit (shell_js, ":", -1);
+  if (shell_js)
+    {
+      search_path = g_strsplit (shell_js, ":", -1);
+    }
+  else
+    {
+      search_path = g_malloc0 (2 * sizeof (char *));
+      search_path[0] = g_strdup ("resource:///org/gnome/shell");
+    }
+
   global->js_context = g_object_new (GJS_TYPE_CONTEXT,
                                      "search-path", search_path,
                                      "js-version", "1.8",


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