[gnome-shell] Make gnome-shell-extension-prefs a binary executable



commit 2dd7db480835e702f53623dbdb776e6aff63e08d
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Dec 6 21:20:03 2013 +0100

    Make gnome-shell-extension-prefs a binary executable
    
    Since commit 1ebb162a00bf6c4b0 moved JS sources into resources,
    the extension-prefs tool was broken. To fix it, we would either
    need to generate an external GResource in addition to the generated
    C code and teach gjs-console about loading it before evaluating
    the script, or turn gnome-shell-extension-prefs into a binary with
    the JS resources compiled in.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722334

 src/Makefile.am                    |   18 +++++++------
 src/gnome-shell-extension-prefs.c  |   49 ++++++++++++++++++++++++++++++++++++
 src/gnome-shell-extension-prefs.in |   15 -----------
 3 files changed, 59 insertions(+), 23 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c0d377..f25d475 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -29,11 +29,9 @@ CLEANFILES += $(service_DATA)
 
 CLEANFILES += $(gir_DATA) $(typelib_DATA)
 
-bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-extension-prefs \
-              gnome-shell-perf-tool
-EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-extension-prefs.in \
-             gnome-shell-perf-tool.in
-bin_PROGRAMS = gnome-shell
+bin_SCRIPTS += gnome-shell-extension-tool gnome-shell-perf-tool
+EXTRA_DIST += gnome-shell-extension-tool.in gnome-shell-perf-tool.in
+bin_PROGRAMS = gnome-shell gnome-shell-extension-prefs
 
 if HAVE_MUTTER_WAYLAND
 bin_PROGRAMS += gnome-shell-wayland
@@ -54,9 +52,6 @@ generated_script_substitutions = \
 gnome-shell-extension-tool: gnome-shell-extension-tool.in Makefile
        $(AM_V_GEN) sed $(generated_script_substitutions) $< > $  tmp && mv $  tmp $@ && chmod a+x $@
 
-gnome-shell-extension-prefs: gnome-shell-extension-prefs.in Makefile
-       $(AM_V_GEN) sed $(generated_script_substitutions) $< > $  tmp && mv $  tmp $@ && chmod a+x $@
-
 gnome-shell-perf-tool: gnome-shell-perf-tool.in Makefile
        $(AM_V_GEN) sed $(generated_script_substitutions) $< > $  tmp && mv $  tmp $@ && chmod a+x $@
 
@@ -209,6 +204,13 @@ gnome_shell_wayland_LDADD = libgnome-shell-wayland.la libgnome-shell-js.la $(GNO
 gnome_shell_wayland_DEPENDENCIES = libgnome-shell-wayland.la
 endif HAVE_MUTTER_WAYLAND
 
+gnome_shell_extension_prefs_SOURCES = gnome-shell-extension-prefs.c \
+       $(top_builddir)/js/js-resources.c               \
+       $(top_builddir)/js/js-resources.h               \
+       $(NULL)
+gnome_shell_extension_prefs_CPPFLAGS = $(gnome_shell_cflags)
+gnome_shell_extension_prefs_LDADD = libgnome-shell-js.la
+
 ########################################
 
 libgnome_shell_js_la_SOURCES =         \
diff --git a/src/gnome-shell-extension-prefs.c b/src/gnome-shell-extension-prefs.c
new file mode 100644
index 0000000..fefa3be
--- /dev/null
+++ b/src/gnome-shell-extension-prefs.c
@@ -0,0 +1,49 @@
+#include "config.h"
+
+#include <girepository.h>
+#include <gjs/gjs.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);
+
+  g_irepository_prepend_search_path (GNOME_SHELL_PKGLIBDIR);
+
+  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);
+
+      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);
+
+      return status;
+    }
+
+  return 0;
+}


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