Commit b16e11d4 authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

reviewed by: Darin Adler <darin@eazel.com>

2001-02-16  Gene Z. Ragan  <gzr@eazel.com>

	reviewed by: Darin Adler <darin@eazel.com>

	Fixed bug 6689, Segmentation fault from volume_in_black_list after
	the death of the desktop.

	* src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list):
	Add an assert to catch a NULL icon view being passed in.  We need to
	find out why this happens if it ever does.

	* src/nautilus-application.c: (window_can_be_closed),
	(is_last_closable_window), (volume_unmounted_callback):
	Handle single window case in the code where we close the windows
	the are displaying the contents of the unmounted volume.  In the case
	of a single window, direct it back to the default home directory.
parent 49e74380
2001-02-16 Gene Z. Ragan <gzr@eazel.com>
reviewed by: Darin Adler <darin@eazel.com>
Fixed bug 6689, Segmentation fault from volume_in_black_list after
the death of the desktop.
* src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list):
Add an assert to catch a NULL icon view being passed in. We need to
find out why this happens if it ever does.
* src/nautilus-application.c: (window_can_be_closed),
(is_last_closable_window), (volume_unmounted_callback):
Handle single window case in the code where we close the windows
the are displaying the contents of the unmounted volume. In the case
of a single window, direct it back to the default home directory.
2001-02-16 Andy Hertzfeld <andy@eazel.com>
* src/nautilus-sidebar-tabs.c: (draw_one_tab_themed),
......
......@@ -225,6 +225,8 @@ volume_in_black_list (FMDesktopIconView *icon_view,
const NautilusVolume *volume)
{
GList *p;
g_return_val_if_fail (FM_IS_DESKTOP_ICON_VIEW (icon_view), TRUE);
for (p = icon_view->details->mount_black_list; p != NULL; p = p->next) {
if (strcmp ((char *) p->data, volume->mount_path) == 0) {
......
......@@ -686,7 +686,7 @@ need_to_show_first_time_druid (void)
return result;
}
/* Called whenever a volume is mounted.s
/* Called whenever a volume is mounted.
* It would also be cool to restore open windows and
* position info saved when the volume was unmounted.
*/
......@@ -696,6 +696,33 @@ volume_mounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volume,
{
}
static gboolean
window_can_be_closed (NautilusWindow *window)
{
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
return TRUE;
}
return FALSE;
}
static gboolean
is_last_closable_window (NautilusWindow *window)
{
GList *node, *window_list;
window_list = nautilus_application_get_window_list ();
for (node = window_list; node != NULL; node = node->next) {
if (window != NAUTILUS_WINDOW (node->data) && window_can_be_closed (NAUTILUS_WINDOW (node->data))) {
return FALSE;
}
}
return TRUE;
}
/* Called whenever a volume is unmounted. Check and see if there are any windows open
* displaying contents on the volume. If there are, close them.
* It would also be cool to save open window and position info.
......@@ -704,7 +731,7 @@ static void
volume_unmounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volume,
NautilusApplication *application)
{
GList *windows, *node, *close_list;
GList *window_list, *node, *close_list;
NautilusWindow *window;
char *uri;
char *path;
......@@ -712,12 +739,12 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volum
close_list = NULL;
/* Check and see if any of the open windows are displaying contents from the unmounted volume */
windows = nautilus_application_get_window_list ();
window_list = nautilus_application_get_window_list ();
/* Construct a list of windows to be closed */
for (node = windows; node != NULL; node = node->next) {
/* Construct a list of windows to be closed. Do not add the non-closable windows to the list. */
for (node = window_list; node != NULL; node = node->next) {
window = NAUTILUS_WINDOW (node->data);
if (window != NULL) {
if (window != NULL && window_can_be_closed (window)) {
uri = nautilus_window_get_location (window);
path = gnome_vfs_get_local_path_from_uri (uri);
if (nautilus_str_has_prefix (path, volume->mount_path)) {
......@@ -727,12 +754,18 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volum
g_free (uri);
}
}
/* Now close all windows in the close list */
/* Handle the windows in the close list. */
for (node = close_list; node != NULL; node = node->next) {
nautilus_window_close (NAUTILUS_WINDOW (node->data));
window = NAUTILUS_WINDOW (node->data);
if (is_last_closable_window (window)) {
/* Don't close the last or only window. Try to redirect to the default home directory. */
nautilus_window_go_home (window);
} else {
nautilus_window_close (window);
}
}
g_list_free (close_list);
}
......
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