|
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", |