Commit b79cbe1f authored by Mike Engber's avatar Mike Engber

Removed our quitting logic from nautilus-application (where it was tied to


	Removed our quitting logic from nautilus-application
	(where it was tied to nautilus-window closing) and added
	a more general mechanism in main.c - by which you can
	register any gtk object to keep the main event loop
	alive while the object is around. This, in turn, fixed
	a problem with the first-time-druid not causing nautilus
	to quit when it was cancel via the close box (bug 2211)
	and also a problem with nautilus quitting before you had
	a chance to see an error dialog (bug 1871). Also, added
	nautilus_main_event_loop_quit as the preferred way to
	cause nautilus to quit (as opposed to gtk_main_quit)

	* src/nautilus-application.c: (nautilus_application_startup),
	(nautilus_application_close_desktop),
	(nautilus_application_destroyed_window):
	* src/nautilus-application.h:
	* src/nautilus-first-time-druid.c: (druid_finished),
	(nautilus_first_time_druid_show):
	* src/nautilus-main.c: (nautilus_main_is_event_loop_needed),
	(nautilus_main_event_loop_unregister),
	(nautilus_main_event_loop_register),
	(nautilus_main_is_event_loop_mainstay),
	(nautilus_main_event_loop_quit), (main):
	* src/nautilus-main.h:
	* src/nautilus-shell.c: (corba_quit), (corba_restart):
	* src/nautilus-window-manage-views.c:
	(nautilus_window_end_location_change_callback):
	* src/nautilus-window.c: (nautilus_window_initialize):
parent a329e7ef
2000-09-01 Michael Engber <engber@eazel.com>
Removed our quitting logic from nautilus-application
(where it was tied to nautilus-window closing) and added
a more general mechanism in main.c - by which you can
register any gtk object to keep the main event loop
alive while the object is around. This, in turn, fixed
a problem with the first-time-druid not causing nautilus
to quit when it was cancel via the close box (bug 2211)
and also a problem with nautilus quitting before you had
a chance to see an error dialog (bug 1871). Also, added
nautilus_main_event_loop_quit as the preferred way to
cause nautilus to quit (as opposed to gtk_main_quit)
* src/nautilus-application.c: (nautilus_application_startup),
(nautilus_application_close_desktop),
(nautilus_application_destroyed_window):
* src/nautilus-application.h:
* src/nautilus-first-time-druid.c: (druid_finished),
(nautilus_first_time_druid_show):
* src/nautilus-main.c: (nautilus_main_is_event_loop_needed),
(nautilus_main_event_loop_unregister),
(nautilus_main_event_loop_register),
(nautilus_main_is_event_loop_mainstay),
(nautilus_main_event_loop_quit), (main):
* src/nautilus-main.h:
* src/nautilus-shell.c: (corba_quit), (corba_restart):
* src/nautilus-window-manage-views.c:
(nautilus_window_end_location_change_callback):
* src/nautilus-window.c: (nautilus_window_initialize):
2000-09-01 J Shane Culpepper <pepper@eazel.com>
* components/services/nautilus-dependent-shared/icons/Makefile.am:
......
......@@ -40,6 +40,7 @@
#include "nautilus-desktop-window.h"
#include "nautilus-first-time-druid.h"
#include "nautilus-shell.h"
#include "nautilus-main.h"
#include <bonobo.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-global-preferences.h>
......@@ -289,7 +290,7 @@ nautilus_make_uri_list_from_strv (const char * const *strv)
return uri_list;
}
gboolean
void
nautilus_application_startup (NautilusApplication *application,
gboolean kill_shell,
gboolean restart_shell,
......@@ -303,17 +304,16 @@ nautilus_application_startup (NautilusApplication *application,
const char *message, *detailed_message;
GnomeDialog *dialog;
Nautilus_URIList *url_list;
gboolean need_main_loop;
/* Perform check for nautilus being run as super user */
if (!check_for_and_run_as_super_user ()) {
return FALSE;
return;
}
/* Run the first time startup druid if needed. */
if (need_to_show_first_time_druid ()) {
nautilus_first_time_druid_show (application, start_desktop, urls);
return TRUE;
return;
}
/* Check the user's ~/.nautilus directories and post warnings
......@@ -401,11 +401,9 @@ nautilus_application_startup (NautilusApplication *application,
}
if (message != NULL) {
dialog = nautilus_error_dialog_with_details
(message, detailed_message, NULL);
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
gtk_main_quit, NULL);
need_main_loop = TRUE;
dialog = nautilus_error_dialog_with_details (message, detailed_message, NULL);
/* We need the main event loop so the user has a chance to see the dialog. */
nautilus_main_event_loop_register (GTK_OBJECT (dialog));
goto out;
}
}
......@@ -437,12 +435,8 @@ nautilus_application_startup (NautilusApplication *application,
Nautilus_Shell_unref (shell, &ev);
CORBA_Object_release (shell, &ev);
need_main_loop = nautilus_application_window_list != NULL
|| nautilus_application_desktop_window != NULL;
out:
CORBA_exception_free (&ev);
return need_main_loop;
}
static void
......@@ -469,11 +463,7 @@ nautilus_application_close_desktop (void)
if (nautilus_application_desktop_window != NULL) {
gtk_widget_destroy (GTK_WIDGET (nautilus_application_desktop_window));
nautilus_application_desktop_window = NULL;
}
if (nautilus_application_window_list == NULL && gtk_main_level () > 0) {
gtk_main_quit ();
}
}
}
void
......@@ -488,9 +478,6 @@ static void
nautilus_application_destroyed_window (GtkObject *object, NautilusApplication *application)
{
nautilus_application_window_list = g_slist_remove (nautilus_application_window_list, object);
if (nautilus_application_window_list == NULL && nautilus_application_desktop_window == NULL) {
gtk_main_quit ();
}
}
NautilusWindow *
......
......@@ -54,7 +54,7 @@ typedef struct {
GtkType nautilus_application_get_type (void);
NautilusApplication *nautilus_application_new (void);
gboolean nautilus_application_startup (NautilusApplication *application,
void nautilus_application_startup (NautilusApplication *application,
gboolean kill_shell,
gboolean restart_shell,
gboolean stop_desktop,
......@@ -69,8 +69,4 @@ void nautilus_application_close_all_windows (void);
void nautilus_application_open_desktop (NautilusApplication *application);
void nautilus_application_close_desktop (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* NAUTILUS_APPLICATION_H */
......@@ -34,6 +34,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libgnomevfs/gnome-vfs.h>
#include <nautilus-main.h>
#include <libnautilus-extensions/nautilus-background.h>
#include <libnautilus-extensions/nautilus-druid.h>
#include <libnautilus-extensions/nautilus-druid-page-eazel.h>
......@@ -124,7 +125,6 @@ druid_finished (GtkWidget *druid_page)
char *user_main_directory;
const char *signup_uris[2];
gtk_widget_destroy(gtk_widget_get_toplevel(druid_page));
user_main_directory = nautilus_get_user_main_directory();
......@@ -156,8 +156,12 @@ druid_finished (GtkWidget *druid_page)
signup_uris[0] = NULL;
break;
}
nautilus_application_startup(save_application, FALSE, FALSE, save_manage_desktop,
nautilus_application_startup(save_application, FALSE, FALSE, save_manage_desktop,
FALSE, (signup_uris[0] != NULL) ? &signup_uris[0] : NULL);
/* Destroy druid last because it may be the only thing keeping the main event loop alive. */
gtk_widget_destroy(gtk_widget_get_toplevel(druid_page));
}
/* set up an event box to serve as the background */
......@@ -679,6 +683,9 @@ GtkWidget *nautilus_first_time_druid_show (NautilusApplication *application, gbo
_("Nautilus: Initial Preferences"));
gtk_container_set_border_width (GTK_CONTAINER (dialog), 0);
gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, FALSE, FALSE);
/* Ensure there's a main event loop while the druid is running. */
nautilus_main_event_loop_register (GTK_OBJECT (dialog));
druid = nautilus_druid_new ();
gtk_container_set_border_width (GTK_CONTAINER (druid), 0);
......
......@@ -29,8 +29,10 @@
/* 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-window.h"
#include "nautilus-self-check-functions.h"
#include <bonobo/bonobo-main.h>
#include <dlfcn.h>
......@@ -41,9 +43,50 @@
#include <libnautilus-extensions/nautilus-lib-self-check-functions.h>
#include <libnautilus-extensions/nautilus-self-checks.h>
#include <liboaf/liboaf.h>
#include <gtk/gtkmain.h>
#include <popt.h>
#include <stdlib.h>
/* Keeps track of everyone who wants the main event loop kept active */
static GSList *nautilus_main_event_loop_registrants;
static gboolean
nautilus_main_is_event_loop_needed (void)
{
return nautilus_main_event_loop_registrants != NULL;
}
static void
nautilus_main_event_loop_unregister (GtkObject* object)
{
g_assert (g_slist_find (nautilus_main_event_loop_registrants, object) != NULL);
nautilus_main_event_loop_registrants = g_slist_remove (nautilus_main_event_loop_registrants, object);
if (!nautilus_main_is_event_loop_needed () && gtk_main_level () > 0) {
gtk_main_quit ();
}
}
void
nautilus_main_event_loop_register (GtkObject* object)
{
gtk_signal_connect (object, "destroy", nautilus_main_event_loop_unregister, NULL);
nautilus_main_event_loop_registrants = g_slist_prepend (nautilus_main_event_loop_registrants, object);
}
gboolean
nautilus_main_is_event_loop_mainstay (GtkObject* object)
{
return g_slist_length (nautilus_main_event_loop_registrants) == 1 && nautilus_main_event_loop_registrants->data == object;
}
void
nautilus_main_event_loop_quit (void)
{
while (nautilus_main_event_loop_registrants != NULL) {
gtk_object_destroy (nautilus_main_event_loop_registrants->data);
}
}
int
main (int argc, char *argv[])
{
......@@ -128,12 +171,13 @@ main (int argc, char *argv[])
fprintf(stderr, _("nautiluls: --stop-desktop and --start-desktop cannot be used together.\n"));
} else {
application = nautilus_application_new ();
if (nautilus_application_startup (application,
kill_shell,
restart_shell,
stop_desktop,
start_desktop,
args)) {
nautilus_application_startup (application,
kill_shell,
restart_shell,
stop_desktop,
start_desktop,
args);
if (nautilus_main_is_event_loop_needed ()) {
bonobo_main ();
}
bonobo_object_unref (BONOBO_OBJECT (application));
......
/* -*- 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/gtktypeutils.h>
void nautilus_main_event_loop_register (GtkObject* object);
gboolean nautilus_main_is_event_loop_mainstay (GtkObject* object);
void nautilus_main_event_loop_quit (void);
#endif /* NAUTILUS_MAIN_H */
\ No newline at end of file
......@@ -30,6 +30,7 @@
#include <config.h>
#include "nautilus-window-private.h"
#include "nautilus-main.h"
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-sidebar.h"
......@@ -150,6 +151,9 @@ nautilus_window_initialize (NautilusWindow *window)
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
window);
/* Keep the main event loop alive as long as the window exists */
nautilus_main_event_loop_register (GTK_OBJECT (window));
}
static gboolean
......
......@@ -30,6 +30,7 @@
#include <config.h>
#include "nautilus-window-private.h"
#include "nautilus-main.h"
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-sidebar.h"
......@@ -150,6 +151,9 @@ nautilus_window_initialize (NautilusWindow *window)
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
window);
/* Keep the main event loop alive as long as the window exists */
nautilus_main_event_loop_register (GTK_OBJECT (window));
}
static gboolean
......
......@@ -36,6 +36,7 @@
#define nautilus_view_component_H
#include "nautilus-desktop-window.h"
#include "nautilus-main.h"
#include <gtk/gtklabel.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkmain.h>
......@@ -303,7 +304,7 @@ corba_quit (PortableServer_Servant servant,
CORBA_Environment *ev)
{
if (gtk_main_level () > 0) {
gtk_main_quit ();
nautilus_main_event_loop_quit ();
}
}
......@@ -402,7 +403,7 @@ corba_restart (PortableServer_Servant servant,
CORBA_Environment *ev)
{
if (gtk_main_level () > 0) {
gtk_main_quit ();
nautilus_main_event_loop_quit ();
}
save_window_states ();
setenv ("_NAUTILUS_RESTART", "yes", 1);
......
......@@ -30,6 +30,7 @@
#include <config.h>
#include "nautilus-window-private.h"
#include "nautilus-main.h"
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-sidebar.h"
......@@ -150,6 +151,9 @@ nautilus_window_initialize (NautilusWindow *window)
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
window);
/* Keep the main event loop alive as long as the window exists */
nautilus_main_event_loop_register (GTK_OBJECT (window));
}
static gboolean
......
......@@ -35,6 +35,7 @@
#include "nautilus-applicable-views.h"
#include "nautilus-application.h"
#include "nautilus-main.h"
#include "nautilus-location-bar.h"
#include "nautilus-window-private.h"
#include <libgnome/gnome-i18n.h>
......@@ -1276,7 +1277,8 @@ nautilus_window_end_location_change_callback (NautilusNavigationResult result_co
char *error_message;
char *scheme_string;
char *type_string;
GnomeDialog *dialog;
g_assert (navi != NULL);
window->location_change_end_reached = TRUE;
......@@ -1375,9 +1377,20 @@ nautilus_window_end_location_change_callback (NautilusNavigationResult result_co
/* Destroy never-had-a-chance-to-be-seen window. This case
* happens when a new window cannot display its initial URI.
*/
dialog = nautilus_error_dialog (error_message, NULL);
/* If window is the sole window open, destroying it will
* kill the main event loop and the dialog will go away
* before the user has a chance to see it. Prevent this
* by registering the dialog before calling destroy.
*/
if (nautilus_main_is_event_loop_mainstay (GTK_OBJECT (window))) {
nautilus_main_event_loop_register (GTK_OBJECT (dialog));
}
/* FIXME bugzilla.eazel.com 2459: Is a destroy really sufficient here? Who does the unref? */
gtk_object_destroy (GTK_OBJECT (window));
nautilus_error_dialog (error_message, NULL);
} else {
/* Clean up state of already-showing window */
nautilus_window_allow_stop (window, FALSE);
......
......@@ -30,6 +30,7 @@
#include <config.h>
#include "nautilus-window-private.h"
#include "nautilus-main.h"
#include "nautilus-application.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-sidebar.h"
......@@ -150,6 +151,9 @@ nautilus_window_initialize (NautilusWindow *window)
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE,
sidebar_panels_changed_callback,
window);
/* Keep the main event loop alive as long as the window exists */
nautilus_main_event_loop_register (GTK_OBJECT (window));
}
static gboolean
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment