static void splash_map(void) { /* Reenable startup notification after the splash has been shown * so that the next window that is mapped sends the notification. */ gtk_window_set_auto_startup_notification(TRUE); }
/** * gwy_app_splash_start: * @visible: If %FALSE, splash screen is not actually shown, all functions just * silently return. * * Starts splash screen. **/ void gwy_app_splash_start(gboolean visible) { GtkWidget *image, *vbox, *frame, *lab; GdkPixbuf *pixbuf; char *p, *version; gwy_debug(""); g_return_if_fail(!in_splash); in_splash = TRUE; if (!visible) return; window = gtk_window_new(GTK_WINDOW_POPUP); p = g_strconcat(_("Starting "), g_get_application_name(), NULL); gtk_window_set_title(GTK_WINDOW(window), p); gtk_window_set_wmclass(GTK_WINDOW(window), "splash", g_get_application_name()); gtk_window_set_resizable(GTK_WINDOW(window), FALSE); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_window_set_decorated(GTK_WINDOW(window), FALSE); gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); g_signal_connect_swapped(window, "delete-event", G_CALLBACK(exit), GINT_TO_POINTER(0)); /* we don't want the splash screen to send the startup notification */ gtk_window_set_auto_startup_notification(FALSE); g_signal_connect(window, "map", G_CALLBACK(splash_map), NULL); frame = gtk_frame_new(NULL); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); gtk_container_add(GTK_CONTAINER(window), frame); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(frame), vbox); gtk_container_set_border_width(GTK_CONTAINER(vbox), 2); version = g_strdup_printf("%d.%d", GWY_VERSION_MAJOR, GWY_VERSION_MINOR); pixbuf = compose_splash(version); g_free(version); if (pixbuf) { image = gtk_image_new_from_pixbuf(pixbuf); g_object_unref(pixbuf); } else image = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_DIALOG); gtk_box_pack_start(GTK_BOX(vbox), image, FALSE, FALSE, 0); label = gtk_label_new(p); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_misc_set_padding(GTK_MISC(label), 6, 4); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); g_free(p); lab = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vbox), lab, FALSE, FALSE, 0); p = g_strconcat("<small>", PACKAGE_NAME, _(" is free software released under GNU GPL."), "</small>", NULL); lab = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(lab), p); gtk_misc_set_alignment(GTK_MISC(lab), 0.0, 0.5); gtk_misc_set_padding(GTK_MISC(lab), 5, 3); gtk_box_pack_start(GTK_BOX(vbox), lab, FALSE, FALSE, 0); g_free(p); gtk_widget_show_all(window); while (gtk_events_pending()) gtk_main_iteration(); }
GimpInitStatusFunc gui_init (Gimp *gimp, gboolean no_splash) { GimpInitStatusFunc status_callback = NULL; gchar *abort_message; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (the_gui_gimp == NULL, NULL); abort_message = gui_sanity_check (); if (abort_message) gui_abort (abort_message); the_gui_gimp = gimp; /* TRANSLATORS: there is no need to translate this in GIMP. This uses * "gtk20" domain as a special trick to determine language direction, * but xgettext extracts it anyway mistakenly into GIMP po files. * Leave an empty string as translation. It does not matter. */ if (g_strcmp0 (dgettext ("gtk20", "default:LTR"), "default:RTL") == 0) /* Normally this should have been taken care of during command line * parsing as a post-parse hook of gtk_get_option_group(), using the * system locales. * But user config may have overriden the language, therefore we must * check the widget directions again. */ gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); else gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR); gui_unique_init (gimp); gimp_language_store_parser_init (); gimp_widgets_init (gui_help_func, gui_get_foreground_func, gui_get_background_func, NULL); g_type_class_ref (GIMP_TYPE_COLOR_SELECT); /* disable automatic startup notification */ gtk_window_set_auto_startup_notification (FALSE); gimp_dnd_init (gimp); themes_init (gimp); initial_monitor = gimp_get_monitor_at_pointer (&initial_screen); gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (initial_screen)); if (! no_splash) { splash_create (gimp->be_verbose, initial_screen, initial_monitor); status_callback = splash_update; } g_signal_connect_after (gimp, "initialize", G_CALLBACK (gui_initialize_after_callback), NULL); g_signal_connect (gimp, "restore", G_CALLBACK (gui_restore_callback), NULL); g_signal_connect_after (gimp, "restore", G_CALLBACK (gui_restore_after_callback), NULL); g_signal_connect (gimp, "exit", G_CALLBACK (gui_exit_callback), NULL); g_signal_connect_after (gimp, "exit", G_CALLBACK (gui_exit_after_callback), NULL); return status_callback; }
void gtkpod_init(int argc, char *argv[]) { AnjutaPluginManager *plugin_manager; AnjutaProfileManager *profile_manager; AnjutaApp *app; AnjutaStatus *status; AnjutaProfile *profile; GFile *session_profile; GError *error = NULL; gchar *default_profile_file = NULL; gchar *user_profile_file = NULL; gchar *ui_file = NULL; gchar *remembered_plugins = NULL; gchar *session_dir = NULL; gchar *splash = NULL; /* Initialise important directories */ init_directories(argv); register_stock_icon(GTKPOD_ICON, GTKPOD_ICON_STOCK_ID); /* Initialise the ui file */ ui_file = g_build_filename(get_ui_dir(), "gtkpod.ui", NULL); anjuta_set_ui_file_path(ui_file); /* Register the application icon */ register_stock_icon("gtkpod", GTKPOD_APP_ICON_STOCK_ID); /* Initialize application class instance*/ app = ANJUTA_APP(anjuta_app_new()); gtkpod_app = GTKPOD_APP(app); /* Initialise the preferences as required for the display of the splash screen */ prefs_init(argc, argv); /* Show some progress as the app is initialised */ status = anjuta_shell_get_status(ANJUTA_SHELL(app), NULL); anjuta_status_progress_add_ticks(status, 1); /* Show the splash screen if user requires */ if (! prefs_get_int(DISABLE_SPLASH_SCREEN)) { splash = g_build_filename(get_icon_dir(), "gtkpod-splash.png", NULL); if (g_file_test(splash, G_FILE_TEST_IS_REGULAR)) anjuta_status_set_splash(status, splash, 100); else { anjuta_status_disable_splash(status, TRUE); } g_free(splash); } /* * initialise gtkpod library items. Needs to be safety threaded due * to splash screen. */ gdk_threads_enter(); gp_init(argc, argv); gdk_threads_leave(); /* Add blocking widgets from the framework */ add_blocked_widget(app->toolbar); add_blocked_widget(app->view_menu); /* Set up shutdown signals */ g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK( on_gtkpod_delete_event), NULL); g_signal_connect(G_OBJECT(app), "destroy", G_CALLBACK(on_gtkpod_destroy), NULL); plugin_manager = anjuta_shell_get_plugin_manager(ANJUTA_SHELL(app), NULL); profile_manager = anjuta_shell_get_profile_manager(ANJUTA_SHELL(app), NULL); /* Restore remembered plugins */ remembered_plugins = g_settings_get_string(app->settings, GTKPOD_REMEMBERED_PLUGINS); if (remembered_plugins) anjuta_plugin_manager_set_remembered_plugins(plugin_manager, remembered_plugins); g_free(remembered_plugins); /* Load default profile */ default_profile_file = get_default_profile_path(); profile = anjuta_profile_new(USER_PROFILE_NAME, plugin_manager); session_profile = g_file_new_for_path(default_profile_file); anjuta_profile_add_plugins_from_xml(profile, session_profile, TRUE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_object_unref(session_profile); g_free(default_profile_file); /* Load user session profile */ user_profile_file = get_user_profile_path(); session_profile = g_file_new_for_path(user_profile_file); if (g_file_query_exists(session_profile, NULL)) { anjuta_profile_add_plugins_from_xml(profile, session_profile, FALSE, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } } anjuta_profile_set_sync_file(profile, session_profile); g_object_unref(session_profile); g_free(user_profile_file); /* Load profile */ anjuta_profile_manager_freeze(profile_manager); anjuta_profile_manager_push(profile_manager, profile, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } /* Prepare for session save and load on profile change */ g_signal_connect (profile_manager, "profile-scoped", G_CALLBACK (on_profile_scoped), app); anjuta_profile_manager_thaw(profile_manager, &error); if (error) { anjuta_util_dialog_error(GTK_WINDOW(app), "%s", error->message); g_error_free(error); error = NULL; } g_signal_connect (profile_manager, "profile-descoped", G_CALLBACK (on_profile_descoped), app); gdk_threads_enter(); gp_init_itdbs(); gdk_threads_leave(); /* Load layout.*/ session_dir = get_user_session_dir(); if (!g_file_test(session_dir, G_FILE_TEST_IS_DIR)) session_dir = g_strdup(get_data_dir()); /* Restore session */ anjuta_shell_session_load(ANJUTA_SHELL(app), session_dir, NULL); g_free(session_dir); anjuta_status_progress_tick(status, NULL, _("Loaded Session...")); anjuta_status_disable_splash(status, TRUE); gtk_window_set_default_icon_name("gtkpod"); gtk_window_set_auto_startup_notification(TRUE); gtk_window_set_role(GTK_WINDOW(app), "gtkpod-app"); gtk_widget_show(GTK_WIDGET(app)); }
GimpInitStatusFunc gui_init (Gimp *gimp, gboolean no_splash) { GimpInitStatusFunc status_callback = NULL; GdkScreen *screen; gchar *abort_message; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (the_gui_gimp == NULL, NULL); abort_message = gui_sanity_check (); if (abort_message) gui_abort (abort_message); the_gui_gimp = gimp; gui_unique_init (gimp); gimp_widgets_init (gui_help_func, gui_get_foreground_func, gui_get_background_func, NULL); g_type_class_ref (GIMP_TYPE_COLOR_SELECT); /* disable automatic startup notification */ gtk_window_set_auto_startup_notification (FALSE); gimp_dnd_init (gimp); themes_init (gimp); screen = gdk_screen_get_default (); gtk_widget_set_default_colormap (gdk_screen_get_rgb_colormap (screen)); if (! no_splash) { splash_create (gimp->be_verbose); status_callback = splash_update; } g_signal_connect_after (gimp, "initialize", G_CALLBACK (gui_initialize_after_callback), NULL); g_signal_connect (gimp, "restore", G_CALLBACK (gui_restore_callback), NULL); g_signal_connect_after (gimp, "restore", G_CALLBACK (gui_restore_after_callback), NULL); g_signal_connect (gimp, "exit", G_CALLBACK (gui_exit_callback), NULL); g_signal_connect_after (gimp, "exit", G_CALLBACK (gui_exit_after_callback), NULL); return status_callback; }
int main (int argc, char *argv[]) { gboolean kill_shell; gboolean restart_shell; gboolean no_default_window; gboolean browser_window; gboolean no_desktop; const char *startup_id; char *startup_id_copy; char *session_to_load; gchar *geometry; const gchar **remaining; gboolean perform_self_check; GOptionContext *context; NautilusApplication *application; char **argv_copy; GnomeProgram *program; const GOptionEntry options[] = { #ifndef NAUTILUS_OMIT_SELF_CHECK { "check", 'c', 0, G_OPTION_ARG_NONE, &perform_self_check, N_("Perform a quick set of self-check tests."), NULL }, #endif { "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 Nautilus."), NULL }, { "restart", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &restart_shell, N_("Restart Nautilus."), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, N_("[URI...]") }, { "load-session", 'l', 0, G_OPTION_ARG_STRING, &session_to_load, /* Translators: --no-default-window is a nautilus command line parameter, don't modify it. */ N_("Load a saved session from the specified file. Implies \"--no-default-window\"."), N_("FILENAME") }, { NULL } }; g_thread_init (NULL); setlocale (LC_ALL, ""); /* This will be done by gtk+ later, but for now, force it to GNOME */ g_desktop_app_info_set_desktop_env ("GNOME"); if (g_getenv ("NAUTILUS_DEBUG") != NULL) { eel_make_warnings_and_criticals_stop_in_debugger (); } /* Initialize gettext support */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); startup_id = g_getenv ("DESKTOP_STARTUP_ID"); startup_id_copy = NULL; if (startup_id != NULL && *startup_id != '\0') { /* Clear the DESKTOP_STARTUP_ID, but make sure to copy it first */ startup_id_copy = g_strdup (startup_id); g_unsetenv ("DESKTOP_STARTUP_ID"); } /* we'll do it ourselves due to complicated factory setup */ gtk_window_set_auto_startup_notification (FALSE); /* Get parameters. */ remaining = NULL; geometry = NULL; session_to_load = NULL; kill_shell = FALSE; no_default_window = FALSE; no_desktop = FALSE; perform_self_check = FALSE; restart_shell = FALSE; browser_window = FALSE; g_set_application_name (_("File Manager")); context = g_option_context_new (_("\n\nBrowse the file system with the file manager")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); #ifdef HAVE_EXEMPI xmp_init(); #endif program = gnome_program_init ("nautilus", VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_HUMAN_READABLE_NAME, _("Nautilus"), NULL); /* We do this after gnome_program_init(), since that function sets up * its own handler for SIGSEGV and others --- we want to chain to those * handlers. */ setup_debug_log (); if (session_to_load != NULL) { no_default_window = TRUE; } /* Do this here so that gdk_display is initialized */ if (startup_id_copy == NULL) { /* Create a fake one containing a timestamp that we can use */ Time timestamp; timestamp = slowly_and_stupidly_obtain_timestamp (gdk_display); startup_id_copy = g_strdup_printf ("_TIME%lu", timestamp); } /* Set default icon for all nautilus windows */ gtk_window_set_default_icon_name (NAUTILUS_ICON_FOLDER); /* Need to set this to the canonical DISPLAY value, since thats where we're registering per-display components */ bonobo_activation_set_activation_env_value ("DISPLAY", gdk_display_get_name (gdk_display_get_default())); if (perform_self_check && remaining != NULL) { /* translators: %s is an option (e.g. --check) */ fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--check"); return EXIT_FAILURE; } if (perform_self_check && (kill_shell || restart_shell)) { fprintf (stderr, _("nautilus: --check cannot be used with other options.\n")); return EXIT_FAILURE; } if (kill_shell && remaining != NULL) { fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--quit"); return EXIT_FAILURE; } if (restart_shell && remaining != NULL) { fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--restart"); return EXIT_FAILURE; } if (geometry != NULL && remaining != NULL && remaining[0] != NULL && remaining[1] != NULL) { fprintf (stderr, _("nautilus: --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. */ nautilus_global_preferences_init (); if (no_desktop) { eel_preferences_set_is_invisible (NAUTILUS_PREFERENCES_SHOW_DESKTOP, TRUE); eel_preferences_set_is_invisible (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, TRUE); } bonobo_activate (); /* do now since we need it before main loop */ application = NULL; /* Do either the self-check or the real work. */ if (perform_self_check) { #ifndef NAUTILUS_OMIT_SELF_CHECK /* Run the checks (each twice) for nautilus and libnautilus-private. */ nautilus_run_self_checks (); nautilus_run_lib_self_checks (); eel_exit_if_self_checks_failed (); nautilus_run_self_checks (); nautilus_run_lib_self_checks (); eel_exit_if_self_checks_failed (); #endif } else { /* Run the nautilus application. */ application = nautilus_application_new (); nautilus_application_startup (application, kill_shell, restart_shell, no_default_window, no_desktop, !(kill_shell || restart_shell), browser_window, startup_id_copy, geometry, session_to_load, remaining); g_free (startup_id_copy); /* The application startup does things in an idle, so we need to check whether the main loop is needed in an idle */ g_idle_add (initial_event_loop_needed, NULL); gtk_main (); } nautilus_icon_info_clear_caches (); if (application != NULL) { bonobo_object_unref (application); } eel_debug_shut_down (); /* If told to restart, exec() myself again. This is used when * the program is told to restart with CORBA, for example when * an update takes place. */ if (g_getenv ("_NAUTILUS_RESTART") != NULL) { g_unsetenv ("_NAUTILUS_RESTART"); /* Might eventually want to copy all the parameters * from argv into the new exec. For now, though, that * would just interfere with the re-creation of * windows based on the window info stored in gconf, * including whether the desktop was started. */ argv_copy = g_new0 (char *, 2); argv_copy[0] = argv[0]; execvp (argv[0], argv_copy); }
int main (int argc, char *argv[]) { GOptionContext *ctx; GError *error = NULL; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif #ifdef G_THREADS_ENABLED #if GLIB_CHECK_VERSION(2,31,0) /* No longer need to init threads manually anymore */ #else /* this must be called before gtk_init () */ g_thread_init (NULL); #endif /* FIXME: this call causes gtkpod to freeze as soon as tracks should be displayed */ gdk_threads_init (); #endif #ifdef HAVE_CLUTTER_GTK gtk_clutter_init(&argc, &argv); clutter_threads_init(); #else gtk_init (&argc, &argv); #endif ctx = g_option_context_new (_("- Interface with your iPod")); g_option_context_add_main_entries(ctx, gtkpod_get_option_entries(), NULL); g_option_context_add_group (ctx, gtk_get_option_group (TRUE)); #ifdef HAVE_GSTREAMER g_option_context_add_group (ctx, gst_init_get_option_group ()); #endif #ifdef HAVE_BRASERO g_option_context_add_group (ctx, brasero_media_get_option_group ()); #endif g_option_context_parse (ctx, &argc, &argv, &error); if (error != NULL) { g_printerr (_("Error parsing options: %s\n"), error->message); g_error_free(error); exit(1); } g_option_context_free (ctx); g_set_application_name(_("gtkpod")); gtk_window_set_auto_startup_notification(FALSE); srand(time(NULL)); gtkpod_init (argc, argv); #ifdef G_THREADS_ENABLED gdk_threads_enter(); #endif gtk_main (); #ifdef G_THREADS_ENABLED gdk_threads_leave(); #endif return 0; }