environment: move more init stuff here from main.js

Move some more environment-initializationy stuff from main.js to
environment.js, and be more careful about not importing shell JS
modules until after the environment has been fully patched.

Change gnome-shell-plugin to call Environment.init() before
Main.start(); this means that Environment.init() now runs before any
shell JS modules (besides environment itself) have been imported.

Make run-js-test create a ShellGlobal and use its js_context, so that
the shell_global_set_property_mutable() stuff in Environment.init()
will work correctly in tests as well.

https://bugzilla.gnome.org/show_bug.cgi?id=649203
This commit is contained in:
Dan Winship
2011-04-30 10:27:36 -04:00
parent 0e42de9149
commit 7921954a31
4 changed files with 51 additions and 50 deletions

View File

@ -178,7 +178,8 @@ gnome_shell_plugin_start (MetaPlugin *plugin)
gjs_context = _shell_global_get_gjs_context (shell_plugin->global);
if (!gjs_context_eval (gjs_context,
"const Main = imports.ui.main; Main.start();",
"imports.ui.environment.init();"
"imports.ui.main.start();",
-1,
"<main>",
&status,

View File

@ -24,15 +24,19 @@
* IN THE SOFTWARE.
*/
#include <config.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <clutter/x11/clutter-x11.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include "config.h"
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <clutter/x11/clutter-x11.h>
#include <gdk/gdkx.h>
#include <gjs/gjs.h>
#include <gtk/gtk.h>
#include "shell-global.h"
#include "shell-global-private.h"
static char **include_path = NULL;
static char *command = NULL;
@ -59,10 +63,10 @@ event_filter (GdkXEvent *xevent,
int
main(int argc, char **argv)
{
char *command_line;
GOptionContext *context;
ClutterActor *stage;
GError *error = NULL;
ShellGlobal *global;
GjsContext *js_context;
char *script;
const char *filename;
@ -94,12 +98,8 @@ main(int argc, char **argv)
setlocale (LC_ALL, "");
g_type_init ();
command_line = g_strjoinv (" ", argv);
g_debug ("Command line: %s", command_line);
g_free (command_line);
g_debug ("Creating new context to eval console script");
js_context = gjs_context_new_with_search_path (include_path);
global = shell_global_get ();
js_context = _shell_global_get_gjs_context (global);
/* prepare command line arguments */
if (!gjs_context_define_string_array (js_context, "ARGV",