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; }
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) { DBusGConnection *session_bus; GError *error = NULL; RBShell *rb_shell; gboolean activated; gboolean autostarted; char *accel_map_file = NULL; char *desktop_file_path; GOptionContext *context; static const GOptionEntry options [] = { { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, N_("Enable debug output"), NULL }, { "debug-match", 'D', 0, G_OPTION_ARG_STRING, &debug_match, N_("Enable debug output matching a specified string"), NULL }, { "no-update", 0, 0, G_OPTION_ARG_NONE, &no_update, N_("Do not update the library with file changes"), NULL }, { "no-registration", 'n', 0, G_OPTION_ARG_NONE, &no_registration, N_("Do not register the shell"), NULL }, { "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, N_("Don't save any data permanently (implies --no-registration)"), NULL }, { "disable-plugins", 0, 0, G_OPTION_ARG_NONE, &disable_plugins, N_("Disable loading of plugins"), NULL }, { "rhythmdb-file", 0, 0, G_OPTION_ARG_STRING, &rhythmdb_file, N_("Path for database file to use"), NULL }, { "playlists-file", 0, 0, G_OPTION_ARG_STRING, &playlists_file, N_("Path for playlists file to use"), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &quit, N_("Quit Rhythmbox"), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, N_("[URI...]") }, { NULL } }; g_thread_init (NULL); rb_profile_start ("starting rhythmbox"); autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL); #ifdef USE_UNINSTALLED_DIRS desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL); g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE); #else desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL); #endif egg_set_desktop_file (desktop_file_path); g_free (desktop_file_path); context = g_option_context_new (NULL); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); rb_profile_start ("initializing gstreamer"); g_option_context_add_group (context, gst_init_get_option_group ()); rb_profile_end ("initializing gstreamer"); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); setlocale (LC_ALL, NULL); rb_profile_start ("parsing command line options"); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print (_("%s\nRun '%s --help' to see a full list of available command line options.\n"), error->message, argv[0]); g_error_free (error); g_option_context_free (context); exit (1); } g_option_context_free (context); rb_profile_end ("parsing command line options"); g_random_set_seed (time (0)); #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); /* ask for utf-8 message text from GStreamer too, * since it doesn't do that itself. */ bind_textdomain_codeset ("gstreamer-0.10", "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif if (!debug && debug_match) rb_debug_init_match (debug_match); else rb_debug_init (debug); rb_debug ("initializing Rhythmbox %s", VERSION); #if defined(USE_UNINSTALLED_DIRS) g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi"); #endif /* TODO: kill this function */ rb_threads_init (); gdk_threads_enter (); activated = FALSE; rb_debug ("going to create DBus object"); dbus_g_thread_init (); session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (session_bus == NULL) { g_warning ("couldn't connect to session bus: %s", (error) ? error->message : "(null)"); g_clear_error (&error); } else if (!no_registration) { guint request_name_reply; int flags; #ifndef DBUS_NAME_FLAG_DO_NOT_QUEUE flags = DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT; #else flags = DBUS_NAME_FLAG_DO_NOT_QUEUE; #endif DBusGProxy *bus_proxy; bus_proxy = dbus_g_proxy_new_for_name (session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus", "org.freedesktop.DBus"); if (!dbus_g_proxy_call (bus_proxy, "RequestName", &error, G_TYPE_STRING, "org.gnome.Rhythmbox", G_TYPE_UINT, flags, G_TYPE_INVALID, G_TYPE_UINT, &request_name_reply, G_TYPE_INVALID)) { g_warning ("Failed to invoke RequestName: %s", error->message); } g_object_unref (bus_proxy); if (request_name_reply == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER || request_name_reply == DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER) activated = FALSE; else if (request_name_reply == DBUS_REQUEST_NAME_REPLY_EXISTS || request_name_reply == DBUS_REQUEST_NAME_REPLY_IN_QUEUE) activated = TRUE; else { g_warning ("Got unhandled reply %u from RequestName", request_name_reply); activated = FALSE; } } if (!activated) { if (quit) { rb_debug ("was asked to quit, but no instance was running"); gdk_notify_startup_complete (); exit (0); } #ifdef WITH_RHYTHMDB_GDA gda_init (PACKAGE, VERSION, argc, argv); #endif rb_refstring_system_init (); #ifdef USE_UNINSTALLED_DIRS rb_file_helpers_init (TRUE); #else rb_file_helpers_init (FALSE); #endif /* XXX not sure what to do with this. should we move it to * the config dir, or leave it where it is? */ accel_map_file = g_build_filename (g_get_home_dir (), ".gnome2", "accels", "rhythmbox", NULL); gtk_accel_map_load (accel_map_file); rb_debug ("Going to create a new shell"); rb_stock_icons_init (); g_setenv ("PULSE_PROP_media.role", "music", TRUE); rb_shell = rb_shell_new (no_registration, no_update, dry_run, autostarted, disable_plugins, rhythmdb_file, playlists_file); g_object_weak_ref (G_OBJECT (rb_shell), main_shell_weak_ref_cb, NULL); if (!no_registration && session_bus != NULL) { dbus_g_object_type_install_info (RB_TYPE_SHELL, &dbus_glib_rb_shell_object_info); dbus_g_connection_register_g_object (session_bus, "/org/gnome/Rhythmbox/Shell", G_OBJECT (rb_shell)); g_signal_connect (G_OBJECT (rb_shell), "database-load-complete", G_CALLBACK (database_load_complete), NULL); } } else if (!no_registration && session_bus != NULL) { DBusGProxy *shell_proxy; guint32 current_time; current_time = gdk_x11_display_get_user_time (gdk_display_get_default ()); shell_proxy = dbus_g_proxy_new_for_name_owner (session_bus, "org.gnome.Rhythmbox", "/org/gnome/Rhythmbox/Shell", "org.gnome.Rhythmbox.Shell", &error); if (!shell_proxy) { g_warning ("Couldn't create proxy for Rhythmbox shell: %s", error->message); } else { if (quit) { dbus_g_proxy_call_no_reply (shell_proxy, "quit", G_TYPE_INVALID); } else { load_uri_args ((const char **) remaining_args, (GFunc) dbus_load_uri, shell_proxy); dbus_g_proxy_call_no_reply (shell_proxy, "present", G_TYPE_UINT, current_time, G_TYPE_INVALID); } g_object_unref (G_OBJECT (shell_proxy)); } } if (activated) { gdk_notify_startup_complete (); } else { rb_profile_start ("mainloop"); #ifdef ENABLE_PYTHON if (rb_python_init_successful ()) { pyg_begin_allow_threads; gtk_main (); pyg_end_allow_threads; } else { gtk_main (); } #else gtk_main (); #endif rb_profile_end ("mainloop"); rb_debug ("out of toplevel loop"); rb_file_helpers_shutdown (); rb_stock_icons_shutdown (); rb_refstring_system_shutdown (); } gst_deinit (); rb_debug ("THE END"); rb_profile_end ("starting rhythmbox"); if (accel_map_file != NULL) { gtk_accel_map_save (accel_map_file); } gdk_threads_leave (); exit (0); }
int main (int argc, char **argv) { RBShell *shell; gboolean autostarted; char *desktop_file_path; int new_argc; char **new_argv; /* disable multidevice so clutter-gtk events work. * this needs to be done before gtk_open, so the visualizer * plugin can't do it. */ gdk_disable_multidevice (); g_thread_init (NULL); g_type_init (); g_random_set_seed (time (0)); autostarted = (g_getenv ("DESKTOP_AUTOSTART_ID") != NULL); #ifdef USE_UNINSTALLED_DIRS desktop_file_path = g_build_filename (SHARE_UNINSTALLED_BUILDDIR, "rhythmbox.desktop", NULL); g_setenv ("GSETTINGS_SCHEMA_DIR", SHARE_UNINSTALLED_BUILDDIR, TRUE); #else desktop_file_path = g_build_filename (DATADIR, "applications", "rhythmbox.desktop", NULL); #endif egg_set_desktop_file (desktop_file_path); g_free (desktop_file_path); setlocale (LC_ALL, NULL); #ifdef ENABLE_NLS /* initialize i18n */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif #if defined(USE_UNINSTALLED_DIRS) g_irepository_prepend_search_path (SHARE_UNINSTALLED_BUILDDIR "/../bindings/gi"); #endif /* TODO: kill this function */ rb_threads_init (); if (glib_check_version (2, 31, 1) != NULL) { gdk_threads_enter (); } new_argc = argc; new_argv = argv; shell = rb_shell_new (autostarted, &argc, &argv); g_application_run (G_APPLICATION (shell), new_argc, new_argv); g_object_unref (shell); if (glib_check_version (2, 31, 1) != NULL) { gdk_threads_leave (); } exit (0); }
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; }
static void ide_init_ctor (void) { GgitFeatureFlags ggit_flags; g_irepository_prepend_search_path (LIBDIR"/gnome-builder/girepository-1.0"); g_type_ensure (IDE_TYPE_CONTEXT); g_type_ensure (IDE_TYPE_VCS); g_io_extension_point_register (IDE_FILE_SETTINGS_EXTENSION_POINT); g_io_extension_point_register (IDE_SCRIPT_EXTENSION_POINT); g_io_extension_point_register (IDE_VCS_EXTENSION_POINT); g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT, IDE_TYPE_MODELINES_FILE_SETTINGS, IDE_FILE_SETTINGS_EXTENSION_POINT".modelines", -100); g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT, IDE_TYPE_EDITORCONFIG_FILE_SETTINGS, IDE_FILE_SETTINGS_EXTENSION_POINT".editorconfig", -200); g_io_extension_point_implement (IDE_FILE_SETTINGS_EXTENSION_POINT, IDE_TYPE_GSETTINGS_FILE_SETTINGS, IDE_FILE_SETTINGS_EXTENSION_POINT".gsettings", -300); #ifdef ENABLE_GJS_SCRIPTING g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT, IDE_TYPE_GJS_SCRIPT, IDE_SCRIPT_EXTENSION_POINT".gjs", -100); #endif #ifdef ENABLE_PYTHON_SCRIPTING g_io_extension_point_implement (IDE_SCRIPT_EXTENSION_POINT, IDE_TYPE_PYGOBJECT_SCRIPT, IDE_SCRIPT_EXTENSION_POINT".py", -100); #endif g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT, IDE_TYPE_GIT_VCS, IDE_VCS_EXTENSION_POINT".git", -100); g_io_extension_point_implement (IDE_VCS_EXTENSION_POINT, IDE_TYPE_DIRECTORY_VCS, IDE_VCS_EXTENSION_POINT".directory", -200); modeline_parser_init (); ggit_init (); ggit_flags = ggit_get_features (); if ((ggit_flags & GGIT_FEATURE_THREADS) == 0) { g_error (_("Builder requires libgit2-glib with threading support.")); exit (EXIT_FAILURE); } if ((ggit_flags & GGIT_FEATURE_SSH) == 0) { g_error (_("Builder requires libgit2-glib with SSH support.")); exit (EXIT_FAILURE); } _ide_thread_pool_init (); _ide_battery_monitor_init (); }
/** * meta_init: (skip) * * Initialize muffin. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; GIOChannel *channel; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif if (pipe (sigterm_pipe_fds) != 0) g_printerr ("Failed to create SIGTERM pipe: %s\n", g_strerror (errno)); channel = g_io_channel_unix_new (sigterm_pipe_fds[0]); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL); g_io_channel_set_close_on_unref (channel, TRUE); g_io_channel_unref (channel); act.sa_handler = &sigterm_handler; if (sigaction (SIGTERM, &act, NULL) < 0) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); if (g_getenv ("MUFFIN_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUFFIN_DEBUG")) meta_set_debugging (TRUE); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUFFIN_PKGLIBDIR); #endif meta_set_syncing (opt_sync || (g_getenv ("MUFFIN_SYNC") != NULL)); meta_select_display (opt_display_name); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); const char *renderer = (const char *) glGetString (GL_RENDERER); if (strstr (renderer, "llvmpipe") || strstr (renderer, "Rasterizer") || strstr (renderer, "softpipe")) { /* Clutter envs not set, since they won't work after Clutter init */ g_setenv ("CINNAMON_SOFTWARE_RENDERING", "1", FALSE); g_setenv ("CINNAMON_SLOWDOWN_FACTOR", "0.0001", FALSE); g_setenv ("MUFFIN_NO_SHADOWS", "1", FALSE); meta_warning ("Software rendering detected: %s\n", renderer); } }
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); }
/** * meta_init: (skip) * * Initialize mutter. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif g_unix_signal_add (SIGTERM, on_sigterm, NULL); if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUTTER_DEBUG")) meta_set_debugging (TRUE); #if defined(CLUTTER_WINDOWING_EGL) && defined(HAVE_NATIVE_BACKEND) if (opt_display_server) clutter_set_windowing_backend (CLUTTER_WINDOWING_EGL); else #endif clutter_set_windowing_backend (CLUTTER_WINDOWING_X11); #ifdef HAVE_WAYLAND meta_set_is_wayland_compositor (opt_wayland); #endif if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); #endif #ifdef HAVE_WAYLAND if (meta_is_wayland_compositor ()) meta_wayland_pre_clutter_init (); #endif /* NB: When running as a hybrid wayland compositor we run our own headless X * server so the user can't control the X display to connect too. */ if (!meta_is_wayland_compositor ()) meta_select_display (opt_display_name); meta_clutter_init (); #ifdef HAVE_WAYLAND /* Bring up Wayland. This also launches Xwayland and sets DISPLAY as well... */ if (meta_is_wayland_compositor ()) meta_wayland_init (); #endif meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL)); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); meta_restart_init (); }
/** * meta_init: (skip) * * Initialize muffin. Call this after meta_get_option_context() and * meta_plugin_type_register(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; GIOChannel *channel; g_type_init (); sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif if (pipe (sigterm_pipe_fds) != 0) g_printerr ("Failed to create SIGTERM pipe: %s\n", g_strerror (errno)); channel = g_io_channel_unix_new (sigterm_pipe_fds[0]); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN, (GIOFunc) on_sigterm, NULL); g_io_channel_set_close_on_unref (channel, TRUE); g_io_channel_unref (channel); act.sa_handler = &sigterm_handler; if (sigaction (SIGTERM, &act, NULL) < 0) g_printerr ("Failed to register SIGTERM handler: %s\n", g_strerror (errno)); if (g_getenv ("MUFFIN_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUFFIN_DEBUG")) meta_set_debugging (TRUE); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUFFIN_PKGLIBDIR); #endif meta_set_syncing (opt_sync || (g_getenv ("MUFFIN_SYNC") != NULL)); meta_select_display (opt_display_name); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); }
static GObject* gjs_context_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_params) { GObject *object; GjsContext *js_context; guint32 options_flags; JSVersion js_version; object = (* G_OBJECT_CLASS (gjs_context_parent_class)->constructor) (type, n_construct_properties, construct_params); js_context = GJS_CONTEXT(object); if (js_context->runtime == NULL) { js_context->runtime = JS_NewRuntime(32*1024*1024 /* max bytes */); if (js_context->runtime == NULL) gjs_fatal("Failed to create javascript runtime"); JS_SetGCParameter(js_context->runtime, JSGC_MAX_BYTES, 0xffffffff); js_context->we_own_runtime = TRUE; gjs_runtime_init(js_context->runtime); } js_context->context = JS_NewContext(js_context->runtime, 8192 /* stack chunk size */); if (js_context->context == NULL) gjs_fatal("Failed to create javascript context"); JS_BeginRequest(js_context->context); /* same as firefox, see discussion at * https://bugzilla.mozilla.org/show_bug.cgi?id=420869 */ JS_SetScriptStackQuota(js_context->context, 100*1024*1024); /* JSOPTION_DONT_REPORT_UNCAUGHT: Don't send exceptions to our * error report handler; instead leave them set. This allows us * to get at the exception object. * * JSOPTION_STRICT: Report warnings to error reporter function. */ options_flags = JSOPTION_DONT_REPORT_UNCAUGHT | JSOPTION_STRICT; if (!g_getenv("GJS_DISABLE_JIT")) { gjs_debug(GJS_DEBUG_CONTEXT, "Enabling JIT"); options_flags |= JSOPTION_METHODJIT; } JS_SetOptions(js_context->context, JS_GetOptions(js_context->context) | options_flags); JS_SetLocaleCallbacks(js_context->context, &gjs_locale_callbacks); JS_SetErrorReporter(js_context->context, gjs_error_reporter); /* set ourselves as the private data */ JS_SetContextPrivate(js_context->context, js_context); js_version = JS_StringToVersion(js_context->jsversion_string); /* It doesn't make sense to throw here; just use the default if we * don't know. */ if (js_version == JSVERSION_UNKNOWN) js_version = JSVERSION_DEFAULT; /* Set the version if we need to. */ if (js_version != JSVERSION_DEFAULT && JS_GetVersion(js_context->context) != js_version) { gjs_debug(GJS_DEBUG_CONTEXT, "Changing JavaScript version to %s from %s", JS_VersionToString(js_version), JS_VersionToString(JS_GetVersion(js_context->context))); JS_SetVersion(js_context->context, js_version); } if (!gjs_init_context_standard(js_context->context)) gjs_fatal("Failed to initialize context"); js_context->global = JS_GetGlobalObject(js_context->context); if (!JS_DefineProperty(js_context->context, js_context->global, "window", OBJECT_TO_JSVAL(js_context->global), NULL, NULL, JSPROP_READONLY | JSPROP_PERMANENT)) gjs_fatal("No memory to export global object as 'window'"); /* Define a global function called log() */ if (!JS_DefineFunction(js_context->context, js_context->global, "log", (JSNative)gjs_log, 1, GJS_MODULE_PROP_FLAGS)) gjs_fatal("Failed to define log function"); if (!JS_DefineFunction(js_context->context, js_context->global, "logError", (JSNative)gjs_log_error, 2, GJS_MODULE_PROP_FLAGS)) gjs_fatal("Failed to define logError function"); /* Define global functions called print() and printerr() */ if (!JS_DefineFunction(js_context->context, js_context->global, "print", (JSNative)gjs_print, 3, GJS_MODULE_PROP_FLAGS)) gjs_fatal("Failed to define print function"); if (!JS_DefineFunction(js_context->context, js_context->global, "printerr", (JSNative)gjs_printerr, 4, GJS_MODULE_PROP_FLAGS)) gjs_fatal("Failed to define printerr function"); /* We need to know what the default context is, since it's the context whose * global object is used to load imported JS modules. We currently say that * it's the context of the runtime's owner, but if we needed to support * externally created runtimes, we could define it in some other fashion. */ if (js_context->we_own_runtime) { gjs_runtime_set_default_context(js_context->runtime, js_context->context); } else { if (gjs_runtime_get_default_context(js_context->runtime) == NULL) gjs_fatal("GjsContext created for a runtime not owned by GJS"); } /* We create the global-to-runtime root importer with the * passed-in search path. If someone else already created * the root importer, this is a no-op. */ if (!gjs_create_root_importer(js_context->context, js_context->search_path ? (const char**) js_context->search_path : NULL, TRUE)) gjs_fatal("Failed to create root importer"); /* Now copy the global root importer (which we just created, * if it didn't exist) to our global object */ if (!gjs_define_root_importer(js_context->context, js_context->global, "imports")) gjs_fatal("Failed to point 'imports' property at root importer"); if (js_context->we_own_runtime) { js_context->profiler = gjs_profiler_new(js_context->runtime); } if (!gjs_is_registered_native_module(js_context->context, NULL, "gi")) gjs_register_native_module("gi", gjs_define_gi_stuff, GJS_NATIVE_SUPPLIES_MODULE_OBJ); /* For GjsDBus */ { char *priv_typelib_dir = g_build_filename (PKGLIBDIR, "girepository-1.0", NULL); g_irepository_prepend_search_path(priv_typelib_dir); g_free (priv_typelib_dir); } if (js_context->gc_notifications_enabled) JS_SetGCCallback(js_context->context, gjs_on_context_gc); JS_EndRequest(js_context->context); g_static_mutex_lock (&contexts_lock); all_contexts = g_list_prepend(all_contexts, object); g_static_mutex_unlock (&contexts_lock); return object; }
int main(int argc, char **argv) { char *js_test_dir; GSList *all_tests, *iter; GSList *all_registered_test_data = NULL; int retval; /* The tests are known to fail in the presence of the JIT; * we leak objects. * https://bugzilla.gnome.org/show_bug.cgi?id=616193 */ g_setenv("GJS_DISABLE_JIT", "1", FALSE); /* The fact that this isn't the default is kind of lame... */ g_setenv("GJS_DEBUG_OUTPUT", "stderr", FALSE); setlocale(LC_ALL, ""); g_test_init(&argc, &argv, NULL); if (g_getenv ("GJS_USE_UNINSTALLED_FILES") != NULL) { /* typelib path is handled by the environment */ js_test_dir = g_build_filename(g_getenv ("TOP_SRCDIR"), "installed-tests", "js", NULL); } else { g_irepository_prepend_search_path(INSTTESTDIR); js_test_dir = g_build_filename(INSTTESTDIR, "js", NULL); } const char *coverage_prefix = g_getenv("GJS_UNIT_COVERAGE_PREFIX"); const char *coverage_output_directory = g_getenv("GJS_UNIT_COVERAGE_OUTPUT"); all_tests = read_all_dir_sorted(js_test_dir); for (iter = all_tests; iter; iter = iter->next) { char *name = (char*) iter->data; char *test_name; char *file_name; GjsTestData *test_data; if (!(g_str_has_prefix(name, "test") && g_str_has_suffix(name, ".js"))) { g_free(name); continue; } if (g_str_has_prefix (name, "testCairo") && g_getenv ("GJS_TEST_SKIP_CAIRO")) continue; /* pretty print, drop 'test' prefix and '.js' suffix from test name */ test_name = g_strconcat("/js/", name + 4, NULL); test_name[strlen(test_name)-3] = '\0'; file_name = g_build_filename(js_test_dir, name, NULL); test_data = gjs_unit_test_data_new(coverage_prefix, coverage_output_directory, file_name); g_test_add(test_name, GjsTestJSFixture, test_data, setup, test, teardown); g_free(name); g_free(test_name); all_registered_test_data = g_slist_prepend(all_registered_test_data, test_data); /* not freeing file_name or test_data yet as it's needed while running the test */ } g_free(js_test_dir); g_slist_free(all_tests); retval = g_test_run (); g_slist_foreach(all_registered_test_data, (GFunc)gjs_unit_test_data_free, all_registered_test_data); g_slist_free(all_registered_test_data); return retval; }
/** * meta_init: (skip) * * Initialize mutter. Call this after meta_get_option_context() and * meta_plugin_manager_set_plugin_type(), and before meta_run(). */ void meta_init (void) { struct sigaction act; sigset_t empty_mask; ClutterSettings *clutter_settings; sigemptyset (&empty_mask); act.sa_handler = SIG_IGN; act.sa_mask = empty_mask; act.sa_flags = 0; if (sigaction (SIGPIPE, &act, NULL) < 0) g_printerr ("Failed to register SIGPIPE handler: %s\n", g_strerror (errno)); #ifdef SIGXFSZ if (sigaction (SIGXFSZ, &act, NULL) < 0) g_printerr ("Failed to register SIGXFSZ handler: %s\n", g_strerror (errno)); #endif g_unix_signal_add (SIGTERM, on_sigterm, NULL); if (g_getenv ("MUTTER_VERBOSE")) meta_set_verbose (TRUE); if (g_getenv ("MUTTER_DEBUG")) meta_set_debugging (TRUE); #if defined(CLUTTER_WINDOWING_EGL) && defined(HAVE_NATIVE_BACKEND) if (opt_display_server) clutter_set_windowing_backend (CLUTTER_WINDOWING_EGL); #endif meta_set_is_wayland_compositor (opt_wayland); if (g_get_home_dir ()) if (chdir (g_get_home_dir ()) < 0) meta_warning ("Could not change to home directory %s.\n", g_get_home_dir ()); meta_print_self_identity (); #ifdef HAVE_INTROSPECTION g_irepository_prepend_search_path (MUTTER_PKGLIBDIR); #endif if (meta_is_wayland_compositor ()) { /* NB: When running as a hybrid wayland compositor we run our own headless X * server so the user can't control the X display to connect too. */ meta_wayland_init (); } else meta_select_display (opt_display_name); meta_set_syncing (opt_sync || (g_getenv ("MUTTER_SYNC") != NULL)); if (opt_replace_wm) meta_set_replace_current_wm (TRUE); if (opt_save_file && opt_client_id) meta_fatal ("Can't specify both SM save file and SM client id\n"); meta_main_loop = g_main_loop_new (NULL, FALSE); meta_ui_init (); /* If we are running with wayland then we don't wait until we have * an X connection before initializing clutter we instead initialize * it earlier since we need to initialize the GL driver so the driver * can register any needed wayland extensions. */ if (!meta_is_wayland_compositor ()) { /* * Clutter can only be initialized after the UI. */ meta_clutter_init (); } meta_restart_init (); /* * XXX: We cannot handle high dpi scaling yet, so fix the scale to 1 * for now. */ clutter_settings = clutter_settings_get_default (); g_object_set (clutter_settings, "window-scaling-factor", 1, NULL); }
void ide_application_discover_plugins (IdeApplication *self) { PeasEngine *engine = peas_engine_get_default (); const GList *list; gchar *path; g_autoptr(GError) error = NULL; g_return_if_fail (IDE_IS_APPLICATION (self)); if (g_getenv ("GB_IN_TREE_PLUGINS") != NULL) { GDir *dir; g_irepository_prepend_search_path (BUILDDIR"/src/gstyle"); g_irepository_prepend_search_path (BUILDDIR"/src/libide"); if ((dir = g_dir_open (BUILDDIR"/src/plugins", 0, NULL))) { const gchar *name; while ((name = g_dir_read_name (dir))) { path = g_build_filename (BUILDDIR, "src", "plugins", name, NULL); peas_engine_prepend_search_path (engine, path, path); g_free (path); } g_dir_close (dir); } } else { g_irepository_prepend_search_path (PACKAGE_LIBDIR"/gnome-builder/girepository-1.0"); peas_engine_prepend_search_path (engine, PACKAGE_LIBDIR"/gnome-builder/plugins", PACKAGE_DATADIR"/gnome-builder/plugins"); } /* * We have access to ~/.local/share/gnome-builder/ for plugins even when we are * bundled with flatpak, so might as well use it. */ if (ide_is_flatpak ()) { g_autofree gchar *plugins_dir = g_build_filename (g_get_home_dir (), ".local", "share", "gnome-builder", "plugins", NULL); g_irepository_prepend_search_path (plugins_dir); peas_engine_prepend_search_path (engine, plugins_dir, plugins_dir); } if (!g_irepository_require (NULL, "Ide", "1.0", 0, &error) || !g_irepository_require (NULL, "Gtk", "3.0", 0, &error) || !g_irepository_require (NULL, "Dazzle", "1.0", 0, &error)) g_warning ("Cannot enable Python 3 plugins: %s", error->message); else { /* Avoid spamming stderr with Ide import tracebacks */ peas_engine_enable_loader (engine, "python3"); } peas_engine_prepend_search_path (engine, "resource:///org/gnome/builder/plugins/", NULL); path = g_build_filename (g_get_user_data_dir (), "gnome-builder", "plugins", NULL); peas_engine_prepend_search_path (engine, path, NULL); g_free (path); list = peas_engine_get_plugin_list (engine); for (; list; list = list->next) { PeasPluginInfo *plugin_info = list->data; g_debug ("Discovered plugin \"%s\"", peas_plugin_info_get_module_name (plugin_info)); } }