View | Details | Raw Unified | Return to bug 222490
Collapse All | Expand All

(-)a/libnautilus-private/nautilus-desktop-icon-file.c (-4 / +20 lines)
Lines 179-185 update_info_from_link (NautilusDesktopIconFile *icon_file) Link Here
179
	NautilusFile *file;
179
	NautilusFile *file;
180
	GnomeVFSFileInfo *file_info;
180
	GnomeVFSFileInfo *file_info;
181
	NautilusDesktopLink *link;
181
	NautilusDesktopLink *link;
182
	GnomeVFSVolume *volume;
182
	GObject *drive_or_volume;
183
	
183
	
184
	file = NAUTILUS_FILE (icon_file);
184
	file = NAUTILUS_FILE (icon_file);
185
	
185
	
Lines 216-224 update_info_from_link (NautilusDesktopIconFile *icon_file) Link Here
216
		GNOME_VFS_FILE_INFO_FIELDS_ACCESS |
216
		GNOME_VFS_FILE_INFO_FIELDS_ACCESS |
217
		GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
217
		GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
218
218
219
	volume = nautilus_desktop_link_get_volume (link);
219
	drive_or_volume = nautilus_desktop_link_get_drive_or_volume (link);
220
	nautilus_file_set_volume (file, volume);
220
221
	gnome_vfs_volume_unref (volume);
221
	if (GNOME_IS_VFS_VOLUME (drive_or_volume)) {
222
		GnomeVFSVolume *volume;
223
224
		volume = GNOME_VFS_VOLUME (drive_or_volume);
225
		nautilus_file_set_volume (file, volume);
226
		gnome_vfs_volume_unref (volume);
227
228
		nautilus_file_set_drive (file, NULL);
229
	} else {
230
		GnomeVFSDrive *drive;
231
232
		drive = GNOME_VFS_DRIVE (drive_or_volume);
233
		nautilus_file_set_drive (file, drive);
234
		gnome_vfs_drive_unref (drive);
235
236
		nautilus_file_set_volume (file, NULL);
237
	}
222
	
238
	
223
	file->details->file_info_is_up_to_date = TRUE;
239
	file->details->file_info_is_up_to_date = TRUE;
224
240
(-)a/libnautilus-private/nautilus-desktop-link-monitor.c (-70 / +355 lines)
Lines 52-64 struct NautilusDesktopLinkMonitorDetails { Link Here
52
	NautilusDesktopLink *trash_link;
52
	NautilusDesktopLink *trash_link;
53
	NautilusDesktopLink *network_link;
53
	NautilusDesktopLink *network_link;
54
54
55
	gulong connected_id;
56
	gulong disconnected_id;
55
	gulong mount_id;
57
	gulong mount_id;
56
	gulong unmount_id;
58
	gulong unmount_id;
57
	
59
	
58
	GList *volume_links;
60
	GList *volume_links;
59
};
61
};
60
62
61
62
static void nautilus_desktop_link_monitor_init       (gpointer              object,
63
static void nautilus_desktop_link_monitor_init       (gpointer              object,
63
						      gpointer              klass);
64
						      gpointer              klass);
