94
set_metadata_get_info_callback (GObject *source_object,
96
gpointer callback_data)
102
file = callback_data;
105
new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
106
if (new_info != NULL) {
107
if (nautilus_file_update_info (file, new_info)) {
108
nautilus_file_changed (file);
110
g_object_unref (new_info);
112
nautilus_file_unref (file);
114
g_error_free (error);
119
set_metadata_callback (GObject *source_object,
120
GAsyncResult *result,
121
gpointer callback_data)
127
file = callback_data;
130
res = g_file_set_attributes_finish (G_FILE (source_object),
136
g_file_query_info_async (G_FILE (source_object),
137
NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
141
set_metadata_get_info_callback, file);
143
nautilus_file_unref (file);
144
g_error_free (error);
149
vfs_file_set_metadata (NautilusFile *file,
157
info = g_file_info_new ();
159
gio_key = g_strconcat ("metadata::", key, NULL);
161
g_file_info_set_attribute_string (info, gio_key, value);
164
g_file_info_set_attribute (info, gio_key,
165
G_FILE_ATTRIBUTE_TYPE_INVALID,
170
location = nautilus_file_get_location (file);
171
g_file_set_attributes_async (location,
176
set_metadata_callback,
177
nautilus_file_ref (file));
178
g_object_unref (location);
179
g_object_unref (info);
183
vfs_file_set_metadata_as_list (NautilusFile *file,
191
info = g_file_info_new ();
193
gio_key = g_strconcat ("metadata::", key, NULL);
194
g_file_info_set_attribute_stringv (info, gio_key, value);
197
location = nautilus_file_get_location (file);
198
g_file_set_attributes_async (location,
203
set_metadata_callback,
204
nautilus_file_ref (file));
205
g_object_unref (info);
206
g_object_unref (location);
93
210
vfs_file_get_item_count (NautilusFile *file,
317
vfs_file_unmount (NautilusFile *file)
434
vfs_file_unmount (NautilusFile *file,
435
GMountOperation *mount_op,
436
GCancellable *cancellable,
437
NautilusFileOperationCallback callback,
438
gpointer callback_data)
319
440
NautilusFileOperation *op;
322
op = nautilus_file_operation_new (file, NULL, NULL);
443
op = nautilus_file_operation_new (file, callback, callback_data);
445
g_object_unref (op->cancellable);
446
op->cancellable = g_object_ref (cancellable);
324
449
location = nautilus_file_get_location (file);
325
g_file_unmount_mountable (location,
326
G_MOUNT_UNMOUNT_NONE,
328
vfs_file_unmount_callback,
450
g_file_unmount_mountable_with_operation (location,
451
G_MOUNT_UNMOUNT_NONE,
454
vfs_file_unmount_callback,
330
456
g_object_unref (location);
363
vfs_file_eject (NautilusFile *file)
489
vfs_file_eject (NautilusFile *file,
490
GMountOperation *mount_op,
491
GCancellable *cancellable,
492
NautilusFileOperationCallback callback,
493
gpointer callback_data)
365
495
NautilusFileOperation *op;
368
op = nautilus_file_operation_new (file, NULL, NULL);
370
location = nautilus_file_get_location (file);
371
g_file_eject_mountable (location,
372
G_MOUNT_UNMOUNT_NONE,
498
op = nautilus_file_operation_new (file, callback, callback_data);
500
g_object_unref (op->cancellable);
501
op->cancellable = g_object_ref (cancellable);
504
location = nautilus_file_get_location (file);
505
g_file_eject_mountable_with_operation (location,
506
G_MOUNT_UNMOUNT_NONE,
509
vfs_file_eject_callback,
511
g_object_unref (location);
515
vfs_file_start_callback (GObject *source_object,
517
gpointer callback_data)
519
NautilusFileOperation *op;
526
started = g_file_start_mountable_finish (G_FILE (source_object),
530
error->domain == G_IO_ERROR &&
531
(error->code == G_IO_ERROR_FAILED_HANDLED ||
532
error->code == G_IO_ERROR_CANCELLED)) {
533
g_error_free (error);
537
nautilus_file_operation_complete (op, G_FILE (source_object), error);
539
g_error_free (error);
545
vfs_file_start (NautilusFile *file,
546
GMountOperation *mount_op,
547
GCancellable *cancellable,
548
NautilusFileOperationCallback callback,
549
gpointer callback_data)
551
NautilusFileOperation *op;
555
if (file->details->type != G_FILE_TYPE_MOUNTABLE) {
558
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
559
_("This file cannot be started"));
560
callback (file, NULL, error, callback_data);
561
g_error_free (error);
566
op = nautilus_file_operation_new (file, callback, callback_data);
568
g_object_unref (op->cancellable);
569
op->cancellable = g_object_ref (cancellable);
572
location = nautilus_file_get_location (file);
573
g_file_start_mountable (location,
374
vfs_file_eject_callback,
577
vfs_file_start_callback,
376
579
g_object_unref (location);
583
vfs_file_stop_callback (GObject *source_object,
585
gpointer callback_data)
587
NautilusFileOperation *op;
594
stopped = g_file_stop_mountable_finish (G_FILE (source_object),
598
error->domain == G_IO_ERROR &&
599
(error->code == G_IO_ERROR_FAILED_HANDLED ||
600
error->code == G_IO_ERROR_CANCELLED)) {
601
g_error_free (error);
605
nautilus_file_operation_complete (op, G_FILE (source_object), error);
607
g_error_free (error);
612
vfs_file_stop (NautilusFile *file,
613
GMountOperation *mount_op,
614
GCancellable *cancellable,
615
NautilusFileOperationCallback callback,
616
gpointer callback_data)
618
NautilusFileOperation *op;
621
op = nautilus_file_operation_new (file, callback, callback_data);
623
g_object_unref (op->cancellable);
624
op->cancellable = g_object_ref (cancellable);
627
location = nautilus_file_get_location (file);
628
g_file_stop_mountable (location,
629
G_MOUNT_UNMOUNT_NONE,
632
vfs_file_stop_callback,
634
g_object_unref (location);
638
vfs_file_poll_callback (GObject *source_object,
640
gpointer callback_data)
642
NautilusFileOperation *op;
649
stopped = g_file_poll_mountable_finish (G_FILE (source_object),
653
error->domain == G_IO_ERROR &&
654
(error->code == G_IO_ERROR_FAILED_HANDLED ||
655
error->code == G_IO_ERROR_CANCELLED)) {
656
g_error_free (error);
660
nautilus_file_operation_complete (op, G_FILE (source_object), error);
662
g_error_free (error);
667
vfs_file_poll_for_media (NautilusFile *file)
669
NautilusFileOperation *op;
672
op = nautilus_file_operation_new (file, NULL, NULL);
674
location = nautilus_file_get_location (file);
675
g_file_poll_mountable (location,
677
vfs_file_poll_callback,
679
g_object_unref (location);
380
683
nautilus_vfs_file_init (gpointer object, gpointer klass)
382
685
NautilusVFSFile *file;