From 4ce7b8ead389ada57be40d1a0b7e7af9527a3950 Mon Sep 17 00:00:00 2001 From: John Sullivan Date: Thu, 24 Feb 2000 01:18:19 +0000 Subject: [PATCH] Fixed bug where Open in New Window would only open one new window when multiple items were selected. --- ChangeLog-20000414 | 21 +++++++++++ src/nautilus-application.c | 5 ++- src/nautilus-window-manage-views.c | 56 +++++++++++++++++++++++++++--- src/ntl-app.c | 5 ++- src/ntl-window-msgs.c | 56 +++++++++++++++++++++++++++--- 5 files changed, 131 insertions(+), 12 deletions(-) diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index cf7d8598e..6c31e6bf0 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,3 +1,24 @@ +2000-02-23 John Sullivan + + Visible part of the fix to bug 14 (Open in New Window only + opens one window when multiple items selected). Still need + to clean up old, unnecessary code. Checking this in now for + convenience; will clean up other code tomorrow. + + * src/ntl-app.c: (nautilus_app_create_window): Replaced the + gtk_widget_show of new window with comment explaining why not + to show it yet. + + * src/ntl-window-msgs.c: + (nautilus_window_request_location_change): Spawn new window here + if the NavigationRequestInfo says so (formerly didn't spawn new + window until after we knew it was a displayable uri; that code + is still present but now never invoked; I will kill it tomorrow). + (nautilus_window_change_location_2): Call gtk_widget_show on + window when we know that location change will succeed; if the + location change failed, destroy the nascent window and put the + error message in an unparented dialog. + 2000-02-23 Darin Adler Some of the underlying work to prepare for emblems on the icons. diff --git a/src/nautilus-application.c b/src/nautilus-application.c index e7c0caa9b..0be7a4fa5 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -105,7 +105,10 @@ nautilus_app_create_window(void) gtk_signal_connect(GTK_OBJECT(win), "destroy", nautilus_app_destroy_window, NULL); - gtk_widget_show(win); + /* Do not yet show the window. It will be shown later on if it can + * successfully display its initial uri. Otherwise it will be destroyed + * without ever having seen the light of day. + */ return NAUTILUS_WINDOW(win); } diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index b7b63721f..2220da7b2 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -456,7 +456,27 @@ nautilus_window_request_location_change(NautilusWindow *window, Nautilus_NavigationRequestInfo *loc, NautilusView *requesting_view) { - nautilus_window_change_location(window, loc, requesting_view, FALSE, FALSE); + gboolean use_new_window; + + + /* FIXME: Either remove distinctions between default, suggested, & enforced, or + * deal with them somehow. + */ + use_new_window = (loc->new_window_default == Nautilus_V_TRUE || + loc->new_window_suggested == Nautilus_V_TRUE || + loc->new_window_enforced == Nautilus_V_TRUE); + + if (use_new_window) + { + NautilusWindow *new_window; + + new_window = nautilus_app_create_window (); + nautilus_window_set_initial_state (new_window, loc->requested_uri); + } + else + { + nautilus_window_change_location(window, loc, requesting_view, FALSE, FALSE); + } } static NautilusView * @@ -879,12 +899,19 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data) if(!navi) { + /* FIXME: Give uri explicitly in this message. Also reword to + * make it more understandable. + */ errmsg = _("The chosen file could not be retrieved."); goto errout; } if(!navi->default_content_iid) { + /* FIXME: Give uri explicitly in this message. Also reword to + * make it more understandable. Is this any different to the user + * than the previous case? + */ errmsg = _("There is no known method of displaying the chosen file."); goto errout; } @@ -898,18 +925,37 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data) (NautilusWindowStateItem)0); window = nautilus_app_create_window (); - gtk_widget_show (GTK_WIDGET (window)); } + /* Show the window to handle the new-window case. + * Doesn't hurt if window already showing. Maybe this should + * go sometime later so the gray window isn't on screen so long. + */ + gtk_widget_show (GTK_WIDGET (window)); + nautilus_window_set_state_info(window, (NautilusWindowStateItem)NAVINFO_RECEIVED, navi, (NautilusWindowStateItem)0); return; errout: - nautilus_window_allow_stop(window, FALSE); + if (navi != NULL) nautilus_navinfo_free(navi); - window->is_back = FALSE; - nautilus_window_progress_indicate(window, PROGRESS_ERROR, 0, errmsg); + + if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) + { + /* Destroy never-had-a-chance-to-be-seen window. This case + * happens when a new window cannot display its initial URI. + */ + gtk_object_destroy (GTK_OBJECT (window)); + gtk_widget_show (gnome_error_dialog (errmsg)); + } + else + { + /* Clean up state of already-showing window */ + nautilus_window_allow_stop(window, FALSE); + window->is_back = FALSE; + nautilus_window_progress_indicate(window, PROGRESS_ERROR, 0, errmsg); + } } void diff --git a/src/ntl-app.c b/src/ntl-app.c index e7c0caa9b..0be7a4fa5 100644 --- a/src/ntl-app.c +++ b/src/ntl-app.c @@ -105,7 +105,10 @@ nautilus_app_create_window(void) gtk_signal_connect(GTK_OBJECT(win), "destroy", nautilus_app_destroy_window, NULL); - gtk_widget_show(win); + /* Do not yet show the window. It will be shown later on if it can + * successfully display its initial uri. Otherwise it will be destroyed + * without ever having seen the light of day. + */ return NAUTILUS_WINDOW(win); } diff --git a/src/ntl-window-msgs.c b/src/ntl-window-msgs.c index b7b63721f..2220da7b2 100644 --- a/src/ntl-window-msgs.c +++ b/src/ntl-window-msgs.c @@ -456,7 +456,27 @@ nautilus_window_request_location_change(NautilusWindow *window, Nautilus_NavigationRequestInfo *loc, NautilusView *requesting_view) { - nautilus_window_change_location(window, loc, requesting_view, FALSE, FALSE); + gboolean use_new_window; + + + /* FIXME: Either remove distinctions between default, suggested, & enforced, or + * deal with them somehow. + */ + use_new_window = (loc->new_window_default == Nautilus_V_TRUE || + loc->new_window_suggested == Nautilus_V_TRUE || + loc->new_window_enforced == Nautilus_V_TRUE); + + if (use_new_window) + { + NautilusWindow *new_window; + + new_window = nautilus_app_create_window (); + nautilus_window_set_initial_state (new_window, loc->requested_uri); + } + else + { + nautilus_window_change_location(window, loc, requesting_view, FALSE, FALSE); + } } static NautilusView * @@ -879,12 +899,19 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data) if(!navi) { + /* FIXME: Give uri explicitly in this message. Also reword to + * make it more understandable. + */ errmsg = _("The chosen file could not be retrieved."); goto errout; } if(!navi->default_content_iid) { + /* FIXME: Give uri explicitly in this message. Also reword to + * make it more understandable. Is this any different to the user + * than the previous case? + */ errmsg = _("There is no known method of displaying the chosen file."); goto errout; } @@ -898,18 +925,37 @@ nautilus_window_change_location_2(NautilusNavigationInfo *navi, gpointer data) (NautilusWindowStateItem)0); window = nautilus_app_create_window (); - gtk_widget_show (GTK_WIDGET (window)); } + /* Show the window to handle the new-window case. + * Doesn't hurt if window already showing. Maybe this should + * go sometime later so the gray window isn't on screen so long. + */ + gtk_widget_show (GTK_WIDGET (window)); + nautilus_window_set_state_info(window, (NautilusWindowStateItem)NAVINFO_RECEIVED, navi, (NautilusWindowStateItem)0); return; errout: - nautilus_window_allow_stop(window, FALSE); + if (navi != NULL) nautilus_navinfo_free(navi); - window->is_back = FALSE; - nautilus_window_progress_indicate(window, PROGRESS_ERROR, 0, errmsg); + + if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) + { + /* Destroy never-had-a-chance-to-be-seen window. This case + * happens when a new window cannot display its initial URI. + */ + gtk_object_destroy (GTK_OBJECT (window)); + gtk_widget_show (gnome_error_dialog (errmsg)); + } + else + { + /* Clean up state of already-showing window */ + nautilus_window_allow_stop(window, FALSE); + window->is_back = FALSE; + nautilus_window_progress_indicate(window, PROGRESS_ERROR, 0, errmsg); + } } void