64
static void nautilus_desktop_link_monitor_class_init (gpointer              klass);
65
static void nautilus_desktop_link_monitor_class_init (gpointer              klass);
Lines 69-74 EEL_CLASS_BOILERPLATE (NautilusDesktopLinkMonitor, Link Here
69
70
70
static NautilusDesktopLinkMonitor *the_link_monitor = NULL;
71
static NautilusDesktopLinkMonitor *the_link_monitor = NULL;
71
72
73
static void refresh_volume_links (NautilusDesktopLinkMonitor *monitor);
74
72
static void
75
static void
73
destroy_desktop_link_monitor (void)
76
destroy_desktop_link_monitor (void)
74
{
77
{
Lines 104-144 static void Link Here
104
volume_delete_dialog (GtkWidget *parent_view,
107
volume_delete_dialog (GtkWidget *parent_view,
105
                      NautilusDesktopLink *link)
108
                      NautilusDesktopLink *link)
106
{
109
{
107
	GnomeVFSVolume *volume;
110
	GObject *drive_or_volume;
108
	char *dialog_str;
111
	char *dialog_str;
112
	char *detail_str;
109
	char *display_name;
113
	char *display_name;
110
114
111
	volume = nautilus_desktop_link_get_volume (link);
115
	drive_or_volume = nautilus_desktop_link_get_drive_or_volume (link);
116
	if (drive_or_volume == NULL)
117
		return;
118
119
	display_name = nautilus_desktop_link_get_display_name (link);
112
120
113
	if (volume != NULL) {
121
	if (GNOME_IS_VFS_VOLUME (drive_or_volume)) {
114
		display_name = nautilus_desktop_link_get_display_name (link);
115
		dialog_str = g_strdup_printf (_("You cannot move the volume \"%s\" to the trash."),
122
		dialog_str = g_strdup_printf (_("You cannot move the volume \"%s\" to the trash."),
116
					      display_name);
123
					      display_name);
117
		g_free (display_name);
124
118
125
		if (eject_for_type (gnome_vfs_volume_get_device_type (GNOME_VFS_VOLUME (drive_or_volume)))) {
119
		if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
126
			detail_str = _("If you want to eject the volume, please use \"Eject\" in the "
120
			eel_run_simple_dialog
127
				       "popup menu of the volume.");
121
				(parent_view, 
122
				 FALSE,
123
				 GTK_MESSAGE_ERROR,
124
				 dialog_str,
125
				 _("If you want to eject the volume, please use \"Eject\" in the "
126
				   "popup menu of the volume."),
127
				 GTK_STOCK_OK, NULL);
128
		} else {
128
		} else {
129
			eel_run_simple_dialog
129
			detail_str = _("If you want to unmount the volume, please use \"Unmount Volume\" in the "
130
				(parent_view, 
130
				       "popup menu of the volume.");
131
				 FALSE,
132
				 GTK_MESSAGE_ERROR,
133
				 dialog_str,
134
				 _("If you want to unmount the volume, please use \"Unmount Volume\" in the "
135
				   "popup menu of the volume."),
136
				 GTK_STOCK_OK, NULL);
137
		}
131
		}
132
	} else {
133
		dialog_str = g_strdup_printf (_("You cannot move the drive \"%s\" to the trash."),
134
					      display_name);
138
135
139
		gnome_vfs_volume_unref (volume);
136
		detail_str = NULL;
140
		g_free (dialog_str);
137
	}
138
139
	eel_run_simple_dialog (parent_view, FALSE, GTK_MESSAGE_ERROR,
140
			       dialog_str,
141
			       detail_str,
142
			       NULL, GTK_STOCK_OK, NULL);
143
144
	if (GNOME_IS_VFS_VOLUME (drive_or_volume)) {
145
		gnome_vfs_volume_unref (GNOME_VFS_VOLUME (drive_or_volume));
146
	} else {
147
		gnome_vfs_drive_unref (GNOME_VFS_DRIVE (drive_or_volume));
141
	}
148
	}
149
150
	g_free (display_name);
151
	g_free (dialog_str);
142
}
152
}
143
153
144
void
154
void
Lines 161-166 nautilus_desktop_link_monitor_delete_link (NautilusDesktopLinkMonitor *monitor, Link Here
161
171
162
static gboolean
172
static gboolean
163
volume_file_name_used (NautilusDesktopLinkMonitor *monitor,
173
volume_file_name_used (NautilusDesktopLinkMonitor *monitor,
174
		       NautilusDesktopLink *skip_link,
164
		       const char *name)
175
		       const char *name)
165
{
176
{
166
	GList *l;
177
	GList *l;
Lines 168-173 volume_file_name_used (NautilusDesktopLinkMonitor *monitor, Link Here
168
	gboolean same;
179
	gboolean same;
169
180
170
	for (l = monitor->details->volume_links; l != NULL; l = l->next) {
181
	for (l = monitor->details->volume_links; l != NULL; l = l->next) {
182
		if (l->data == skip_link)
183
			continue;
184
171
		other_name = nautilus_desktop_link_get_file_name (l->data);
185
		other_name = nautilus_desktop_link_get_file_name (l->data);
172
		same = strcmp (name, other_name) == 0;
186
		same = strcmp (name, other_name) == 0;
173
		g_free (other_name);
187
		g_free (other_name);
Lines 182-187 volume_file_name_used (NautilusDesktopLinkMonitor *monitor, Link Here
182
196
183
char *
197
char *
184
nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor *monitor,
198
nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor *monitor,
199
						    NautilusDesktopLink *skip_link,
185
						    const char *filename)
200
						    const char *filename)
186
{
201
{
187
	char *unique_name;
202
	char *unique_name;
Lines 189-201 nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor * Link Here
189
	
204
	
190
	i = 2;
205
	i = 2;
191
	unique_name = g_strdup (filename);
206
	unique_name = g_strdup (filename);
192
	while (volume_file_name_used (monitor, unique_name)) {
207
	while (volume_file_name_used (monitor, skip_link, unique_name)) {
193
		g_free (unique_name);
208
		g_free (unique_name);
194
		unique_name = g_strdup_printf ("%s.%d", filename, i++);
209
		unique_name = g_strdup_printf ("%s.%d", filename, i++);
195
	}
210
	}
196
	return unique_name;
211
	return unique_name;
197
}
212
}
198
213
214
static gboolean
215
drive_has_volumes_apart_from (GnomeVFSDrive *drive, GnomeVFSVolume *possibly_last_volume)
216
{
217
	GList *volumes;
218
	GList *l;
219
	gboolean has_other_volumes;
220
221
	has_other_volumes = FALSE;
222
223
	volumes = gnome_vfs_drive_get_mounted_volumes (drive);
224
225
	for (l = volumes; l; l = l->next) {
226
		GnomeVFSVolume *volume;
227
228
		volume = GNOME_VFS_VOLUME (l->data);
229
		if (volume != possibly_last_volume)
230
			has_other_volumes = TRUE;
231
232
		gnome_vfs_volume_unref (volume);
233
	}
234
235
	g_list_free (volumes);
236
237
	return has_other_volumes;
238
}
239
240
static gboolean
241
should_show_drive (GnomeVFSDrive *drive, GnomeVFSVolume *possibly_last_volume)
242
{
243
	gboolean should_show;
244
245
	if (possibly_last_volume)
246
		should_show = !drive_has_volumes_apart_from (drive, possibly_last_volume);
247
	else
248
		should_show = !gnome_vfs_drive_is_mounted (drive);
249
250
	return (gnome_vfs_drive_is_user_visible (drive)
251
		&& should_show
252
		&& eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE));
253
}
254
255
static gboolean
256
should_show_volume (GnomeVFSVolume *volume)
257
{
258
	return (gnome_vfs_volume_is_user_visible (volume)
259
		&& eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE));
260
}
261
262
static void
263
create_drive_link (NautilusDesktopLinkMonitor *monitor,
264
		   GnomeVFSDrive *drive)
265
{
266
	NautilusDesktopLink *link;
267
268
	if (!should_show_drive (drive, NULL))
269
		return;
270
271
	link = nautilus_desktop_link_new_from_drive_or_volume (G_OBJECT (drive));
272
	monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
273
}
274
199
static void
275
static void
200
create_volume_link (NautilusDesktopLinkMonitor *monitor,
276
create_volume_link (NautilusDesktopLinkMonitor *monitor,
201
		    GnomeVFSVolume *volume)
277
		    GnomeVFSVolume *volume)
Lines 204-227 create_volume_link (NautilusDesktopLinkMonitor *monitor, Link Here
204
280
205
	link = NULL;
281
	link = NULL;
206
282
207
	if (!gnome_vfs_volume_is_user_visible (volume)) {
283
	if (!should_show_volume (volume)) {
208
		return;
284
		return;
209
	}
285
	}
210
286
211
	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
287
	link = nautilus_desktop_link_new_from_drive_or_volume (G_OBJECT (volume));
212
		link = nautilus_desktop_link_new_from_volume (volume);
288
	monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
213
		monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
289
}
290
291
static gboolean
292
link_corresponds_to_drive (NautilusDesktopLink *link,
293
			   GnomeVFSDrive *drive)
294
{
295
	GObject *drive_or_volume;
296
	gboolean same;
297
298
	drive_or_volume = nautilus_desktop_link_get_drive_or_volume (link);
299
	same = FALSE;
300
301
	if (GNOME_IS_VFS_DRIVE (drive_or_volume)) {
302
		GnomeVFSDrive *link_drive;
303
304
		link_drive = GNOME_VFS_DRIVE (drive_or_volume);
305
306
		if (link_drive == drive) {
307
			same = TRUE;
308
		}
309
310
		gnome_vfs_drive_unref (link_drive);
311
	} else {
312
		GnomeVFSVolume *link_volume;
313
		GnomeVFSDrive *link_drive;
314
315
		link_volume = GNOME_VFS_VOLUME (drive_or_volume);
316
		link_drive = gnome_vfs_volume_get_drive (link_volume);
317
318
		if (link_drive == drive) {
319
			same = TRUE;
320
		}
321
322
		if (link_drive) {
323
			gnome_vfs_drive_unref (link_drive);
324
		}
325
326
		gnome_vfs_volume_unref (link_volume);
214
	}
327
	}
328
329
	return same;
215
}
330
}
216
331
332
static NautilusDesktopLink *
333
find_unique_link_for_drive (NautilusDesktopLinkMonitor *monitor,
334
			    GnomeVFSDrive *drive)
335
{
336
	GList *l;
337
	NautilusDesktopLink *first_volume_link_for_drive;
338
339
	first_volume_link_for_drive = NULL;
217
340
341
	for (l = monitor->details->volume_links; l; l = l->next) {
342
		NautilusDesktopLink *link;
343
344
		link = NAUTILUS_DESKTOP_LINK (l->data);
345
346
		if (link_corresponds_to_drive (link, drive)) {
347
			if (first_volume_link_for_drive == NULL) {
348
				first_volume_link_for_drive = link;
349
			} else {
350
				return NULL; /* We know that we have more than
351
					      * one link for volumes that belong
352
					      * to the same drive, so there is
353
					      * no unique link for the drive.
354
					      */
355
			}
356
		}
357
	}
358
359
	return first_volume_link_for_drive;
360
}
361
362
static void
363
drive_connected_callback (GnomeVFSVolumeMonitor *volume_monitor,
364
			  GnomeVFSDrive *drive,
365
			  NautilusDesktopLinkMonitor *monitor)
366
{
367
	NautilusDesktopLink *link;
368
369
	/* fprintf (stderr, "drive connected!\n"); */
370
371
	link = find_unique_link_for_drive (monitor, drive);
372
373
	if (link)
374
		return; /* huh, we already have a link for that drive... */
375
376
	create_drive_link (monitor, drive);
377
}
378
379
static void
380
drive_disconnected_callback (GnomeVFSVolumeMonitor *volume_monitor,
381
			     GnomeVFSDrive *drive,
382
			     NautilusDesktopLinkMonitor *monitor)
383
{
384
	GList *l;
385
386
	/* fprintf (stderr, "drive disconnected!\n"); */
387
388
	/* Remove all the links that correspond to that drive, even if they have
389
	 * mounted volumes.
390
	 */
391
392
	l = monitor->details->volume_links;
393
394
	while (l) {
395
		GList *next;
396
		NautilusDesktopLink *link;
397
398
		next = l->next;
399
		link = NAUTILUS_DESKTOP_LINK (l->data);
400
401
		if (link_corresponds_to_drive (link, drive)) {
402
			g_object_unref (link);
403
			monitor->details->volume_links = g_list_remove_link (monitor->details->volume_links, l);
404
			g_list_free_1 (l);
405
		}
406
407
		l = next;
408
	}
409
}
218
410
219
static void
411
static void
220
volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
412
volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
221
			 GnomeVFSVolume *volume, 
413
			 GnomeVFSVolume *volume, 
222
			 NautilusDesktopLinkMonitor *monitor)
414
			 NautilusDesktopLinkMonitor *monitor)
223
{
415
{
224
	create_volume_link (monitor, volume);
416
	GnomeVFSDrive *drive;
417
418
	/* fprintf (stderr, "volume mounted!\n"); */
419
420
	drive = gnome_vfs_volume_get_drive (volume);
421
422
	if (drive) {
423
		NautilusDesktopLink *link;
424
425
		/* We may have an existing link for the drive, which needs to be
426
		 * updated for the volume.  Or we may have several volumes
427
		 * within the same drive; in this case, we need to create a
428
		 * completely new link.
429
		 */
430
431
		link = find_unique_link_for_drive (monitor, drive);
432
		gnome_vfs_drive_unref (drive);
433
434
		if (link) {
435
			/* fprintf (stderr, "updating desktop link from mounted volume\n"); */
436
			nautilus_desktop_link_update_from_volume (link, volume);
437
		} else {
438
			/* fprintf (stderr, "creating desktop link\n"); */
439
			create_volume_link (monitor, volume);
440
		}
441
	} else {
442
		/* fprintf (stderr, "creating desktop link\n"); */
443
		create_volume_link (monitor, volume);
444
	}
445
}
446
447
static NautilusDesktopLink *
448
find_link_for_volume (NautilusDesktopLinkMonitor *monitor,
449
		      GnomeVFSVolume             *volume)
450
{
451
	GList *l;
452
453
	for (l = monitor->details->volume_links; l != NULL; l = l->next) {
454
		NautilusDesktopLink *link;
455
		GObject *drive_or_volume;
456
		gboolean same;
457
458
		link = NAUTILUS_DESKTOP_LINK (l->data);
459
		drive_or_volume = nautilus_desktop_link_get_drive_or_volume (link);
460
461
		same = FALSE;
462
463
		if (GNOME_IS_VFS_VOLUME (drive_or_volume)) {
464
			same = (GNOME_VFS_VOLUME (drive_or_volume) == volume);
465
			gnome_vfs_volume_unref (GNOME_VFS_VOLUME (drive_or_volume));
466
		} else {
467
			gnome_vfs_drive_unref (GNOME_VFS_DRIVE (drive_or_volume));
468
		}
469
470
		if (same)
471
			return link;
472
	}
473
474
	return NULL;
225
}
475
}
226
476
227
477
Lines 230-251 volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor, Link Here
230
			   GnomeVFSVolume *volume, 
480
			   GnomeVFSVolume *volume, 
231
			   NautilusDesktopLinkMonitor *monitor)
