static void egg_sm_client_post_args_parse (GnomeProgram *app, GnomeModuleInfo *mod_info) { if (desktop_file) egg_set_desktop_file (desktop_file); egg_sm_client_set_mode (mode); }
int main (int argc, char *argv[]) { gint retval; CajaApplication *application; #if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD) /* Caja uses lots and lots of small and medium size allocations, * and then a few large ones for the desktop background. By default * glibc uses a dynamic treshold for how large allocations should * be mmaped. Unfortunately this triggers quickly for caja when * it does the desktop background allocations, raising the limit * such that a lot of temporary large allocations end up on the * heap and are thus not returned to the OS. To fix this we set * a hardcoded limit. I don't know what a good value is, but 128K * was the old glibc static limit, lets use that. */ mallopt (M_MMAP_THRESHOLD, 128 *1024); #endif if (g_getenv ("CAJA_DEBUG") != NULL) { eel_make_warnings_and_criticals_stop_in_debugger (); } /* Initialize gettext support */ bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); g_set_prgname ("caja"); gdk_set_allowed_backends ("x11"); if (g_file_test (DATADIR "/applications/caja.desktop", G_FILE_TEST_EXISTS)) { egg_set_desktop_file (DATADIR "/applications/caja.desktop"); } #ifdef HAVE_EXEMPI xmp_init(); #endif setup_debug_log (); /* Initialize the services that we use. */ LIBXML_TEST_VERSION /* Run the caja application. */ application = caja_application_new(); retval = g_application_run (G_APPLICATION (application), argc, argv); g_object_unref (application); eel_debug_shut_down (); return retval; }
static void fr_application_init (FrApplication *self) { #ifdef GDK_WINDOWING_X11 egg_set_desktop_file (APPLICATIONS_DIR "/file-roller.desktop"); #else /* manually set name and icon */ g_set_application_name (_("File Roller")); gtk_window_set_default_icon_name ("file-roller"); #endif #ifdef ENABLE_NOTIFICATION if (! notify_init (g_get_application_name ())) g_warning ("Cannot initialize notification system."); #endif /* ENABLE_NOTIFICATION */ self->owner_id = 0; self->introspection_data = NULL; }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("mate-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); /* reset the configuration and exit. */ if (reset == TRUE) { panel_reset(); return 0; } if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return -1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); mateconf_client_add_dir (panel_mateconf_get_client (), "/desktop/mate/interface", MATECONF_CLIENT_PRELOAD_NONE, NULL); panel_global_config_load (); panel_lockdown_init (); panel_profile_load (); /*add forbidden lists to ALL panels*/ g_slist_foreach (panels, (GFunc)panel_widget_add_forbidden, NULL); xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the caja desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_lockdown_finalize (); mateconf_client_remove_dir (panel_mateconf_get_client (), "/desktop/mate/interface", NULL); panel_cleanup_do (); return 0; }
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[]) { gboolean kill_shell; gboolean no_default_window; gboolean browser_window; gboolean no_desktop; gboolean version; gboolean autostart_mode; const char *autostart_id; gchar *geometry; gchar **remaining; gboolean perform_self_check; CajaApplication *application; GOptionContext *context; GFile *file = NULL; GFileInfo *fileinfo = NULL; GAppInfo *appinfo = NULL; char *uri = NULL; char **uris = NULL; GPtrArray *uris_array; GError *error; int i; const GOptionEntry options[] = { #ifndef CAJA_OMIT_SELF_CHECK { "check", 'c', 0, G_OPTION_ARG_NONE, &perform_self_check, N_("Perform a quick set of self-check tests."), NULL }, #endif { "version", '\0', 0, G_OPTION_ARG_NONE, &version, N_("Show the version of the program."), NULL }, { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, N_("Create the initial window with the given geometry."), N_("GEOMETRY") }, { "no-default-window", 'n', 0, G_OPTION_ARG_NONE, &no_default_window, N_("Only create windows for explicitly specified URIs."), NULL }, { "no-desktop", '\0', 0, G_OPTION_ARG_NONE, &no_desktop, N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL }, { "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window, N_("open a browser window."), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell, N_("Quit Caja."), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, N_("[URI...]") }, { NULL } }; #if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD) /* Caja uses lots and lots of small and medium size allocations, * and then a few large ones for the desktop background. By default * glibc uses a dynamic treshold for how large allocations should * be mmaped. Unfortunately this triggers quickly for caja when * it does the desktop background allocations, raising the limit * such that a lot of temporary large allocations end up on the * heap and are thus not returned to the OS. To fix this we set * a hardcoded limit. I don't know what a good value is, but 128K * was the old glibc static limit, lets use that. */ mallopt (M_MMAP_THRESHOLD, 128 *1024); #endif g_thread_init (NULL); /* This will be done by gtk+ later, but for now, force it to MATE */ g_desktop_app_info_set_desktop_env ("MATE"); if (g_getenv ("CAJA_DEBUG") != NULL) { eel_make_warnings_and_criticals_stop_in_debugger (); } /* Initialize gettext support */ bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); autostart_mode = FALSE; autostart_id = g_getenv ("DESKTOP_AUTOSTART_ID"); if (autostart_id != NULL && *autostart_id != '\0') { autostart_mode = TRUE; } /* Get parameters. */ remaining = NULL; geometry = NULL; version = FALSE; kill_shell = FALSE; no_default_window = FALSE; no_desktop = FALSE; perform_self_check = FALSE; browser_window = FALSE; g_set_prgname ("caja"); if (g_file_test (DATADIR "/applications/caja.desktop", G_FILE_TEST_EXISTS)) { egg_set_desktop_file (DATADIR "/applications/caja.desktop"); } context = g_option_context_new (_("\n\nBrowse the file system with the file manager")); g_option_context_add_main_entries (context, options, NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_group (context, egg_sm_client_get_option_group ()); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Could not parse arguments: %s\n", error->message); g_error_free (error); return 1; } g_option_context_free (context); if (version) { g_print ("MATE caja " PACKAGE_VERSION "\n"); return 0; } #ifdef HAVE_EXEMPI xmp_init(); #endif setup_debug_log (); /* If in autostart mode (aka started by mate-session), we need to ensure * caja starts with the correct options. */ if (autostart_mode) { no_default_window = TRUE; no_desktop = FALSE; } if (perform_self_check && remaining != NULL) { /* translators: %s is an option (e.g. --check) */ fprintf (stderr, _("caja: %s cannot be used with URIs.\n"), "--check"); return EXIT_FAILURE; } if (perform_self_check && kill_shell) { fprintf (stderr, _("caja: --check cannot be used with other options.\n")); return EXIT_FAILURE; } if (kill_shell && remaining != NULL) { fprintf (stderr, _("caja: %s cannot be used with URIs.\n"), "--quit"); return EXIT_FAILURE; } if (geometry != NULL && remaining != NULL && remaining[0] != NULL && remaining[1] != NULL) { fprintf (stderr, _("caja: --geometry cannot be used with more than one URI.\n")); return EXIT_FAILURE; } /* Initialize the services that we use. */ LIBXML_TEST_VERSION /* Initialize preferences. This is needed so that proper * defaults are available before any preference peeking * happens. */ caja_global_preferences_init (); /* exit_with_last_window being FALSE, caja can run without window. */ exit_with_last_window = g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_EXIT_WITH_LAST_WINDOW); application = NULL; /* Do either the self-check or the real work. */ if (perform_self_check) { #ifndef CAJA_OMIT_SELF_CHECK /* Run the checks (each twice) for caja and libcaja-private. */ caja_run_self_checks (); caja_run_lib_self_checks (); eel_exit_if_self_checks_failed (); caja_run_self_checks (); caja_run_lib_self_checks (); eel_exit_if_self_checks_failed (); #endif } else { /* Convert args to URIs */ if (remaining != NULL) { uris_array = g_ptr_array_new (); for (i = 0; remaining[i] != NULL; i++) { file = g_file_new_for_commandline_arg (remaining[i]); if (file != NULL) { uri = g_file_get_uri (file); if (uri) { fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (fileinfo && g_file_info_get_file_type(fileinfo) == G_FILE_TYPE_DIRECTORY) { g_ptr_array_add (uris_array, uri); } else { if (fileinfo) g_object_unref (fileinfo); fileinfo = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, NULL); if (fileinfo) { appinfo = g_app_info_get_default_for_type (g_file_info_get_content_type (fileinfo), TRUE); if (appinfo) { if (g_strcmp0 (g_app_info_get_executable (appinfo), "caja") != 0) { g_app_info_launch_default_for_uri (uri, NULL, NULL); } else { fprintf (stderr, _("caja: set erroneously as default application for '%s' content type.\n"), g_file_info_get_content_type (fileinfo)); } g_object_unref (appinfo); } g_free (uri); } else { g_ptr_array_add (uris_array, uri); } } if (fileinfo) g_object_unref (fileinfo); } if (file) g_object_unref (file); } } if (uris_array->len == 0) { /* Caja is being used only to open files (not directories), so closing */ g_strfreev (remaining); return EXIT_SUCCESS; } g_ptr_array_add (uris_array, NULL); uris = (char**) g_ptr_array_free (uris_array, FALSE); g_strfreev (remaining); } /* Run the caja application. */ application = caja_application_new (); if (egg_sm_client_is_resumed (application->smclient)) { no_default_window = TRUE; } caja_application_startup (application, kill_shell, no_default_window, no_desktop, browser_window, geometry, uris); g_strfreev (uris); if (unique_app_is_running (application->unique_app) || kill_shell) { exit_with_last_window = TRUE; } if (is_event_loop_needed ()) { gtk_main (); } } caja_icon_info_clear_caches (); if (application != NULL) { g_object_unref (application); } eel_debug_shut_down (); caja_application_save_accel_map (NULL); return EXIT_SUCCESS; }
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 *context; PlumaPluginsEngine *engine; PlumaWindow *window; PlumaApp *app; gboolean restored = FALSE; GError *error = NULL; gchar *dir; gchar *icon_dir; /* Setup debugging */ pluma_debug_init (); pluma_debug_message (DEBUG_APP, "Startup"); setlocale (LC_ALL, ""); dir = pluma_dirs_get_pluma_locale_dir (); bindtextdomain (GETTEXT_PACKAGE, dir); g_free (dir); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); startup_timestamp = get_startup_timestamp(); /* Setup command line options */ context = g_option_context_new (_("- Edit text files")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (FALSE)); g_option_context_add_group (context, egg_sm_client_get_option_group ()); gtk_init (&argc, &argv); if (!g_option_context_parse (context, &argc, &argv, &error)) { 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); return 1; } g_option_context_free (context); pluma_debug_message (DEBUG_APP, "Create bacon connection"); connection = bacon_message_connection_new ("pluma"); if (connection != NULL) { if (!bacon_message_connection_get_is_server (connection)) { pluma_debug_message (DEBUG_APP, "I'm a client"); pluma_get_command_line_data (); send_bacon_message (); free_command_line_data (); /* we never popup a window... tell startup-notification * that we are done. */ gdk_notify_startup_complete (); bacon_message_connection_free (connection); exit (0); } else { pluma_debug_message (DEBUG_APP, "I'm a server"); bacon_message_connection_set_callback (connection, on_message_received, NULL); } } else { g_warning ("Cannot create the 'pluma' connection."); } pluma_debug_message (DEBUG_APP, "Set icon"); dir = pluma_dirs_get_pluma_data_dir (); icon_dir = g_build_filename (dir, "icons", NULL); g_free (dir); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir); g_free (icon_dir); /* Set the associated .desktop file */ egg_set_desktop_file (DATADIR "/applications/pluma.desktop"); /* Load user preferences */ pluma_debug_message (DEBUG_APP, "Init prefs manager"); pluma_prefs_manager_app_init (); /* Init plugins engine */ pluma_debug_message (DEBUG_APP, "Init plugins"); engine = pluma_plugins_engine_get_default (); /* Initialize session management */ pluma_debug_message (DEBUG_APP, "Init session manager"); pluma_session_init (); if (pluma_session_is_restored ()) restored = pluma_session_load (); if (!restored) { pluma_debug_message (DEBUG_APP, "Analyze command line data"); pluma_get_command_line_data (); pluma_debug_message (DEBUG_APP, "Get default app"); app = pluma_app_get_default (); pluma_debug_message (DEBUG_APP, "Create main window"); window = pluma_app_create_window (app, NULL); if (file_list != NULL) { const PlumaEncoding *encoding = NULL; if (encoding_charset) encoding = pluma_encoding_get_from_charset (encoding_charset); pluma_debug_message (DEBUG_APP, "Load files"); _pluma_cmd_load_files_from_prompt (window, file_list, encoding, line_position); } else { pluma_debug_message (DEBUG_APP, "Create tab"); pluma_window_create_tab (window, TRUE); } pluma_debug_message (DEBUG_APP, "Show window"); gtk_widget_show (GTK_WIDGET (window)); free_command_line_data (); } pluma_debug_message (DEBUG_APP, "Start gtk-main"); gtk_main(); bacon_message_connection_free (connection); /* We kept the original engine reference here. So let's unref it to * finalize it properly. */ g_object_unref (engine); pluma_prefs_manager_app_shutdown (); #ifndef ENABLE_GVFS_METADATA pluma_metadata_manager_shutdown (); #endif return 0; }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("gnome-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("gnome-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return 1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); if (!panel_layout_load ()) { panel_cleanup_do (); return 1; } xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the nautilus desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_cleanup_do (); return 0; }
int main (int argc, char *argv[]) { GOptionContext *context; GError *error = NULL; #ifdef G_OS_WIN32 if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) { /* stdout is fine, presumably redirected to a file or pipe */ } else { typedef BOOL (* WINAPI AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole"); if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS)) { freopen ("CONOUT$", "w", stdout); dup2 (fileno (stdout), 1); freopen ("CONOUT$", "w", stderr); dup2 (fileno (stderr), 2); } } #endif #if (!GLIB_CHECK_VERSION(2,31,0)) /* Remove this once we bump dependencies to glib >= 2.31.0 */ /* Init glib threads asap */ if (!g_thread_supported ()) g_thread_init (NULL); #endif #ifdef ENABLE_NLS /* Initialize the i18n stuff */ bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir()); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif context = g_option_context_new (N_("GNOME Document Viewer")); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE); #ifdef WITH_SMCLIENT g_option_context_add_group (context, egg_sm_client_get_option_group ()); #endif g_option_context_add_group (context, gtk_get_option_group (TRUE)); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Cannot parse arguments: %s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); if (preview_mode) { gboolean retval; retval = launch_previewer (); return retval ? 0 : 1; } if (!ev_init ()) return 1; ev_stock_icons_init (); #if defined(WITH_SMCLIENT) && defined(GDK_WINDOWING_X11) egg_set_desktop_file (GNOMEDATADIR "/applications/evince.desktop"); #else /* Manually set name and icon */ g_set_application_name (_("Document Viewer")); gtk_window_set_default_icon_name ("evince"); #endif /* WITH_SMCLIENT && GDK_WINDOWING_X11 */ ev_application_load_session (EV_APP); load_files (file_arguments); /* Change directory so we don't prevent unmounting in case the initial cwd * is on an external device (see bug #575436) */ g_chdir (g_get_home_dir ()); gtk_main (); ev_shutdown (); ev_stock_icons_shutdown (); return 0; }
int main (int argc, char **argv) { char *desktopfile; GOptionContext *context; GError *error; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* We will register explicitly when we're ready -- see panel-session.c */ egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED); g_set_prgname ("mate-panel"); desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop"); if (desktopfile) { egg_set_desktop_file (desktopfile); g_free (desktopfile); } context = g_option_context_new (""); g_option_context_add_group (context, egg_sm_client_get_option_group ()); g_option_context_add_group (context, gtk_get_option_group (TRUE)); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); gtk_init (&argc, &argv); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); g_option_context_free (context); return 1; } g_option_context_free (context); /* set the default layout */ if (layout != NULL && layout[0] != 0) { GSettings *settings; settings = g_settings_new (PANEL_SCHEMA); g_settings_set_string (settings, PANEL_DEFAULT_LAYOUT, layout); g_object_unref (settings); g_message ("Panel layout set to '%s'", layout); /* exit, except if reset argument is given */ if (!reset) return 0; } /* reset the configuration and exit. */ if (reset == TRUE) { panel_reset(); return 0; } /* open the run dialog and exit */ if (run_dialog == TRUE) { panel_multiscreen_init (); panel_global_config_load (); panel_lockdown_init (); panel_profile_settings_load (); panel_run_dialog_present (gdk_screen_get_default (), gtk_get_current_event_time ()); panel_run_dialog_quit_on_destroy (); gtk_main (); panel_lockdown_finalize (); panel_cleanup_do (); return 0; } if (!egg_get_desktop_file ()) { g_set_application_name (_("Panel")); gtk_window_set_default_icon_name (PANEL_ICON_PANEL); } if (!panel_shell_register (replace)) { panel_cleanup_do (); return -1; } panel_action_protocol_init (); panel_multiscreen_init (); panel_init_stock_icons_and_items (); panel_global_config_load (); panel_lockdown_init (); panel_profile_load (); /*add forbidden lists to ALL panels*/ g_slist_foreach (panels, (GFunc)panel_widget_add_forbidden, NULL); xstuff_init (); /* Flush to make sure our struts are seen by everyone starting * immediate after (eg, the caja desktop). */ gdk_flush (); /* Do this at the end, to be sure that we're really ready when * connecting to the session manager */ panel_session_init (); gtk_main (); panel_lockdown_finalize (); panel_cleanup_do (); return 0; }