int main (int argc, char **argv) { GjsContext *js_context; GError *error; #ifdef GDK_WINDOWING_X11 XInitThreads (); #endif clutter_x11_set_use_argb_visual (TRUE); if (gtk_clutter_init (&argc, &argv) < 0) return EXIT_FAILURE; clutter_gst_init (0, NULL); parse_options (&argc, &argv); js_context = gjs_context_new_with_search_path (NULL); error = NULL; register_all_viewers (js_context); if (!gjs_context_eval (js_context, "const Main = imports.ui.main;\n" "Main.run();\n", -1, __FILE__, NULL, &error)) g_error("Failed to load main javascript: %s", error->message); return EXIT_SUCCESS; }
static void setup(GjsTestJSFixture *fix, gconstpointer test_data) { gboolean success; GError *error = NULL; int code; char *filename; char *search_path[2]; search_path[0] = g_build_filename(top_srcdir, "test", "modules", NULL); search_path[1] = NULL; fix->context = gjs_context_new_with_search_path(search_path); g_free(search_path[0]); /* Load jsUnit.js directly into global scope, rather than * requiring each test to import it as a module, among other * things this lets us test importing modules without relying on * importing a module, but also it's just less typing to have * "assert*" without a prefix. */ filename = g_build_filename(top_srcdir, "modules", "jsUnit.js", NULL); success = gjs_context_eval_file(fix->context, filename, &code, &error); g_free(filename); if (!success) g_error("%s", error->message); }
int main(int argc, char **argv) { GjsContext *gjs_context; const char *js_dir; char **search_path; GError *error = NULL; int status; g_type_init (); g_irepository_prepend_search_path (TYPELIBDIR); js_dir = JSDIR":."; search_path = g_strsplit(js_dir, ":", -1); gjs_context = gjs_context_new_with_search_path(search_path); debug_init (&argc, &argv, gjs_context); if (!gjs_context_eval (gjs_context, "const Main = imports.main; Main.start();", -1, "<main>", &status, &error)) { g_warning ("Evaling main.js failed: %s", error->message); g_error_free (error); } g_strfreev (search_path); return 0; }
int main (int argc, char *argv[]) { const char *search_path[] = { "resource:///org/gnome/maps", 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_MAPS_PKGLIBDIR); context = gjs_context_new_with_search_path ((char**) search_path); if (!gjs_context_define_string_array(context, "ARGV", argc, (const char**)argv, &error)) { g_critical ("Failed to define ARGV: %s", error->message); g_error_free (error); return 1; } if (!gjs_context_eval (context, "const Main = imports.main; Main.start();", -1, "<main>", &status, &error)) { g_critical ("Failed to run: %s", error->message); g_error_free (error); return status; } return 0; }