481
			   NautilusDesktopLinkMonitor *monitor)
232
{
482
{
233
	GList *l;
234
	NautilusDesktopLink *link;
483
	NautilusDesktopLink *link;
235
	GnomeVFSVolume *other_volume;
484
	GnomeVFSDrive *drive;
485
	gboolean remove_link;
236
486
237
	link = NULL;
487
	/* fprintf (stderr, "volume unmounted!\n"); */
238
	for (l = monitor->details->volume_links; l != NULL; l = l->next) {
488
239
		other_volume = nautilus_desktop_link_get_volume (l->data);
489
	link = find_link_for_volume (monitor, volume);
240
		if (volume == other_volume) {
490
	if (!link) {
241
			gnome_vfs_volume_unref (other_volume);
491
		return;
242
			link = l->data;
492
	}
243
			break;
493
494
	remove_link = FALSE;
495
496
	drive = gnome_vfs_volume_get_drive (volume);
497
	if (drive) {
498
		if (should_show_drive (drive, volume)) {
499
			nautilus_desktop_link_update_from_volume (link, volume);
500
		} else {
501
			remove_link = TRUE;
244
		}
502
		}
245
		gnome_vfs_volume_unref (other_volume);
503
	} else {
504
		remove_link = TRUE;
246
	}
505
	}
247
506
248
	if (link) {
507
	if (remove_link) {
249
		monitor->details->volume_links = g_list_remove (monitor->details->volume_links, link);
508
		monitor->details->volume_links = g_list_remove (monitor->details->volume_links, link);
250
		g_object_unref (link);
509
		g_object_unref (link);
251
	}
510
	}
Lines 322-353 desktop_network_visible_changed (gpointer callback_data) Link Here
322
}
581
}
323
582
324
static void
583
static void
325
desktop_volumes_visible_changed (gpointer callback_data)
584
refresh_volume_links (NautilusDesktopLinkMonitor *monitor)
326
{
585
{
327
	GnomeVFSVolumeMonitor *volume_monitor;
586
	GnomeVFSVolumeMonitor *volume_monitor;
328
	NautilusDesktopLinkMonitor *monitor;
329
	GList *l, *volumes;
330
	
587
	
331
	volume_monitor = gnome_vfs_get_volume_monitor ();
588
	volume_monitor = gnome_vfs_get_volume_monitor ();
332
	monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
589
590
	/* Free existing links */
591
592
	g_list_foreach (monitor->details->volume_links, (GFunc)g_object_unref, NULL);
593
	g_list_free (monitor->details->volume_links);
594
	monitor->details->volume_links = NULL;
595
596
	/* Scan the links again */
333
597
334
	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
598
	if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
335
		if (monitor->details->volume_links == NULL) {
599
		GList *l;
336
			volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
600
		GList *volumes, *drives;
337
			for (l = volumes; l != NULL; l = l->next) {
601
338
				create_volume_link (monitor, l->data);
602
		/* Unmounted drives */
339
				gnome_vfs_volume_unref (l->data);
603
340
			}
604
		drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor);
341
			g_list_free (volumes);
605
		for (l = drives; l != NULL; l = l->next) {
606
			GnomeVFSDrive *drive;
607
608
			drive = GNOME_VFS_DRIVE (l->data);
609
			create_drive_link (monitor, drive);
610
			gnome_vfs_drive_unref (drive);
342
		}
611
		}
343
	} else {
612
		g_list_free (drives);
344
		g_list_foreach (monitor->details->volume_links, (GFunc)g_object_unref, NULL);
613
345
		g_list_free (monitor->details->volume_links);
614
		/* Volumes */
346
		monitor->details->volume_links = NULL;
615
616
		volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
617
		for (l = volumes; l != NULL; l = l->next) {
618
			GnomeVFSVolume *volume;
619
620
			volume = GNOME_VFS_VOLUME (l->data);
621
			create_volume_link (monitor, volume);
622
			gnome_vfs_volume_unref (volume);
623
		}
624
		g_list_free (volumes);
347
	}
