diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/nautilus-application-smclient.c | 1 | ||||
-rw-r--r-- | src/nautilus-application.c | 1 | ||||
-rw-r--r-- | src/nautilus-main.c | 255 | ||||
-rw-r--r-- | src/nautilus-main.h | 37 | ||||
-rw-r--r-- | src/nautilus-navigation-window.c | 1 | ||||
-rw-r--r-- | src/nautilus-spatial-window.c | 1 | ||||
-rw-r--r-- | src/nautilus-window-manage-views.c | 1 | ||||
-rw-r--r-- | src/nautilus-window.c | 1 |
9 files changed, 21 insertions, 278 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2152e7ecd..c9fdc066b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -86,7 +86,6 @@ nautilus_SOURCES = \ nautilus-location-entry.c \ nautilus-location-entry.h \ nautilus-main.c \ - nautilus-main.h \ nautilus-navigation-action.c \ nautilus-navigation-action.h \ nautilus-navigation-bar.c \ diff --git a/src/nautilus-application-smclient.c b/src/nautilus-application-smclient.c index c70ffee8a..924361c79 100644 --- a/src/nautilus-application-smclient.c +++ b/src/nautilus-application-smclient.c @@ -23,7 +23,6 @@ #include "nautilus-application-smclient.h" -#include "nautilus-main.h" #include "nautilus-navigation-window.h" #include "nautilus-window-private.h" #include "nautilus-window-slot.h" diff --git a/src/nautilus-application.c b/src/nautilus-application.c index a5836960d..fdaeb710e 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -42,7 +42,6 @@ #include "nautilus-desktop-window.h" #include "nautilus-history-sidebar.h" #include "nautilus-image-properties-page.h" -#include "nautilus-main.h" #include "nautilus-navigation-window.h" #include "nautilus-navigation-window-slot.h" #include "nautilus-notes-viewer.h" diff --git a/src/nautilus-main.c b/src/nautilus-main.c index 34145f018..1f8c58a10 100644 --- a/src/nautilus-main.c +++ b/src/nautilus-main.c @@ -29,7 +29,6 @@ /* nautilus-main.c: Implementation of the routines that drive program lifecycle and main window creation/destruction. */ #include <config.h> -#include "nautilus-main.h" #include "nautilus-application.h" #include "nautilus-self-check-functions.h" @@ -64,97 +63,6 @@ #include <exempi/xmp.h> #endif -/* Keeps track of everyone who wants the main event loop kept active */ -static GSList *event_loop_registrants; - -static gboolean exit_with_last_window = TRUE; - -static gboolean -is_event_loop_needed (void) -{ - return event_loop_registrants != NULL || !exit_with_last_window; -} - -static int -quit_if_in_main_loop (gpointer callback_data) -{ - guint level; - - g_assert (callback_data == NULL); - - level = gtk_main_level (); - - /* We can be called even outside the main loop, - * so check that we are in a loop before calling quit. - */ - if (level != 0) { - gtk_main_quit (); - } - - /* We need to be called again if we quit a nested loop. */ - return level > 1; -} - -static void -eel_gtk_main_quit_all (void) -{ - /* Calling gtk_main_quit directly only kills the current/top event loop. - * This idler will be run by the current event loop, killing it, and then - * by the next event loop, ... - */ - g_idle_add (quit_if_in_main_loop, NULL); -} - -static void -event_loop_unregister (GtkWidget *object) -{ - event_loop_registrants = g_slist_remove (event_loop_registrants, object); - if (!is_event_loop_needed ()) { - eel_gtk_main_quit_all (); - } -} - -void -nautilus_main_event_loop_register (GtkWidget *object) -{ - g_signal_connect (object, "destroy", G_CALLBACK (event_loop_unregister), NULL); - event_loop_registrants = g_slist_prepend (event_loop_registrants, object); -} - -gboolean -nautilus_main_is_event_loop_mainstay (GtkWidget *object) -{ - return g_slist_length (event_loop_registrants) == 1 - && event_loop_registrants->data == object; -} - -void -nautilus_main_event_loop_quit (gboolean explicit) -{ - if (explicit) { - /* Explicit --quit, make sure we don't restart */ - - /* To quit all instances, reset exit_with_last_window */ - exit_with_last_window = TRUE; - - if (event_loop_registrants == NULL) { - /* If this is reached, nautilus must run in "daemon" mode - * (i.e. !exit_with_last_window) with no windows open. - * We need to quit_all here because the below loop won't - * trigger a quit. - */ - eel_gtk_main_quit_all(); - } - - /* TODO: With the old session we needed to set restart - style to GNOME_RESTART_IF_RUNNING here, but i don't think we need - that now since gnome-session doesn't restart apps except on startup. */ - } - while (event_loop_registrants != NULL) { - gtk_widget_destroy (event_loop_registrants->data); - } -} - static void dump_debug_log (void) { @@ -318,47 +226,14 @@ setup_debug_log (void) int main (int argc, char *argv[]) { - gboolean kill_shell; gboolean no_default_window; - gboolean browser_window; gboolean no_desktop; - gboolean version; gboolean autostart_mode; + gint retval; const char *autostart_id; - gchar *geometry; - gchar **remaining; - gboolean perform_self_check; + gboolean perform_self_check = FALSE; NautilusApplication *application; - GOptionContext *context; - GFile *file; - char *uri; - char **uris; - GPtrArray *uris_array; - GError *error; - int i; - 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 - { "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 Nautilus."), NULL }, - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, N_("[URI...]") }, - - { NULL } - }; - #if defined (HAVE_MALLOPT) && defined(M_MMAP_THRESHOLD) /* Nautilus uses lots and lots of small and medium size allocations, * and then a few large ones for the desktop background. By default @@ -372,7 +247,8 @@ main (int argc, char *argv[]) */ mallopt (M_MMAP_THRESHOLD, 128 *1024); #endif - + + g_type_init (); g_thread_init (NULL); /* This will be done by gtk+ later, but for now, force it to GNOME */ @@ -394,41 +270,19 @@ main (int argc, char *argv[]) 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; + /* If in autostart mode (aka started by gnome-session), we need to ensure + * nautilus starts with the correct options. + */ + if (autostart_mode) { + no_default_window = TRUE; + no_desktop = FALSE; + } g_set_prgname ("nautilus"); if (g_file_test (DATADIR "/applications/nautilus.desktop", G_FILE_TEST_EXISTS)) { egg_set_desktop_file (DATADIR "/applications/nautilus.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 ("GNOME nautilus " PACKAGE_VERSION "\n"); - return 0; - } #ifdef HAVE_EXEMPI xmp_init(); @@ -436,34 +290,6 @@ main (int argc, char *argv[]) setup_debug_log (); - /* If in autostart mode (aka started by gnome-session), we need to ensure - * nautilus 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, _("nautilus: %s cannot be used with URIs.\n"), - "--check"); - return EXIT_FAILURE; - } - if (perform_self_check && kill_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 (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 @@ -472,10 +298,11 @@ main (int argc, char *argv[]) */ nautilus_global_preferences_init (); +#if 0 /* exit_with_last_window being FALSE, nautilus can run without window. */ exit_with_last_window = g_settings_get_boolean (nautilus_preferences, NAUTILUS_PREFERENCES_EXIT_WITH_LAST_WINDOW); - +#endif application = NULL; /* Do either the self-check or the real work. */ @@ -490,61 +317,21 @@ main (int argc, char *argv[]) nautilus_run_self_checks (); nautilus_run_lib_self_checks (); eel_exit_if_self_checks_failed (); + + retval = EXIT_SUCCESS; #endif } else { - /* Convert args to URIs */ - uris = NULL; - 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); - g_object_unref (file); - if (uri) { - g_ptr_array_add (uris_array, uri); - } - } - } - g_ptr_array_add (uris_array, NULL); - uris = (char **)g_ptr_array_free (uris_array, FALSE); - g_strfreev (remaining); - } - - /* Run the nautilus application. */ - application = nautilus_application_new (); - - if (egg_sm_client_is_resumed (application->smclient)) { - no_default_window = TRUE; - } - - nautilus_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 (); - } - } + application = nautilus_application_dup_singleton (); - nautilus_icon_info_clear_caches (); - - if (application != NULL) { - g_object_unref (application); + retval = g_application_run (G_APPLICATION (application), + argc, argv); } + nautilus_icon_info_clear_caches (); + g_object_unref (application); eel_debug_shut_down (); - + nautilus_application_save_accel_map (NULL); return EXIT_SUCCESS; diff --git a/src/nautilus-main.h b/src/nautilus-main.h deleted file mode 100644 index 1ddb93036..000000000 --- a/src/nautilus-main.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* nautilus-main.c - */ - -#ifndef NAUTILUS_MAIN_H -#define NAUTILUS_MAIN_H - -#include <gtk/gtk.h> - -void nautilus_main_event_loop_register (GtkWidget *object); -gboolean nautilus_main_is_event_loop_mainstay (GtkWidget *object); -void nautilus_main_event_loop_quit (gboolean explicit); - -#endif /* NAUTILUS_MAIN_H */ - diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index f6bc9ab09..1155faa9a 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -34,7 +34,6 @@ #include "nautilus-actions.h" #include "nautilus-application.h" #include "nautilus-bookmarks-window.h" -#include "nautilus-main.h" #include "nautilus-location-bar.h" #include "nautilus-query-editor.h" #include "nautilus-search-bar.h" diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index fb01d1dd1..e18bb0f71 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -37,7 +37,6 @@ #include "nautilus-desktop-window.h" #include "nautilus-bookmarks-window.h" #include "nautilus-location-dialog.h" -#include "nautilus-main.h" #include "nautilus-query-editor.h" #include "nautilus-search-bar.h" #include "nautilus-window-manage-views.h" diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 99a9c055e..66013efc6 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -33,7 +33,6 @@ #include "nautilus-location-bar.h" #include "nautilus-search-bar.h" #include "nautilus-pathbar.h" -#include "nautilus-main.h" #include "nautilus-window-private.h" #include "nautilus-window-slot.h" #include "nautilus-navigation-window-slot.h" diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 0cac14954..e861c1b4b 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -33,7 +33,6 @@ #include "nautilus-actions.h" #include "nautilus-application.h" #include "nautilus-bookmarks-window.h" -#include "nautilus-main.h" #include "nautilus-window-manage-views.h" #include "nautilus-window-bookmarks.h" #include "nautilus-window-slot.h" |