int main (int argc, char **argv) { GOptionContext *ctx; GError *error = NULL; CinnamonSessionType session_type; int ecode; TpDebugSender *sender; g_type_init (); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); ctx = meta_get_option_context (); g_option_context_add_main_entries (ctx, gnome_cinnamon_options, GETTEXT_PACKAGE); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_printerr ("%s: %s\n", argv[0], error->message); exit (1); } g_option_context_free (ctx); meta_plugin_type_register (gnome_cinnamon_plugin_get_type ()); /* Prevent meta_init() from causing gtk to load gail and at-bridge */ g_setenv ("NO_GAIL", "1", TRUE); g_setenv ("NO_AT_BRIDGE", "1", TRUE); meta_init (); g_unsetenv ("NO_GAIL"); g_unsetenv ("NO_AT_BRIDGE"); /* FIXME: Add gjs API to set this stuff and don't depend on the * environment. These propagate to child processes. */ g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE); g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE); cinnamon_dbus_init (meta_get_replace_current_wm ()); cinnamon_a11y_init (); cinnamon_fonts_init (); cinnamon_perf_log_init (); cinnamon_prefs_init (); gdk_event_handler_set (gnome_cinnamon_gdk_event_handler, NULL, NULL); g_irepository_prepend_search_path (CINNAMON_PKGLIBDIR); #if HAVE_BLUETOOTH g_irepository_prepend_search_path (BLUETOOTH_DIR); #endif /* Disable debug spew from various libraries */ g_log_set_handler ("Gvc", G_LOG_LEVEL_DEBUG, muted_log_handler, NULL); g_log_set_handler ("AccountsService", G_LOG_LEVEL_DEBUG, muted_log_handler, NULL); g_log_set_handler ("Bluetooth", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE, muted_log_handler, NULL); g_log_set_handler ("tp-glib/proxy", G_LOG_LEVEL_DEBUG, muted_log_handler, NULL); /* Turn on telepathy-glib debugging but filter it out in * default_log_handler. This handler also exposes all the logs over D-Bus * using TpDebugSender. */ tp_debug_set_flags ("all"); sender = tp_debug_sender_dup (); g_log_set_default_handler (default_log_handler, sender); /* Initialize the global object */ if (is_gdm_mode) session_type = CINNAMON_SESSION_GDM; else session_type = CINNAMON_SESSION_USER; _cinnamon_global_init ("session-type", session_type, NULL); ecode = meta_run (); if (g_getenv ("CINNAMON_ENABLE_CLEANUP")) { g_printerr ("Doing final cleanup...\n"); g_object_unref (cinnamon_global_get ()); } g_object_unref (sender); return ecode; }
int main (int argc, char **argv) { GOptionContext *ctx; GError *error = NULL; int ecode; g_setenv ("CLUTTER_DISABLE_XINPUT", "1", TRUE); g_setenv ("CLUTTER_BACKEND", "x11", TRUE); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_setenv ("GDK_SCALE", "1", TRUE); ctx = meta_get_option_context (); g_option_context_add_main_entries (ctx, gnome_cinnamon_options, GETTEXT_PACKAGE); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_printerr ("%s: %s\n", argv[0], error->message); exit (1); } g_option_context_free (ctx); meta_plugin_manager_set_plugin_type (gnome_cinnamon_plugin_get_type ()); /* Prevent meta_init() from causing gtk to load gail and at-bridge */ g_setenv ("NO_GAIL", "1", TRUE); g_setenv ("NO_AT_BRIDGE", "1", TRUE); meta_init (); g_unsetenv ("NO_GAIL"); g_unsetenv ("NO_AT_BRIDGE"); g_unsetenv ("CLUTTER_DISABLE_XINPUT"); g_unsetenv ("CLUTTER_BACKEND"); /* FIXME: Add gjs API to set this stuff and don't depend on the * environment. These propagate to child processes. */ g_setenv ("GJS_DEBUG_OUTPUT", "stderr", TRUE); g_setenv ("GJS_DEBUG_TOPICS", "JS ERROR;JS LOG", TRUE); g_setenv ("CINNAMON_VERSION", VERSION, TRUE); center_pointer_on_screen(); cinnamon_dbus_init (meta_get_replace_current_wm ()); cinnamon_a11y_init (); cinnamon_perf_log_init (); g_irepository_prepend_search_path (CINNAMON_PKGLIBDIR); #if HAVE_BLUETOOTH g_irepository_prepend_search_path (BLUETOOTH_DIR); #endif /* Disable debug spew from various libraries */ g_log_set_handler ("Cvc", G_LOG_LEVEL_DEBUG, muted_log_handler, NULL); g_log_set_handler ("AccountsService", G_LOG_LEVEL_DEBUG, muted_log_handler, NULL); g_log_set_handler ("Bluetooth", G_LOG_LEVEL_DEBUG | G_LOG_LEVEL_MESSAGE, muted_log_handler, NULL); /* Initialize the global object */ _cinnamon_global_init (NULL); g_unsetenv ("GDK_SCALE"); ecode = meta_run (); if (g_getenv ("CINNAMON_ENABLE_CLEANUP")) { g_printerr ("Doing final cleanup...\n"); g_object_unref (cinnamon_global_get ()); } return ecode; }
int main(int argc, char **argv) { GOptionContext *context; ClutterActor *stage; GError *error = NULL; CinnamonGlobal *global; GjsContext *js_context; char *script; const char *filename; char *title; gsize len; int code; gtk_init (&argc, &argv); clutter_x11_set_display (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())); clutter_x11_disable_event_retrieval (); if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; gdk_window_add_filter (NULL, event_filter, NULL); context = g_option_context_new (NULL); /* pass unknown through to the JS script */ g_option_context_set_ignore_unknown_options (context, TRUE); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) g_error ("option parsing failed: %s", error->message); setlocale (LC_ALL, ""); g_type_init (); _cinnamon_global_init (NULL); global = cinnamon_global_get (); js_context = _cinnamon_global_get_gjs_context (global); /* prepare command line arguments */ if (!gjs_context_define_string_array (js_context, "ARGV", argc - 2, (const char**)argv + 2, &error)) { g_printerr ("Failed to defined ARGV: %s", error->message); exit (1); } if (command != NULL) { script = command; len = strlen (script); filename = "<command line>"; } else if (argc <= 1) { script = g_strdup ("const Console = imports.console; Console.interact();"); len = strlen (script); filename = "<stdin>"; } else /*if (argc >= 2)*/ { error = NULL; if (!g_file_get_contents (argv[1], &script, &len, &error)) { g_printerr ("%s\n", error->message); exit (1); } filename = argv[1]; } stage = clutter_stage_get_default (); title = g_filename_display_basename (filename); clutter_stage_set_title (CLUTTER_STAGE (stage), title); g_free (title); #if HAVE_BLUETOOTH /* The module imports are all so intertwined that if the test * imports anything in js/ui, it will probably eventually end up * pulling in ui/status/bluetooth.js. So we need this. */ g_irepository_prepend_search_path (BLUETOOTH_DIR); #endif /* evaluate the script */ error = NULL; if (!gjs_context_eval (js_context, script, len, filename, &code, &error)) { g_free (script); g_printerr ("%s\n", error->message); exit (1); } g_free (script); exit (code); }