625
	}
348
}
626
}
349
627
350
static void
628
static void
629
desktop_volumes_visible_changed (gpointer callback_data)
630
{
631
	NautilusDesktopLinkMonitor *monitor;
632
633
	monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
634
	refresh_volume_links (monitor);
635
}
636
637
static void
351
create_link_and_add_preference (NautilusDesktopLink   **link_ref,
638
create_link_and_add_preference (NautilusDesktopLink   **link_ref,
352
				NautilusDesktopLinkType link_type,
639
				NautilusDesktopLinkType link_type,
353
				const char             *preference_key,
640
				const char             *preference_key,
Lines 365-372 static void Link Here
365
nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
652
nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
366
{
653
{
367
	NautilusDesktopLinkMonitor *monitor;
654
	NautilusDesktopLinkMonitor *monitor;
368
	GList *l, *volumes;
369
	GnomeVFSVolume *volume;
370
	GnomeVFSVolumeMonitor *volume_monitor;
655
	GnomeVFSVolumeMonitor *volume_monitor;
371
656
372
	monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
657
	monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
Lines 404-425 nautilus_desktop_link_monitor_init (gpointer object, gpointer klass) Link Here
404
					desktop_network_visible_changed,
689
					desktop_network_visible_changed,
405
					monitor);
690
					monitor);
406
691
407
	/* Volume links */
692
	/* Drives and volumes */
408
693
409
	volume_monitor = gnome_vfs_get_volume_monitor ();
694
	refresh_volume_links (monitor);
410
	
411
	volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
412
	for (l = volumes; l != NULL; l = l->next) {
413
		volume = l->data;
414
		create_volume_link (monitor, volume);
415
		gnome_vfs_volume_unref (volume);
416
	}
417
	g_list_free (volumes);
418
695
419
	eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE,
696
	eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE,
420
				      desktop_volumes_visible_changed,
697
				      desktop_volumes_visible_changed,
421
				      monitor);
698
				      monitor);
422
699
700
	volume_monitor = gnome_vfs_get_volume_monitor ();
701
702
	monitor->details->connected_id = g_signal_connect_object (volume_monitor, "drive_connected",
703
								  G_CALLBACK (drive_connected_callback),
704
								  monitor, 0);
705
	monitor->details->disconnected_id = g_signal_connect_object (volume_monitor, "drive_disconnected",
706
								     G_CALLBACK (drive_disconnected_callback),
707
								     monitor, 0);
423
	monitor->details->mount_id = g_signal_connect_object (volume_monitor, "volume_mounted",
708
	monitor->details->mount_id = g_signal_connect_object (volume_monitor, "volume_mounted",
424
							      G_CALLBACK (volume_mounted_callback), monitor, 0);
709
							      G_CALLBACK (volume_mounted_callback), monitor, 0);
425
	monitor->details->unmount_id = g_signal_connect_object (volume_monitor, "volume_unmounted",
710
	monitor->details->unmount_id = g_signal_connect_object (volume_monitor, "volume_unmounted",
(-)a/libnautilus-private/nautilus-desktop-link-monitor.h (+1 lines)
Lines 59-64 void nautilus_desktop_link_monitor_delete_link (NautilusDesktopLinkMonitor *moni Link Here
59
59
60
/* Used by nautilus-desktop-link.c */
60
/* Used by nautilus-desktop-link.c */
61
char * nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor *monitor,
61
char * nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor *monitor,
62
							   NautilusDesktopLink *skip_link,
62
							   const char *filename);
63
							   const char *filename);
63
64
64
#endif /* NAUTILUS_DESKTOP_LINK_MONITOR_H */
65
#endif /* NAUTILUS_DESKTOP_LINK_MONITOR_H */
(-)a/libnautilus-private/nautilus-desktop-link.c (-25 / +142 lines)
Lines 54-61 struct NautilusDesktopLinkDetails { Link Here
54
	/* Just for trash icons: */
54
	/* Just for trash icons: */
55
	gulong trash_state_handler;
55
	gulong trash_state_handler;
56
56
57
	/* Just for volume icons: */
57
	/* Just for drive/volume icons */
58
	GnomeVFSVolume *volume;
58
	GObject *drive_or_volume;
59
};
59
};
60
60
61
static void nautilus_desktop_link_init       (gpointer              object,
61
static void nautilus_desktop_link_init       (gpointer              object,
Lines 208-257 nautilus_desktop_link_new (NautilusDesktopLinkType type) Link Here
208
	return link;
208
	return link;
209
}
209
}
210
210
211
NautilusDesktopLink *
211
static void
212
nautilus_desktop_link_new_from_volume (GnomeVFSVolume *volume)
212
reread_drive_or_volume (NautilusDesktopLink *link)
213
{
213
{
214
	NautilusDesktopLink *link;
215
	GnomeVFSDrive *drive;
216
	char *name, *filename;
214
	char *name, *filename;
215
	char *display_name, *activation_uri, *icon;
217
216
218
	link = NAUTILUS_DESKTOP_LINK (g_object_new (NAUTILUS_TYPE_DESKTOP_LINK, NULL));
217
	g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME);
219
	
218
	g_assert (link->details->drive_or_volume != NULL);
220
	link->details->type = NAUTILUS_DESKTOP_LINK_VOLUME;
219
220
	g_free (link->details->filename);
221
	g_free (link->details->display_name);
222
	g_free (link->details->activation_uri);
223
	g_free (link->details->icon);
221
224
222
	link->details->volume = gnome_vfs_volume_ref (volume);
225
	if (GNOME_IS_VFS_VOLUME (link->details->drive_or_volume)) {
226
		GnomeVFSVolume *volume;
227
		GnomeVFSDrive *drive;
223
228
224
	/* We try to use the drive name to get somewhat stable filenames
229
		volume = GNOME_VFS_VOLUME (link->details->drive_or_volume);
225
	   for metadata */
230
226
	drive = gnome_vfs_volume_get_drive (volume);
231
		/* We try to use the drive name to get somewhat stable filenames
227
	if (drive != NULL) {
232
		   for metadata */
228
		name = gnome_vfs_drive_get_display_name (drive);
233
		drive = gnome_vfs_volume_get_drive (volume);
234
		if (drive != NULL) {
235
			name = gnome_vfs_drive_get_display_name (drive);
236
		} else {
237
			name = gnome_vfs_volume_get_display_name (volume);
238
		}
239
		gnome_vfs_drive_unref (drive);
240
241
		display_name = gnome_vfs_volume_get_display_name (volume);
242
		activation_uri = gnome_vfs_volume_get_activation_uri (volume);
243
		icon = gnome_vfs_volume_get_icon (volume);
229
	} else {
244
	} else {
230
		name = gnome_vfs_volume_get_display_name (volume);
245
		GnomeVFSDrive *drive;
246
247
		g_assert (GNOME_IS_VFS_DRIVE (link->details->drive_or_volume));
248
249
		drive = GNOME_VFS_DRIVE (link->details->drive_or_volume);
250
251
		name = gnome_vfs_drive_get_display_name (drive);
252
253
		display_name = gnome_vfs_drive_get_display_name (drive);
254
		activation_uri = NULL; /* We don't know the activation URI until the drive gets mounted */
255
		icon = gnome_vfs_drive_get_icon (drive);
231
	}
256
	}
232
	gnome_vfs_drive_unref (drive);
233
257
234
	filename = g_strconcat (name, ".volume", NULL);
258
	filename = g_strconcat (name, ".volume", NULL);
235
	link->details->filename =
259
	link->details->filename =
236
		nautilus_desktop_link_monitor_make_filename_unique (nautilus_desktop_link_monitor_get (),
260
		nautilus_desktop_link_monitor_make_filename_unique (nautilus_desktop_link_monitor_get (),
261
								    link,
237
								    filename);
262
								    filename);
238
	g_free (filename);
263
	g_free (filename);
239
	g_free (name);
264
	g_free (name);
265
266
	link->details->display_name = display_name;
267
	link->details->activation_uri = activation_uri;
268
	link->details->icon = icon;
269
}
270
271
NautilusDesktopLink *
272
nautilus_desktop_link_new_from_drive_or_volume (GObject *object)
273
{
274
	NautilusDesktopLink *link;
275
	gboolean is_volume;
276
277
	is_volume = GNOME_IS_VFS_VOLUME (object);
278
279
	g_return_val_if_fail (GNOME_IS_VFS_DRIVE (object) || is_volume, NULL);
280
281
	link = NAUTILUS_DESKTOP_LINK (g_object_new (NAUTILUS_TYPE_DESKTOP_LINK, NULL));
240
	
282
	
241
	link->details->display_name = gnome_vfs_volume_get_display_name (volume);
283
	link->details->type = NAUTILUS_DESKTOP_LINK_VOLUME;
242
	
284
243
	link->details->activation_uri = gnome_vfs_volume_get_activation_uri (volume);
285
	if (is_volume) {
244
	link->details->icon = gnome_vfs_volume_get_icon (volume);
286
		GnomeVFSVolume *volume;
287
288
		volume = gnome_vfs_volume_ref (GNOME_VFS_VOLUME (object));
289
		link->details->drive_or_volume = G_OBJECT (volume);
290
	} else {
291
		GnomeVFSDrive *drive;
245
292
293
		drive = gnome_vfs_drive_ref (GNOME_VFS_DRIVE (object));
294
		link->details->drive_or_volume = G_OBJECT (drive);
295
	}
296
297
	reread_drive_or_volume (link);
246
	create_icon_file (link);
298
	create_icon_file (link);
247
299
248
	return link;
300
	return link;
249
}
301
}
250
302
251
GnomeVFSVolume *
303
GObject *
252
nautilus_desktop_link_get_volume (NautilusDesktopLink *link)
304
nautilus_desktop_link_get_drive_or_volume (NautilusDesktopLink *link)
253
{
305
{
254
	return gnome_vfs_volume_ref (link->details->volume);
306
	if (GNOME_IS_VFS_VOLUME (link->details->drive_or_volume))
307
		return G_OBJECT (gnome_vfs_volume_ref (GNOME_VFS_VOLUME (link->details->drive_or_volume)));
308
	else
309
		return G_OBJECT (gnome_vfs_drive_ref (GNOME_VFS_DRIVE (link->details->drive_or_volume)));
255
}
310
}
256
311
257
312
Lines 416-422 desktop_link_finalize (GObject *object) Link Here
416
	}
471
	}
417
472
418
	if (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME) {
473
	if (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME) {
419
		gnome_vfs_volume_unref (link->details->volume);
474
		if (GNOME_IS_VFS_VOLUME (link->details->drive_or_volume)) {
475
			gnome_vfs_volume_unref (GNOME_VFS_VOLUME (link->details->drive_or_volume));
476
		} else {
477
			gnome_vfs_drive_unref (GNOME_VFS_DRIVE (link->details->drive_or_volume));
478
		}
420
	}
479
	}
421
480
422
	g_free (link->details->filename);
481
	g_free (link->details->filename);
Lines 438-440 nautilus_desktop_link_class_init (gpointer klass) Link Here
438
	object_class->finalize = desktop_link_finalize;
497
	object_class->finalize = desktop_link_finalize;
439
498
440
}
499
}
500
501
void
502
nautilus_desktop_link_update_from_volume (NautilusDesktopLink *link,
503
					  GnomeVFSVolume      *volume)
504
{
505
	g_return_if_fail (NAUTILUS_IS_DESKTOP_LINK (link));
506
	g_return_if_fail (GNOME_IS_VFS_VOLUME (volume));
507
508
	g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME);
509
	g_assert (link->details->drive_or_volume != NULL);
510
511
	if (GNOME_IS_VFS_DRIVE (link->details->drive_or_volume)) {
512
		GnomeVFSDrive *drive;
513
514
		drive = gnome_vfs_volume_get_drive (volume);
515
516
		g_assert (G_OBJECT (drive) == G_OBJECT (link->details->drive_or_volume));
517
		gnome_vfs_drive_unref (drive);
518
519
		/* The link is for a drive.  If the new volume is mounted,
520
		 * replace the link's object with the volume.  If the new volume
521
		 * is unmounted, just refresh the link (who knows why we didn't
522
		 * get the mount notification before).
523
		 */
524
525
		if (gnome_vfs_volume_is_mounted (volume)) {
526
			gnome_vfs_drive_unref (GNOME_VFS_DRIVE (link->details->drive_or_volume));
527
528
			gnome_vfs_volume_ref (volume);
529
			link->details->drive_or_volume = G_OBJECT (volume);
530
		}
531
532
		/* The link will get updated below */
533
	} else {
534
		g_assert (GNOME_IS_VFS_VOLUME (link->details->drive_or_volume));
535
		g_assert (GNOME_VFS_VOLUME (link->details->drive_or_volume) == volume);
536
537
		/* If the volume got unmounted, restore the link's object to the
538
		 * corresponding drive.  Otherwise, we shouldn't need to be
539
		 * called, but just update the link in that case.
540
		 */
541
542
		if (!gnome_vfs_volume_is_mounted (volume)) {
543
			GnomeVFSDrive *drive;
544
545
			drive = gnome_vfs_volume_get_drive (volume);
546
547
			gnome_vfs_volume_unref (GNOME_VFS_VOLUME (link->details->drive_or_volume));
548
549
			link->details->drive_or_volume = G_OBJECT (drive);
550
		}
551
552
		/* The link will get updated below */
553
	}
554
555
	reread_drive_or_volume (link);
556
	nautilus_desktop_link_changed (link);
557
}
(-)a/libnautilus-private/nautilus-desktop-link.h (-2 / +5 lines)
Lines 26-31 Link Here
26
#define NAUTILUS_DESKTOP_LINK_H
26
#define NAUTILUS_DESKTOP_LINK_H
27
27
28
#include <libnautilus-private/nautilus-file.h>
28
#include <libnautilus-private/nautilus-file.h>
29
#include <libgnomevfs/gnome-vfs-drive.h>
29
#include <libgnomevfs/gnome-vfs-volume.h>
30
#include <libgnomevfs/gnome-vfs-volume.h>
30
31
31
#define NAUTILUS_TYPE_DESKTOP_LINK \
32
#define NAUTILUS_TYPE_DESKTOP_LINK \
Lines 61-67 typedef enum { Link Here
61
GType   nautilus_desktop_link_get_type (void);
62
GType   nautilus_desktop_link_get_type (void);
62
63
63
NautilusDesktopLink *   nautilus_desktop_link_new                (NautilusDesktopLinkType  type);
64
NautilusDesktopLink *   nautilus_desktop_link_new                (NautilusDesktopLinkType  type);
64
NautilusDesktopLink *   nautilus_desktop_link_new_from_volume    (GnomeVFSVolume          *volume);
65
NautilusDesktopLink *   nautilus_desktop_link_new_from_drive_or_volume (GObject           *object);
65
NautilusDesktopLinkType nautilus_desktop_link_get_link_type      (NautilusDesktopLink     *link);
66
NautilusDesktopLinkType nautilus_desktop_link_get_link_type      (NautilusDesktopLink     *link);
66
char *                  nautilus_desktop_link_get_file_name      (NautilusDesktopLink     *link);
67
char *                  nautilus_desktop_link_get_file_name      (NautilusDesktopLink     *link);
67
char *                  nautilus_desktop_link_get_display_name   (NautilusDesktopLink     *link);
68
char *                  nautilus_desktop_link_get_display_name   (NautilusDesktopLink     *link);
Lines 70-79 char * nautilus_desktop_link_get_activation_uri (NautilusDeskto Link Here
70
gboolean                nautilus_desktop_link_get_date           (NautilusDesktopLink     *link,
71
gboolean                nautilus_desktop_link_get_date           (NautilusDesktopLink     *link,
71
								  NautilusDateType         date_type,
72
								  NautilusDateType         date_type,
72
								  time_t                  *date);
73
								  time_t                  *date);
73
GnomeVFSVolume *        nautilus_desktop_link_get_volume         (NautilusDesktopLink     *link);
74
GObject *               nautilus_desktop_link_get_drive_or_volume (NautilusDesktopLink     *link);
74
75
75
gboolean                nautilus_desktop_link_can_rename         (NautilusDesktopLink     *link);
76
gboolean                nautilus_desktop_link_can_rename         (NautilusDesktopLink     *link);
76
gboolean                nautilus_desktop_link_rename             (NautilusDesktopLink     *link,
77
gboolean                nautilus_desktop_link_rename             (NautilusDesktopLink     *link,
77
								  const char              *name);
78
								  const char              *name);
79
void                    nautilus_desktop_link_update_from_volume (NautilusDesktopLink     *link,
80
								  GnomeVFSVolume          *volume);
78
81
79
#endif /* NAUTILUS_DESKTOP_LINK_H */
82
#endif /* NAUTILUS_DESKTOP_LINK_H */
(-)a/src/file-manager/fm-directory-view.c (-34 / +123 lines)
Lines 301-311 typedef struct { Link Here
301
	NautilusWindowOpenMode mode;
301
	NautilusWindowOpenMode mode;
302
	NautilusWindowOpenFlags flags;
302
	NautilusWindowOpenFlags flags;
303
	gboolean mount_success;
303
	gboolean mount_success;
304
	unsigned int pending_mounts;
304
	GList *drives_being_mounted;
305
	gboolean cancelled;
305
	gboolean cancelled;
306
} ActivateParameters;
306
} ActivateParameters;
307
307
308
typedef struct {
308
typedef struct {
309
	ActivateParameters *parameters;
310
311
	GnomeVFSDrive *drive;
312
	NautilusFile *file;
313
	guint file_changed_id;
314
} DriveBeingMounted;
315
316
typedef struct {
309
	NautilusFile *file;
317
	NautilusFile *file;
310
	NautilusDirectory *directory;
318
	NautilusDirectory *directory;
311
} FileAndDirectory;
319
} FileAndDirectory;
Lines 8272-8278 cancel_activate (gpointer callback_data) Link Here
8272
8280
8273
	parameters->cancelled = TRUE;
8281
	parameters->cancelled = TRUE;
8274
	
8282
	
8275
	if (parameters->pending_mounts == 0) {
8283
	if (parameters->drives_being_mounted == NULL) {
8276
		nautilus_file_list_cancel_call_when_ready (parameters->files_handle);
8284
		nautilus_file_list_cancel_call_when_ready (parameters->files_handle);
8277
		nautilus_file_list_free (parameters->files);
8285
		nautilus_file_list_free (parameters->files);
8278
		g_free (parameters);
8286
		g_free (parameters);
Lines 8644-8659 activate_callback (GList *files, gpointer callback_data) Link Here
8644
}
8652
}
8645
8653
8646
static void
8654
static void
8655
try_to_finish_drive_activation (ActivateParameters *parameters)
8656
{
8657
	if (parameters->drives_being_mounted != NULL) {
8658
		/* wait for other mounts to finish... */
8659
		return;
8660
	}
8661
8662
	if (parameters->cancelled || !parameters->mount_success) {
8663
		stop_activate (parameters);
8664
8665
		nautilus_file_list_free (parameters->files);
8666
		g_free (parameters);
8667
		return;
8668
	}
8669
8670
	/* all drives were mounted successfully */
8671
	activate_activation_uris_ready_callback (parameters->files,
8672
						 parameters);
8673
}
8674
8675
static void
8676
remove_drive_being_mounted (DriveBeingMounted *drive_being_mounted)
8677
{
8678
	ActivateParameters *parameters;
8679
8680
	parameters = drive_being_mounted->parameters;
8681
8682
	if (drive_being_mounted->file_changed_id != 0) {
8683
		g_signal_handler_disconnect (drive_being_mounted->file, drive_being_mounted->file_changed_id);
8684
	}
8685
8686
	nautilus_file_unref (drive_being_mounted->file);
8687
	gnome_vfs_drive_unref (drive_being_mounted->drive);
8688
8689
	parameters->drives_being_mounted = g_list_remove (parameters->drives_being_mounted,
8690
							  drive_being_mounted);
8691
	g_free (drive_being_mounted);
8692
}
8693
8694
static void
8695
activation_file_changed_after_drive_mounted (NautilusFile *file,
8696
					     gpointer data)
8697
{
8698
	DriveBeingMounted *drive_being_mounted;
8699
	ActivateParameters *parameters;
8700
8701
	drive_being_mounted = data;
8702
	parameters = drive_being_mounted->parameters;
8703
8704
	if (!gnome_vfs_drive_is_mounted (drive_being_mounted->drive)) {
8705
		/* Huh?  The NautilusFile changed, but the drive is not mounted
8706
		 * yet.  So, wait some more until the file gets another change
8707
		 * and the drive gets mounted.
8708
		 */
8709
		return;
8710
	}
8711
8712
	remove_drive_being_mounted (drive_being_mounted);
8713
8714
	try_to_finish_drive_activation (parameters);
8715
}
8716
8717
static void
8647
activation_drive_mounted_callback (gboolean succeeded,
8718
activation_drive_mounted_callback (gboolean succeeded,
8648
				   char *error,
8719
				   char *error,
8649
				   char *detailed_error,
8720
				   char *detailed_error,
8650
				   gpointer callback_data)
8721
				   gpointer callback_data)
8651
{
8722
{
8723
	DriveBeingMounted *drive_being_mounted;
8652
	ActivateParameters *parameters;
8724
	ActivateParameters *parameters;
8653
8725
8654
	parameters = callback_data;
8726
	drive_being_mounted = callback_data;
8727
	parameters = drive_being_mounted->parameters;
8655
8728
8656
	parameters->mount_success &= succeeded;
8729
	parameters->mount_success = parameters->mount_success && succeeded;
8657
8730
8658
	if (!succeeded && !parameters->cancelled) {
8731
	if (!succeeded && !parameters->cancelled) {
8659
		if (*error == 0 &&
8732
		if (*error == 0 &&
Lines 8666-8694 activation_drive_mounted_callback (gboolean succeeded, Link Here
8666
		}
8739
		}
8667
	}
8740
	}
8668
8741
8669
	if (--parameters->pending_mounts > 0) {
8742
	if (gnome_vfs_drive_is_mounted (drive_being_mounted->drive)) {
8670
		/* wait for other mounts to finish... */
8743
		remove_drive_being_mounted (drive_being_mounted);
8671
		return;
8744
	} else {
8672
	}
8745
		/* Here, the drive is already mounted, but
8673
8746
		 * gnome-vfs-volume-monitor thinks that it is not.  This is
8674
	if (parameters->cancelled || !parameters->mount_success) {
8747
		 * because gnome-vfs-daemon has not yet notified it.  So we'll
8675
		stop_activate (parameters);
8748
		 * wait for the NautilusFile to change:  this will happen
8749
		 * when gnome-vfs-volume-monitor actually picks up and emits the
8750
		 * volume_mounted notification, and the NautilusDesktopLink
8751
		 * modifies the NautilusFile.
8752
		 */
8676
8753
8677
		nautilus_file_list_free (parameters->files);
8754
		drive_being_mounted->file_changed_id = g_signal_connect (
8678
		g_free (parameters);
8755
			drive_being_mounted->file, "changed",
8679
		return;
8756
			G_CALLBACK (activation_file_changed_after_drive_mounted),
8757
			drive_being_mounted);
8680
	}
8758
	}
8681
8759
8682
	/* all drives were mounted successfully */
8760
	try_to_finish_drive_activation (parameters);
8683
	activate_activation_uris_ready_callback (parameters->files,
8684
						 parameters);
8685
}
8686
8687
static void
8688
mount_foreach (gpointer drive,
8689
	       gpointer callback_data)
8690
{
8691
	gnome_vfs_drive_mount (drive, activation_drive_mounted_callback, callback_data);
8692
}
8761
}
8693
8762
8694
static void
8763
static void
Lines 8696-8702 activate_activation_uris_ready_callback (GList *files_ignore, Link Here
8696
					 gpointer callback_data)
8765
					 gpointer callback_data)
8697
{
8766
{
8698
	ActivateParameters *parameters;
8767
	ActivateParameters *parameters;
8699
	GList *not_yet_mounted;
8700
	GList *l, *next;
8768
	GList *l, *next;
8701
	NautilusFile *file;
8769
	NautilusFile *file;
8702
	NautilusFile *actual_file;
8770
	NautilusFile *actual_file;
Lines 8705-8711 activate_activation_uris_ready_callback (GList *files_ignore, Link Here
8705
	char *uri;
8773
	char *uri;
8706
	
8774
	
8707
	parameters = callback_data;
8775
	parameters = callback_data;
8708
	not_yet_mounted = NULL;
8709
8776
8710
	for (l = parameters->files; l != NULL; l = next) {
8777
	for (l = parameters->files; l != NULL; l = next) {
8711
		file = NAUTILUS_FILE (l->data);
8778
		file = NAUTILUS_FILE (l->data);
Lines 8728-8751 activate_activation_uris_ready_callback (GList *files_ignore, Link Here
8728
			drive = nautilus_file_get_drive (file);
8795
			drive = nautilus_file_get_drive (file);
8729
			if (drive != NULL &&
8796
			if (drive != NULL &&
8730
			    !gnome_vfs_drive_is_mounted (drive)) {
8797
			    !gnome_vfs_drive_is_mounted (drive)) {
8731
				not_yet_mounted = g_list_prepend (not_yet_mounted, drive);
8798
				DriveBeingMounted *drive_being_mounted;
8732
				parameters->pending_mounts++;
8799
8800
				drive_being_mounted = g_new (DriveBeingMounted, 1);
8801
				drive_being_mounted->parameters = parameters;
8802
				drive_being_mounted->drive = gnome_vfs_drive_ref (drive);
8803
				drive_being_mounted->file = nautilus_file_ref (file);
8804
				drive_being_mounted->file_changed_id = 0;
8805
8806
				parameters->drives_being_mounted = g_list_prepend (parameters->drives_being_mounted,
8807
										   drive_being_mounted);
8733
			}
8808
			}
8734
		}
8809
		}
8735
	}
8810
	}
8736
8811
8737
	if (parameters->files == NULL) {
8812
	if (parameters->files == NULL) {
8738
		g_assert (not_yet_mounted == NULL);
8813
		g_assert (parameters->drives_being_mounted == NULL);
8739
8814
8740
		stop_activate (parameters);
8815
		stop_activate (parameters);
8741
		g_free (parameters);
8816
		g_free (parameters);
8742
		return;
8817
		return;
8743
	}
8818
	}
8744
8819
8745
	if (not_yet_mounted != NULL) {
8820
	if (parameters->drives_being_mounted != NULL) {
8746
		not_yet_mounted = g_list_reverse (not_yet_mounted);
8821
		GList *l;
8747
		g_list_foreach (not_yet_mounted, mount_foreach, callback_data);
8822
8748
		g_list_free (not_yet_mounted);
8823
		parameters->drives_being_mounted = g_list_reverse (parameters->drives_being_mounted);
8824
8825
		for (l = parameters->drives_being_mounted; l; l = l->next) {
8826
			DriveBeingMounted *drive_being_mounted;
8827
8828
			drive_being_mounted = l->data;
8829
8830
			/* @#$% gnome_vfs_drive_mount() doesn't tell the
8831
			 * callback *which* drive was mounted.  So, we pass the
8832
			 * drive as part of the drive_being_mounted closure.
8833
			 */
8834
			gnome_vfs_drive_mount (drive_being_mounted->drive,
8835
					       activation_drive_mounted_callback,
8836
					       drive_being_mounted);
8837
		}
8749
8838
8750
		/* activation_drive_mounted_callback will reveal whether all mounts were successful */
8839
		/* activation_drive_mounted_callback will reveal whether all mounts were successful */
8751
		parameters->mount_success = TRUE;
8840
		parameters->mount_success = TRUE;
Lines 8869-8875 fm_directory_view_activate_files (FMDirectoryView *view, Link Here
8869
	parameters->mode = mode;
8958
	parameters->mode = mode;
8870
	parameters->flags = flags;
8959
	parameters->flags = flags;
8871
	parameters->mount_success = FALSE;
8960
	parameters->mount_success = FALSE;
8872
	parameters->pending_mounts = 0;
8961
	parameters->drives_being_mounted = NULL;
8873
	parameters->cancelled = FALSE;
8962
	parameters->cancelled = FALSE;
8874
8963
8875
	if (file_count == 1) {
8964
	if (file_count == 1) {

Return to bug 222490