summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2118
-rw-r--r--NEWS2
-rw-r--r--TODO-gio16
-rw-r--r--configure.in12
-rw-r--r--docs/key_mouse_navigation.txt2
-rw-r--r--libnautilus-extension/nautilus-file-info.c47
-rw-r--r--libnautilus-extension/nautilus-file-info.h20
-rw-r--r--libnautilus-private/Makefile.am21
-rw-r--r--libnautilus-private/nautilus-audio-player.c549
-rw-r--r--libnautilus-private/nautilus-audio-player.h55
-rw-r--r--libnautilus-private/nautilus-bookmark.c163
-rw-r--r--libnautilus-private/nautilus-bookmark.h13
-rw-r--r--libnautilus-private/nautilus-column-chooser.c73
-rw-r--r--libnautilus-private/nautilus-column-chooser.h11
-rw-r--r--libnautilus-private/nautilus-column-utilities.c23
-rw-r--r--libnautilus-private/nautilus-column-utilities.h2
-rw-r--r--libnautilus-private/nautilus-customization-data.c150
-rw-r--r--libnautilus-private/nautilus-customization-data.h3
-rw-r--r--libnautilus-private/nautilus-desktop-directory-file.c17
-rw-r--r--libnautilus-private/nautilus-desktop-directory.c5
-rw-r--r--libnautilus-private/nautilus-desktop-icon-file.c135
-rw-r--r--libnautilus-private/nautilus-desktop-link-monitor.c74
-rw-r--r--libnautilus-private/nautilus-desktop-link.c193
-rw-r--r--libnautilus-private/nautilus-desktop-link.h30
-rw-r--r--libnautilus-private/nautilus-directory-async.c2317
-rw-r--r--libnautilus-private/nautilus-directory-background.c9
-rw-r--r--libnautilus-private/nautilus-directory-metafile-monitor.c2
-rw-r--r--libnautilus-private/nautilus-directory-notify.h32
-rw-r--r--libnautilus-private/nautilus-directory-private.h60
-rw-r--r--libnautilus-private/nautilus-directory.c881
-rw-r--r--libnautilus-private/nautilus-directory.h12
-rw-r--r--libnautilus-private/nautilus-dnd.c147
-rw-r--r--libnautilus-private/nautilus-emblem-utils.c115
-rw-r--r--libnautilus-private/nautilus-emblem-utils.h5
-rw-r--r--libnautilus-private/nautilus-file-attributes.h26
-rw-r--r--libnautilus-private/nautilus-file-changes-queue.c107
-rw-r--r--libnautilus-private/nautilus-file-changes-queue.h34
-rw-r--r--libnautilus-private/nautilus-file-dnd.c8
-rw-r--r--libnautilus-private/nautilus-file-operations-progress.c18
-rw-r--r--libnautilus-private/nautilus-file-operations-progress.h11
-rw-r--r--libnautilus-private/nautilus-file-operations.c3273
-rw-r--r--libnautilus-private/nautilus-file-operations.h52
-rw-r--r--libnautilus-private/nautilus-file-private.h134
-rw-r--r--libnautilus-private/nautilus-file-utilities.c450
-rw-r--r--libnautilus-private/nautilus-file-utilities.h22
-rw-r--r--libnautilus-private/nautilus-file.c2884
-rw-r--r--libnautilus-private/nautilus-file.h114
-rw-r--r--libnautilus-private/nautilus-global-preferences.c120
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.c154
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.h17
-rw-r--r--libnautilus-private/nautilus-icon-container.c277
-rw-r--r--libnautilus-private/nautilus-icon-container.h8
-rw-r--r--libnautilus-private/nautilus-icon-dnd.c145
-rw-r--r--libnautilus-private/nautilus-icon-dnd.h3
-rw-r--r--libnautilus-private/nautilus-icon-factory-private.h34
-rw-r--r--libnautilus-private/nautilus-icon-factory.c1886
-rw-r--r--libnautilus-private/nautilus-icon-factory.h185
-rw-r--r--libnautilus-private/nautilus-icon-info.c666
-rw-r--r--libnautilus-private/nautilus-icon-info.h90
-rw-r--r--libnautilus-private/nautilus-icon-private.h3
-rw-r--r--libnautilus-private/nautilus-lib-self-check-functions.h1
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.c409
-rw-r--r--libnautilus-private/nautilus-link-desktop-file.h55
-rw-r--r--libnautilus-private/nautilus-link.c472
-rw-r--r--libnautilus-private/nautilus-link.h67
-rw-r--r--libnautilus-private/nautilus-merged-directory.c2
-rw-r--r--libnautilus-private/nautilus-metafile.c207
-rw-r--r--libnautilus-private/nautilus-mime-actions.c1436
-rw-r--r--libnautilus-private/nautilus-mime-actions.h42
-rw-r--r--libnautilus-private/nautilus-mime-application-chooser.c676
-rw-r--r--libnautilus-private/nautilus-mime-application-chooser.h53
-rw-r--r--libnautilus-private/nautilus-monitor.c151
-rw-r--r--libnautilus-private/nautilus-monitor.h4
-rw-r--r--libnautilus-private/nautilus-open-with-dialog.c982
-rw-r--r--libnautilus-private/nautilus-open-with-dialog.h61
-rw-r--r--libnautilus-private/nautilus-program-choosing.c648
-rw-r--r--libnautilus-private/nautilus-program-choosing.h8
-rw-r--r--libnautilus-private/nautilus-progress-info.c752
-rw-r--r--libnautilus-private/nautilus-progress-info.h80
-rw-r--r--libnautilus-private/nautilus-query.h1
-rw-r--r--libnautilus-private/nautilus-recent.c20
-rw-r--r--libnautilus-private/nautilus-recent.h4
-rw-r--r--libnautilus-private/nautilus-saved-search-file.c27
-rw-r--r--libnautilus-private/nautilus-search-directory-file.c111
-rw-r--r--libnautilus-private/nautilus-search-directory-file.h1
-rw-r--r--libnautilus-private/nautilus-search-directory.c34
-rw-r--r--libnautilus-private/nautilus-search-engine-simple.c201
-rw-r--r--libnautilus-private/nautilus-search-engine-tracker.c5
-rw-r--r--libnautilus-private/nautilus-search-engine.h1
-rw-r--r--libnautilus-private/nautilus-signaller.c9
-rw-r--r--libnautilus-private/nautilus-theme.c288
-rw-r--r--libnautilus-private/nautilus-theme.h62
-rw-r--r--libnautilus-private/nautilus-thumbnails.c204
-rw-r--r--libnautilus-private/nautilus-thumbnails.h8
-rw-r--r--libnautilus-private/nautilus-trash-directory.c362
-rw-r--r--libnautilus-private/nautilus-trash-directory.h56
-rw-r--r--libnautilus-private/nautilus-trash-file.c784
-rw-r--r--libnautilus-private/nautilus-trash-file.h55
-rw-r--r--libnautilus-private/nautilus-trash-monitor.c275
-rw-r--r--libnautilus-private/nautilus-trash-monitor.h13
-rw-r--r--libnautilus-private/nautilus-tree-view-drag-dest.c5
-rw-r--r--libnautilus-private/nautilus-ui-utilities.c49
-rw-r--r--libnautilus-private/nautilus-vfs-file.c104
-rw-r--r--libnautilus-private/nautilus-view-factory.c14
-rw-r--r--libnautilus-private/nautilus-view-factory.h10
-rw-r--r--libnautilus-private/nautilus-view.h2
-rw-r--r--libnautilus-private/nautilus-window-info.c2
-rw-r--r--libnautilus-private/nautilus-window-info.h4
-rw-r--r--src/Makefile.am21
-rw-r--r--src/file-manager/Makefile.am1
-rw-r--r--src/file-manager/fm-desktop-icon-view.c5
-rw-r--r--src/file-manager/fm-directory-view.c2534
-rw-r--r--src/file-manager/fm-directory-view.h20
-rw-r--r--src/file-manager/fm-ditem-page.c118
-rw-r--r--src/file-manager/fm-empty-view.c6
-rw-r--r--src/file-manager/fm-error-reporting.c211
-rw-r--r--src/file-manager/fm-error-reporting.h11
-rw-r--r--src/file-manager/fm-icon-container.c82
-rw-r--r--src/file-manager/fm-icon-view.c334
-rw-r--r--src/file-manager/fm-list-model.c55
-rw-r--r--src/file-manager/fm-list-model.h1
-rw-r--r--src/file-manager/fm-list-view.c182
-rw-r--r--src/file-manager/fm-properties-window.c424
-rw-r--r--src/file-manager/fm-tree-model.c155
-rw-r--r--src/file-manager/fm-tree-model.h30
-rw-r--r--src/file-manager/fm-tree-view.c287
-rw-r--r--src/file-manager/nautilus-audio-mime-types.h41
-rw-r--r--src/nautilus-application.c324
-rw-r--r--src/nautilus-application.h6
-rw-r--r--src/nautilus-bookmark-list.c419
-rw-r--r--src/nautilus-bookmark-list.h4
-rw-r--r--src/nautilus-bookmarks-window.c36
-rw-r--r--src/nautilus-connect-server-dialog-nonmain.c7
-rw-r--r--src/nautilus-desktop-window.c18
-rw-r--r--src/nautilus-emblem-sidebar.c81
-rw-r--r--src/nautilus-file-management-properties.c124
-rw-r--r--src/nautilus-history-sidebar.c8
-rw-r--r--src/nautilus-image-properties-page.c312
-rw-r--r--src/nautilus-information-panel.c63
-rw-r--r--src/nautilus-location-bar.c68
-rw-r--r--src/nautilus-location-dialog.c18
-rw-r--r--src/nautilus-location-entry.c257
-rw-r--r--src/nautilus-main.c14
-rw-r--r--src/nautilus-navigation-window-menus.c24
-rw-r--r--src/nautilus-navigation-window.c63
-rw-r--r--src/nautilus-notes-viewer.c2
-rw-r--r--src/nautilus-pathbar.c293
-rw-r--r--src/nautilus-pathbar.h11
-rw-r--r--src/nautilus-places-sidebar.c296
-rw-r--r--src/nautilus-property-browser.c151
-rw-r--r--src/nautilus-query-editor.c37
-rw-r--r--src/nautilus-shell-ui.xml2
-rw-r--r--src/nautilus-shell.c122
-rw-r--r--src/nautilus-sidebar-title.c56
-rw-r--r--src/nautilus-spatial-window.c247
-rw-r--r--src/nautilus-spatial-window.h4
-rw-r--r--src/nautilus-window-bookmarks.c15
-rw-r--r--src/nautilus-window-manage-views.c559
-rw-r--r--src/nautilus-window-manage-views.h6
-rw-r--r--src/nautilus-window-menus.c86
-rw-r--r--src/nautilus-window-private.h15
-rw-r--r--src/nautilus-window.c122
-rw-r--r--src/nautilus-window.h9
-rw-r--r--src/nautilus-zoom-control.h2
-rw-r--r--test/Makefile.am3
-rw-r--r--test/test-copy.c93
-rw-r--r--test/test-nautilus-directory-async.c4
-rw-r--r--test/test-nautilus-mime-actions-set.c4
-rw-r--r--test/test-nautilus-mime-actions.c18
-rw-r--r--test/test-nautilus-preferences-change.c121
-rw-r--r--test/test-nautilus-wrap-table.c2
-rw-r--r--test/test.c52
-rw-r--r--test/test.h1
173 files changed, 19649 insertions, 15900 deletions
diff --git a/ChangeLog b/ChangeLog
index 336a326ca..0f2a9e55f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,2054 @@
+2007-11-30 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Reimplement copy_move helper with _copy and _move
+ Also support move to trash as trash
+
+ * src/file-manager/fm-directory-view.c:
+ Use _copy_move again
+
+2007-11-30 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-changes-queue.[ch]:
+ Convert changes queue to only use GFile, not uris.
+ Kill all _by_uri versions
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-link.c:
+ * libnautilus-private/nautilus-monitor.c:
+ * src/file-manager/fm-directory-view.c:
+ Update for above changes
+
+2007-11-30 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-changes-queue.[ch]:
+ More uri -> gfile API changes
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Add move operation
+
+ * src/file-manager/fm-directory-view.c:
+ Use move operation
+
+2007-11-29 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-changes-queue.[ch]:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ Change position setting api to accept GFile instead of
+ uri
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Set positions and copy metadata.
+
+2007-11-29 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-changes-queue.[ch]:
+ Add some GFile version and rename the old to _by_uri
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Emit change events
+
+ * libnautilus-private/nautilus-file-operations-progress.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ * libnautilus-private/nautilus-metafile.c:
+ * libnautilus-private/nautilus-monitor.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-icon-view.c:
+ Update to latest APIs
+
+2007-11-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Better status message when copying one folder
+
+ * libnautilus-private/nautilus-progress-info.c:
+ Correct tooltip message for status icon
+
+2007-11-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Nicer progress texts
+
+ * libnautilus-private/nautilus-progress-info.c:
+ Hide progress window when last op finishes.
+
+2007-11-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ Don't free uninitialized memory.
+
+ * libnautilus-private/nautilus-file-operations.c:
+ * libnautilus-private/nautilus-progress-info.[ch]:
+ Add progress info dialog
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Handle debuting URIs in file copy op
+
+ * src/file-manager/fm-directory-view.c:
+ Use new nautilus_file_operations_copy for copy.
+ Make debuting_uri hash into debuting_files in new
+ API. Convert for old calls.
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add run_warning and run_error to simplify the
+ code for error dialogs.
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add defines for common button names to make sure
+ they are consistent
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Use the right create_dest arg to copy_directory
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Free primary / secondary in run_simple_dialog
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add IS_IO_ERROR macro and use that
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-progress-info.[ch]:
+ Remove printf versions
+ rename _set_foo_nocopy to _take_foo
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Use new custom printf formating for all strings
+
+2007-11-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Use eel_strdup_printf_with_custom to make it easier
+ to create error dialogs.
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Handle deleting a directory when overwriting it with a
+ file.
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Handle errors in remove destination
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Pass cancellable into strdup_with_name
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add progress updates to copy.
+ Make some error dialogs more consistent (add skip all, reorder)
+
+ * libnautilus-private/nautilus-progress-info.[ch]:
+ Add nautilus_progress_info_set_status_printf
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Don't create dest dir on merges
+
+2007-11-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Handle recursive copies
+
+2007-11-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Pass in same_fs instead of dest_fs_id so we can
+ reuse copy_file recursively and only check once.
+
+2007-11-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ More work on file copies
+
+2007-11-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add error handling for source scanning
+
+2007-11-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-progress-info.[ch]:
+ Add nautilus_get_all_progress_info()
+
+ * test/test-copy.c:
+ Print progress info
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Implement generic run_simple_dialog()
+
+2007-11-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.c:
+ Add generic run_simple_dialog.
+
+2007-11-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-progress-info.c:
+ Fix signal emissions
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Add nautilus_file_operations_copy, with some initial
+ (far from done) code
+
+ * test/Makefile.am:
+ * test/test-copy.c:
+ nautilus_file_operations_copy testcase
+
+2007-11-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-progress-info.c:
+ Reindent
+ Fix threading issues wrt the idle source
+
+2007-11-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-progress-info.[ch]:
+ Added NautilusProgressInfo class
+
+ * libnautilus-private/nautilus-file-operations.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-places-sidebar.c:
+ Update to new gio API
+
+2007-11-13 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-error-reporting.c:
+ Remove last use of GNOME_VFS_ERROR
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-vfs-utils.[ch]: Removed.
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-window-manage-views.c:
+ Remove GNOME_VFS_ERROR
+
+2007-11-13 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-window-manage-views.c:
+ * src/nautilus-window-private.h:
+ Better error reporting on view failure
+
+2007-11-13 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-window-manage-views.c:
+ * src/nautilus-window-private.h:
+ Try to mount location if not mounted.
+
+2007-11-13 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Handle std:target_uri gio links
+
+2007-11-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Fix reversed checks
+
+2007-11-08 Sebastian Dröge <slomo@circular-chaos.org>
+
+ * configure.in:
+ * src/nautilus-image-properties-page.c:
+ Add support for exempi >= 1.99.5 while keeping support for older
+ versions.
+
+2007-11-06 Sebastian Dröge <slomo@circular-chaos.org>
+
+ * NEWS:
+ * docs/key_mouse_navigation.txt:
+ * libnautilus-private/nautilus-emblem-utils.c:
+ * libnautilus-private/nautilus-emblem-utils.h:
+ * src/file-manager/fm-properties-window.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-property-browser.c:
+ Fix typo: availible -> available.
+
+2007-11-06 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ Update to the new GAppInfo and EelAppLaunchContext APIs
+ Remove old startup notify code
+
+2007-11-05 Jürg Billeter <j@bitron.ch>
+
+ reviewed by: Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-actions.h:
+ * src/file-manager/fm-directory-view.c:
+ (action_open_folder_window_callback), (open_one_in_folder_window),
+ (action_location_open_folder_window_callback),
+ (real_update_location_menu), (real_update_menus):
+ * src/file-manager/nautilus-directory-view-ui.xml:
+ * src/nautilus-actions.h:
+ * src/nautilus-navigation-window-menus.c:
+ (nautilus_navigation_window_update_spatial_menu_item),
+ (action_folder_window_callback),
+ (nautilus_navigation_window_initialize_menus):
+ * src/nautilus-navigation-window-ui.xml:
+ * src/nautilus-navigation-window.c:
+ (nautilus_navigation_window_init), (always_use_browser_changed):
+ * src/nautilus-window-private.h:
+ Add menu item to open spatial folder window from browser window to File
+ menu and context menus.
+
+2007-11-02 Paolo Borelli <pborelli@katamail.com>
+
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-file-management-properties.c:
+ * src/nautilus-navigation-window.c:
+ * libnautilus-private/nautilus-icon-info.c:
+ * libnautilus-private/nautilus-mime-application-chooser.c:
+ Plug some minor memory leaks.
+
+2007-11-02 Paolo Borelli <pborelli@katamail.com>
+
+ * src/file-manager/fm-icon-container.c:
+ * src/file-manager/fm-list-view.c:
+ * src/nautilus-shell.c:
+ * src/nautilus-file-management-properties.c:
+ * libnautilus-private/nautilus-column-utilities.c:
+ * libnautilus-private/nautilus-column-utilities.h:
+ * libnautilus-private/nautilus-column-chooser.c:
+ * libnautilus-private/nautilus-column-chooser.h:
+ Remove all uses of eel-string-list and update code to the new
+ eel_preferences_[set|get]_string_array api.
+
+ * libnautilus-private/nautilus-global-preferences.c:
+ Update to the eel-enumerations api changes.
+
+2007-11-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-customization-data.[ch]:
+ * libnautilus-private/nautilus-desktop-directory.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.[ch]:
+ * libnautilus-private/nautilus-file-operations-progress.[ch]:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file-utilities.c:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-global-preferences.c:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ * libnautilus-private/nautilus-metafile.c:
+ * libnautilus-private/nautilus-monitor.c:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * libnautilus-private/nautilus-query.h:
+ * libnautilus-private/nautilus-search-directory.c:
+ * libnautilus-private/nautilus-search-engine-tracker.c:
+ * libnautilus-private/nautilus-search-engine.h:
+ * libnautilus-private/nautilus-thumbnails.c:
+ * libnautilus-private/nautilus-tree-view-drag-dest.c:
+ * libnautilus-private/nautilus-vfs-utils.h:
+ * src/file-manager/fm-desktop-icon-view.c:
+ * src/file-manager/fm-ditem-page.c:
+ * src/file-manager/fm-icon-container.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-desktop-window.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-location-bar.c:
+ * src/nautilus-location-dialog.c:
+ * src/nautilus-location-entry.c:
+ * src/nautilus-main.c:
+ * src/nautilus-navigation-window-menus.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-query-editor.c:
+ * src/nautilus-shell.c:
+ * src/nautilus-sidebar-title.c:
+ * src/nautilus-window-manage-views.c:
+ * src/nautilus-window.c:
+ * test/test-nautilus-mime-actions-set.c:
+ * test/test-nautilus-mime-actions.c:
+ * test/test.h:
+ Remove lots of gnome vfs includes
+
+ * src/Makefile.am:
+ Disable building of connect to server app
+
+2007-11-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_is_launchable
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ Add launched apps to recent files
+
+ * libnautilus-private/nautilus-mime-actions.[ch]:
+ * src/file-manager/fm-directory-view.[ch]:
+ Move all the file activaton code from FMDirectoryView
+ to a common place in nautilus-mime-actions
+
+2007-11-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Stub out all gnome-vfs using operations with a
+ dialog saying this isn't supported yet.
+
+ * src/Makefile.am:
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-shell-ui.xml:
+ * src/nautilus-window-menus.c:
+ Remove all connect to server use for now
+ Not sure what to do with it in the gvfs world
+
+ * src/file-manager/fm-error-reporting.c:
+ * src/nautilus-main.c:
+ Remove gnome_vfs uses
+
+2007-11-01 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-window-manage-views.c: use g_file_get_uri_scheme
+ instead of a hand rolled version.
+
+2007-11-01 Paolo Borelli <pborelli@katamail.com>
+
+ * src/file-manager/fm-directory-view.c: do not use the deprecated
+ gnome_util_home_file and make sure tha ~/.gnome2 is created if it
+ doesn't exist.
+
+2007-11-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Convert unmount volume to gio
+ Remove unmount drive (makes no sense!)
+
+ * src/nautilus-places-sidebar.c:
+ Use new APIs
+
+2007-11-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ (nautilus_file_get_uri_scheme):
+ Better get_uri_scheme implementation
+
+ * libnautilus-private/nautilus-mime-actions.[ch]:
+ Remove the open_with versions (not needed anymore)
+ Add support for uri_handlers
+
+ * libnautilus-private/nautilus-program-choosing.[ch]:
+ Remove now unused function nautilus_launch_show_file
+
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-information-panel.c:
+ * src/nautilus-window.c:
+ Update for above api changes
+
+2007-10-31 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-dnd.c:
+ Convert default dnd op to gio code
+
+2007-10-31 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-search-engine-simple.c:
+ Update to changed gio API
+
+2007-10-31 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Remove more unused gnome-vfs helpers
+
+2007-10-31 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-icon-view.c (play_file):
+ Use a better pipeline for audio preview (doesn't play videos)
+ Add back totem preview app.
+
+ * libnautilus-private/nautilus-file.c:
+ (nautilus_file_get_volume_name):
+ Get volume name using gio
+
+ * src/file-manager/fm-properties-window.c:
+ Show volume name for non local files too
+ Avoid crashes if query fsinfo fails
+
+2007-10-30 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ (nautilus_launch_show_file):
+ Avoid gnome_vfs calls
+
+2007-10-30 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-canvas-item.c:
+ (real_map_pixbuf):
+ Fix indentation
+
+ * src/file-manager/Makefile.am:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/nautilus-audio-mime-types.h:
+ Replace audio preview code with new one based
+ on gst-launch, removing all the gnome-vfs code
+
+2007-10-29 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-dnd.c:
+ Remove gnome-vfs code
+
+2007-10-29 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ * libnautilus-private/nautilus-file-operations.c:
+ Move public gnome-vfs functions from file-utilities to internal
+ calls in file-operations.c
+ Replace gnome-vfs use with gio
+
+ * libnautilus-private/nautilus-file-operations-progress.c:
+ * src/file-manager/fm-tree-view.c:
+ Replace gnome-vfs use with gio
+
+2007-10-29 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Move nautilus_file_operations_delete to the gio code.
+
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-tree-view.c:
+ Update to use new nautilus_file_operations_delete
+
+2007-10-26 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-module.c:
+ Fix valgrind warning on shutdown (#346401, ported from trunk).
+
+2007-10-26 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-desktop-link.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-bookmark.c:
+ * libnautilus-private/nautilus-trash-monitor.c:
+ * libnautilus-private/nautilus-file.c:
+ Plug minor memory leaks and improper uses of eel_ref_str_*
+
+2007-10-26 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-desktop-link.c: unref the icon instead
+ of freeing it to avoid memory corruption.
+
+2007-10-25 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-changes-queue.[ch]:
+ * libnautilus-private/nautilus-monitor.c:
+ Rename some file change queue functions to _by_uri
+ add GFile based version with the original name
+
+ * libnautilus-private/nautilus-file-operations.[ch]:
+ Add gio based nautilus_file_operations_trash_or_delete() call.
+
+ * src/file-manager/fm-directory-view.c:
+ Call nautilus_file_operations_trash_or_delete()
+ Remove unused code
+
+2007-10-25 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-directory-view.[ch]:
+ Make file activation handle mounting of mountables and non-mounted
+ locations. Also general cleanup of activation.
+ Cancellation not handled yet.
+
+2007-10-25 Paolo Borelli <pborelli@katamail.com>
+
+ * src/file-manager/fm-list-view.c:
+ * libnautilus-private/nautilus-icon-info.c:
+ * libnautilus-private/nautilus-file.c:
+ Plug some minor memory leaks.
+
+2007-10-25 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-window-manage-view.c (location_has_really_changed):
+ Fix a warning when switching view.
+
+2007-10-25 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-application.c:
+ * src/nautilus-property-browser.c:
+ * src/nautilus-shell.c:
+
+ Do not use EelStringList.
+
+2007-10-24 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-file-management-properties.c:
+ remove eel_string_list (ab)use.
+
+2007-10-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-vfs-file.c:
+ Pass GMountOperation instead of parent to mount.
+ Nothing for unmount/eject
+
+ * src/file-manager/fm-directory-view.c:
+ Pass in a mount operation for mount.
+ Disable timeout when mount operation is active
+
+2007-10-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Use g_utf8_collate, not eel_strcoll.
+
+2007-10-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-canvas-item.c:
+ * test/test.c:
+ Update for eel changes
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * configure.in:
+ * libnautilus-private/nautilus-icon-canvas-item.[ch]:
+ * libnautilus-private/nautilus-icon-container.c:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ * libnautilus-private/nautilus-icon-private.h:
+ * test/test.c:
+ Remove libart dependency, use eel rect and point types
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ (nautilus_launch_application_from_command):
+ Use gdk_spawn instead of eel
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-dnd.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-information-panel.c:
+ Don't use removed eel gnome-vfs functions
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory.[ch]:
+ Add nautilus_directory_get_location
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_get_parent_location.
+ Port from eel_format_uri_for_display to gio parse names
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-location-bar.c:
+ * src/nautilus-location-dialog.c:
+ * src/nautilus-navigation-window-menus.c:
+ * src/nautilus-window-bookmarks.c:
+ Port from eel_format_uri_for_display to gio parse names
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.c:
+ (nautilus_ensure_unique_file_name):
+ Port from gnome-vfs
+
+ * src/file-manager/fm-directory-view.c:
+ (fm_directory_view_handle_netscape_url_drop):
+ Handle missing mimetype
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.c:
+ (nautilus_compute_title_for_location):
+ Make this use only display name.
+
+ * libnautilus-private/nautilus-icon-info.c:
+ (nautilus_icon_info_lookup):
+ Don't free filename before use
+
+ * libnautilus-private/nautilus-search-directory-file.[ch]:
+ * libnautilus-private/nautilus-search-directory.c:
+ Create nice display name for search directories, and keep it updated.
+
+ * src/nautilus-window-manage-views.c:
+ Fix wrong type of argument passed to signal
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Replace some gnome vfs calls
+
+2007-10-23 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-metafile.c:
+ Use new gio uri escape functions instead of gnome-vfs
+
+2007-10-22 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-location-entry.c:
+ Use GFilenameCompleter
+
+2007-10-22 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-application.c:
+ * src/nautilus-information-panel.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-spatial-window.h:
+ * src/nautilus-window-manage-views.c:
+ Use GFile * instead of uris in some more places
+
+ Patch from Paolo Borelli
+
+2007-10-22 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-saved-search-file.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ Fix handling of mimetype as refstring
+ Fix leak of GFile
+ Code cleanups
+
+ Patch from Paolo Borelli
+
+2007-10-19 Paolo Borelli <pborelli@katamail.com>
+
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-directory-view.c:
+ use g_content_type_equals instead of strcasecmp on the mime type.
+
+ * src/nautilus-window-menus.c:
+ Remove unneeded includes
+
+2007-10-19 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-emblem-utils.h:
+ * libnautilus-private/nautilus-emblem-utils.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-property-browser.c:
+
+ Make nautilus_emblem_load_pixbuf_for_emblem take a GFile.
+
+2007-10-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ (nautilus_file_set_display_name):
+ Don't crash on NULL display name
+
+2007-10-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-vfs-file.c:
+ Remove NautilusFileMountCallback and just make
+ NautilusFileOperationCallback take an extra
+ resultant file argument.
+
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-error-reporting.c:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Update to API change
+
+ * src/nautilus-pathbar.c:
+ (get_display_name_for_folder):
+ Fix crash if NULL display name
+
+2007-10-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ Set can_mount/unmount to FALSE unless set
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-file.h:
+ Make the Operation object semi-public
+ Move mount ops to virtual functions
+
+ * libnautilus-private/nautilus-vfs-file.c:
+ Initial work to implement mount op
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ * src/nautilus-pathbar.c:
+ Add & use nautilus_get_desktop_location
+
+ * libnautilus-private/nautilus-dnd.c:
+ Port code to gio
+
+ * libnautilus-private/nautilus-icon-dnd.c:
+ Trash is now a real uri location, remove special case
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ Make compute_title take a GFile
+
+ * libnautilus-private/nautilus-view-factory.[ch]:
+ * libnautilus-private/nautilus-window-info.[ch]:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-application.[ch]:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-bookmarks-window.c:
+ * src/nautilus-connect-server-dialog-nonmain.c:
+ * src/nautilus-desktop-window.c:
+ * src/nautilus-history-sidebar.c:
+ * src/nautilus-location-bar.c:
+ * src/nautilus-location-dialog.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-shell.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window-manage-views.[ch]:
+ * src/nautilus-window-menus.c:
+ * src/nautilus-window-private.h:
+ * src/nautilus-window.[ch]:
+ Use GFile * instead of char * uri in all loation handling
+ for windows.
+
+2007-10-18 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-image-properties-page.c: port to gio.
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.[ch]:
+ * src/nautilus-application.c:
+ Make nautilus_directory_get_existing take GFile *.
+ Add nautilus_directory_get taking a GFile *
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-directory-file.c:
+ * libnautilus-private/nautilus-desktop-directory.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-desktop-link-monitor.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-directory.h:
+ * libnautilus-private/nautilus-file-operations.c:
+ * libnautilus-private/nautilus-file-utilities.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-window-manage-views.c:
+ * test/test-nautilus-directory-async.c:
+ Rename nautilus_directory_get to nautilus_directory_get_by_uri.
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-link.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ Handle NULL volume
+
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ Convert gnome_vfs calls to gio
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * src/nautilus-application.c:
+ * src/nautilus-window-menus.c:
+ * test/test-nautilus-directory-async.c:
+ * test/test.c:
+ Convert gnome_vfs calls to gio
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-application.[ch]:
+ Convert gnome_vfs calls to gio
+
+ * TODO-gio:
+ Document some stuff that needs doing in gio-branch
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-search-engine-simple.c:
+ Remove spew
+
+ * src/nautilus-query-editor.c:
+ Work around crash getting NULL back as the location.
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ Add nautilus_is_home_directory and nautilus_is_root_directory
+
+ * src/nautilus-window-manage-views.c:
+ Convert gnome_vfs calls to gio
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-window.c (nautilus_window_go_up):
+ Use gio to find parent
+
+2007-10-18 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-pathbar.[ch]:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-window-manage-views.c:
+ Use gio in pathbar
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Remove now unused gnome_vfs to gio helpers
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-location-bar.c:
+ Remove some unused code
+ Replace gnome_vfs code with gio code
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c (nautilus_file_can_trash):
+ Typo can_delete -> can_trash
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-property-browser.c:
+ Replace some gnome-vfs code with gio code
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-properties-window.c:
+ Replace some gnome-vfs code with gio code
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ Add can_delete and can_trash
+
+ * src/file-manager/fm-directory-view.c:
+ Replace some gnome-vfs code with gio code
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-location-dialog.c (open_current_location):
+ Use g_file_parse_name instead of gnome_vfs_make_uri_from_input
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-search-engine-simple.c:
+ Update to use gio
+
+2007-10-17 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-recent.c: do not use gnome-vfs.
+
+2007-10-17 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-emblem-utils.c: do not use gnome-vfs.
+
+2007-10-17 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-link.[ch]: remove.
+ * libnautilus-private/nautilus-link-desktop-file.[ch]: port to gio
+ and rename them to nautilus-link.[ch]
+ * libnautilus-private/nautilus-file.c: adapt for the above change.
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-places-sidebar.c:
+ Use gio volume APIs
+
+2007-10-17 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-file-private.h:
+ Remove has/get_volume/drive, replace with
+ can_mount/unmount/eject and mount/unmount/eject.
+ (Which are not fully implemented yet)
+ Add nautilus_file_is_mountpoint.
+
+ * libnautilus-extension/nautilus-file-info.[ch]:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-link-desktop-file.[ch]:
+ * libnautilus-private/nautilus-link.[ch]:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.[ch]:
+ * src/file-manager/fm-tree-view.c:
+ Use gio volume APIs
+
+2007-10-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-desktop-link-monitor.c:
+ * libnautilus-private/nautilus-desktop-link.[ch]:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Convert some volume monitor use to gio
+
+2007-10-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-trash-monitor.c:
+ Ref icon in nautilus_trash_monitor_get_icon()
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-desktop-link.c:
+ * libnautilus-private/nautilus-desktop-link.h:
+ * src/nautilus-places-sidebar.c:
+ Use nautilus_trash_monitor_get_icon() when possible
+
+2007-10-16 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-trash-monitor.[ch]:
+ Add full gio implementation and get_icon()
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-icon-factory-private.h: Removed.
+ * libnautilus-private/nautilus-icon-factory.c: Removed.
+ * libnautilus-private/nautilus-icon-factory.h: Removed.
+ Remove NautilusIconFactory code.
+ Now all code use the new APIs
+ YAHOO!!!
+
+ * libnautilus-private/nautilus-bookmark.c:
+ * libnautilus-private/nautilus-bookmark.h:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-global-preferences.c:
+ * libnautilus-private/nautilus-icon-canvas-item.c:
+ * libnautilus-private/nautilus-icon-canvas-item.h:
+ * libnautilus-private/nautilus-icon-container.h:
+ * libnautilus-private/nautilus-icon-private.h:
+ * libnautilus-private/nautilus-link-desktop-file.c:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * libnautilus-private/nautilus-view.h:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-list-model.c:
+ * src/file-manager/fm-list-model.h:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-application.c:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-bookmarks-window.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-navigation-window-menus.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-pathbar.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-sidebar-title.c:
+ * src/nautilus-window-menus.c:
+ * src/nautilus-window.c:
+ * src/nautilus-zoom-control.h:
+ * test/test-nautilus-wrap-table.c:
+ Don't include the nautilus-icon-factory headers
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER
+ Fix force_size handling
+
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-empty-view.c:
+ * src/file-manager/fm-list-model.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-navigation-window-menus.c:
+ * src/nautilus-property-browser.c:
+ * src/nautilus-sidebar-title.c:
+ Convert more stuff to new icon API
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Add nautilus_icon_info_lookup_from_name
+
+ * libnautilus-private/nautilus-ui-utilities.c:
+ * src/nautilus-desktop-window.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-pathbar.c:
+ Use nautilus_icon_info_lookup_from_name to get less
+ code
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * src/nautilus-pathbar.c:
+ * src/nautilus-spatial-window.c:
+ Convert more stuff to new icon API
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_get_icon_pixbuf and
+ IGNORE_VISITING icon flag
+
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Add nautilus_icon_info_get_used_name function
+
+ * libnautilus-private/nautilus-emblem-utils.c:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * libnautilus-private/nautilus-ui-utilities.c:
+ * src/nautilus-desktop-window.c:
+ * src/nautilus-navigation-window.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window.[ch]:
+ Convert to new icon APIs
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-audio-player.c: Removed.
+ * libnautilus-private/nautilus-audio-player.h: Removed.
+ * src/file-manager/fm-icon-view.c:
+ Kill old unused code
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Add nautilus_icon_info_get_pixbuf_nodefault_at_size
+
+ * libnautilus-private/nautilus-file.[ch]:
+ New functions for getting emblem icons and emblem pixbufs
+
+ * libnautilus-private/nautilus-icon-container.[ch]:
+ * libnautilus-private/nautilus-icon-factory.c:
+ * src/file-manager/fm-directory-view.[ch]:
+ * src/file-manager/fm-icon-container.c:
+ * src/file-manager/fm-list-model.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/nautilus-sidebar-title.c:
+ Update to use the new emblem getters
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Add nautilus_get_icon_size_for_stock_size
+
+ * libnautilus-private/nautilus-bookmark.c:
+ * src/nautilus-places-sidebar.c:
+ Use the above
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-thumbnails.c:
+ Add required thumbnailing stuff from NautilusIconFactory here
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-factory.[ch]:
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Move over icon size util functions to nautilus-icon-info
+
+ * libnautilus-private/nautilus-icon-container.c:
+ * libnautilus-private/nautilus-lib-self-check-functions.h:
+ * src/file-manager/fm-list-model.c:
+ * src/nautilus-sidebar-title.c:
+ Update to new names
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-container.c:
+ * libnautilus-private/nautilus-icon-factory.h:
+ Remove NAUTILUS_ICON_SIZE_THUMBNAIL define as this is
+ really dynamic.
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Actually handle thumbnail size prefs
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Handle thumbnail size prefs
+ Handle all sorts of icon changes and emit CHANGED on
+ files in this case.
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-icon-container.c:
+ * libnautilus-private/nautilus-icon-info.c:
+ * libnautilus-private/nautilus-icon-info.h:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/file-manager/fm-tree-model.h:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-bookmarks-window.c:
+ * src/nautilus-sidebar-title.c:
+ * src/nautilus-window-bookmarks.c:
+ * src/nautilus-window.c:
+ Remove use of icon factory icons_changed signal, using instead
+ the file CHANGED signal.
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c (nautilus_file_get_all_attributes):
+ Add thumbnail to all attributes
+
+2007-10-15 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.h:
+ Add NAUTILUS_FILE_ATTRIBUTES_FOR_ICON
+
+ * libnautilus-private/nautilus-bookmark.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-pathbar.c:
+ * src/nautilus-sidebar-title.c:
+ Use NAUTILUS_FILE_ATTRIBUTES_FOR_ICON instead of
+ nautilus_icon_factory_is_icon_ready_for_file and
+ nautilus_icon_factory_get_required_file_attributes.
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-bookmark.[ch]:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-icon-info.c:
+ * src/nautilus-application.c:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-bookmarks-window.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-window-manage-views.c:
+ * src/nautilus-window-private.h:
+ * src/nautilus-window.c:
+ Convert bookmarks API to gio / GIcon
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-icon-container.c:
+ * libnautilus-private/nautilus-thumbnails.[ch]:
+ Add back support for generating thumbnails.
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ For large icons, try to use the original file
+ when thumbnailing.
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Only invalidate thumbnails when sizing up, not
+ on the original scale from raw
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Simplify thumbnail size handling and make it work.
+ Now handles resizing icons.
+
+2007-10-12 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ More exact handling of thumbnail up_to_date-ness, including
+ if loading a thumbnail fails.
+ Return thumbnails of the right size.
+
+ * libnautilus-private/nautilus-thumbnails.[ch]:
+ Add nautilus_thumbnail_unframe_image and export
+ frame element sizes as defines
+
+2007-10-11 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-directory-async.c:
+ Export nautilus_file_should_show_thumbnail and use it as needed in the
+ thumbnail reading code
+
+2007-10-11 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-attributes.h:
+ Add NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL attribute
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ Load thumbnails asynchronosuly.
+
+ * libnautilus-private/nautilus-file.c:
+ Initial code to use the asynchronoulsy loaded thumbnail
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ Add NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL as a required attribute for
+ icons
+
+2007-10-11 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Read thumbnail info from gio
+
+2007-10-11 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c (nautilus_file_get_gicon):
+ Handle accept, visited and embedding text state and
+ rewrite the icon as needed.
+
+ * libnautilus-private/nautilus-icon-info.c:
+ (nautilus_icon_info_finalize):
+ Fix crash if pixbuf is NULL
+
+2007-10-11 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-icon-info.[ch]:
+ Added NautilusInfoInfo, including caches and GIcon => pixbuf lookup
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Make nautilus_file_get_icon return a NautilusFileInfo
+
+ * libnautilus-private/nautilus-icon-canvas-item.[ch]:
+ Split out attach points instead of using NautilusAttachPoints
+
+ * libnautilus-private/nautilus-icon-container.[ch]:
+ * src/file-manager/fm-icon-container.c:
+ Use the new nautilus_file_get_icon and nautilus_file_info_* stuff
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * libnautilus-private/nautilus-mime-application-chooser.c:
+ * libnautilus-private/nautilus-open-with-dialog.c:
+ Update to g_themed_icon_get_names const type
+
+2007-10-10 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ Keep track of GIcon from gio.
+ Add nautilus_file_get_icon()
+
+ * libnautilus-private/nautilus-icon-factory.[ch]:
+ Add nautilus_icon_factory_get_pixbuf_for_gicon().
+ This is a bit temporary, but can be used to move over
+ users to nautilus_file_get_icon().
+
+ * libnautilus-private/nautilus-icon-container.[ch]:
+ * src/file-manager/fm-icon-container.c:
+ Use nautilus_file_get_icon() in icon view.
+
+2007-10-10 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.c:
+ * libnautilus-private/nautilus-monitor.c:
+ * src/nautilus-bookmark-list.c:
+ Update for file monitoring API change
+
+ * src/nautilus-spatial-window.c:
+ Gio port from Paolo Borelli
+
+2007-10-08 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ (nautilus_file_peek_display_name):
+ Use a display name based on the filename as the default instead
+ of "" before we've read the real display name from the backend.
+
+2007-10-08 Paolo Borelli <pborelli@katamail.com>
+
+ * libnautilus-private/nautilus-icon-dnd.[ch]:
+ * src/nautilus-emblem-sidebar.c:
+ * src/nautilus-location-bar.c:
+
+ Replace nautilus_icon_dnd_uri_list_extract_uris with
+ g_uri_list_extract_uris.
+
+2007-10-08 Paolo Borelli <pborelli@katamail.com>
+
+ * src/nautilus-bookmark-list.[ch]: port to gio.
+
+2007-10-05 Paolo Borelli <pborelli@katamail.com>
+
+ * configure.in: use gio-2.0 instead of gio-standalone.
+
+2007-10-04 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-trash-directory.[ch]:
+ * libnautilus-private/nautilus-trash-file.[ch]:
+ Remove virtual trash locations, we now use the gvfs trash:
+
+ * libnautilus-private/nautilus-trash-monitor.[ch]:
+ Make this a stub for now. Need to figure out how to do this.
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-operations.c:
+ * libnautilus-private/nautilus-file.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-window-manage-views.c:
+ Handle the removal of NautilusTrash*
+
+2007-10-04 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-thumbnails.c:
+ Use gio instead of gnome-vfs to get mtime
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-customization-data.c:
+ * libnautilus-private/nautilus-customization-data.h:
+ * src/nautilus-property-browser.c:
+ Use gio to read info
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-dnd.c (selection_is_image_file):
+ Use gio to get mime type
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.c:
+ Use GFileMonitor to monitor xdg user dirs file
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am (INCLUDES):
+ Bump name for extension dir since we're not compatible anymore
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-bookmark.c:
+ * libnautilus-private/nautilus-customization-data.c:
+ * libnautilus-private/nautilus-desktop-directory.c:
+ * libnautilus-private/nautilus-directory-background.c:
+ * libnautilus-private/nautilus-dnd.c:
+ * libnautilus-private/nautilus-file-operations.c:
+ * libnautilus-private/nautilus-file-utilities.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-metafile.c:
+ * libnautilus-private/nautilus-search-directory.c:
+ * libnautilus-private/nautilus-search-engine-tracker.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-ditem-page.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-application.c:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-image-properties-page.c:
+ * src/nautilus-information-panel.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-property-browser.c:
+ * src/nautilus-query-editor.c:
+ gnome_vfs_get_local_path_from_uri -> g_filename_from_uri
+ gnome_vfs_get_uri_from_local_path -> g_filename_to_uri
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ Don't clear thumbnails and other absolute pathnames from icon
+ cache when mime data or icon theme changes. This is to avoid
+ flashing and async realoading of all thumbnails.
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ (mime_db_changed_callback):
+ Use the right call to invalidate attributes, so that
+ they get re-read correctly.
+
+2007-10-02 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ (mime_type_data_changed_callback):
+ * libnautilus-private/nautilus-directory-async.c:
+ (mime_db_changed_callback):
+ Fix up types in callbacks
+
+ * libnautilus-private/nautilus-mime-application-chooser.c:
+ * libnautilus-private/nautilus-open-with-dialog.c:
+ Handle and emit mime_data_changed on NautilusSignaller
+
+2007-10-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-mime-application-chooser.[ch]:
+ * libnautilus-private/nautilus-open-with-dialog.[ch]:
+ Moved these from eel and renamed
+
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Use the nautilus version imported above instead of the eel one.
+
+2007-10-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-signaller.c:
+ Replace gnome-vfs mime monitor with NautilusSignaller signal.
+
+ * src/nautilus-query-editor.c:
+ Use gio to list all mime types
+
+2007-10-01 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-theme.[ch]:
+ Delete leftover files
+
+2007-09-28 Alexander Larsson <alexl@redhat.com>
+
+ * configure.in:
+ Update for new gio pkgconfig name
+
+2007-09-28 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Update to the new name for g_format_file_size_for_display
+
+2007-09-28 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-link.c:
+ * src/file-manager/fm-icon-container.c:
+ * src/nautilus-query-editor.c:
+ Use gio mimetype functions instead of gnome-vfs ones.
+
+2007-09-28 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-mime-actions.[ch]:
+ * libnautilus-private/nautilus-program-choosing.[ch]:
+ * libnautilus-private/nautilus-recent.[ch]:
+ Use GAppInfo instead of GnomeVFSMimeApplication
+
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-information-panel.c:
+ * test/test-nautilus-mime-actions.c:
+ Update due to the api changes in the GAppInfo move.
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Use g_file_size_format_for_display instead of
+ gnome_vfs_format_file_size_for_display
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Remove unused GnomeVFSHandle stuff
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Forgot to change GnomeVFSResult to GError in
+ one spot.
+
+007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Implement nautilus_file_set_owner and nautilus_file_set_group
+ using set_attributes
+
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.c:
+ Implement nautilus_file_set_permissions using
+ nautilus_file_set_attributes.
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_set_attributes
+
+2007-09-27 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Add gnome_vfs_result_to_error call
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Convert renaming to use gio.
+ Pass GError instead of GnomeVFSResult in
+ NautilusFileOperationCallback
+
+ * src/file-manager/fm-error-reporting.c:
+ * src/file-manager/fm-error-reporting.h:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Update to the NautilusFileOperationCallback API change
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Read can_delete and can_rename from gio.
+ Use can_rename in nautilus_file_can_rename.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_get_edit_name()
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ Make string args const char * where possible.
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Read display_name and edit_name from gio.
+ Kill old cached_display_name creation.
+ Use eel_ref_str for name, display_name, edit_name and make sure to
+ share them when possible.
+ Old use of display_name as the link info only is moved so that
+ its shared with the normal name, with got_custom_display_name showing
+ where its from.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Use new refcounted string implementation for mime_type.
+ This way we don't have to store duplicate strings for
+ each file.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory.c (nautilus_directory_finalize):
+ directory->details->pending_file_info now has GFileInfo objects, not
+ GnomeVFSFileInfo objects. Free them in the correct way.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ Remove old irrelevant comment
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ Read top left text with gio
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-ditem-page.c:
+ Use g_file_load_contents_async instead of
+ eel_read_entire_file_async.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-thumbnails.c:
+ Use g_file_load_contents_async instead of
+ eel_read_entire_file_async.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-metafile.c:
+ Use g_file_load_contents_async instead of
+ eel_read_entire_file_async.
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file.c:
+ Initialize hidden_file_hash lazily
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ Read link info using gio
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Read mime list using gio
+
+2007-09-26 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ Read .hidden using gio.
+
+2007-09-25 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ Free file_info after last use (fixed valgrind warning)
+
+ * libnautilus-private/nautilus-file.c:
+ Sometimes we freed an uninitialized pointer
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Keep all the directory loading info in DirectoryLoadState
+
+2007-09-25 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Implement deep count using gio
+
+2007-09-25 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-metafile.c (set_metafile_contents):
+ Don't crash on files that have slashes in them.
+
+2007-09-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Use gio to do directory counts
+
+2007-09-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ Define NAUTILUS_FILE_DEFAULT_ATTRIBUTES
+
+2007-09-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-directory-file.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-file.h:
+ * libnautilus-private/nautilus-saved-search-file.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ * libnautilus-private/nautilus-trash-file.c:
+ There was some problems removing the virtual call for
+ get_file_type, as this broke getting the type for "virtual"
+ directory types like trash and the desktop. Re-introduce this,
+ but set the type directly instead of via an indirect jump.
+
+2007-09-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-file.h:
+ nautilus_file_get_for_location -> nautilus_file_get
+ same for get_existing
+
+2007-09-24 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-bookmark.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-operations.c:
+ * libnautilus-private/nautilus-file-utilities.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-file.h:
+ * libnautilus-private/nautilus-icon-dnd.c:
+ * libnautilus-private/nautilus-search-directory.c:
+ * libnautilus-private/nautilus-thumbnails.c:
+ * libnautilus-private/nautilus-trash-monitor.c:
+ * libnautilus-private/nautilus-tree-view-drag-dest.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-ditem-page.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-list-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-application.c:
+ * src/nautilus-bookmark-list.c:
+ * src/nautilus-information-panel.c:
+ * src/nautilus-notes-viewer.c:
+ * src/nautilus-pathbar.c:
+ * src/nautilus-places-sidebar.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window-manage-views.c:
+ * test/test-nautilus-mime-actions-set.c:
+ * test/test-nautilus-mime-actions.c:
+ Rename nautilus_file_get -> nautilus_file_get_by_uri.
+ Same with nautilus_file_get_existing.
+
+2007-09-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Fix up type for get_permissions return value (don't use gnome-vfs types).
+
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Add gnome_vfs_file_type_from_g_file_type()
+
+ * libnautilus-private/nautilus-icon-factory.c:
+ Set up more GnomeVFSInfo fields needed for gnome_icon_lookup.
+
+2007-09-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-monitor.[ch]:
+ Use gio to implement file monitoring.
+
+2007-09-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Read info for new files
+
+2007-09-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Implement get_file_info using gio
+
+2007-09-21 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ Read directory list via gio instead of gnome-vfs
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Get is_hidden & is_backup from gio instead of doing
+ filename matching ourselves.
+
+ * libnautilus-private/nautilus-file-utilities.c:
+ Remove unused hidden/backup pattern matching.
+
+ * src/nautilus-main.c:
+ Initiate GThreads, as we need this for gio async emulation.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-vfs-utils.c:
+ Fix typo in attribute name
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ Make NautilusFile info update use GFileInfo.
+ Update all call sites to convert to it.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Add gnome_vfs_file_info_to_gio
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-metafile-monitor.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-metafile.c:
+ Make the filename key for metadata be unescaped in memory.
+ Escape it only when reading/writing the metadata files.
+ This is to avoid escaping a lot since we're now storing the
+ filename unescaped in NautilusFile.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ Add GFile versions of metadata scheduling functions.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ Add GFile versions:
+ nautilus_directory_notify_files_changed
+ nautilus_directory_notify_files_removed
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file.c:
+ Avoid for_location suffix when its not needed anymore
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory.c:
+ Add _by_uri suffix to uri versions of functions and
+ remove suffix for GFile versions
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-changes-queue.c:
+ * libnautilus-private/nautilus-link-desktop-file.c:
+ * libnautilus-private/nautilus-merged-directory.c:
+ Rename notify functions that work on uris to _by_uri and
+ the GFile ones to have no suffix
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-metafile.c:
+ * libnautilus-private/nautilus-directory.[ch]:
+ Remove unused function nautilus_directory_make_uri_canonical
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ Added nautilus_directory_notify_files_moved_by_location and
+ made nautilus_directory_notify_files_moved use that.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-notify.h:
+ * libnautilus-private/nautilus-directory.c:
+ Add nautilus_directory_notify_files_added_by_location.
+ Use GFile instead of uris in more places
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_get_for_location and nautilus_file_get_existing_for_location.
+ and implement nautilus_file_get based on these.
+
+2007-09-20 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file.[ch]:
+ Add nautilus_file_get_location () and use it when
+ generating uris.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory.c:
+ (nautilus_directory_is_desktop_directory):
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ (nautilus_is_home_directory_file):
+ (nautilus_is_desktop_directory_file):
+ (nautilus_is_desktop_directory):
+ * libnautilus-private/nautilus-file.c:
+ (nautilus_file_is_desktop_directory):
+ (nautilus_file_is_home):
+ Don't keep dup:ing strings for these commonly called
+ functions.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ * libnautilus-private/nautilus-file.c:
+ Use GFile *location to store the uri for NautilusDirectory.
+ In preparation for using GFile for all I/O.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-attributes.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-mime-actions.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-ditem-page.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/nautilus-window.c:
+ Remove slow mimetype attribute and all its use.
+ This is in preparation for the gio move which has
+ a canonical mimetype definition instead of the
+ guessed/slow couple.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-attributes.h:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-utilities.c:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-mime-actions.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-properties-window.c:
+ * src/file-manager/fm-tree-model.c:
+ * src/file-manager/fm-tree-view.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window-manage-views.c:
+ * src/nautilus-window.c:
+ Limit the set of file attributes to the ones we actually read
+ separately. This makes it more obvious what is happening when
+ doing I/O. It does put some extra work on users, because they
+ need to know where the data is coming from, but that is rarely
+ a problem.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file-utilities.[ch]:
+ * libnautilus-private/nautilus-file.c:
+ Store "name" instead of "relative_uri" in NautilusFile.
+ We want to avoid escaping/unescaping as much as possible and
+ limit that to when we go from/to a full uri.
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ Remove declaration for removed function
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-program-choosing.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/nautilus-spatial-window.c:
+ * src/nautilus-window-manage-views.c:
+ Use GError instead of GnomeVFSResult for get_info_error
+
+2007-09-19 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-directory-file.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-saved-search-file.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ * libnautilus-private/nautilus-trash-file.c:
+ * libnautilus-private/nautilus-vfs-file.c:
+ * libnautilus-private/nautilus-vfs-utils.c:
+ * libnautilus-private/nautilus-vfs-utils.h:
+ * libnautilus-private/nautilus-view-factory.c:
+ * libnautilus-private/nautilus-view-factory.h:
+ * src/file-manager/fm-desktop-icon-view.c:
+ * src/file-manager/fm-empty-view.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-list-view.c:
+ Move from GnomeVFSFileType to GFileType
+
2007-11-28 Alexander Larsson <alexl@redhat.com>
* src/nautilus-search-bar.c:
@@ -83,6 +2134,73 @@
Fixes #478363.
2007-09-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-file-private.h:
+ Clean up NautilusFileDetails a bit.
+
+2007-09-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-extension/nautilus-file-info.[ch]:
+ * libnautilus-private/nautilus-desktop-directory-file.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory.c:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.[ch]:
+ * libnautilus-private/nautilus-icon-factory.c:
+ * libnautilus-private/nautilus-saved-search-file.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ * libnautilus-private/nautilus-thumbnails.c:
+ * libnautilus-private/nautilus-trash-file.c:
+ * libnautilus-private/nautilus-vfs-file.c:
+ * src/file-manager/fm-directory-view.c:
+ Store file info directly in NautilusFile instead of using a
+ GnomeVfsFileInfo.
+
+2007-09-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/nautilus-desktop-directory-file.c:
+ * libnautilus-private/nautilus-desktop-icon-file.c:
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-file-operations-progress.c:
+ * libnautilus-private/nautilus-file-operations-progress.h:
+ * libnautilus-private/nautilus-file-private.h:
+ * libnautilus-private/nautilus-file.c:
+ * libnautilus-private/nautilus-file.h:
+ * libnautilus-private/nautilus-metafile.c:
+ * libnautilus-private/nautilus-search-directory-file.c:
+ * libnautilus-private/nautilus-thumbnails.c:
+ * libnautilus-private/nautilus-trash-file.c:
+ * libnautilus-private/nautilus-vfs-file.c:
+ * src/file-manager/fm-directory-view.c:
+ * src/file-manager/fm-ditem-page.c:
+ * src/file-manager/fm-icon-view.c:
+ * src/file-manager/fm-properties-window.c:
+ Use goffset instead of GnomeVFSFileSize
+
+2007-09-18 Alexander Larsson <alexl@redhat.com>
+
+ * libnautilus-private/Makefile.am:
+ * libnautilus-private/nautilus-vfs-utils.[ch]:
+ Added tools for conversion from GnomeVFSResult to GError
+
+ * libnautilus-private/nautilus-directory-async.c:
+ * libnautilus-private/nautilus-directory-private.h:
+ * libnautilus-private/nautilus-directory.[ch]:
+ * libnautilus-private/nautilus-search-directory.c:
+ * src/file-manager/fm-directory-view.[ch]:
+ * src/file-manager/fm-error-reporting.[ch]:
+ Use GError instead of GnomeVFSResult for directory loading errors
+
+2007-09-18 Alexander Larsson <alexl@redhat.com>
+
+ * configure.in:
+ Add -gio to version for now
+ Pull in gio-standalone
+
+=== gio-branch starts here ===
+
+2007-09-18 Alexander Larsson <alexl@redhat.com>
* configure.in:
Post release version bump
diff --git a/NEWS b/NEWS
index 0d2ffea1f..9f0065a9f 100644
--- a/NEWS
+++ b/NEWS
@@ -419,7 +419,7 @@ Major changes in 2.9.90 are:
* Better icons for burn: & computer: in the ui
* Allow eject of unmounted devices
* Better handling of DnD from mozilla
-* Make connect to server dialog availible as separate app
+* Make connect to server dialog available as separate app
* Use GtkAboutDialog
Major changes in 2.9.2 are:
diff --git a/TODO-gio b/TODO-gio
new file mode 100644
index 000000000..929945066
--- /dev/null
+++ b/TODO-gio
@@ -0,0 +1,16 @@
+Monitor for UNMOUNT file change event and close window
+
+Break out file activation from fm-directory-view.c
+File actication cancellation not implemented yet
+
+convert delete to use trash_or_delete code
+recursive deletes
+progress for trash/delete
+
+Automount location when loading it in a window and its not mounted.
+
+"translate" gnome-vfs errors and update error handling
+
+fm-directory-view.c: pre_copy_move stuff leaks as it waits for uris that are not in the target directory.
+
+
diff --git a/configure.in b/configure.in
index 180e28754..238137fc8 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,6 @@ AC_PREREQ(2.54)
dnl ===========================================================================
-m4_define(art_minver, 2.3.10)
m4_define(bonobo_activation_minver, 2.1.0)
m4_define(bonobo_minver, 2.1.0)
m4_define(eel_minver, 2.15.91)
@@ -22,6 +21,7 @@ m4_define(exif_minver, 0.5.12)
m4_define(beagle_minver, 0.0.12)
m4_define(tracker_minver, 0.0.1)
m4_define(exempi_minver, 1.99.2)
+m4_define(exempi_minver_newapi, 1.99.5)
dnl 1. If the library code has changed at all since last release, then increment revision.
dnl 2. If any interfaces have been added, then increment current and set revision to 0.
@@ -29,7 +29,7 @@ dnl Interface break is not allowed.
m4_define(nautilus_extension_current, 2)
m4_define(nautilus_extension_revision, 0)
-AC_INIT(nautilus, 2.20.1,
+AC_INIT(nautilus, 2.21.1
[http://bugzilla.gnome.org/enter_bug.cgi?product=nautilus])
dnl ===========================================================================
@@ -41,7 +41,6 @@ AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE
AC_SUBST([ACLOCAL_AMFLAGS], ["\${ACLOCAL_FLAGS}"])
-AC_SUBST(ART_REQUIRED, [art_minver])
AC_SUBST(BONOBO_ACTIVATION_REQUIRED, [bonobo_activation_minver])
AC_SUBST(BONOBO_REQUIRED, [bonobo_minver])
AC_SUBST(EEL_REQUIRED, [eel_minver])
@@ -97,10 +96,10 @@ PKG_CHECK_MODULES(ALL, [
gnome-desktop-2.0 >= gnome_desktop_minver
gnome-vfs-2.0 >= gnome_vfs_minver
gnome-vfs-module-2.0 >= gnome_vfs_minver
+ gio-2.0
ORBit-2.0 >= orbit_minver
pango >= pango_minver
gtk+-2.0 >= gtk_minver
- libart-2.0 >= art_minver
libbonobo-2.0 >= bonobo_minver
libgnome-2.0 >= gnome_minver
libgnomeui-2.0 >= gnome_ui_minver
@@ -266,6 +265,9 @@ PKG_CHECK_MODULES(EXEMPI, exempi-2.0 >= exempi_minver, [
AC_DEFINE(HAVE_EXEMPI, 1, [Define to enable XMP support])
], [AM_CONDITIONAL(HAVE_EXEMPI, false)])
+PKG_CHECK_MODULES(EXEMPI_NEW_API, exempi-2.0 >= exempi_minver_newapi,
+ AC_DEFINE(HAVE_EXEMPI_NEW_API, 1, [Define if we have exempi with the new API]), true)
+
AC_SUBST(EXEMPI_CFLAGS)
AC_SUBST(EXEMPI_LIBS)
@@ -404,7 +406,7 @@ LIBNAUTILUS_EXTENSION_LIBS="`$PKG_CONFIG --libs $LIBNAUTILUS_EXTENSION_MODULES`"
AC_SUBST(LIBNAUTILUS_EXTENSION_LIBS)
dnl core nautilus (must list bonobo-activation and libbonobo because idldir does not respect "requires")
-CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 esound gnome-desktop-2.0 gnome-vfs-module-2.0 $EXTRA_CORE_MODULES"
+CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 esound gnome-desktop-2.0 gnome-vfs-module-2.0 gio-2.0 $EXTRA_CORE_MODULES"
CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES` $x_cflags $WARNING_CFLAGS"
AC_SUBST(CORE_CFLAGS)
CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $x_libs"
diff --git a/docs/key_mouse_navigation.txt b/docs/key_mouse_navigation.txt
index 1f523a493..6a23c6b8c 100644
--- a/docs/key_mouse_navigation.txt
+++ b/docs/key_mouse_navigation.txt
@@ -88,7 +88,7 @@ Control can be held down while starting a drag
While doing a drag modifers affect the operation the drag causes:
Control - Copy the files
Shift - Move the files
-Alt - Open a menu with the availible alternatives
+Alt - Open a menu with the available alternatives
All the basic clicks are typically done with the left button, but can
be done with the other buttons to. [Do we want this?] However some of
diff --git a/libnautilus-extension/nautilus-file-info.c b/libnautilus-extension/nautilus-file-info.c
index 08cae486b..762a0d5b8 100644
--- a/libnautilus-extension/nautilus-file-info.c
+++ b/libnautilus-extension/nautilus-file-info.c
@@ -165,21 +165,12 @@ nautilus_file_info_is_directory (NautilusFileInfo *file)
return NAUTILUS_FILE_INFO_GET_IFACE (file)->is_directory (file);
}
-GnomeVFSFileInfo *
-nautilus_file_info_get_vfs_file_info (NautilusFileInfo *file)
-{
- g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (file), NULL);
- g_return_val_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->get_vfs_file_info != NULL, NULL);
-
- return NAUTILUS_FILE_INFO_GET_IFACE (file)->get_vfs_file_info (file);
-}
-
void
nautilus_file_info_add_emblem (NautilusFileInfo *file,
const char *emblem_name)
{
g_return_if_fail (NAUTILUS_IS_FILE_INFO (file));
- g_return_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->get_vfs_file_info != NULL);
+ g_return_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->add_emblem != NULL);
NAUTILUS_FILE_INFO_GET_IFACE (file)->add_emblem (file, emblem_name);
}
@@ -218,39 +209,3 @@ nautilus_file_info_invalidate_extension_info (NautilusFileInfo *file)
NAUTILUS_FILE_INFO_GET_IFACE (file)->invalidate_extension_info (file);
}
-
-gboolean
-nautilus_file_info_has_volume (NautilusFileInfo *file)
-{
- g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (file), FALSE);
- g_return_val_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->has_volume != NULL, FALSE);
-
- return NAUTILUS_FILE_INFO_GET_IFACE (file)->has_volume (file);
-}
-
-gboolean
-nautilus_file_info_has_drive (NautilusFileInfo *file)
-{
- g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (file), FALSE);
- g_return_val_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->has_drive != NULL, FALSE);
-
- return NAUTILUS_FILE_INFO_GET_IFACE (file)->has_drive (file);
-}
-
-GnomeVFSVolume*
-nautilus_file_info_get_volume (NautilusFileInfo *file)
-{
- g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (file),NULL);
- g_return_val_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->get_volume != NULL,NULL);
-
- return NAUTILUS_FILE_INFO_GET_IFACE (file)->get_volume (file);
-}
-
-GnomeVFSDrive*
-nautilus_file_info_get_drive (NautilusFileInfo *file)
-{
- g_return_val_if_fail (NAUTILUS_IS_FILE_INFO (file),NULL);
- g_return_val_if_fail (NAUTILUS_FILE_INFO_GET_IFACE (file)->get_drive != NULL,NULL);
-
- return NAUTILUS_FILE_INFO_GET_IFACE (file)->get_drive (file);
-}
diff --git a/libnautilus-extension/nautilus-file-info.h b/libnautilus-extension/nautilus-file-info.h
index bb1a8f682..48fa1ab8f 100644
--- a/libnautilus-extension/nautilus-file-info.h
+++ b/libnautilus-extension/nautilus-file-info.h
@@ -27,8 +27,6 @@
#define NAUTILUS_FILE_INFO_H
#include <glib-object.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
G_BEGIN_DECLS
@@ -65,8 +63,6 @@ struct _NautilusFileInfoIface
const char *mime_Type);
gboolean (*is_directory) (NautilusFileInfo *file);
- GnomeVFSFileInfo *(*get_vfs_file_info) (NautilusFileInfo *file);
-
void (*add_emblem) (NautilusFileInfo *file,
const char *emblem_name);
char * (*get_string_attribute) (NautilusFileInfo *file,
@@ -76,11 +72,6 @@ struct _NautilusFileInfoIface
const char *value);
void (*invalidate_extension_info) (NautilusFileInfo *file);
- gboolean (*has_volume) (NautilusFileInfo *file);
- gboolean (*has_drive) (NautilusFileInfo *file);
- GnomeVFSVolume* (*get_volume) (NautilusFileInfo *file);
- GnomeVFSDrive* (*get_drive) (NautilusFileInfo *file);
-
char * (*get_activation_uri) (NautilusFileInfo *file);
};
@@ -105,12 +96,6 @@ gboolean nautilus_file_info_is_mime_type (NautilusFileInfo *fil
gboolean nautilus_file_info_is_directory (NautilusFileInfo *file);
-
-/* Other File Info */
-GnomeVFSFileInfo *nautilus_file_info_get_vfs_file_info (NautilusFileInfo *file);
-
-
-
/* Modifying the NautilusFileInfo */
void nautilus_file_info_add_emblem (NautilusFileInfo *file,
const char *emblem_name);
@@ -123,11 +108,6 @@ void nautilus_file_info_add_string_attribute (NautilusFileInfo *fil
/* Invalidating file info */
void nautilus_file_info_invalidate_extension_info (NautilusFileInfo *file);
-/* Volumes and Drives */
-gboolean nautilus_file_info_has_volume (NautilusFileInfo *file);
-gboolean nautilus_file_info_has_drive (NautilusFileInfo *file);
-GnomeVFSVolume* nautilus_file_info_get_volume (NautilusFileInfo *file);
-GnomeVFSDrive* nautilus_file_info_get_drive (NautilusFileInfo *file);
G_END_DECLS
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 260742cfd..bd7d8764f 100644
--- a/libnautilus-private/Makefile.am
+++ b/libnautilus-private/Makefile.am
@@ -13,7 +13,7 @@ INCLUDES = \
-DDATADIR=\""$(datadir)"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \
- -DNAUTILUS_EXTENSIONDIR=\""$(libdir)/nautilus/extensions-1.0"\" \
+ -DNAUTILUS_EXTENSIONDIR=\""$(libdir)/nautilus/extensions-2.0"\" \
$(NULL)
dependency_static_libs = \
@@ -49,8 +49,6 @@ marshal_sources = \
libnautilus_private_la_SOURCES = \
$(nautilus_metafile_server_idl_sources) \
- nautilus-audio-player.c \
- nautilus-audio-player.h \
nautilus-bookmark.c \
nautilus-bookmark.h \
nautilus-cell-renderer-pixbuf-emblem.c \
@@ -125,10 +123,9 @@ libnautilus_private_la_SOURCES = \
nautilus-icon-container.h \
nautilus-icon-dnd.c \
nautilus-icon-dnd.h \
- nautilus-icon-factory-private.h \
- nautilus-icon-factory.c \
- nautilus-icon-factory.h \
nautilus-icon-private.h \
+ nautilus-icon-info.c \
+ nautilus-icon-info.h \
nautilus-idle-queue.c \
nautilus-idle-queue.h \
nautilus-iso9660.h \
@@ -136,8 +133,6 @@ libnautilus_private_la_SOURCES = \
nautilus-keep-last-vertical-box.h \
nautilus-lib-self-check-functions.c \
nautilus-lib-self-check-functions.h \
- nautilus-link-desktop-file.c \
- nautilus-link-desktop-file.h \
nautilus-link.c \
nautilus-link.h \
nautilus-marshal.c \
@@ -151,10 +146,16 @@ libnautilus_private_la_SOURCES = \
nautilus-metafile.h \
nautilus-mime-actions.c \
nautilus-mime-actions.h \
+ nautilus-mime-application-chooser.c \
+ nautilus-mime-application-chooser.h \
nautilus-module.c \
nautilus-module.h \
nautilus-monitor.c \
nautilus-monitor.h \
+ nautilus-open-with-dialog.c \
+ nautilus-open-with-dialog.h \
+ nautilus-progress-info.c \
+ nautilus-progress-info.h \
nautilus-program-choosing.c \
nautilus-program-choosing.h \
nautilus-recent.c \
@@ -179,10 +180,6 @@ libnautilus_private_la_SOURCES = \
nautilus-query.h \
nautilus-thumbnails.c \
nautilus-thumbnails.h \
- nautilus-trash-directory.c \
- nautilus-trash-directory.h \
- nautilus-trash-file.c \
- nautilus-trash-file.h \
nautilus-trash-monitor.c \
nautilus-trash-monitor.h \
nautilus-tree-view-drag-dest.c \
diff --git a/libnautilus-private/nautilus-audio-player.c b/libnautilus-private/nautilus-audio-player.c
deleted file mode 100644
index b59bcd2f5..000000000
--- a/libnautilus-private/nautilus-audio-player.c
+++ /dev/null
@@ -1,549 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-audio-player.c - Simple threaded audio file playback.
-
- Copyright (C) 2001 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Gene Z. Ragan <gzr@eazel.com>
-*/
-
-#include <config.h>
-#include "nautilus-audio-player.h"
-
-#include <esd.h>
-#include <glib/gmem.h>
-#include <glib/gstrfuncs.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-
-/* BUFFER_FRAMES represents the size of the buffer in frames. */
-#define BUFFER_FRAMES 4096
-
-#define PLAYER_STREAM_NAME "nautilus-audio-player"
-
-typedef enum {
- FORMAT_U8,
- FORMAT_S8,
- FORMAT_U16_LE,
- FORMAT_U16_BE,
- FORMAT_U16_NE,
- FORMAT_S16_LE,
- FORMAT_S16_BE,
- FORMAT_S16_NE
-}
-AudioFormat;
-
-typedef struct {
- pthread_t buffer_thread;
- gint fd;
- gpointer buffer;
- gboolean going, prebuffer, paused;
- gint buffer_size, prebuffer_size, block_size;
- gint rd_index, wr_index;
- gint output_time_offset;
- guint64 written, output_bytes;
- gint bps, ebps;
- gint flush;
- gint channels, frequency, latency;
- AudioFormat format;
- esd_format_t esd_format;
- gint input_bps, input_format, input_frequency, input_channels;
- char *hostname;
- ESDConfig esd_config;
- void *(*esd_translate)(void *, gint);
-} ESDInfo;
-
-
-static gboolean esdout_open (ESDInfo *info,
- AudioFormat format,
- gint rate,
- gint nch);
-static void esdout_close (ESDInfo *info);
-static void esdout_set_audio_params (ESDInfo *info);
-static void esdout_write (ESDInfo *info,
- gpointer data,
- int length);
-static int esdout_used (ESDInfo *info);
-static gboolean esdout_playing (ESDInfo *info);
-
-static void *
-player_thread (void *arg)
-{
- NautilusAudioPlayerData *data;
- AFframecount frames_read;
- int sample_format, frame_size, channel_count, sample_width;
- double rate;
- void *buffer;
- ESDInfo info;
-
- data = arg;
-
- if (data == NULL) {
- pthread_exit (NULL);
- return (void *) 0;
- }
-
- /* Read information from file */
- afGetSampleFormat (data->handle, AF_DEFAULT_TRACK, &sample_format, &sample_width);
- frame_size = afGetFrameSize (data->handle, AF_DEFAULT_TRACK, 1);
- channel_count = afGetChannels (data->handle, AF_DEFAULT_TRACK);
- rate = afGetRate (data->handle, AF_DEFAULT_TRACK);
-
- /* Attempt to open ESD */
- if (!esdout_open (&info, sample_width == 16 ? FORMAT_S16_NE : FORMAT_U8, (int)rate, channel_count)) {
- pthread_exit (NULL);
- return (void *) 0;
- }
-
- /* Read audio data from file and send it to the esd output thread */
- buffer = malloc (BUFFER_FRAMES * frame_size);
- frames_read = afReadFrames (data->handle, AF_DEFAULT_TRACK, buffer, BUFFER_FRAMES);
- while (frames_read > 0 && data->running) {
- esdout_write (&info, buffer, frames_read * frame_size);
- frames_read = afReadFrames (data->handle, AF_DEFAULT_TRACK, buffer, BUFFER_FRAMES);
- }
- afCloseFile (data->handle);
-
- /* Now wait for the esd output thread to complete it task */
- while (esdout_playing (&info) && data->running) {
- usleep (20000);
- }
-
- /* Shutdown esd output thread */
- esdout_close (&info);
-
- g_free (buffer);
-
- pthread_exit (NULL);
-
- return (void *) 0;
-}
-
-NautilusAudioPlayerData *
-nautilus_audio_player_play (const char *filename)
-{
- AFfilehandle handle;
- NautilusAudioPlayerData *data;
-
- handle = afOpenFile (filename, "r", NULL);
- if (handle == AF_NULL_FILEHANDLE) {
- return NULL;
- }
-
- data = g_new0 (NautilusAudioPlayerData, 1);
- data->handle = handle;
- data->running = TRUE;
-
- pthread_create (&data->player_id, NULL, player_thread, data);
-
- return data;
-}
-
-void
-nautilus_audio_player_stop (NautilusAudioPlayerData *data)
-{
- if (data == NULL) {
- return;
- }
-
- data->running = FALSE;
- pthread_join (data->player_id, NULL);
-}
-
-
-static void
-esdout_init (ESDInfo *info)
-{
- memset (&info->esd_config, 0, sizeof (ESDConfig));
-
- info->fd = 0;
- info->going = FALSE;
- info->paused = FALSE;
- info->buffer = NULL;
- info->block_size = BUFFER_FRAMES;
- info->rd_index = 0;
- info->wr_index = 0;
- info->output_time_offset = 0;
- info->written = 0;
- info->output_bytes = 0;
- info->hostname = NULL;
- info->esd_config.port = ESD_DEFAULT_PORT;
- info->esd_config.buffer_size = 3000;
- info->esd_config.prebuffer = 25;
-}
-
-static void
-esdout_write (ESDInfo *info, gpointer data, int length)
-{
- int count, offset;
-
- offset = 0;
-
- info->written += length;
-
- while (length > 0) {
- count = MIN (length, info->buffer_size - info->wr_index);
- memcpy ((char *)info->buffer + info->wr_index, (char *)data + offset, count);
- info->wr_index = (info->wr_index + count) % info->buffer_size;
- length -= count;
- offset += count;
- }
-}
-
-
-static gint
-get_latency (ESDInfo *config)
-{
- int fd, amount = 0;
-
-#ifndef HAVE_ESD_GET_LATENCY
- esd_server_info_t *info;
-#endif
-
- fd = esd_open_sound (config->hostname);
- if (fd == -1) {
- return 0;
- }
-
-#ifdef HAVE_ESD_GET_LATENCY
- amount = get_latency (fd);
-#else
- info = esd_get_server_info (fd);
- if (info != NULL) {
- if (info->format & ESD_STEREO) {
- if (info->format & ESD_BITS16)
- amount = (44100 * (ESD_BUF_SIZE + 64)) / info->rate;
- else
- amount = (44100 * (ESD_BUF_SIZE + 128)) / info->rate;
- } else {
- if (info->format & ESD_BITS16)
- amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / info->rate;
- else
- amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / info->rate;
- }
- free (info);
- }
- amount += ESD_BUF_SIZE * 2;
-#endif
- esd_close (fd);
- return amount;
-}
-
-static void *
-esd_stou8 (void *data, gint length)
-{
- int len = length;
- unsigned char *dat = (unsigned char *)data;
- while (len-- > 0)
- *dat++ ^= 0x80;
- return data;
-}
-
-static void *
-esd_utos16sw (void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat = GUINT16_SWAP_LE_BE ( *dat ) ^ 0x8000;
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void *
-esd_utos16 (void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat ^= 0x8000;
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void *
-esd_16sw (void *data, gint length)
-{
- int len = length;
- short *dat = data;
- while ( len > 0 ) {
- *dat = GUINT16_SWAP_LE_BE( *dat );
- dat++;
- len-=2;
- }
- return data;
-}
-
-static void
-esdout_setup_format (ESDInfo *info, AudioFormat format, gint rate, gint nch)
-{
- gboolean swap_sign = FALSE;
- gboolean swap_16 = FALSE;
-
- info->format = format;
- info->frequency = rate;
- info->channels = nch;
-
- switch (format) {
- case FORMAT_S8:
- swap_sign = TRUE;
- case FORMAT_U8:
- info->esd_format = ESD_BITS8;
- break;
- case FORMAT_U16_LE:
- case FORMAT_U16_BE:
- case FORMAT_U16_NE:
- swap_sign = TRUE;
- case FORMAT_S16_LE:
- case FORMAT_S16_BE:
- case FORMAT_S16_NE:
- info->esd_format = ESD_BITS16;
- break;
- }
-
-#ifdef WORDS_BIGENDIAN
- if (format == FORMAT_U16_LE || format == FORMAT_S16_LE)
-#else
- if (format == FORMAT_U16_BE || format == FORMAT_S16_BE)
-#endif
- swap_16 = TRUE;
-
- info->esd_translate = (void*(*)())NULL;
- if (info->esd_format == ESD_BITS8) {
- if (swap_sign) {
- info->esd_translate = esd_stou8;
- }
- } else {
- if (swap_sign) {
- if (swap_16) {
- info->esd_translate = esd_utos16sw;
- } else {
- info->esd_translate = esd_utos16;
- }
- } else {
- if (swap_16) {
- info->esd_translate = esd_16sw;
- }
- }
- }
-
- info->bps = rate * nch;
- if (info->esd_format == ESD_BITS16) {
- info->bps *= 2;
- }
-
- if (nch == 1) {
- info->esd_format |= ESD_MONO;
- } else {
- info->esd_format |= ESD_STEREO;
- }
-
- info->esd_format |= ESD_STREAM | ESD_PLAY;
-
- info->latency = ((get_latency (info) * info->frequency) / 44100) * info->channels;
- if (info->format != FORMAT_U8 && info->format != FORMAT_S8) {
- info->latency *= 2;
- }
-}
-
-
-static gint
-esdout_used (ESDInfo *info)
-{
- if (info->wr_index >= info->rd_index) {
- return info->wr_index - info->rd_index;
- }
-
- return info->buffer_size - (info->rd_index - info->wr_index);
-}
-
-static void
-esdout_write_audio (ESDInfo *info, gint length)
-{
- AudioFormat new_format;
- gint new_frequency, new_channels;
- char *data;
-
- data = (char *)info->buffer + info->rd_index;
-
- new_format = info->input_format;
- new_frequency = info->input_frequency;
- new_channels = info->input_channels;
-
- if (new_format != info->format || new_frequency != info->frequency || new_channels != info->channels) {
- info->output_time_offset += (gint) ((info->output_bytes * 1000) / info->ebps);
- info->output_bytes = 0;
- esdout_setup_format (info, new_format, new_frequency, new_channels);
- info->frequency = new_frequency;
- info->channels = new_channels;
- close (info->fd);
- esdout_set_audio_params (info);
- }
-
- if (info->esd_translate) {
- info->output_bytes += write (info->fd, info->esd_translate (data, length), length);
- } else {
- info->output_bytes += write (info->fd, data, length);
- }
-}
-
-
-static void
-esdout_close (ESDInfo *info)
-{
- info->going = FALSE;
- info->wr_index = 0;
- info->rd_index = 0;
- info->going = 0;
- g_free (info->hostname);
- info->hostname = NULL;
- pthread_join (info->buffer_thread, NULL);
-}
-
-static void *
-esdout_loop (void *arg)
-{
- int length, count, used;
- ESDInfo *info;
-
- info = arg;
-
- while (info->going) {
- used = esdout_used (info);
-
- if (used > info->prebuffer_size) {
- info->prebuffer = FALSE;
- }
-
- if (used > 0 && !info->paused && !info->prebuffer) {
- length = MIN (info->block_size, used);
- while (length > 0) {
- count = MIN (length, info->buffer_size - info->rd_index);
- esdout_write_audio (info, count);
- info->rd_index = (info->rd_index + count) % info->buffer_size;
- length -= count;
- }
- } else {
- usleep (10000);
- }
-
- if (info->flush != -1) {
- info->output_time_offset = info->flush;
- info->written = (guint64)(info->flush / 10) * (guint64)(info->input_bps / 100);
- info->rd_index = info->wr_index = info->output_bytes = 0;
- info->flush = -1;
- info->prebuffer = TRUE;
- }
- }
-
- close (info->fd);
- g_free (info->buffer);
-
- while (info->going) {
- usleep (10000);
- }
-
- pthread_exit (NULL);
-
- return (void *) 0;
-}
-
-static void
-esdout_set_audio_params (ESDInfo *info)
-{
- info->fd = esd_play_stream (info->esd_format, info->frequency, info->hostname, PLAYER_STREAM_NAME);
- info->ebps = info->frequency * info->channels;
- if (info->format == FORMAT_U16_BE || info->format == FORMAT_U16_LE || info->format == FORMAT_S16_BE
- || info->format == FORMAT_S16_LE || info->format == FORMAT_S16_NE || info->format == FORMAT_U16_NE) {
- info->ebps *= 2;
- }
-}
-
-static gboolean
-esdout_open (ESDInfo *info, AudioFormat format, gint rate, gint nch)
-{
- esdout_init (info);
-
- esdout_setup_format (info, format, rate, nch);
-
- info->input_format = info->format;
- info->input_channels = info->channels;
- info->input_frequency = info->frequency;
- info->input_bps = info->bps;
-
- info->buffer_size = (info->esd_config.buffer_size * info->input_bps) / 1000;
- if (info->buffer_size < 8192) {
- info->buffer_size = 8192;
- }
-
- info->prebuffer_size = (info->buffer_size * info->esd_config.prebuffer) / 100;
- if (info->buffer_size - info->prebuffer_size < 4096) {
- info->prebuffer_size = info->buffer_size - 4096;
- }
-
- info->buffer = g_malloc0 (info->buffer_size);
-
- info->flush = -1;
- info->prebuffer = TRUE;
- info->wr_index = info->rd_index = info->output_time_offset = info->written = info->output_bytes = 0;
- info->paused = FALSE;
-
- if (info->hostname != NULL) {
- g_free (info->hostname);
- }
-
- if (info->esd_config.use_remote) {
- info->hostname = g_strdup_printf ("%s:%d", info->esd_config.server, info->esd_config.port);
- } else {
- info->hostname = NULL;
- }
-
- esdout_set_audio_params (info);
- if (info->fd == -1) {
- g_free (info->buffer);
- info->buffer = NULL;
- return FALSE;
- }
-
- info->going = TRUE;
-
- pthread_create (&info->buffer_thread, NULL, esdout_loop, info);
-
- return TRUE;
-}
-
-static gboolean
-esdout_playing (ESDInfo *info)
-{
- if (!info->going) {
- return FALSE;
- }
-
- if (esdout_used (info) <= 0) {
- return FALSE;
- }
-
- return TRUE;
-}
-
diff --git a/libnautilus-private/nautilus-audio-player.h b/libnautilus-private/nautilus-audio-player.h
deleted file mode 100644
index 6c44be28f..000000000
--- a/libnautilus-private/nautilus-audio-player.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-audio-player.h - Simple threaded audio file playback.
-
- Copyright (C) 2001 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Gene Z. Ragan <gzr@eazel.com>
-*/
-
-#ifndef NAUTILUS_AUDIO_PLAYER_H
-#define NAUTILUS_AUDIO_PLAYER_H
-
-#include <config.h>
-#include <sys/types.h>
-
-#include <audiofile.h>
-#include <pthread.h>
-
-#include <glib/gtypes.h>
-
-typedef struct {
- gboolean use_remote;
- char *server;
- int port;
- int buffer_size;
- int prebuffer;
-} ESDConfig;
-
-typedef struct {
- AFfilehandle handle;
- pthread_t player_id;
- gboolean running;
- ESDConfig esd_config;
-} NautilusAudioPlayerData;
-
-
-NautilusAudioPlayerData *nautilus_audio_player_play (const char *filename);
-void nautilus_audio_player_stop (NautilusAudioPlayerData *data);
-
-#endif
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index c45290b77..ff68097c8 100644
--- a/libnautilus-private/nautilus-bookmark.c
+++ b/libnautilus-private/nautilus-bookmark.c
@@ -25,7 +25,7 @@
#include <config.h>
#include "nautilus-bookmark.h"
-#include "nautilus-icon-factory.h"
+#include "nautilus-file.h"
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
@@ -35,11 +35,11 @@
#include <gtk/gtkimage.h>
#include <gtk/gtkimagemenuitem.h>
#include <gtk/gtksignal.h>
+#include <gtk/gtkiconfactory.h>
#include <libgnome/gnome-macros.h>
#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gthemedicon.h>
+#include <libnautilus-private/nautilus-file.h>
enum {
APPEARANCE_CHANGED,
@@ -58,8 +58,8 @@ struct NautilusBookmarkDetails
{
char *name;
gboolean has_custom_name;
- char *uri;
- char *icon;
+ GFile *location;
+ GIcon *icon;
NautilusFile *file;
char *scroll_file;
@@ -85,8 +85,10 @@ nautilus_bookmark_finalize (GObject *object)
nautilus_bookmark_disconnect_file (bookmark);
g_free (bookmark->details->name);
- g_free (bookmark->details->uri);
- g_free (bookmark->details->icon);
+ g_object_unref (bookmark->details->location);
+ if (bookmark->details->icon) {
+ g_object_unref (bookmark->details->icon);
+ }
g_free (bookmark->details->scroll_file);
g_free (bookmark->details);
@@ -153,9 +155,9 @@ nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b)
return 1;
}
- if (!gnome_vfs_uris_match (bookmark_a->details->uri,
- bookmark_b->details->uri)) {
- return 1;
+ if (g_file_equal (bookmark_a->details->location,
+ bookmark_b->details->location)) {
+ return 0;
}
return 0;
@@ -183,8 +185,8 @@ nautilus_bookmark_compare_uris (gconstpointer a, gconstpointer b)
bookmark_a = NAUTILUS_BOOKMARK (a);
bookmark_b = NAUTILUS_BOOKMARK (b);
- return !gnome_vfs_uris_match (bookmark_a->details->uri,
- bookmark_b->details->uri);
+ return !g_file_equal (bookmark_a->details->location,
+ bookmark_b->details->location);
}
NautilusBookmark *
@@ -193,7 +195,7 @@ nautilus_bookmark_copy (NautilusBookmark *bookmark)
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new_with_icon (
- bookmark->details->uri,
+ bookmark->details->location,
bookmark->details->name,
bookmark->details->has_custom_name,
bookmark->details->icon);
@@ -219,10 +221,13 @@ nautilus_bookmark_get_has_custom_name (NautilusBookmark *bookmark)
GdkPixbuf *
nautilus_bookmark_get_pixbuf (NautilusBookmark *bookmark,
- GtkIconSize icon_size)
+ GtkIconSize stock_size)
{
GdkPixbuf *result;
- char *icon;
+ GIcon *icon;
+ NautilusIconInfo *info;
+ int pixel_size;
+
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL);
@@ -230,18 +235,16 @@ nautilus_bookmark_get_pixbuf (NautilusBookmark *bookmark,
if (icon == NULL) {
return NULL;
}
-
- result = nautilus_icon_factory_get_pixbuf_for_icon_with_stock_size
- (icon, NULL,
- icon_size, NULL, NULL,
- TRUE, NULL);
- g_free (icon);
+ pixel_size = nautilus_get_icon_size_for_stock_size (stock_size);
+ info = nautilus_icon_info_lookup (icon, pixel_size);
+ result = nautilus_icon_info_get_pixbuf_at_size (info, pixel_size);
+ g_object_unref (info);
return result;
}
-char *
+GIcon *
nautilus_bookmark_get_icon (NautilusBookmark *bookmark)
{
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL);
@@ -249,11 +252,14 @@ nautilus_bookmark_get_icon (NautilusBookmark *bookmark)
/* Try to connect a file in case file exists now but didn't earlier. */
nautilus_bookmark_connect_file (bookmark);
- return g_strdup (bookmark->details->icon);
+ if (bookmark->details->icon) {
+ return g_object_ref (bookmark->details->icon);
+ }
+ return NULL;
}
-char *
-nautilus_bookmark_get_uri (NautilusBookmark *bookmark)
+GFile *
+nautilus_bookmark_get_location (NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
@@ -265,7 +271,19 @@ nautilus_bookmark_get_uri (NautilusBookmark *bookmark)
*/
nautilus_bookmark_connect_file (bookmark);
- return g_strdup (bookmark->details->uri);
+ return g_object_ref (bookmark->details->location);
+}
+
+char *
+nautilus_bookmark_get_uri (NautilusBookmark *bookmark)
+{
+ GFile *file;
+ char *uri;
+
+ file = nautilus_bookmark_get_location (bookmark);
+ uri = g_file_get_uri (file);
+ g_object_unref (file);
+ return uri;
}
@@ -303,12 +321,16 @@ nautilus_bookmark_set_has_custom_name (NautilusBookmark *bookmark, gboolean has_
static gboolean
nautilus_bookmark_icon_is_different (NautilusBookmark *bookmark,
- char *new_icon)
+ GIcon *new_icon)
{
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (new_icon != NULL);
- return eel_strcmp (bookmark->details->icon, new_icon) != 0;
+ if (bookmark->details->icon == NULL) {
+ return new_icon == NULL;
+ }
+
+ return !g_icon_equal (bookmark->details->icon, new_icon) != 0;
}
/**
@@ -318,7 +340,7 @@ nautilus_bookmark_icon_is_different (NautilusBookmark *bookmark,
static gboolean
nautilus_bookmark_update_icon (NautilusBookmark *bookmark)
{
- char *new_icon;
+ GIcon *new_icon;
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -326,14 +348,17 @@ nautilus_bookmark_update_icon (NautilusBookmark *bookmark)
return FALSE;
}
- if (nautilus_icon_factory_is_icon_ready_for_file (bookmark->details->file)) {
- new_icon = nautilus_icon_factory_get_icon_for_file (bookmark->details->file, FALSE);
+ if (nautilus_file_check_if_ready (bookmark->details->file,
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
+ new_icon = nautilus_file_get_gicon (bookmark->details->file, 0);
if (nautilus_bookmark_icon_is_different (bookmark, new_icon)) {
- g_free (bookmark->details->icon);
+ if (bookmark->details->icon) {
+ g_object_unref (bookmark->details->icon);
+ }
bookmark->details->icon = new_icon;
return TRUE;
}
- g_free (new_icon);
+ g_object_unref (new_icon);
}
return FALSE;
@@ -342,25 +367,26 @@ nautilus_bookmark_update_icon (NautilusBookmark *bookmark)
static void
bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
{
- char *file_uri;
+ GFile *location;
gboolean should_emit_appearance_changed_signal;
gboolean should_emit_contents_changed_signal;
-
+ char *display_name;
+
g_assert (NAUTILUS_IS_FILE (file));
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
g_assert (file == bookmark->details->file);
should_emit_appearance_changed_signal = FALSE;
should_emit_contents_changed_signal = FALSE;
- file_uri = nautilus_file_get_uri (file);
+ location = nautilus_file_get_location (file);
- if (!gnome_vfs_uris_match (bookmark->details->uri, file_uri) &&
+ if (!g_file_equal (bookmark->details->location, location) &&
!nautilus_file_is_in_trash (file)) {
- g_free (bookmark->details->uri);
- bookmark->details->uri = file_uri;
+ g_object_unref (bookmark->details->location);
+ bookmark->details->location = location;
should_emit_contents_changed_signal = TRUE;
} else {
- g_free (file_uri);
+ g_object_unref (location);
}
if (nautilus_file_is_gone (file) ||
@@ -380,6 +406,18 @@ bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
should_emit_appearance_changed_signal = TRUE;
}
+ if (!bookmark->details->has_custom_name) {
+ display_name = nautilus_file_get_display_name (file);
+
+ if (strcmp (bookmark->details->name, display_name) != 0) {
+ g_free (bookmark->details->name);
+ bookmark->details->name = display_name;
+ should_emit_appearance_changed_signal = TRUE;
+ } else {
+ g_free (display_name);
+ }
+ }
+
if (should_emit_appearance_changed_signal) {
g_signal_emit (bookmark, signals[APPEARANCE_CHANGED], 0);
}
@@ -401,7 +439,9 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
const char *icon_name;
- g_free (bookmark->details->icon);
+ if (bookmark->details->icon) {
+ g_object_unref (bookmark->details->icon);
+ }
if (nautilus_bookmark_uri_known_not_to_exist (bookmark)) {
icon_name = MISSING_BOOKMARK_ICON_NAME;
@@ -409,7 +449,7 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
icon_name = GENERIC_BOOKMARK_ICON_NAME;
}
- bookmark->details->icon = g_strdup (icon_name);
+ bookmark->details->icon = g_themed_icon_new (icon_name);
}
/**
@@ -427,9 +467,9 @@ nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
*
**/
NautilusBookmark *
-nautilus_bookmark_new (const char *uri, const char *name)
+nautilus_bookmark_new (GFile *location, const char *name)
{
- return nautilus_bookmark_new_with_icon (uri, name, FALSE, NULL);
+ return nautilus_bookmark_new_with_icon (location, name, FALSE, NULL);
}
static void
@@ -446,7 +486,7 @@ nautilus_bookmark_disconnect_file (NautilusBookmark *bookmark)
}
if (bookmark->details->icon != NULL) {
- g_free (bookmark->details->icon);
+ g_object_unref (bookmark->details->icon);
bookmark->details->icon = NULL;
}
}
@@ -454,6 +494,8 @@ nautilus_bookmark_disconnect_file (NautilusBookmark *bookmark)
static void
nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
{
+ char *display_name;
+
g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
if (bookmark->details->file != NULL) {
@@ -461,7 +503,7 @@ nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
}
if (!nautilus_bookmark_uri_known_not_to_exist (bookmark)) {
- bookmark->details->file = nautilus_file_get (bookmark->details->uri);
+ bookmark->details->file = nautilus_file_get (bookmark->details->location);
g_assert (!nautilus_file_is_gone (bookmark->details->file));
g_signal_connect_object (bookmark->details->file, "changed",
@@ -476,22 +518,35 @@ nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
nautilus_bookmark_set_icon_to_default (bookmark);
}
}
+
+ if (!bookmark->details->has_custom_name &&
+ bookmark->details->file &&
+ nautilus_file_check_if_ready (bookmark->details->file, NAUTILUS_FILE_ATTRIBUTE_INFO)) {
+ display_name = nautilus_file_get_display_name (bookmark->details->file);
+ if (strcmp (bookmark->details->name, display_name) != 0) {
+ g_free (bookmark->details->name);
+ bookmark->details->name = display_name;
+ } else {
+ g_free (display_name);
+ }
+ }
}
NautilusBookmark *
-nautilus_bookmark_new_with_icon (const char *uri, const char *name, gboolean has_custom_name,
- const char *icon)
+nautilus_bookmark_new_with_icon (GFile *location, const char *name, gboolean has_custom_name,
+ GIcon *icon)
{
NautilusBookmark *new_bookmark;
new_bookmark = NAUTILUS_BOOKMARK (g_object_new (NAUTILUS_TYPE_BOOKMARK, NULL));
- g_object_ref (new_bookmark);
- gtk_object_sink (GTK_OBJECT (new_bookmark));
+ g_object_ref_sink (new_bookmark);
new_bookmark->details->name = g_strdup (name);
- new_bookmark->details->uri = g_strdup (uri);
+ new_bookmark->details->location = g_object_ref (location);
new_bookmark->details->has_custom_name = has_custom_name;
- new_bookmark->details->icon = g_strdup (icon);
+ if (icon) {
+ new_bookmark->details->icon = g_object_ref (icon);
+ }
nautilus_bookmark_connect_file (new_bookmark);
@@ -552,7 +607,7 @@ nautilus_bookmark_uri_known_not_to_exist (NautilusBookmark *bookmark)
gboolean exists;
/* Convert to a path, returning FALSE if not local. */
- path_name = gnome_vfs_get_local_path_from_uri (bookmark->details->uri);
+ path_name = g_file_get_path (bookmark->details->location);
if (path_name == NULL) {
return FALSE;
}
diff --git a/libnautilus-private/nautilus-bookmark.h b/libnautilus-private/nautilus-bookmark.h
index 17a4ad18e..92341af22 100644
--- a/libnautilus-private/nautilus-bookmark.h
+++ b/libnautilus-private/nautilus-bookmark.h
@@ -27,8 +27,8 @@
#include <gtk/gtkenums.h>
#include <gtk/gtkwidget.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-
+#include <gio/gfile.h>
+#include <gio/gicon.h>
typedef struct NautilusBookmark NautilusBookmark;
#define NAUTILUS_TYPE_BOOKMARK \
@@ -68,16 +68,17 @@ struct NautilusBookmarkClass {
typedef struct NautilusBookmarkClass NautilusBookmarkClass;
GType nautilus_bookmark_get_type (void);
-NautilusBookmark * nautilus_bookmark_new (const char *uri,
+NautilusBookmark * nautilus_bookmark_new (GFile *location,
const char *name);
-NautilusBookmark * nautilus_bookmark_new_with_icon (const char *uri,
+NautilusBookmark * nautilus_bookmark_new_with_icon (GFile *location,
const char *name,
gboolean has_custom_name,
- const char *icon);
+ GIcon *icon);
NautilusBookmark * nautilus_bookmark_copy (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_name (NautilusBookmark *bookmark);
+GFile * nautilus_bookmark_get_location (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_uri (NautilusBookmark *bookmark);
-char * nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
+GIcon * nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
gboolean nautilus_bookmark_get_has_custom_name (NautilusBookmark *bookmark);
gboolean nautilus_bookmark_set_name (NautilusBookmark *bookmark,
const char *new_name);
diff --git a/libnautilus-private/nautilus-column-chooser.c b/libnautilus-private/nautilus-column-chooser.c
index 383e89d1c..f0c016964 100644
--- a/libnautilus-private/nautilus-column-chooser.c
+++ b/libnautilus-private/nautilus-column-chooser.c
@@ -26,8 +26,6 @@
#include "nautilus-column-chooser.h"
#include <string.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include <gtk/gtkalignment.h>
#include <gtk/gtkbutton.h>
#include <gtk/gtkcellrenderertext.h>
@@ -71,19 +69,12 @@ enum {
};
static guint signals[LAST_SIGNAL];
-static void nautilus_column_chooser_class_init (NautilusColumnChooserClass *chooser_class);
-static void nautilus_column_chooser_init (NautilusColumnChooser *chooser);
-static void nautilus_column_chooser_destroy (GtkObject *object);
-static void nautilus_column_chooser_finalize (GObject *object);
-EEL_CLASS_BOILERPLATE (NautilusColumnChooser, nautilus_column_chooser, GTK_TYPE_HBOX);
+G_DEFINE_TYPE(NautilusColumnChooser, nautilus_column_chooser, GTK_TYPE_HBOX);
static void
nautilus_column_chooser_class_init (NautilusColumnChooserClass *chooser_class)
{
- G_OBJECT_CLASS (chooser_class)->finalize = nautilus_column_chooser_finalize;
- GTK_OBJECT_CLASS (chooser_class)->destroy = nautilus_column_chooser_destroy;
-
signals[CHANGED] = g_signal_new
("changed",
G_TYPE_FROM_CLASS (chooser_class),
@@ -498,24 +489,20 @@ nautilus_column_chooser_init (NautilusColumnChooser *chooser)
G_CALLBACK (row_deleted_callback), chooser);
}
-static void
-nautilus_column_chooser_destroy (GtkObject *object)
-{
- NautilusColumnChooser *chooser;
-
- chooser = NAUTILUS_COLUMN_CHOOSER (object);
-}
-
-static void
-nautilus_column_chooser_finalize (GObject *object)
-{
-}
-
static void
set_visible_columns (NautilusColumnChooser *chooser,
- GList *visible_columns)
+ char **visible_columns)
{
+ GHashTable *visible_columns_hash;
GtkTreeIter iter;
+ int i;
+
+ visible_columns_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0; visible_columns[i] != NULL; ++i) {
+ g_hash_table_insert (visible_columns_hash,
+ visible_columns[i],
+ visible_columns[i]);
+ }
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->details->store),
&iter)) {
@@ -528,7 +515,7 @@ set_visible_columns (NautilusColumnChooser *chooser,
COLUMN_NAME, &name,
-1);
- visible = (eel_g_str_list_index (visible_columns, name) != -1);
+ visible = (g_hash_table_lookup (visible_columns_hash, name) != NULL);
gtk_list_store_set (chooser->details->store,
&iter,
@@ -537,17 +524,18 @@ set_visible_columns (NautilusColumnChooser *chooser,
g_free (name);
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser->details->store), &iter));
- }
+ }
+
+ g_hash_table_destroy (visible_columns_hash);
}
-static GList *
+static char **
get_column_names (NautilusColumnChooser *chooser, gboolean only_visible)
{
-
- GList *ret;
+ GPtrArray *ret;
GtkTreeIter iter;
-
- ret = NULL;
+
+ ret = g_ptr_array_new ();
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (chooser->details->store),
&iter)) {
do {
@@ -559,14 +547,15 @@ get_column_names (NautilusColumnChooser *chooser, gboolean only_visible)
COLUMN_NAME, &name,
-1);
if (!only_visible || visible) {
- /* give ownership to the list */
- ret = g_list_prepend (ret, name);
+ /* give ownership to the array */
+ g_ptr_array_add (ret, name);
}
-
+
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser->details->store), &iter));
}
+ g_ptr_array_add (ret, NULL);
- return g_list_reverse (ret);
+ return (char **) g_ptr_array_free (ret, FALSE);
}
static gboolean
@@ -603,7 +592,7 @@ get_column_iter (NautilusColumnChooser *chooser,
static void
set_column_order (NautilusColumnChooser *chooser,
- GList *column_order)
+ char **column_order)
{
GList *columns;
@@ -646,8 +635,8 @@ set_column_order (NautilusColumnChooser *chooser,
void
nautilus_column_chooser_set_settings (NautilusColumnChooser *chooser,
- GList *visible_columns,
- GList *column_order)
+ char **visible_columns,
+ char **column_order)
{
g_return_if_fail (NAUTILUS_IS_COLUMN_CHOOSER (chooser));
g_return_if_fail (visible_columns != NULL);
@@ -661,13 +650,13 @@ nautilus_column_chooser_set_settings (NautilusColumnChooser *chooser,
void
nautilus_column_chooser_get_settings (NautilusColumnChooser *chooser,
- GList **visible_columns,
- GList **column_order)
+ char ***visible_columns,
+ char ***column_order)
{
g_return_if_fail (NAUTILUS_IS_COLUMN_CHOOSER (chooser));
g_return_if_fail (visible_columns != NULL);
g_return_if_fail (column_order != NULL);
-
+
*visible_columns = get_column_names (chooser, TRUE);
*column_order = get_column_names (chooser, FALSE);
}
@@ -678,5 +667,3 @@ nautilus_column_chooser_new (void)
return g_object_new (NAUTILUS_TYPE_COLUMN_CHOOSER, NULL);
}
-
-
diff --git a/libnautilus-private/nautilus-column-chooser.h b/libnautilus-private/nautilus-column-chooser.h
index 677f15280..a1d781f51 100644
--- a/libnautilus-private/nautilus-column-chooser.h
+++ b/libnautilus-private/nautilus-column-chooser.h
@@ -50,12 +50,11 @@ typedef struct {
GType nautilus_column_chooser_get_type (void);
GtkWidget *nautilus_column_chooser_new (void);
-void nautilus_column_chooser_set_settings (NautilusColumnChooser *chooser,
- GList *visible_columns,
- GList *column_order);
+void nautilus_column_chooser_set_settings (NautilusColumnChooser *chooser,
+ char **visible_columns,
+ char **column_order);
void nautilus_column_chooser_get_settings (NautilusColumnChooser *chooser,
- GList **visible_columns,
- GList **column_order);
-
+ char ***visible_columns,
+ char ***column_order);
#endif /* NAUTILUS_COLUMN_CHOOSER_H */
diff --git a/libnautilus-private/nautilus-column-utilities.c b/libnautilus-private/nautilus-column-utilities.c
index b467d952c..4aeaf9a47 100644
--- a/libnautilus-private/nautilus-column-utilities.c
+++ b/libnautilus-private/nautilus-column-utilities.c
@@ -190,18 +190,31 @@ nautilus_column_list_free (GList *columns)
}
static int
-column_compare (NautilusColumn *a, NautilusColumn *b, GList *column_order)
+strv_index (char **strv, const char *str)
+{
+ int i;
+
+ for (i = 0; strv[i] != NULL; ++i) {
+ if (strcmp (strv[i], str) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static int
+column_compare (NautilusColumn *a, NautilusColumn *b, char **column_order)
{
int index_a;
int index_b;
char *name;
g_object_get (G_OBJECT (a), "name", &name, NULL);
- index_a = eel_g_str_list_index (column_order, name);
+ index_a = strv_index (column_order, name);
g_free (name);
g_object_get (G_OBJECT (b), "name", &name, NULL);
- index_b = eel_g_str_list_index (column_order, name);
+ index_b = strv_index (column_order, name);
g_free (name);
if (index_a == index_b) {
@@ -226,8 +239,8 @@ column_compare (NautilusColumn *a, NautilusColumn *b, GList *column_order)
}
GList *
-nautilus_sort_columns (GList *columns,
- GList *column_order)
+nautilus_sort_columns (GList *columns,
+ char **column_order)
{
return g_list_sort_with_data (columns,
(GCompareDataFunc)column_compare,
diff --git a/libnautilus-private/nautilus-column-utilities.h b/libnautilus-private/nautilus-column-utilities.h
index 48611db6c..a8306519a 100644
--- a/libnautilus-private/nautilus-column-utilities.h
+++ b/libnautilus-private/nautilus-column-utilities.h
@@ -32,7 +32,7 @@ GList *nautilus_column_list_copy (GList *columns);
void nautilus_column_list_free (GList *columns);
GList *nautilus_sort_columns (GList *columns,
- GList *column_order);
+ char **column_order);
#endif /* NAUTILUS_COLUMN_UTILITIES_H */
diff --git a/libnautilus-private/nautilus-customization-data.c b/libnautilus-private/nautilus-customization-data.c
index 57f565f45..29d4d96a5 100644
--- a/libnautilus-private/nautilus-customization-data.c
+++ b/libnautilus-private/nautilus-customization-data.c
@@ -43,8 +43,6 @@
#include <librsvg/rsvg.h>
#include <glib/gi18n.h>
#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-directory.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libxml/parser.h>
#include <stdlib.h>
#include <string.h>
@@ -74,14 +72,48 @@ struct NautilusCustomizationData {
/* The Property here should be one of "emblems", "colors" or "patterns" */
-static char * get_global_customization_uri (const char *customization_name);
-static char * get_private_customization_uri (const char *customization_name);
+static char * get_global_customization_path (const char *customization_name);
+static char * get_private_customization_path (const char *customization_name);
static char * get_file_path_for_mode (const NautilusCustomizationData *data,
const char *file_name);
static char* format_name_for_display (NautilusCustomizationData *data, const char *name);
static char* strip_extension (const char* string_to_strip);
static void load_name_map_hash_table (NautilusCustomizationData *data);
+
+static gboolean
+read_all_children (char *filename,
+ const char *attributes,
+ GList **list_out)
+{
+ GFileEnumerator *enumerator;
+ GList *list;
+ GFile *file;
+ GFileInfo *info;
+
+ file = g_file_new_for_path (filename);
+
+ enumerator = g_file_enumerate_children (file, attributes, 0, NULL, NULL);
+ if (enumerator == NULL) {
+ return FALSE;
+ }
+
+ list = NULL;
+ do {
+ info = g_file_enumerator_next_file (enumerator, NULL, NULL);
+ if (info) {
+ list = g_list_prepend (list, info);
+ }
+ } while (info != NULL);
+
+ g_object_unref (enumerator);
+ g_object_unref (file);
+
+ *list_out = g_list_reverse (list);
+ return TRUE;
+}
+
+
NautilusCustomizationData*
nautilus_customization_data_new (const char *customization_name,
gboolean show_public_customizations,
@@ -89,42 +121,40 @@ nautilus_customization_data_new (const char *customization_name,
int maximum_icon_width)
{
NautilusCustomizationData *data;
- char *public_directory_uri, *private_directory_uri;
+ char *public_directory_path, *private_directory_path;
char *temp_str;
- GnomeVFSResult public_result, private_result;
+ gboolean public_result, private_result;
data = g_new0 (NautilusCustomizationData, 1);
- public_result = GNOME_VFS_OK;
+ public_result = TRUE;
if (show_public_customizations) {
- public_directory_uri = get_global_customization_uri (customization_name);
-
+ public_directory_path = get_global_customization_path (customization_name);
- public_result = gnome_vfs_directory_list_load (&data->public_file_list,
- public_directory_uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- g_free (public_directory_uri);
+ public_result = read_all_children (public_directory_path,
+ G_FILE_ATTRIBUTE_STD_NAME ","
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE,
+ &data->public_file_list);
+ g_free (public_directory_path);
}
- private_directory_uri = get_private_customization_uri (customization_name);
- private_result = gnome_vfs_directory_list_load (&data->private_file_list,
- private_directory_uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- g_free (private_directory_uri);
- if (public_result != GNOME_VFS_OK &&
- private_result != GNOME_VFS_OK) {
+ private_directory_path = get_private_customization_path (customization_name);
+ private_result = read_all_children (private_directory_path,
+ G_FILE_ATTRIBUTE_STD_NAME ","
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE,
+ &data->private_file_list);
+ g_free (private_directory_path);
+ if (!public_result && !private_result) {
g_warning ("Couldn't read any of the emblem directories\n");
g_free (data);
return NULL;
}
- if (private_result == GNOME_VFS_OK) {
+ if (private_result) {
data->reading_mode = READ_PRIVATE_CUSTOMIZATIONS;
data->current_file_list = data->private_file_list;
}
- if (show_public_customizations && public_result == GNOME_VFS_OK) {
+ if (show_public_customizations && public_result) {
data->reading_mode = READ_PUBLIC_CUSTOMIZATIONS;
data->current_file_list = data->public_file_list;
}
@@ -151,27 +181,27 @@ nautilus_customization_data_new (const char *customization_name,
return data;
}
-GnomeVFSResult
+gboolean
nautilus_customization_data_get_next_element_for_display (NautilusCustomizationData *data,
char **emblem_name,
GdkPixbuf **pixbuf_out,
char **label_out)
{
- GnomeVFSFileInfo *current_file_info;
+ GFileInfo *current_file_info;
char *image_file_name;
GdkPixbuf *pixbuf;
GdkPixbuf *orig_pixbuf;
gboolean is_reset_image;
- g_return_val_if_fail (data != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
- g_return_val_if_fail (emblem_name != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
- g_return_val_if_fail (pixbuf_out != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
- g_return_val_if_fail (label_out != NULL, GNOME_VFS_ERROR_BAD_PARAMETERS);
+ g_return_val_if_fail (data != NULL, FALSE);
+ g_return_val_if_fail (emblem_name != NULL, FALSE);
+ g_return_val_if_fail (pixbuf_out != NULL, FALSE);
+ g_return_val_if_fail (label_out != NULL, FALSE);
if (data->current_file_list == NULL) {
if (data->reading_mode == READ_PUBLIC_CUSTOMIZATIONS) {
if (data->private_file_list == NULL) {
- return GNOME_VFS_ERROR_EOF;
+ return FALSE;
}
data->reading_mode = READ_PRIVATE_CUSTOMIZATIONS;
data->current_file_list = data->private_file_list;
@@ -181,7 +211,7 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD
label_out);
}
else {
- return GNOME_VFS_ERROR_EOF;
+ return FALSE;
}
}
@@ -191,8 +221,8 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD
g_assert (current_file_info != NULL);
- if (!eel_istr_has_prefix (current_file_info->mime_type, "image/")
- || eel_istr_has_prefix (current_file_info->name, ".")) {
+ if (!eel_istr_has_prefix (g_file_info_get_content_type (current_file_info), "image/")
+ || eel_istr_has_prefix (g_file_info_get_name (current_file_info), ".")) {
return nautilus_customization_data_get_next_element_for_display (data,
emblem_name,
pixbuf_out,
@@ -200,7 +230,7 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD
}
image_file_name = get_file_path_for_mode (data,
- current_file_info->name);
+ g_file_info_get_name (current_file_info));
orig_pixbuf = gdk_pixbuf_new_from_file (image_file_name, NULL);
if (orig_pixbuf == NULL) {
@@ -218,9 +248,9 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD
label_out);
}
- is_reset_image = eel_strcmp(current_file_info->name, RESET_IMAGE_NAME) == 0;
+ is_reset_image = eel_strcmp(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0;
- *emblem_name = g_strdup (current_file_info->name);
+ *emblem_name = g_strdup (g_file_info_get_name (current_file_info));
if (strcmp (data->customization_name, "patterns") == 0 &&
data->pattern_frame != NULL) {
@@ -235,12 +265,12 @@ nautilus_customization_data_get_next_element_for_display (NautilusCustomizationD
*pixbuf_out = pixbuf;
- *label_out = format_name_for_display (data, current_file_info->name);
+ *label_out = format_name_for_display (data, g_file_info_get_name (current_file_info));
if (data->reading_mode == READ_PRIVATE_CUSTOMIZATIONS) {
data->private_data_was_displayed = TRUE;
}
- return GNOME_VFS_OK;
+ return TRUE;
}
gboolean
@@ -259,8 +289,8 @@ nautilus_customization_data_destroy (NautilusCustomizationData *data)
g_object_unref (data->pattern_frame);
}
- gnome_vfs_file_info_list_free (data->public_file_list);
- gnome_vfs_file_info_list_free (data->private_file_list);
+ eel_g_object_list_free (data->public_file_list);
+ eel_g_object_list_free (data->private_file_list);
if (data->name_map_hash != NULL) {
g_hash_table_destroy (data->name_map_hash);
@@ -279,19 +309,11 @@ nautilus_customization_data_destroy (NautilusCustomizationData *data)
Return value: The directory name where the customization's
public pixmaps are stored */
static char *
-get_global_customization_uri (const char *customization_name)
+get_global_customization_path (const char *customization_name)
{
- char *directory_path, *directory_uri;
-
- directory_path = g_build_filename (NAUTILUS_DATADIR,
- customization_name,
- NULL);
- directory_uri = gnome_vfs_get_uri_from_local_path (directory_path);
-
- g_free (directory_path);
-
- return directory_uri;
-
+ return g_build_filename (NAUTILUS_DATADIR,
+ customization_name,
+ NULL);
}
@@ -303,20 +325,18 @@ get_global_customization_uri (const char *customization_name)
Return value: The directory name where the customization's
user-specific pixmaps are stored */
static char *
-get_private_customization_uri (const char *customization_name)
+get_private_customization_path (const char *customization_name)
{
char *user_directory;
- char *directory_path, *directory_uri;
+ char *directory_path;
user_directory = nautilus_get_user_directory ();
directory_path = g_build_filename (user_directory,
customization_name,
NULL);
g_free (user_directory);
- directory_uri = gnome_vfs_get_uri_from_local_path (directory_path);
- g_free (directory_path);
- return directory_uri;
+ return directory_path;
}
@@ -324,20 +344,18 @@ static char *
get_file_path_for_mode (const NautilusCustomizationData *data,
const char *file_name)
{
- char *directory_uri, *uri, *directory_name;
+ char *directory_path, *file;
if (data->reading_mode == READ_PUBLIC_CUSTOMIZATIONS) {
- directory_uri = get_global_customization_uri (data->customization_name);
+ directory_path = get_global_customization_path (data->customization_name);
}
else {
- directory_uri = get_private_customization_uri (data->customization_name);
+ directory_path = get_private_customization_path (data->customization_name);
}
- uri = g_build_filename (directory_uri, file_name, NULL);
- g_free (directory_uri);
- directory_name = gnome_vfs_get_local_path_from_uri (uri);
- g_free (uri);
+ file = g_build_filename (directory_path, file_name, NULL);
+ g_free (directory_path);
- return directory_name;
+ return file;
}
diff --git a/libnautilus-private/nautilus-customization-data.h b/libnautilus-private/nautilus-customization-data.h
index 4966c6eff..b68dffe78 100644
--- a/libnautilus-private/nautilus-customization-data.h
+++ b/libnautilus-private/nautilus-customization-data.h
@@ -32,7 +32,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtklabel.h>
-#include <libgnomevfs/gnome-vfs-types.h>
#define RESET_IMAGE_NAME "reset.png"
@@ -51,7 +50,7 @@ NautilusCustomizationData* nautilus_customization_data_new
* object_pixbuf - Pixbuf for graphical display of the object.
* object_label - Textual label display of the object.
*/
-GnomeVFSResult nautilus_customization_data_get_next_element_for_display (NautilusCustomizationData *data,
+gboolean nautilus_customization_data_get_next_element_for_display (NautilusCustomizationData *data,
char **object_name,
GdkPixbuf **object_pixbuf,
char **object_label);
diff --git a/libnautilus-private/nautilus-desktop-directory-file.c b/libnautilus-private/nautilus-desktop-directory-file.c
index e0c4db81d..d55298ce2 100644
--- a/libnautilus-private/nautilus-desktop-directory-file.c
+++ b/libnautilus-private/nautilus-desktop-directory-file.c
@@ -69,7 +69,7 @@ typedef struct {
static void nautilus_desktop_directory_file_init (gpointer object,
- gpointer klass);
+ gpointer klass);
static void nautilus_desktop_directory_file_class_init (gpointer klass);
EEL_CLASS_BOILERPLATE (NautilusDesktopDirectoryFile,
@@ -370,12 +370,6 @@ desktop_directory_file_check_if_ready (NautilusFile *file,
delegated_attributes);
}
-static GnomeVFSFileType
-desktop_directory_file_get_file_type (NautilusFile *file)
-{
- return GNOME_VFS_FILE_TYPE_DIRECTORY;
-}
-
static gboolean
desktop_directory_file_get_item_count (NautilusFile *file,
guint *count,
@@ -402,7 +396,7 @@ desktop_directory_file_get_deep_counts (NautilusFile *file,
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size)
+ goffset *total_size)
{
NautilusDesktopDirectoryFile *desktop_file;
NautilusRequestStatus status;
@@ -464,7 +458,7 @@ nautilus_desktop_directory_file_init (gpointer object, gpointer klass)
desktop_file = NAUTILUS_DESKTOP_DIRECTORY_FILE (object);
- desktop_directory = NAUTILUS_DESKTOP_DIRECTORY (nautilus_directory_get (EEL_DESKTOP_URI));
+ desktop_directory = NAUTILUS_DESKTOP_DIRECTORY (nautilus_directory_get_by_uri (EEL_DESKTOP_URI));
desktop_file->details = g_new0 (NautilusDesktopDirectoryFileDetails, 1);
desktop_file->details->desktop_directory = desktop_directory;
@@ -473,7 +467,7 @@ nautilus_desktop_directory_file_init (gpointer object, gpointer klass)
(desktop_callback_hash, desktop_callback_equal);
desktop_file->details->monitors = g_hash_table_new_full (NULL, NULL,
NULL, monitor_destroy);
-
+
real_dir = nautilus_desktop_directory_get_real_directory (desktop_directory);
real_dir_file = nautilus_directory_get_corresponding_file (real_dir);
nautilus_directory_unref (real_dir);
@@ -537,12 +531,13 @@ nautilus_desktop_directory_file_class_init (gpointer klass)
object_class->finalize = desktop_finalize;
+ file_class->default_file_type = G_FILE_TYPE_DIRECTORY;
+
file_class->monitor_add = desktop_directory_file_monitor_add;
file_class->monitor_remove = desktop_directory_file_monitor_remove;
file_class->call_when_ready = desktop_directory_file_call_when_ready;
file_class->cancel_call_when_ready = desktop_directory_file_cancel_call_when_ready;
file_class->check_if_ready = desktop_directory_file_check_if_ready;
- file_class->get_file_type = desktop_directory_file_get_file_type;
file_class->get_item_count = desktop_directory_file_get_item_count;
file_class->get_deep_counts = desktop_directory_file_get_deep_counts;
file_class->get_date = desktop_directory_file_get_date;
diff --git a/libnautilus-private/nautilus-desktop-directory.c b/libnautilus-private/nautilus-desktop-directory.c
index 96ddf3d58..3d5d50dd6 100644
--- a/libnautilus-private/nautilus-desktop-directory.c
+++ b/libnautilus-private/nautilus-desktop-directory.c
@@ -33,7 +33,6 @@
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
#include <eel/eel-glib-extensions.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-macros.h>
@@ -479,8 +478,8 @@ update_desktop_directory (NautilusDesktopDirectory *desktop)
}
desktop_path = nautilus_get_desktop_directory ();
- desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
- real_directory = nautilus_directory_get (desktop_uri);
+ desktop_uri = g_filename_to_uri (desktop_path, NULL, NULL);
+ real_directory = nautilus_directory_get_by_uri (desktop_uri);
g_free (desktop_uri);
g_free (desktop_path);
diff --git a/libnautilus-private/nautilus-desktop-icon-file.c b/libnautilus-private/nautilus-desktop-icon-file.c
index 733be4122..673e6b5ab 100644
--- a/libnautilus-private/nautilus-desktop-icon-file.c
+++ b/libnautilus-private/nautilus-desktop-icon-file.c
@@ -32,24 +32,16 @@
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include "nautilus-desktop-directory.h"
-#include <gtk/gtksignal.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <string.h>
struct NautilusDesktopIconFileDetails {
NautilusDesktopLink *link;
};
-static void nautilus_desktop_icon_file_init (gpointer object,
- gpointer klass);
-static void nautilus_desktop_icon_file_class_init (gpointer klass);
+G_DEFINE_TYPE(NautilusDesktopIconFile, nautilus_desktop_icon_file, NAUTILUS_TYPE_FILE)
-EEL_CLASS_BOILERPLATE (NautilusDesktopIconFile,
- nautilus_desktop_icon_file,
- NAUTILUS_TYPE_FILE)
static void
desktop_icon_file_monitor_add (NautilusFile *file,
@@ -69,13 +61,11 @@ desktop_icon_file_monitor_remove (NautilusFile *file,
(file->details->directory, file, client);
}
-
static void
desktop_icon_file_call_when_ready (NautilusFile *file,
NautilusFileAttributes attributes,
NautilusFileCallback callback,
gpointer callback_data)
-
{
nautilus_directory_call_when_ready_internal
(file->details->directory, file,
@@ -101,12 +91,6 @@ desktop_icon_file_check_if_ready (NautilusFile *file,
attributes);
}
-static GnomeVFSFileType
-desktop_icon_file_get_file_type (NautilusFile *file)
-{
- return GNOME_VFS_FILE_TYPE_REGULAR;
-}
-
static gboolean
desktop_icon_file_get_item_count (NautilusFile *file,
guint *count,
@@ -126,7 +110,7 @@ desktop_icon_file_get_deep_counts (NautilusFile *file,
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size)
+ goffset *total_size)
{
if (directory_count != NULL) {
*directory_count = 0;
@@ -164,22 +148,20 @@ desktop_icon_file_get_where_string (NautilusFile *file)
}
static void
-nautilus_desktop_icon_file_init (gpointer object, gpointer klass)
+nautilus_desktop_icon_file_init (NautilusDesktopIconFile *desktop_file)
{
- NautilusDesktopIconFile *desktop_file;
-
- desktop_file = NAUTILUS_DESKTOP_ICON_FILE (object);
-
- desktop_file->details = g_new0 (NautilusDesktopIconFileDetails, 1);
-}
+ desktop_file->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_file,
+ NAUTILUS_TYPE_DESKTOP_ICON_FILE,
+ NautilusDesktopIconFileDetails);
+}
static void
update_info_from_link (NautilusDesktopIconFile *icon_file)
{
NautilusFile *file;
- GnomeVFSFileInfo *file_info;
NautilusDesktopLink *link;
- GnomeVFSVolume *volume;
+ char *display_name;
+ GVolume *volume;
file = NAUTILUS_FILE (icon_file);
@@ -188,46 +170,40 @@ update_info_from_link (NautilusDesktopIconFile *icon_file)
if (link == NULL) {
return;
}
-
- file_info = file->details->info;
-
- gnome_vfs_file_info_clear (file_info);
-
- file_info->name = nautilus_desktop_link_get_file_name (link);
- file_info->mime_type = g_strdup ("application/x-nautilus-link");
- file_info->type = GNOME_VFS_FILE_TYPE_REGULAR;
- file_info->flags = GNOME_VFS_FILE_FLAGS_NONE;
- file_info->link_count = 1;
- file_info->size = 0;
- file_info->permissions =
- GNOME_VFS_PERM_OTHER_WRITE |
- GNOME_VFS_PERM_GROUP_WRITE |
- GNOME_VFS_PERM_USER_READ |
- GNOME_VFS_PERM_OTHER_READ |
- GNOME_VFS_PERM_GROUP_READ |
- GNOME_VFS_PERM_ACCESS_READABLE |
- GNOME_VFS_PERM_ACCESS_WRITABLE;
-
- file_info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE |
- GNOME_VFS_FILE_INFO_FIELDS_FLAGS |
- GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FIELDS_SIZE |
- GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS |
- GNOME_VFS_FILE_INFO_FIELDS_ACCESS |
- GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
+ eel_ref_str_unref (file->details->mime_type);
+ file->details->mime_type = eel_ref_str_get_unique ("application/x-nautilus-link");
+ file->details->type = G_FILE_TYPE_REGULAR;
+ file->details->size = 0;
+ file->details->has_permissions = FALSE;
+ file->details->can_read = TRUE;
+ file->details->can_write = TRUE;
+
+ file->details->can_mount = FALSE;
+ file->details->can_unmount = FALSE;
+ file->details->can_eject = FALSE;
volume = nautilus_desktop_link_get_volume (link);
- nautilus_file_set_volume (file, volume);
- gnome_vfs_volume_unref (volume);
+ if (volume) {
+ file->details->can_unmount = g_volume_can_unmount (volume);
+ file->details->can_eject = g_volume_can_eject (volume);
+ g_object_unref (volume);
+ }
file->details->file_info_is_up_to_date = TRUE;
- g_free (file->details->display_name);
- file->details->display_name = nautilus_desktop_link_get_display_name (link);
- g_free (file->details->custom_icon);
- file->details->custom_icon = nautilus_desktop_link_get_icon (link);
- g_free (file->details->activation_uri);
- file->details->activation_uri = nautilus_desktop_link_get_activation_uri (link);
+ display_name = nautilus_desktop_link_get_display_name (link);
+ nautilus_file_set_display_name (file,
+ display_name, NULL, TRUE);
+ g_free (display_name);
+
+ if (file->details->icon != NULL) {
+ g_object_unref (file->details->icon);
+ }
+ file->details->icon = nautilus_desktop_link_get_icon (link);
+ if (file->details->activation_location) {
+ g_object_unref (file->details->activation_location);
+ }
+ file->details->activation_location = nautilus_desktop_link_get_activation_location (link);
file->details->got_link_info = TRUE;
file->details->link_info_is_up_to_date = TRUE;
@@ -243,7 +219,6 @@ nautilus_desktop_icon_file_update (NautilusDesktopIconFile *icon_file)
update_info_from_link (icon_file);
file = NAUTILUS_FILE (icon_file);
- nautilus_file_clear_cached_display_name (file);
nautilus_file_changed (file);
}
@@ -275,17 +250,16 @@ nautilus_desktop_icon_file_remove (NautilusDesktopIconFile *icon_file)
nautilus_file_unref (file);
}
-
NautilusDesktopIconFile *
nautilus_desktop_icon_file_new (NautilusDesktopLink *link)
{
NautilusFile *file;
NautilusDirectory *directory;
NautilusDesktopIconFile *icon_file;
- char *name;
GList list;
-
- directory = nautilus_directory_get (EEL_DESKTOP_URI);
+ char *name;
+
+ directory = nautilus_directory_get_by_uri (EEL_DESKTOP_URI);
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_DESKTOP_ICON_FILE, NULL));
@@ -299,13 +273,12 @@ nautilus_desktop_icon_file_new (NautilusDesktopLink *link)
icon_file = NAUTILUS_DESKTOP_ICON_FILE (file);
icon_file->details->link = link;
- file->details->info = gnome_vfs_file_info_new ();
name = nautilus_desktop_link_get_file_name (link);
- file->details->relative_uri = gnome_vfs_escape_string (name);
+ file->details->name = eel_ref_str_new (name);
g_free (name);
update_info_from_link (icon_file);
-
+
nautilus_directory_add_file (directory, file);
list.data = file;
@@ -316,7 +289,6 @@ nautilus_desktop_icon_file_new (NautilusDesktopLink *link)
return icon_file;
}
-
/* Note: This can return NULL if the link was recently removed (i.e. unmounted) */
NautilusDesktopLink *
nautilus_desktop_icon_file_get_link (NautilusDesktopIconFile *icon_file)
@@ -328,36 +300,25 @@ nautilus_desktop_icon_file_get_link (NautilusDesktopIconFile *icon_file)
}
static void
-desktop_icon_file_finalize (GObject *object)
-{
- NautilusDesktopIconFile *desktop_file;
-
- desktop_file = NAUTILUS_DESKTOP_ICON_FILE (object);
-
- g_free (desktop_file->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-nautilus_desktop_icon_file_class_init (gpointer klass)
+nautilus_desktop_icon_file_class_init (NautilusDesktopIconFileClass *klass)
{
GObjectClass *object_class;
NautilusFileClass *file_class;
object_class = G_OBJECT_CLASS (klass);
file_class = NAUTILUS_FILE_CLASS (klass);
-
- object_class->finalize = desktop_icon_file_finalize;
+ file_class->default_file_type = G_FILE_TYPE_DIRECTORY;
+
file_class->monitor_add = desktop_icon_file_monitor_add;
file_class->monitor_remove = desktop_icon_file_monitor_remove;
file_class->call_when_ready = desktop_icon_file_call_when_ready;
file_class->cancel_call_when_ready = desktop_icon_file_cancel_call_when_ready;
file_class->check_if_ready = desktop_icon_file_check_if_ready;
- file_class->get_file_type = desktop_icon_file_get_file_type;
file_class->get_item_count = desktop_icon_file_get_item_count;
file_class->get_deep_counts = desktop_icon_file_get_deep_counts;
file_class->get_date = desktop_icon_file_get_date;
file_class->get_where_string = desktop_icon_file_get_where_string;
+
+ g_type_class_add_private (object_class, sizeof(NautilusDesktopIconFileDetails));
}
diff --git a/libnautilus-private/nautilus-desktop-link-monitor.c b/libnautilus-private/nautilus-desktop-link-monitor.c
index 6469c6a85..aef754cf5 100644
--- a/libnautilus-private/nautilus-desktop-link-monitor.c
+++ b/libnautilus-private/nautilus-desktop-link-monitor.c
@@ -39,12 +39,12 @@
#include <gtk/gtksignal.h>
#include <gtk/gtkstock.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gvolumemonitor.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <string.h>
struct NautilusDesktopLinkMonitorDetails {
+ GVolumeMonitor *volume_monitor;
NautilusDirectory *desktop_dir;
NautilusDesktopLink *home_link;
@@ -87,24 +87,11 @@ nautilus_desktop_link_monitor_get (void)
return the_link_monitor;
}
-static gboolean
-eject_for_type (GnomeVFSDeviceType type)
-{
- switch (type) {
- case GNOME_VFS_DEVICE_TYPE_CDROM:
- case GNOME_VFS_DEVICE_TYPE_ZIP:
- case GNOME_VFS_DEVICE_TYPE_JAZ:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
static void
volume_delete_dialog (GtkWidget *parent_view,
NautilusDesktopLink *link)
{
- GnomeVFSVolume *volume;
+ GVolume *volume;
char *dialog_str;
char *display_name;
@@ -116,7 +103,7 @@ volume_delete_dialog (GtkWidget *parent_view,
display_name);
g_free (display_name);
- if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
+ if (g_volume_can_eject (volume)) {
eel_run_simple_dialog
(parent_view,
FALSE,
@@ -136,7 +123,7 @@ volume_delete_dialog (GtkWidget *parent_view,
GTK_STOCK_OK, NULL);
}
- gnome_vfs_volume_unref (volume);
+ g_object_unref (volume);
g_free (dialog_str);
}
}
@@ -198,16 +185,12 @@ nautilus_desktop_link_monitor_make_filename_unique (NautilusDesktopLinkMonitor *
static void
create_volume_link (NautilusDesktopLinkMonitor *monitor,
- GnomeVFSVolume *volume)
+ GVolume *volume)
{
NautilusDesktopLink *link;
link = NULL;
- if (!gnome_vfs_volume_is_user_visible (volume)) {
- return;
- }
-
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
link = nautilus_desktop_link_new_from_volume (volume);
monitor->details->volume_links = g_list_prepend (monitor->details->volume_links, link);
@@ -217,8 +200,8 @@ create_volume_link (NautilusDesktopLinkMonitor *monitor,
static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_mounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
NautilusDesktopLinkMonitor *monitor)
{
create_volume_link (monitor, volume);
@@ -226,23 +209,23 @@ volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_unmounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
NautilusDesktopLinkMonitor *monitor)
{
GList *l;
NautilusDesktopLink *link;
- GnomeVFSVolume *other_volume;
+ GVolume *other_volume;
link = NULL;
for (l = monitor->details->volume_links; l != NULL; l = l->next) {
other_volume = nautilus_desktop_link_get_volume (l->data);
if (volume == other_volume) {
- gnome_vfs_volume_unref (other_volume);
+ g_object_unref (other_volume);
link = l->data;
break;
}
- gnome_vfs_volume_unref (other_volume);
+ g_object_unref (other_volume);
}
if (link) {
@@ -324,19 +307,17 @@ desktop_network_visible_changed (gpointer callback_data)
static void
desktop_volumes_visible_changed (gpointer callback_data)
{
- GnomeVFSVolumeMonitor *volume_monitor;
NautilusDesktopLinkMonitor *monitor;
GList *l, *volumes;
- volume_monitor = gnome_vfs_get_volume_monitor ();
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (callback_data);
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_VOLUMES_VISIBLE)) {
if (monitor->details->volume_links == NULL) {
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+ volumes = g_volume_monitor_get_mounted_volumes (monitor->details->volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
create_volume_link (monitor, l->data);
- gnome_vfs_volume_unref (l->data);
+ g_object_unref (l->data);
}
g_list_free (volumes);
}
@@ -366,8 +347,7 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
{
NautilusDesktopLinkMonitor *monitor;
GList *l, *volumes;
- GnomeVFSVolume *volume;
- GnomeVFSVolumeMonitor *volume_monitor;
+ GVolume *volume;
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
@@ -375,8 +355,10 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
monitor->details = g_new0 (NautilusDesktopLinkMonitorDetails, 1);
+ monitor->details->volume_monitor = g_volume_monitor_get ();
+
/* We keep around a ref to the desktop dir */
- monitor->details->desktop_dir = nautilus_directory_get (EEL_DESKTOP_URI);
+ monitor->details->desktop_dir = nautilus_directory_get_by_uri (EEL_DESKTOP_URI);
/* Default links */
@@ -406,13 +388,11 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
/* Volume links */
- volume_monitor = gnome_vfs_get_volume_monitor ();
-
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+ volumes = g_volume_monitor_get_mounted_volumes (monitor->details->volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
volume = l->data;
create_volume_link (monitor, volume);
- gnome_vfs_volume_unref (volume);
+ g_object_unref (volume);
}
g_list_free (volumes);
@@ -420,10 +400,12 @@ nautilus_desktop_link_monitor_init (gpointer object, gpointer klass)
desktop_volumes_visible_changed,
monitor);
- monitor->details->mount_id = g_signal_connect_object (volume_monitor, "volume_mounted",
- G_CALLBACK (volume_mounted_callback), monitor, 0);
- monitor->details->unmount_id = g_signal_connect_object (volume_monitor, "volume_unmounted",
- G_CALLBACK (volume_unmounted_callback), monitor, 0);
+ monitor->details->mount_id =
+ g_signal_connect_object (monitor->details->volume_monitor, "volume_mounted",
+ G_CALLBACK (volume_mounted_callback), monitor, 0);
+ monitor->details->unmount_id =
+ g_signal_connect_object (monitor->details->volume_monitor, "volume_unmounted",
+ G_CALLBACK (volume_unmounted_callback), monitor, 0);
}
@@ -448,6 +430,8 @@ desktop_link_monitor_finalize (GObject *object)
monitor = NAUTILUS_DESKTOP_LINK_MONITOR (object);
+ g_object_unref (monitor->details->volume_monitor);
+
/* Default links */
remove_link_and_preference (&monitor->details->home_link,
diff --git a/libnautilus-private/nautilus-desktop-link.c b/libnautilus-private/nautilus-desktop-link.c
index e27bac458..47ebb4a3e 100644
--- a/libnautilus-private/nautilus-desktop-link.c
+++ b/libnautilus-private/nautilus-desktop-link.c
@@ -28,26 +28,21 @@
#include "nautilus-desktop-icon-file.h"
#include "nautilus-directory-private.h"
#include "nautilus-desktop-directory.h"
-
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-vfs-extensions.h>
-#include <gtk/gtksignal.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs.h>
+#include <gio/gthemedicon.h>
+#include <gio/gvolume.h>
+#include <gio/gdrive.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <string.h>
-#define TRASH_EMPTY_ICON "gnome-fs-trash-empty"
-#define TRASH_FULL_ICON "gnome-fs-trash-full"
-
struct NautilusDesktopLinkDetails {
NautilusDesktopLinkType type;
char *filename;
char *display_name;
- char *activation_uri;
- char *icon;
+ GFile *activation_location;
+ GIcon *icon;
NautilusDesktopIconFile *icon_file;
@@ -55,20 +50,10 @@ struct NautilusDesktopLinkDetails {
gulong trash_state_handler;
/* Just for volume icons: */
- GnomeVFSVolume *volume;
+ GVolume *volume;
};
-static void nautilus_desktop_link_init (gpointer object,
- gpointer klass);
-static void nautilus_desktop_link_class_init (gpointer klass);
-static void trash_state_changed_callback (NautilusTrashMonitor *trash_monitor,
- gboolean state,
- gpointer callback_data);
-static void nautilus_desktop_link_changed (NautilusDesktopLink *link);
-
-EEL_CLASS_BOILERPLATE (NautilusDesktopLink,
- nautilus_desktop_link,
- G_TYPE_OBJECT)
+G_DEFINE_TYPE(NautilusDesktopLink, nautilus_desktop_link, G_TYPE_OBJECT)
static void
create_icon_file (NautilusDesktopLink *link)
@@ -77,6 +62,32 @@ create_icon_file (NautilusDesktopLink *link)
}
static void
+nautilus_desktop_link_changed (NautilusDesktopLink *link)
+{
+ if (link->details->icon_file != NULL) {
+ nautilus_desktop_icon_file_update (link->details->icon_file);
+ }
+}
+
+static void
+trash_state_changed_callback (NautilusTrashMonitor *trash_monitor,
+ gboolean state,
+ gpointer callback_data)
+{
+ NautilusDesktopLink *link;
+
+ link = NAUTILUS_DESKTOP_LINK (callback_data);
+ g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_TRASH);
+
+ if (link->details->icon) {
+ g_object_unref (link->details->icon);
+ }
+ link->details->icon = nautilus_trash_monitor_get_icon ();
+
+ nautilus_desktop_link_changed (link);
+}
+
+static void
home_name_changed (gpointer callback_data)
{
NautilusDesktopLink *link;
@@ -112,7 +123,6 @@ trash_name_changed (gpointer callback_data)
link = NAUTILUS_DESKTOP_LINK (callback_data);
g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_TRASH);
-
g_free (link->details->display_name);
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_TRASH_NAME);
nautilus_desktop_link_changed (link);
@@ -126,13 +136,11 @@ network_name_changed (gpointer callback_data)
link = NAUTILUS_DESKTOP_LINK (callback_data);
g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_NETWORK);
-
g_free (link->details->display_name);
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME);
nautilus_desktop_link_changed (link);
}
-
NautilusDesktopLink *
nautilus_desktop_link_new (NautilusDesktopLinkType type)
{
@@ -145,8 +153,8 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
case NAUTILUS_DESKTOP_LINK_HOME:
link->details->filename = g_strdup ("home");
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME);
- link->details->activation_uri = nautilus_get_home_directory_uri ();
- link->details->icon = g_strdup ("gnome-fs-home");
+ link->details->activation_location = g_file_new_for_path (g_get_home_dir ());
+ link->details->icon = g_themed_icon_new ("user-home");
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME,
home_name_changed,
@@ -156,12 +164,10 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
case NAUTILUS_DESKTOP_LINK_COMPUTER:
link->details->filename = g_strdup ("computer");
-
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_NAME);
-
- link->details->activation_uri = g_strdup ("computer:///");
+ link->details->activation_location = g_file_new_for_uri ("computer:///");
/* TODO: This might need a different icon: */
- link->details->icon = g_strdup ("gnome-fs-client");
+ link->details->icon = g_themed_icon_new ("gnome-fs-client");
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_COMPUTER_NAME,
computer_name_changed,
@@ -172,12 +178,8 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
case NAUTILUS_DESKTOP_LINK_TRASH:
link->details->filename = g_strdup ("trash");
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_TRASH_NAME);
- link->details->activation_uri = g_strdup (EEL_TRASH_URI);
- if (nautilus_trash_monitor_is_empty ()) {
- link->details->icon = g_strdup (TRASH_EMPTY_ICON);
- } else {
- link->details->icon = g_strdup (TRASH_FULL_ICON);
- }
+ link->details->activation_location = g_file_new_for_uri (EEL_TRASH_URI);
+ link->details->icon = nautilus_trash_monitor_get_icon ();
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_TRASH_NAME,
trash_name_changed,
@@ -190,8 +192,8 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
case NAUTILUS_DESKTOP_LINK_NETWORK:
link->details->filename = g_strdup ("network");
link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME);
- link->details->activation_uri = g_strdup ("network:///");
- link->details->icon = g_strdup ("gnome-fs-network");
+ link->details->activation_location = g_file_new_for_uri ("network:///");
+ link->details->icon = g_themed_icon_new ("gnome-fs-network");
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_NETWORK_NAME,
network_name_changed,
@@ -209,56 +211,59 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type)
}
NautilusDesktopLink *
-nautilus_desktop_link_new_from_volume (GnomeVFSVolume *volume)
+nautilus_desktop_link_new_from_volume (GVolume *volume)
{
NautilusDesktopLink *link;
- GnomeVFSDrive *drive;
+ GDrive *drive;
char *name, *filename;
link = NAUTILUS_DESKTOP_LINK (g_object_new (NAUTILUS_TYPE_DESKTOP_LINK, NULL));
link->details->type = NAUTILUS_DESKTOP_LINK_VOLUME;
- link->details->volume = gnome_vfs_volume_ref (volume);
+ link->details->volume = g_object_ref (volume);
/* We try to use the drive name to get somewhat stable filenames
for metadata */
- drive = gnome_vfs_volume_get_drive (volume);
+ drive = g_volume_get_drive (volume);
if (drive != NULL) {
- name = gnome_vfs_drive_get_display_name (drive);
+ name = g_drive_get_name (drive);
+ g_object_unref (drive);
} else {
- name = gnome_vfs_volume_get_display_name (volume);
+ name = g_volume_get_name (volume);
}
- gnome_vfs_drive_unref (drive);
- filename = g_strconcat (name, ".volume", NULL);
+ /* Replace slashes in name */
+ filename = g_strconcat (g_strdelimit (name, "/", '-'), ".volume", NULL);
link->details->filename =
nautilus_desktop_link_monitor_make_filename_unique (nautilus_desktop_link_monitor_get (),
filename);
g_free (filename);
g_free (name);
- link->details->display_name = gnome_vfs_volume_get_display_name (volume);
+ link->details->display_name = g_volume_get_name (volume);
+
+ link->details->activation_location = g_volume_get_root (volume);
+ link->details->icon = g_volume_get_icon (volume);
- link->details->activation_uri = gnome_vfs_volume_get_activation_uri (volume);
- link->details->icon = gnome_vfs_volume_get_icon (volume);
-
create_icon_file (link);
return link;
}
-GnomeVFSVolume *
+GVolume *
nautilus_desktop_link_get_volume (NautilusDesktopLink *link)
{
- return gnome_vfs_volume_ref (link->details->volume);
+ if (link->details->volume) {
+ return g_object_ref (link->details->volume);
+ }
+ return NULL;
}
-
NautilusDesktopLinkType
-nautilus_desktop_link_get_link_type (NautilusDesktopLink *link)
+nautilus_desktop_link_get_link_type (NautilusDesktopLink *link)
{
- return link->details->type;
+ return link->details->type;
}
char *
@@ -273,16 +278,22 @@ nautilus_desktop_link_get_display_name (NautilusDesktopLink *link)
return g_strdup (link->details->display_name);
}
-char *
+GIcon *
nautilus_desktop_link_get_icon (NautilusDesktopLink *link)
{
- return g_strdup (link->details->icon);
+ if (link->details->icon != NULL) {
+ return g_object_ref (link->details->icon);
+ }
+ return NULL;
}
-char *
-nautilus_desktop_link_get_activation_uri (NautilusDesktopLink *link)
+GFile *
+nautilus_desktop_link_get_activation_location (NautilusDesktopLink *link)
{
- return g_strdup (link->details->activation_uri);
+ if (link->details->activation_location) {
+ return g_object_ref (link->details->activation_location);
+ }
+ return NULL;
}
gboolean
@@ -293,35 +304,6 @@ nautilus_desktop_link_get_date (NautilusDesktopLink *link,
return FALSE;
}
-static void
-nautilus_desktop_link_changed (NautilusDesktopLink *link)
-{
- if (link->details->icon_file != NULL) {
- nautilus_desktop_icon_file_update (link->details->icon_file);
- }
-}
-
-static void
-trash_state_changed_callback (NautilusTrashMonitor *trash_monitor,
- gboolean state,
- gpointer callback_data)
-{
- NautilusDesktopLink *link;
-
- link = NAUTILUS_DESKTOP_LINK (callback_data);
- g_assert (link->details->type == NAUTILUS_DESKTOP_LINK_TRASH);
-
- g_free (link->details->icon);
-
- if (state) {
- link->details->icon = g_strdup (TRASH_EMPTY_ICON);
- } else {
- link->details->icon = g_strdup (TRASH_FULL_ICON);
- }
-
- nautilus_desktop_link_changed (link);
-}
-
gboolean
nautilus_desktop_link_can_rename (NautilusDesktopLink *link)
{
@@ -362,16 +344,13 @@ nautilus_desktop_link_rename (NautilusDesktopLink *link,
return TRUE;
}
-
static void
-nautilus_desktop_link_init (gpointer object, gpointer klass)
+nautilus_desktop_link_init (NautilusDesktopLink *link)
{
- NautilusDesktopLink *link;
-
- link = NAUTILUS_DESKTOP_LINK (object);
-
- link->details = g_new0 (NautilusDesktopLinkDetails, 1);
-}
+ link->details = G_TYPE_INSTANCE_GET_PRIVATE (link,
+ NAUTILUS_TYPE_DESKTOP_LINK,
+ NautilusDesktopLinkDetails);
+}
static void
desktop_link_finalize (GObject *object)
@@ -416,25 +395,29 @@ desktop_link_finalize (GObject *object)
}
if (link->details->type == NAUTILUS_DESKTOP_LINK_VOLUME) {
- gnome_vfs_volume_unref (link->details->volume);
+ g_object_unref (link->details->volume);
}
g_free (link->details->filename);
g_free (link->details->display_name);
- g_free (link->details->activation_uri);
- g_free (link->details->icon);
- g_free (link->details);
+ if (link->details->activation_location) {
+ g_object_unref (link->details->activation_location);
+ }
+ if (link->details->icon) {
+ g_object_unref (link->details->icon);
+ }
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (nautilus_desktop_link_parent_class)->finalize (object);
}
static void
-nautilus_desktop_link_class_init (gpointer klass)
+nautilus_desktop_link_class_init (NautilusDesktopLinkClass *klass)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (klass);
-
+
object_class->finalize = desktop_link_finalize;
+ g_type_class_add_private (object_class, sizeof(NautilusDesktopLinkDetails));
}
diff --git a/libnautilus-private/nautilus-desktop-link.h b/libnautilus-private/nautilus-desktop-link.h
index 578e592a2..3fa7e6924 100644
--- a/libnautilus-private/nautilus-desktop-link.h
+++ b/libnautilus-private/nautilus-desktop-link.h
@@ -26,7 +26,7 @@
#define NAUTILUS_DESKTOP_LINK_H
#include <libnautilus-private/nautilus-file.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
+#include <gio/gvolume.h>
#define NAUTILUS_TYPE_DESKTOP_LINK \
(nautilus_desktop_link_get_type ())
@@ -60,20 +60,20 @@ typedef enum {
GType nautilus_desktop_link_get_type (void);
-NautilusDesktopLink * nautilus_desktop_link_new (NautilusDesktopLinkType type);
-NautilusDesktopLink * nautilus_desktop_link_new_from_volume (GnomeVFSVolume *volume);
-NautilusDesktopLinkType nautilus_desktop_link_get_link_type (NautilusDesktopLink *link);
-char * nautilus_desktop_link_get_file_name (NautilusDesktopLink *link);
-char * nautilus_desktop_link_get_display_name (NautilusDesktopLink *link);
-char * nautilus_desktop_link_get_icon (NautilusDesktopLink *link);
-char * nautilus_desktop_link_get_activation_uri (NautilusDesktopLink *link);
-gboolean nautilus_desktop_link_get_date (NautilusDesktopLink *link,
- NautilusDateType date_type,
- time_t *date);
-GnomeVFSVolume * nautilus_desktop_link_get_volume (NautilusDesktopLink *link);
+NautilusDesktopLink * nautilus_desktop_link_new (NautilusDesktopLinkType type);
+NautilusDesktopLink * nautilus_desktop_link_new_from_volume (GVolume *volume);
+NautilusDesktopLinkType nautilus_desktop_link_get_link_type (NautilusDesktopLink *link);
+char * nautilus_desktop_link_get_file_name (NautilusDesktopLink *link);
+char * nautilus_desktop_link_get_display_name (NautilusDesktopLink *link);
+GIcon * nautilus_desktop_link_get_icon (NautilusDesktopLink *link);
+GFile * nautilus_desktop_link_get_activation_location (NautilusDesktopLink *link);
+gboolean nautilus_desktop_link_get_date (NautilusDesktopLink *link,
+ NautilusDateType date_type,
+ time_t *date);
+GVolume * nautilus_desktop_link_get_volume (NautilusDesktopLink *link);
+gboolean nautilus_desktop_link_can_rename (NautilusDesktopLink *link);
+gboolean nautilus_desktop_link_rename (NautilusDesktopLink *link,
+ const char *name);
-gboolean nautilus_desktop_link_can_rename (NautilusDesktopLink *link);
-gboolean nautilus_desktop_link_rename (NautilusDesktopLink *link,
- const char *name);
#endif /* NAUTILUS_DESKTOP_LINK_H */
diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c
index 49757cf59..5877b321d 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -30,6 +30,7 @@
#include "nautilus-file-attributes.h"
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
+#include "nautilus-signaller.h"
#include "nautilus-global-preferences.h"
#include "nautilus-link.h"
#include "nautilus-marshal.h"
@@ -37,10 +38,6 @@
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime-monitor.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libxml/parser.h>
#include <stdio.h>
#include <stdlib.h>
@@ -60,23 +57,76 @@
#define DEBUG_START_STOP
#endif
-
#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 100
/* Keep async. jobs down to this number for all directories. */
#define MAX_ASYNC_JOBS 10
struct TopLeftTextReadState {
- gboolean large;
+ NautilusDirectory *directory;
NautilusFile *file;
- EelReadFileHandle *handle;
+ gboolean large;
+ GCancellable *cancellable;
};
struct LinkInfoReadState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ NautilusFile *file;
+};
+
+struct ThumbnailState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
NautilusFile *file;
- EelReadFileHandle *handle;
+ gboolean trying_original;
+ gboolean tried_original;
+};
+
+struct DirectoryLoadState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ GFileEnumerator *enumerator;
+ GHashTable *load_mime_list_hash;
+ NautilusFile *load_directory_file;
+ int load_file_count;
+};
+
+struct MimeListState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ GFileEnumerator *enumerator;
+ GHashTable *mime_list_hash;
+};
+
+struct GetInfoState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+};
+
+struct NewFilesState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ int count;
};
+struct DirectoryCountState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ GFileEnumerator *enumerator;
+ int file_count;
+};
+
+struct DeepCountState {
+ NautilusDirectory *directory;
+ GCancellable *cancellable;
+ GFileEnumerator *enumerator;
+ GFile *deep_count_location;
+ GList *deep_count_subdirectories;
+};
+
+
+
typedef struct {
NautilusFile *file; /* Which file, NULL means all. */
union {
@@ -121,25 +171,23 @@ static GHashTable *async_jobs;
static char *kde_trash_dir_name = NULL;
/* Forward declarations for functions that need them. */
-static void deep_count_load (NautilusDirectory *directory,
- const char *uri);
-static gboolean request_is_satisfied (NautilusDirectory *directory,
- NautilusFile *file,
- Request *request);
-static void cancel_loading_attributes (NautilusDirectory *directory,
- NautilusFileAttributes file_attributes);
-static void add_all_files_to_work_queue (NautilusDirectory *directory);
-static void link_info_done (NautilusDirectory *directory,
- NautilusFile *file,
- const char *uri,
- const char *name,
- const char *icon,
- gulong drive_id,
- gulong volume_id);
-static void move_file_to_low_priority_queue (NautilusDirectory *directory,
- NautilusFile *file);
-static void move_file_to_extension_queue (NautilusDirectory *directory,
- NautilusFile *file);
+static void deep_count_load (DeepCountState *state,
+ GFile *location);
+static gboolean request_is_satisfied (NautilusDirectory *directory,
+ NautilusFile *file,
+ Request *request);
+static void cancel_loading_attributes (NautilusDirectory *directory,
+ NautilusFileAttributes file_attributes);
+static void add_all_files_to_work_queue (NautilusDirectory *directory);
+static void link_info_done (NautilusDirectory *directory,
+ NautilusFile *file,
+ const char *uri,
+ const char *name,
+ const char *icon);
+static void move_file_to_low_priority_queue (NautilusDirectory *directory,
+ NautilusFile *file);
+static void move_file_to_extension_queue (NautilusDirectory *directory,
+ NautilusFile *file);
static void nautilus_directory_invalidate_file_attributes (NautilusDirectory *directory,
NautilusFileAttributes file_attributes);
@@ -227,7 +275,7 @@ async_job_start (NautilusDirectory *directory,
#endif
#ifdef DEBUG_START_STOP
- g_message ("starting %s in %s", job, directory->details->uri);
+ g_message ("starting %s in %p", job, directory->details->location);
#endif
g_assert (async_job_count >= 0);
@@ -248,18 +296,22 @@ async_job_start (NautilusDirectory *directory,
}
#ifdef DEBUG_ASYNC_JOBS
- if (async_jobs == NULL) {
- async_jobs = eel_g_hash_table_new_free_at_exit
- (g_str_hash, g_str_equal,
- "nautilus-directory-async.c: async_jobs");
- }
- key = g_strconcat (directory->details->uri, ": ", job, NULL);
- if (g_hash_table_lookup (async_jobs, key) != NULL) {
- g_warning ("same job twice: %s in %s",
- job,
- directory->details->uri);
- }
- g_hash_table_insert (async_jobs, key, directory);
+ {
+ char *uri;
+ if (async_jobs == NULL) {
+ async_jobs = eel_g_hash_table_new_free_at_exit
+ (g_str_hash, g_str_equal,
+ "nautilus-directory-async.c: async_jobs");
+ }
+ uri = = nautilus_directory_get_uri (directory);
+ key = g_strconcat (uri, ": ", job, NULL);
+ if (g_hash_table_lookup (async_jobs, key) != NULL) {
+ g_warning ("same job twice: %s in %s",
+ job, uri);
+ }
+ g_free (uri);
+ g_hash_table_insert (async_jobs, key, directory);
+ }
#endif
async_job_count += 1;
@@ -277,23 +329,27 @@ async_job_end (NautilusDirectory *directory,
#endif
#ifdef DEBUG_START_STOP
- g_message ("stopping %s in %s", job, directory->details->uri);
+ g_message ("stopping %s in %p", job, directory->details->location);
#endif
g_assert (async_job_count > 0);
#ifdef DEBUG_ASYNC_JOBS
- g_assert (async_jobs != NULL);
- key = g_strconcat (directory->details->uri, ": ", job, NULL);
- if (!g_hash_table_lookup_extended (async_jobs, key, &table_key, &value)) {
- g_warning ("ending job we didn't start: %s in %s",
- job,
- directory->details->uri);
- } else {
- g_hash_table_remove (async_jobs, key);
- g_free (table_key);
+ {
+ char *uri;
+ uri = nautilus_directory_get_uri (directory);
+ g_assert (async_jobs != NULL);
+ key = g_strconcat (uri, ": ", job, NULL);
+ if (!g_hash_table_lookup_extended (async_jobs, key, &table_key, &value)) {
+ g_warning ("ending job we didn't start: %s in %s",
+ job, uri);
+ } else {
+ g_hash_table_remove (async_jobs, key);
+ g_free (table_key);
+ }
+ g_free (uri);
+ g_free (key);
}
- g_free (key);
#endif
async_job_count -= 1;
@@ -355,9 +411,11 @@ static void
directory_count_cancel (NautilusDirectory *directory)
{
if (directory->details->count_in_progress != NULL) {
- gnome_vfs_async_cancel (directory->details->count_in_progress);
- directory->details->count_file = NULL;
+ g_cancellable_cancel (directory->details->count_in_progress->cancellable);
+ directory->details->count_in_progress->directory = NULL;
directory->details->count_in_progress = NULL;
+ directory->details->count_file = NULL;
+
async_job_end (directory, "directory count");
}
@@ -368,17 +426,14 @@ deep_count_cancel (NautilusDirectory *directory)
{
if (directory->details->deep_count_in_progress != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->deep_count_file));
-
- gnome_vfs_async_cancel (directory->details->deep_count_in_progress);
+
+ g_cancellable_cancel (directory->details->deep_count_in_progress->cancellable);
directory->details->deep_count_file->details->deep_counts_status = NAUTILUS_REQUEST_NOT_STARTED;
- directory->details->deep_count_file = NULL;
+ directory->details->deep_count_in_progress->directory = NULL;
directory->details->deep_count_in_progress = NULL;
- g_free (directory->details->deep_count_uri);
- directory->details->deep_count_uri = NULL;
- eel_g_list_free_deep (directory->details->deep_count_subdirectories);
- directory->details->deep_count_subdirectories = NULL;
+ directory->details->deep_count_file = NULL;
async_job_end (directory, "deep count");
}
@@ -390,12 +445,11 @@ mime_list_cancel (NautilusDirectory *directory)
if (directory->details->mime_list_in_progress != NULL) {
g_assert (NAUTILUS_IS_FILE (directory->details->mime_list_file));
- gnome_vfs_async_cancel (directory->details->mime_list_in_progress);
- istr_set_destroy (directory->details->mime_list_hash);
-
- directory->details->mime_list_file = NULL;
+ g_cancellable_cancel (directory->details->mime_list_in_progress->cancellable);
+
+ directory->details->mime_list_in_progress->directory = NULL;
directory->details->mime_list_in_progress = NULL;
- directory->details->mime_list_hash = NULL;
+ directory->details->mime_list_file = NULL;
async_job_end (directory, "MIME list");
}
@@ -405,10 +459,10 @@ static void
top_left_cancel (NautilusDirectory *directory)
{
if (directory->details->top_left_read_state != NULL) {
- eel_read_file_cancel (directory->details->top_left_read_state->handle);
- g_free (directory->details->top_left_read_state);
+ g_cancellable_cancel (directory->details->top_left_read_state->cancellable);
+ directory->details->top_left_read_state->directory = NULL;
directory->details->top_left_read_state = NULL;
-
+
async_job_end (directory, "top left");
}
}
@@ -417,20 +471,32 @@ static void
link_info_cancel (NautilusDirectory *directory)
{
if (directory->details->link_info_read_state != NULL) {
- eel_read_file_cancel (directory->details->link_info_read_state->handle);
- g_free (directory->details->link_info_read_state);
+ g_cancellable_cancel (directory->details->link_info_read_state->cancellable);
+ directory->details->link_info_read_state->directory = NULL;
directory->details->link_info_read_state = NULL;
async_job_end (directory, "link info");
}
}
static void
+thumbnail_cancel (NautilusDirectory *directory)
+{
+ if (directory->details->thumbnail_state != NULL) {
+ g_cancellable_cancel (directory->details->thumbnail_state->cancellable);
+ directory->details->thumbnail_state->directory = NULL;
+ directory->details->thumbnail_state = NULL;
+ async_job_end (directory, "thumbnail");
+ }
+}
+
+static void
file_info_cancel (NautilusDirectory *directory)
{
if (directory->details->get_info_in_progress != NULL) {
- gnome_vfs_async_cancel (directory->details->get_info_in_progress);
- directory->details->get_info_file = NULL;
+ g_cancellable_cancel (directory->details->get_info_in_progress->cancellable);
+ directory->details->get_info_in_progress->directory = NULL;
directory->details->get_info_in_progress = NULL;
+ directory->details->get_info_file = NULL;
async_job_end (directory, "file info");
}
@@ -439,11 +505,17 @@ file_info_cancel (NautilusDirectory *directory)
static void
new_files_cancel (NautilusDirectory *directory)
{
- if (directory->details->get_file_infos_in_progress != NULL) {
- g_list_foreach (directory->details->get_file_infos_in_progress,
- (GFunc)gnome_vfs_async_cancel, NULL);
- g_list_free (directory->details->get_file_infos_in_progress);
- directory->details->get_file_infos_in_progress = NULL;
+ GList *l;
+ NewFilesState *state;
+
+ if (directory->details->new_files_in_progress != NULL) {
+ for (l = directory->details->new_files_in_progress; l != NULL; l = l->next) {
+ state = l->data;
+ g_cancellable_cancel (state->cancellable);
+ state->directory = NULL;
+ }
+ g_list_free (directory->details->new_files_in_progress);
+ directory->details->new_files_in_progress = NULL;
}
}
@@ -515,18 +587,18 @@ nautilus_directory_set_up_request (Request *request,
{
memset (request, 0, sizeof (*request));
- request->directory_count = (file_attributes &
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT) != FALSE;
- request->deep_count = (file_attributes &
- NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS) != FALSE;
- request->mime_list = (file_attributes &
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES) != FALSE;
- request->file_info = (file_attributes &
- (NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES |
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE)) != FALSE;
+ request->directory_count =
+ (file_attributes & NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT) != 0;
+ request->deep_count =
+ (file_attributes & NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS) != 0;
+ request->mime_list =
+ (file_attributes & NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES) != 0;
+ request->file_info = (file_attributes & NAUTILUS_FILE_ATTRIBUTE_INFO) != 0;
+
+ if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_LINK_INFO) {
+ request->file_info = TRUE;
+ request->link_info = TRUE;
+ }
if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT) {
request->top_left_text = TRUE;
@@ -537,61 +609,27 @@ nautilus_directory_set_up_request (Request *request,
request->large_top_left_text = TRUE;
request->file_info = TRUE;
}
-
- if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI) {
- request->file_info = TRUE;
- request->link_info = TRUE;
- }
-
- if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_VOLUMES) {
- request->link_info = TRUE;
- }
- if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME) {
- request->file_info = TRUE;
- request->link_info = TRUE;
- }
+ request->metafile |= (file_attributes & NAUTILUS_FILE_ATTRIBUTE_METADATA) != 0;
+ request->extension_info = (file_attributes & NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO) != 0;
- /* FIXME bugzilla.gnome.org 42435:
- * Some file attributes are really pieces of metadata.
- * This is a confusing/broken design, since other metadata
- * pieces are handled separately from file attributes. There
- * are many ways this could be changed, ranging from making
- * all metadata pieces have corresponding file attributes, to
- * making a single file attribute that means "get all metadata",
- * to making metadata keys be acceptable as file attributes
- * directly (would need some funky char trick to prevent
- * namespace collisions).
- */
- if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON) {
- request->metafile = TRUE;
+ if (file_attributes & NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL) {
+ request->thumbnail = TRUE;
request->file_info = TRUE;
- request->link_info = TRUE;
}
-
- request->metafile |= (file_attributes &
- NAUTILUS_FILE_ATTRIBUTE_METADATA) != FALSE;
-
- request->slow_mime_type = (file_attributes & NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE) != FALSE;
-
- request->extension_info = (file_attributes & NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO) != FALSE;
}
static void
-mime_db_changed_callback (GnomeVFSMIMEMonitor *ignore, NautilusDirectory *dir)
+mime_db_changed_callback (GObject *ignore, NautilusDirectory *dir)
{
NautilusFileAttributes attrs;
g_return_if_fail (dir != NULL);
g_return_if_fail (dir->details != NULL);
- attrs = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
- NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES |
- NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE |
+ attrs = NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE |
NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES;
nautilus_directory_force_reload_internal (dir, attrs);
@@ -609,7 +647,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
{
Monitor *monitor;
GList *file_list;
-
+
g_assert (NAUTILUS_IS_DIRECTORY (directory));
/* Replace any current monitor for this client/file pair. */
@@ -639,7 +677,7 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
* it allows us to avoid one file monitor per file in a directory.
*/
if (directory->details->monitor == NULL) {
- directory->details->monitor = nautilus_monitor_directory (directory->details->uri);
+ directory->details->monitor = nautilus_monitor_directory (directory->details->location);
}
/* We could just call update_metadata_monitors here, but we can be smarter
@@ -650,10 +688,10 @@ nautilus_directory_monitor_add_internal (NautilusDirectory *directory,
}
if (monitor->request.file_info && directory->details->mime_db_monitor == 0) {
- directory->details->mime_db_monitor = g_signal_connect_object (
- gnome_vfs_mime_monitor_get (),
- "data_changed",
- G_CALLBACK (mime_db_changed_callback), directory, 0);
+ directory->details->mime_db_monitor =
+ g_signal_connect_object (nautilus_signaller_get_current (),
+ "mime_data_changed",
+ G_CALLBACK (mime_db_changed_callback), directory, 0);
}
/* Put the monitor file or all the files on the work queue. */
@@ -704,25 +742,7 @@ show_backup_files_changed_callback (gpointer callback_data)
}
static gboolean
-is_dot_or_dot_dot (const char *name)
-{
- if (name[0] != '.') {
- return FALSE;
- }
- if (name[1] == '\0') {
- return TRUE;
- }
- if (name[1] != '.') {
- return FALSE;
- }
- if (name[2] == '\0') {
- return TRUE;
- }
- return FALSE;
-}
-
-static gboolean
-should_skip_file (NautilusDirectory *directory, GnomeVFSFileInfo *info)
+should_skip_file (NautilusDirectory *directory, GFileInfo *info)
{
static gboolean show_hidden_files_changed_callback_installed = FALSE;
static gboolean show_backup_files_changed_callback_installed = FALSE;
@@ -749,56 +769,21 @@ should_skip_file (NautilusDirectory *directory, GnomeVFSFileInfo *info)
show_backup_files_changed_callback (NULL);
}
- if (info == NULL || info->name == NULL) {
- return TRUE;
- }
-
- if (is_dot_or_dot_dot (info->name)) {
- return TRUE;
- }
-
- if (!show_hidden_files && (nautilus_file_name_matches_hidden_pattern (info->name) ||
- (directory != NULL &&
- g_hash_table_lookup (directory->details->hidden_file_hash, info->name) != NULL))) {
+ if (!show_hidden_files &&
+ (g_file_info_get_is_hidden (info) ||
+ (directory != NULL && directory->details->hidden_file_hash != NULL &&
+ g_hash_table_lookup (directory->details->hidden_file_hash,
+ g_file_info_get_name (info)) != NULL))) {
return TRUE;
}
- if (!show_backup_files && nautilus_file_name_matches_backup_pattern (info->name)) {
+
+ if (!show_backup_files && g_file_info_get_is_backup (info)) {
return TRUE;
}
return FALSE;
}
-static void
-load_directory_state_destroy (NautilusDirectory *directory)
-{
- NautilusFile *file;
-
- if (directory->details->load_mime_list_hash != NULL) {
- istr_set_destroy (directory->details->load_mime_list_hash);
- directory->details->load_mime_list_hash = NULL;
- }
-
- file = directory->details->load_directory_file;
- if (file != NULL) {
- directory->details->load_directory_file = NULL;
-
- file->details->loading_directory = FALSE;
- if (file->details->directory != directory) {
- nautilus_directory_async_state_changed (file->details->directory);
- }
-
- nautilus_file_unref (file);
- }
-}
-
-static void
-load_directory_done (NautilusDirectory *directory)
-{
- load_directory_state_destroy (directory);
- nautilus_directory_async_state_changed (directory);
-}
-
static gboolean
dequeue_pending_idle_callback (gpointer callback_data)
{
@@ -807,7 +792,9 @@ dequeue_pending_idle_callback (gpointer callback_data)
GList *node, *next;
NautilusFile *file;
GList *changed_files, *added_files;
- GnomeVFSFileInfo *file_info;
+ GFileInfo *file_info;
+ const char *mimetype, *name;
+ DirectoryLoadState *dir_load_state;
directory = NAUTILUS_DIRECTORY (callback_data);
@@ -821,17 +808,21 @@ dequeue_pending_idle_callback (gpointer callback_data)
/* If we are no longer monitoring, then throw away these. */
if (!nautilus_directory_is_file_list_monitored (directory)) {
- load_directory_done (directory);
+ nautilus_directory_async_state_changed (directory);
goto drain;
}
added_files = NULL;
changed_files = NULL;
+ dir_load_state = directory->details->directory_load_in_progress;
+
/* Build a list of NautilusFile objects. */
for (node = pending_file_info; node != NULL; node = node->next) {
file_info = node->data;
+ name = g_file_info_get_name (file_info);
+
/* Update the file count. */
/* FIXME bugzilla.gnome.org 45063: This could count a
* file twice if we get it from both load_directory
@@ -839,32 +830,33 @@ dequeue_pending_idle_callback (gpointer callback_data)
* moving this into the actual callback instead of
* waiting for the idle function.
*/
- if (!should_skip_file (directory, file_info)) {
- directory->details->load_file_count += 1;
+ if (dir_load_state &&
+ !should_skip_file (directory, file_info)) {
+ dir_load_state->load_file_count += 1;
/* Add the MIME type to the set. */
- if ((file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) != 0
- && directory->details->load_mime_list_hash != NULL) {
- istr_set_insert (directory->details->load_mime_list_hash,
- file_info->mime_type);
+ mimetype = g_file_info_get_content_type (file_info);
+ if (mimetype != NULL) {
+ istr_set_insert (dir_load_state->load_mime_list_hash,
+ mimetype);
}
}
/* check if the file already exists */
- file = nautilus_directory_find_file_by_name (directory, file_info->name);
+ file = nautilus_directory_find_file_by_name (directory, name);
if (file != NULL) {
/* file already exists in dir, check if we still need to
* emit file_added or if it changed */
set_file_unconfirmed (file, FALSE);
if (!file->details->is_added) {
/* We consider this newly added even if its in the list.
- * This can happen if someone called nautilus_file_get()
+ * This can happen if someone called nautilus_file_get_by_uri()
* on a file in the folder before the add signal was
* emitted */
nautilus_file_ref (file);
file->details->is_added = TRUE;
added_files = g_list_prepend (added_files, file);
- } else if (nautilus_file_update_info (file, file_info, FALSE)) {
+ } else if (nautilus_file_update_info (file, file_info)) {
/* File changed, notify about the change. */
nautilus_file_ref (file);
changed_files = g_list_prepend (changed_files, file);
@@ -902,33 +894,34 @@ dequeue_pending_idle_callback (gpointer callback_data)
nautilus_directory_emit_files_added (directory, added_files);
nautilus_file_list_free (added_files);
- if (directory->details->directory_loaded
- && !directory->details->directory_loaded_sent_notification) {
+ if (directory->details->directory_loaded &&
+ !directory->details->directory_loaded_sent_notification) {
/* Send the done_loading signal. */
nautilus_directory_emit_done_loading (directory);
- file = directory->details->load_directory_file;
-
- if (file != NULL) {
+ if (dir_load_state) {
+ file = dir_load_state->load_directory_file;
+
+ file->details->directory_count = dir_load_state->load_file_count;
file->details->directory_count_is_up_to_date = TRUE;
file->details->got_directory_count = TRUE;
- file->details->directory_count = directory->details->load_file_count;
file->details->got_mime_list = TRUE;
file->details->mime_list_is_up_to_date = TRUE;
+ eel_g_list_free_deep (file->details->mime_list);
file->details->mime_list = istr_set_get_as_list
- (directory->details->load_mime_list_hash);
+ (dir_load_state->load_mime_list_hash);
nautilus_file_changed (file);
}
- load_directory_done (directory);
+ nautilus_directory_async_state_changed (directory);
directory->details->directory_loaded_sent_notification = TRUE;
}
drain:
- gnome_vfs_file_info_list_free (pending_file_info);
+ eel_g_object_list_free (pending_file_info);
/* Get the state machine running again. */
nautilus_directory_async_state_changed (directory);
@@ -948,15 +941,14 @@ nautilus_directory_schedule_dequeue_pending (NautilusDirectory *directory)
static void
directory_load_one (NautilusDirectory *directory,
- GnomeVFSFileInfo *info)
+ GFileInfo *info)
{
- if (info == NULL || info->name == NULL ||
- is_dot_or_dot_dot (info->name)) {
+ if (info == NULL) {
return;
}
/* Arrange for the "loading" part of the work. */
- gnome_vfs_file_info_ref (info);
+ g_object_ref (info);
directory->details->pending_file_info
= g_list_prepend (directory->details->pending_file_info, info);
nautilus_directory_schedule_dequeue_pending (directory);
@@ -965,8 +957,19 @@ directory_load_one (NautilusDirectory *directory,
static void
directory_load_cancel (NautilusDirectory *directory)
{
- if (directory->details->directory_load_in_progress != NULL) {
- gnome_vfs_async_cancel (directory->details->directory_load_in_progress);
+ NautilusFile *file;
+ DirectoryLoadState *state;
+
+ state = directory->details->directory_load_in_progress;
+ if (state != NULL) {
+ file = state->load_directory_file;
+ file->details->loading_directory = FALSE;
+ if (file->details->directory != directory) {
+ nautilus_directory_async_state_changed (file->details->directory);
+ }
+
+ g_cancellable_cancel (state->cancellable);
+ state->directory = NULL;
directory->details->directory_load_in_progress = NULL;
async_job_end (directory, "file list");
}
@@ -989,30 +992,25 @@ file_list_cancel (NautilusDirectory *directory)
}
if (directory->details->pending_file_info != NULL) {
- gnome_vfs_file_info_list_free (directory->details->pending_file_info);
+ eel_g_object_list_free (directory->details->pending_file_info);
directory->details->pending_file_info = NULL;
}
- g_hash_table_foreach_remove (directory->details->hidden_file_hash, remove_callback, NULL);
-
- load_directory_state_destroy (directory);
+ if (directory->details->hidden_file_hash) {
+ g_hash_table_foreach_remove (directory->details->hidden_file_hash, remove_callback, NULL);
+ }
}
static void
directory_load_done (NautilusDirectory *directory,
- GnomeVFSResult result)
+ GError *error)
{
GList *node;
- directory_load_cancel (directory);
directory->details->directory_loaded = TRUE;
directory->details->directory_loaded_sent_notification = FALSE;
- /* Note that GNOME_VFS_OK can make it this far when the file-list
- * length limit has been reached. In that case, don't treat it as
- * an error.
- */
- if (result != GNOME_VFS_ERROR_EOF && result != GNOME_VFS_OK) {
+ if (error != NULL) {
/* The load did not complete successfully. This means
* we don't know the status of the files in this directory.
* We clear the unconfirmed bit on each file here so that
@@ -1024,8 +1022,7 @@ directory_load_done (NautilusDirectory *directory,
set_file_unconfirmed (NAUTILUS_FILE (node->data), FALSE);
}
- nautilus_directory_emit_load_error (directory,
- result, NULL);
+ nautilus_directory_emit_load_error (directory, error);
}
/* Call the idle function right away. */
@@ -1033,35 +1030,8 @@ directory_load_done (NautilusDirectory *directory,
g_source_remove (directory->details->dequeue_pending_idle_id);
}
dequeue_pending_idle_callback (directory);
-}
-
-static void
-directory_load_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GList *list,
- guint entries_read,
- gpointer callback_data)
-{
- NautilusDirectory *directory;
- GList *element;
-
- directory = NAUTILUS_DIRECTORY (callback_data);
-
- g_assert (directory->details->directory_load_in_progress != NULL);
- g_assert (directory->details->directory_load_in_progress == handle);
- nautilus_directory_ref (directory);
-
- for (element = list; element != NULL; element = element->next) {
- directory_load_one (directory, element->data);
- }
-
- if (nautilus_directory_file_list_length_reached (directory)
- || result != GNOME_VFS_OK) {
- directory_load_done (directory, result);
- }
-
- nautilus_directory_unref (directory);
+ directory_load_cancel (directory);
}
/* This checks if there's a request for the metafile contents. */
@@ -1415,116 +1385,87 @@ nautilus_directory_cancel_callback_internal (NautilusDirectory *directory,
} while (node != NULL);
}
-static guint
-count_non_skipped_files (GList *list)
+static void
+new_files_state_unref (NewFilesState *state)
{
- guint count;
- GList *node;
+ state->count--;
- count = 0;
- for (node = list; node != NULL; node = node->next) {
- if (!should_skip_file (NULL, node->data)) {
- count += 1;
+ if (state->count == 0) {
+ if (state->directory) {
+ state->directory->details->new_files_in_progress =
+ g_list_remove (state->directory->details->new_files_in_progress,
+ state);
}
+
+ g_object_unref (state->cancellable);
+ g_free (state);
}
- return count;
}
static void
-directory_count_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GList *list,
- guint entries_read,
- gpointer callback_data)
+new_files_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
NautilusDirectory *directory;
- NautilusFile *count_file;
-
- directory = NAUTILUS_DIRECTORY (callback_data);
+ GFileInfo *info;
+ NewFilesState *state;
- g_assert (directory->details->count_in_progress == handle);
- count_file = directory->details->count_file;
- g_assert (NAUTILUS_IS_FILE (count_file));
+ state = user_data;
- if (result == GNOME_VFS_OK) {
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ new_files_state_unref (state);
return;
}
-
- nautilus_directory_ref (directory);
-
- count_file->details->directory_count_is_up_to_date = TRUE;
-
- /* Record either a failure or success. */
- if (result != GNOME_VFS_ERROR_EOF) {
- count_file->details->directory_count_failed = TRUE;
- count_file->details->got_directory_count = FALSE;
- count_file->details->directory_count = 0;
- } else {
- count_file->details->directory_count_failed = FALSE;
- count_file->details->got_directory_count = TRUE;
- count_file->details->directory_count = count_non_skipped_files (list);
- }
- directory->details->count_file = NULL;
- directory->details->count_in_progress = NULL;
-
- /* Send file-changed even if count failed, so interested parties can
- * distinguish between unknowable and not-yet-known cases.
- */
- nautilus_file_changed (count_file);
-
- /* Start up the next one. */
- async_job_end (directory, "directory count");
- nautilus_directory_async_state_changed (directory);
-
- nautilus_directory_unref (directory);
-}
-
-static void
-new_files_callback (GnomeVFSAsyncHandle *handle,
- GList *results,
- gpointer callback_data)
-{
- GList **handles, *node;
- NautilusDirectory *directory;
- GnomeVFSGetFileInfoResult *result;
-
- directory = NAUTILUS_DIRECTORY (callback_data);
- handles = &directory->details->get_file_infos_in_progress;
- g_assert (handle == NULL || g_list_find (*handles, handle) != NULL);
-
- nautilus_directory_ref (directory);
- /* Note that this call is done. */
- *handles = g_list_remove (*handles, handle);
-
- /* Queue up the new files. */
- for (node = results; node != NULL; node = node->next) {
- result = node->data;
-
- if (result->result == GNOME_VFS_OK) {
- directory_load_one (directory, result->file_info);
- }
+ directory = nautilus_directory_ref (state->directory);
+
+ /* Queue up the new file. */
+ info = g_file_query_info_finish (G_FILE (source_object), res, NULL);
+ if (info != NULL) {
+ directory_load_one (directory, info);
+ g_object_unref (info);
}
+ new_files_state_unref (state);
+
nautilus_directory_unref (directory);
}
void
nautilus_directory_get_info_for_new_files (NautilusDirectory *directory,
- GList *vfs_uri_list)
+ GList *location_list)
{
- GnomeVFSAsyncHandle *handle;
- gnome_vfs_async_get_file_info
- (&handle,
- vfs_uri_list,
- NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS,
- GNOME_VFS_PRIORITY_DEFAULT,
- new_files_callback,
- directory);
+ NewFilesState *state;
+ GFile *location;
+ GList *l;
- directory->details->get_file_infos_in_progress
- = g_list_prepend (directory->details->get_file_infos_in_progress,
- handle);
+ if (location_list == NULL) {
+ return;
+ }
+
+ state = g_new (NewFilesState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+ state->count = 0;
+
+ for (l = location_list; l != NULL; l = l->next) {
+ location = l->data;
+
+ state->count++;
+
+ g_file_query_info_async (location,
+ NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
+ 0,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ new_files_callback, state);
+ }
+
+ directory->details->new_files_in_progress
+ = g_list_prepend (directory->details->new_files_in_progress,
+ state);
}
void
@@ -1596,8 +1537,8 @@ nautilus_async_destroying_file (NautilusFile *file)
directory->details->top_left_read_state->file = NULL;
changed = TRUE;
}
- if (directory->details->link_info_read_state != NULL
- && directory->details->link_info_read_state->file == file) {
+ if (directory->details->link_info_read_state != NULL &&
+ directory->details->link_info_read_state->file == file) {
directory->details->link_info_read_state->file = NULL;
changed = TRUE;
}
@@ -1606,6 +1547,12 @@ nautilus_async_destroying_file (NautilusFile *file)
changed = TRUE;
}
+ if (directory->details->thumbnail_state != NULL &&
+ directory->details->thumbnail_state->file == file) {
+ directory->details->thumbnail_state->file = NULL;
+ changed = TRUE;
+ }
+
/* Let the directory take care of the rest. */
if (changed) {
nautilus_directory_async_state_changed (directory);
@@ -1675,27 +1622,6 @@ wants_info (const Request *request)
}
static gboolean
-always_lacks (NautilusFile *file)
-{
- return TRUE;
-}
-
-static gboolean
-lacks_slow_mime_type (NautilusFile *file)
-{
- return !file->details->got_slow_mime_type
- && !file->details->is_gone &&
- !file->details->get_info_failed;
-}
-
-static gboolean
-wants_slow_mime_type (const Request *request)
-{
- return request->slow_mime_type;
-}
-
-
-static gboolean
lacks_deep_count (NautilusFile *file)
{
return file->details->deep_counts_status != NAUTILUS_REQUEST_DONE;
@@ -1733,7 +1659,7 @@ lacks_link_info (NautilusFile *file)
if (nautilus_file_is_nautilus_link (file)) {
return TRUE;
} else {
- link_info_done (file->details->directory, file, NULL, NULL, NULL, 0, 0);
+ link_info_done (file->details->directory, file, NULL, NULL, NULL);
return FALSE;
}
} else {
@@ -1760,6 +1686,20 @@ wants_extension_info (const Request *request)
}
static gboolean
+lacks_thumbnail (NautilusFile *file)
+{
+ return nautilus_file_should_show_thumbnail (file) &&
+ file->details->thumbnail_path != NULL &&
+ !file->details->thumbnail_is_up_to_date;
+}
+
+static gboolean
+wants_thumbnail (const Request *request)
+{
+ return request->thumbnail;
+}
+
+static gboolean
has_problem (NautilusDirectory *directory, NautilusFile *file, FileCheck problem)
{
GList *node;
@@ -1803,12 +1743,6 @@ request_is_satisfied (NautilusDirectory *directory,
}
}
- if (request->slow_mime_type) {
- if (has_problem (directory, file, lacks_slow_mime_type)) {
- return FALSE;
- }
- }
-
if (request->top_left_text) {
if (has_problem (directory, file, lacks_top_left)) {
return FALSE;
@@ -1977,64 +1911,50 @@ mark_all_files_unconfirmed (NautilusDirectory *directory)
static void
read_dot_hidden_file (NautilusDirectory *directory)
{
- char *dot_hidden_uri;
- GnomeVFSURI *dot_hidden_vfs_uri;
- GnomeVFSResult result;
- int i, file_size;
+ gsize file_size;
char *file_contents;
- GnomeVFSFileInfo *file_info;
- gboolean file_ok;
+ GFile *child;
+ GFileInfo *info;
+ GFileType type;
+ int i;
/* FIXME: We only support .hidden on file: uri's for the moment.
* Need to figure out if we should do this async or sync to extend
* it to all types of uris.
*/
- if (directory->details->vfs_uri == NULL ||
- (eel_strcasecmp (directory->details->vfs_uri->method_string, "file") != 0)) {
+ if (directory->details->location == NULL ||
+ !g_file_is_native (directory->details->location)) {
return;
}
- /* FIXME: what we really need is a uri_append_file_name call
- * that works on strings, so we can avoid the VFS parsing step.
- */
- dot_hidden_vfs_uri = gnome_vfs_uri_append_file_name (directory->details->vfs_uri, ".hidden");
+ child = g_file_get_child (directory->details->location, ".hidden");
- file_info = gnome_vfs_file_info_new ();
- if (!file_info) {
- gnome_vfs_uri_unref (dot_hidden_vfs_uri);
- return;
+ type = G_FILE_TYPE_UNKNOWN;
+
+ info = g_file_query_info (child, G_FILE_ATTRIBUTE_STD_TYPE, 0, NULL, NULL);
+ if (info != NULL) {
+ type = g_file_info_get_file_type (info);
+ g_object_unref (info);
}
- if (gnome_vfs_get_file_info_uri (
- dot_hidden_vfs_uri,
- file_info,
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS) != GNOME_VFS_OK) {
- gnome_vfs_uri_unref (dot_hidden_vfs_uri);
- gnome_vfs_file_info_unref (file_info);
+ if (type != G_FILE_TYPE_REGULAR) {
+ g_object_unref (child);
return;
}
- file_ok = (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) &&
- (file_info->type == GNOME_VFS_FILE_TYPE_REGULAR);
-
- gnome_vfs_file_info_unref (file_info);
-
- if (!file_ok) {
- gnome_vfs_uri_unref (dot_hidden_vfs_uri);
+ if (!g_file_load_contents (child, NULL, &file_contents, &file_size, NULL, NULL)) {
+ g_object_unref (child);
return;
}
-
- dot_hidden_uri = gnome_vfs_uri_to_string (dot_hidden_vfs_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (dot_hidden_vfs_uri);
-
- result = eel_read_entire_file (dot_hidden_uri, &file_size, &file_contents);
- g_free (dot_hidden_uri);
- if (result != GNOME_VFS_OK) {
- return;
- }
+ g_object_unref (child);
+ if (directory->details->hidden_file_hash == NULL) {
+ directory->details->hidden_file_hash =
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ }
+
/* Now parse the data */
i = 0;
while (i < file_size) {
@@ -2046,14 +1966,11 @@ read_dot_hidden_file (NautilusDirectory *directory)
}
if (i > start) {
- char *tmp, *tmp2;
+ char *hidden_filename;
- tmp = g_strndup (file_contents + start, i - start);
- tmp2 = gnome_vfs_escape_string (tmp);
- g_free (tmp);
-
+ hidden_filename = g_strndup (file_contents + start, i - start);
g_hash_table_insert (directory->details->hidden_file_hash,
- tmp2, tmp2);
+ hidden_filename, hidden_filename);
}
i++;
@@ -2063,18 +1980,133 @@ read_dot_hidden_file (NautilusDirectory *directory)
g_free (file_contents);
}
+static void
+directory_load_state_free (DirectoryLoadState *state)
+{
+ if (state->enumerator) {
+ if (!g_file_enumerator_is_closed (state->enumerator)) {
+ g_file_enumerator_close_async (state->enumerator,
+ 0, NULL, NULL, NULL);
+ }
+ g_object_unref (state->enumerator);
+ }
+
+ if (state->load_mime_list_hash != NULL) {
+ istr_set_destroy (state->load_mime_list_hash);
+ }
+ nautilus_file_unref (state->load_directory_file);
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
+
+static void
+more_files_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DirectoryLoadState *state;
+ NautilusDirectory *directory;
+ GError *error;
+ GList *files, *l;
+ GFileInfo *info;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ directory_load_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ g_assert (directory->details->directory_load_in_progress != NULL);
+ g_assert (directory->details->directory_load_in_progress == state);
+
+ error = NULL;
+ files = g_file_enumerator_next_files_finish (state->enumerator,
+ res, &error);
+
+ for (l = files; l != NULL; l = l->next) {
+ info = l->data;
+ directory_load_one (directory, info);
+ g_object_unref (info);
+ }
+
+ if (nautilus_directory_file_list_length_reached (directory) ||
+ files == NULL) {
+ directory_load_done (directory, error);
+ directory_load_state_free (state);
+ } else {
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ more_files_callback,
+ state);
+ }
+
+ nautilus_directory_unref (directory);
+
+ if (error) {
+ g_error_free (error);
+ }
+
+ g_list_free (files);
+}
+
+static void
+enumerate_children_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DirectoryLoadState *state;
+ GFileEnumerator *enumerator;
+ GError *error;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ directory_load_state_free (state);
+ return;
+ }
+
+ error = NULL;
+ enumerator = g_file_enumerate_children_finish (G_FILE (source_object),
+ res, &error);
+
+ if (enumerator == NULL) {
+ directory_load_done (state->directory, error);
+ g_error_free (error);
+ directory_load_state_free (state);
+ return;
+ } else {
+ state->enumerator = enumerator;
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ more_files_callback,
+ state);
+ }
+}
+
+
/* Start monitoring the file list if it isn't already. */
static void
start_monitoring_file_list (NautilusDirectory *directory)
{
+ DirectoryLoadState *state;
+
if (!directory->details->file_list_monitored) {
- g_assert (directory->details->directory_load_in_progress == NULL);
+ g_assert (!directory->details->directory_load_in_progress);
directory->details->file_list_monitored = TRUE;
nautilus_file_list_ref (directory->details->file_list);
}
- if (directory->details->directory_loaded
- || directory->details->directory_load_in_progress != NULL) {
+ if (directory->details->directory_loaded ||
+ directory->details->directory_load_in_progress != NULL) {
return;
}
@@ -2084,36 +2116,47 @@ start_monitoring_file_list (NautilusDirectory *directory)
mark_all_files_unconfirmed (directory);
- g_assert (directory->details->uri != NULL);
- directory->details->load_directory_file =
+ state = g_new0 (DirectoryLoadState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+ state->load_mime_list_hash = istr_set_new ();
+ state->load_file_count = 0;
+
+ g_assert (directory->details->location != NULL);
+ state->load_directory_file =
nautilus_directory_get_corresponding_file (directory);
-
- directory->details->load_directory_file->details->loading_directory = TRUE;
- directory->details->load_file_count = 0;
- directory->details->load_mime_list_hash = istr_set_new ();
+ state->load_directory_file->details->loading_directory = TRUE;
read_dot_hidden_file (directory);
/* Hack to work around kde trash dir */
if (kde_trash_dir_name != NULL && nautilus_directory_is_desktop_directory (directory)) {
- char *escaped;
- escaped = gnome_vfs_escape_string (kde_trash_dir_name);
+ char *fn;
+
+ if (directory->details->hidden_file_hash == NULL) {
+ directory->details->hidden_file_hash =
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ }
+
+ fn = g_strdup (kde_trash_dir_name);
g_hash_table_insert (directory->details->hidden_file_hash,
- escaped, escaped);
+ fn, fn);
}
#ifdef DEBUG_LOAD_DIRECTORY
- g_message ("load_directory called to monitor file list of %s", directory->details->uri);
+ g_message ("load_directory called to monitor file list of %p", directory->details->location);
#endif
- gnome_vfs_async_load_directory
- (&directory->details->directory_load_in_progress, /* handle */
- directory->details->uri, /* uri */
- NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS,
- DIRECTORY_LOAD_ITEMS_PER_CALLBACK, /* items_per_notification */
- GNOME_VFS_PRIORITY_DEFAULT,
- directory_load_callback, /* callback */
- directory);
+
+ directory->details->directory_load_in_progress = state;
+
+ g_file_enumerate_children_async (directory->details->location,
+ NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
+ 0, /* flags */
+ G_PRIORITY_DEFAULT, /* prio */
+ state->cancellable,
+ enumerate_children_callback,
+ state);
}
/* Stop monitoring the file list if it is being monitored. */
@@ -2290,12 +2333,171 @@ directory_count_stop (NautilusDirectory *directory)
}
}
+static guint
+count_non_skipped_files (GList *list)
+{
+ guint count;
+ GList *node;
+ GFileInfo *info;
+
+ count = 0;
+ for (node = list; node != NULL; node = node->next) {
+ info = node->data;
+ if (!should_skip_file (NULL, info)) {
+ count += 1;
+ }
+ }
+ return count;
+}
+
+static void
+count_children_done (NautilusDirectory *directory,
+ gboolean succeeded,
+ int count)
+{
+ NautilusFile *count_file;
+
+ count_file = directory->details->count_file;
+
+ g_assert (NAUTILUS_IS_FILE (count_file));
+
+ nautilus_directory_ref (directory);
+
+ count_file->details->directory_count_is_up_to_date = TRUE;
+
+ /* Record either a failure or success. */
+ if (!succeeded) {
+ count_file->details->directory_count_failed = TRUE;
+ count_file->details->got_directory_count = FALSE;
+ count_file->details->directory_count = 0;
+ } else {
+ count_file->details->directory_count_failed = FALSE;
+ count_file->details->got_directory_count = TRUE;
+ count_file->details->directory_count = count;
+ }
+ directory->details->count_file = NULL;
+ directory->details->count_in_progress = NULL;
+
+ /* Send file-changed even if count failed, so interested parties can
+ * distinguish between unknowable and not-yet-known cases.
+ */
+ nautilus_file_changed (count_file);
+
+ /* Start up the next one. */
+ async_job_end (directory, "directory count");
+ nautilus_directory_async_state_changed (directory);
+
+ nautilus_directory_unref (directory);
+}
+
+static void
+directory_count_state_free (DirectoryCountState *state)
+{
+ if (state->enumerator) {
+ if (!g_file_enumerator_is_closed (state->enumerator)) {
+ g_file_enumerator_close_async (state->enumerator,
+ 0, NULL, NULL, NULL);
+ }
+ g_object_unref (state->enumerator);
+ }
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
+
+static void
+count_more_files_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DirectoryCountState *state;
+ NautilusDirectory *directory;
+ GError *error;
+ GList *files;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ directory_count_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ g_assert (directory->details->count_in_progress != NULL);
+ g_assert (directory->details->count_in_progress == state);
+
+ error = NULL;
+ files = g_file_enumerator_next_files_finish (state->enumerator,
+ res, &error);
+
+ state->file_count += count_non_skipped_files (files);
+
+ if (files == NULL) {
+ count_children_done (directory, TRUE, state->file_count);
+ directory_count_state_free (state);
+ } else {
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ count_more_files_callback,
+ state);
+ }
+
+ eel_g_object_list_free (files);
+
+ nautilus_directory_unref (directory);
+
+ if (error) {
+ g_error_free (error);
+ }
+}
+
+static void
+count_children_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DirectoryCountState *state;
+ GFileEnumerator *enumerator;
+ GError *error;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ directory_count_state_free (state);
+ return;
+ }
+
+ error = NULL;
+ enumerator = g_file_enumerate_children_finish (G_FILE (source_object),
+ res, &error);
+
+ if (enumerator == NULL) {
+ count_children_done (state->directory, FALSE, 0);
+ g_error_free (error);
+ directory_count_state_free (state);
+ return;
+ } else {
+ state->enumerator = enumerator;
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ count_more_files_callback,
+ state);
+ }
+}
+
static void
directory_count_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
+ DirectoryCountState *state;
+ GFile *location;
if (directory->details->count_in_progress != NULL) {
*doing_io = TRUE;
@@ -2324,103 +2526,110 @@ directory_count_start (NautilusDirectory *directory,
/* Start counting. */
directory->details->count_file = file;
- uri = nautilus_file_get_uri (file);
+
+ state = g_new0 (DirectoryCountState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+
+ directory->details->count_in_progress = state;
+
#ifdef DEBUG_LOAD_DIRECTORY
g_message ("load_directory called to get shallow file count for %s", uri);
-#endif
- gnome_vfs_async_load_directory
- (&directory->details->count_in_progress,
- uri,
- GNOME_VFS_FILE_INFO_NAME_ONLY,
- G_MAXINT,
- GNOME_VFS_PRIORITY_DEFAULT,
- directory_count_callback,
- directory);
- g_free (uri);
+#endif
+ location = nautilus_file_get_location (file);
+
+ g_file_enumerate_children_async (location,
+ "std:name,std:is_hidden,std:is_backup",
+ 0, /* flags */
+ G_PRIORITY_DEFAULT, /* prio */
+ state->cancellable,
+ count_children_callback,
+ state);
+ g_object_unref (location);
}
static void
-deep_count_one (NautilusDirectory *directory,
- GnomeVFSFileInfo *info)
+deep_count_one (DeepCountState *state,
+ GFileInfo *info)
{
NautilusFile *file;
- char *escaped_name, *uri;
-
- if (should_skip_file (NULL, info))
+ GFile *subdir;
+
+ if (should_skip_file (NULL, info)) {
return;
+ }
- file = directory->details->deep_count_file;
+ file = state->directory->details->deep_count_file;
- if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) != 0
- && info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
/* Count the directory. */
file->details->deep_directory_count += 1;
/* Record the fact that we have to descend into this directory. */
- escaped_name = gnome_vfs_escape_string (info->name);
- uri = g_build_filename (directory->details->deep_count_uri, escaped_name, NULL);
- g_free (escaped_name);
- directory->details->deep_count_subdirectories = g_list_prepend
- (directory->details->deep_count_subdirectories, uri);
+
+ subdir = g_file_get_child (state->deep_count_location, g_file_info_get_name (info));
+ state->deep_count_subdirectories = g_list_prepend
+ (state->deep_count_subdirectories, subdir);
} else {
/* Even non-regular files count as files. */
file->details->deep_file_count += 1;
}
/* Count the size. */
- if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) != 0) {
- file->details->deep_size += info->size;
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STD_SIZE)) {
+ file->details->deep_size += g_file_info_get_size (info);
}
}
static void
-deep_count_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GList *list,
- guint entries_read,
- gpointer callback_data)
+deep_count_state_free (DeepCountState *state)
{
- NautilusDirectory *directory;
+ if (state->enumerator) {
+ if (!g_file_enumerator_is_closed (state->enumerator)) {
+ g_file_enumerator_close_async (state->enumerator,
+ 0, NULL, NULL, NULL);
+ }
+ g_object_unref (state->enumerator);
+ }
+ g_object_unref (state->cancellable);
+ if (state->deep_count_location) {
+ g_object_unref (state->deep_count_location);
+ }
+ eel_g_object_list_free (state->deep_count_subdirectories);
+ g_free (state);
+}
+
+static void
+deep_count_next_dir (DeepCountState *state)
+{
+ GFile *location;
NautilusFile *file;
- GList *element;
- char *uri;
+ NautilusDirectory *directory;
gboolean done;
- directory = NAUTILUS_DIRECTORY (callback_data);
- g_assert (directory->details->deep_count_in_progress == handle);
- file = directory->details->deep_count_file;
- g_assert (NAUTILUS_IS_FILE (file));
-
- nautilus_directory_ref (directory);
-
- for (element = list; element != NULL; element = element->next) {
- deep_count_one (directory, element->data);
- }
+ directory = state->directory;
+
+ g_object_unref (state->deep_count_location);
+ state->deep_count_location = NULL;
done = FALSE;
- if (result != GNOME_VFS_OK) {
- if (result != GNOME_VFS_ERROR_EOF) {
- file->details->deep_unreadable_count += 1;
- }
-
+ file = directory->details->deep_count_file;
+
+ if (state->deep_count_subdirectories != NULL) {
+ /* Work on a new directory. */
+ location = state->deep_count_subdirectories->data;
+ state->deep_count_subdirectories = g_list_remove
+ (state->deep_count_subdirectories, location);
+ deep_count_load (state, location);
+ g_object_unref (location);
+ } else {
+ file->details->deep_counts_status = NAUTILUS_REQUEST_DONE;
+ directory->details->deep_count_file = NULL;
directory->details->deep_count_in_progress = NULL;
- g_free (directory->details->deep_count_uri);
- directory->details->deep_count_uri = NULL;
-
- if (directory->details->deep_count_subdirectories != NULL) {
- /* Work on a new directory. */
- uri = directory->details->deep_count_subdirectories->data;
- directory->details->deep_count_subdirectories = g_list_remove
- (directory->details->deep_count_subdirectories, uri);
- deep_count_load (directory, uri);
- g_free (uri);
- } else {
- file->details->deep_counts_status = NAUTILUS_REQUEST_DONE;
- directory->details->deep_count_file = NULL;
- done = TRUE;
- }
+ deep_count_state_free (state);
+ done = TRUE;
}
-
+
nautilus_file_updated_deep_count_in_progress (file);
if (done) {
@@ -2428,26 +2637,115 @@ deep_count_callback (GnomeVFSAsyncHandle *handle,
async_job_end (directory, "deep count");
nautilus_directory_async_state_changed (directory);
}
+}
+
+static void
+deep_count_more_files_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DeepCountState *state;
+ NautilusDirectory *directory;
+ GList *files, *l;
+ GFileInfo *info;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ deep_count_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ g_assert (directory->details->deep_count_in_progress != NULL);
+ g_assert (directory->details->deep_count_in_progress == state);
+
+ files = g_file_enumerator_next_files_finish (state->enumerator,
+ res, NULL);
+
+ for (l = files; l != NULL; l = l->next) {
+ info = l->data;
+ deep_count_one (state, info);
+ g_object_unref (info);
+ }
+
+ if (files == NULL) {
+ g_file_enumerator_close_async (state->enumerator, 0, NULL, NULL, NULL);
+ g_object_unref (state->enumerator);
+ state->enumerator = NULL;
+
+ deep_count_next_dir (state);
+ } else {
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_LOW,
+ state->cancellable,
+ deep_count_more_files_callback,
+ state);
+ }
+
+ g_list_free (files);
nautilus_directory_unref (directory);
}
static void
-deep_count_load (NautilusDirectory *directory, const char *uri)
+deep_count_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ DeepCountState *state;
+ GFileEnumerator *enumerator;
+ NautilusFile *file;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ deep_count_state_free (state);
+ return;
+ }
+
+ file = state->directory->details->deep_count_file;
+
+ enumerator = g_file_enumerate_children_finish (G_FILE (source_object), res, NULL);
+
+ if (enumerator == NULL) {
+ file->details->deep_unreadable_count += 1;
+
+ deep_count_next_dir (state);
+ } else {
+ state->enumerator = enumerator;
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_LOW,
+ state->cancellable,
+ deep_count_more_files_callback,
+ state);
+ }
+}
+
+
+static void
+deep_count_load (DeepCountState *state, GFile *location)
{
- g_assert (directory->details->deep_count_uri == NULL);
- directory->details->deep_count_uri = g_strdup (uri);
+ NautilusDirectory *directory;
+
+ directory = state->directory;
+ state->deep_count_location = g_object_ref (location);
+
#ifdef DEBUG_LOAD_DIRECTORY
- g_message ("load_directory called to get deep file count for %s", uri);
+ g_message ("load_directory called to get deep file count for %p", location);
#endif
- gnome_vfs_async_load_directory
- (&directory->details->deep_count_in_progress,
- uri,
- GNOME_VFS_FILE_INFO_DEFAULT,
- G_MAXINT,
- GNOME_VFS_PRIORITY_DEFAULT,
- deep_count_callback,
- directory);
+ g_file_enumerate_children_async (state->deep_count_location,
+ "std:name,std:is_hidden,std:is_backup,std:type,std:size",
+ 0, /* flags */
+ G_PRIORITY_LOW, /* prio */
+ state->cancellable,
+ deep_count_callback,
+ state);
}
static void
@@ -2477,8 +2775,9 @@ deep_count_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
-
+ GFile *location;
+ DeepCountState *state;
+
if (directory->details->deep_count_in_progress != NULL) {
*doing_io = TRUE;
return;
@@ -2509,67 +2808,78 @@ deep_count_start (NautilusDirectory *directory,
file->details->deep_unreadable_count = 0;
file->details->deep_size = 0;
directory->details->deep_count_file = file;
- uri = nautilus_file_get_uri (file);
- deep_count_load (directory, uri);
- g_free (uri);
-}
-static void
-mime_list_one (NautilusDirectory *directory,
- GnomeVFSFileInfo *info)
-{
- if (should_skip_file (NULL, info)) {
- return;
- }
+ state = g_new0 (DeepCountState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
- if ((info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) != 0) {
- istr_set_insert (directory->details->mime_list_hash, info->mime_type);
- }
+ directory->details->deep_count_in_progress = state;
+
+ location = nautilus_file_get_location (file);
+ deep_count_load (state, location);
+ g_object_unref (location);
}
static void
-mime_list_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GList *list,
- guint entries_read,
- gpointer callback_data)
+mime_list_stop (NautilusDirectory *directory)
{
- NautilusDirectory *directory;
NautilusFile *file;
- GList *element;
- directory = NAUTILUS_DIRECTORY (callback_data);
- g_assert (directory->details->mime_list_in_progress == handle);
- file = directory->details->mime_list_file;
- g_assert (NAUTILUS_IS_FILE (file));
+ if (directory->details->mime_list_in_progress != NULL) {
+ file = directory->details->mime_list_file;
+ if (file != NULL) {
+ g_assert (NAUTILUS_IS_FILE (file));
+ g_assert (file->details->directory == directory);
+ if (is_needy (file,
+ should_get_mime_list,
+ wants_mime_list)) {
+ return;
+ }
+ }
- for (element = list; element != NULL; element = element->next) {
- mime_list_one (directory, element->data);
+ /* The count is not wanted, so stop it. */
+ mime_list_cancel (directory);
}
+}
- if (result == GNOME_VFS_OK) {
- return;
+static void
+mime_list_state_free (MimeListState *state)
+{
+ if (state->enumerator) {
+ if (!g_file_enumerator_is_closed (state->enumerator)) {
+ g_file_enumerator_close_async (state->enumerator,
+ 0, NULL, NULL, NULL);
+ }
+ g_object_unref (state->enumerator);
}
+ g_object_unref (state->cancellable);
+ istr_set_destroy (state->mime_list_hash);
+ g_free (state);
+}
- nautilus_directory_ref (directory);
- file->details->mime_list_is_up_to_date = TRUE;
+static void
+mime_list_done (MimeListState *state, gboolean success)
+{
+ NautilusFile *file;
+ NautilusDirectory *directory;
- /* Record either a failure or success. */
+ directory = state->directory;
+ g_assert (directory != NULL);
+
+ file = directory->details->mime_list_file;
+
+ file->details->mime_list_is_up_to_date = TRUE;
eel_g_list_free_deep (file->details->mime_list);
- if (result != GNOME_VFS_ERROR_EOF) {
+ if (success) {
file->details->mime_list_failed = TRUE;
file->details->mime_list = NULL;
} else {
file->details->got_mime_list = TRUE;
- file->details->mime_list = istr_set_get_as_list
- (directory->details->mime_list_hash);
+ file->details->mime_list = istr_set_get_as_list (state->mime_list_hash);
}
- istr_set_destroy (directory->details->mime_list_hash);
-
directory->details->mime_list_in_progress = NULL;
directory->details->mime_list_file = NULL;
- directory->details->mime_list_hash = NULL;
/* Send file-changed even if getting the item type list
* failed, so interested parties can distinguish between
@@ -2580,46 +2890,115 @@ mime_list_callback (GnomeVFSAsyncHandle *handle,
/* Start up the next one. */
async_job_end (directory, "MIME list");
nautilus_directory_async_state_changed (directory);
+
+}
- nautilus_directory_unref (directory);
+static void
+mime_list_one (MimeListState *state,
+ GFileInfo *info)
+{
+ const char *mime_type;
+
+ if (should_skip_file (NULL, info)) {
+ g_object_unref (info);
+ return;
+ }
+
+ mime_type = g_file_info_get_content_type (info);
+ if (mime_type != NULL) {
+ istr_set_insert (state->mime_list_hash, mime_type);
+ }
}
static void
-mime_list_load (NautilusDirectory *directory, const char *uri)
+mime_list_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- directory->details->mime_list_hash = istr_set_new ();
-#ifdef DEBUG_LOAD_DIRECTORY
- g_message ("load_directory called to get MIME list of %s", uri);
-#endif
- gnome_vfs_async_load_directory
- (&directory->details->mime_list_in_progress,
- uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
- DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
- GNOME_VFS_PRIORITY_DEFAULT,
- mime_list_callback,
- directory);
+ MimeListState *state;
+ NautilusDirectory *directory;
+ GError *error;
+ GList *files, *l;
+ GFileInfo *info;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ mime_list_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ g_assert (directory->details->mime_list_in_progress != NULL);
+ g_assert (directory->details->mime_list_in_progress == state);
+
+ error = NULL;
+ files = g_file_enumerator_next_files_finish (state->enumerator,
+ res, &error);
+
+ for (l = files; l != NULL; l = l->next) {
+ info = l->data;
+ mime_list_one (state, info);
+ g_object_unref (info);
+ }
+
+ if (files == NULL) {
+ mime_list_done (state, error != NULL);
+ mime_list_state_free (state);
+ } else {
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ mime_list_callback,
+ state);
+ }
+
+ g_list_free (files);
+
+ nautilus_directory_unref (directory);
+
+ if (error) {
+ g_error_free (error);
+ }
}
static void
-mime_list_stop (NautilusDirectory *directory)
+list_mime_enum_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
- NautilusFile *file;
+ MimeListState *state;
+ GFileEnumerator *enumerator;
+ GError *error;
- if (directory->details->mime_list_in_progress != NULL) {
- file = directory->details->mime_list_file;
- if (file != NULL) {
- g_assert (NAUTILUS_IS_FILE (file));
- g_assert (file->details->directory == directory);
- if (is_needy (file,
- should_get_mime_list,
- wants_mime_list)) {
- return;
- }
- }
+ state = user_data;
- /* The count is not wanted, so stop it. */
- mime_list_cancel (directory);
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ mime_list_state_free (state);
+ return;
+ }
+
+ error = NULL;
+ enumerator = g_file_enumerate_children_finish (G_FILE (source_object),
+ res, &error);
+
+ if (enumerator == NULL) {
+ mime_list_done (state, FALSE);
+ g_error_free (error);
+ mime_list_state_free (state);
+ return;
+ } else {
+ state->enumerator = enumerator;
+ g_file_enumerator_next_files_async (state->enumerator,
+ DIRECTORY_LOAD_ITEMS_PER_CALLBACK,
+ G_PRIORITY_DEFAULT,
+ state->cancellable,
+ mime_list_callback,
+ state);
}
}
@@ -2628,7 +3007,8 @@ mime_list_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
+ MimeListState *state;
+ GFile *location;
mime_list_stop (directory);
@@ -2659,114 +3039,142 @@ mime_list_start (NautilusDirectory *directory,
return;
}
+
+ state = g_new0 (MimeListState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+ state->mime_list_hash = istr_set_new ();
+
directory->details->mime_list_file = file;
- uri = nautilus_file_get_uri (file);
- mime_list_load (directory, uri);
- g_free (uri);
+ directory->details->mime_list_in_progress = state;
+
+#ifdef DEBUG_LOAD_DIRECTORY
+ g_message ("load_directory called to get MIME list of %s", uri);
+#endif
+
+ location = nautilus_file_get_location (file);
+ g_file_enumerate_children_async (location,
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE,
+ 0, /* flags */
+ G_PRIORITY_LOW, /* prio */
+ state->cancellable,
+ list_mime_enum_callback,
+ state);
+ g_object_unref (location);
}
-static int
-count_lines (const char *text, int length)
+static void
+top_left_stop (NautilusDirectory *directory)
{
- int count, i;
+ NautilusFile *file;
- count = 0;
- for (i = 0; i < length; i++) {
- count += *text++ == '\n';
+ if (directory->details->top_left_read_state != NULL) {
+ file = directory->details->top_left_read_state->file;
+ if (file != NULL) {
+ g_assert (NAUTILUS_IS_FILE (file));
+ g_assert (file->details->directory == directory);
+ if (is_needy (file,
+ lacks_top_left,
+ wants_top_left) ||
+ is_needy (file,
+ lacks_large_top_left,
+ wants_large_top_left)) {
+ return;
+ }
+ }
+
+ /* The top left is not wanted, so stop it. */
+ top_left_cancel (directory);
}
- return count;
}
static void
-top_left_read_done (NautilusDirectory *directory)
+top_left_read_state_free (TopLeftTextReadState *state)
{
- g_assert (directory->details->top_left_read_state->handle == NULL);
- g_assert (NAUTILUS_IS_FILE (directory->details->top_left_read_state->file));
-
- g_free (directory->details->top_left_read_state);
- directory->details->top_left_read_state = NULL;
-
- async_job_end (directory, "top left");
- nautilus_directory_async_state_changed (directory);
+ g_object_unref (state->cancellable);
+ g_free (state);
}
static void
-top_left_read_callback (GnomeVFSResult result,
- GnomeVFSFileSize bytes_read,
- char *file_contents,
+top_left_read_callback (GObject *source_object,
+ GAsyncResult *res,
gpointer callback_data)
{
+ TopLeftTextReadState *state;
NautilusDirectory *directory;
NautilusFileDetails *file_details;
+ gsize file_size;
+ char *file_contents;
- directory = NAUTILUS_DIRECTORY (callback_data);
-
- directory->details->top_left_read_state->handle = NULL;
+ state = callback_data;
- file_details = directory->details->top_left_read_state->file->details;
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ top_left_read_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ file_details = state->file->details;
file_details->top_left_text_is_up_to_date = TRUE;
g_free (file_details->top_left_text);
- if (result == GNOME_VFS_OK) {
- file_details->top_left_text = nautilus_extract_top_left_text (file_contents, directory->details->top_left_read_state->large, bytes_read);
+
+ if (g_file_load_partial_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL)) {
+ file_details->top_left_text = nautilus_extract_top_left_text (file_contents, state->large, file_size);
file_details->got_top_left_text = TRUE;
- file_details->got_large_top_left_text = directory->details->top_left_read_state->large;
+ file_details->got_large_top_left_text = state->large;
+ g_free (file_contents);
} else {
file_details->top_left_text = NULL;
file_details->got_top_left_text = FALSE;
file_details->got_large_top_left_text = FALSE;
}
- g_free (file_contents);
+ nautilus_file_changed (state->file);
- nautilus_file_changed (directory->details->top_left_read_state->file);
+ directory->details->top_left_read_state = NULL;
+ async_job_end (directory, "top left");
- top_left_read_done (directory);
+ top_left_read_state_free (state);
+
+ nautilus_directory_async_state_changed (directory);
+
+ nautilus_directory_unref (directory);
}
-static gboolean
-top_left_read_more_callback (GnomeVFSFileSize bytes_read,
- const char *file_contents,
- gpointer callback_data)
+static int
+count_lines (const char *text, int length)
{
- NautilusDirectory *directory;
-
- directory = NAUTILUS_DIRECTORY (callback_data);
-
+ int count, i;
- /* Stop reading when we have enough. */
- if (directory->details->top_left_read_state->large) {
- return bytes_read < NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_BYTES
- && count_lines (file_contents, bytes_read) <= NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_LINES;
- } else {
- return bytes_read < NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES
- && count_lines (file_contents, bytes_read) <= NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_LINES;
+ count = 0;
+ for (i = 0; i < length; i++) {
+ count += *text++ == '\n';
}
-
+ return count;
}
-static void
-top_left_stop (NautilusDirectory *directory)
+static gboolean
+top_left_read_more_callback (const char *file_contents,
+ goffset bytes_read,
+ gpointer callback_data)
{
- NautilusFile *file;
+ TopLeftTextReadState *state;
- if (directory->details->top_left_read_state != NULL) {
- file = directory->details->top_left_read_state->file;
- if (file != NULL) {
- g_assert (NAUTILUS_IS_FILE (file));
- g_assert (file->details->directory == directory);
- if (is_needy (file,
- lacks_top_left,
- wants_top_left) ||
- is_needy (file,
- lacks_large_top_left,
- wants_large_top_left)) {
- return;
- }
- }
+ state = callback_data;
- /* The top left is not wanted, so stop it. */
- top_left_cancel (directory);
+ /* Stop reading when we have enough. */
+ if (state->large) {
+ return bytes_read < NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_BYTES &&
+ count_lines (file_contents, bytes_read) <= NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_LINES;
+ } else {
+ return bytes_read < NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES &&
+ count_lines (file_contents, bytes_read) <= NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_LINES;
}
}
@@ -2775,8 +3183,9 @@ top_left_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
+ GFile *location;
gboolean needs_large;
+ TopLeftTextReadState *state;
if (directory->details->top_left_read_state != NULL) {
*doing_io = TRUE;
@@ -2816,42 +3225,56 @@ top_left_start (NautilusDirectory *directory,
}
/* Start reading. */
- directory->details->top_left_read_state = g_new0 (TopLeftTextReadState, 1);
- directory->details->top_left_read_state->large = needs_large;
- directory->details->top_left_read_state->file = file;
- uri = nautilus_file_get_uri (file);
- directory->details->top_left_read_state->handle = eel_read_file_async
- (uri,
- GNOME_VFS_PRIORITY_DEFAULT,
- top_left_read_callback,
- top_left_read_more_callback,
- directory);
- g_free (uri);
+ state = g_new0 (TopLeftTextReadState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+ state->large = needs_large;
+ state->file = file;
+
+ directory->details->top_left_read_state = state;
+
+ location = nautilus_file_get_location (file);
+ g_file_load_partial_contents_async (location,
+ state->cancellable,
+ top_left_read_more_callback,
+ top_left_read_callback,
+ state);
+ g_object_unref (location);
}
static void
-get_info_callback (GnomeVFSAsyncHandle *handle,
- GList *results,
- gpointer callback_data)
+get_info_state_free (GetInfoState *state)
+{
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
+
+static void
+query_info_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
NautilusDirectory *directory;
NautilusFile *get_info_file;
- GnomeVFSGetFileInfoResult *result;
- gboolean has_slow_mime_type;
+ GFileInfo *info;
+ GetInfoState *state;
+ GError *error;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ get_info_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
- directory = NAUTILUS_DIRECTORY (callback_data);
- g_assert (handle == NULL || handle == directory->details->get_info_in_progress);
- g_assert (eel_g_list_exactly_one_item (results));
get_info_file = directory->details->get_info_file;
g_assert (NAUTILUS_IS_FILE (get_info_file));
- nautilus_directory_ref (directory);
-
- has_slow_mime_type = directory->details->get_info_has_slow_mime_type;
-
directory->details->get_info_file = NULL;
directory->details->get_info_in_progress = NULL;
- directory->details->get_info_has_slow_mime_type = FALSE;
/* ref here because we might be removing the last ref when we
* mark the file gone below, but we need to keep a ref at
@@ -2859,22 +3282,21 @@ get_info_callback (GnomeVFSAsyncHandle *handle,
*/
nautilus_file_ref (get_info_file);
- result = results->data;
-
- if (result->result != GNOME_VFS_OK) {
- if (result->result == GNOME_VFS_ERROR_NOT_FOUND) {
+ error = NULL;
+ info = g_file_query_info_finish (G_FILE (source_object), res, &error);
+
+ if (info == NULL) {
+ if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND) {
/* mark file as gone */
nautilus_file_mark_gone (get_info_file);
}
get_info_file->details->file_info_is_up_to_date = TRUE;
- if (get_info_file->details->info != NULL) {
- gnome_vfs_file_info_unref (get_info_file->details->info);
- get_info_file->details->info = NULL;
- }
+ nautilus_file_clear_info (get_info_file);
get_info_file->details->get_info_failed = TRUE;
- get_info_file->details->get_info_error = result->result;
+ get_info_file->details->get_info_error = error;
} else {
- nautilus_file_update_info (get_info_file, result->file_info, has_slow_mime_type);
+ nautilus_file_update_info (get_info_file, info);
+ g_object_unref (info);
}
nautilus_file_changed (get_info_file);
@@ -2884,6 +3306,8 @@ get_info_callback (GnomeVFSAsyncHandle *handle,
nautilus_directory_async_state_changed (directory);
nautilus_directory_unref (directory);
+
+ get_info_state_free (state);
}
static void
@@ -2896,8 +3320,7 @@ file_info_stop (NautilusDirectory *directory)
if (file != NULL) {
g_assert (NAUTILUS_IS_FILE (file));
g_assert (file->details->directory == directory);
- if (is_needy (file, lacks_info, wants_info) ||
- is_needy (file, lacks_slow_mime_type, wants_slow_mime_type)) {
+ if (is_needy (file, lacks_info, wants_info)) {
return;
}
}
@@ -2912,11 +3335,8 @@ file_info_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
- GnomeVFSURI *vfs_uri;
- GList fake_list;
- gboolean need_slow_mime;
- GnomeVFSFileInfoOptions options;
+ GFile *location;
+ GetInfoState *state;
file_info_stop (directory);
@@ -2925,53 +3345,35 @@ file_info_start (NautilusDirectory *directory,
return;
}
- if (!is_needy (file, lacks_info, wants_info) &&
- !is_needy (file, lacks_slow_mime_type, wants_slow_mime_type)) {
+ if (!is_needy (file, lacks_info, wants_info)) {
return;
}
*doing_io = TRUE;
- need_slow_mime = is_needy (file, always_lacks, wants_slow_mime_type);
-
- uri = nautilus_file_get_uri (file);
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
-
- /* If we can't even get info, fill in the info and go on.
- */
-
- if (vfs_uri == NULL) {
- file->details->file_info_is_up_to_date = TRUE;
- file->details->get_info_failed = TRUE;
- file->details->get_info_error = GNOME_VFS_ERROR_INVALID_URI;
- file->details->got_slow_mime_type = need_slow_mime;
-
- nautilus_directory_async_state_changed (directory);
- return;
- }
-
if (!async_job_start (directory, "file info")) {
return;
}
+
directory->details->get_info_file = file;
file->details->get_info_failed = FALSE;
- fake_list.data = vfs_uri;
- fake_list.prev = NULL;
- fake_list.next = NULL;
-
- options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS;
- if (need_slow_mime) {
- options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE;
+ if (file->details->get_info_error) {
+ g_error_free (file->details->get_info_error);
+ file->details->get_info_error = NULL;
}
- directory->details->get_info_has_slow_mime_type = need_slow_mime;
- gnome_vfs_async_get_file_info
- (&directory->details->get_info_in_progress,
- &fake_list,
- options,
- GNOME_VFS_PRIORITY_DEFAULT,
- get_info_callback,
- directory);
- gnome_vfs_uri_unref (vfs_uri);
+
+ state = g_new (GetInfoState, 1);
+ state->directory = directory;
+ state->cancellable = g_cancellable_new ();
+
+ directory->details->get_info_in_progress = state;
+
+ location = nautilus_file_get_location (file);
+ g_file_query_info_async (location,
+ NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
+ 0,
+ G_PRIORITY_DEFAULT,
+ state->cancellable, query_info_callback, state);
+ g_object_unref (location);
}
static void
@@ -2979,40 +3381,23 @@ link_info_done (NautilusDirectory *directory,
NautilusFile *file,
const char *uri,
const char *name,
- const char *icon,
- gulong drive_id,
- gulong volume_id)
+ const char *icon)
{
- GnomeVFSVolumeMonitor *monitor;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
-
file->details->link_info_is_up_to_date = TRUE;
+ nautilus_file_set_display_name (file, name, name, TRUE);
+
file->details->got_link_info = TRUE;
- g_free (file->details->activation_uri);
- g_free (file->details->display_name);
g_free (file->details->custom_icon);
- file->details->activation_uri = g_strdup (uri);
- file->details->display_name = g_strdup (name);
- file->details->custom_icon = g_strdup (icon);
- nautilus_file_clear_cached_display_name (file);
-
- volume = NULL;
- if (volume_id != 0) {
- monitor = gnome_vfs_get_volume_monitor ();
- volume = gnome_vfs_volume_monitor_get_volume_by_id (monitor, volume_id);
- }
- nautilus_file_set_volume (file, volume);
- gnome_vfs_volume_unref (volume);
-
- drive = NULL;
- if (drive_id != 0) {
- monitor = gnome_vfs_get_volume_monitor ();
- drive = gnome_vfs_volume_monitor_get_drive_by_id (monitor, drive_id);
+ if (uri) {
+ if (file->details->activation_location) {
+ g_object_unref (file->details->activation_location);
+ file->details->activation_location = NULL;
+ }
+ file->details->got_custom_activation_location = TRUE;
+ file->details->activation_location = g_file_new_for_uri (uri);
}
- nautilus_file_set_drive (file, drive);
- gnome_vfs_drive_unref (drive);
+ file->details->custom_icon = g_strdup (icon);
nautilus_directory_async_state_changed (directory);
}
@@ -3020,68 +3405,64 @@ link_info_done (NautilusDirectory *directory,
static gboolean
should_read_link_info_sync (NautilusFile *file)
{
- return (nautilus_file_is_local (file) &&
- !nautilus_file_is_directory (file));
+#ifdef READ_LOCAL_LINKS_SYNC
+ return (nautilus_file_is_local (file) && !nautilus_file_is_directory (file));
+#else
+ return FALSE;
+#endif
}
static void
-link_info_read_done (NautilusDirectory *directory,
- const char *uri,
- const char *name,
- const char *icon,
- gulong drive_id,
- gulong volume_id)
+link_info_stop (NautilusDirectory *directory)
{
NautilusFile *file;
- file = directory->details->link_info_read_state->file;
- g_free (directory->details->link_info_read_state);
- directory->details->link_info_read_state = NULL;
+ if (directory->details->link_info_read_state != NULL) {
+ file = directory->details->link_info_read_state->file;
- nautilus_file_ref (file);
- link_info_done (directory, file, uri, name, icon, drive_id, volume_id);
- nautilus_file_changed (file);
+ if (file != NULL) {
+ g_assert (NAUTILUS_IS_FILE (file));
+ g_assert (file->details->directory == directory);
+ if (is_needy (file,
+ lacks_link_info,
+ wants_link_info)) {
+ return;
+ }
+ }
- if (!should_read_link_info_sync (file)) {
- async_job_end (directory, "link info");
+ /* The link info is not wanted, so stop it. */
+ link_info_cancel (directory);
}
-
- nautilus_file_unref (file);
}
-
static void
-link_info_nautilus_link_read_callback (GnomeVFSResult result,
- GnomeVFSFileSize bytes_read,
- char *file_contents,
- gpointer callback_data)
+link_info_got_data (NautilusDirectory *directory,
+ NautilusFile *file,
+ gboolean result,
+ goffset bytes_read,
+ char *file_contents)
{
- NautilusDirectory *directory;
- char *buffer, *uri, *name, *icon;
- gulong drive_id, volume_id;
-
- directory = NAUTILUS_DIRECTORY (callback_data);
+ char *uri, *name, *icon;
nautilus_directory_ref (directory);
+ uri = NULL;
+ name = NULL;
+ icon = NULL;
+
/* Handle the case where we read the Nautilus link. */
- if (result != GNOME_VFS_OK) {
- /* FIXME bugzilla.gnome.org 42433: We should report this error to the user. */
- g_free (file_contents);
- uri = NULL;
- name = NULL;
- icon = NULL;
- volume_id = drive_id = 0;
+ if (result) {
+ nautilus_link_get_link_info_given_file_contents (file_contents, bytes_read,
+ &uri, &name, &icon);
} else {
- /* The libxml parser requires a zero-terminated array. */
- buffer = g_realloc (file_contents, bytes_read + 1);
- buffer[bytes_read] = '\0';
- nautilus_link_get_link_info_given_file_contents (buffer, bytes_read,
- &uri, &name, &icon, &drive_id, &volume_id);
- g_free (buffer);
+ /* FIXME bugzilla.gnome.org 42433: We should report this error to the user. */
}
- link_info_read_done (directory, uri, name, icon, drive_id, volume_id);
+ nautilus_file_ref (file);
+ link_info_done (directory, file, uri, name, icon);
+ nautilus_file_changed (file);
+ nautilus_file_unref (file);
+
g_free (uri);
g_free (name);
g_free (icon);
@@ -3090,39 +3471,61 @@ link_info_nautilus_link_read_callback (GnomeVFSResult result,
}
static void
-link_info_stop (NautilusDirectory *directory)
+link_info_read_state_free (LinkInfoReadState *state)
{
- NautilusFile *file;
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
- if (directory->details->link_info_read_state != NULL) {
- file = directory->details->link_info_read_state->file;
+static void
+link_info_nautilus_link_read_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ LinkInfoReadState *state;
+ gsize file_size;
+ char *file_contents;
+ gboolean result;
+ NautilusDirectory *directory;
- if (file != NULL) {
- g_assert (NAUTILUS_IS_FILE (file));
- g_assert (file->details->directory == directory);
- if (is_needy (file,
- lacks_link_info,
- wants_link_info)) {
- return;
- }
- }
+ state = user_data;
- /* The link info is not wanted, so stop it. */
- link_info_cancel (directory);
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ link_info_read_state_free (state);
+ return;
}
-}
+ directory = nautilus_directory_ref (state->directory);
+
+ result = g_file_load_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL);
+
+ state->directory->details->link_info_read_state = NULL;
+ async_job_end (state->directory, "link info");
+
+ link_info_got_data (state->directory, state->file, result, file_size, file_contents);
+
+ g_free (file_contents);
+
+ link_info_read_state_free (state);
+
+ nautilus_directory_unref (directory);
+}
static void
link_info_start (NautilusDirectory *directory,
NautilusFile *file,
gboolean *doing_io)
{
- char *uri;
+ GFile *location;
gboolean nautilus_style_link;
- int file_size;
+ gsize file_size;
char *file_contents;
- GnomeVFSResult result;
+ gboolean result;
+ LinkInfoReadState *state;
if (directory->details->link_info_read_state != NULL) {
*doing_io = TRUE;
@@ -3138,39 +3541,246 @@ link_info_start (NautilusDirectory *directory,
/* Figure out if it is a link. */
nautilus_style_link = nautilus_file_is_nautilus_link (file);
- uri = nautilus_file_get_uri (file);
+ location = nautilus_file_get_location (file);
/* If it's not a link we are done. If it is, we need to read it. */
if (!nautilus_style_link) {
- link_info_done (directory, file, NULL, NULL, NULL, 0, 0);
+ link_info_done (directory, file, NULL, NULL, NULL);
} else if (should_read_link_info_sync (file)) {
- directory->details->link_info_read_state = g_new0 (LinkInfoReadState, 1);
- directory->details->link_info_read_state->file = file;
-
- result = eel_read_entire_file (uri, &file_size, &file_contents);
- link_info_nautilus_link_read_callback (result, file_size, file_contents, directory);
-
- /* We don't have to free file_contents here
- * because it's done in the callback function
- */
+ result = g_file_load_contents (location, NULL, &file_contents, &file_size, NULL, NULL);
+ link_info_got_data (directory, file, result, file_size, file_contents);
+ g_free (file_contents);
} else {
if (!async_job_start (directory, "link info")) {
- g_free (uri);
+ g_object_unref (location);
return;
}
- directory->details->link_info_read_state = g_new0 (LinkInfoReadState, 1);
- directory->details->link_info_read_state->file = file;
- directory->details->link_info_read_state->handle = eel_read_entire_file_async
- (uri,
- GNOME_VFS_PRIORITY_DEFAULT,
- link_info_nautilus_link_read_callback,
- directory);
+ state = g_new0 (LinkInfoReadState, 1);
+ state->directory = directory;
+ state->file = file;
+ state->cancellable = g_cancellable_new ();
+
+ directory->details->link_info_read_state = state;
+
+ g_file_load_contents_async (location,
+ state->cancellable,
+ link_info_nautilus_link_read_callback,
+ state);
}
- g_free (uri);
+ g_object_unref (location);
+}
+
+static void
+thumbnail_done (NautilusDirectory *directory,
+ NautilusFile *file,
+ GdkPixbuf *pixbuf,
+ gboolean tried_original)
+{
+ file->details->thumbnail_is_up_to_date = TRUE;
+ file->details->thumbnail_tried_original = tried_original;
+ if (file->details->thumbnail) {
+ g_object_unref (file->details->thumbnail);
+ file->details->thumbnail = NULL;
+ }
+ file->details->thumbnail_size = 0;
+ if (pixbuf) {
+ file->details->thumbnail = g_object_ref (pixbuf);
+ }
+
+ nautilus_directory_async_state_changed (directory);
+}
+
+static void
+thumbnail_stop (NautilusDirectory *directory)
+{
+ NautilusFile *file;
+
+ if (directory->details->thumbnail_state != NULL) {
+ file = directory->details->thumbnail_state->file;
+
+ if (file != NULL) {
+ g_assert (NAUTILUS_IS_FILE (file));
+ g_assert (file->details->directory == directory);
+ if (is_needy (file,
+ lacks_thumbnail,
+ wants_thumbnail)) {
+ return;
+ }
+ }
+
+ /* The link info is not wanted, so stop it. */
+ thumbnail_cancel (directory);
+ }
+}
+
+static void
+thumbnail_got_pixbuf (NautilusDirectory *directory,
+ NautilusFile *file,
+ GdkPixbuf *pixbuf,
+ gboolean tried_original)
+{
+ nautilus_directory_ref (directory);
+
+ nautilus_file_ref (file);
+ thumbnail_done (directory, file, pixbuf, tried_original);
+ nautilus_file_changed (file);
+ nautilus_file_unref (file);
+
+ if (pixbuf) {
+ g_object_unref (pixbuf);
+ }
+
+ nautilus_directory_unref (directory);
}
static void
+thumbnail_state_free (ThumbnailState *state)
+{
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
+
+static GdkPixbuf *
+get_pixbuf_for_content (goffset file_len,
+ char *file_contents)
+{
+ gboolean res;
+ GdkPixbuf *pixbuf, *pixbuf2;
+ GdkPixbufLoader *loader;
+ gsize chunk_len;
+ pixbuf = NULL;
+
+ loader = gdk_pixbuf_loader_new ();
+
+ /* For some reason we have to write in chunks, or gdk-pixbuf fails */
+ res = TRUE;
+ while (res && file_len > 0) {
+ chunk_len = MIN (32*1024, file_len);
+ res = gdk_pixbuf_loader_write (loader, file_contents, chunk_len, NULL);
+ file_contents += chunk_len;
+ file_len -= chunk_len;
+ }
+ if (res) {
+ res = gdk_pixbuf_loader_close (loader, NULL);
+ }
+ if (res) {
+ pixbuf = g_object_ref (gdk_pixbuf_loader_get_pixbuf (loader));
+ }
+ g_object_unref (G_OBJECT (loader));
+
+ if (pixbuf) {
+ pixbuf2 = gdk_pixbuf_apply_embedded_orientation (pixbuf);
+ g_object_unref (pixbuf);
+ pixbuf = pixbuf2;
+ }
+ return pixbuf;
+}
+
+
+static void
+thumbnail_read_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ ThumbnailState *state;
+ gsize file_size;
+ char *file_contents;
+ gboolean result;
+ NautilusDirectory *directory;
+ GdkPixbuf *pixbuf;
+ GFile *location;
+
+ state = user_data;
+
+ if (state->directory == NULL) {
+ /* Operation was cancelled. Bail out */
+ thumbnail_state_free (state);
+ return;
+ }
+
+ directory = nautilus_directory_ref (state->directory);
+
+ result = g_file_load_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL);
+
+ pixbuf = NULL;
+ if (result) {
+ pixbuf = get_pixbuf_for_content (file_size, file_contents);
+ g_free (file_contents);
+ }
+
+ if (pixbuf == NULL && state->trying_original) {
+ state->trying_original = FALSE;
+
+ location = g_file_new_for_path (state->file->details->thumbnail_path);
+ g_file_load_contents_async (location,
+ state->cancellable,
+ thumbnail_read_callback,
+ state);
+ g_object_unref (location);
+ } else {
+ state->directory->details->thumbnail_state = NULL;
+ async_job_end (state->directory, "thumbnail");
+
+ thumbnail_got_pixbuf (state->directory, state->file, pixbuf, state->tried_original);
+
+ thumbnail_state_free (state);
+ }
+
+ nautilus_directory_unref (directory);
+}
+
+static void
+thumbnail_start (NautilusDirectory *directory,
+ NautilusFile *file,
+ gboolean *doing_io)
+{
+ GFile *location;
+ ThumbnailState *state;
+
+ if (directory->details->thumbnail_state != NULL) {
+ *doing_io = TRUE;
+ return;
+ }
+
+ if (!is_needy (file,
+ lacks_thumbnail,
+ wants_thumbnail)) {
+ return;
+ }
+ *doing_io = TRUE;
+
+ if (!async_job_start (directory, "thumbnail")) {
+ return;
+ }
+
+ state = g_new0 (ThumbnailState, 1);
+ state->directory = directory;
+ state->file = file;
+ state->cancellable = g_cancellable_new ();
+
+ if (file->details->thumbnail_size > 128) {
+ state->tried_original = TRUE;
+ state->trying_original = TRUE;
+ location = nautilus_file_get_location (file);
+ } else {
+ location = g_file_new_for_path (file->details->thumbnail_path);
+ }
+
+ directory->details->thumbnail_state = state;
+
+ g_file_load_contents_async (location,
+ state->cancellable,
+ thumbnail_read_callback,
+ state);
+ g_object_unref (location);
+}
+
+
+static void
extension_info_cancel (NautilusDirectory *directory)
{
if (directory->details->extension_info_in_progress != NULL) {
@@ -3346,6 +3956,7 @@ start_or_stop_io (NautilusDirectory *directory)
top_left_stop (directory);
link_info_stop (directory);
extension_info_stop (directory);
+ thumbnail_stop (directory);
doing_io = FALSE;
/* Take files that are all done off the queue. */
@@ -3372,6 +3983,7 @@ start_or_stop_io (NautilusDirectory *directory)
deep_count_start (directory, file, &doing_io);
mime_list_start (directory, file, &doing_io);
top_left_start (directory, file, &doing_io);
+ thumbnail_start (directory, file, &doing_io);
if (doing_io) {
return;
@@ -3441,6 +4053,7 @@ nautilus_directory_cancel (NautilusDirectory *directory)
new_files_cancel (directory);
top_left_cancel (directory);
extension_info_cancel (directory);
+ thumbnail_cancel (directory);
/* We aren't waiting for anything any more. */
if (waiting_directories != NULL) {
@@ -3499,7 +4112,7 @@ cancel_file_info_for_file (NautilusDirectory *directory,
static void
cancel_link_info_for_file (NautilusDirectory *directory,
- NautilusFile *file)
+ NautilusFile *file)
{
if (directory->details->link_info_read_state != NULL &&
directory->details->link_info_read_state->file == file) {
@@ -3540,6 +4153,10 @@ cancel_loading_attributes (NautilusDirectory *directory,
extension_info_cancel (directory);
}
+ if (request.thumbnail) {
+ thumbnail_cancel (directory);
+ }
+
/* FIXME bugzilla.gnome.org 45064: implement cancelling metadata when we
implement invalidating metadata */
diff --git a/libnautilus-private/nautilus-directory-background.c b/libnautilus-private/nautilus-directory-background.c
index 092b85e06..4e00649c1 100644
--- a/libnautilus-private/nautilus-directory-background.c
+++ b/libnautilus-private/nautilus-directory-background.c
@@ -34,12 +34,7 @@
#include "nautilus-global-preferences.h"
#include "nautilus-metadata.h"
#include "nautilus-file-attributes.h"
-#include <eel/eel-string.h>
#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <libgnome/gnome-config.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libbackground/preferences.h>
static void background_changed_callback (EelBackground *background,
@@ -125,7 +120,7 @@ nautilus_file_background_read_desktop_settings (char **color,
if (prefs->wallpaper_enabled) {
if (prefs->wallpaper_filename != NULL &&
prefs->wallpaper_filename [0] != '\0') {
- *image = gnome_vfs_get_uri_from_local_path (prefs->wallpaper_filename);
+ *image = g_filename_to_uri (prefs->wallpaper_filename, NULL, NULL);
} else {
*image = NULL;
}
@@ -218,7 +213,7 @@ nautilus_file_background_write_desktop_settings (char *color, char *image, EelBa
original_filename = prefs->wallpaper_filename;
if (image != NULL) {
- prefs->wallpaper_filename = gnome_vfs_get_local_path_from_uri (image);
+ prefs->wallpaper_filename = g_filename_from_uri (image, NULL, NULL);
prefs->wallpaper_enabled = TRUE;
switch (placement) {
case EEL_BACKGROUND_TILED:
diff --git a/libnautilus-private/nautilus-directory-metafile-monitor.c b/libnautilus-private/nautilus-directory-metafile-monitor.c
index 4297d0f18..f67e6a1d1 100644
--- a/libnautilus-private/nautilus-directory-metafile-monitor.c
+++ b/libnautilus-private/nautilus-directory-metafile-monitor.c
@@ -81,7 +81,7 @@ corba_metafile_changed (PortableServer_Servant servant,
file_list = NULL;
for (buf_pos = 0; buf_pos < file_names->_length; ++buf_pos) {
- file = nautilus_directory_find_file_by_internal_uri
+ file = nautilus_directory_find_file_by_internal_filename
(monitor->details->directory, file_names->_buffer [buf_pos]);
if (file != NULL) {
diff --git a/libnautilus-private/nautilus-directory-notify.h b/libnautilus-private/nautilus-directory-notify.h
index 50e4e9a9e..1d65c9172 100644
--- a/libnautilus-private/nautilus-directory-notify.h
+++ b/libnautilus-private/nautilus-directory-notify.h
@@ -31,20 +31,36 @@ typedef struct {
} URIPair;
typedef struct {
- char *uri;
+ GFile *from;
+ GFile *to;
+} GFilePair;
+
+typedef struct {
+ GFile *location;
gboolean set;
GdkPoint point;
int screen;
} NautilusFileChangesQueuePosition;
/* Almost-public change notification calls */
-void nautilus_directory_notify_files_added (GList *uris);
-void nautilus_directory_notify_files_changed (GList *uris);
-void nautilus_directory_notify_files_moved (GList *uri_pairs);
-void nautilus_directory_notify_files_removed (GList *uris);
-void nautilus_directory_schedule_metadata_copy (GList *uri_pairs);
-void nautilus_directory_schedule_metadata_move (GList *uri_pairs);
-void nautilus_directory_schedule_metadata_remove (GList *uris);
+void nautilus_directory_notify_files_added (GList *files);
+void nautilus_directory_notify_files_moved (GList *file_pairs);
+void nautilus_directory_notify_files_changed (GList *files);
+void nautilus_directory_notify_files_removed (GList *files);
+
+void nautilus_directory_schedule_metadata_copy (GList *file_pairs);
+void nautilus_directory_schedule_metadata_move (GList *file_pairs);
+void nautilus_directory_schedule_metadata_remove (GList *files);
+
+/* Deprecated URI versions: to be converted */
+void nautilus_directory_notify_files_added_by_uri (GList *uris);
+void nautilus_directory_notify_files_changed_by_uri (GList *uris);
+void nautilus_directory_notify_files_moved_by_uri (GList *uri_pairs);
+void nautilus_directory_notify_files_removed_by_uri (GList *uris);
+
+void nautilus_directory_schedule_metadata_copy_by_uri (GList *uri_pairs);
+void nautilus_directory_schedule_metadata_move_by_uri (GList *uri_pairs);
+void nautilus_directory_schedule_metadata_remove_by_uri (GList *uris);
void nautilus_directory_schedule_position_set (GList *position_setting_list);
/* Change notification hack.
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index 1d15b90e2..e5bb36052 100644
--- a/libnautilus-private/nautilus-directory-private.h
+++ b/libnautilus-private/nautilus-directory-private.h
@@ -22,10 +22,8 @@
Author: Darin Adler <darin@bentspoon.com>
*/
+#include <gio/gfile.h>
#include <eel/eel-vfs-extensions.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus-private/nautilus-directory-metafile-monitor.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file-queue.h>
@@ -39,13 +37,18 @@
typedef struct LinkInfoReadState LinkInfoReadState;
typedef struct TopLeftTextReadState TopLeftTextReadState;
typedef struct FileMonitors FileMonitors;
+typedef struct DirectoryLoadState DirectoryLoadState;
+typedef struct DirectoryCountState DirectoryCountState;
+typedef struct DeepCountState DeepCountState;
+typedef struct GetInfoState GetInfoState;
+typedef struct NewFilesState NewFilesState;
+typedef struct MimeListState MimeListState;
+typedef struct ThumbnailState ThumbnailState;
struct NautilusDirectoryDetails
{
/* The location. */
- char *uri;
- GnomeVFSURI *vfs_uri;
- int is_local_state;
+ GFile *location;
/* The file objects. */
NautilusFile *as_file;
@@ -77,44 +80,33 @@ struct NautilusDirectoryDetails
gboolean file_list_monitored;
gboolean directory_loaded;
gboolean directory_loaded_sent_notification;
- GnomeVFSAsyncHandle *directory_load_in_progress;
+ DirectoryLoadState *directory_load_in_progress;
GList *pending_file_info; /* list of GnomeVFSFileInfo's that are pending */
int confirmed_file_count;
guint dequeue_pending_idle_id;
- NautilusFile *load_directory_file;
- int load_file_count;
- GHashTable *load_mime_list_hash;
-
- GList *get_file_infos_in_progress; /* list of GnomeVFSAsyncHandle * */
+ GList *new_files_in_progress; /* list of NewFilesState * */
NautilusFile *count_file;
- GnomeVFSAsyncHandle *count_in_progress;
+ DirectoryCountState *count_in_progress;
NautilusFile *deep_count_file;
- GnomeVFSAsyncHandle *deep_count_in_progress;
- char *deep_count_uri;
- GList *deep_count_subdirectories;
+ DeepCountState *deep_count_in_progress;
NautilusFile *mime_list_file;
- GnomeVFSAsyncHandle *mime_list_in_progress;
- GHashTable *mime_list_hash;
+ MimeListState *mime_list_in_progress;
NautilusFile *get_info_file;
- GnomeVFSAsyncHandle *get_info_in_progress;
- gboolean get_info_has_slow_mime_type;
-
- int is_in_trash_state;
-
- NautilusFile *slow_mime_type_file;
- GnomeVFSAsyncHandle *slow_mime_type_in_progress;
+ GetInfoState *get_info_in_progress;
NautilusFile *extension_info_file;
NautilusInfoProvider *extension_info_provider;
NautilusOperationHandle *extension_info_in_progress;
guint extension_info_idle;
+ ThumbnailState *thumbnail_state;
+
TopLeftTextReadState *top_left_read_state;
LinkInfoReadState *link_info_read_state;
@@ -136,10 +128,10 @@ typedef struct {
gboolean top_left_text;
gboolean large_top_left_text;
gboolean extension_info;
- gboolean slow_mime_type;
+ gboolean thumbnail;
} Request;
-NautilusDirectory *nautilus_directory_get_existing (const char *uri);
+NautilusDirectory *nautilus_directory_get_existing (GFile *location);
/* async. interface */
void nautilus_directory_async_state_changed (NautilusDirectory *directory);
@@ -195,11 +187,11 @@ void nautilus_directory_emit_files_changed (NautilusD
void nautilus_directory_emit_change_signals (NautilusDirectory *directory,
GList *changed_files);
void emit_change_signals_for_all_files (NautilusDirectory *directory);
+void emit_change_signals_for_all_files_in_all_directories (void);
void nautilus_directory_emit_done_loading (NautilusDirectory *directory);
void nautilus_directory_emit_load_error (NautilusDirectory *directory,
- GnomeVFSResult error_result,
- const char *error_message);
-NautilusDirectory *nautilus_directory_get_internal (const char *uri,
+ GError *error);
+NautilusDirectory *nautilus_directory_get_internal (GFile *location,
gboolean create);
char * nautilus_directory_get_name_for_self_as_new_file (NautilusDirectory *directory);
void nautilus_directory_set_up_request (Request *request,
@@ -207,11 +199,9 @@ void nautilus_directory_set_up_request (Request
/* Interface to the file list. */
NautilusFile * nautilus_directory_find_file_by_name (NautilusDirectory *directory,
- const char *relative_uri);
-NautilusFile * nautilus_directory_find_file_by_relative_uri (NautilusDirectory *directory,
- const char *relative_uri);
-NautilusFile * nautilus_directory_find_file_by_internal_uri (NautilusDirectory *directory,
- const char *relative_uri);
+ const char *filename);
+NautilusFile * nautilus_directory_find_file_by_internal_filename (NautilusDirectory *directory,
+ const char *internal_filename);
void nautilus_directory_add_file (NautilusDirectory *directory,
NautilusFile *file);
diff --git a/libnautilus-private/nautilus-directory.c b/libnautilus-private/nautilus-directory.c
index c02d1528a..6e84bbdd4 100644
--- a/libnautilus-private/nautilus-directory.c
+++ b/libnautilus-private/nautilus-directory.c
@@ -37,14 +37,12 @@
#include "nautilus-metadata.h"
#include "nautilus-metafile.h"
#include "nautilus-desktop-directory.h"
-#include "nautilus-trash-directory.h"
#include "nautilus-vfs-directory.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
enum {
FILES_ADDED,
@@ -59,10 +57,10 @@ static guint signals[LAST_SIGNAL];
/* Specifications for parallel-directory metafile. */
#define METAFILES_DIRECTORY_NAME "metafiles"
#define METAFILE_SUFFIX ".xml"
-#define METAFILES_DIRECTORY_PERMISSIONS \
- (GNOME_VFS_PERM_USER_ALL \
- | GNOME_VFS_PERM_GROUP_ALL \
- | GNOME_VFS_PERM_OTHER_ALL)
+#define METAFILES_DIRECTORY_PERMISSIONS \
+ (S_IRUSR | S_IWUSR | S_IXUSR | \
+ S_IRGRP | S_IWGRP | S_IXGRP | \
+ S_IROTH | S_IWOTH | S_IXOTH)
static GHashTable *directories;
@@ -70,12 +68,12 @@ static void nautilus_directory_finalize (GObject
static void nautilus_directory_init (gpointer object,
gpointer klass);
static void nautilus_directory_class_init (NautilusDirectoryClass *klass);
-static NautilusDirectory *nautilus_directory_new (const char *uri);
+static NautilusDirectory *nautilus_directory_new (GFile *location);
static char * real_get_name_for_self_as_new_file (NautilusDirectory *directory);
static GList * real_get_file_list (NautilusDirectory *directory);
static gboolean real_is_editable (NautilusDirectory *directory);
-static void set_directory_uri (NautilusDirectory *directory,
- const char *new_uri);
+static void set_directory_location (NautilusDirectory *directory,
+ GFile *location);
EEL_CLASS_BOILERPLATE (NautilusDirectory,
nautilus_directory,
@@ -120,8 +118,8 @@ nautilus_directory_class_init (NautilusDirectoryClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusDirectoryClass, load_error),
NULL, NULL,
- nautilus_marshal_VOID__INT_STRING,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING);
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
klass->get_name_for_self_as_new_file = real_get_name_for_self_as_new_file;
klass->get_file_list = real_get_file_list;
@@ -143,8 +141,6 @@ nautilus_directory_init (gpointer object, gpointer klass)
directory->details->low_priority_queue = nautilus_file_queue_new ();
directory->details->extension_queue = nautilus_file_queue_new ();
directory->details->idle_queue = nautilus_idle_queue_new ();
-
- directory->details->hidden_file_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
}
NautilusDirectory *
@@ -179,7 +175,7 @@ nautilus_directory_finalize (GObject *object)
directory = NAUTILUS_DIRECTORY (object);
- g_hash_table_remove (directories, directory->details->uri);
+ g_hash_table_remove (directories, directory->details->location);
nautilus_directory_cancel (directory);
g_assert (directory->details->count_in_progress == NULL);
@@ -207,17 +203,17 @@ nautilus_directory_finalize (GObject *object)
if (directory->details->call_ready_idle_id != 0) {
g_source_remove (directory->details->call_ready_idle_id);
}
-
- g_free (directory->details->uri);
- if (directory->details->vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->vfs_uri);
+ if (directory->details->location) {
+ g_object_unref (directory->details->location);
}
g_assert (directory->details->file_list == NULL);
g_hash_table_destroy (directory->details->file_hash);
- g_hash_table_destroy (directory->details->hidden_file_hash);
+ if (directory->details->hidden_file_hash) {
+ g_hash_table_destroy (directory->details->hidden_file_hash);
+ }
nautilus_file_queue_destroy (directory->details->high_priority_queue);
nautilus_file_queue_destroy (directory->details->low_priority_queue);
@@ -226,7 +222,7 @@ nautilus_directory_finalize (GObject *object)
g_assert (directory->details->directory_load_in_progress == NULL);
g_assert (directory->details->count_in_progress == NULL);
g_assert (directory->details->dequeue_pending_idle_id == 0);
- gnome_vfs_file_info_list_unref (directory->details->pending_file_info);
+ eel_g_object_list_free (directory->details->pending_file_info);
EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
}
@@ -273,6 +269,40 @@ emit_change_signals_for_all_files (NautilusDirectory *directory)
}
static void
+collect_all_directories (gpointer key, gpointer value, gpointer callback_data)
+{
+ NautilusDirectory *directory;
+ GList **dirs;
+ GFile *location;
+
+ location = (GFile *) key;
+ directory = NAUTILUS_DIRECTORY (value);
+ dirs = callback_data;
+
+ *dirs = g_list_prepend (*dirs, nautilus_directory_ref (directory));
+}
+
+void
+emit_change_signals_for_all_files_in_all_directories (void)
+{
+ GList *dirs, *l;
+ NautilusDirectory *directory;
+
+ dirs = NULL;
+ g_hash_table_foreach (directories,
+ collect_all_directories,
+ &dirs);
+
+ for (l = dirs; l != NULL; l = l->next) {
+ directory = NAUTILUS_DIRECTORY (l->data);
+ emit_change_signals_for_all_files (directory);
+ nautilus_directory_unref (directory);
+ }
+
+ g_list_free (dirs);
+}
+
+static void
async_state_changed_one (gpointer key, gpointer value, gpointer user_data)
{
NautilusDirectory *directory;
@@ -321,45 +351,8 @@ add_preferences_callbacks (void)
NULL);
}
-char *
-nautilus_directory_make_uri_canonical (const char *uri)
-{
- char *canonical_maybe_trailing_slash;
- char *canonical;
- char *with_slashes;
- size_t length;
-
- canonical_maybe_trailing_slash = eel_make_uri_canonical (uri);
-
- /* To NautilusDirectory, a uri with or without a trailing
- * / is equivalent. This is necessary to prevent separate
- * NautilusDirectories for the same location from being
- * created. (See bugzilla.gnome.org 43322 for an example.)
- */
- canonical = eel_str_strip_trailing_chr (canonical_maybe_trailing_slash, '/');
- if (strcmp (canonical, canonical_maybe_trailing_slash) != 0 &&
- strcmp (canonical, "favorites:") != 0) {
- /* If some trailing '/' were stripped, there's the possibility,
- * that we stripped away all the '/' from a uri that has only
- * '/' characters. If you change this code, check to make sure
- * that "file:///" still works as a URI.
- */
- length = strlen (canonical);
- if (length == 0 || canonical[length - 1] == ':') {
- with_slashes = g_strconcat (canonical, "///", NULL);
- g_free (canonical);
- canonical = with_slashes;
- }
- }
-
- g_free (canonical_maybe_trailing_slash);
-
- return canonical;
-}
-
-
/**
- * nautilus_directory_get:
+ * nautilus_directory_get_by_uri:
* @uri: URI of directory to get.
*
* Get a directory given a uri.
@@ -368,21 +361,14 @@ nautilus_directory_make_uri_canonical (const char *uri)
* If two windows are viewing the same uri, the directory object is shared.
*/
NautilusDirectory *
-nautilus_directory_get_internal (const char *uri, gboolean create)
+nautilus_directory_get_internal (GFile *location, gboolean create)
{
- char *canonical_uri;
NautilusDirectory *directory;
-
- if (uri == NULL) {
- return NULL;
- }
-
- canonical_uri = nautilus_directory_make_uri_canonical (uri);
-
+
/* Create the hash table first time through. */
if (directories == NULL) {
directories = eel_g_hash_table_new_free_at_exit
- (g_str_hash, g_str_equal, "nautilus-directory.c: directories");
+ (g_file_hash, (GCompareFunc)g_file_equal, "nautilus-directory.c: directories");
add_preferences_callbacks ();
}
@@ -390,39 +376,61 @@ nautilus_directory_get_internal (const char *uri, gboolean create)
/* If the object is already in the hash table, look it up. */
directory = g_hash_table_lookup (directories,
- canonical_uri);
+ location);
if (directory != NULL) {
nautilus_directory_ref (directory);
} else if (create) {
/* Create a new directory object instead. */
- directory = nautilus_directory_new (canonical_uri);
+ directory = nautilus_directory_new (location);
if (directory == NULL) {
return NULL;
}
- g_assert (strcmp (directory->details->uri, canonical_uri) == 0);
-
/* Put it in the hash table. */
g_hash_table_insert (directories,
- directory->details->uri,
+ directory->details->location,
directory);
}
- g_free (canonical_uri);
-
return directory;
}
NautilusDirectory *
-nautilus_directory_get (const char *uri)
+nautilus_directory_get (GFile *location)
{
- return nautilus_directory_get_internal (uri, TRUE);
+ if (location == NULL) {
+ return NULL;
+ }
+
+ return nautilus_directory_get_internal (location, TRUE);
}
NautilusDirectory *
-nautilus_directory_get_existing (const char *uri)
+nautilus_directory_get_existing (GFile *location)
{
- return nautilus_directory_get_internal (uri, FALSE);
+ if (location == NULL) {
+ return NULL;
+ }
+
+ return nautilus_directory_get_internal (location, FALSE);
+}
+
+
+NautilusDirectory *
+nautilus_directory_get_by_uri (const char *uri)
+{
+ NautilusDirectory *directory;
+ GFile *location;
+
+ if (uri == NULL) {
+ return NULL;
+ }
+
+ location = g_file_new_for_uri (uri);
+
+ directory = nautilus_directory_get_internal (location, TRUE);
+ g_object_unref (location);
+ return directory;
}
NautilusDirectory *
@@ -434,7 +442,7 @@ nautilus_directory_get_for_file (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
uri = nautilus_file_get_uri (file);
- directory = nautilus_directory_get (uri);
+ directory = nautilus_directory_get_by_uri (uri);
g_free (uri);
return directory;
}
@@ -445,10 +453,13 @@ NautilusFile *
nautilus_directory_get_corresponding_file (NautilusDirectory *directory)
{
NautilusFile *file;
+ char *uri;
file = nautilus_directory_get_existing_corresponding_file (directory);
if (file == NULL) {
- file = nautilus_file_get (directory->details->uri);
+ uri = nautilus_directory_get_uri (directory);
+ file = nautilus_file_get_by_uri (uri);
+ g_free (uri);
}
return file;
@@ -461,6 +472,7 @@ NautilusFile *
nautilus_directory_get_existing_corresponding_file (NautilusDirectory *directory)
{
NautilusFile *file;
+ char *uri;
file = directory->details->as_file;
if (file != NULL) {
@@ -468,7 +480,10 @@ nautilus_directory_get_existing_corresponding_file (NautilusDirectory *directory
return file;
}
- return nautilus_file_get_existing (directory->details->uri);
+ uri = nautilus_directory_get_uri (directory);
+ file = nautilus_file_get_existing_by_uri (uri);
+ g_free (uri);
+ return file;
}
/* nautilus_directory_get_name_for_self_as_new_file:
@@ -490,10 +505,10 @@ nautilus_directory_get_name_for_self_as_new_file (NautilusDirectory *directory)
static char *
real_get_name_for_self_as_new_file (NautilusDirectory *directory)
{
- const char *directory_uri;
+ char *directory_uri;
char *name, *colon;
- directory_uri = directory->details->uri;
+ directory_uri = nautilus_directory_get_uri (directory);
colon = strchr (directory_uri, ':');
if (colon == NULL || colon == directory_uri) {
@@ -501,7 +516,8 @@ real_get_name_for_self_as_new_file (NautilusDirectory *directory)
} else {
name = g_strndup (directory_uri, colon - directory_uri);
}
-
+ g_free (directory_uri);
+
return name;
}
@@ -510,20 +526,26 @@ nautilus_directory_get_uri (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- return g_strdup (directory->details->uri);
+ return g_file_get_uri (directory->details->location);
}
+GFile *
+nautilus_directory_get_location (NautilusDirectory *directory)
+{
+ g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
+
+ return g_object_ref (directory->details->location);
+}
static NautilusDirectory *
-nautilus_directory_new (const char *uri)
+nautilus_directory_new (GFile *location)
{
NautilusDirectory *directory;
+ char *uri;
- g_assert (uri != NULL);
-
- if (eel_uri_is_trash (uri)) {
- directory = NAUTILUS_DIRECTORY (g_object_new (NAUTILUS_TYPE_TRASH_DIRECTORY, NULL));
- } else if (eel_uri_is_desktop (uri)) {
+ uri = g_file_get_uri (location);
+
+ if (eel_uri_is_desktop (uri)) {
directory = NAUTILUS_DIRECTORY (g_object_new (NAUTILUS_TYPE_DESKTOP_DIRECTORY, NULL));
} else if (eel_uri_is_search (uri)) {
directory = NAUTILUS_DIRECTORY (g_object_new (NAUTILUS_TYPE_SEARCH_DIRECTORY, NULL));
@@ -533,8 +555,10 @@ nautilus_directory_new (const char *uri)
directory = NAUTILUS_DIRECTORY (g_object_new (NAUTILUS_TYPE_VFS_DIRECTORY, NULL));
}
- set_directory_uri (directory, uri);
+ set_directory_location (directory, location);
+ g_free (uri);
+
return directory;
}
@@ -543,37 +567,30 @@ nautilus_directory_is_local (NautilusDirectory *directory)
{
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), FALSE);
- if (directory->details->vfs_uri == NULL) {
+ if (directory->details->location == NULL) {
return TRUE;
}
- if (directory->details->is_local_state == 0) {
- if (gnome_vfs_uri_is_local (directory->details->vfs_uri)) {
- directory->details->is_local_state = 1;
- } else {
- directory->details->is_local_state = -1;
- }
- }
-
- return directory->details->is_local_state > 0;
+ return g_file_is_native (directory->details->location);
}
gboolean
nautilus_directory_is_in_trash (NautilusDirectory *directory)
{
+ char *uri;
+ gboolean res;
+
g_assert (NAUTILUS_IS_DIRECTORY (directory));
- if (directory->details->uri == NULL) {
+ if (directory->details->location == NULL) {
return FALSE;
}
- if (directory->details->is_in_trash_state == 0) {
- if (eel_uri_is_in_trash (directory->details->uri)) {
- directory->details->is_in_trash_state = 1;
- } else {
- directory->details->is_in_trash_state = -1;
- }
- }
- return directory->details->is_in_trash_state > 0;
+ /* TODO-gio: Should have g_file_is_in_trash()? */
+ uri = nautilus_directory_get_uri (directory);
+ res = eel_uri_is_trash (uri);
+ g_free (uri);
+
+ return res;
}
gboolean
@@ -589,27 +606,30 @@ nautilus_directory_are_all_files_seen (NautilusDirectory *directory)
static void
add_to_hash_table (NautilusDirectory *directory, NautilusFile *file, GList *node)
{
+ const char *name;
+
+ name = eel_ref_str_peek (file->details->name);
+
g_assert (node != NULL);
g_assert (g_hash_table_lookup (directory->details->file_hash,
- file->details->relative_uri) == NULL);
- g_hash_table_insert (directory->details->file_hash,
- file->details->relative_uri, node);
+ name) == NULL);
+ g_hash_table_insert (directory->details->file_hash, (char *) name, node);
}
static GList *
extract_from_hash_table (NautilusDirectory *directory, NautilusFile *file)
{
- char *relative_uri;
+ const char *name;
GList *node;
- relative_uri = file->details->relative_uri;
- if (relative_uri == NULL) {
+ name = eel_ref_str_peek (file->details->name);
+ if (name == NULL) {
return NULL;
}
/* Find the list node in the hash table. */
- node = g_hash_table_lookup (directory->details->file_hash, relative_uri);
- g_hash_table_remove (directory->details->file_hash, relative_uri);
+ node = g_hash_table_lookup (directory->details->file_hash, name);
+ g_hash_table_remove (directory->details->file_hash, name);
return node;
}
@@ -621,7 +641,7 @@ nautilus_directory_add_file (NautilusDirectory *directory, NautilusFile *file)
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (NAUTILUS_IS_FILE (file));
- g_assert (file->details->relative_uri != NULL);
+ g_assert (file->details->name != NULL);
/* Add to list. */
node = g_list_prepend (directory->details->file_list, file);
@@ -646,7 +666,7 @@ nautilus_directory_remove_file (NautilusDirectory *directory, NautilusFile *file
g_assert (NAUTILUS_IS_DIRECTORY (directory));
g_assert (NAUTILUS_IS_FILE (file));
- g_assert (file->details->relative_uri != NULL);
+ g_assert (file->details->name != NULL);
/* Find the list node in the hash table. */
node = extract_from_hash_table (directory, file);
@@ -717,46 +737,30 @@ NautilusFile *
nautilus_directory_find_file_by_name (NautilusDirectory *directory,
const char *name)
{
- char *relative_uri;
- NautilusFile *file;
-
- g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- relative_uri = gnome_vfs_escape_string (name);
- file = nautilus_directory_find_file_by_relative_uri
- (directory, relative_uri);
- g_free (relative_uri);
- return file;
-}
-
-NautilusFile *
-nautilus_directory_find_file_by_relative_uri (NautilusDirectory *directory,
- const char *relative_uri)
-{
GList *node;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- g_return_val_if_fail (relative_uri != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
node = g_hash_table_lookup (directory->details->file_hash,
- relative_uri);
+ name);
return node == NULL ? NULL : NAUTILUS_FILE (node->data);
}
+/* "." for the directory-as-file, otherwise the filename */
NautilusFile *
-nautilus_directory_find_file_by_internal_uri (NautilusDirectory *directory,
- const char *relative_uri)
+nautilus_directory_find_file_by_internal_filename (NautilusDirectory *directory,
+ const char *internal_filename)
{
NautilusFile *result;
- if (eel_strcmp (relative_uri, ".") == 0) {
+ if (eel_strcmp (internal_filename, ".") == 0) {
result = nautilus_directory_get_existing_corresponding_file (directory);
if (result != NULL) {
nautilus_file_unref (result);
}
} else {
- result = nautilus_directory_find_file_by_relative_uri (directory, relative_uri);
+ result = nautilus_directory_find_file_by_name (directory, internal_filename);
}
return result;
@@ -805,69 +809,45 @@ nautilus_directory_emit_done_loading (NautilusDirectory *directory)
void
nautilus_directory_emit_load_error (NautilusDirectory *directory,
- GnomeVFSResult error_result,
- const char *error_message)
+ GError *error)
{
g_signal_emit (directory,
signals[LOAD_ERROR], 0,
- error_result, error_message);
-}
-
-
-static char *
-uri_get_directory_part (const char *uri)
-{
- GnomeVFSURI *vfs_uri, *directory_vfs_uri;
- char *directory_uri;
-
- /* Make VFS version of URI. */
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- return NULL;
- }
-
- /* Make VFS version of directory URI. */
- directory_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- if (directory_vfs_uri == NULL) {
- return NULL;
- }
-
- /* Make text version of directory URI. */
- directory_uri = gnome_vfs_uri_to_string (directory_vfs_uri,
- GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (directory_vfs_uri);
-
- return directory_uri;
+ error);
}
/* Return a directory object for this one's parent. */
static NautilusDirectory *
-get_parent_directory (const char *uri)
+get_parent_directory (GFile *location)
{
- char *directory_uri;
NautilusDirectory *directory;
+ GFile *parent;
- directory_uri = uri_get_directory_part (uri);
- directory = nautilus_directory_get (directory_uri);
- g_free (directory_uri);
- return directory;
+ parent = g_file_get_parent (location);
+ if (parent) {
+ directory = nautilus_directory_get_internal (parent, TRUE);
+ g_object_unref (parent);
+ return directory;
+ }
+ return NULL;
}
/* If a directory object exists for this one's parent, then
* return it, otherwise return NULL.
*/
static NautilusDirectory *
-get_parent_directory_if_exists (const char *uri)
+get_parent_directory_if_exists (GFile *location)
{
- char *directory_uri;
NautilusDirectory *directory;
+ GFile *parent;
- /* Make text version of directory URI. */
- directory_uri = uri_get_directory_part (uri);
- directory = nautilus_directory_get_existing (directory_uri);
- g_free (directory_uri);
- return directory;
+ parent = g_file_get_parent (location);
+ if (parent) {
+ directory = nautilus_directory_get_internal (parent, FALSE);
+ g_object_unref (parent);
+ return directory;
+ }
+ return NULL;
}
static void
@@ -933,12 +913,19 @@ call_files_changed_unref_free_list (gpointer key, gpointer value, gpointer user_
static void
call_get_file_info_free_list (gpointer key, gpointer value, gpointer user_data)
{
+ NautilusDirectory *directory;
+ GList *files;
+
g_assert (NAUTILUS_IS_DIRECTORY (key));
g_assert (value != NULL);
g_assert (user_data == NULL);
- nautilus_directory_get_info_for_new_files (key, value);
- gnome_vfs_uri_list_free (value);
+ directory = key;
+ files = value;
+
+ nautilus_directory_get_info_for_new_files (directory, files);
+ g_list_foreach (files, (GFunc) g_object_unref, NULL);
+ g_list_free (files);
}
static void
@@ -965,16 +952,14 @@ collect_parent_directories (GHashTable *hash_table, NautilusDirectory *directory
}
void
-nautilus_directory_notify_files_added (GList *uris)
+nautilus_directory_notify_files_added (GList *files)
{
GHashTable *added_lists;
GList *p;
NautilusDirectory *directory;
GHashTable *parent_directories;
- const char *uri;
- char *directory_uri;
- GnomeVFSURI *vfs_uri;
NautilusFile *file;
+ GFile *location, *parent;
/* Make a list of added files in each directory. */
added_lists = g_hash_table_new (NULL, NULL);
@@ -982,20 +967,24 @@ nautilus_directory_notify_files_added (GList *uris)
/* Make a list of parent directories that will need their counts updated. */
parent_directories = g_hash_table_new (NULL, NULL);
- for (p = uris; p != NULL; p = p->next) {
- uri = (const char *) p->data;
+ for (p = files; p != NULL; p = p->next) {
+ location = p->data;
/* See if the directory is already known. */
- directory = get_parent_directory_if_exists (uri);
+ directory = get_parent_directory_if_exists (location);
if (directory == NULL) {
/* In case the directory is not being
* monitored, but the corresponding file is,
* we must invalidate it's item count.
*/
-
- directory_uri = uri_get_directory_part (uri);
- file = nautilus_file_get_existing (directory_uri);
- g_free (directory_uri);
+
+
+ file = NULL;
+ parent = g_file_get_parent (location);
+ if (parent) {
+ file = nautilus_file_get_existing (parent);
+ g_object_unref (parent);
+ }
if (file != NULL) {
nautilus_file_invalidate_count_and_mime_list (file);
@@ -1013,7 +1002,7 @@ nautilus_directory_notify_files_added (GList *uris)
continue;
}
- file = nautilus_file_get_existing (uri);
+ file = nautilus_file_get_existing (location);
if (file) {
/* A file already exists, it was probably renamed.
* If it was renamed this could be ignored, but
@@ -1021,17 +1010,9 @@ nautilus_directory_notify_files_added (GList *uris)
nautilus_file_changed (file);
nautilus_file_unref (file);
} else {
- /* Collect the URIs to use. */
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
- nautilus_directory_unref (directory);
- g_warning ("bad uri %s", uri);
- continue;
- }
-
hash_table_list_prepend (added_lists,
directory,
- vfs_uri);
+ g_object_ref (location));
}
nautilus_directory_unref (directory);
}
@@ -1047,23 +1028,79 @@ nautilus_directory_notify_files_added (GList *uris)
g_hash_table_destroy (parent_directories);
}
+static GList *
+uri_list_to_file_list (GList *uris)
+{
+ GList *l, *file_list;
+ const char *uri;
+ GFile *file;
+
+
+ file_list = NULL;
+
+ for (l = uris; l != NULL; l = l->next) {
+ uri = l->data;
+ file = g_file_new_for_uri (uri);
+ file_list = g_list_prepend (file_list, file);
+ }
+ return g_list_reverse (file_list);
+}
+
+static void
+g_file_pair_free (GFilePair *pair)
+{
+ g_object_unref (pair->to);
+ g_object_unref (pair->from);
+ g_free (pair);
+}
+
+static GList *
+uri_pairs_to_file_pairs (GList *uri_pairs)
+{
+ GList *l, *file_pair_list;
+ GFilePair *file_pair;
+ URIPair *uri_pair;
+
+ file_pair_list = NULL;
+
+ for (l = uri_pairs; l != NULL; l = l->next) {
+ uri_pair = l->data;
+ file_pair = g_new (GFilePair, 1);
+ file_pair->from = g_file_new_for_uri (uri_pair->from_uri);
+ file_pair->to = g_file_new_for_uri (uri_pair->to_uri);
+
+ file_pair_list = g_list_prepend (file_pair_list, file_pair);
+ }
+ return g_list_reverse (file_pair_list);
+}
+
+void
+nautilus_directory_notify_files_added_by_uri (GList *uris)
+{
+ GList *files;
+
+ files = uri_list_to_file_list (uris);
+ nautilus_directory_notify_files_added (files);
+ eel_g_object_list_free (files);
+}
+
void
-nautilus_directory_notify_files_changed (GList *uris)
+nautilus_directory_notify_files_changed (GList *files)
{
GHashTable *changed_lists;
GList *node;
- const char *uri;
+ GFile *location;
NautilusFile *file;
/* Make a list of changed files in each directory. */
changed_lists = g_hash_table_new (NULL, NULL);
/* Go through all the notifications. */
- for (node = uris; node != NULL; node = node->next) {
- uri = (const char *) node->data;
+ for (node = files; node != NULL; node = node->next) {
+ location = node->data;
/* Find the file. */
- file = nautilus_file_get_existing (uri);
+ file = nautilus_file_get_existing (location);
if (file != NULL) {
/* Tell it to re-get info now, and later emit
* a changed signal.
@@ -1085,14 +1122,24 @@ nautilus_directory_notify_files_changed (GList *uris)
}
void
-nautilus_directory_notify_files_removed (GList *uris)
+nautilus_directory_notify_files_changed_by_uri (GList *uris)
+{
+ GList *files;
+
+ files = uri_list_to_file_list (uris);
+ nautilus_directory_notify_files_changed (files);
+ eel_g_object_list_free (files);
+}
+
+void
+nautilus_directory_notify_files_removed (GList *files)
{
GHashTable *changed_lists;
GList *p;
NautilusDirectory *directory;
GHashTable *parent_directories;
- const char *uri;
NautilusFile *file;
+ GFile *location;
/* Make a list of changed files in each directory. */
changed_lists = g_hash_table_new (NULL, NULL);
@@ -1101,18 +1148,18 @@ nautilus_directory_notify_files_removed (GList *uris)
parent_directories = g_hash_table_new (NULL, NULL);
/* Go through all the notifications. */
- for (p = uris; p != NULL; p = p->next) {
- uri = (const char *) p->data;
+ for (p = files; p != NULL; p = p->next) {
+ location = p->data;
/* Update file count for parent directory if anyone might care. */
- directory = get_parent_directory_if_exists (uri);
+ directory = get_parent_directory_if_exists (location);
if (directory != NULL) {
collect_parent_directories (parent_directories, directory);
nautilus_directory_unref (directory);
}
/* Find the file. */
- file = nautilus_file_get_existing (uri);
+ file = nautilus_file_get_existing (location);
if (file != NULL && !nautilus_file_rename_in_progress (file)) {
/* Mark it gone and prepare to send the changed signal. */
nautilus_file_mark_gone (file);
@@ -1132,27 +1179,33 @@ nautilus_directory_notify_files_removed (GList *uris)
g_hash_table_destroy (parent_directories);
}
-static void
-set_directory_uri (NautilusDirectory *directory,
- const char *new_uri)
+void
+nautilus_directory_notify_files_removed_by_uri (GList *uris)
{
- GnomeVFSURI *new_vfs_uri;
+ GList *files;
- new_vfs_uri = gnome_vfs_uri_new (new_uri);
+ files = uri_list_to_file_list (uris);
+ nautilus_directory_notify_files_changed (files);
+ eel_g_object_list_free (files);
+}
- g_free (directory->details->uri);
- directory->details->uri = g_strdup (new_uri);
-
- if (directory->details->vfs_uri != NULL) {
- gnome_vfs_uri_unref (directory->details->vfs_uri);
+static void
+set_directory_location (NautilusDirectory *directory,
+ GFile *location)
+{
+ if (directory->details->location) {
+ g_object_unref (directory->details->location);
}
- directory->details->vfs_uri = new_vfs_uri;
+ directory->details->location = g_object_ref (location);
+
}
static void
-change_directory_uri (NautilusDirectory *directory,
- const char *new_uri)
+change_directory_location (NautilusDirectory *directory,
+ GFile *new_location)
{
+ char *new_uri;
+
/* I believe it's impossible for a self-owned file/directory
* to be moved. But if that did somehow happen, this function
* wouldn't do enough to handle it.
@@ -1160,112 +1213,99 @@ change_directory_uri (NautilusDirectory *directory,
g_return_if_fail (directory->details->as_file == NULL);
g_hash_table_remove (directories,
- directory->details->uri);
+ directory->details->location);
- set_directory_uri (directory, new_uri);
+ set_directory_location (directory, new_location);
g_hash_table_insert (directories,
- directory->details->uri,
+ directory->details->location,
directory);
+ new_uri = g_file_get_uri (new_location);
nautilus_directory_rename_directory_metadata (directory, new_uri);
+ g_free (new_uri);
}
typedef struct {
- char *uri_prefix;
+ GFile *container;
GList *directories;
} CollectData;
static void
-collect_directories_by_prefix (gpointer key, gpointer value, gpointer callback_data)
+collect_directories_by_container (gpointer key, gpointer value, gpointer callback_data)
{
- const char *uri, *uri_suffix;
NautilusDirectory *directory;
CollectData *collect_data;
+ GFile *location;
- uri = (const char *) key;
+ location = (GFile *) key;
directory = NAUTILUS_DIRECTORY (value);
collect_data = (CollectData *) callback_data;
-
- if (eel_str_has_prefix (uri, collect_data->uri_prefix)) {
- uri_suffix = &uri[strlen (collect_data->uri_prefix)];
- switch (uri_suffix[0]) {
- case '\0':
- case '/':
- nautilus_directory_ref (directory);
- collect_data->directories =
- g_list_prepend (collect_data->directories,
- directory);
- break;
- }
- }
-}
-
-static char *
-str_replace_prefix (const char *str,
- const char *old_prefix,
- const char *new_prefix)
-{
- const char *old_suffix;
-
- g_return_val_if_fail (eel_str_has_prefix (str, old_prefix),
- g_strdup (str));
- old_suffix = &str [strlen (old_prefix)];
- return g_strconcat (new_prefix, old_suffix, NULL);
+ if (g_file_contains_file (collect_data->container, location) ||
+ g_file_equal (collect_data->container, location)) {
+ nautilus_directory_ref (directory);
+ collect_data->directories =
+ g_list_prepend (collect_data->directories,
+ directory);
+ }
}
static GList *
-nautilus_directory_moved_internal (const char *old_uri,
- const char *new_uri)
+nautilus_directory_moved_internal (GFile *old_location,
+ GFile *new_location)
{
- char *canonical_old_uri, *canonical_new_uri;
CollectData collection;
NautilusDirectory *directory;
- char *new_directory_uri;
GList *node, *affected_files;
+ GFile *new_directory_location;
+ char *relative_path;
- canonical_old_uri = nautilus_directory_make_uri_canonical (old_uri);
- canonical_new_uri = nautilus_directory_make_uri_canonical (new_uri);
-
- collection.uri_prefix = canonical_old_uri;
+ collection.container = old_location;
collection.directories = NULL;
g_hash_table_foreach (directories,
- collect_directories_by_prefix,
+ collect_directories_by_container,
&collection);
affected_files = NULL;
for (node = collection.directories; node != NULL; node = node->next) {
directory = NAUTILUS_DIRECTORY (node->data);
+ new_directory_location = NULL;
- /* Change the URI in the directory object. */
- new_directory_uri = str_replace_prefix (directory->details->uri,
- canonical_old_uri,
- canonical_new_uri);
- change_directory_uri (directory,
- new_directory_uri);
- g_free (new_directory_uri);
-
- /* Collect affected files. */
- if (directory->details->as_file != NULL) {
- affected_files = g_list_prepend
+ if (g_file_equal (directory->details->location, old_location)) {
+ new_directory_location = g_object_ref (new_location);
+ } else {
+ relative_path = g_file_get_relative_path (old_location,
+ directory->details->location);
+ if (relative_path != NULL) {
+ new_directory_location = g_file_resolve_relative_path (new_location, relative_path);
+ g_free (relative_path);
+
+ }
+ }
+
+ if (new_directory_location) {
+ change_directory_location (directory, new_directory_location);
+ g_object_unref (new_directory_location);
+
+ /* Collect affected files. */
+ if (directory->details->as_file != NULL) {
+ affected_files = g_list_prepend
+ (affected_files,
+ nautilus_file_ref (directory->details->as_file));
+ }
+ affected_files = g_list_concat
(affected_files,
- nautilus_file_ref (directory->details->as_file));
+ nautilus_file_list_copy (directory->details->file_list));
}
- affected_files = g_list_concat
- (affected_files,
- nautilus_file_list_copy (directory->details->file_list));
nautilus_directory_unref (directory);
}
g_list_free (collection.directories);
- g_free (canonical_old_uri);
- g_free (canonical_new_uri);
-
return affected_files;
}
@@ -1276,10 +1316,15 @@ nautilus_directory_moved (const char *old_uri,
GList *list, *node;
GHashTable *hash;
NautilusFile *file;
+ GFile *old_location;
+ GFile *new_location;
hash = g_hash_table_new (NULL, NULL);
- list = nautilus_directory_moved_internal (old_uri, new_uri);
+ old_location = g_file_new_for_uri (old_uri);
+ new_location = g_file_new_for_uri (new_uri);
+
+ list = nautilus_directory_moved_internal (old_location, new_location);
for (node = list; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (hash,
@@ -1287,16 +1332,19 @@ nautilus_directory_moved (const char *old_uri,
nautilus_file_ref (file));
}
nautilus_file_list_free (list);
+
+ g_object_unref (old_location);
+ g_object_unref (new_location);
g_hash_table_foreach (hash, call_files_changed_unref_free_list, NULL);
g_hash_table_destroy (hash);
}
void
-nautilus_directory_notify_files_moved (GList *uri_pairs)
+nautilus_directory_notify_files_moved (GList *file_pairs)
{
GList *p, *affected_files, *node;
- URIPair *pair;
+ GFilePair *pair;
NautilusFile *file;
NautilusDirectory *old_directory, *new_directory;
GHashTable *parent_directories;
@@ -1304,6 +1352,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
GHashTable *added_lists, *changed_lists;
char *name;
NautilusFileAttributes cancel_attributes;
+ GFile *to_location, *from_location;
/* Make a list of added and changed files in each directory. */
new_files_list = NULL;
@@ -1316,11 +1365,13 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
cancel_attributes = nautilus_file_get_all_attributes ();
- for (p = uri_pairs; p != NULL; p = p->next) {
+ for (p = file_pairs; p != NULL; p = p->next) {
pair = p->data;
+ from_location = pair->from;
+ to_location = pair->to;
/* Handle overwriting a file. */
- file = nautilus_file_get_existing (pair->to_uri);
+ file = nautilus_file_get_existing (to_location);
if (file != NULL) {
/* Mark it gone and prepare to send the changed signal. */
nautilus_file_mark_gone (file);
@@ -1333,8 +1384,8 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
}
/* Update any directory objects that are affected. */
- affected_files = nautilus_directory_moved_internal (pair->from_uri,
- pair->to_uri);
+ affected_files = nautilus_directory_moved_internal (from_location,
+ to_location);
for (node = affected_files; node != NULL; node = node->next) {
file = NAUTILUS_FILE (node->data);
hash_table_list_prepend (changed_lists,
@@ -1344,11 +1395,11 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
unref_list = g_list_concat (unref_list, affected_files);
/* Move an existing file. */
- file = nautilus_file_get_existing (pair->from_uri);
+ file = nautilus_file_get_existing (from_location);
if (file == NULL) {
/* Handle this as if it was a new file. */
new_files_list = g_list_prepend (new_files_list,
- pair->to_uri);
+ to_location);
} else {
/* Handle notification in the old directory. */
old_directory = file->details->directory;
@@ -1359,7 +1410,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
(old_directory, file, cancel_attributes);
/* Locate the new directory. */
- new_directory = get_parent_directory (pair->to_uri);
+ new_directory = get_parent_directory (to_location);
collect_parent_directories (parent_directories, new_directory);
/* We can unref now -- new_directory is in the
* parent directories list so it will be
@@ -1369,7 +1420,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
nautilus_directory_unref (new_directory);
/* Update the file's name and directory. */
- name = eel_uri_get_basename (pair->to_uri);
+ name = g_file_get_basename (to_location);
nautilus_file_update_name_and_directory
(file, name, new_directory);
g_free (name);
@@ -1383,7 +1434,7 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
file);
}
- /* Unref each file once to balance out nautilus_file_get. */
+ /* Unref each file once to balance out nautilus_file_get_by_uri. */
unref_list = g_list_prepend (unref_list, file);
}
}
@@ -1406,32 +1457,43 @@ nautilus_directory_notify_files_moved (GList *uri_pairs)
g_list_free (new_files_list);
}
+void
+nautilus_directory_notify_files_moved_by_uri (GList *uri_pairs)
+{
+ GList *file_pairs;
+
+ file_pairs = uri_pairs_to_file_pairs (uri_pairs);
+ nautilus_directory_notify_files_moved (file_pairs);
+ g_list_foreach (file_pairs, (GFunc)g_file_pair_free, NULL);
+ g_list_free (file_pairs);
+}
+
void
-nautilus_directory_schedule_metadata_copy (GList *uri_pairs)
+nautilus_directory_schedule_metadata_copy (GList *file_pairs)
{
GList *p;
- URIPair *pair;
+ GFilePair *pair;
NautilusDirectory *source_directory, *destination_directory;
- char *source_relative_uri, *destination_relative_uri;
+ char *source_basename, *destination_basename;
- for (p = uri_pairs; p != NULL; p = p->next) {
- pair = (URIPair *) p->data;
+ for (p = file_pairs; p != NULL; p = p->next) {
+ pair = p->data;
- source_directory = get_parent_directory (pair->from_uri);
- destination_directory = get_parent_directory (pair->to_uri);
-
- source_relative_uri = g_path_get_basename (pair->from_uri);
- destination_relative_uri = g_path_get_basename (pair->to_uri);
+ source_directory = get_parent_directory (pair->from);
+ destination_directory = get_parent_directory (pair->to);
+ source_basename = g_file_get_basename (pair->from);
+ destination_basename = g_file_get_basename (pair->to);
+
if (source_directory != NULL && destination_directory != NULL) {
nautilus_directory_copy_file_metadata (source_directory,
- source_relative_uri,
+ source_basename,
destination_directory,
- destination_relative_uri);
+ destination_basename);
}
- g_free (source_relative_uri);
- g_free (destination_relative_uri);
+ g_free (source_basename);
+ g_free (destination_basename);
nautilus_directory_unref (source_directory);
nautilus_directory_unref (destination_directory);
@@ -1439,60 +1501,92 @@ nautilus_directory_schedule_metadata_copy (GList *uri_pairs)
}
void
-nautilus_directory_schedule_metadata_move (GList *uri_pairs)
+nautilus_directory_schedule_metadata_copy_by_uri (GList *uri_pairs)
+{
+ GList *file_pairs;
+
+ file_pairs = uri_pairs_to_file_pairs (uri_pairs);
+ nautilus_directory_schedule_metadata_copy (file_pairs);
+ g_list_foreach (file_pairs, (GFunc)g_file_pair_free, NULL);
+ g_list_free (file_pairs);
+}
+
+
+void
+nautilus_directory_schedule_metadata_move (GList *file_pairs)
{
GList *p;
- URIPair *pair;
+ GFilePair *pair;
NautilusDirectory *source_directory, *destination_directory;
- char *source_relative_uri, *destination_relative_uri;
+ char *source_basename, *destination_basename;
- for (p = uri_pairs; p != NULL; p = p->next) {
- pair = (URIPair *) p->data;
+ for (p = file_pairs; p != NULL; p = p->next) {
+ pair = p->data;
- source_directory = get_parent_directory (pair->from_uri);
- destination_directory = get_parent_directory (pair->to_uri);
+ source_directory = get_parent_directory (pair->from);
+ destination_directory = get_parent_directory (pair->to);
- source_relative_uri = g_path_get_basename (pair->from_uri);
- destination_relative_uri = g_path_get_basename (pair->to_uri);
+ source_basename = g_file_get_basename (pair->from);
+ destination_basename = g_file_get_basename (pair->to);
nautilus_directory_copy_file_metadata (source_directory,
- source_relative_uri,
+ source_basename,
destination_directory,
- destination_relative_uri);
+ destination_basename);
nautilus_directory_remove_file_metadata (source_directory,
- source_relative_uri);
+ source_basename);
+
+ g_free (source_basename);
+ g_free (destination_basename);
- g_free (source_relative_uri);
- g_free (destination_relative_uri);
-
nautilus_directory_unref (source_directory);
nautilus_directory_unref (destination_directory);
}
}
void
-nautilus_directory_schedule_metadata_remove (GList *uris)
+nautilus_directory_schedule_metadata_move_by_uri (GList *uri_pairs)
+{
+ GList *file_pairs;
+
+ file_pairs = uri_pairs_to_file_pairs (uri_pairs);
+ nautilus_directory_schedule_metadata_move (file_pairs);
+ g_list_foreach (file_pairs, (GFunc)g_file_pair_free, NULL);
+ g_list_free (file_pairs);
+}
+
+void
+nautilus_directory_schedule_metadata_remove (GList *files)
{
GList *p;
- const char *uri;
NautilusDirectory *directory;
- char *relative_uri;
+ char *basename;
+ GFile *location;
- for (p = uris; p != NULL; p = p->next) {
- uri = (const char *) p->data;
+ for (p = files; p != NULL; p = p->next) {
+ location = p->data;
- directory = get_parent_directory (uri);
- relative_uri = g_path_get_basename (uri);
-
- nautilus_directory_remove_file_metadata (directory,
- relative_uri);
+ directory = get_parent_directory (location);
+
+ basename = g_file_get_basename (location);
+ nautilus_directory_remove_file_metadata (directory, basename);
+ g_free (basename);
- g_free (relative_uri);
nautilus_directory_unref (directory);
}
}
+void
+nautilus_directory_schedule_metadata_remove_by_uri (GList *uris)
+{
+ GList *files;
+
+ files = uri_list_to_file_list (uris);
+ nautilus_directory_schedule_metadata_remove (files);
+ eel_g_object_list_free (files);
+}
+
void
nautilus_directory_schedule_position_set (GList *position_setting_list)
{
@@ -1505,7 +1599,7 @@ nautilus_directory_schedule_position_set (GList *position_setting_list)
for (p = position_setting_list; p != NULL; p = p->next) {
item = (NautilusFileChangesQueuePosition *) p->data;
- file = nautilus_file_get (item->uri);
+ file = nautilus_file_get (item->location);
if (item->set) {
position_string = g_strdup_printf ("%d,%d",
@@ -1556,7 +1650,7 @@ char *
nautilus_directory_get_file_uri (NautilusDirectory *directory,
const char *file_name)
{
- GnomeVFSURI *directory_uri, *file_uri;
+ GFile *child;
char *result;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
@@ -1564,18 +1658,10 @@ nautilus_directory_get_file_uri (NautilusDirectory *directory,
result = NULL;
- directory_uri = gnome_vfs_uri_new (directory->details->uri);
-
- g_assert (directory_uri != NULL);
-
- file_uri = gnome_vfs_uri_append_string (directory_uri, file_name);
- gnome_vfs_uri_unref (directory_uri);
-
- if (file_uri != NULL) {
- result = gnome_vfs_uri_to_string (file_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (file_uri);
- }
-
+ child = g_file_get_child (directory->details->location, file_name);
+ result = g_file_get_uri (child);
+ g_object_unref (child);
+
return result;
}
@@ -1673,7 +1759,7 @@ is_tentative (gpointer data, gpointer callback_data)
* will later be sent with the files_added signal, and a
* user doing get_file_list + files_added monitoring will
* then see the file twice */
- return file->details->info == NULL || !file->details->is_added;
+ return !file->details->got_file_info || !file->details->is_added;
}
GList *
@@ -1796,7 +1882,18 @@ nautilus_directory_list_copy (GList *list)
static int
compare_by_uri (NautilusDirectory *a, NautilusDirectory *b)
{
- return strcmp (a->details->uri, b->details->uri);
+ char *uri_a, *uri_b;
+ int res;
+
+ uri_a = g_file_get_uri (a->details->location);
+ uri_b = g_file_get_uri (b->details->location);
+
+ res = strcmp (uri_a, uri_b);
+
+ g_free (uri_a);
+ g_free (uri_b);
+
+ return res;
}
static int
@@ -1820,16 +1917,11 @@ nautilus_directory_list_sort_by_uri (GList *list)
gboolean
nautilus_directory_is_desktop_directory (NautilusDirectory *directory)
{
- GnomeVFSURI *dir_vfs_uri;
-
- dir_vfs_uri = directory->details->vfs_uri;
-
- if (dir_vfs_uri == NULL ||
- strcmp (dir_vfs_uri->method_string, "file") != 0) {
+ if (directory->details->location == NULL) {
return FALSE;
}
- return nautilus_is_desktop_directory_escaped (dir_vfs_uri->text);
+ return nautilus_is_desktop_directory (directory->details->location);
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
@@ -1873,8 +1965,8 @@ nautilus_self_check_directory (void)
NautilusDirectory *directory;
NautilusFile *file;
- directory = nautilus_directory_get ("file:///etc");
- file = nautilus_file_get ("file:///etc/passwd");
+ directory = nautilus_directory_get_by_uri ("file:///etc");
+ file = nautilus_file_get_by_uri ("file:///etc/passwd");
EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1);
@@ -1909,13 +2001,13 @@ nautilus_self_check_directory (void)
EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (NULL, "test_integer", 42), 42);
EEL_CHECK_INTEGER_RESULT (nautilus_file_get_integer_metadata (file, "nonexistent_key", 42), 42);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc") == directory, TRUE);
+ EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc") == directory, TRUE);
nautilus_directory_unref (directory);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc/") == directory, TRUE);
+ EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc/") == directory, TRUE);
nautilus_directory_unref (directory);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get ("file:///etc////") == directory, TRUE);
+ EEL_CHECK_BOOLEAN_RESULT (nautilus_directory_get_by_uri ("file:///etc////") == directory, TRUE);
nautilus_directory_unref (directory);
nautilus_file_unref (file);
@@ -1930,7 +2022,7 @@ nautilus_self_check_directory (void)
EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0);
- directory = nautilus_directory_get ("file:///etc");
+ directory = nautilus_directory_get_by_uri ("file:///etc");
got_metadata_flag = FALSE;
nautilus_directory_call_when_ready (directory, NAUTILUS_FILE_ATTRIBUTE_METADATA, TRUE,
@@ -1945,7 +2037,7 @@ nautilus_self_check_directory (void)
got_files_flag = FALSE;
nautilus_directory_call_when_ready (directory,
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS,
TRUE,
got_files_callback, &data_dummy);
@@ -1958,7 +2050,7 @@ nautilus_self_check_directory (void)
EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 1);
- file = nautilus_file_get ("file:///etc/passwd");
+ file = nautilus_file_get_by_uri ("file:///etc/passwd");
EEL_CHECK_STRING_RESULT (nautilus_file_get_metadata (file, "test", "default"), "value");
@@ -1967,37 +2059,6 @@ nautilus_self_check_directory (void)
nautilus_directory_unref (directory);
EEL_CHECK_INTEGER_RESULT (g_hash_table_size (directories), 0);
-
- /* escape_slashes: code is now in gnome-vfs, but lets keep the tests here for now */
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes (""), "");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("a"), "a");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("/"), "%2F");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("%"), "%25");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("a/a"), "a%2Fa");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("a%a"), "a%25a");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("%25"), "%2525");
- EEL_CHECK_STRING_RESULT (gnome_vfs_escape_slashes ("%2F"), "%252F");
-
- /* nautilus_directory_make_uri_canonical */
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical (""), "file:///");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("file:/"), "file:///");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("file:///"), "file:///");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("TRASH:XXX"), EEL_TRASH_URI);
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("trash:xxx"), EEL_TRASH_URI);
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("GNOME-TRASH:XXX"), EEL_TRASH_URI);
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("gnome-trash:xxx"), EEL_TRASH_URI);
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("file:///home/mathieu/"), "file:///home/mathieu");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("file:///home/mathieu"), "file:///home/mathieu");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("ftp://mathieu:password@le-hackeur.org"), "ftp://mathieu:password@le-hackeur.org");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("ftp://mathieu:password@le-hackeur.org/"), "ftp://mathieu:password@le-hackeur.org");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("http://le-hackeur.org"), "http://le-hackeur.org");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("http://le-hackeur.org/"), "http://le-hackeur.org");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("http://le-hackeur.org/dir"), "http://le-hackeur.org/dir");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("http://le-hackeur.org/dir/"), "http://le-hackeur.org/dir");
- /* FIXME bugzilla.gnome.org 45068: the "nested" URI loses some characters here. Maybe that's OK because we escape them in practice? */
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("search://[file://]file_name contains stuff"), "search://[file/]file_name contains stuff");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("eazel-services:/~turtle"), "eazel-services:///~turtle");
- EEL_CHECK_STRING_RESULT (nautilus_directory_make_uri_canonical ("eazel-services:///~turtle"), "eazel-services:///~turtle");
}
#endif /* !NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-directory.h b/libnautilus-private/nautilus-directory.h
index a8fa91698..40397b863 100644
--- a/libnautilus-private/nautilus-directory.h
+++ b/libnautilus-private/nautilus-directory.h
@@ -26,13 +26,13 @@
#define NAUTILUS_DIRECTORY_H
#include <gtk/gtkobject.h>
-#include <libgnomevfs/gnome-vfs-types.h>
+#include <gio/gfile.h>
#include <libnautilus-private/nautilus-file-attributes.h>
/* NautilusDirectory is a class that manages the model for a directory,
real or virtual, for Nautilus, mainly the file-manager component. The directory is
responsible for managing both real data and cached metadata. On top of
- the file system independence provided by gnome-vfs, the directory
+ the file system independence provided by gio, the directory
object also provides:
1) A synchronization framework, which notifies via signals as the
@@ -101,8 +101,7 @@ typedef struct
void (* done_loading) (NautilusDirectory *directory);
void (* load_error) (NautilusDirectory *directory,
- GnomeVFSResult error_result,
- const char *error_message);
+ GError *error);
/*** Virtual functions for subclasses to override. ***/
gboolean (* contains_file) (NautilusDirectory *directory,
@@ -152,7 +151,8 @@ GType nautilus_directory_get_type (void);
* Returns a referenced object, not a floating one. Unref when finished.
* If two windows are viewing the same uri, the directory object is shared.
*/
-NautilusDirectory *nautilus_directory_get (const char *uri);
+NautilusDirectory *nautilus_directory_get (GFile *location);
+NautilusDirectory *nautilus_directory_get_by_uri (const char *uri);
NautilusDirectory *nautilus_directory_get_for_file (NautilusFile *file);
/* Covers for gtk_object_ref and gtk_object_unref that provide two conveniences:
@@ -164,6 +164,7 @@ void nautilus_directory_unref (NautilusDirector
/* Access to a URI. */
char * nautilus_directory_get_uri (NautilusDirectory *directory);
+GFile * nautilus_directory_get_location (NautilusDirectory *directory);
/* Is this file still alive and in this directory? */
gboolean nautilus_directory_contains_file (NautilusDirectory *directory,
@@ -223,7 +224,6 @@ gboolean nautilus_directory_is_in_trash (NautilusDirector
*/
gboolean nautilus_directory_is_not_empty (NautilusDirectory *directory);
gboolean nautilus_directory_file_list_length_reached (NautilusDirectory *directory);
-char * nautilus_directory_make_uri_canonical (const char *uri);
/* Convenience functions for dealing with a list of NautilusDirectory objects that each have a ref.
* These are just convenient names for functions that work on lists of GtkObject *.
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index 7c15df1ca..c2acda0dc 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -40,11 +40,6 @@
#include <gtk/gtkseparatormenuitem.h>
#include <glib/gi18n.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-find-directory.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <stdio.h>
#include <string.h>
@@ -216,8 +211,7 @@ nautilus_drag_items_local (const char *target_uri_string, const GList *selection
* we should really test each item but that would be slow for large selections
* and currently dropped items can only be from the same container
*/
- GnomeVFSURI *target_uri;
- GnomeVFSURI *item_uri;
+ GFile *target, *item, *parent;
gboolean result;
/* must have at least one item */
@@ -225,21 +219,17 @@ nautilus_drag_items_local (const char *target_uri_string, const GList *selection
result = FALSE;
- target_uri = gnome_vfs_uri_new (target_uri_string);
+ target = g_file_new_for_uri (target_uri_string);
- if (target_uri != NULL) {
- /* get the parent URI of the first item in the selection */
- item_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)selection_list->data)->uri);
-
- if (item_uri != NULL) {
- result = gnome_vfs_uri_is_parent (target_uri, item_uri, FALSE);
-
- gnome_vfs_uri_unref (item_uri);
- }
-
- gnome_vfs_uri_unref (target_uri);
+ /* get the parent URI of the first item in the selection */
+ item = g_file_new_for_uri (((NautilusDragSelectionItem *)selection_list->data)->uri);
+ parent = g_file_get_parent (item);
+ g_object_unref (item);
+
+ if (parent != NULL) {
+ result = g_file_equal (parent, target);
+ g_object_unref (parent);
}
-
return result;
}
@@ -252,15 +242,14 @@ nautilus_drag_items_in_trash (const GList *selection_list)
* we should really test each item but that would be slow for large selections
* and currently dropped items can only be from the same container
*/
- return eel_uri_is_in_trash (((NautilusDragSelectionItem *)selection_list->data)->uri);
+ return eel_uri_is_trash (((NautilusDragSelectionItem *)selection_list->data)->uri);
}
gboolean
nautilus_drag_items_on_desktop (const GList *selection_list)
{
char *uri;
- GnomeVFSURI *vfs_uri, *desktop_vfs_uri;
- char *desktop_uri;
+ GFile *desktop, *item, *parent;
gboolean result;
/* check if the first item on the list is in trash.
@@ -272,16 +261,20 @@ nautilus_drag_items_on_desktop (const GList *selection_list)
if (eel_uri_is_desktop (uri)) {
return TRUE;
}
-
- vfs_uri = gnome_vfs_uri_new (uri);
- desktop_uri = nautilus_get_desktop_directory_uri ();
- desktop_vfs_uri = gnome_vfs_uri_new (desktop_uri);
- g_free (desktop_uri);
- result = gnome_vfs_uri_is_parent (desktop_vfs_uri, vfs_uri, FALSE);
+ desktop = nautilus_get_desktop_location ();
- gnome_vfs_uri_unref (desktop_vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
+ item = g_file_new_for_uri (uri);
+ parent = g_file_get_parent (item);
+ g_object_unref (item);
+
+ result = FALSE;
+
+ if (parent) {
+ result = g_file_equal (desktop, parent);
+ g_object_unref (parent);
+ }
+ g_object_unref (desktop);
return result;
@@ -303,18 +296,59 @@ nautilus_drag_default_drop_action_for_netscape_url (GdkDragContext *context)
return context->suggested_action;
}
+static gboolean
+check_same_fs (GFile *file1, GFile *file2)
+{
+ GFileInfo *info1, *info2;
+ const char *id1, *id2;
+ gboolean res;
+
+ info1 = g_file_query_info (file1,
+ G_FILE_ATTRIBUTE_ID_FS,
+ 0, NULL, NULL);
+
+ if (info1 == NULL) {
+ return FALSE;
+ }
+
+ id1 = g_file_info_get_attribute_string (info1, G_FILE_ATTRIBUTE_ID_FS);
+ if (id1 == NULL) {
+ g_object_unref (info1);
+ return FALSE;
+ }
+
+ info2 = g_file_query_info (file2,
+ G_FILE_ATTRIBUTE_ID_FS,
+ 0, NULL, NULL);
+ if (info2 == NULL) {
+ g_object_unref (info1);
+ return FALSE;
+ }
+
+ id2 = g_file_info_get_attribute_string (info2, G_FILE_ATTRIBUTE_ID_FS);
+ if (id2 == NULL) {
+ g_object_unref (info1);
+ g_object_unref (info2);
+ return FALSE;
+ }
+
+ res = strcmp (id1, id2) == 0;
+
+ g_object_unref (info1);
+ g_object_unref (info2);
+
+ return res;
+}
void
nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
- const char *target_uri_string, const GList *items,
- int *action)
+ const char *target_uri_string, const GList *items,
+ int *action)
{
gboolean same_fs;
gboolean target_is_source_parent;
- GnomeVFSURI *target_uri;
- GnomeVFSURI *dropped_uri;
+ GFile *target, *dropped;
GdkDragAction actions;
- GnomeVFSResult result;
if (target_uri_string == NULL) {
*action = 0;
@@ -340,22 +374,11 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
* passed with 700 while creating .Trash directory
*/
if (eel_uri_is_trash (target_uri_string)) {
- result = gnome_vfs_find_directory (NULL, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &target_uri, TRUE, FALSE, 0);
- if (result != GNOME_VFS_OK) {
- *action = 0;
- return;
- }
-
/* Only move to Trash */
if (actions & GDK_ACTION_MOVE) {
*action = GDK_ACTION_MOVE;
}
- if (target_uri) {
- gnome_vfs_uri_unref (target_uri);
- }
-
return;
} else if (g_str_has_prefix (target_uri_string, NAUTILUS_COMMAND_SPECIFIER)
@@ -365,30 +388,16 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
}
return;
} else if (eel_uri_is_desktop (target_uri_string)) {
- char *desktop_uri;
- desktop_uri = nautilus_get_desktop_directory_uri ();
- target_uri = gnome_vfs_uri_new (desktop_uri);
- g_free (desktop_uri);
+ target = nautilus_get_desktop_location ();
} else {
- target_uri = gnome_vfs_uri_new (target_uri_string);
- }
-
- if (target_uri == NULL) {
- *action = 0;
- return;
+ target = g_file_new_for_uri (target_uri_string);
}
/* Compare the first dropped uri with the target uri for same fs match. */
- dropped_uri = gnome_vfs_uri_new (((NautilusDragSelectionItem *)items->data)->uri);
- same_fs = TRUE;
+ dropped = g_file_new_for_uri (((NautilusDragSelectionItem *)items->data)->uri);
+ same_fs = check_same_fs (target, dropped);
target_is_source_parent = FALSE;
-
- if (dropped_uri != NULL) {
- gnome_vfs_check_same_fs_uris (dropped_uri, target_uri, &same_fs);
- target_is_source_parent = gnome_vfs_uri_is_parent (target_uri, dropped_uri, FALSE);
- gnome_vfs_uri_unref (dropped_uri);
- }
- gnome_vfs_uri_unref (target_uri);
+ target_is_source_parent = g_file_contains_file (target, dropped);
if (same_fs || target_is_source_parent) {
if (actions & GDK_ACTION_MOVE) {
@@ -403,6 +412,10 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
*action = context->suggested_action;
}
}
+
+ g_object_unref (target);
+ g_object_unref (dropped);
+
}
/* Encode a "x-special/gnome-icon-list" selection.
@@ -480,7 +493,7 @@ add_one_compatible_uri (const char *uri, int x, int y, int w, int h, gpointer da
g_string_append (result, uri);
g_string_append (result, "\r\n");
} else {
- local_path = gnome_vfs_get_local_path_from_uri (uri);
+ local_path = g_filename_from_uri (uri, NULL, NULL);
/* Check for characters that confuse the old
* gnome_uri_list_extract_filenames implementation, and just leave
diff --git a/libnautilus-private/nautilus-emblem-utils.c b/libnautilus-private/nautilus-emblem-utils.c
index 0a1cbf88f..66a884372 100644
--- a/libnautilus-private/nautilus-emblem-utils.c
+++ b/libnautilus-private/nautilus-emblem-utils.c
@@ -27,17 +27,15 @@
#include <sys/types.h>
#include <utime.h>
#include <stdio.h>
+#include <string.h>
#include <time.h>
#include <unistd.h>
-#include "nautilus-icon-factory.h"
-#include <eel/eel-string.h>
+#include "nautilus-file.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-vfs-extensions.h>
#include <glib/gi18n.h>
-#include <libgnomeui/gnome-icon-theme.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gtk/gtkicontheme.h>
#include "nautilus-emblem-utils.h"
#define EMBLEM_NAME_TRASH "emblem-trash"
@@ -48,14 +46,13 @@
#define EMBLEM_NAME_DESKTOP "emblem-desktop"
GList *
-nautilus_emblem_list_availible (void)
+nautilus_emblem_list_available (void)
{
GtkIconTheme *icon_theme;
GList *list;
- icon_theme = nautilus_icon_factory_get_icon_theme ();
+ icon_theme = gtk_icon_theme_get_default ();
list = gtk_icon_theme_list_icons (icon_theme, "Emblems");
- g_object_unref (icon_theme);
return list;
}
@@ -64,9 +61,8 @@ nautilus_emblem_refresh_list (void)
{
GtkIconTheme *icon_theme;
- icon_theme = nautilus_icon_factory_get_icon_theme ();
+ icon_theme = gtk_icon_theme_get_default ();
gtk_icon_theme_rescan_if_needed (icon_theme);
- g_object_unref (icon_theme);
}
char *
@@ -80,37 +76,39 @@ nautilus_emblem_get_icon_name_from_keyword (const char *keyword)
static gboolean
is_reserved_keyword (const char *keyword)
{
- GList *availible;
+ GList *available;
char *icon_name;
gboolean result;
+ g_assert (keyword != NULL);
+
/* check intrinsic emblems */
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_TRASH) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_TRASH) == 0) {
return TRUE;
}
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_CANT_READ) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_CANT_READ) == 0) {
return TRUE;
}
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE) == 0) {
return TRUE;
}
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_SYMBOLIC_LINK) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_SYMBOLIC_LINK) == 0) {
return TRUE;
}
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_NOTE) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_NOTE) == 0) {
return TRUE;
}
- if (eel_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_DESKTOP) == 0) {
+ if (g_strcasecmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_DESKTOP) == 0) {
return TRUE;
}
- availible = nautilus_emblem_list_availible ();
+ available = nautilus_emblem_list_available ();
icon_name = nautilus_emblem_get_icon_name_from_keyword (keyword);
/* see if the keyword already exists */
- result = g_list_find_custom (availible,
+ result = g_list_find_custom (available,
(char *) icon_name,
- (GCompareFunc) eel_strcasecmp) != NULL;
- eel_g_list_free_deep (availible);
+ (GCompareFunc) g_strcasecmp) != NULL;
+ eel_g_list_free_deep (available);
g_free (icon_name);
return result;
}
@@ -145,7 +143,7 @@ nautilus_emblem_get_keyword_from_icon_name (const char *emblem)
{
g_return_val_if_fail (emblem != NULL, NULL);
- if (eel_str_has_prefix (emblem, "emblem-")) {
+ if (g_str_has_prefix (emblem, "emblem-")) {
return g_strdup (&emblem[7]);
} else {
return g_strdup (emblem);
@@ -153,19 +151,26 @@ nautilus_emblem_get_keyword_from_icon_name (const char *emblem)
}
GdkPixbuf *
-nautilus_emblem_load_pixbuf_for_emblem (const char *uri)
+nautilus_emblem_load_pixbuf_for_emblem (GFile *emblem)
{
+ GInputStream *stream;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
- pixbuf = eel_gdk_pixbuf_load (uri);
+ stream = (GInputStream *) g_file_read (emblem, NULL, NULL);
+ if (!stream) {
+ return NULL;
+ }
+ pixbuf = eel_gdk_pixbuf_load_from_stream (stream);
g_return_val_if_fail (pixbuf != NULL, NULL);
scaled = eel_gdk_pixbuf_scale_down_to_fit (pixbuf,
NAUTILUS_ICON_SIZE_STANDARD,
NAUTILUS_ICON_SIZE_STANDARD);
- g_object_unref (G_OBJECT (pixbuf));
+
+ g_object_unref (pixbuf);
+ g_object_unref (stream);
return scaled;
}
@@ -227,9 +232,7 @@ nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf,
const char *display_name,
GtkWindow *parent_window)
{
- GnomeVFSURI *vfs_uri;
- char *path, *dir, *stat_dir;
- FILE *file;
+ char *basename, *path, *dir, *stat_dir;
struct stat stat_buf;
struct utimbuf ubuf;
@@ -239,19 +242,25 @@ nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf,
return;
}
- dir = g_strdup_printf ("%s/.icons/hicolor/48x48/emblems",
- g_get_home_dir ());
- stat_dir = g_strdup_printf ("%s/.icons/hicolor",
- g_get_home_dir ());
+ dir = g_build_filename (g_get_home_dir (),
+ ".icons", "hicolor", "48x48", "emblems",
+ NULL);
+ stat_dir = g_build_filename (g_get_home_dir (),
+ ".icons", "hicolor",
+ NULL);
- vfs_uri = gnome_vfs_uri_new (dir);
+ if (g_mkdir_with_parents (dir, 0755) != 0) {
+ eel_show_error_dialog (_("The emblem cannot be installed."),
+ _("Sorry, unable to save custom emblem."),
+ GTK_WINDOW (parent_window));
+ g_free (dir);
+ g_free (stat_dir);
+ return;
+ }
- g_return_if_fail (vfs_uri != NULL);
-
- eel_make_directory_and_parents (vfs_uri, 0755);
- gnome_vfs_uri_unref (vfs_uri);
-
- path = g_strdup_printf ("%s/emblem-%s.png", dir, keyword);
+ basename = g_strdup_printf ("emblem-%s.png", keyword);
+ path = g_build_filename (dir, basename, NULL);
+ g_free (basename);
/* save the image */
if (eel_gdk_pixbuf_save_to_file (pixbuf, path) != TRUE) {
@@ -267,23 +276,28 @@ nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf,
g_free (path);
if (display_name != NULL) {
- path = g_strdup_printf ("%s/emblem-%s.icon", dir, keyword);
- file = fopen (path, "w+");
- g_free (path);
+ char *contents;
+
+ basename = g_strdup_printf ("emblem-%s.icon", keyword);
+ path = g_build_filename (dir, basename, NULL);
+ g_free (basename);
- if (file == NULL) {
+ contents = g_strdup_printf ("\n[Icon Data]\n\nDisplayName=%s\n",
+ display_name);
+
+ if (!g_file_set_contents (path, contents, strlen (contents), NULL)) {
eel_show_error_dialog (_("The emblem cannot be installed."),
_("Sorry, unable to save custom emblem name."),
GTK_WINDOW (parent_window));
+ g_free (contents);
+ g_free (path);
g_free (stat_dir);
g_free (dir);
return;
}
-
- /* write the icon description */
- fprintf (file, "\n[Icon Data]\n\nDisplayName=%s\n", display_name);
- fflush (file);
- fclose (file);
+
+ g_free (contents);
+ g_free (path);
}
/* Touch the toplevel dir */
@@ -292,7 +306,7 @@ nautilus_emblem_install_custom_emblem (GdkPixbuf *pixbuf,
ubuf.modtime = time (NULL);
utime (stat_dir, &ubuf);
}
-
+
g_free (dir);
g_free (stat_dir);
@@ -416,8 +430,7 @@ nautilus_emblem_rename_emblem (const char *keyword, const char *name)
fclose (file);
icon_name = nautilus_emblem_get_icon_name_from_keyword (keyword);
- nautilus_icon_factory_remove_from_cache (icon_name, NULL,
- NAUTILUS_ICON_SIZE_STANDARD);
+ nautilus_icon_info_clear_caches (); /* A bit overkill, but this happens rarely */
g_free (icon_name);
diff --git a/libnautilus-private/nautilus-emblem-utils.h b/libnautilus-private/nautilus-emblem-utils.h
index 6da93237a..ffdc74d27 100644
--- a/libnautilus-private/nautilus-emblem-utils.h
+++ b/libnautilus-private/nautilus-emblem-utils.h
@@ -23,10 +23,11 @@
*/
#include <glib.h>
+#include <gio/gfile.h>
#include <gtk/gtkwindow.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-GList * nautilus_emblem_list_availible (void);
+GList * nautilus_emblem_list_available (void);
void nautilus_emblem_refresh_list (void);
gboolean nautilus_emblem_should_show_in_list (const char *emblem);
gboolean nautilus_emblem_verify_keyword (GtkWindow *parent_window,
@@ -41,7 +42,7 @@ gboolean nautilus_emblem_remove_emblem (const char *keyword);
gboolean nautilus_emblem_rename_emblem (const char *keyword,
const char *display_name);
-GdkPixbuf *nautilus_emblem_load_pixbuf_for_emblem (const char *uri);
+GdkPixbuf *nautilus_emblem_load_pixbuf_for_emblem (GFile *emblem);
char * nautilus_emblem_get_keyword_from_icon_name (const char *emblem);
char * nautilus_emblem_get_icon_name_from_keyword (const char *keyword);
diff --git a/libnautilus-private/nautilus-file-attributes.h b/libnautilus-private/nautilus-file-attributes.h
index cdee9d1f7..d263cbec6 100644
--- a/libnautilus-private/nautilus-file-attributes.h
+++ b/libnautilus-private/nautilus-file-attributes.h
@@ -30,22 +30,16 @@
*/
typedef enum {
- NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI = 1 << 0,
- NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES = 1 << 1,
- NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON = 1 << 2,
- NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS = 1 << 3,
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT = 1 << 4,
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES = 1 << 5,
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE = 1 << 6,
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY = 1 << 7,
- NAUTILUS_FILE_ATTRIBUTE_METADATA = 1 << 8,
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE = 1 << 9,
- NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT = 1 << 10,
- NAUTILUS_FILE_ATTRIBUTE_LARGE_TOP_LEFT_TEXT = 1 << 11,
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME = 1 << 12,
- NAUTILUS_FILE_ATTRIBUTE_VOLUMES = 1 << 13,
- NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO = 1 << 14,
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE = 1 << 15
+ NAUTILUS_FILE_ATTRIBUTE_INFO = 1 << 0, /* All standard info */
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO = 1 << 1, /* info from desktop links */
+ NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS = 1 << 2,
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT = 1 << 3,
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES = 1 << 4,
+ NAUTILUS_FILE_ATTRIBUTE_METADATA = 1 << 5,
+ NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT = 1 << 6,
+ NAUTILUS_FILE_ATTRIBUTE_LARGE_TOP_LEFT_TEXT = 1 << 7,
+ NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO = 1 << 8,
+ NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL = 1 << 9,
} NautilusFileAttributes;
#endif /* NAUTILUS_FILE_ATTRIBUTES_H */
diff --git a/libnautilus-private/nautilus-file-changes-queue.c b/libnautilus-private/nautilus-file-changes-queue.c
index 09b23563c..13afaed96 100644
--- a/libnautilus-private/nautilus-file-changes-queue.c
+++ b/libnautilus-private/nautilus-file-changes-queue.c
@@ -49,8 +49,8 @@ typedef enum {
typedef struct {
NautilusFileChangeKind kind;
- char *from_uri;
- char *to_uri;
+ GFile *from;
+ GFile *to;
GdkPoint point;
int screen;
} NautilusFileChange;
@@ -93,8 +93,12 @@ nautilus_file_changes_queue_get (void)
static void
nautilus_file_change_free (NautilusFileChange *change)
{
- g_free (change->from_uri);
- g_free (change->to_uri);
+ if (change->from) {
+ g_object_unref (change->from);
+ }
+ if (change->to) {
+ g_object_unref (change->to);
+ }
}
void
@@ -139,7 +143,7 @@ nautilus_file_changes_queue_add_common (NautilusFileChangesQueue *queue,
}
void
-nautilus_file_changes_queue_file_added (const char *uri)
+nautilus_file_changes_queue_file_added (GFile *location)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -148,12 +152,12 @@ nautilus_file_changes_queue_file_added (const char *uri)
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_ADDED;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_file_changed (const char *uri)
+nautilus_file_changes_queue_file_changed (GFile *location)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -162,12 +166,12 @@ nautilus_file_changes_queue_file_changed (const char *uri)
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_CHANGED;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_file_removed (const char *uri)
+nautilus_file_changes_queue_file_removed (GFile *location)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -176,12 +180,13 @@ nautilus_file_changes_queue_file_removed (const char *uri)
new_item = g_new0 (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_REMOVED;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_file_moved (const char *from, const char *to)
+nautilus_file_changes_queue_file_moved (GFile *from,
+ GFile *to)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -190,14 +195,14 @@ nautilus_file_changes_queue_file_moved (const char *from, const char *to)
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_FILE_MOVED;
- new_item->from_uri = g_strdup (from);
- new_item->to_uri = g_strdup (to);
+ new_item->from = g_object_ref (from);
+ new_item->to = g_object_ref (to);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_schedule_metadata_copy (const char *from_uri,
- const char *to_uri)
+nautilus_file_changes_queue_schedule_metadata_copy (GFile *from,
+ GFile *to)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -206,14 +211,14 @@ nautilus_file_changes_queue_schedule_metadata_copy (const char *from_uri,
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_METADATA_COPIED;
- new_item->from_uri = g_strdup (from_uri);
- new_item->to_uri = g_strdup (to_uri);
+ new_item->from = g_object_ref (from);
+ new_item->to = g_object_ref (to);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_schedule_metadata_move (const char *from_uri,
- const char *to_uri)
+nautilus_file_changes_queue_schedule_metadata_move (GFile *from,
+ GFile *to)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -222,13 +227,13 @@ nautilus_file_changes_queue_schedule_metadata_move (const char *from_uri,
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_METADATA_MOVED;
- new_item->from_uri = g_strdup (from_uri);
- new_item->to_uri = g_strdup (to_uri);
+ new_item->from = g_object_ref (from);
+ new_item->to = g_object_ref (to);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_schedule_metadata_remove (const char *uri)
+nautilus_file_changes_queue_schedule_metadata_remove (GFile *location)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -237,12 +242,12 @@ nautilus_file_changes_queue_schedule_metadata_remove (const char *uri)
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_METADATA_REMOVED;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_schedule_position_set (const char *uri,
+nautilus_file_changes_queue_schedule_position_set (GFile *location,
GdkPoint point,
int screen)
{
@@ -253,14 +258,14 @@ nautilus_file_changes_queue_schedule_position_set (const char *uri,
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_POSITION_SET;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
new_item->point = point;
new_item->screen = screen;
nautilus_file_changes_queue_add_common (queue, new_item);
}
void
-nautilus_file_changes_queue_schedule_position_remove (const char *uri)
+nautilus_file_changes_queue_schedule_position_remove (GFile *location)
{
NautilusFileChange *new_item;
NautilusFileChangesQueue *queue;
@@ -269,7 +274,7 @@ nautilus_file_changes_queue_schedule_position_remove (const char *uri)
new_item = g_new (NautilusFileChange, 1);
new_item->kind = CHANGE_POSITION_REMOVE;
- new_item->from_uri = g_strdup (uri);
+ new_item->from = g_object_ref (location);
nautilus_file_changes_queue_add_common (queue, new_item);
}
@@ -308,15 +313,15 @@ static void
pairs_list_free (GList *pairs)
{
GList *p;
- URIPair *pair;
+ GFilePair *pair;
/* deep delete the list of pairs */
for (p = pairs; p != NULL; p = p->next) {
/* delete the strings in each pair */
pair = p->data;
- g_free (pair->from_uri);
- g_free (pair->to_uri);
+ g_object_unref (pair->from);
+ g_object_unref (pair->to);
}
/* delete the list and the now empty pair structs */
@@ -331,7 +336,7 @@ position_set_list_free (GList *list)
for (p = list; p != NULL; p = p->next) {
item = p->data;
- g_free (item->uri);
+ g_object_unref (item->location);
}
/* delete the list and the now empty structs */
eel_g_list_free_deep (list);
@@ -347,7 +352,7 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
GList *additions, *changes, *deletions, *moves;
GList *metadata_copy_requests, *metadata_move_requests, *metadata_remove_requests;
GList *position_set_requests;
- URIPair *pair;
+ GFilePair *pair;
NautilusFileChangesQueuePosition *position_set;
guint chunk_count;
NautilusFileChangesQueue *queue;
@@ -435,7 +440,7 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
if (deletions != NULL) {
deletions = g_list_reverse (deletions);
nautilus_directory_notify_files_removed (deletions);
- eel_g_list_free_deep (deletions);
+ eel_g_object_list_free (deletions);
deletions = NULL;
}
if (moves != NULL) {
@@ -447,13 +452,13 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
if (additions != NULL) {
additions = g_list_reverse (additions);
nautilus_directory_notify_files_added (additions);
- eel_g_list_free_deep (additions);
+ eel_g_object_list_free (additions);
additions = NULL;
}
if (changes != NULL) {
changes = g_list_reverse (changes);
nautilus_directory_notify_files_changed (changes);
- eel_g_list_free_deep (changes);
+ eel_g_object_list_free (changes);
changes = NULL;
}
if (metadata_copy_requests != NULL) {
@@ -471,7 +476,7 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
if (metadata_remove_requests != NULL) {
metadata_remove_requests = g_list_reverse (metadata_remove_requests);
nautilus_directory_schedule_metadata_remove (metadata_remove_requests);
- eel_g_list_free_deep (metadata_remove_requests);
+ eel_g_object_list_free (metadata_remove_requests);
metadata_remove_requests = NULL;
}
if (position_set_requests != NULL) {
@@ -490,46 +495,46 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
/* add the new change to the list */
switch (change->kind) {
case CHANGE_FILE_ADDED:
- additions = g_list_prepend (additions, change->from_uri);
+ additions = g_list_prepend (additions, change->from);
break;
case CHANGE_FILE_CHANGED:
- changes = g_list_prepend (changes, change->from_uri);
+ changes = g_list_prepend (changes, change->from);
break;
case CHANGE_FILE_REMOVED:
- deletions = g_list_prepend (deletions, change->from_uri);
+ deletions = g_list_prepend (deletions, change->from);
break;
case CHANGE_FILE_MOVED:
- pair = g_new (URIPair, 1);
- pair->from_uri = change->from_uri;
- pair->to_uri = change->to_uri;
+ pair = g_new (GFilePair, 1);
+ pair->from = change->from;
+ pair->to = change->to;
moves = g_list_prepend (moves, pair);
break;
case CHANGE_METADATA_COPIED:
- pair = g_new (URIPair, 1);
- pair->from_uri = change->from_uri;
- pair->to_uri = change->to_uri;
+ pair = g_new (GFilePair, 1);
+ pair->from = change->from;
+ pair->to = change->to;
metadata_copy_requests = g_list_prepend (metadata_copy_requests, pair);
break;
case CHANGE_METADATA_MOVED:
- pair = g_new (URIPair, 1);
- pair->from_uri = change->from_uri;
- pair->to_uri = change->to_uri;
+ pair = g_new (GFilePair, 1);
+ pair->from = change->from;
+ pair->to = change->to;
metadata_move_requests = g_list_prepend (metadata_move_requests, pair);
break;
case CHANGE_METADATA_REMOVED:
metadata_remove_requests = g_list_prepend (metadata_remove_requests,
- change->from_uri);
+ change->from);
break;
case CHANGE_POSITION_SET:
position_set = g_new (NautilusFileChangesQueuePosition, 1);
- position_set->uri = change->from_uri;
+ position_set->location = change->from;
position_set->set = TRUE;
position_set->point = change->point;
position_set->screen = change->screen;
@@ -539,7 +544,7 @@ nautilus_file_changes_consume_changes (gboolean consume_all)
case CHANGE_POSITION_REMOVE:
position_set = g_new (NautilusFileChangesQueuePosition, 1);
- position_set->uri = change->from_uri;
+ position_set->location = change->from;
position_set->set = FALSE;
position_set_requests = g_list_prepend (position_set_requests,
position_set);
diff --git a/libnautilus-private/nautilus-file-changes-queue.h b/libnautilus-private/nautilus-file-changes-queue.h
index 51b171c11..573dad30f 100644
--- a/libnautilus-private/nautilus-file-changes-queue.h
+++ b/libnautilus-private/nautilus-file-changes-queue.h
@@ -24,22 +24,24 @@
#define NAUTILUS_FILE_CHANGES_QUEUE_H
#include <gdk/gdktypes.h>
+#include <gio/gfile.h>
+
+void nautilus_file_changes_queue_file_added (GFile *location);
+void nautilus_file_changes_queue_file_changed (GFile *location);
+void nautilus_file_changes_queue_file_removed (GFile *location);
+void nautilus_file_changes_queue_file_moved (GFile *from,
+ GFile *to);
+void nautilus_file_changes_queue_schedule_metadata_copy (GFile *from,
+ GFile *to);
+void nautilus_file_changes_queue_schedule_metadata_move (GFile *from,
+ GFile *to);
+void nautilus_file_changes_queue_schedule_metadata_remove (GFile *location);
+void nautilus_file_changes_queue_schedule_position_set (GFile *location,
+ GdkPoint point,
+ int screen);
+void nautilus_file_changes_queue_schedule_position_remove (GFile *location);
+
+void nautilus_file_changes_consume_changes (gboolean consume_all);
-void nautilus_file_changes_queue_file_added (const char *uri);
-void nautilus_file_changes_queue_file_changed (const char *uri);
-void nautilus_file_changes_queue_file_removed (const char *uri);
-void nautilus_file_changes_queue_file_moved (const char *from_uri,
- const char *to_uri);
-void nautilus_file_changes_queue_schedule_metadata_copy (const char *from_uri,
- const char *to_uri);
-void nautilus_file_changes_queue_schedule_metadata_move (const char *from_uri,
- const char *to_uri);
-void nautilus_file_changes_queue_schedule_metadata_remove (const char *uri);
-void nautilus_file_changes_queue_schedule_position_set (const char *uri,
- GdkPoint point,
- int screen);
-void nautilus_file_changes_queue_schedule_position_remove (const char *uri);
-
-void nautilus_file_changes_consume_changes (gboolean consume_all);
#endif /* NAUTILUS_FILE_CHANGES_QUEUE_H */
diff --git a/libnautilus-private/nautilus-file-dnd.c b/libnautilus-private/nautilus-file-dnd.c
index 0f5b4e939..2919b254f 100644
--- a/libnautilus-private/nautilus-file-dnd.c
+++ b/libnautilus-private/nautilus-file-dnd.c
@@ -30,7 +30,7 @@
#include "nautilus-dnd.h"
#include "nautilus-directory.h"
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
+#include <string.h>
static gboolean
nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
@@ -134,11 +134,11 @@ nautilus_drag_can_accept_info (NautilusFile *drop_target_item,
g_assert_not_reached ();
return FALSE;
}
-
}
void
-nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, const char *keyword)
+nautilus_drag_file_receive_dropped_keyword (NautilusFile *file,
+ const char *keyword)
{
GList *keywords, *word;
@@ -159,7 +159,7 @@ nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, const char *keyw
g_list_free_1 (word);
}
}
-
+
nautilus_file_set_keywords (file, keywords);
eel_g_list_free_deep (keywords);
}
diff --git a/libnautilus-private/nautilus-file-operations-progress.c b/libnautilus-private/nautilus-file-operations-progress.c
index 3c60f0dc0..e6293b50f 100644
--- a/libnautilus-private/nautilus-file-operations-progress.c
+++ b/libnautilus-private/nautilus-file-operations-progress.c
@@ -40,7 +40,7 @@
#include <gtk/gtktable.h>
#include <gtk/gtkvbox.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <glib/gurifuncs.h>
#include "nautilus-file-operations-progress-icons.h"
/* The default width of the progress dialog. It will be wider
@@ -88,8 +88,8 @@ struct NautilusFileOperationsProgressDetails {
gulong files_total;
gulong file_index;
- GnomeVFSFileSize bytes_copied;
- GnomeVFSFileSize bytes_total;
+ goffset bytes_copied;
+ goffset bytes_total;
/* system time (microseconds) when show timeout was started */
gint64 start_time;
@@ -190,7 +190,7 @@ set_text_unescaped_trimmed (GtkLabel *label, const char *text)
return;
}
- unescaped_text = gnome_vfs_unescape_string_for_display (text);
+ unescaped_text = g_uri_unescape_string (text, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH);
unescaped_utf8 = eel_make_valid_utf8 (unescaped_text);
gtk_label_set_text (label, unescaped_utf8);
g_free (unescaped_utf8);
@@ -486,7 +486,7 @@ nautilus_file_operations_progress_new (const char *title,
const char *from_prefix,
const char *to_prefix,
gulong total_files,
- GnomeVFSFileSize total_bytes,
+ goffset total_bytes,
gboolean use_timeout)
{
GtkWidget *widget;
@@ -531,7 +531,7 @@ nautilus_file_operations_progress_new (const char *title,
void
nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *progress,
gulong files_total,
- GnomeVFSFileSize bytes_total)
+ goffset bytes_total)
{
g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
@@ -562,7 +562,7 @@ nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *prog
const char *from_prefix,
const char *to_prefix,
gulong file_index,
- GnomeVFSFileSize size)
+ goffset size)
{
char *operation_markup;
char *item_markup;
@@ -621,8 +621,8 @@ nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *progres
void
nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *progress,
- GnomeVFSFileSize bytes_done_in_file,
- GnomeVFSFileSize bytes_done)
+ goffset bytes_done_in_file,
+ goffset bytes_done)
{
g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
diff --git a/libnautilus-private/nautilus-file-operations-progress.h b/libnautilus-private/nautilus-file-operations-progress.h
index 627cead0a..f7a0adafa 100644
--- a/libnautilus-private/nautilus-file-operations-progress.h
+++ b/libnautilus-private/nautilus-file-operations-progress.h
@@ -30,7 +30,6 @@
#define NAUTILUS_FILE_OPERATIONS_PROGRESS_H
#include <gtk/gtkdialog.h>
-#include <libgnomevfs/gnome-vfs-file-size.h>
typedef struct NautilusFileOperationsProgressDetails NautilusFileOperationsProgressDetails;
@@ -56,14 +55,14 @@ NautilusFileOperationsProgress *nautilus_file_operations_progress_new
const char *from_prefix,
const char *to_prefix,
gulong files_total,
- GnomeVFSFileSize bytes_total,
+ goffset bytes_total,
gboolean use_timeout);
void nautilus_file_operations_progress_done (NautilusFileOperationsProgress *dialog);
void nautilus_file_operations_progress_set_progress_title (NautilusFileOperationsProgress *dialog,
const char *progress_title);
void nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
gulong files_total,
- GnomeVFSFileSize bytes_total);
+ goffset bytes_total);
void nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
const char *operation_string);
void nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog);
@@ -75,10 +74,10 @@ void nautilus_file_operations_progress_new_file
const char *from_prefix,
const char *to_prefix,
gulong file_index,
- GnomeVFSFileSize size);
+ goffset size);
void nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
- GnomeVFSFileSize bytes_done_in_file,
- GnomeVFSFileSize bytes_done);
+ goffset bytes_done_in_file,
+ goffset bytes_done);
void nautilus_file_operations_progress_pause_timeout (NautilusFileOperationsProgress *progress);
void nautilus_file_operations_progress_resume_timeout (NautilusFileOperationsProgress *progress);
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 74af423ba..cfef8376f 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -4,6 +4,7 @@
Copyright (C) 1999, 2000 Free Software Foundation
Copyright (C) 2000, 2001 Eazel, Inc.
+ Copyright (C) 2007 Red Hat, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -20,20 +21,27 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- Authors: Ettore Perazzoli <ettore@gnu.org>
+ Authors: Alexander Larsson <alexl@redhat.com>
+ Ettore Perazzoli <ettore@gnu.org>
Pavel Cisler <pavel@eazel.com>
*/
#include <config.h>
#include <string.h>
#include <stdio.h>
+#include <stdarg.h>
#include <locale.h>
+#include <math.h>
#include "nautilus-file-operations.h"
#include "nautilus-debug-log.h"
#include "nautilus-file-operations-progress.h"
+#include "nautilus-file-changes-queue.h"
#include "nautilus-lib-self-check-functions.h"
+#include "nautilus-progress-info.h"
+
+#include <eel/eel-alert-dialog.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-pango-extensions.h>
#include <eel/eel-gtk-extensions.h>
@@ -54,6 +62,9 @@
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-volume.h>
#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gfile.h>
+#include <glib/gurifuncs.h>
+#include <gio/gioscheduler.h>
#include "nautilus-file-changes-queue.h"
#include "nautilus-file-private.h"
#include "nautilus-desktop-icon-file.h"
@@ -63,6 +74,210 @@
#include "nautilus-trash-monitor.h"
#include "nautilus-file-utilities.h"
+static gboolean confirm_trash_auto_value;
+
+/* TODO:
+ * Add cancellation
+ * Implement missing functions:
+ * duplicate, new file, new folder, empty trash, set_permissions recursive
+ * Make delete handle recursive deletes
+ * Use CommonJob in trash/delete code
+ * TESTING!!!
+ */
+
+typedef struct {
+ GIOJob *io_job;
+ GTimer *time;
+ GtkWidget *parent_window;
+ NautilusProgressInfo *progress;
+ GCancellable *cancellable;
+ gboolean aborted;
+ GHashTable *skip_files;
+ GHashTable *skip_readdir_error;
+ gboolean skip_all_error;
+ gboolean skip_all_conflict;
+ gboolean merge_all;
+ gboolean replace_all;
+} CommonJob;
+
+typedef struct {
+ CommonJob common;
+ gboolean is_move;
+ GList *files;
+ GFile *destination;
+ GdkPoint *icon_positions;
+ int n_icon_positions;
+ int screen_num;
+ GHashTable *debuting_files;
+ NautilusCopyCallback done_callback;
+ gpointer done_callback_data;
+} CopyMoveJob;
+
+#define SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE 15
+#define NSEC_PER_SEC 1000000000
+#define NSEC_PER_MSEC 1000000
+
+#define IS_IO_ERROR(__error, KIND) (((__error)->domain == G_IO_ERROR && (__error)->code == G_IO_ERROR_ ## KIND))
+
+#define SKIP _("_Skip")
+#define SKIP_ALL _("S_kip All")
+#define RETRY _("_Retry")
+#define REPLACE _("_Replace")
+#define REPLACE_ALL _("Replace _All")
+#define MERGE _("_Merge")
+#define MERGE_ALL _("Merge _All")
+
+static char *
+format_time (int seconds)
+{
+ int minutes;
+ int hours;
+ char *res;
+
+ if (seconds < 0) {
+ /* Just to make sure... */
+ seconds = 0;
+ }
+
+ if (seconds < 60) {
+ return g_strdup_printf (ngettext ("%d second","%d seconds", (int) seconds), (int) seconds);
+ }
+
+ if (seconds < 60*60) {
+ minutes = (seconds + 30) / 60;
+ return g_strdup_printf (ngettext (_("%d minute"), _("%d minutes"), minutes), minutes);
+ }
+
+ hours = seconds / (60*60);
+
+ if (seconds < 60*60*4) {
+ char *h, *m;
+
+ minutes = (seconds - hours * 60 * 60 + 30) / 60;
+
+ h = g_strdup_printf (ngettext (_("%d hour"), _("%d hours"), hours), hours);
+ m = g_strdup_printf (ngettext (_("%d minute"), _("%d minutes"), minutes), minutes);
+ res = g_strconcat (h, ", ", m, NULL);
+ g_free (h);
+ g_free (m);
+ return res;
+ }
+
+ return g_strdup_printf (_("about %d hours"), hours);
+}
+
+static char *
+custom_full_name_to_string (char *format, va_list va)
+{
+ GFile *file;
+
+ file = va_arg (va, GFile *);
+
+ return g_file_get_parse_name (file);
+}
+
+static void
+custom_full_name_skip (va_list *va)
+{
+ va_arg (*va, GFile *);
+}
+
+static char *
+custom_basename_to_string (char *format, va_list va)
+{
+ GFile *file;
+ GFileInfo *info;
+ char *name, *basename;
+
+ file = va_arg (va, GFile *);
+
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STD_DISPLAY_NAME,
+ 0,
+ g_cancellable_get_current (),
+ NULL);
+
+ name = NULL;
+ if (info) {
+ name = g_strdup (g_file_info_get_display_name (info));
+ g_object_unref (info);
+ }
+
+ if (name == NULL) {
+ basename = g_file_get_basename (file);
+ if (g_utf8_validate (basename, -1, NULL)) {
+ name = basename;
+ } else {
+ name = g_uri_escape_string (basename, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
+ g_free (basename);
+ }
+ }
+
+ return name;
+}
+
+static void
+custom_basename_skip (va_list *va)
+{
+ va_arg (*va, GFile *);
+}
+
+
+static char *
+custom_size_to_string (char *format, va_list va)
+{
+ goffset size;
+
+ size = va_arg (va, goffset);
+ return g_format_file_size_for_display (size);
+}
+
+static void
+custom_size_skip (va_list *va)
+{
+ va_arg (*va, goffset);
+}
+
+static char *
+custom_time_to_string (char *format, va_list va)
+{
+ int secs;
+
+ secs = va_arg (va, int);
+ return format_time (secs);
+}
+
+static void
+custom_time_skip (va_list *va)
+{
+ va_arg (*va, int);
+}
+
+static EelPrintfHandler handlers[] = {
+ { 'F', custom_full_name_to_string, custom_full_name_skip },
+ { 'B', custom_basename_to_string, custom_basename_skip },
+ { 'S', custom_size_to_string, custom_size_skip },
+ { 'T', custom_time_to_string, custom_time_skip },
+ { 0 }
+};
+
+
+static char *
+f (const char *format, ...) {
+ va_list va;
+ char *res;
+
+ va_start (va, format);
+ res = eel_strdup_vprintf_with_custom (handlers, format, va);
+ va_end (va);
+
+ return res;
+}
+
+
+
+#ifdef GIO_CONVERSION_DONE
+
typedef enum TransferKind TransferKind;
typedef struct TransferInfo TransferInfo;
typedef struct IconPositionIterator IconPositionIterator;
@@ -126,6 +341,21 @@ transfer_info_destroy (TransferInfo *transfer_info)
g_free (transfer_info);
}
+#endif /* GIO_CONVERSION_DONE */
+
+static void
+setup_autos (void)
+{
+ static gboolean setup_autos = FALSE;
+ if (!setup_autos) {
+ setup_autos = TRUE;
+ eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
+ &confirm_trash_auto_value);
+ }
+}
+
+#ifdef GIO_CONVERSION_DONE
+
/* Struct used to control applying icon positions to
* top level items during a copy, drag, new folder creation and
* link creation
@@ -408,6 +638,81 @@ create_transfer_dialog (const GnomeVFSXferProgressInfo *progress_info,
}
}
+/* TODO: This should really use the gio display name */
+static const char *
+get_vfs_method_display_name (char *method)
+{
+ if (g_ascii_strcasecmp (method, "computer") == 0 ) {
+ return _("Computer");
+ } else if (g_ascii_strcasecmp (method, "network") == 0 ) {
+ return _("Network");
+ } else if (g_ascii_strcasecmp (method, "fonts") == 0 ) {
+ return _("Fonts");
+ } else if (g_ascii_strcasecmp (method, "themes") == 0 ) {
+ return _("Themes");
+ } else if (g_ascii_strcasecmp (method, "burn") == 0 ) {
+ return _("CD/DVD Creator");
+ } else if (g_ascii_strcasecmp (method, "smb") == 0 ) {
+ return _("Windows Network");
+ } else if (g_ascii_strcasecmp (method, "dns-sd") == 0 ) {
+ /* translators: this is the title of the "dns-sd:///" location */
+ return _("Services in");
+ }
+ return NULL;
+}
+
+/* TODO: This should really use the gio display name */
+static char *
+get_uri_shortname_for_display (GnomeVFSURI *uri)
+{
+ char *utf8_name, *name, *tmp;
+ char *text_uri, *local_file;
+ gboolean validated;
+ const char *method;
+
+
+ validated = FALSE;
+ name = gnome_vfs_uri_extract_short_name (uri);
+ if (name == NULL) {
+ name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
+ } else if (g_ascii_strcasecmp (uri->method_string, "file") == 0) {
+ text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
+ local_file = g_filename_from_uri (text_uri, NULL, NULL);
+ g_free (name);
+ if (local_file == NULL) { /* Happens for e.g. file:///# */
+ local_file = g_strdup ("/");
+ }
+ name = g_filename_display_basename (local_file);
+ g_free (local_file);
+ g_free (text_uri);
+ validated = TRUE;
+ } else if (!gnome_vfs_uri_has_parent (uri)) {
+ /* Special-case the display name for roots that are not local files */
+ method = get_vfs_method_display_name (uri->method_string);
+ if (method == NULL) {
+ method = uri->method_string;
+ }
+
+ if (name == NULL ||
+ strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) {
+ g_free (name);
+ name = g_strdup (method);
+ } else {
+ tmp = name;
+ name = g_strdup_printf ("%s: %s", method, name);
+ g_free (tmp);
+ }
+ }
+
+ if (!validated && !g_utf8_validate (name, -1, NULL)) {
+ utf8_name = eel_make_valid_utf8 (name);
+ g_free (name);
+ name = utf8_name;
+ }
+
+ return name;
+}
+
static void
progress_dialog_set_to_from_item_text (NautilusFileOperationsProgress *dialog,
const char *progress_verb,
@@ -435,7 +740,7 @@ progress_dialog_set_to_from_item_text (NautilusFileOperationsProgress *dialog,
if (from_uri != NULL) {
uri = gnome_vfs_uri_new (from_uri);
- item = nautilus_get_uri_shortname_for_display (uri);
+ item = get_uri_shortname_for_display (uri);
from_path = gnome_vfs_uri_extract_dirname (uri);
hostname = NULL;
@@ -518,10 +823,12 @@ handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
&& strcmp (progress_info->source_name, progress_info->target_name) != 0
&& progress_info->bytes_total != progress_info->bytes_copied) {
GList *delete_me;
+ GtkWidget *toplevel;
- delete_me = g_list_prepend (NULL, progress_info->target_name);
- nautilus_file_operations_delete (delete_me, transfer_info->parent_view, NULL, NULL);
- g_list_free (delete_me);
+ delete_me = g_list_prepend (NULL, g_file_new_for_uri (progress_info->target_name));
+ toplevel = gtk_widget_get_toplevel (transfer_info->parent_view);
+ nautilus_file_operations_delete (delete_me, GTK_WINDOW (toplevel), NULL, NULL);
+ eel_g_object_list_free (delete_me);
}
return 0;
@@ -1026,7 +1333,7 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
error_dialog_button_pressed = eel_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE,
GTK_MESSAGE_ERROR, text,
- detail, GTK_STOCK_CANCEL, _("_Retry"), NULL);
+ detail, GTK_STOCK_CANCEL, RETRY, NULL);
switch (error_dialog_button_pressed) {
case 0:
@@ -1043,7 +1350,7 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
error_dialog_button_pressed = eel_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE,
GTK_MESSAGE_ERROR, text,
- detail, _("_Skip"), GTK_STOCK_CANCEL, _("_Retry"), NULL);
+ detail, SKIP, GTK_STOCK_CANCEL, RETRY, NULL);
switch (error_dialog_button_pressed) {
case 0:
@@ -1211,7 +1518,7 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
GTK_MESSAGE_WARNING,
text,
secondary_text,
- _("_Skip"), _("_Replace"), NULL);
+ SKIP, REPLACE, NULL);
g_free (text);
g_free (secondary_text);
@@ -1230,7 +1537,7 @@ handle_transfer_overwrite (const GnomeVFSXferProgressInfo *progress_info,
result = eel_run_simple_dialog
(parent_for_error_dialog (transfer_info), TRUE, GTK_MESSAGE_WARNING, text,
secondary_text,
- _("S_kip All"), _("Replace _All"), _("_Skip"), _("_Replace"), NULL);
+ SKIP_ALL, REPLACE_ALL, SKIP, REPLACE, NULL);
g_free (text);
g_free (secondary_text);
@@ -1761,7 +2068,7 @@ sync_transfer_callback (GnomeVFSXferProgressInfo *progress_info, gpointer data)
*/
if (progress_info->source_name == NULL) {
/* remove any old metadata */
- nautilus_file_changes_queue_schedule_metadata_remove
+ nautilus_file_changes_queue_schedule_metadata_remove_by_uri
(progress_info->target_name);
} else {
nautilus_file_changes_queue_schedule_metadata_copy
@@ -1821,10 +2128,10 @@ sync_transfer_callback (GnomeVFSXferProgressInfo *progress_info, gpointer data)
case GNOME_VFS_XFER_PHASE_DELETESOURCE:
g_assert (progress_info->source_name != NULL);
if (progress_info->top_level_item) {
- nautilus_file_changes_queue_schedule_metadata_remove
+ nautilus_file_changes_queue_schedule_metadata_remove_by_uri
(progress_info->source_name);
}
- nautilus_file_changes_queue_file_removed (progress_info->source_name);
+ nautilus_file_changes_queue_file_removed_by_uri (progress_info->source_name);
break;
case GNOME_VFS_XFER_PHASE_COMPLETED:
@@ -1998,7 +2305,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
text_uri = gnome_vfs_uri_to_string (source_uri, GNOME_VFS_URI_HIDE_NONE);
- path = gnome_vfs_get_local_path_from_uri (text_uri);
+ path = g_filename_from_uri (text_uri, NULL, NULL);
volume = NULL;
if (path != NULL) {
@@ -2733,7 +3040,7 @@ nautilus_file_operations_new_file (GtkWidget *parent_view,
target_filename = g_filename_from_utf8 (_("new file"), -1, NULL, NULL, NULL);
- source_file_uri = gnome_vfs_get_uri_from_local_path (source_file_str);
+ source_file_uri = g_filename_to_uri (source_file_str, NULL, NULL);
new_data = g_new (struct NewFileData, 1);
new_data->tmp_file = g_strdup (source_file_str);
@@ -2752,84 +3059,692 @@ nautilus_file_operations_new_file (GtkWidget *parent_view,
g_free (target_filename);
}
-void
-nautilus_file_operations_delete (const GList *item_uris,
- GtkWidget *parent_view,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data)
+#endif /* GIO_CONVERSION_DONE */
+
+
+typedef struct {
+ GList *files;
+ GtkWindow *parent_window;
+ gboolean try_trash;
+ gboolean delete_if_all_already_in_trash;
+ NautilusDeleteCallback done_callback;
+ gpointer done_callback_data;
+} DeleteJob;
+
+static gboolean
+can_delete_without_confirm (GFile *file)
{
- GList *uri_list;
- const GList *p;
- const char *item_uri;
- NautilusFile *file;
- TransferInfo *transfer_info;
+ if (g_file_has_uri_scheme (file, "burn")) {
+ return TRUE;
+ }
- nautilus_debug_log_with_uri_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, item_uris,
- "delete files:");
+ return FALSE;
+}
- uri_list = NULL;
- for (p = item_uris; p != NULL; p = p->next) {
- item_uri = (const char *) p->data;
-
- if (eel_uri_is_desktop (item_uri)) {
- file = nautilus_file_get_existing (item_uri);
- if (file != NULL) {
- if (NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
- NautilusDesktopLink *link;
-
- link = nautilus_desktop_icon_file_get_link (NAUTILUS_DESKTOP_ICON_FILE (file));
-
- if (link != NULL) {
- nautilus_desktop_link_monitor_delete_link (nautilus_desktop_link_monitor_get (),
- link,
- parent_view);
- g_object_unref (link);
- }
- }
- nautilus_file_unref (file);
- }
+static gboolean
+can_delete_files_without_confirm (GList *files)
+{
+ g_assert (files != NULL);
+
+ while (files != NULL) {
+ if (!can_delete_without_confirm (files->data)) {
+ return FALSE;
+ }
+
+ files = files->next;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+can_trash_file (GFile *file, GCancellable *cancellable)
+{
+ GFileInfo *info;
+ gboolean res;
+
+ res = FALSE;
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH,
+ 0,
+ cancellable,
+ NULL);
+
+ if (info) {
+ res = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH);
+ g_object_unref (info);
+ }
+
+ return res;
+}
+
+static char *
+get_display_name (GFile *file, GCancellable *cancellable)
+{
+ GFileInfo *info;
+ char *name, *basename;
+
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STD_DISPLAY_NAME,
+ 0, cancellable, NULL);
+
+ name = NULL;
+ if (info) {
+ name = g_strdup (g_file_info_get_display_name (info));
+ g_object_unref (info);
+ }
+
+ if (name == NULL) {
+ basename = g_file_get_basename (file);
+ if (g_utf8_validate (basename, -1, NULL)) {
+ name = basename;
} else {
- uri_list = g_list_prepend (uri_list,
- gnome_vfs_uri_new (item_uri));
+ name = g_uri_escape_string (basename, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
+ g_free (basename);
}
}
- uri_list = g_list_reverse (uri_list);
+
+ return name;
+}
- if (uri_list == NULL) {
- return;
+static void
+delete_files (GList *files, GCancellable *cancellable, GtkWindow *parent_window)
+{
+ GList *l;
+ GFile *file;
+ GError *error;
+
+ for (l = files; l != NULL; l = l->next) {
+ file = l->data;
+
+ error = NULL;
+ if (!g_file_delete (file, cancellable, &error)) {
+ /* TODO-gio: Dialog here, and handle recursive deletes */
+ g_print ("Error deleting file: %s\n", error->message);
+ } else {
+ nautilus_file_changes_queue_schedule_metadata_remove (file);
+ nautilus_file_changes_queue_file_removed (file);
+ }
}
+}
- transfer_info = transfer_info_new (parent_view);
+static void
+trash_files (GList *files, GCancellable *cancellable, GtkWindow *parent_window)
+{
+ GList *l;
+ GFile *file;
+ GError *error;
- /* localizers: progress dialog title */
- transfer_info->operation_title = _("Deleting files");
- /* localizers: label prepended to the progress count */
- transfer_info->action_label =_("Files deleted:");
- /* localizers: label prepended to the name of the current file deleted */
- transfer_info->progress_verb =_("Deleting");
- transfer_info->preparation_name =_("Preparing to Delete files...");
- transfer_info->cleanup_name ="";
+ for (l = files; l != NULL; l = l->next) {
+ file = l->data;
- transfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
- transfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE;
- transfer_info->kind = TRANSFER_DELETE;
+ error = NULL;
+ if (!g_file_trash (file, cancellable, &error)) {
+ /* TODO-gio: Dialog here, allow delete instead of trash, etc */
+ g_print ("Error trashing file: %s\n", error->message);
+ } else {
+ nautilus_file_changes_queue_schedule_metadata_remove (file);
+ nautilus_file_changes_queue_file_removed (file);
+ }
+ }
+}
+
+typedef struct {
+ GtkWindow *parent_window;
+ gboolean ignore_close_box;
+ GtkMessageType message_type;
+ const char *primary_text;
+ const char *secondary_text;
+ const char *details_text;
+ const char **button_titles;
- transfer_info->done_callback = done_callback;
- transfer_info->done_callback_data = done_callback_data;
- transfer_info->debuting_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ int result;
+} RunSimpleDialogData;
- gnome_vfs_async_xfer (&transfer_info->handle, uri_list, NULL,
- GNOME_VFS_XFER_DELETE_ITEMS | GNOME_VFS_XFER_RECURSIVE,
- GNOME_VFS_XFER_ERROR_MODE_QUERY,
- GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
- GNOME_VFS_PRIORITY_DEFAULT,
- update_transfer_callback, transfer_info,
- sync_transfer_callback, NULL);
+static void
+do_run_simple_dialog (gpointer _data)
+{
+ RunSimpleDialogData *data = _data;
+ const char *button_title;
+ GtkWidget *dialog;
+ int result;
+ int response_id;
+
+ /* Create the dialog. */
+ dialog = eel_alert_dialog_new (data->parent_window,
+ 0,
+ data->message_type,
+ GTK_BUTTONS_NONE,
+ data->primary_text,
+ data->secondary_text);
+
+ for (response_id = 0;
+ data->button_titles[response_id] != NULL;
+ response_id++) {
+ button_title = data->button_titles[response_id];
+ gtk_dialog_add_button (GTK_DIALOG (dialog), button_title, response_id);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), response_id);
+ }
+
+ if (data->details_text) {
+ eel_alert_dialog_set_details_label (EEL_ALERT_DIALOG (dialog),
+ data->details_text);
+ }
+
+ /* Run it. */
+ gtk_widget_show (dialog);
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ while ((result == GTK_RESPONSE_NONE || result == GTK_RESPONSE_DELETE_EVENT) && data->ignore_close_box) {
+ gtk_widget_show (GTK_WIDGET (dialog));
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+ }
+
+ gtk_object_destroy (GTK_OBJECT (dialog));
+
+ data->result = result;
+}
+
+static int
+_run_simple_dialog (GIOJob *job,
+ GtkWindow *parent_window,
+ gboolean ignore_close_box,
+ GtkMessageType message_type,
+ const char *primary_text,
+ const char *secondary_text,
+ const char *details_text,
+ ...)
+{
+ RunSimpleDialogData *data;
+ va_list varargs;
+ int res;
+ const char *button_title;
+ GPtrArray *ptr_array;
+
+ data = g_new0 (RunSimpleDialogData, 1);
+ data->parent_window = parent_window;
+ data->ignore_close_box = ignore_close_box;
+ data->message_type = message_type;
+ data->primary_text = primary_text;
+ data->secondary_text = secondary_text;
+ data->details_text = details_text;
+
+ ptr_array = g_ptr_array_new ();
+ va_start (varargs, details_text);
+ while ((button_title = va_arg (varargs, const char *)) != NULL) {
+ g_ptr_array_add (ptr_array, (char *)button_title);
+ }
+ g_ptr_array_add (ptr_array, NULL);
+ data->button_titles = (const char **)g_ptr_array_free (ptr_array, FALSE);
+ va_end (varargs);
+
+ g_io_job_send_to_mainloop (job,
+ do_run_simple_dialog,
+ data,
+ NULL,
+ TRUE);
+
+ res = data->result;
+
+ g_free (data->button_titles);
+ g_free (data);
+ return res;
+}
+
+static int
+_run_alert (GIOJob *job,
+ GtkWindow *parent_window,
+ const char *primary_message,
+ const char *secondary_message,
+ const char *ok_label)
+{
+ return _run_simple_dialog (job, parent_window,
+ FALSE,
+ GTK_MESSAGE_WARNING,
+ primary_message,
+ secondary_message,
+ NULL,
+ GTK_STOCK_CANCEL,
+ ok_label,
+ NULL);
+}
+
+static int
+_run_yes_no_dialog (GIOJob *job,
+ const char *prompt,
+ const char *detail,
+ const char *yes_label,
+ const char *no_label,
+ GtkWindow *parent_window)
+{
+ return _run_simple_dialog (job, parent_window,
+ FALSE,
+ GTK_MESSAGE_QUESTION,
+ prompt,
+ detail,
+ NULL,
+ no_label,
+ yes_label,
+ NULL);
+}
+
+/* NOTE: This frees the primary / secondary strings, in order to
+ avoid doing that everywhere. So, make sure they are strduped */
+
+static int
+run_simple_dialog_va (CommonJob *job,
+ gboolean ignore_close_box,
+ GtkMessageType message_type,
+ char *primary_text,
+ char *secondary_text,
+ const char *details_text,
+ va_list varargs)
+{
+ RunSimpleDialogData *data;
+ int res;
+ const char *button_title;
+ GPtrArray *ptr_array;
+
+ g_timer_stop (job->time);
+
+ data = g_new0 (RunSimpleDialogData, 1);
+ data->parent_window = GTK_WINDOW (job->parent_window);
+ data->ignore_close_box = ignore_close_box;
+ data->message_type = message_type;
+ data->primary_text = primary_text;
+ data->secondary_text = secondary_text;
+ data->details_text = details_text;
+
+ ptr_array = g_ptr_array_new ();
+ while ((button_title = va_arg (varargs, const char *)) != NULL) {
+ g_ptr_array_add (ptr_array, (char *)button_title);
+ }
+ g_ptr_array_add (ptr_array, NULL);
+ data->button_titles = (const char **)g_ptr_array_free (ptr_array, FALSE);
+
+ g_io_job_send_to_mainloop (job->io_job,
+ do_run_simple_dialog,
+ data,
+ NULL,
+ TRUE);
+
+ res = data->result;
+
+ g_free (data->button_titles);
+ g_free (data);
+
+ g_timer_continue (job->time);
+
+ g_free (primary_text);
+ g_free (secondary_text);
+
+ return res;
+}
+
+#if 0 /* Not used at the moment */
+static int
+run_simple_dialog (CommonJob *job,
+ gboolean ignore_close_box,
+ GtkMessageType message_type,
+ char *primary_text,
+ char *secondary_text,
+ const char *details_text,
+ ...)
+{
+ va_list varargs;
+ int res;
+
+ va_start (varargs, details_text);
+ res = run_simple_dialog_va (job,
+ ignore_close_box,
+ message_type,
+ primary_text,
+ secondary_text,
+ details_text,
+ varargs);
+ va_end (varargs);
+ return res;
+}
+#endif
+
+static int
+run_error (CommonJob *job,
+ char *primary_text,
+ char *secondary_text,
+ const char *details_text,
+ ...)
+{
+ va_list varargs;
+ int res;
+
+ va_start (varargs, details_text);
+ res = run_simple_dialog_va (job,
+ FALSE,
+ GTK_MESSAGE_ERROR,
+ primary_text,
+ secondary_text,
+ details_text,
+ varargs);
+ va_end (varargs);
+ return res;
+}
+
+static int
+run_warning (CommonJob *job,
+ char *primary_text,
+ char *secondary_text,
+ const char *details_text,
+ ...)
+{
+ va_list varargs;
+ int res;
+
+ va_start (varargs, details_text);
+ res = run_simple_dialog_va (job,
+ FALSE,
+ GTK_MESSAGE_WARNING,
+ primary_text,
+ secondary_text,
+ details_text,
+ varargs);
+ va_end (varargs);
+ return res;
+}
+
+static gboolean
+confirm_delete_from_trash (GIOJob *job,
+ GtkWindow *parent_window,
+ GList *files)
+{
+ char *prompt;
+ char *file_name;
+ int file_count;
+ int response;
+
+ /* Just Say Yes if the preference says not to confirm. */
+ if (!confirm_trash_auto_value) {
+ return TRUE;
+ }
+
+ file_count = g_list_length (files);
+ g_assert (file_count > 0);
+
+ if (file_count == 1) {
+ file_name = get_display_name ((GFile *) files->data, NULL);
+ prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\" "
+ "from the trash?"), file_name);
+ g_free (file_name);
+ } else {
+ prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
+ "the %d selected item from the trash?",
+ "Are you sure you want to permanently delete "
+ "the %d selected items from the trash?",
+ file_count),
+ file_count);
+ }
+
+ response = _run_alert (job, parent_window,
+ prompt,
+ _("If you delete an item, it will be permanently lost."),
+ GTK_STOCK_DELETE);
+
+ return (response == 1);
+}
+
+static gboolean
+confirm_deletion (GIOJob *job,
+ GtkWindow *parent_window,
+ GList *files,
+ gboolean all)
+{
+ char *prompt;
+ char *detail;
+ int file_count;
+ GFile *file;
+ char *file_name;
+ int response;
+
+ file_count = g_list_length (files);
+ g_assert (file_count > 0);
+
+ if (file_count == 1) {
+ file = files->data;
+ if (g_file_has_uri_scheme (file, "x-nautilus-desktop")) {
+ /* Don't ask for desktop icons */
+ return TRUE;
+ }
+ file_name = get_display_name (file, NULL);
+ prompt = _("Cannot move file to trash, do you want to delete immediately?");
+ detail = g_strdup_printf (_("The file \"%s\" cannot be moved to the trash."), file_name);
+ g_free (file_name);
+ } else {
+ if (all) {
+ prompt = _("Cannot move items to trash, do you want to delete them immediately?");
+ detail = g_strdup_printf (ngettext("The selected item could not be moved to the Trash",
+ "The %d selected items could not be moved to the Trash",
+ file_count),
+ file_count);
+ } else {
+ prompt = _("Cannot move some items to trash, do you want to delete these immediately?");
+ detail = g_strdup_printf (_("%d of the selected items cannot be moved to the Trash"), file_count);
+ }
+ }
+
+ response = _run_yes_no_dialog (job,
+ prompt,
+ detail,
+ GTK_STOCK_DELETE, GTK_STOCK_CANCEL,
+ parent_window);
+
+ g_free (detail);
+
+ return (response == 1);
+}
+
+static gboolean
+confirm_delete_directly (GIOJob *job,
+ GtkWindow *parent_window,
+ GList *files)
+{
+ char *prompt;
+ char *file_name;
+ int file_count;
+ int response;
+
+ /* Just Say Yes if the preference says not to confirm. */
+ if (!confirm_trash_auto_value) {
+ return TRUE;
+ }
+
+ file_count = g_list_length (files);
+ g_assert (file_count > 0);
+
+ if (can_delete_files_without_confirm (files)) {
+ return TRUE;
+ }
+
+ if (file_count == 1) {
+ file_name = get_display_name (files->data, NULL);
+ prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
+ file_name);
+ g_free (file_name);
+ } else {
+ prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
+ "the %d selected item?",
+ "Are you sure you want to permanently delete "
+ "the %d selected items?", file_count), file_count);
+ }
+
+ response = _run_alert (job, parent_window,
+ prompt,
+ _("If you delete an item, it will be permanently lost."),
+ GTK_STOCK_DELETE);
+
+ return response == 1;
+}
+
+
+static void delete_job_done (gpointer data);
+
+static void
+delete_job (GIOJob *io_job,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ DeleteJob *job = user_data;
+ GList *trashable_files;
+ GList *untrashable_files;
+ GList *in_trash_files;
+ GList *no_confirm_files;
+ GList *l;
+ GFile *file;
+ gboolean confirmed;
+
+ /* Collect three lists: (1) items that can be moved to trash,
+ * (2) items that can only be deleted in place, and (3) items that
+ * are already in trash.
+ *
+ * Always move (1) to trash if non-empty.
+ * Delete (3) only if (1) and (2) are non-empty, otherwise ignore (3).
+ * Ask before deleting (2) if non-empty.
+ * Ask before deleting (3) if non-empty.
+ */
+
+ trashable_files = NULL;
+ untrashable_files = NULL;
+ in_trash_files = NULL;
+ no_confirm_files = NULL;
+
+ for (l = job->files; l != NULL; l = l->next) {
+ file = l->data;
+
+ if (job->try_trash &&
+ job->delete_if_all_already_in_trash &&
+ g_file_has_uri_scheme (file, "trash")) {
+ in_trash_files = g_list_prepend (in_trash_files, file);
+ } else if (can_delete_without_confirm (file)) {
+ no_confirm_files = g_list_prepend (no_confirm_files, file);
+ } else if (job->try_trash &&
+ can_trash_file (file, NULL)) {
+ trashable_files = g_list_prepend (trashable_files, file);
+ } else {
+ untrashable_files = g_list_prepend (untrashable_files, file);
+ }
+ }
+
+ if (in_trash_files != NULL && trashable_files == NULL && untrashable_files == NULL) {
+ if (confirm_delete_from_trash (io_job, job->parent_window, in_trash_files)) {
+ delete_files (in_trash_files, NULL, job->parent_window);
+ }
+ } else {
+ if (no_confirm_files != NULL) {
+ delete_files (no_confirm_files, NULL, job->parent_window);
+ }
+ if (trashable_files != NULL) {
+ trash_files (trashable_files, NULL, job->parent_window);
+ }
+ if (untrashable_files != NULL) {
+ if (job->try_trash) {
+ confirmed = confirm_deletion (io_job, job->parent_window,
+ untrashable_files, trashable_files == NULL);
+ } else {
+ confirmed = confirm_delete_directly (io_job, job->parent_window, untrashable_files);
+ }
+
+ if (confirmed) {
+ delete_files (untrashable_files, NULL, job->parent_window);
+ }
+ }
+ }
+
+ g_list_free (in_trash_files);
+ g_list_free (trashable_files);
+ g_list_free (untrashable_files);
+ g_list_free (no_confirm_files);
+
+ g_io_job_send_to_mainloop (io_job,
+ delete_job_done,
+ job,
+ NULL,
+ FALSE);
+
+}
+
+static void
+delete_job_done (gpointer user_data)
+{
+ DeleteJob *job = user_data;
+ GHashTable *debuting_uris;
+
+ eel_g_object_list_free (job->files);
+ if (job->parent_window) {
+ g_object_unref (job->parent_window);
+ }
+
+ if (job->done_callback) {
+ debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+ job->done_callback (debuting_uris, job->done_callback_data);
+ g_hash_table_unref (debuting_uris);
+ }
+ g_free (job);
- gnome_vfs_uri_list_free (uri_list);
+ nautilus_file_changes_consume_changes (TRUE);
}
static void
+trash_or_delete_internal (GList *files,
+ GtkWindow *parent_window,
+ gboolean try_trash,
+ NautilusDeleteCallback done_callback,
+ gpointer done_callback_data)
+{
+ DeleteJob *job;
+
+ setup_autos ();
+
+ /* TODO: special case desktop icon link files ... */
+
+ /* TODO: Progress dialog, cancellation */
+
+ job = g_new0 (DeleteJob, 1);
+ job->files = eel_g_object_list_copy (files);
+ job->parent_window = g_object_ref (parent_window);
+ job->try_trash = try_trash;
+ job->done_callback = done_callback;
+ job->done_callback_data = done_callback_data;
+
+ g_schedule_io_job (delete_job,
+ job,
+ NULL,
+ 0,
+ NULL);
+}
+
+void
+nautilus_file_operations_trash_or_delete (GList *files,
+ GtkWindow *parent_window,
+ NautilusDeleteCallback done_callback,
+ gpointer done_callback_data)
+{
+ trash_or_delete_internal (files, parent_window,
+ TRUE,
+ done_callback, done_callback_data);
+}
+
+void
+nautilus_file_operations_delete (GList *files,
+ GtkWindow *parent_window,
+ NautilusDeleteCallback done_callback,
+ gpointer done_callback_data)
+{
+ trash_or_delete_internal (files, parent_window,
+ FALSE,
+ done_callback, done_callback_data);
+}
+
+#ifdef GIO_CONVERSION_DONE
+
+static void
do_empty_trash (GtkWidget *parent_view)
{
TransferInfo *transfer_info;
@@ -2838,7 +3753,8 @@ do_empty_trash (GtkWidget *parent_view)
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"empty trash");
- trash_dir_list = nautilus_trash_monitor_get_trash_directories ();
+ /* TODO-gio: Implement */
+ trash_dir_list = NULL;
if (trash_dir_list != NULL) {
/* set up the move parameters */
transfer_info = transfer_info_new (parent_view);
@@ -2979,13 +3895,13 @@ typedef struct {
gpointer volume;
GnomeVFSVolumeOpCallback callback;
gpointer user_data;
-} NautilusUnmountCallback;
+} NautilusUnmountDataCallback;
static void
delete_callback (GHashTable *debuting_uris,
gpointer data)
{
- NautilusUnmountCallback *unmount_info;
+ NautilusUnmountDataCallback *unmount_info;
unmount_info = data;
if (GNOME_IS_VFS_VOLUME (unmount_info->volume)) {
@@ -3044,12 +3960,46 @@ prompt_empty_trash (GtkWidget *parent_view)
return result;
}
-void
-nautilus_file_operations_unmount_volume (GtkWidget *parent_view,
- GnomeVFSVolume *volume,
- GnomeVFSVolumeOpCallback callback,
- gpointer user_data)
+#endif /* GIO_CONVERSION_DONE */
+
+
+typedef struct {
+ NautilusUnmountCallback callback;
+ gpointer user_data;
+} UnmountData;
+
+static void
+unmount_volume_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ UnmountData *data = user_data;
+ GError *error;
+
+ error = NULL;
+ g_volume_unmount_finish (G_VOLUME (source_object),
+ res, &error);
+ if (data->callback) {
+ data->callback (error, data->user_data);
+ }
+
+ if (error) {
+ g_error_free (error);
+ }
+
+ g_free (data);
+}
+
+
+void
+nautilus_file_operations_unmount_volume (GtkWindow *parent_window,
+ GVolume *volume,
+ NautilusUnmountCallback callback,
+ gpointer user_data)
+{
+ /* TODO-gio: Empty trash before unmount */
+
+#ifdef GIO_CONVERSION_DONE
gchar *trash_uri_str;
gboolean trash_is_empty;
@@ -3059,7 +4009,7 @@ nautilus_file_operations_unmount_volume (GtkWidget *parent_view,
trash_uri_str = get_trash_uri_for_volume (volume);
if (trash_uri_str) {
NautilusDirectory *trash_dir;
- trash_dir = nautilus_directory_get (trash_uri_str);
+ trash_dir = nautilus_directory_get_by_uri (trash_uri_str);
/* Check if the trash on this volume is empty,
* If the trash directory on this volume exists it's monitored
@@ -3075,18 +4025,20 @@ nautilus_file_operations_unmount_volume (GtkWidget *parent_view,
case GTK_RESPONSE_ACCEPT:
{
GList *trash_dir_list;
- NautilusUnmountCallback *unmount_cb;
+ NautilusUnmountDataCallback *unmount_cb;
+ GtkWidget *toplevel;
trash_dir_list = NULL;
- unmount_cb = g_new (NautilusUnmountCallback, 1);
+ unmount_cb = g_new (NautilusUnmountDataCallback, 1);
unmount_cb->volume = gnome_vfs_volume_ref (volume);
unmount_cb->callback = callback;
unmount_cb->user_data = user_data;
- trash_dir_list = g_list_append (trash_dir_list, trash_uri_str);
- nautilus_file_operations_delete (trash_dir_list, parent_view,
+ trash_dir_list = g_list_append (trash_dir_list, g_file_new_for_uri (trash_uri_str));
+ toplevel = gtk_widget_get_toplevel (parent_view);
+ nautilus_file_operations_delete (trash_dir_list, GTK_WINDOW (toplevel),
(NautilusDeleteCallback) delete_callback,
unmount_cb);
- g_list_free (trash_dir_list);
+ eel_g_object_list_free (trash_dir_list);
/* volume is unmounted in the callback */
break;
}
@@ -3098,78 +4050,19 @@ nautilus_file_operations_unmount_volume (GtkWidget *parent_view,
}
}
g_free (trash_uri_str);
+#endif
+ UnmountData *data;
+
+ data = g_new0 (UnmountData, 1);
+ data->callback = callback;
+ data->user_data = user_data;
+ g_volume_unmount (volume,
+ NULL,
+ unmount_volume_callback,
+ data);
}
-void
-nautilus_file_operations_unmount_drive (GtkWidget *parent_view,
- GnomeVFSDrive *drive,
- GnomeVFSVolumeOpCallback callback,
- gpointer user_data)
-{
- GList *volumes;
- GList *it;
- GList *trash_dir_list;
- GnomeVFSVolume *volume;
- gchar *trash_uri_str;
- gboolean trash_is_empty;
-
- g_return_if_fail (parent_view != NULL);
-
- trash_dir_list = NULL;
- trash_is_empty = TRUE;
- volumes = gnome_vfs_drive_get_mounted_volumes (drive);
- for (it = volumes; it != NULL; it = g_list_next (it)) {
- volume = it->data;
- trash_uri_str = get_trash_uri_for_volume (volume);
- if (trash_uri_str) {
- trash_dir_list = g_list_prepend (trash_dir_list, trash_uri_str);
- /* Check if any of the volumes have trash on them.
- * If the trash directories on the volumes exist they are monitored
- * by the trash monitor so this should give accurate results. */
- if (trash_is_empty) {
- NautilusDirectory *trash_dir;
- trash_dir = nautilus_directory_get (trash_uri_str);
- trash_is_empty = ! nautilus_directory_is_not_empty (trash_dir);
- }
- }
- gnome_vfs_volume_unref (volume);
- }
-
- if (trash_is_empty) {
- /* no trash so unmount as usual */
- gnome_vfs_drive_unmount (drive, callback, user_data);
- } else {
- switch (prompt_empty_trash (parent_view)) {
- case GTK_RESPONSE_ACCEPT:
- {
- NautilusUnmountCallback *unmount_cb;
- gchar *temp;
-
- unmount_cb = g_new (NautilusUnmountCallback, 1);
- unmount_cb->volume = gnome_vfs_drive_ref (drive);
- unmount_cb->callback = callback;
- unmount_cb->user_data = user_data;
- trash_dir_list = g_list_reverse (trash_dir_list);
- nautilus_file_operations_delete (trash_dir_list, parent_view,
- (NautilusDeleteCallback) delete_callback,
- unmount_cb);
-
- for (it = trash_dir_list; it != NULL; it = g_list_next (it)) {
- temp = it->data;
- g_free (temp);
- }
- g_list_free (trash_dir_list);
- /* volume is unmounted in the callback */
- break;
- }
- case GTK_RESPONSE_REJECT:
- gnome_vfs_drive_unmount (drive, callback, user_data);
- break;
- default:
- break;
- }
- }
-}
+#ifdef GIO_CONVERSION_DONE
struct RecursivePermissionsInfo {
GnomeVFSAsyncHandle *handle;
@@ -3177,22 +4070,22 @@ struct RecursivePermissionsInfo {
GnomeVFSURI *current_file;
GList *files;
GList *directories;
- GnomeVFSFilePermissions file_permissions;
- GnomeVFSFilePermissions file_mask;
- GnomeVFSFilePermissions dir_permissions;
- GnomeVFSFilePermissions dir_mask;
+ guint32 file_permissions;
+ guint32 file_mask;
+ guint32 dir_permissions;
+ guint32 dir_mask;
NautilusSetPermissionsCallback callback;
gpointer callback_data;
};
struct FileInfo {
char *name;
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
};
struct DirInfo {
GnomeVFSURI *uri;
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
};
static void set_permissions_run (struct RecursivePermissionsInfo *info);
@@ -3372,10 +4265,10 @@ set_permissions_run (struct RecursivePermissionsInfo *info)
void
nautilus_file_set_permissions_recursive (const char *directory,
- GnomeVFSFilePermissions file_permissions,
- GnomeVFSFilePermissions file_mask,
- GnomeVFSFilePermissions dir_permissions,
- GnomeVFSFilePermissions dir_mask,
+ guint32 file_permissions,
+ guint32 file_mask,
+ guint32 dir_permissions,
+ guint32 dir_mask,
NautilusSetPermissionsCallback callback,
gpointer callback_data)
{
@@ -3403,6 +4296,2044 @@ nautilus_file_set_permissions_recursive (const char *directo
set_permissions_load_dir (NULL, GNOME_VFS_OK, NULL, info);
}
+#endif /* GIO_CONVERSION_DONE */
+
+#define op_job_new(__type, parent_window) ((__type *)(init_common (sizeof(__type), parent_window)))
+
+static gpointer
+init_common (gsize job_size,
+ GtkWindow *parent_window)
+{
+ CommonJob *common;
+
+ common = g_malloc0 (job_size);
+
+ common->parent_window = g_object_ref (parent_window);
+ common->progress = nautilus_progress_info_new ();
+ common->cancellable = nautilus_progress_info_get_cancellable (common->progress);
+ common->time = g_timer_new ();
+
+ return common;
+}
+
+static void
+finalize_common (CommonJob *common)
+{
+ nautilus_progress_info_finish (common->progress);
+
+ g_timer_destroy (common->time);
+
+ if (common->parent_window) {
+ g_object_unref (common->parent_window);
+ }
+ if (common->skip_files) {
+ g_hash_table_destroy (common->skip_files);
+ }
+ if (common->skip_readdir_error) {
+ g_hash_table_destroy (common->skip_readdir_error);
+ }
+ g_object_unref (common->progress);
+ g_object_unref (common->cancellable);
+ g_free (common);
+}
+
+static void
+skip_file (CommonJob *common,
+ GFile *file)
+{
+ if (common->skip_files == NULL) {
+ common->skip_files =
+ g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+ }
+
+ g_hash_table_insert (common->skip_files, g_object_ref (file), file);
+}
+
+static void
+skip_readdir_error (CommonJob *common,
+ GFile *dir)
+{
+ if (common->skip_readdir_error == NULL) {
+ common->skip_readdir_error =
+ g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+ }
+
+ g_hash_table_insert (common->skip_readdir_error, g_object_ref (dir), dir);
+}
+
+static gboolean
+should_skip_file (CommonJob *common,
+ GFile *file)
+{
+ if (common->skip_files != NULL) {
+ return g_hash_table_lookup (common->skip_files, file) != NULL;
+ }
+ return FALSE;
+}
+
+static gboolean
+should_skip_readdir_error (CommonJob *common,
+ GFile *dir)
+{
+ if (common->skip_readdir_error != NULL) {
+ return g_hash_table_lookup (common->skip_readdir_error, dir) != NULL;
+ }
+ return FALSE;
+}
+
+typedef enum {
+ OP_KIND_COPY = 0
+} OpKind;
+
+typedef struct {
+ int num_files;
+ goffset num_bytes;
+ int num_files_since_progress;
+ OpKind op;
+} SourceInfo;
+
+typedef struct {
+ int num_files;
+ goffset num_bytes;
+ OpKind op;
+ guint64 last_report_time;
+} TransferInfo;
+
+static void
+report_count_progress (CommonJob *job,
+ SourceInfo *source_info)
+{
+ char *s;
+
+ if (source_info->op == OP_KIND_COPY) {
+ s = f (_("Preparing to copy %d files (%S)"),
+ source_info->num_files, source_info->num_bytes);
+ nautilus_progress_info_take_details (job->progress, s);
+ }
+
+ nautilus_progress_info_pulse_progress (job->progress);
+}
+
+static void
+count_file (GFileInfo *info,
+ CommonJob *job,
+ SourceInfo *source_info)
+{
+ source_info->num_files += 1;
+ source_info->num_bytes += g_file_info_get_size (info);
+
+ if (source_info->num_files_since_progress++ > 100) {
+ report_count_progress (job, source_info);
+ source_info->num_files_since_progress = 0;
+ }
+
+}
+static void
+scan_dir (GFile *dir,
+ SourceInfo *source_info,
+ CommonJob *job,
+ GQueue *dirs)
+{
+ GFileInfo *info;
+ GError *error;
+ GFile *subdir;
+ GFileEnumerator *enumerator;
+ char *primary, *secondary, *details;
+ int response;
+ SourceInfo saved_info;
+
+ saved_info = *source_info;
+
+ retry:
+ error = NULL;
+ enumerator = g_file_enumerate_children (dir,
+ G_FILE_ATTRIBUTE_STD_NAME","
+ G_FILE_ATTRIBUTE_STD_TYPE","
+ G_FILE_ATTRIBUTE_STD_SIZE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ job->cancellable,
+ &error);
+ if (enumerator) {
+ error = NULL;
+ while ((info = g_file_enumerator_next_file (enumerator, job->cancellable, &error)) != NULL) {
+ count_file (info, job, source_info);
+
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ subdir = g_file_get_child (dir,
+ g_file_info_get_name (info));
+
+ /* Push to head, since we want depth-first */
+ g_queue_push_head (dirs, subdir);
+ }
+
+ g_object_unref (info);
+ }
+ g_file_enumerator_close (enumerator, job->cancellable, NULL);
+
+ if (error) {
+ primary = f (_("Error while copying."));
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("Files in the folder \"%B\" cannot be copied because you do "
+ "not have permissions to read them."), dir);
+ } else {
+ secondary = f (_("There was an error getting information about the files in the folder \"%B\"."), dir);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, RETRY, SKIP,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ *source_info = saved_info;
+ goto retry;
+ } else if (response == 2) {
+ skip_readdir_error (job, dir);
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ } else if (job->skip_all_error) {
+ skip_file (job, dir);
+ } else {
+ primary = f (_("Error while copying."));
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("The folder \"%B\" cannot be copied because you do not have "
+ "permissions to read it."), dir);
+ } else {
+ secondary = f (_("There was an error reading the folder \"%B\"."), dir);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1 || response == 2) {
+ if (response == 1) {
+ job->skip_all_error = TRUE;
+ }
+ skip_file (job, dir);
+ } else if (response == 3) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+}
+
+static void
+scan_file (GFile *file,
+ SourceInfo *source_info,
+ CommonJob *job)
+{
+ GFileInfo *info;
+ GError *error;
+ GQueue *dirs;
+ GFile *dir;
+ char *primary;
+ char *secondary;
+ char *details;
+ int response;
+
+ dirs = g_queue_new ();
+
+ retry:
+ error = NULL;
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STD_TYPE","
+ G_FILE_ATTRIBUTE_STD_SIZE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ job->cancellable,
+ &error);
+
+ if (info) {
+ count_file (info, job, source_info);
+
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ g_queue_push_head (dirs, g_object_ref (file));
+ }
+
+ g_object_unref (info);
+ } else if (job->skip_all_error) {
+ skip_file (job, file);
+ } else {
+ primary = f (_("Error while copying."));
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("The file \"%B\" cannot be copied because you do not have "
+ "permissions to read it."), file);
+ } else {
+ secondary = f (_("There was an error getting information about \"%B\"."), file);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP, RETRY,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1 || response == 2) {
+ if (response == 1) {
+ job->skip_all_error = TRUE;
+ }
+ skip_file (job, file);
+ } else if (response == 3) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ while (!job->aborted &&
+ (dir = g_queue_pop_head (dirs)) != NULL) {
+ scan_dir (dir, source_info, job, dirs);
+ g_object_unref (dir);
+ }
+
+ /* Free all from queue if we exited early */
+ g_queue_foreach (dirs, (GFunc)g_object_unref, NULL);
+ g_queue_free (dirs);
+}
+
+static void
+scan_sources (GList *files,
+ SourceInfo *source_info,
+ CommonJob *job)
+{
+ GList *l;
+ GFile *file;
+
+ if (source_info->op == OP_KIND_COPY) {
+ nautilus_progress_info_set_status (job->progress,
+ _("Preparing for copy"));
+ }
+
+ for (l = files; l != NULL && !job->aborted; l = l->next) {
+ file = l->data;
+
+ scan_file (file,
+ source_info,
+ job);
+ }
+
+ /* Make sure we report the final count */
+ report_count_progress (job, source_info);
+}
+
+static void
+verify_destination (CommonJob *job,
+ GFile *dest,
+ char **dest_fs_id,
+ goffset required_size)
+{
+ GFileInfo *info, *fsinfo;
+ GError *error;
+ guint64 free_size;
+ char *primary, *secondary, *details;
+ int response;
+ GFileType file_type;
+
+ *dest_fs_id = NULL;
+
+ retry:
+
+ error = NULL;
+ info = g_file_query_info (dest,
+ G_FILE_ATTRIBUTE_STD_TYPE","
+ G_FILE_ATTRIBUTE_ID_FS,
+ 0,
+ job->cancellable,
+ &error);
+
+ if (info == NULL) {
+ primary = f (_("Error while copying to \"%B\"."), dest);
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("You don't have permissions to access the destination folder."));
+ } else {
+ secondary = f (_("There was an error getting information about the destination."));
+ details = error->message;
+ }
+
+ response = run_error (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, RETRY,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+
+ return;
+ }
+
+ file_type = g_file_info_get_file_type (info);
+
+ *dest_fs_id =
+ g_strdup (g_file_info_get_attribute_string (info,
+ G_FILE_ATTRIBUTE_ID_FS));
+
+ g_object_unref (info);
+
+ if (file_type != G_FILE_TYPE_DIRECTORY) {
+ primary = f (_("Error while copying to \"%B\"."), dest);
+ secondary = f (_("The destination is not a folder."));
+
+ response = run_error (job,
+ primary,
+ secondary,
+ NULL,
+ GTK_STOCK_CANCEL,
+ NULL);
+
+ g_error_free (error);
+
+ job->aborted = TRUE;
+ return;
+ }
+
+ fsinfo = g_file_query_filesystem_info (dest,
+ G_FILE_ATTRIBUTE_FS_FREE","
+ G_FILE_ATTRIBUTE_FS_READONLY,
+ job->cancellable,
+ NULL);
+ if (fsinfo == NULL) {
+ /* All sorts of things can go wrong getting the fs info (like not supported)
+ * only check these things if the fs returns them
+ */
+ return;
+ }
+
+ if (required_size > 0 &&
+ g_file_info_has_attribute (fsinfo, G_FILE_ATTRIBUTE_FS_FREE)) {
+ free_size = g_file_info_get_attribute_uint64 (fsinfo,
+ G_FILE_ATTRIBUTE_FS_FREE);
+
+ if (free_size < required_size) {
+ primary = f (_("Error while copying to \"%B\"."), dest);
+ secondary = _("There is not enough space on the destination. Try to remove files to make space.");
+
+ details = f (_("There is %S availible, but %S is required."), free_size, required_size);
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, RETRY,
+ NULL);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+ }
+
+ if (!job->aborted &&
+ g_file_info_get_attribute_boolean (fsinfo,
+ G_FILE_ATTRIBUTE_FS_READONLY)) {
+ primary = f (_("Error while copying to \"%B\"."), dest);
+ secondary = f (_("The destination is read-only."));
+
+ response = run_error (job,
+ primary,
+ secondary,
+ NULL,
+ GTK_STOCK_CANCEL,
+ NULL);
+
+ g_error_free (error);
+
+ job->aborted = TRUE;
+ }
+
+ g_object_unref (fsinfo);
+}
+
+static void
+report_copy_progress (CopyMoveJob *copy_job,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info)
+{
+ int files_left;
+ goffset total_size;
+ double elapsed, transfer_rate;
+ int remaining_time;
+ guint64 now;
+ CommonJob *job;
+ gboolean is_move;
+
+ job = (CommonJob *)copy_job;
+
+ is_move = copy_job->is_move;
+
+ now = g_thread_gettime ();
+
+ if (transfer_info->last_report_time != 0 &&
+ ABS (transfer_info->last_report_time - now) < 100 * NSEC_PER_MSEC) {
+ return;
+ }
+ transfer_info->last_report_time = now;
+
+ files_left = source_info->num_files - transfer_info->num_files;
+
+ /* Races and whatnot could cause this to be negative... */
+ if (files_left < 0) {
+ files_left = 1;
+ }
+
+ if (source_info->num_files == 1) {
+ nautilus_progress_info_take_status (job->progress,
+ f (is_move ?
+ _("Moving \"%B\" to \"%B\""):
+ _("Copying \"%B\" to \"%B\""),
+ (GFile *)copy_job->files->data,
+ copy_job->destination));
+ } else if (copy_job->files != NULL &&
+ copy_job->files->next == NULL) {
+ nautilus_progress_info_take_status (job->progress,
+ f (is_move?
+ _("Moving %d files (in \"%B\") to \"%B\""):
+ _("Copying %d files (in \"%B\") to \"%B\""),
+ files_left,
+ (GFile *)copy_job->files->data,
+ copy_job->destination));
+ } else {
+ nautilus_progress_info_take_status (job->progress,
+ f (is_move?
+ _("Moving %d files to \"%B\""):
+ _("Copying %d files to \"%B\""),
+ files_left, copy_job->destination));
+ }
+
+ total_size = MAX (source_info->num_bytes, transfer_info->num_bytes);
+
+ elapsed = g_timer_elapsed (job->time, NULL);
+ if (elapsed < SECONDS_NEEDED_FOR_RELIABLE_TRANSFER_RATE) {
+ char *s;
+ s = f (_("%S of %S"), transfer_info->num_bytes, total_size);
+ nautilus_progress_info_take_details (job->progress, s);
+ } else {
+ char *s;
+ transfer_rate = transfer_info->num_bytes / elapsed;
+ remaining_time = (total_size - transfer_info->num_bytes) / transfer_rate;
+
+ s = f (_("%S of %S \xE2\x80\x94 %T left (%S/sec)"),
+ transfer_info->num_bytes, total_size,
+ remaining_time,
+ (goffset)transfer_rate);
+ nautilus_progress_info_take_details (job->progress, s);
+ }
+
+ nautilus_progress_info_set_progress (job->progress, (double)transfer_info->num_bytes / total_size);
+}
+
+static GFile *
+get_target_file (GFile *src,
+ GFile *dest_dir,
+ gboolean same_fs)
+{
+ char *basename;
+ GFile *dest;
+ GFileInfo *info;
+ const char *copyname;
+
+ dest = NULL;
+ if (!same_fs) {
+ info = g_file_query_info (src,
+ G_FILE_ATTRIBUTE_STD_COPY_NAME,
+ 0, NULL, NULL);
+
+ if (info) {
+ copyname = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STD_COPY_NAME);
+
+ if (copyname) {
+ dest = g_file_get_child_for_display_name (dest_dir, copyname, NULL);
+ }
+
+ g_object_unref (info);
+ }
+ }
+
+ if (dest == NULL) {
+ basename = g_file_get_basename (src);
+ dest = g_file_get_child (dest_dir, basename);
+ g_free (basename);
+ }
+
+ return dest;
+}
+
+static gboolean
+has_fs_id (GFile *file, const char *fs_id)
+{
+ const char *id;
+ GFileInfo *info;
+ gboolean res;
+
+ res = FALSE;
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_ID_FS,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, NULL);
+
+ if (info) {
+ id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FS);
+
+ if (id && strcmp (id, fs_id) == 0) {
+ res = TRUE;
+ }
+
+ g_object_unref (info);
+ }
+
+ return res;
+}
+
+static gboolean
+is_dir (GFile *file)
+{
+ GFileInfo *info;
+ gboolean res;
+
+ res = FALSE;
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STD_TYPE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ NULL, NULL);
+ if (info) {
+ res = g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY;
+ g_object_unref (info);
+ }
+
+ return res;
+}
+
+static void copy_move_file (CopyMoveJob *job,
+ GFile *src,
+ GFile *dest_dir,
+ gboolean same_fs,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info,
+ GHashTable *debuting_files,
+ GdkPoint *point,
+ gboolean overwrite,
+ gboolean *skipped_file);
+
+static gboolean
+create_dest_dir (CommonJob *job,
+ GFile *src,
+ GFile *dest)
+{
+ GError *error;
+ char *primary, *secondary, *details;
+ int response;
+
+ retry:
+ /* First create the directory, then copy stuff to it before
+ copying the attributes, because we need to be sure we can write to it */
+
+ error = NULL;
+ if (!g_file_make_directory (dest, job->cancellable, &error)) {
+ primary = f (_("Error while copying."));
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("The folder \"%B\" cannot be copied because you do not have "
+ "permissions to create it in the destination."), src);
+ } else {
+ secondary = f (_("There was an error creating the folder \"%B\"."), src);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP, RETRY,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ /* Skip: Do Nothing */
+ } else if (response == 2) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ return FALSE;
+ }
+ nautilus_file_changes_queue_file_added (dest);
+ return TRUE;
+}
+
+static void
+copy_move_directory (CopyMoveJob *copy_job,
+ GFile *src,
+ GFile *dest,
+ gboolean same_fs,
+ gboolean create_dest,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info,
+ GHashTable *debuting_files,
+ gboolean *skipped_file)
+{
+ GFileInfo *info;
+ GError *error;
+ GFile *src_file;
+ GFileEnumerator *enumerator;
+ char *primary, *secondary, *details;
+ int response;
+ gboolean skip_error;
+ gboolean local_skipped_file;
+ CommonJob *job;
+
+ job = (CommonJob *)copy_job;
+
+ if (create_dest) {
+ if (!create_dest_dir (job, src, dest)) {
+ *skipped_file = TRUE;
+ return;
+ }
+ if (debuting_files) {
+ g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (TRUE));
+ }
+
+ }
+
+ local_skipped_file = FALSE;
+
+ skip_error = should_skip_readdir_error (job, src);
+ retry:
+ error = NULL;
+ enumerator = g_file_enumerate_children (src,
+ G_FILE_ATTRIBUTE_STD_NAME,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ job->cancellable,
+ &error);
+ if (enumerator) {
+ error = NULL;
+
+ while (!job->aborted &&
+ (info = g_file_enumerator_next_file (enumerator, job->cancellable, skip_error?NULL:&error)) != NULL) {
+ src_file = g_file_get_child (src,
+ g_file_info_get_name (info));
+ copy_move_file (copy_job, src_file, dest, same_fs, source_info, transfer_info, NULL, NULL, FALSE, &local_skipped_file);
+ g_object_unref (info);
+ }
+ g_file_enumerator_close (enumerator, job->cancellable, NULL);
+
+ if (error) {
+ if (copy_job->is_move) {
+ primary = f (_("Error while moving."));
+ } else {
+ primary = f (_("Error while copying."));
+ }
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("Files in the folder \"%B\" cannot be copied because you do "
+ "not have permissions to read them."), src);
+ } else {
+ secondary = f (_("There was an error getting information about the files in the folder \"%B\"."), src);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, _("_Skip files"),
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ /* Skip: Do Nothing */
+ local_skipped_file = TRUE;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ /* Count the copied directory as a file */
+ transfer_info->num_files ++;
+ report_copy_progress (copy_job, source_info, transfer_info);
+
+ if (debuting_files) {
+ g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (create_dest));
+ }
+ } else {
+ if (copy_job->is_move) {
+ primary = f (_("Error while moving."));
+ } else {
+ primary = f (_("Error while copying."));
+ }
+ details = NULL;
+
+ if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+ secondary = f (_("The folder \"%B\" cannot be copied because you do not have "
+ "permissions to read it."), src);
+ } else {
+ secondary = f (_("There was an error reading the folder \"%B\"."), src);
+ details = error->message;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP, RETRY,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) {
+ /* Skip: Do Nothing */
+ local_skipped_file = TRUE;
+ } else if (response == 2) {
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ if (create_dest) {
+ /* Ignore errors here. Failure to copy metadata is not a hard error */
+ g_file_copy_attributes (src, dest,
+ G_FILE_COPY_NOFOLLOW_SYMLINKS,
+ job->cancellable, NULL);
+ }
+
+ if (!job->aborted && copy_job->is_move &&
+ /* Don't delete source if there was a skipped file */
+ !local_skipped_file) {
+ if (!g_file_delete (src, job->cancellable, &error)) {
+ if (job->skip_all_error) {
+ goto skip;
+ }
+ primary = f (_("Error while moving \"%B\"."), src);
+ secondary = f (_("Couldn't remove the source folder."));
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ local_skipped_file = TRUE;
+ } else if (response == 2) { /* skip */
+ local_skipped_file = TRUE;
+ } else {
+ g_assert_not_reached ();
+ }
+
+ skip:
+ g_error_free (error);
+ }
+ }
+
+ if (local_skipped_file) {
+ *skipped_file = TRUE;
+ }
+}
+
+static gboolean
+remove_target_recursively (CommonJob *job,
+ GFile *src,
+ GFile *toplevel_dest,
+ GFile *file)
+{
+ GFileEnumerator *enumerator;
+ GError *error;
+ GFile *child;
+ gboolean stop;
+ char *primary, *secondary, *details;
+ int response;
+ GFileInfo *info;
+
+ stop = FALSE;
+
+ error = NULL;
+ enumerator = g_file_enumerate_children (file,
+ G_FILE_ATTRIBUTE_STD_NAME,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
+ job->cancellable,
+ &error);
+ if (enumerator) {
+ error = NULL;
+
+ while (!job->aborted &&
+ (info = g_file_enumerator_next_file (enumerator, job->cancellable, &error)) != NULL) {
+ child = g_file_get_child (file,
+ g_file_info_get_name (info));
+ if (!remove_target_recursively (job, src, toplevel_dest, child)) {
+ stop = TRUE;
+ break;
+ }
+ g_object_unref (info);
+ }
+ g_file_enumerator_close (enumerator, job->cancellable, NULL);
+
+ } else if (IS_IO_ERROR (error, NOT_DIRECTORY)) {
+ /* Not a dir, continue */
+ g_error_free (error);
+
+ } else {
+ if (job->skip_all_error) {
+ goto skip1;
+ }
+
+ primary = f (_("Error while copying \"%B\"."), src);
+ secondary = f (_("Couldn't remove files from the already folder %F."), file);
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ } else if (response == 2) { /* skip */
+ /* do nothing */
+ } else {
+ g_assert_not_reached ();
+ }
+ skip1:
+ g_error_free (error);
+
+ stop = TRUE;
+ }
+
+ if (stop) {
+ return FALSE;
+ }
+
+ error = NULL;
+
+ if (!g_file_delete (file, job->cancellable, &error)) {
+ if (job->skip_all_error) {
+ goto skip2;
+ }
+ primary = f (_("Error while copying \"%B\"."), src);
+ secondary = f (_("Couldn't remove the already existing file %F."), file);
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ } else if (response == 2) { /* skip */
+ /* do nothing */
+ } else {
+ g_assert_not_reached ();
+ }
+
+ skip2:
+ g_error_free (error);
+
+ return FALSE;
+ }
+ nautilus_file_changes_queue_file_removed (file);
+ nautilus_file_changes_queue_schedule_metadata_remove (file);
+
+ return TRUE;
+
+}
+
+typedef struct {
+ CopyMoveJob *job;
+ goffset last_size;
+ SourceInfo *source_info;
+ TransferInfo *transfer_info;
+} ProgressData;
+
+static void
+copy_file_progress_callback (goffset current_num_bytes,
+ goffset total_num_bytes,
+ gpointer user_data)
+{
+ ProgressData *pdata;
+ goffset new_size;
+
+ pdata = user_data;
+
+ new_size = current_num_bytes - pdata->last_size;
+
+ if (new_size > 0) {
+ pdata->transfer_info->num_bytes += new_size;
+ pdata->last_size = current_num_bytes;
+ report_copy_progress (pdata->job,
+ pdata->source_info,
+ pdata->transfer_info);
+ }
+}
+
+/* Debuting files is non-NULL only for toplevel items */
+static void
+copy_move_file (CopyMoveJob *copy_job,
+ GFile *src,
+ GFile *dest_dir,
+ gboolean same_fs,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info,
+ GHashTable *debuting_files,
+ GdkPoint *position,
+ gboolean overwrite,
+ gboolean *skipped_file)
+{
+ GFile *dest;
+ GError *error;
+ GFileCopyFlags flags;
+ char *primary, *secondary, *details;
+ int response;
+ ProgressData pdata;
+ gboolean would_recurse;
+ CommonJob *job;
+ gboolean res;
+
+ job = (CommonJob *)copy_job;
+
+ if (should_skip_file (job, src)) {
+ *skipped_file = TRUE;
+ return;
+ }
+
+ dest = get_target_file (src, dest_dir, same_fs);
+
+ retry:
+
+ error = NULL;
+ flags = G_FILE_COPY_NOFOLLOW_SYMLINKS;
+ if (overwrite) {
+ flags |= G_FILE_COPY_OVERWRITE;
+ }
+ pdata.job = copy_job;
+ pdata.last_size = 0;
+ pdata.source_info = source_info;
+ pdata.transfer_info = transfer_info;
+
+ if (copy_job->is_move) {
+ res = g_file_move (src, dest,
+ flags,
+ job->cancellable,
+ copy_file_progress_callback,
+ &pdata,
+ &error);
+ } else {
+ res = g_file_copy (src, dest,
+ flags,
+ job->cancellable,
+ copy_file_progress_callback,
+ &pdata,
+ &error);
+ }
+
+ if (res) {
+ transfer_info->num_files ++;
+ report_copy_progress (copy_job, source_info, transfer_info);
+
+ if (debuting_files) {
+ nautilus_file_changes_queue_schedule_metadata_copy (src, dest);
+ if (position) {
+ nautilus_file_changes_queue_schedule_position_set (dest, *position, copy_job->screen_num);
+ } else {
+ nautilus_file_changes_queue_schedule_position_remove (dest);
+ }
+
+ g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (TRUE));
+ }
+ nautilus_file_changes_queue_file_added (dest);
+ g_object_unref (dest);
+ return;
+ }
+
+ /* Conflict */
+ if (!overwrite &&
+ IS_IO_ERROR (error, EXISTS)) {
+ gboolean is_merge;
+
+ is_merge = FALSE;
+ if (is_dir (dest)) {
+ if (is_dir (src)) {
+ is_merge = TRUE;
+ primary = f (_("A folder named \"%B\" already exists. Do you want to merge the source folder?"),
+ dest);
+ secondary = f (_("The source folder already exists in \"%B\". "
+ "Merging will ask for confirmation before replacing any files in the folder that conflict with the files being copied."),
+ dest_dir);
+
+ } else {
+ primary = f (_("A folder named \"%B\" already exists. Do you want to replace it?"),
+ dest);
+ secondary = f (_("The folder already exists in \"%F\". "
+ "Replacing it will remove all files in the folder."),
+ dest_dir);
+ }
+ } else {
+ primary = f (_("A file named \"%B\" already exists. Do you want to replace it?"),
+ dest);
+ secondary = f (_("The file already exists in \"%F\". "
+ "Replacing it will overwrite its content."),
+ dest_dir);
+ }
+
+ if ((is_merge && job->merge_all) ||
+ (!is_merge && job->replace_all)) {
+ g_free (primary);
+ g_free (secondary);
+ g_error_free (error);
+
+ overwrite = TRUE;
+ goto retry;
+ }
+
+ if (job->skip_all_conflict) {
+ g_free (primary);
+ g_free (secondary);
+ g_error_free (error);
+
+ goto out;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ NULL,
+ GTK_STOCK_CANCEL,
+ SKIP_ALL,
+ is_merge?MERGE_ALL:REPLACE_ALL,
+ SKIP,
+ is_merge?MERGE:REPLACE,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1 || response == 3) { /* skip all / skip */
+ if (response == 1) {
+ job->skip_all_conflict = TRUE;
+ }
+ } else if (response == 2 || response == 4) { /* merge/replace all / merge/replace*/
+ if (response == 2) {
+ if (is_merge) {
+ job->merge_all = TRUE;
+ } else {
+ job->replace_all = TRUE;
+ }
+ }
+ overwrite = TRUE;
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ else if (overwrite &&
+ IS_IO_ERROR (error, IS_DIRECTORY)) {
+
+ g_error_free (error);
+
+ if (remove_target_recursively (job, src, dest, dest)) {
+ goto retry;
+ }
+ }
+
+ /* Needs to recurse */
+ else if (IS_IO_ERROR (error, WOULD_RECURSE) ||
+ IS_IO_ERROR (error, WOULD_MERGE)) {
+ would_recurse = error->code == G_IO_ERROR_WOULD_RECURSE;
+ g_error_free (error);
+
+ if (overwrite && would_recurse) {
+ error = NULL;
+
+ /* Copying a dir onto file, first remove the file */
+ if (!g_file_delete (dest, job->cancellable, &error) &&
+ !IS_IO_ERROR (error, NOT_FOUND)) {
+ if (job->skip_all_error) {
+ goto out;
+ }
+ if (copy_job->is_move) {
+ primary = f (_("Error while moving \"%B\"."), src);
+ } else {
+ primary = f (_("Error while copying \"%B\"."), src);
+ }
+ secondary = f (_("Couldn't remove the already existing file with the same name in %F."), dest_dir);
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ } else if (response == 2) { /* skip */
+ /* do nothing */
+ } else {
+ g_assert_not_reached ();
+ }
+ goto out;
+
+ }
+ if (error) {
+ g_error_free (error);
+ error = NULL;
+ }
+ if (debuting_files) { /* Only remove metadata for toplevel items */
+ nautilus_file_changes_queue_schedule_metadata_remove (dest);
+ }
+ nautilus_file_changes_queue_file_removed (dest);
+ }
+
+ copy_move_directory (copy_job, src, dest, same_fs,
+ would_recurse,
+ source_info, transfer_info,
+ debuting_files, skipped_file);
+
+ g_object_unref (dest);
+ return;
+ }
+
+ /* Other error */
+ else {
+ if (job->skip_all_error) {
+ goto out;
+ }
+ primary = f (_("Error while copying \"%B\"."), src);
+ secondary = f (_("There was an error copying the file into %F."), dest_dir);
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ } else if (response == 2) { /* skip */
+ /* do nothing */
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+ out:
+ *skipped_file = TRUE; /* Or aborted, but same-same */
+ g_object_unref (dest);
+}
+
+static void
+copy_files (CopyMoveJob *job,
+ const char *dest_fs_id,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info)
+{
+ CommonJob *common;
+ GList *l;
+ GFile *src;
+ gboolean same_fs;
+ int i;
+ GdkPoint *point;
+ gboolean skipped_file;
+
+ common = &job->common;
+
+ report_copy_progress (job, source_info, transfer_info);
+
+ i = 0;
+ for (l = job->files;
+ l != NULL && !common->aborted ;
+ l = l->next) {
+ src = l->data;
+
+ if (i < job->n_icon_positions) {
+ point = &job->icon_positions[i];
+ } else {
+ point = NULL;
+ }
+
+
+ same_fs = FALSE;
+ if (dest_fs_id) {
+ same_fs = has_fs_id (src, dest_fs_id);
+ }
+
+ skipped_file = FALSE;
+ copy_move_file (job, src, job->destination,
+ same_fs,
+ source_info, transfer_info,
+ job->debuting_files,
+ point, FALSE, &skipped_file);
+ i++;
+ }
+}
+
+static void
+copy_job_done (gpointer user_data)
+{
+ CopyMoveJob *job;
+
+ job = user_data;
+ if (job->done_callback) {
+ job->done_callback (job->debuting_files, job->done_callback_data);
+ }
+
+ eel_g_object_list_free (job->files);
+ g_object_unref (job->destination);
+ g_hash_table_unref (job->debuting_files);
+ g_free (job->icon_positions);
+
+ finalize_common ((CommonJob *)job);
+
+ nautilus_file_changes_consume_changes (TRUE);
+}
+
+static void
+copy_job (GIOJob *io_job,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ CopyMoveJob *job;
+ CommonJob *common;
+ SourceInfo source_info;
+ TransferInfo transfer_info;
+ char *dest_fs_id;
+
+ job = user_data;
+ common = &job->common;
+ common->io_job = io_job;
+
+ dest_fs_id = NULL;
+
+ nautilus_progress_info_start (job->common.progress);
+
+ memset (&source_info, 0, sizeof (SourceInfo));
+ scan_sources (job->files,
+ &source_info,
+ common);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ verify_destination (&job->common,
+ job->destination,
+ &dest_fs_id,
+ source_info.num_bytes);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ g_timer_start (job->common.time);
+
+ memset (&transfer_info, 0, sizeof (transfer_info));
+ copy_files (job,
+ dest_fs_id,
+ &source_info, &transfer_info);
+
+ aborted:
+
+ g_free (dest_fs_id);
+
+ g_io_job_send_to_mainloop (io_job,
+ copy_job_done,
+ job,
+ NULL,
+ FALSE);
+}
+
+void
+nautilus_file_operations_copy (GList *files,
+ GArray *relative_item_points,
+ GFile *target_dir,
+ GtkWindow *parent_window,
+ NautilusCopyCallback done_callback,
+ gpointer done_callback_data)
+{
+ CopyMoveJob *job;
+ GdkScreen *screen;
+
+ job = op_job_new (CopyMoveJob, parent_window);
+ job->done_callback = done_callback;
+ job->done_callback_data = done_callback_data;
+ job->files = eel_g_object_list_copy (files);
+ job->destination = g_object_ref (target_dir);
+ if (relative_item_points != NULL &&
+ relative_item_points->len > 0) {
+ job->icon_positions =
+ g_memdup (relative_item_points->data,
+ sizeof (GdkPoint) * relative_item_points->len);
+ job->n_icon_positions = relative_item_points->len;
+ }
+ job->screen_num = 0;
+ if (parent_window) {
+ screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
+ job->screen_num = gdk_screen_get_number (screen);
+ }
+ job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+
+ g_schedule_io_job (copy_job,
+ job,
+ NULL, /* destroy notify */
+ 0,
+ job->common.cancellable);
+}
+
+static void
+report_move_progress (CopyMoveJob *move_job, int total, int left)
+{
+ CommonJob *job;
+
+ job = (CommonJob *)move_job;
+
+ nautilus_progress_info_take_status (job->progress,
+ f (_("Preparing to Move to \"%B\""),
+ move_job->destination));
+
+ nautilus_progress_info_take_details (job->progress,
+ f (_("Preparing to move %d files"), left));
+
+ nautilus_progress_info_pulse_progress (job->progress);
+}
+
+static void
+move_file_prepare (CopyMoveJob *move_job,
+ GFile *src,
+ GFile *dest_dir,
+ gboolean same_fs,
+ GHashTable *debuting_files,
+ GdkPoint *position,
+ GList **copy_files,
+ GArray *copy_positions)
+{
+ GFile *dest;
+ GError *error;
+ CommonJob *job;
+ gboolean overwrite;
+ char *primary, *secondary, *details;
+ int response;
+ GFileCopyFlags flags;
+ gboolean would_recurse;
+
+ overwrite = FALSE;
+
+ job = (CommonJob *)move_job;
+
+ dest = get_target_file (src, dest_dir, same_fs);
+
+ retry:
+
+ flags = G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_NO_FALLBACK_FOR_MOVE;
+ if (overwrite) {
+ flags |= G_FILE_COPY_OVERWRITE;
+ }
+
+ error = NULL;
+ if (g_file_move (src, dest,
+ flags,
+ job->cancellable,
+ NULL,
+ NULL,
+ &error)) {
+
+ if (debuting_files) {
+ g_hash_table_replace (debuting_files, g_object_ref (dest), GINT_TO_POINTER (TRUE));
+ }
+
+ nautilus_file_changes_queue_file_moved (src, dest);
+ nautilus_file_changes_queue_schedule_metadata_move (src, dest);
+
+ return;
+ }
+
+ /* Conflict */
+ if (!overwrite &&
+ IS_IO_ERROR (error, EXISTS)) {
+ gboolean is_merge;
+
+ g_error_free (error);
+
+ is_merge = FALSE;
+ if (is_dir (dest)) {
+ if (is_dir (src)) {
+ is_merge = TRUE;
+ primary = f (_("A folder named \"%B\" already exists. Do you want to merge the source folder?"),
+ dest);
+ secondary = f (_("The source folder already exists in \"%B\". "
+ "Merging will ask for confirmation before replacing any files in the folder that conflict with the files being moved."),
+ dest_dir);
+
+ } else {
+ primary = f (_("A folder named \"%B\" already exists. Do you want to replace it?"),
+ dest);
+ secondary = f (_("The folder already exists in \"%F\". "
+ "Replacing it will remove all files in the folder."),
+ dest_dir);
+ }
+ } else {
+ primary = f (_("A file named \"%B\" already exists. Do you want to replace it?"),
+ dest);
+ secondary = f (_("The file already exists in \"%F\". "
+ "Replacing it will overwrite its content."),
+ dest_dir);
+ }
+
+ if ((is_merge && job->merge_all) ||
+ (!is_merge && job->replace_all)) {
+ g_free (primary);
+ g_free (secondary);
+ g_error_free (error);
+
+ overwrite = TRUE;
+ goto retry;
+ }
+
+ if (job->skip_all_conflict) {
+ g_free (primary);
+ g_free (secondary);
+ g_error_free (error);
+
+ goto out;
+ }
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ NULL,
+ GTK_STOCK_CANCEL,
+ SKIP_ALL,
+ is_merge?MERGE_ALL:REPLACE_ALL,
+ SKIP,
+ is_merge?MERGE:REPLACE,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1 || response == 3) { /* skip all / skip */
+ if (response == 1) {
+ job->skip_all_conflict = TRUE;
+ }
+ } else if (response == 2 || response == 4) { /* merge/replace all / merge/replace*/
+ if (response == 2) {
+ if (is_merge) {
+ job->merge_all = TRUE;
+ } else {
+ job->replace_all = TRUE;
+ }
+ }
+ overwrite = TRUE;
+ goto retry;
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ else if (IS_IO_ERROR (error, WOULD_RECURSE) ||
+ IS_IO_ERROR (error, WOULD_MERGE) ||
+ IS_IO_ERROR (error, NOT_SUPPORTED)) {
+ gboolean delete_dest;
+ would_recurse = error->code == G_IO_ERROR_WOULD_RECURSE;
+ g_error_free (error);
+
+ delete_dest = FALSE;
+ if (overwrite && would_recurse) {
+ delete_dest = TRUE;
+
+ error = NULL;
+ }
+
+ *copy_files = g_list_prepend (*copy_files, src);
+ if (position) {
+ g_array_append_val (copy_positions, *position);
+ }
+ }
+
+ /* Other error */
+ else {
+ if (job->skip_all_error) {
+ goto out;
+ }
+ primary = f (_("Error while moving \"%B\"."), src);
+ secondary = f (_("There was an error moving the file into %F."), dest_dir);
+ details = error->message;
+
+ response = run_warning (job,
+ primary,
+ secondary,
+ details,
+ GTK_STOCK_CANCEL, SKIP_ALL, SKIP,
+ NULL);
+
+ g_error_free (error);
+
+ if (response == 0 || response == GTK_RESPONSE_DELETE_EVENT) {
+ job->aborted = TRUE;
+ } else if (response == 1) { /* skip all */
+ job->skip_all_error = TRUE;
+ } else if (response == 2) { /* skip */
+ /* do nothing */
+ } else {
+ g_assert_not_reached ();
+ }
+ }
+
+ out:
+ g_object_unref (dest);
+}
+
+static void
+move_files_prepare (CopyMoveJob *job,
+ const char *dest_fs_id,
+ GList **copy_files,
+ GArray *copy_positions)
+{
+ CommonJob *common;
+ GList *l;
+ GFile *src;
+ gboolean same_fs;
+ int i;
+ GdkPoint *point;
+ int total, left;
+
+ common = &job->common;
+
+ total = left = g_list_length (job->files);
+
+ report_move_progress (job, total, left);
+
+ i = 0;
+ for (l = job->files;
+ l != NULL && !common->aborted ;
+ l = l->next) {
+ src = l->data;
+
+ if (i < job->n_icon_positions) {
+ point = &job->icon_positions[i];
+ } else {
+ point = NULL;
+ }
+
+
+ same_fs = FALSE;
+ if (dest_fs_id) {
+ same_fs = has_fs_id (src, dest_fs_id);
+ }
+
+ move_file_prepare (job, src, job->destination,
+ same_fs,
+ job->debuting_files,
+ point,
+ copy_files,
+ copy_positions);
+ i++;
+ }
+
+}
+
+static void
+move_files (CopyMoveJob *job,
+ GList *files,
+ GArray *icon_positions,
+ const char *dest_fs_id,
+ SourceInfo *source_info,
+ TransferInfo *transfer_info)
+{
+ CommonJob *common;
+ GList *l;
+ GFile *src;
+ gboolean same_fs;
+ int i;
+ GdkPoint *point;
+ gboolean skipped_file;
+
+ common = &job->common;
+
+ report_copy_progress (job, source_info, transfer_info);
+
+ i = 0;
+ for (l = files;
+ l != NULL && !common->aborted ;
+ l = l->next) {
+ src = l->data;
+
+ if (i < icon_positions->len) {
+ point = &g_array_index (icon_positions, GdkPoint, i);
+ } else {
+ point = NULL;
+ }
+
+ same_fs = FALSE;
+ if (dest_fs_id) {
+ same_fs = has_fs_id (src, dest_fs_id);
+ }
+
+ /* Set overwrite to true, as the user has
+ selected overwrite on all toplevel items */
+ skipped_file = FALSE;
+ copy_move_file (job, src, job->destination,
+ same_fs,
+ source_info, transfer_info,
+ job->debuting_files,
+ point, TRUE, &skipped_file);
+ i++;
+ }
+}
+
+
+static void
+move_job_done (gpointer user_data)
+{
+ CopyMoveJob *job;
+
+ job = user_data;
+ if (job->done_callback) {
+ job->done_callback (job->debuting_files, job->done_callback_data);
+ }
+
+ eel_g_object_list_free (job->files);
+ g_object_unref (job->destination);
+ g_hash_table_unref (job->debuting_files);
+ g_free (job->icon_positions);
+
+ finalize_common ((CommonJob *)job);
+
+ nautilus_file_changes_consume_changes (TRUE);
+}
+
+static void
+move_job (GIOJob *io_job,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ CopyMoveJob *job;
+ CommonJob *common;
+ GList *copy_files;
+ GArray *copy_positions;
+ SourceInfo source_info;
+ TransferInfo transfer_info;
+ char *dest_fs_id;
+
+ job = user_data;
+ common = &job->common;
+ common->io_job = io_job;
+
+ dest_fs_id = NULL;
+
+ copy_files = NULL;
+ copy_positions = NULL;
+
+ nautilus_progress_info_start (job->common.progress);
+
+ verify_destination (&job->common,
+ job->destination,
+ &dest_fs_id,
+ -1);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ copy_files = NULL;
+ copy_positions = g_array_new (FALSE, TRUE, sizeof (GdkPoint));
+
+ /* This moves all files that we can do without copy + delete */
+ move_files_prepare (job, dest_fs_id, &copy_files, copy_positions);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ copy_files = g_list_reverse (copy_files);
+
+ /* The rest we need to do deep copy + delete behind on,
+ so scan for size */
+
+ memset (&source_info, 0, sizeof (SourceInfo));
+ scan_sources (copy_files,
+ &source_info,
+ common);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ verify_destination (&job->common,
+ job->destination,
+ &dest_fs_id,
+ source_info.num_bytes);
+ if (common->aborted) {
+ goto aborted;
+ }
+
+ memset (&transfer_info, 0, sizeof (transfer_info));
+ move_files (job,
+ copy_files,
+ copy_positions,
+ dest_fs_id,
+ &source_info, &transfer_info);
+
+ aborted:
+ g_list_free (copy_files);
+ if (copy_positions) {
+ g_array_free (copy_positions, TRUE);
+ }
+
+ g_free (dest_fs_id);
+
+ g_io_job_send_to_mainloop (io_job,
+ move_job_done,
+ job,
+ NULL,
+ FALSE);
+}
+
+void
+nautilus_file_operations_move (GList *files,
+ GArray *relative_item_points,
+ GFile *target_dir,
+ GtkWindow *parent_window,
+ NautilusCopyCallback done_callback,
+ gpointer done_callback_data)
+{
+ CopyMoveJob *job;
+ GdkScreen *screen;
+
+ job = op_job_new (CopyMoveJob, parent_window);
+ job->is_move = TRUE;
+ job->done_callback = done_callback;
+ job->done_callback_data = done_callback_data;
+ job->files = eel_g_object_list_copy (files);
+ job->destination = g_object_ref (target_dir);
+ if (relative_item_points != NULL &&
+ relative_item_points->len > 0) {
+ job->icon_positions =
+ g_memdup (relative_item_points->data,
+ sizeof (GdkPoint) * relative_item_points->len);
+ job->n_icon_positions = relative_item_points->len;
+ }
+ job->screen_num = 0;
+ if (parent_window) {
+ screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
+ job->screen_num = gdk_screen_get_number (screen);
+ }
+ job->debuting_files = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL);
+
+ g_schedule_io_job (move_job,
+ job,
+ NULL, /* destroy notify */
+ 0,
+ job->common.cancellable);
+}
+
+
+
+static void
+not_supported_yet (void)
+{
+ eel_show_warning_dialog ("This operation isn't supported with the gio-based nautilus",
+ "This is work in progress. Please be patient",
+ NULL);
+}
+
+void
+nautilus_file_set_permissions_recursive (const char *directory,
+ guint32 file_permissions,
+ guint32 file_mask,
+ guint32 dir_permissions,
+ guint32 dir_mask,
+ NautilusSetPermissionsCallback callback,
+ gpointer callback_data)
+{
+ /* TODO-gio: Implement */
+ not_supported_yet ();
+}
+
+static GList *
+location_list_from_uri_list (const GList *uris)
+{
+ const GList *l;
+ GList *files;
+ GFile *f;
+
+ files = NULL;
+ for (l = uris; l != NULL; l = l->next) {
+ f = g_file_new_for_uri (l->data);
+ files = g_list_prepend (files, f);
+ }
+
+ return g_list_reverse (files);
+}
+
+void
+nautilus_file_operations_copy_move (const GList *item_uris,
+ GArray *relative_item_points,
+ const char *target_dir,
+ GdkDragAction copy_action,
+ GtkWidget *parent_view,
+ NautilusCopyCallback done_callback,
+ gpointer done_callback_data)
+{
+ GList *locations;
+ GFile *dest;
+ GtkWindow *parent_window;
+
+ dest = g_file_new_for_uri (target_dir);
+ locations = location_list_from_uri_list (item_uris);
+
+ parent_window = NULL;
+ if (parent_view) {
+ parent_window = (GtkWindow *)gtk_widget_get_ancestor (parent_view, GTK_TYPE_WINDOW);
+ }
+
+ if (copy_action == GDK_ACTION_COPY) {
+ nautilus_file_operations_copy (locations,
+ relative_item_points,
+ dest,
+ parent_window,
+ done_callback, done_callback_data);
+
+ } else if (copy_action == GDK_ACTION_MOVE) {
+
+ if (g_file_has_uri_scheme (dest, "trash")) {
+ nautilus_file_operations_trash_or_delete (locations,
+ parent_window,
+ done_callback, done_callback_data);
+ } else {
+ nautilus_file_operations_move (locations,
+ relative_item_points,
+ dest,
+ parent_window,
+ done_callback, done_callback_data);
+ }
+ } else {
+ /* TODO-gio: Implement link */
+ not_supported_yet ();
+ }
+
+ eel_g_object_list_free (locations);
+ g_object_unref (dest);
+}
+
+void
+nautilus_file_operations_new_folder (GtkWidget *parent_view,
+ GdkPoint *target_point,
+ const char *parent_dir,
+ NautilusNewFolderCallback done_callback,
+ gpointer data)
+{
+ /* TODO-gio: Implement */
+ not_supported_yet ();
+}
+
+void
+nautilus_file_operations_new_file_from_template (GtkWidget *parent_view,
+ GdkPoint *target_point,
+ const char *parent_dir,
+ const char *target_filename,
+ const char *template_uri,
+ NautilusNewFileCallback done_callback,
+ gpointer data)
+{
+ /* TODO-gio: Implement */
+ not_supported_yet ();
+}
+
+void
+nautilus_file_operations_new_file (GtkWidget *parent_view,
+ GdkPoint *target_point,
+ const char *parent_dir,
+ const char *initial_contents,
+ NautilusNewFileCallback done_callback,
+ gpointer data)
+{
+ /* TODO-gio: Implement */
+ not_supported_yet ();
+}
+
+
+void
+nautilus_file_operations_empty_trash (GtkWidget *parent_view)
+{
+ /* TODO-gio: Implement */
+ not_supported_yet ();
+}
+
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
@@ -3411,6 +6342,8 @@ nautilus_self_check_file_operations (void)
{
setlocale (LC_MESSAGES, "C");
+#ifdef GIO_CONVERSION_DONE
+
/* test the next duplicate name generator */
EEL_CHECK_STRING_RESULT (get_duplicate_name (" (copy)", 1), " (another copy)");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo", 1), "foo (copy)");
@@ -3454,6 +6387,8 @@ nautilus_self_check_file_operations (void)
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo (123rd copy)", 1), "foo (124th copy)");
EEL_CHECK_STRING_RESULT (get_duplicate_name ("foo (123rd copy).txt", 1), "foo (124th copy).txt");
+#endif /* GIO_CONVERSION_DONE */
+
setlocale (LC_MESSAGES, "");
}
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index 9400631ce..98c3ee37f 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -29,9 +29,7 @@
#include <gdk/gdkdnd.h>
#include <gtk/gtkwidget.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gvolume.h>
typedef void (* NautilusCopyCallback) (GHashTable *debuting_uris,
gpointer callback_data);
@@ -42,6 +40,8 @@ typedef void (* NautilusNewFileCallback) (const char *new_file_uri,
typedef void (* NautilusSetPermissionsCallback) (gpointer callback_data);
typedef void (* NautilusDeleteCallback) (GHashTable *debuting_uris,
gpointer callback_data);
+typedef void (* NautilusUnmountCallback) (GError *error,
+ gpointer callback_data);
/* FIXME: int copy_action should be an enum */
@@ -72,27 +72,41 @@ void nautilus_file_operations_new_file_from_template (GtkWidget *p
NautilusNewFileCallback done_callback,
gpointer data);
-void nautilus_file_operations_delete (const GList *item_uris,
- GtkWidget *parent_view,
- NautilusDeleteCallback done_callback,
- gpointer done_callback_data);
+void nautilus_file_operations_delete (GList *files,
+ GtkWindow *parent_window,
+ NautilusDeleteCallback done_callback,
+ gpointer done_callback_data);
+void nautilus_file_operations_trash_or_delete (GList *files,
+ GtkWindow *parent_window,
+ NautilusDeleteCallback done_callback,
+ gpointer done_callback_data);
void nautilus_file_set_permissions_recursive (const char *directory,
- GnomeVFSFilePermissions file_permissions,
- GnomeVFSFilePermissions file_mask,
- GnomeVFSFilePermissions folder_permissions,
- GnomeVFSFilePermissions folder_mask,
+ guint32 file_permissions,
+ guint32 file_mask,
+ guint32 folder_permissions,
+ guint32 folder_mask,
NautilusSetPermissionsCallback callback,
gpointer callback_data);
-void nautilus_file_operations_unmount_volume (GtkWidget *parent_view,
- GnomeVFSVolume *volume,
- GnomeVFSVolumeOpCallback callback,
- gpointer user_data);
+void nautilus_file_operations_unmount_volume (GtkWindow *parent_window,
+ GVolume *volume,
+ NautilusUnmountCallback callback,
+ gpointer user_data);
-void nautilus_file_operations_unmount_drive (GtkWidget *parent_view,
- GnomeVFSDrive *drive,
- GnomeVFSVolumeOpCallback callback,
- gpointer user_data);
+
+void nautilus_file_operations_copy (GList *files,
+ GArray *relative_item_points,
+ GFile *target_dir,
+ GtkWindow *parent_window,
+ NautilusCopyCallback done_callback,
+ gpointer done_callback_data);
+
+void nautilus_file_operations_move (GList *files,
+ GArray *relative_item_points,
+ GFile *target_dir,
+ GtkWindow *parent_window,
+ NautilusCopyCallback done_callback,
+ gpointer done_callback_data);
#endif /* NAUTILUS_FILE_OPERATIONS_H */
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 354e2293f..db12994d9 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -29,6 +29,7 @@
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-monitor.h>
#include <eel/eel-glib-extensions.h>
+#include <eel/eel-string.h>
#define NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_CHARACTERS_PER_LINE 80
#define NAUTILUS_FILE_LARGE_TOP_LEFT_TEXT_MAXIMUM_LINES 24
@@ -39,11 +40,14 @@
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES 1024
#define NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS \
- (GNOME_VFS_FILE_INFO_FOLLOW_LINKS | \
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE | \
- GNOME_VFS_FILE_INFO_GET_SELINUX_CONTEXT | \
+ (GNOME_VFS_FILE_INFO_FOLLOW_LINKS | \
+ GNOME_VFS_FILE_INFO_GET_MIME_TYPE | \
+ GNOME_VFS_FILE_INFO_GET_SELINUX_CONTEXT | \
GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS)
+#define NAUTILUS_FILE_DEFAULT_ATTRIBUTES \
+ "std:*,access:*,mountable:*,time:*,unix:*,owner:*,selinux:*,thumbnail:*,mountable:*"
+
/* These are in the typical sort order. Known things come first, then
* things where we can't know, finally things where we don't yet know.
*/
@@ -60,39 +64,55 @@ typedef struct {
struct NautilusFileDetails
{
NautilusDirectory *directory;
- char *relative_uri;
+
+ eel_ref_str name;
- /* Cached version of the display name, guaranteed UTF8 safe.
- * This is used a lot for sorting views.
- */
- char *cached_display_name;
- /* We cache the result of g_utf8_collate_key() on
- * cached_display_name in order to do quick sorting on
- * the display name
- */
- char *display_name_collation_key;
+ /* File info: */
+ GFileType type;
- GnomeVFSFileInfo *info;
- GnomeVFSResult get_info_error;
+ eel_ref_str display_name;
+ char *display_name_collation_key;
+ eel_ref_str edit_name;
+ goffset size; /* -1 is unknown */
+
+ int sort_order;
+
+ guint32 permissions;
+ int uid; /* -1 is none */
+ int gid; /* -1 is none */
+
+ time_t atime; /* 0 is unknown */
+ time_t mtime; /* 0 is unknown */
+ time_t ctime; /* 0 is unknown */
+
+ char *symlink_name;
+
+ eel_ref_str mime_type;
+
+ char* selinux_context;
+
+ GError *get_info_error;
+
guint directory_count;
guint deep_directory_count;
guint deep_file_count;
guint deep_unreadable_count;
- GnomeVFSFileSize deep_size;
+ goffset deep_size;
+ GIcon *icon;
+
+ char *thumbnail_path;
+ GdkPixbuf *thumbnail;
+ int thumbnail_size; /* 0 means original unframed thumbnail */
+
GList *mime_list; /* If this is a directory, the list of MIME types in it. */
char *top_left_text;
/* Info you might get from a link (.desktop, .directory or nautilus link) */
- char *display_name;
char *custom_icon;
- char *activation_uri;
-
- /* The guessed (extension-based) mime type. This is saved for
- * comparison vs. the slow mime type upon activation */
- char *guessed_mime_type;
+ GFile *activation_location;
/* The following is for file operations in progress. Since
* there are normally only a few of these, we can move them to
@@ -128,12 +148,10 @@ struct NautilusFileDetails
* list so the file knows not to do redundant I/O.
*/
eel_boolean_bit loading_directory : 1;
- /* got_info known from info field being non-NULL */
+ eel_boolean_bit got_file_info : 1;
eel_boolean_bit get_info_failed : 1;
eel_boolean_bit file_info_is_up_to_date : 1;
- eel_boolean_bit got_slow_mime_type : 1;
-
eel_boolean_bit got_directory_count : 1;
eel_boolean_bit directory_count_failed : 1;
eel_boolean_bit directory_count_is_up_to_date : 1;
@@ -153,22 +171,52 @@ struct NautilusFileDetails
eel_boolean_bit got_link_info : 1;
eel_boolean_bit link_info_is_up_to_date : 1;
+ eel_boolean_bit got_custom_display_name : 1;
+ eel_boolean_bit got_custom_activation_location : 1;
+ eel_boolean_bit thumbnail_is_up_to_date : 1;
+ eel_boolean_bit thumbnail_tried_original : 1;
+ eel_boolean_bit thumbnailing_failed : 1;
+
eel_boolean_bit is_thumbnailing : 1;
- eel_boolean_bit has_volume : 1;
- eel_boolean_bit has_drive : 1;
-
/* TRUE if the file is open in a spatial window */
eel_boolean_bit has_open_window : 1;
+
+ eel_boolean_bit is_symlink : 1;
+ eel_boolean_bit is_mountpoint : 1;
+ eel_boolean_bit is_hidden : 1;
+ eel_boolean_bit is_backup : 1;
+
+ eel_boolean_bit has_permissions : 1;
+
+ eel_boolean_bit can_read : 1;
+ eel_boolean_bit can_write : 1;
+ eel_boolean_bit can_execute : 1;
+ eel_boolean_bit can_delete : 1;
+ eel_boolean_bit can_trash : 1;
+ eel_boolean_bit can_rename : 1;
+ eel_boolean_bit can_mount : 1;
+ eel_boolean_bit can_unmount : 1;
+ eel_boolean_bit can_eject : 1;
};
+typedef struct {
+ NautilusFile *file;
+ GCancellable *cancellable;
+ NautilusFileOperationCallback callback;
+ gpointer callback_data;
+ gboolean is_rename;
+
+ gpointer data;
+ GDestroyNotify free_data;
+} NautilusFileOperation;
+
+
NautilusFile *nautilus_file_new_from_info (NautilusDirectory *directory,
- GnomeVFSFileInfo *info);
+ GFileInfo *info);
void nautilus_file_emit_changed (NautilusFile *file);
void nautilus_file_mark_gone (NautilusFile *file);
-gboolean nautilus_file_info_missing (NautilusFile *file,
- GnomeVFSFileInfoFields needed_mask);
char * nautilus_extract_top_left_text (const char *text,
gboolean large,
int length);
@@ -178,15 +226,14 @@ gboolean nautilus_file_get_date (NautilusFile
NautilusDateType date_type,
time_t *date);
void nautilus_file_updated_deep_count_in_progress (NautilusFile *file);
-void nautilus_file_clear_cached_display_name (NautilusFile *file);
+void nautilus_file_clear_info (NautilusFile *file);
/* Compare file's state with a fresh file info struct, return FALSE if
* no change, update file and return TRUE if the file info contains
* new state. */
gboolean nautilus_file_update_info (NautilusFile *file,
- GnomeVFSFileInfo *info,
- gboolean info_has_slow_mime);
+ GFileInfo *info);
gboolean nautilus_file_update_name (NautilusFile *file,
const char *name);
@@ -194,6 +241,11 @@ gboolean nautilus_file_update_name_and_directory (NautilusFile
const char *name,
NautilusDirectory *directory);
+gboolean nautilus_file_set_display_name (NautilusFile *file,
+ const char *display_name,
+ const char *edit_name,
+ gboolean custom);
+
/* Return true if the top lefts of files in this directory should be
* fetched, according to the preference settings.
*/
@@ -208,7 +260,6 @@ NautilusFileAttributes nautilus_file_get_all_attributes (void);
gboolean nautilus_file_is_self_owned (NautilusFile *file);
void nautilus_file_invalidate_count_and_mime_list (NautilusFile *file);
gboolean nautilus_file_rename_in_progress (NautilusFile *file);
-GnomeVFSFileInfo * nautilus_file_peek_vfs_file_info (NautilusFile *file);
void nautilus_file_invalidate_extension_info_internal (NautilusFile *file);
void nautilus_file_info_providers_done (NautilusFile *file);
@@ -217,10 +268,13 @@ void nautilus_file_info_providers_done (Nautilu
void nautilus_file_set_is_thumbnailing (NautilusFile *file,
gboolean is_thumbnailing);
-/* Volumes: */
-void nautilus_file_set_drive (NautilusFile *file,
- GnomeVFSDrive *drive);
-void nautilus_file_set_volume (NautilusFile *file,
- GnomeVFSVolume *volume);
+NautilusFileOperation *nautilus_file_operation_new (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+void nautilus_file_operation_free (NautilusFileOperation *op);
+void nautilus_file_operation_complete (NautilusFileOperation *op,
+ GFile *result_location,
+ GError *error);
+void nautilus_file_operation_cancel (NautilusFileOperation *op);
#endif
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index c8815ca86..20d3eb63b 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -34,13 +34,10 @@
#include "nautilus-signaller.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-debug.h>
#include <libgnome/gnome-util.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gfilemonitor.h>
#include <unistd.h>
#include <stdlib.h>
@@ -57,49 +54,22 @@ static void desktop_dir_changed (void);
char *
-nautilus_compute_title_for_uri (const char *text_uri)
+nautilus_compute_title_for_location (GFile *location)
{
NautilusFile *file;
- GnomeVFSURI *uri;
- char *title, *displayname;
- const char *hostname;
- NautilusDirectory *directory;
- NautilusQuery *query;
- hostname = NULL;
-
- if (text_uri) {
- if (eel_uri_is_search (text_uri)) {
- directory = nautilus_directory_get (text_uri);
-
- query = nautilus_search_directory_get_query (NAUTILUS_SEARCH_DIRECTORY (directory));
- nautilus_directory_unref (directory);
-
- if (query != NULL) {
- title = nautilus_query_to_readable_string (query);
- g_object_unref (query);
- } else {
- title = g_strdup (_("Search"));
- }
+ char *title;
- return title;
- }
- file = nautilus_file_get (text_uri);
- uri = gnome_vfs_uri_new (text_uri);
- if (uri && strcmp (uri->method_string, "file") != 0) {
- hostname = gnome_vfs_uri_get_host_name (uri);
- }
- displayname = nautilus_file_get_display_name (file);
- if (hostname) {
- title = g_strdup_printf (_("%s on %s"), displayname, hostname);
- g_free (displayname);
- } else {
- title = displayname;
- }
- if (uri) {
- gnome_vfs_uri_unref (uri);
- }
+ /* TODO-gio: This doesn't really work all that great if the
+ info about the file isn't known atm... */
+
+ title = NULL;
+ if (location) {
+ file = nautilus_file_get (location);
+ title = nautilus_file_get_display_name (file);
nautilus_file_unref (file);
- } else {
+ }
+
+ if (title == NULL) {
title = g_strdup ("");
}
@@ -107,23 +77,6 @@ nautilus_compute_title_for_uri (const char *text_uri)
}
-gboolean
-nautilus_file_name_matches_hidden_pattern (const char *name_or_relative_uri)
-{
- g_return_val_if_fail (name_or_relative_uri != NULL, FALSE);
-
- return name_or_relative_uri[0] == '.';
-}
-
-gboolean
-nautilus_file_name_matches_backup_pattern (const char *name_or_relative_uri)
-{
- g_return_val_if_fail (name_or_relative_uri != NULL, FALSE);
-
- return g_str_has_suffix (name_or_relative_uri, "~") &&
- !g_str_equal (name_or_relative_uri, "~");
-}
-
/**
* nautilus_get_user_directory:
*
@@ -259,21 +212,19 @@ parse_xdg_dirs (const char *config_file)
}
static XdgDirEntry *cached_xdg_dirs = NULL;
-static GnomeVFSMonitorHandle *cached_xdg_dirs_handle = NULL;
+static GFileMonitor *cached_xdg_dirs_monitor = NULL;
static void
xdg_dir_changed (NautilusFile *file,
XdgDirEntry *dir)
{
- char *file_uri;
- char *dir_uri;
+ GFile *location, *dir_location;
char *path;
-
- file_uri = nautilus_file_get_uri (file);
- dir_uri = gnome_vfs_get_uri_from_local_path (dir->path);
- if (file_uri && dir_uri &&
- !gnome_vfs_uris_match (dir_uri, file_uri)) {
- path = gnome_vfs_get_local_path_from_uri (file_uri);
+
+ location = nautilus_file_get_location (file);
+ dir_location = g_file_new_for_path (dir->path);
+ if (!g_file_equal (location, dir_location)) {
+ path = g_file_get_path (location);
if (path) {
char *argv[5];
@@ -304,19 +255,18 @@ xdg_dir_changed (NautilusFile *file,
desktop_dir_changed ();
}
}
- g_free (file_uri);
- g_free (dir_uri);
+ g_object_unref (location);
+ g_object_unref (dir_location);
}
static void
-xdg_dir_cache_changed_cb (GnomeVFSMonitorHandle *handle,
- const gchar *monitor_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer user_data)
-{
- if (event_type == GNOME_VFS_MONITOR_EVENT_CHANGED ||
- event_type == GNOME_VFS_MONITOR_EVENT_CREATED) {
+xdg_dir_cache_changed_cb (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type)
+{
+ if (event_type == G_FILE_MONITOR_EVENT_CHANGED ||
+ event_type == G_FILE_MONITOR_EVENT_CREATED) {
update_xdg_dir_cache ();
}
}
@@ -378,15 +328,16 @@ destroy_xdg_dir_cache (void)
unschedule_user_dirs_changed ();
desktop_dir_changed ();
- if (cached_xdg_dirs_handle != NULL) {
- gnome_vfs_monitor_cancel (cached_xdg_dirs_handle);
- cached_xdg_dirs_handle = NULL;
+ if (cached_xdg_dirs_monitor != NULL) {
+ g_object_unref (cached_xdg_dirs_monitor);
+ cached_xdg_dirs_monitor = NULL;
}
}
static void
update_xdg_dir_cache (void)
{
+ GFile *file;
char *config_file, *uri;
int i;
@@ -399,27 +350,25 @@ update_xdg_dir_cache (void)
for (i = 0 ; cached_xdg_dirs[i].type != NULL; i++) {
cached_xdg_dirs[i].file = NULL;
if (strcmp (cached_xdg_dirs[i].path, g_get_home_dir ()) != 0) {
- uri = gnome_vfs_get_uri_from_local_path (cached_xdg_dirs[i].path);
- cached_xdg_dirs[i].file = nautilus_file_get (uri);
+ uri = g_filename_to_uri (cached_xdg_dirs[i].path, NULL, NULL);
+ cached_xdg_dirs[i].file = nautilus_file_get_by_uri (uri);
nautilus_file_monitor_add (cached_xdg_dirs[i].file,
&cached_xdg_dirs[i],
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE);
+ NAUTILUS_FILE_ATTRIBUTE_INFO);
g_signal_connect (cached_xdg_dirs[i].file,
"changed", G_CALLBACK (xdg_dir_changed), &cached_xdg_dirs[i]);
g_free (uri);
}
}
- if (cached_xdg_dirs_handle == NULL) {
+ if (cached_xdg_dirs_monitor == NULL) {
config_file = g_build_filename (g_get_user_config_dir (),
"user-dirs.dirs", NULL);
- uri = gnome_vfs_get_uri_from_local_path (config_file);
- gnome_vfs_monitor_add (&cached_xdg_dirs_handle,
- uri,
- GNOME_VFS_MONITOR_FILE,
- xdg_dir_cache_changed_cb,
- NULL);
- g_free (uri);
+ file = g_file_new_for_path (config_file);
+ cached_xdg_dirs_monitor = g_file_monitor_file (file, 0, NULL);
+ g_signal_connect (cached_xdg_dirs_monitor, "changed",
+ G_CALLBACK (xdg_dir_cache_changed_cb), NULL);
+ g_object_unref (file);
g_free (config_file);
eel_debug_call_at_shutdown (destroy_xdg_dir_cache);
@@ -491,6 +440,19 @@ nautilus_get_desktop_directory (void)
return desktop_directory;
}
+GFile *
+nautilus_get_desktop_location (void)
+{
+ char *desktop_directory;
+ GFile *res;
+
+ desktop_directory = get_desktop_path ();
+
+ res = g_file_new_for_path (desktop_directory);
+ g_free (desktop_directory);
+ return res;
+}
+
/**
* nautilus_get_desktop_directory_uri:
@@ -506,7 +468,7 @@ nautilus_get_desktop_directory_uri (void)
char *desktop_uri;
desktop_path = nautilus_get_desktop_directory ();
- desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
+ desktop_uri = g_filename_to_uri (desktop_path, NULL, NULL);
g_free (desktop_path);
return desktop_uri;
@@ -519,7 +481,7 @@ nautilus_get_desktop_directory_uri_no_create (void)
char *desktop_uri;
desktop_path = get_desktop_path ();
- desktop_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
+ desktop_uri = g_filename_to_uri (desktop_path, NULL, NULL);
g_free (desktop_path);
return desktop_uri;
@@ -528,7 +490,7 @@ nautilus_get_desktop_directory_uri_no_create (void)
char *
nautilus_get_home_directory_uri (void)
{
- return gnome_vfs_get_uri_from_local_path (g_get_home_dir ());
+ return g_filename_to_uri (g_get_home_dir (), NULL, NULL);
}
@@ -568,7 +530,7 @@ nautilus_get_templates_directory_uri (void)
char *directory, *uri;
directory = nautilus_get_templates_directory ();
- uri = gnome_vfs_get_uri_from_local_path (directory);
+ uri = g_filename_to_uri (directory, NULL, NULL);
g_free (directory);
return uri;
}
@@ -590,21 +552,25 @@ nautilus_get_searches_directory (void)
}
/* These need to be reset to NULL when desktop_is_home_dir changes */
-static char *escaped_desktop_dir = NULL;
-static char *escaped_desktop_dir_dirname = NULL;
-static char *escaped_desktop_dir_filename = NULL;
+static GFile *desktop_dir = NULL;
+static GFile *desktop_dir_dir = NULL;
+static char *desktop_dir_filename = NULL;
static gboolean desktop_dir_changed_callback_installed = FALSE;
static void
desktop_dir_changed (void)
{
- g_free (escaped_desktop_dir);
- g_free (escaped_desktop_dir_filename);
- g_free (escaped_desktop_dir_dirname);
- escaped_desktop_dir = NULL;
- escaped_desktop_dir_dirname = NULL;
- escaped_desktop_dir_filename = NULL;
+ if (desktop_dir) {
+ g_object_unref (desktop_dir);
+ }
+ if (desktop_dir_dir) {
+ g_object_unref (desktop_dir_dir);
+ }
+ g_free (desktop_dir_filename);
+ desktop_dir = NULL;
+ desktop_dir_dir = NULL;
+ desktop_dir_filename = NULL;
}
static void
@@ -616,49 +582,66 @@ desktop_dir_changed_callback (gpointer callback_data)
static void
update_desktop_dir (void)
{
- char *uri, *path;
- GnomeVFSURI *vfs_uri;
+ char *path;
+ char *dirname;
path = get_desktop_path ();
- uri = gnome_vfs_get_uri_from_local_path (path);
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (path);
- g_free (uri);
+ desktop_dir = g_file_new_for_path (path);
- escaped_desktop_dir = g_strdup (vfs_uri->text);
- escaped_desktop_dir_filename = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- escaped_desktop_dir_dirname = gnome_vfs_uri_extract_dirname (vfs_uri);
+ dirname = g_path_get_dirname (path);
+ desktop_dir_dir = g_file_new_for_path (dirname);
+ g_free (dirname);
+ desktop_dir_filename = g_path_get_basename (path);
+ g_free (path);
+}
+
+gboolean
+nautilus_is_home_directory_file (GFile *dir,
+ const char *filename)
+{
+ char *dirname;
+ static GFile *home_dir_dir = NULL;
+ static char *home_dir_filename = NULL;
- gnome_vfs_uri_unref (vfs_uri);
+ if (home_dir_dir == NULL) {
+ dirname = g_path_get_dirname (g_get_home_dir ());
+ home_dir_dir = g_file_new_for_path (dirname);
+ g_free (dirname);
+ home_dir_filename = g_path_get_basename (g_get_home_dir ());
+ }
+
+ return (g_file_equal (dir, home_dir_dir) &&
+ strcmp (filename, home_dir_filename) == 0);
}
gboolean
-nautilus_is_home_directory_file_escaped (char *escaped_dirname,
- char *escaped_file)
+nautilus_is_home_directory (GFile *dir)
{
- static char *escaped_home_dir_dirname = NULL;
- static char *escaped_home_dir_filename = NULL;
- char *uri;
- GnomeVFSURI *vfs_uri;
+ static GFile *home_dir = NULL;
- if (escaped_home_dir_dirname == NULL) {
- uri = nautilus_get_home_directory_uri ();
- vfs_uri = gnome_vfs_uri_new (uri);
- g_free (uri);
+ if (home_dir == NULL) {
+ home_dir = g_file_new_for_path (g_get_home_dir ());
+ }
- escaped_home_dir_filename = gnome_vfs_uri_extract_short_path_name (vfs_uri);
- escaped_home_dir_dirname = gnome_vfs_uri_extract_dirname (vfs_uri);
+ return g_file_equal (dir, home_dir);
+}
- gnome_vfs_uri_unref (vfs_uri);
+gboolean
+nautilus_is_root_directory (GFile *dir)
+{
+ static GFile *root_dir = NULL;
+
+ if (root_dir == NULL) {
+ root_dir = g_file_new_for_path ("/");
}
- return (strcmp (escaped_dirname, escaped_home_dir_dirname) == 0 &&
- strcmp (escaped_file, escaped_home_dir_filename) == 0);
+ return g_file_equal (dir, root_dir);
}
-
+
+
gboolean
-nautilus_is_desktop_directory_file_escaped (char *escaped_dirname,
- char *escaped_file)
+nautilus_is_desktop_directory_file (GFile *dir,
+ const char *file)
{
if (!desktop_dir_changed_callback_installed) {
@@ -668,16 +651,16 @@ nautilus_is_desktop_directory_file_escaped (char *escaped_dirname,
desktop_dir_changed_callback_installed = TRUE;
}
- if (escaped_desktop_dir == NULL) {
+ if (desktop_dir == NULL) {
update_desktop_dir ();
}
- return (strcmp (escaped_dirname, escaped_desktop_dir_dirname) == 0 &&
- strcmp (escaped_file, escaped_desktop_dir_filename) == 0);
+ return (g_file_equal (dir, desktop_dir_dir) &&
+ strcmp (file, desktop_dir_filename) == 0);
}
gboolean
-nautilus_is_desktop_directory_escaped (char *escaped_dir)
+nautilus_is_desktop_directory (GFile *dir)
{
if (!desktop_dir_changed_callback_installed) {
@@ -687,11 +670,11 @@ nautilus_is_desktop_directory_escaped (char *escaped_dir)
desktop_dir_changed_callback_installed = TRUE;
}
- if (escaped_desktop_dir == NULL) {
+ if (desktop_dir == NULL) {
update_desktop_dir ();
}
- return strcmp (escaped_dir, escaped_desktop_dir) == 0;
+ return g_file_equal (dir, desktop_dir);
}
@@ -768,67 +751,52 @@ nautilus_get_data_file_path (const char *partial_path)
return NULL;
}
-/**
- * < 0 invalid URI
- * == 0 no
- * > 0 yes
- **/
-static int
-test_uri_exists (const char *path)
-{
- GnomeVFSURI *uri;
- gboolean exists;
-
- uri = gnome_vfs_uri_new (path);
- if (uri == NULL) {
- return -1;
- } else {
- exists = gnome_vfs_uri_exists (uri);
- gnome_vfs_uri_unref (uri);
-
- return exists ? 1 : 0;
- }
-}
-
char *
nautilus_ensure_unique_file_name (const char *directory_uri,
const char *base_name,
const char *extension)
{
- char *path, *escaped_name;
- int exists;
+ GFileInfo *info;
+ char *filename;
+ GFile *dir, *child;
int copy;
+ char *res;
- escaped_name = gnome_vfs_escape_string (base_name);
+ dir = g_file_new_for_uri (directory_uri);
- path = g_strdup_printf ("%s/%s%s",
- directory_uri,
- escaped_name,
- extension);
- exists = test_uri_exists (path);
+ info = g_file_query_info (dir, G_FILE_ATTRIBUTE_STD_TYPE, 0, NULL, NULL);
+ if (info == NULL) {
+ g_object_unref (dir);
+ return NULL;
+ }
+ g_object_unref (info);
+ filename = g_strdup_printf ("%s%s",
+ base_name,
+ extension);
+ child = g_file_get_child (dir, filename);
+ g_free (filename);
+
copy = 1;
- while (exists > 0) {
- g_free (path);
- path = g_strdup_printf ("%s/%s-%d%s",
- directory_uri,
- escaped_name,
- copy,
- extension);
-
- exists = test_uri_exists (path);
-
+ while ((info = g_file_query_info (child, G_FILE_ATTRIBUTE_STD_TYPE, 0, NULL, NULL)) != NULL) {
+ g_object_unref (info);
+ g_object_unref (child);
+
+ filename = g_strdup_printf ("%s-%d%s",
+ base_name,
+ copy,
+ extension);
+ child = g_file_get_child (dir, filename);
+ g_free (filename);
+
copy++;
}
- g_free (escaped_name);
-
- if (exists < 0) {
- g_free (path);
- path = NULL;
- }
-
- return path;
+ res = g_file_get_uri (child);
+ g_object_unref (child);
+ g_object_unref (dir);
+
+ return res;
}
char *
@@ -851,101 +819,29 @@ nautilus_unique_temporary_file_name (void)
return file_name;
}
-char *
-nautilus_find_existing_uri_in_hierarchy (const char *uri)
+GFile *
+nautilus_find_existing_uri_in_hierarchy (GFile *location)
{
- GnomeVFSURI *vfs_uri, *parent_vfs_uri;
- char *ret = NULL;
-
- g_assert (uri != NULL);
+ GFileInfo *info;
+ GFile *tmp;
- vfs_uri = gnome_vfs_uri_new (uri);
+ g_assert (location != NULL);
- while (vfs_uri != NULL) {
- if (gnome_vfs_uri_exists (vfs_uri)) {
- ret = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_NONE);
- break;
+ location = g_object_ref (location);
+ while (location != NULL) {
+ info = g_file_query_info (location,
+ "std:name",
+ 0, NULL, NULL);
+ g_object_unref (info);
+ if (info != NULL) {
+ return location;
}
-
- parent_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- vfs_uri = parent_vfs_uri;
- }
-
- return ret;
-}
-
-const char *
-nautilus_get_vfs_method_display_name (char *method)
-{
- if (g_ascii_strcasecmp (method, "computer") == 0 ) {
- return _("Computer");
- } else if (g_ascii_strcasecmp (method, "network") == 0 ) {
- return _("Network");
- } else if (g_ascii_strcasecmp (method, "fonts") == 0 ) {
- return _("Fonts");
- } else if (g_ascii_strcasecmp (method, "themes") == 0 ) {
- return _("Themes");
- } else if (g_ascii_strcasecmp (method, "burn") == 0 ) {
- return _("CD/DVD Creator");
- } else if (g_ascii_strcasecmp (method, "smb") == 0 ) {
- return _("Windows Network");
- } else if (g_ascii_strcasecmp (method, "dns-sd") == 0 ) {
- /* translators: this is the title of the "dns-sd:///" location */
- return _("Services in");
+ tmp = location;
+ location = g_file_get_parent (location);
+ g_object_unref (tmp);
}
- return NULL;
-}
-
-char *
-nautilus_get_uri_shortname_for_display (GnomeVFSURI *uri)
-{
- char *utf8_name, *name, *tmp;
- char *text_uri, *local_file;
- gboolean validated;
- const char *method;
-
- validated = FALSE;
- name = gnome_vfs_uri_extract_short_name (uri);
- if (name == NULL) {
- name = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
- } else if (g_ascii_strcasecmp (uri->method_string, "file") == 0) {
- text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
- local_file = gnome_vfs_get_local_path_from_uri (text_uri);
- g_free (name);
- if (local_file == NULL) { /* Happens for e.g. file:///# */
- local_file = g_strdup ("/");
- }
- name = g_filename_display_basename (local_file);
- g_free (local_file);
- g_free (text_uri);
- validated = TRUE;
- } else if (!gnome_vfs_uri_has_parent (uri)) {
- /* Special-case the display name for roots that are not local files */
- method = nautilus_get_vfs_method_display_name (uri->method_string);
- if (method == NULL) {
- method = uri->method_string;
- }
-
- if (name == NULL ||
- strcmp (name, GNOME_VFS_URI_PATH_STR) == 0) {
- g_free (name);
- name = g_strdup (method);
- } else {
- tmp = name;
- name = g_strdup_printf ("%s: %s", method, name);
- g_free (tmp);
- }
- }
-
- if (!validated && !g_utf8_validate (name, -1, NULL)) {
- utf8_name = eel_make_valid_utf8 (name);
- g_free (name);
- name = utf8_name;
- }
-
- return name;
+ return location;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index d55eed038..4f290ae37 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -25,7 +25,7 @@
#ifndef NAUTILUS_FILE_UTILITIES_H
#define NAUTILUS_FILE_UTILITIES_H
-#include <libgnomevfs/gnome-vfs-types.h>
+#include <gio/gfile.h>
#define NAUTILUS_SAVED_SEARCH_EXTENSION ".savedSearch"
#define NAUTILUS_SAVED_SEARCH_MIMETYPE "application/x-gnome-saved-search"
@@ -40,13 +40,16 @@ gboolean nautilus_file_name_matches_backup_pattern (const char *name_or_relati
char * nautilus_get_xdg_dir (const char *type);
char * nautilus_get_user_directory (void);
char * nautilus_get_desktop_directory (void);
+GFile * nautilus_get_desktop_location (void);
char * nautilus_get_desktop_directory_uri (void);
char * nautilus_get_home_directory_uri (void);
-gboolean nautilus_is_desktop_directory_file_escaped (char *escaped_dirname,
- char *escaped_filename);
-gboolean nautilus_is_desktop_directory_escaped (char *escaped_dir);
-gboolean nautilus_is_home_directory_file_escaped (char *escaped_dirname,
- char *escaped_file);
+gboolean nautilus_is_desktop_directory_file (GFile *dir,
+ const char *filename);
+gboolean nautilus_is_root_directory (GFile *dir);
+gboolean nautilus_is_desktop_directory (GFile *dir);
+gboolean nautilus_is_home_directory (GFile *dir);
+gboolean nautilus_is_home_directory_file (GFile *dir,
+ const char *filename);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
@@ -57,7 +60,7 @@ void nautilus_create_templates_directory (void);
char * nautilus_get_searches_directory (void);
-char * nautilus_compute_title_for_uri (const char *text_uri);
+char * nautilus_compute_title_for_location (GFile *file);
/* This function returns something that needs to be freed with g_free,
* is not NULL, but is not garaunteed to exist */
@@ -85,9 +88,6 @@ char * nautilus_ensure_unique_file_name (const char *directory_uri,
const char *extension);
char * nautilus_unique_temporary_file_name (void);
-char * nautilus_find_existing_uri_in_hierarchy (const char *uri);
-
-const char *nautilus_get_vfs_method_display_name (char *method);
-char * nautilus_get_uri_shortname_for_display (GnomeVFSURI *uri);
+GFile * nautilus_find_existing_uri_in_hierarchy (GFile *location);
#endif /* NAUTILUS_FILE_UTILITIES_H */
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 82694736d..e4d9f4ec1 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -28,6 +28,7 @@
#include "nautilus-directory-metafile.h"
#include "nautilus-directory-notify.h"
#include "nautilus-directory-private.h"
+#include "nautilus-signaller.h"
#include "nautilus-desktop-directory.h"
#include "nautilus-desktop-directory-file.h"
#include "nautilus-desktop-icon-file.h"
@@ -37,14 +38,11 @@
#include "nautilus-global-preferences.h"
#include "nautilus-lib-self-check-functions.h"
#include "nautilus-link.h"
-#include "nautilus-link-desktop-file.h"
#include "nautilus-metadata.h"
#include "nautilus-module.h"
#include "nautilus-search-directory.h"
#include "nautilus-search-directory-file.h"
#include "nautilus-thumbnails.h"
-#include "nautilus-trash-directory.h"
-#include "nautilus-trash-file.h"
#include "nautilus-users-groups-cache.h"
#include "nautilus-vfs-file.h"
#include "nautilus-saved-search-file.h"
@@ -57,14 +55,12 @@
#include <grp.h>
#include <gtk/gtksignal.h>
#include <glib/gi18n.h>
+#include <gio/gcontenttype.h>
+#include <glib/gurifuncs.h>
#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libgnomevfs/gnome-vfs-drive.h>
#include <glib/gfileutils.h>
+#include <gio/gthemedicon.h>
+#include <gio/gfileicon.h>
#include <libnautilus-extension/nautilus-file-info.h>
#include <libxml/parser.h>
#include <pwd.h>
@@ -80,6 +76,7 @@
/* Time in seconds to cache getpwuid results */
#define GETPWUID_CACHE_TIME (5*60)
+#define ICON_NAME_THUMBNAIL_LOADING "image-loading"
#undef NAUTILUS_FILE_DEBUG_REF
#undef NAUTILUS_FILE_DEBUG_REF_VALGRIND
@@ -106,15 +103,6 @@ typedef enum {
SHOW_BACKUP = 1 << 1
} FilterOptions;
-typedef struct {
- NautilusFile *file;
- GnomeVFSAsyncHandle *handle;
- NautilusFileOperationCallback callback;
- gpointer callback_data;
- gboolean is_rename;
- gboolean use_slow_mime;
-} Operation;
-
typedef void (* ModifyListFunction) (GList **list, NautilusFile *file);
enum {
@@ -138,10 +126,9 @@ static char * nautilus_file_get_owner_as_string (NautilusFile
gboolean include_real_name);
static char * nautilus_file_get_type_as_string (NautilusFile *file);
static gboolean update_info_and_name (NautilusFile *file,
- GnomeVFSFileInfo *info,
- gboolean info_has_slow_mime);
-static char * nautilus_file_get_display_name_nocopy (NautilusFile *file);
-static char * nautilus_file_get_display_name_collation_key (NautilusFile *file);
+ GFileInfo *info);
+static const char * nautilus_file_peek_display_name (NautilusFile *file);
+static const char * nautilus_file_peek_display_name_collation_key (NautilusFile *file);
GType
nautilus_file_get_type (void)
@@ -183,23 +170,173 @@ nautilus_file_instance_init (NautilusFile *file)
{
file->details = G_TYPE_INSTANCE_GET_PRIVATE ((file), NAUTILUS_TYPE_FILE, NautilusFileDetails);
+ nautilus_file_clear_info (file);
nautilus_file_invalidate_extension_info_internal (file);
}
+static GObject*
+nautilus_file_constructor (GType type,
+ guint n_construct_properties,
+ GObjectConstructParam *construct_params)
+{
+ GObject *object;
+ NautilusFile *file;
+
+ object = (* G_OBJECT_CLASS (parent_class)->constructor) (type,
+ n_construct_properties,
+ construct_params);
+
+ file = NAUTILUS_FILE (object);
+
+ /* Set to default type after full construction */
+ if (NAUTILUS_FILE_GET_CLASS (file)->default_file_type != G_FILE_TYPE_UNKNOWN) {
+ file->details->type = NAUTILUS_FILE_GET_CLASS (file)->default_file_type;
+ }
+
+ return object;
+}
+
+gboolean
+nautilus_file_set_display_name (NautilusFile *file,
+ const char *display_name,
+ const char *edit_name,
+ gboolean custom)
+{
+ gboolean changed;
+
+ if (display_name == NULL) {
+ return FALSE;
+ }
+
+ if (!custom && file->details->got_custom_display_name) {
+ return FALSE;
+ }
+
+ if (custom && display_name == NULL) {
+ /* We're re-setting a custom display name, invalidate it if
+ we already set it so that the old one is re-read */
+ if (file->details->got_custom_display_name) {
+ file->details->got_custom_display_name = FALSE;
+ nautilus_file_invalidate_attributes (file,
+ NAUTILUS_FILE_ATTRIBUTE_INFO);
+ }
+ return FALSE;
+ }
+
+ if (edit_name == NULL) {
+ edit_name = display_name;
+ }
+
+ changed = FALSE;
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->display_name), display_name) != 0) {
+ changed = TRUE;
+
+ eel_ref_str_unref (file->details->display_name);
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->name), display_name) == 0) {
+ file->details->display_name = eel_ref_str_ref (file->details->name);
+ } else {
+ file->details->display_name = eel_ref_str_new (display_name);
+ }
+
+ g_free (file->details->display_name_collation_key);
+ file->details->display_name_collation_key = g_utf8_collate_key_for_filename (display_name, -1);
+ }
+
+ if (eel_strcmp (eel_ref_str_peek (file->details->edit_name), edit_name) != 0) {
+ changed = TRUE;
+
+ eel_ref_str_unref (file->details->edit_name);
+ if (eel_strcmp (eel_ref_str_peek (file->details->display_name), edit_name) == 0) {
+ file->details->edit_name = eel_ref_str_ref (file->details->display_name);
+ } else {
+ file->details->edit_name = eel_ref_str_new (edit_name);
+ }
+ }
+
+ file->details->got_custom_display_name = custom;
+ return changed;
+}
+
+void
+nautilus_file_clear_info (NautilusFile *file)
+{
+ file->details->got_file_info = FALSE;
+ if (file->details->get_info_error) {
+ g_error_free (file->details->get_info_error);
+ file->details->get_info_error = NULL;
+ }
+ /* Reset to default type, which might be other than unknown for
+ special kinds of files like the desktop or a search directory */
+ file->details->type = NAUTILUS_FILE_GET_CLASS (file)->default_file_type;
+
+ if (!file->details->got_custom_display_name) {
+ eel_ref_str_unref (file->details->display_name);
+ file->details->display_name = NULL;
+ g_free (file->details->display_name_collation_key);
+ file->details->display_name_collation_key = NULL;
+ eel_ref_str_unref (file->details->edit_name);
+ file->details->edit_name = NULL;
+ }
+
+ if (!file->details->got_custom_activation_location &&
+ file->details->activation_location != NULL) {
+ g_object_unref (file->details->activation_location);
+ file->details->activation_location = NULL;
+ }
+
+ if (file->details->icon != NULL) {
+ g_object_unref (file->details->icon);
+ file->details->icon = NULL;
+ }
+
+ g_free (file->details->thumbnail_path);
+ file->details->thumbnail_path = NULL;
+ file->details->thumbnailing_failed = FALSE;
+
+ file->details->is_symlink = FALSE;
+ file->details->is_hidden = FALSE;
+ file->details->is_backup = FALSE;
+ file->details->is_mountpoint = FALSE;
+ file->details->uid = -1;
+ file->details->gid = -1;
+ file->details->can_read = TRUE;
+ file->details->can_write = TRUE;
+ file->details->can_execute = TRUE;
+ file->details->can_delete = TRUE;
+ file->details->can_trash = TRUE;
+ file->details->can_rename = TRUE;
+ file->details->can_mount = FALSE;
+ file->details->can_unmount = FALSE;
+ file->details->can_eject = FALSE;
+ file->details->has_permissions = FALSE;
+ file->details->permissions = 0;
+ file->details->size = -1;
+ file->details->sort_order = 0;
+ file->details->mtime = 0;
+ file->details->atime = 0;
+ file->details->ctime = 0;
+ g_free (file->details->symlink_name);
+ file->details->symlink_name = NULL;
+ eel_ref_str_unref (file->details->mime_type);
+ file->details->mime_type = NULL;
+ g_free (file->details->selinux_context);
+ file->details->selinux_context = NULL;
+}
+
static NautilusFile *
-nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
- const char *relative_uri,
- gboolean self_owned)
+nautilus_file_new_from_filename (NautilusDirectory *directory,
+ const char *filename,
+ gboolean self_owned)
{
NautilusFile *file;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
- g_return_val_if_fail (relative_uri != NULL, NULL);
- g_return_val_if_fail (relative_uri[0] != '\0', NULL);
+ g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (filename[0] != '\0', NULL);
- if (self_owned && NAUTILUS_IS_TRASH_DIRECTORY (directory)) {
- file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_TRASH_FILE, NULL));
- } else if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
+ if (NAUTILUS_IS_DESKTOP_DIRECTORY (directory)) {
if (self_owned) {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_DESKTOP_DIRECTORY_FILE, NULL));
} else {
@@ -215,16 +352,15 @@ nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
* that references a file like this. (See #349840) */
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
}
- } else if (g_str_has_suffix (relative_uri, NAUTILUS_SAVED_SEARCH_EXTENSION)) {
+ } else if (g_str_has_suffix (filename, NAUTILUS_SAVED_SEARCH_EXTENSION)) {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_SAVED_SEARCH_FILE, NULL));
} else {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
}
- nautilus_directory_ref (directory);
- file->details->directory = directory;
+ file->details->directory = nautilus_directory_ref (directory);
- file->details->relative_uri = g_strdup (relative_uri);
+ file->details->name = eel_ref_str_new (filename);
#ifdef NAUTILUS_FILE_DEBUG_REF
DEBUG_REF_PRINTF("%10p ref'd", file);
@@ -233,22 +369,6 @@ nautilus_file_new_from_relative_uri (NautilusDirectory *directory,
return file;
}
-gboolean
-nautilus_file_info_missing (NautilusFile *file, GnomeVFSFileInfoFields needed_mask)
-{
- GnomeVFSFileInfo *info;
-
- if (file == NULL) {
- return TRUE;
- }
-
- info = file->details->info;
- if (info == NULL) {
- return TRUE;
- }
- return (info->valid_fields & needed_mask) != needed_mask;
-}
-
static void
modify_link_hash_table (NautilusFile *file,
ModifyListFunction modify_function)
@@ -259,10 +379,7 @@ modify_link_hash_table (NautilusFile *file,
GList **list_ptr;
/* Check if there is a symlink name. If none, we are OK. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)) {
- return;
- }
- if (file->details->info->symlink_name == NULL) {
+ if (file->details->symlink_name == NULL) {
return;
}
@@ -280,7 +397,8 @@ modify_link_hash_table (NautilusFile *file,
&original_key, (gpointer *)&list_ptr);
if (!found) {
list_ptr = g_new0 (GList *, 1);
- g_hash_table_insert (symbolic_links, g_strdup (target_uri), list_ptr);
+ original_key = g_strdup (target_uri);
+ g_hash_table_insert (symbolic_links, original_key, list_ptr);
}
(* modify_function) (list_ptr, file);
if (*list_ptr == NULL) {
@@ -336,25 +454,26 @@ remove_from_link_hash_table (NautilusFile *file)
NautilusFile *
nautilus_file_new_from_info (NautilusDirectory *directory,
- GnomeVFSFileInfo *info)
+ GFileInfo *info)
{
NautilusFile *file;
+ const char *mime_type;
g_return_val_if_fail (NAUTILUS_IS_DIRECTORY (directory), NULL);
g_return_val_if_fail (info != NULL, NULL);
- if (info->mime_type &&
- strcmp (info->mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0) {
+ mime_type = g_file_info_get_content_type (info);
+ if (mime_type &&
+ strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0) {
+ g_file_info_set_file_type (info, G_FILE_TYPE_DIRECTORY);
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_SAVED_SEARCH_FILE, NULL));
} else {
file = NAUTILUS_FILE (g_object_new (NAUTILUS_TYPE_VFS_FILE, NULL));
}
- nautilus_directory_ref (directory);
- file->details->directory = directory;
-
- update_info_and_name (file, info, FALSE);
+ file->details->directory = nautilus_directory_ref (directory);
+ update_info_and_name (file, info);
#ifdef NAUTILUS_FILE_DEBUG_REF
DEBUG_REF_PRINTF("%10p ref'd", file);
@@ -363,116 +482,50 @@ nautilus_file_new_from_info (NautilusDirectory *directory,
return file;
}
-/**
- * nautilus_file_get_internal:
- * @uri: URI of file to get.
- *
- * Get a file given a uri.
- * Returns a referenced object. Unref when finished.
- * If two windows are viewing the same uri, the file object is shared.
- */
static NautilusFile *
-nautilus_file_get_internal (const char *uri, gboolean create)
+nautilus_file_get_internal (GFile *location, gboolean create)
{
- char *canonical_uri, *directory_uri, *relative_uri, *file_name;
- const char *relative_uri_tmp;
gboolean self_owned;
- GnomeVFSURI *vfs_uri, *directory_vfs_uri;
NautilusDirectory *directory;
NautilusFile *file;
+ GFile *parent;
+ char *basename;
- g_return_val_if_fail (uri != NULL, NULL);
-
- /* Maybe we wouldn't need this if the gnome-vfs canonical
- * stuff was strong enough.
- */
- canonical_uri = eel_make_uri_canonical (uri);
+ g_return_val_if_fail (location != NULL, NULL);
- /* Make VFS version of URI. */
- vfs_uri = gnome_vfs_uri_new (canonical_uri);
- relative_uri = NULL;
- if (vfs_uri != NULL) {
- relative_uri = gnome_vfs_uri_extract_short_path_name (vfs_uri);
-
- /* Couldn't parse a name out of the URI: the URI must be bogus,
- * so we'll treat it like the case where gnome_vfs_uri couldn't
- * even create a URI.
- */
- if (eel_str_is_empty (relative_uri)) {
- gnome_vfs_uri_unref (vfs_uri);
- vfs_uri = NULL;
- g_free (relative_uri);
- relative_uri = NULL;
- }
- }
-
- self_owned = FALSE;
- directory_uri = NULL;
+ parent = g_file_get_parent (location);
- /* Make VFS version of directory URI. */
- if (vfs_uri == NULL) {
- if (eel_uri_is_desktop (uri) &&
- !gnome_vfs_uris_match (uri, EEL_DESKTOP_URI)) {
- directory_uri = g_strdup (EEL_DESKTOP_URI);
- }
- } else {
- directory_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
- if (directory_vfs_uri != NULL) {
- directory_uri = gnome_vfs_uri_to_string
- (directory_vfs_uri,
- GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (directory_vfs_uri);
- }
- gnome_vfs_uri_unref (vfs_uri);
- }
-
- if (directory_uri == NULL) {
+ self_owned = FALSE;
+ if (parent == NULL) {
self_owned = TRUE;
- directory_uri = g_strdup (canonical_uri);
- }
+ parent = g_object_ref (location);
+ }
/* Get object that represents the directory. */
- directory = nautilus_directory_get_internal (directory_uri, create);
- g_free (directory_uri);
+ directory = nautilus_directory_get_internal (parent, create);
+
+ g_object_unref (parent);
/* Get the name for the file. */
- if (vfs_uri == NULL) {
- if (self_owned && directory != NULL) {
- file_name = nautilus_directory_get_name_for_self_as_new_file (directory);
- relative_uri = gnome_vfs_escape_string (file_name);
- g_free (file_name);
- } else if (eel_uri_is_desktop (uri) ||
- eel_uri_is_search (uri)) {
- /* Special case virtual methods like desktop and search
- files here. They have no vfs_uri. */
- relative_uri_tmp = uri;
- /* Skip "method:" */
- while (*relative_uri_tmp != 0 && *relative_uri_tmp != ':') {
- relative_uri_tmp++;
- }
- relative_uri_tmp++;
- /* Skip initial slashes */
- while (*relative_uri_tmp == '/') {
- relative_uri_tmp++;
- }
- relative_uri = strdup (relative_uri_tmp);
- }
+ if (self_owned && directory != NULL) {
+ basename = nautilus_directory_get_name_for_self_as_new_file (directory);
+ } else {
+ basename = g_file_get_basename (location);
}
-
/* Check to see if it's a file that's already known. */
if (directory == NULL) {
file = NULL;
} else if (self_owned) {
file = directory->details->as_file;
} else {
- file = nautilus_directory_find_file_by_relative_uri (directory, relative_uri);
+ file = nautilus_directory_find_file_by_name (directory, basename);
}
/* Ref or create the file. */
if (file != NULL) {
nautilus_file_ref (file);
} else if (create) {
- file = nautilus_file_new_from_relative_uri (directory, relative_uri, self_owned);
+ file = nautilus_file_new_from_filename (directory, basename, self_owned);
if (self_owned) {
g_assert (directory->details->as_file == NULL);
directory->details->as_file = file;
@@ -481,23 +534,48 @@ nautilus_file_get_internal (const char *uri, gboolean create)
}
}
- g_free (canonical_uri);
- g_free (relative_uri);
+ g_free (basename);
nautilus_directory_unref (directory);
return file;
}
NautilusFile *
-nautilus_file_get_existing (const char *uri)
+nautilus_file_get (GFile *location)
{
- return nautilus_file_get_internal (uri, FALSE);
+ return nautilus_file_get_internal (location, TRUE);
}
NautilusFile *
-nautilus_file_get (const char *uri)
+nautilus_file_get_existing (GFile *location)
{
- return nautilus_file_get_internal (uri, TRUE);
+ return nautilus_file_get_internal (location, FALSE);
+}
+
+NautilusFile *
+nautilus_file_get_existing_by_uri (const char *uri)
+{
+ GFile *location;
+ NautilusFile *file;
+
+ location = g_file_new_for_uri (uri);
+ file = nautilus_file_get_internal (location, FALSE);
+ g_object_unref (location);
+
+ return file;
+}
+
+NautilusFile *
+nautilus_file_get_by_uri (const char *uri)
+{
+ GFile *location;
+ NautilusFile *file;
+
+ location = g_file_new_for_uri (uri);
+ file = nautilus_file_get_internal (location, TRUE);
+ g_object_unref (location);
+
+ return file;
}
gboolean
@@ -537,19 +615,32 @@ finalize (GObject *object)
}
}
+ if (file->details->get_info_error) {
+ g_error_free (file->details->get_info_error);
+ }
+
nautilus_directory_unref (directory);
- g_free (file->details->relative_uri);
- g_free (file->details->cached_display_name);
+ eel_ref_str_unref (file->details->name);
+ eel_ref_str_unref (file->details->display_name);
g_free (file->details->display_name_collation_key);
- g_free (file->details->guessed_mime_type);
- if (file->details->info != NULL) {
- gnome_vfs_file_info_unref (file->details->info);
- }
+ eel_ref_str_unref (file->details->edit_name);
+ if (file->details->icon) {
+ g_object_unref (file->details->icon);
+ }
+ g_free (file->details->thumbnail_path);
+ g_free (file->details->symlink_name);
+ eel_ref_str_unref (file->details->mime_type);
+ g_free (file->details->selinux_context);
g_free (file->details->top_left_text);
- g_free (file->details->display_name);
g_free (file->details->custom_icon);
- g_free (file->details->activation_uri);
+ if (file->details->activation_location) {
+ g_object_unref (file->details->activation_location);
+ }
g_free (file->details->compare_by_emblem_cache);
+
+ if (file->details->thumbnail) {
+ g_object_unref (file->details->thumbnail);
+ }
eel_g_list_free_deep (file->details->mime_list);
@@ -612,14 +703,18 @@ nautilus_file_unref (NautilusFile *file)
char *
nautilus_file_get_parent_uri_for_display (NautilusFile *file)
{
- char *raw_uri;
+ GFile *parent;
char *result;
g_assert (NAUTILUS_IS_FILE (file));
- raw_uri = nautilus_file_get_parent_uri (file);
- result = eel_format_uri_for_display (raw_uri);
- g_free (raw_uri);
+ parent = nautilus_file_get_parent_location (file);
+ if (parent) {
+ result = g_file_get_parse_name (parent);
+ g_object_unref (parent);
+ } else {
+ result = g_strdup ("");
+ }
return result;
}
@@ -649,56 +744,29 @@ nautilus_file_get_parent_uri (NautilusFile *file)
return nautilus_directory_get_uri (file->details->directory);
}
-NautilusFile *
-nautilus_file_get_parent (NautilusFile *file)
+GFile *
+nautilus_file_get_parent_location (NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
if (nautilus_file_is_self_owned (file)) {
+ /* Callers expect an empty string, not a NULL. */
return NULL;
}
- return nautilus_directory_get_corresponding_file (file->details->directory);
+ return nautilus_directory_get_location (file->details->directory);
}
-/**
- * nautilus_file_denies_access_permission:
- *
- * Check whether the current file does not have a given permission
- * for the current user. The sense is negative because the function
- * returns FALSE if permissions cannot be determined.
- *
- * @file: The file to check.
- * @permissions: The permissions to check. Must be either
- * GNOME_VFS_PERM_ACCESS_READABLE, GNOME_VFS_PERM_ACCESS_WRITABLE,
- * GNOME_VFS_PERM_ACCESS_EXECUTABLE
- *
- * Return value: TRUE if the current user definitely does not have
- * the specified permission. FALSE if the current user does have
- * permission, or if the permissions themselves are not queryable.
- */
-static gboolean
-nautilus_file_denies_access_permission (NautilusFile *file,
- GnomeVFSFilePermissions permissions)
+NautilusFile *
+nautilus_file_get_parent (NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
- g_assert (permissions & (GNOME_VFS_PERM_ACCESS_READABLE |
- GNOME_VFS_PERM_ACCESS_WRITABLE |
- GNOME_VFS_PERM_ACCESS_EXECUTABLE));
- /* Once the file is gone, you are denied permission to do anything. */
- if (nautilus_file_is_gone (file)) {
- return TRUE;
+ if (nautilus_file_is_self_owned (file)) {
+ return NULL;
}
- /* File system does not provide permission bits.
- * Can't determine specific permissions, do not deny permission at all.
- */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_ACCESS)) {
- return FALSE;
- }
-
- return (file->details->info->permissions & permissions) != permissions;
+ return nautilus_directory_get_corresponding_file (file->details->directory);
}
/**
@@ -717,9 +785,8 @@ gboolean
nautilus_file_can_read (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
-
- return !nautilus_file_denies_access_permission
- (file, GNOME_VFS_PERM_ACCESS_READABLE);
+
+ return file->details->can_read;
}
/**
@@ -739,8 +806,7 @@ nautilus_file_can_write (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- return !nautilus_file_denies_access_permission
- (file, GNOME_VFS_PERM_ACCESS_WRITABLE);
+ return file->details->can_write;
}
/**
@@ -760,8 +826,92 @@ nautilus_file_can_execute (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- return !nautilus_file_denies_access_permission
- (file, GNOME_VFS_PERM_ACCESS_EXECUTABLE);
+ return file->details->can_execute;
+}
+
+gboolean
+nautilus_file_can_mount (NautilusFile *file)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+ return file->details->can_mount;
+}
+
+gboolean
+nautilus_file_can_unmount (NautilusFile *file)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+ return file->details->can_unmount;
+}
+
+gboolean
+nautilus_file_can_eject (NautilusFile *file)
+{
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
+
+ return file->details->can_eject;
+}
+
+void
+nautilus_file_mount (NautilusFile *file,
+ GMountOperation *mount_op,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ GError *error;
+
+ if (NAUTILUS_FILE_GET_CLASS (file)->mount == NULL) {
+ if (callback) {
+ error = NULL;
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("This file cannot be mounted"));
+ callback (file, NULL, error, callback_data);
+ g_error_free (error);
+ }
+ } else {
+ NAUTILUS_FILE_GET_CLASS (file)->mount (file, mount_op, callback, callback_data);
+ }
+}
+
+void
+nautilus_file_unmount (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ GError *error;
+
+ if (NAUTILUS_FILE_GET_CLASS (file)->unmount == NULL) {
+ if (callback) {
+ error = NULL;
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("This file cannot be unmounted"));
+ callback (file, NULL, error, callback_data);
+ g_error_free (error);
+ }
+ } else {
+ NAUTILUS_FILE_GET_CLASS (file)->unmount (file, callback, callback_data);
+ }
+}
+
+void
+nautilus_file_eject (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ GError *error;
+
+ if (NAUTILUS_FILE_GET_CLASS (file)->eject == NULL) {
+ if (callback) {
+ error = NULL;
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("This file cannot be eject"));
+ callback (file, NULL, error, callback_data);
+ g_error_free (error);
+ }
+ } else {
+ NAUTILUS_FILE_GET_CLASS (file)->eject (file, callback, callback_data);
+ }
}
/**
@@ -776,17 +926,15 @@ nautilus_file_can_execute (NautilusFile *file)
gboolean
nautilus_file_is_desktop_directory (NautilusFile *file)
{
- GnomeVFSURI *dir_vfs_uri;
+ GFile *dir;
- dir_vfs_uri = file->details->directory->details->vfs_uri;
+ dir = file->details->directory->details->location;
- if (dir_vfs_uri == NULL ||
- strcmp (dir_vfs_uri->method_string, "file") != 0) {
+ if (dir == NULL) {
return FALSE;
}
- return nautilus_is_desktop_directory_file_escaped (dir_vfs_uri->text,
- file->details->relative_uri);
+ return nautilus_is_desktop_directory_file (dir, eel_ref_str_peek (file->details->name));
}
static gboolean
@@ -798,13 +946,12 @@ is_desktop_file (NautilusFile *file)
static gboolean
can_rename_desktop_file (NautilusFile *file)
{
- char *uri;
+ GFile *location;
gboolean res;
- uri = nautilus_file_get_uri (file);
- res = !eel_vfs_has_capability (uri,
- EEL_VFS_CAPABILITY_IS_REMOTE_AND_SLOW);
- g_free (uri);
+ location = nautilus_file_get_location (file);
+ res = g_file_is_native (location);
+ g_object_unref (location);
return res;
}
@@ -823,9 +970,7 @@ can_rename_desktop_file (NautilusFile *file)
gboolean
nautilus_file_can_rename (NautilusFile *file)
{
- NautilusFile *parent;
gboolean can_rename;
- char *uri;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
@@ -845,7 +990,6 @@ nautilus_file_can_rename (NautilusFile *file)
}
can_rename = TRUE;
- uri = nautilus_file_get_uri (file);
/* Certain types of links can't be renamed */
if (NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
@@ -858,124 +1002,114 @@ nautilus_file_can_rename (NautilusFile *file)
g_object_unref (link);
}
}
-
- /* Nautilus trash directories cannot be renamed */
- if (eel_uri_is_trash_folder (uri)) {
- can_rename = FALSE;
- }
-
- g_free (uri);
if (!can_rename) {
return FALSE;
}
-
- /* User must have write permissions for the parent directory. */
- parent = nautilus_file_get_parent (file);
-
- /* No parent directory for some reason (at root level?).
- * Can't tell whether this file is renameable, so return TRUE.
- */
- if (parent == NULL) {
- return TRUE;
- }
-
- can_rename = nautilus_file_can_write (parent);
- nautilus_file_unref (parent);
-
- return can_rename;
+ return file->details->can_rename;
}
gboolean
-nautilus_file_has_volume (NautilusFile *file)
+nautilus_file_can_delete (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
-
- return file->details->has_volume;
+
+ /* Nonexistent files can't be deleted. */
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
+
+ /* Self-owned files can't be deleted */
+ if (nautilus_file_is_self_owned (file)) {
+ return FALSE;
+ }
+
+ return file->details->can_delete;
}
gboolean
-nautilus_file_has_drive (NautilusFile *file)
+nautilus_file_can_trash (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
-
- return file->details->has_drive;
-}
-void
-nautilus_file_set_volume (NautilusFile *file,
- GnomeVFSVolume *volume)
-{
- file->details->has_volume = volume != NULL;
- gnome_vfs_volume_ref (volume);
- g_object_set_data_full (G_OBJECT (file),
- "nautilus_file_volume",
- volume,
- (GDestroyNotify)gnome_vfs_volume_unref);
-
-}
+ /* Nonexistent files can't be deleted. */
+ if (nautilus_file_is_gone (file)) {
+ return FALSE;
+ }
-void
-nautilus_file_set_drive (NautilusFile *file,
- GnomeVFSDrive *drive)
-{
- file->details->has_drive = drive != NULL;
- gnome_vfs_drive_ref (drive);
- g_object_set_data_full (G_OBJECT (file),
- "nautilus_file_drive",
- drive,
- (GDestroyNotify)gnome_vfs_drive_unref);
-}
+ /* Self-owned files can't be deleted */
+ if (nautilus_file_is_self_owned (file)) {
+ return FALSE;
+ }
+ return file->details->can_trash;
+}
-GnomeVFSVolume *
-nautilus_file_get_volume (NautilusFile *file)
+GFile *
+nautilus_file_get_location (NautilusFile *file)
{
- return g_object_get_data (G_OBJECT (file),
- "nautilus_file_volume");
+ GFile *dir;
+
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
+ dir = file->details->directory->details->location;
+
+ if (nautilus_file_is_self_owned (file)) {
+ return g_object_ref (dir);
+ }
+
+ return g_file_get_child (dir, eel_ref_str_peek (file->details->name));
}
-GnomeVFSDrive *
-nautilus_file_get_drive (NautilusFile *file)
+/* Return the actual uri associated with the passed-in file. */
+char *
+nautilus_file_get_uri (NautilusFile *file)
{
- return g_object_get_data (G_OBJECT (file),
- "nautilus_file_drive");
+ char *uri;
+ GFile *loc;
+
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
+
+ loc = nautilus_file_get_location (file);
+ uri = g_file_get_uri (loc);
+ g_object_unref (loc);
+
+ return uri;
}
-static GnomeVFSURI *
-nautilus_file_get_gnome_vfs_uri (NautilusFile *file)
+char *
+nautilus_file_get_uri_scheme (NautilusFile *file)
{
- GnomeVFSURI *vfs_uri;
+ GFile *loc;
+ char *scheme;
+
+ g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- vfs_uri = file->details->directory->details->vfs_uri;
- if (vfs_uri == NULL) {
+ if (file->details->directory == NULL ||
+ file->details->directory->details->location == NULL) {
return NULL;
}
- if (nautilus_file_is_self_owned (file)) {
- gnome_vfs_uri_ref (vfs_uri);
- return vfs_uri;
- }
-
- return gnome_vfs_uri_append_string
- (vfs_uri, file->details->relative_uri);
+ loc = nautilus_directory_get_location (file->details->directory);
+ scheme = g_file_get_uri_scheme (loc);
+ g_object_unref (loc);
+
+ return scheme;
}
-static Operation *
-operation_new (NautilusFile *file,
- NautilusFileOperationCallback callback,
- gpointer callback_data)
+NautilusFileOperation *
+nautilus_file_operation_new (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
{
- Operation *op;
-
- nautilus_file_ref (file);
+ NautilusFileOperation *op;
- op = g_new0 (Operation, 1);
- op->file = file;
+ op = g_new0 (NautilusFileOperation, 1);
+ op->file = nautilus_file_ref (file);
op->callback = callback;
op->callback_data = callback_data;
+ op->cancellable = g_cancellable_new ();
op->file->details->operations_in_progress = g_list_prepend
(op->file->details->operations_in_progress, op);
@@ -984,157 +1118,182 @@ operation_new (NautilusFile *file,
}
static void
-operation_remove (Operation *op)
+nautilus_file_operation_remove (NautilusFileOperation *op)
{
op->file->details->operations_in_progress = g_list_remove
(op->file->details->operations_in_progress, op);
-
}
-static void
-operation_free (Operation *op)
+void
+nautilus_file_operation_free (NautilusFileOperation *op)
{
- operation_remove (op);
+ nautilus_file_operation_remove (op);
nautilus_file_unref (op->file);
+ g_object_unref (op->cancellable);
+ if (op->free_data) {
+ op->free_data (op->data);
+ }
g_free (op);
}
-static void
-operation_complete (Operation *op,
- GnomeVFSResult result)
+void
+nautilus_file_operation_complete (NautilusFileOperation *op, GFile *result_file, GError *error)
{
/* Claim that something changed even if the operation failed.
* This makes it easier for some clients who see the "reverting"
* as "changing back".
*/
- operation_remove (op);
+ nautilus_file_operation_remove (op);
nautilus_file_changed (op->file);
- (* op->callback) (op->file, result, op->callback_data);
- operation_free (op);
+ if (op->callback) {
+ (* op->callback) (op->file, result_file, error, op->callback_data);
+ }
+ nautilus_file_operation_free (op);
}
-static void
-operation_cancel (Operation *op)
+void
+nautilus_file_operation_cancel (NautilusFileOperation *op)
{
/* Cancel the operation if it's still in progress. */
- g_assert (op->handle != NULL);
- gnome_vfs_async_cancel (op->handle);
-
- /* Claim that something changed even though the operation was
- * canceled in case some work was partly done, but don't call
- * the callback.
- */
- nautilus_file_changed (op->file);
- operation_free (op);
-}
-
-static gboolean
-has_local_path (NautilusFile *file)
-{
- return eel_str_has_prefix (file->details->directory->details->uri, "file:");
+ g_cancellable_cancel (op->cancellable);
}
static void
-rename_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GnomeVFSFileInfo *new_info,
- gpointer callback_data)
+rename_get_info_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer callback_data)
{
- Operation *op;
+ NautilusFileOperation *op;
NautilusDirectory *directory;
NautilusFile *existing_file;
- char *old_relative_uri;
+ char *old_name;
char *old_uri;
char *new_uri;
-
+ const char *new_name;
+ GFileInfo *new_info;
+ GError *error;
+
op = callback_data;
- g_assert (handle == op->handle);
- if (result == GNOME_VFS_OK && new_info != NULL) {
+ error = NULL;
+ new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
+ if (new_info != NULL) {
directory = op->file->details->directory;
+
+ new_name = g_file_info_get_name (new_info);
/* If there was another file by the same name in this
* directory, mark it gone.
*/
- existing_file = nautilus_directory_find_file_by_name (directory, new_info->name);
+ existing_file = nautilus_directory_find_file_by_name (directory, new_name);
if (existing_file != NULL) {
nautilus_file_mark_gone (existing_file);
nautilus_file_changed (existing_file);
}
old_uri = nautilus_file_get_uri (op->file);
- old_relative_uri = g_strdup (op->file->details->relative_uri);
-
- update_info_and_name (op->file, new_info, op->use_slow_mime);
-
+ old_name = g_strdup (eel_ref_str_peek (op->file->details->name));
+
+ update_info_and_name (op->file, new_info);
+
/* Self-owned files store their metadata under the
* hard-code name "." so there's no need to rename
* their metadata when they are renamed.
*/
if (!nautilus_file_is_self_owned (op->file)) {
nautilus_directory_rename_file_metadata
- (directory, old_relative_uri, op->file->details->relative_uri);
+ (directory, old_name, eel_ref_str_peek (op->file->details->name));
}
-
- g_free (old_relative_uri);
-
+
+ g_free (old_name);
+
new_uri = nautilus_file_get_uri (op->file);
nautilus_directory_moved (old_uri, new_uri);
g_free (new_uri);
g_free (old_uri);
-
-
+
/* the rename could have affected the display name if e.g.
* we're in a vfolder where the name comes from a desktop file
* and a rename affects the contents of the desktop file.
*/
- if (op->file->details->display_name != NULL) {
+ if (op->file->details->got_custom_display_name) {
nautilus_file_invalidate_attributes (op->file,
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME);
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO);
}
+
+ g_object_unref (new_info);
+ }
+ nautilus_file_operation_complete (op, NULL, error);
+ if (error) {
+ g_error_free (error);
+ }
+}
+
+static void
+rename_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GFile *new_file;
+ GError *error;
+
+ op = callback_data;
+
+ error = NULL;
+ new_file = g_file_set_display_name_finish (G_FILE (source_object),
+ res, &error);
+
+ if (new_file != NULL) {
+ g_file_query_info_async (new_file,
+ NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
+ 0,
+ G_PRIORITY_DEFAULT,
+ op->cancellable,
+ rename_get_info_callback, op);
+ } else {
+ nautilus_file_operation_complete (op, NULL, error);
+ g_error_free (error);
}
- operation_complete (op, result);
}
static gboolean
name_is (NautilusFile *file, const char *new_name)
{
- char *old_name;
- gboolean equal;
-
- old_name = nautilus_file_get_name (file);
- equal = strcmp (new_name, old_name) == 0;
- g_free (old_name);
- return equal;
+ const char *old_name;
+ old_name = eel_ref_str_peek (file->details->name);
+ return strcmp (new_name, old_name) == 0;
}
-static void
-rename_guts (NautilusFile *file,
- const char *new_name,
- NautilusFileOperationCallback callback,
- gpointer callback_data)
-{
- Operation *op;
- GnomeVFSFileInfo *partial_file_info;
- GnomeVFSURI *vfs_uri;
- char *uri, *old_name;
+void
+nautilus_file_rename (NautilusFile *file,
+ const char *new_name,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ char *uri;
+ char *old_name;
gboolean success;
gboolean is_renameable_desktop_file;
- GnomeVFSFileInfoOptions options;
+ GFile *location;
+ GError *error;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
g_return_if_fail (callback != NULL);
- uri = nautilus_file_get_uri (file);
is_renameable_desktop_file =
is_desktop_file (file) && can_rename_desktop_file (file);
/* Return an error for incoming names containing path separators.
* But not for .desktop files as '/' are allowed for them */
if (strstr (new_name, "/") != NULL && !is_renameable_desktop_file) {
- (* callback) (file, GNOME_VFS_ERROR_NOT_PERMITTED, callback_data);
- g_free (uri);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Slashes are not allowed in filenames"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
@@ -1149,18 +1308,19 @@ rename_guts (NautilusFile *file,
* back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_NOT_FOUND, callback_data);
- g_free (uri);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ _("File not found"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
/* Test the name-hasn't-changed case explicitly, for two reasons.
- * (1) gnome_vfs_async_xfer returns an error if new & old are same.
+ * (1) rename returns an error if new & old are same.
* (2) We don't want to send file-changed signal if nothing changed.
*/
if (name_is (file, new_name)) {
- (* callback) (file, GNOME_VFS_OK, callback_data);
- g_free (uri);
+ (* callback) (file, NULL, NULL, callback_data);
return;
}
@@ -1174,12 +1334,14 @@ rename_guts (NautilusFile *file,
* back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_NOT_SUPPORTED, callback_data);
- g_free (uri);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("Toplevel files cannot be renamed"));
+
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
-
if (NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
NautilusDesktopLink *link;
@@ -1187,13 +1349,15 @@ rename_guts (NautilusFile *file,
if (link != NULL &&
nautilus_desktop_link_rename (link, new_name)) {
- (* callback) (file, GNOME_VFS_OK, callback_data);
+ (* callback) (file, NULL, NULL, callback_data);
} else {
- (* callback) (file, GNOME_VFS_ERROR_GENERIC, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unable to rename desktop icon"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
}
g_object_unref (link);
- g_free (uri);
return;
}
@@ -1202,86 +1366,52 @@ rename_guts (NautilusFile *file,
* This helps for the vfolder method where this can happen and
* we want to minimize actual changes
*/
- old_name = nautilus_link_desktop_file_local_get_text (uri);
+ uri = nautilus_file_get_uri (file);
+ old_name = nautilus_link_local_get_text (uri);
if (old_name != NULL && strcmp (new_name, old_name) == 0) {
success = TRUE;
} else {
- success = nautilus_link_desktop_file_local_set_text (uri, new_name);
+ success = nautilus_link_local_set_text (uri, new_name);
}
g_free (old_name);
g_free (uri);
if (success) {
nautilus_file_invalidate_attributes (file,
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME);
- (* callback) (file, GNOME_VFS_OK, callback_data);
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO);
+ (* callback) (file, NULL, NULL, callback_data);
return;
} else {
- (* callback) (file, GNOME_VFS_ERROR_GENERIC, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
+ _("Unable to rename desktop file"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
}
- g_free (uri);
/* Set up a renaming operation. */
- op = operation_new (file, callback, callback_data);
+ op = nautilus_file_operation_new (file, callback, callback_data);
op->is_rename = TRUE;
- op->use_slow_mime = file->details->got_slow_mime_type;
-
- options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS;
- if (op->use_slow_mime) {
- options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE;
- }
/* Do the renaming. */
- partial_file_info = gnome_vfs_file_info_new ();
- partial_file_info->name = g_strdup (new_name);
- vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
- gnome_vfs_async_set_file_info (&op->handle,
- vfs_uri, partial_file_info,
- GNOME_VFS_SET_FILE_INFO_NAME,
- options,
- GNOME_VFS_PRIORITY_DEFAULT,
- rename_callback, op);
- gnome_vfs_file_info_unref (partial_file_info);
- gnome_vfs_uri_unref (vfs_uri);
-}
-
-void
-nautilus_file_rename (NautilusFile *file,
- const char *new_name,
- NautilusFileOperationCallback callback,
- gpointer callback_data)
-{
- char *locale_name;
- gboolean utf8_filenames;
- const char *filename_charset;
-
- utf8_filenames = eel_get_filename_charset (&filename_charset);
- /* Note: Desktop file renaming wants utf8, even with G_BROKEN_FILENAMES */
- if (has_local_path (file) && !utf8_filenames &&
- !is_desktop_file (file)) {
- locale_name = g_filename_from_utf8 (new_name, -1, NULL, NULL, NULL);
- if (locale_name == NULL) {
- (* callback) (file, GNOME_VFS_ERROR_NOT_PERMITTED, callback_data);
- return;
- }
-
- rename_guts (file, locale_name, callback, callback_data);
- g_free (locale_name);
- return;
- }
-
- rename_guts (file, new_name, callback, callback_data);
- return;
+ location = nautilus_file_get_location (file);
+ g_file_set_display_name_async (location,
+ new_name,
+ G_PRIORITY_DEFAULT,
+ op->cancellable,
+ rename_callback,
+ op);
+ g_object_unref (location);
}
gboolean
nautilus_file_rename_in_progress (NautilusFile *file)
{
GList *node;
- Operation *op;
+ NautilusFileOperation *op;
for (node = file->details->operations_in_progress; node != NULL; node = node->next) {
op = node->data;
@@ -1298,16 +1428,15 @@ nautilus_file_cancel (NautilusFile *file,
gpointer callback_data)
{
GList *node, *next;
- Operation *op;
+ NautilusFileOperation *op;
for (node = file->details->operations_in_progress; node != NULL; node = next) {
next = node->next;
op = node->data;
g_assert (op->file == file);
- if (op->callback == callback
- && op->callback_data == callback_data) {
- operation_cancel (op);
+ if (op->callback == callback && op->callback_data == callback_data) {
+ nautilus_file_operation_cancel (op);
}
}
}
@@ -1315,30 +1444,17 @@ nautilus_file_cancel (NautilusFile *file,
gboolean
nautilus_file_matches_uri (NautilusFile *file, const char *match_uri)
{
- GnomeVFSURI *match_vfs_uri, *file_vfs_uri;
- char *file_uri;
+ GFile *match_file, *location;
gboolean result;
-
+
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
g_return_val_if_fail (match_uri != NULL, FALSE);
-
- match_vfs_uri = gnome_vfs_uri_new (match_uri);
- file_vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
-
- if (match_vfs_uri == NULL || file_vfs_uri == NULL) {
- file_uri = nautilus_file_get_uri (file);
- result = strcmp (match_uri, file_uri) == 0;
- g_free (file_uri);
- } else {
- result = gnome_vfs_uri_equal (file_vfs_uri, match_vfs_uri);
- }
-
- if (file_vfs_uri != NULL) {
- gnome_vfs_uri_unref (file_vfs_uri);
- }
- if (match_vfs_uri != NULL) {
- gnome_vfs_uri_unref (match_vfs_uri);
- }
+
+ location = nautilus_file_get_location (file);
+ match_file = g_file_new_for_uri (match_uri);
+ result = g_file_equal (location, match_file);
+ g_object_unref (location);
+ g_object_unref (match_file);
return result;
}
@@ -1356,7 +1472,6 @@ update_link (NautilusFile *link_file, NautilusFile *target_file)
{
g_assert (NAUTILUS_IS_FILE (link_file));
g_assert (NAUTILUS_IS_FILE (target_file));
- g_assert (!nautilus_file_info_missing (link_file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME));
/* FIXME bugzilla.gnome.org 42044: If we don't put any code
* here then the hash table is a waste of time.
@@ -1396,14 +1511,26 @@ update_links_if_target (NautilusFile *target_file)
static gboolean
update_info_internal (NautilusFile *file,
- GnomeVFSFileInfo *info,
- gboolean update_name,
- gboolean info_has_slow_mime)
+ GFileInfo *info,
+ gboolean update_name)
{
GList *node;
- GnomeVFSFileInfo *info_copy;
- char *new_relative_uri;
-
+ gboolean changed;
+ gboolean is_symlink, is_hidden, is_backup, is_mountpoint;
+ gboolean has_permissions;
+ guint32 permissions;
+ gboolean can_read, can_write, can_execute, can_delete, can_trash, can_rename, can_mount, can_unmount, can_eject;
+ gboolean thumbnailing_failed;
+ int uid, gid;
+ goffset size;
+ int sort_order;
+ time_t atime, mtime, ctime;
+ const char *symlink_name, *mime_type, *selinux_context, *name, *thumbnail_path;
+ GFileType file_type;
+ GIcon *icon;
+ GFile *old_activation_location;
+ const char *activation_uri;
+
if (file->details->is_gone) {
return FALSE;
}
@@ -1414,18 +1541,6 @@ update_info_internal (NautilusFile *file,
}
file->details->file_info_is_up_to_date = TRUE;
- file->details->got_slow_mime_type = info_has_slow_mime;
-
- if (!info_has_slow_mime || file->details->guessed_mime_type == NULL) {
- g_free (file->details->guessed_mime_type);
- file->details->guessed_mime_type = g_strdup (info->mime_type);
- }
-
- if (file->details->info != NULL
- && gnome_vfs_file_info_matches (file->details->info, info)) {
- return FALSE;
- }
-
/* FIXME bugzilla.gnome.org 42044: Need to let links that
* point to the old name know that the file has been renamed.
@@ -1433,59 +1548,276 @@ update_info_internal (NautilusFile *file,
remove_from_link_hash_table (file);
- info_copy = gnome_vfs_file_info_dup (info);
- if (file->details->info != NULL) {
- gnome_vfs_file_info_unref (file->details->info);
+ changed = FALSE;
+
+ if (!file->details->got_file_info) {
+ changed = TRUE;
}
- file->details->info = info_copy;
+ file->details->got_file_info = TRUE;
- if (update_name) {
- new_relative_uri = gnome_vfs_escape_string (info->name);
- if (file->details->relative_uri != NULL
- && strcmp (file->details->relative_uri, new_relative_uri) == 0) {
- g_free (new_relative_uri);
+ changed |= nautilus_file_set_display_name (file,
+ g_file_info_get_display_name (info),
+ g_file_info_get_edit_name (info),
+ FALSE);
+
+ file_type = g_file_info_get_file_type (info);
+ if (file->details->type != file_type) {
+ changed = TRUE;
+ }
+ file->details->type = file_type;
+
+ if (!file->details->got_custom_activation_location) {
+ activation_uri = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STD_TARGET_URI);
+ if (activation_uri == NULL) {
+ if (file->details->activation_location) {
+ g_object_unref (file->details->activation_location);
+ file->details->activation_location = NULL;
+ changed = TRUE;
+ }
} else {
+ old_activation_location = file->details->activation_location;
+ file->details->activation_location = g_file_new_for_uri (activation_uri);
+
+ if (old_activation_location) {
+ if (!g_file_equal (old_activation_location,
+ file->details->activation_location)) {
+ changed = TRUE;
+ }
+ g_object_unref (old_activation_location);
+ } else {
+ changed = TRUE;
+ }
+ }
+ }
+
+ is_symlink = g_file_info_get_is_symlink (info);
+ if (file->details->is_symlink != is_symlink) {
+ changed = TRUE;
+ }
+ file->details->is_symlink = is_symlink;
+
+ is_hidden = g_file_info_get_is_hidden (info);
+ if (file->details->is_hidden != is_hidden) {
+ changed = TRUE;
+ }
+ file->details->is_hidden = is_hidden;
+
+ is_backup = g_file_info_get_is_backup (info);
+ if (file->details->is_backup != is_backup) {
+ changed = TRUE;
+ }
+ file->details->is_backup = is_backup;
+
+ is_mountpoint = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT);
+ if (file->details->is_mountpoint != is_mountpoint) {
+ changed = TRUE;
+ }
+ file->details->is_mountpoint = is_mountpoint;
+
+ has_permissions = g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_MODE);
+ permissions = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE);;
+ if (file->details->has_permissions != has_permissions ||
+ file->details->permissions != permissions) {
+ changed = TRUE;
+ }
+ file->details->has_permissions = has_permissions;
+ file->details->permissions = permissions;
+
+ /* We default to TRUE for this if we can't know */
+ can_read = TRUE;
+ can_write = TRUE;
+ can_execute = TRUE;
+ can_delete = TRUE;
+ can_trash = TRUE;
+ can_rename = TRUE;
+ can_mount = FALSE;
+ can_unmount = FALSE;
+ can_eject = FALSE;
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_READ)) {
+ can_read = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE)) {
+ can_write = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)) {
+ can_execute = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE)) {
+ can_delete = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH)) {
+ can_trash = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME)) {
+ can_rename = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT)) {
+ can_mount = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT)) {
+ can_unmount = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT)) {
+ can_eject = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT);
+ }
+ if (file->details->can_read != can_read ||
+ file->details->can_write != can_write ||
+ file->details->can_execute != can_execute ||
+ file->details->can_delete != can_delete ||
+ file->details->can_trash != can_trash ||
+ file->details->can_rename != can_rename ||
+ file->details->can_mount != can_mount ||
+ file->details->can_unmount != can_unmount ||
+ file->details->can_eject != can_eject) {
+ changed = TRUE;
+ }
+
+ file->details->can_read = can_read;
+ file->details->can_write = can_write;
+ file->details->can_execute = can_execute;
+ file->details->can_delete = can_delete;
+ file->details->can_trash = can_trash;
+ file->details->can_rename = can_rename;
+ file->details->can_mount = can_mount;
+ file->details->can_unmount = can_unmount;
+ file->details->can_eject = can_eject;
+
+ uid = -1;
+ gid = -1;
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_UID)) {
+ uid = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID);
+ }
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_UNIX_GID)) {
+ gid = g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID);
+ }
+ if (file->details->uid != uid ||
+ file->details->gid != gid) {
+ changed = TRUE;
+ }
+ file->details->uid = uid;
+ file->details->gid = gid;
+
+ size = -1;
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STD_SIZE)) {
+ size = g_file_info_get_size (info);
+ }
+ if (file->details->size != size) {
+ changed = TRUE;
+ }
+ file->details->size = size;
+
+ sort_order = g_file_info_get_sort_order (info);
+ if (file->details->sort_order != sort_order) {
+ changed = TRUE;
+ }
+ file->details->sort_order = sort_order;
+
+ atime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS);
+ ctime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CHANGED);
+ mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ if (file->details->atime != atime ||
+ file->details->mtime != mtime ||
+ file->details->ctime != ctime) {
+ changed = TRUE;
+ }
+ file->details->atime = atime;
+ file->details->ctime = ctime;
+ file->details->mtime = mtime;
+
+ icon = g_file_info_get_icon (info);
+ if (!g_icon_equal (icon, file->details->icon)) {
+ changed = TRUE;
+
+ if (file->details->icon) {
+ g_object_unref (file->details->icon);
+ }
+ file->details->icon = g_object_ref (icon);
+ }
+
+ thumbnail_path = g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH);
+ if (eel_strcmp (file->details->thumbnail_path, thumbnail_path) != 0) {
+ changed = TRUE;
+ g_free (file->details->thumbnail_path);
+ file->details->thumbnail_path = g_strdup (thumbnail_path);
+ }
+
+ thumbnailing_failed = g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED);
+ if (file->details->thumbnailing_failed != thumbnailing_failed) {
+ changed = TRUE;
+ file->details->thumbnailing_failed = thumbnailing_failed;
+ }
+
+ symlink_name = g_file_info_get_symlink_target (info);
+ if (eel_strcmp (file->details->symlink_name, symlink_name) != 0) {
+ changed = TRUE;
+ g_free (file->details->symlink_name);
+ file->details->symlink_name = g_strdup (symlink_name);
+ }
+
+ mime_type = g_file_info_get_content_type (info);
+ if (eel_strcmp (eel_ref_str_peek (file->details->mime_type), mime_type) != 0) {
+ changed = TRUE;
+ }
+ eel_ref_str_unref (file->details->mime_type);
+ file->details->mime_type = eel_ref_str_get_unique (mime_type);
+
+ selinux_context = g_file_info_get_attribute_string (info, "selinux:context");
+ if (eel_strcmp (file->details->selinux_context, selinux_context) != 0) {
+ changed = TRUE;
+ g_free (file->details->selinux_context);
+ file->details->selinux_context = g_strdup (selinux_context);
+ }
+
+ if (update_name) {
+ name = g_file_info_get_name (info);
+ if (file->details->name == NULL ||
+ strcmp (eel_ref_str_peek (file->details->name), name) != 0) {
node = nautilus_directory_begin_file_name_change
(file->details->directory, file);
- g_free (file->details->relative_uri);
- file->details->relative_uri = new_relative_uri;
- nautilus_file_clear_cached_display_name (file);
-
- /* Since the name changes the old guessed mime type is now
- * incorrect. This might be the slow mime type instead, but
- * by now the user should have seen the warning dialog, so
- * thats not a horrible mistake
- */
- g_free (file->details->guessed_mime_type);
- file->details->guessed_mime_type = g_strdup (info->mime_type);
-
+ eel_ref_str_unref (file->details->name);
+ if (eel_strcmp (eel_ref_str_peek (file->details->display_name),
+ name) == 0) {
+ file->details->name = eel_ref_str_ref (file->details->display_name);
+ } else {
+ file->details->name = eel_ref_str_new (name);
+ }
+
nautilus_directory_end_file_name_change
(file->details->directory, file, node);
}
}
- add_to_link_hash_table (file);
-
- update_links_if_target (file);
+ if (changed) {
+ add_to_link_hash_table (file);
+
+ update_links_if_target (file);
+ }
- return TRUE;
+ return changed;
}
static gboolean
update_info_and_name (NautilusFile *file,
- GnomeVFSFileInfo *info,
- gboolean info_has_slow_mime)
+ GFileInfo *info)
{
- return update_info_internal (file, info, TRUE, info_has_slow_mime);
+ return update_info_internal (file, info, TRUE);
}
gboolean
nautilus_file_update_info (NautilusFile *file,
- GnomeVFSFileInfo *info,
- gboolean info_has_slow_mime)
+ GFileInfo *info)
{
- return update_info_internal (file, info, FALSE, info_has_slow_mime);
+ return update_info_internal (file, info, FALSE);
}
static gboolean
@@ -1494,7 +1826,6 @@ update_name_internal (NautilusFile *file,
gboolean in_directory)
{
GList *node;
- char *new_relative_uri;
g_assert (name != NULL);
@@ -1506,33 +1837,23 @@ update_name_internal (NautilusFile *file,
return FALSE;
}
- new_relative_uri = gnome_vfs_escape_string (name);
-
- if (file->details->info) {
- g_free (file->details->info->name);
- file->details->info->name = g_strdup (name);
- }
-
node = NULL;
if (in_directory) {
node = nautilus_directory_begin_file_name_change
(file->details->directory, file);
}
- g_free (file->details->relative_uri);
- file->details->relative_uri = new_relative_uri;
- nautilus_file_clear_cached_display_name (file);
+ eel_ref_str_unref (file->details->name);
+ file->details->name = eel_ref_str_new (name);
if (in_directory) {
nautilus_directory_end_file_name_change
(file->details->directory, file, node);
}
-
return TRUE;
}
-
gboolean
nautilus_file_update_name (NautilusFile *file, const char *name)
{
@@ -1581,8 +1902,7 @@ nautilus_file_update_name_and_directory (NautilusFile *file,
monitors = nautilus_directory_remove_file_monitors (old_directory, file);
nautilus_directory_remove_file (old_directory, file);
- nautilus_directory_ref (new_directory);
- file->details->directory = new_directory;
+ file->details->directory = nautilus_directory_ref (new_directory);
nautilus_directory_unref (old_directory);
if (name) {
@@ -1627,7 +1947,7 @@ get_item_count (NautilusFile *file,
static Knowledge
get_size (NautilusFile *file,
- GnomeVFSFileSize *size)
+ goffset *size)
{
/* If we tried and failed, then treat it like there is no size
* to know.
@@ -1639,7 +1959,7 @@ get_size (NautilusFile *file,
/* If the info is NULL that means we haven't even tried yet,
* so it's just unknown, not unknowable.
*/
- if (file->details->info == NULL) {
+ if (!file->details->got_file_info) {
return UNKNOWN;
}
@@ -1647,21 +1967,21 @@ get_size (NautilusFile *file,
* such thing as a size as far as gnome-vfs is concerned,
* so "unknowable".
*/
- if ((file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_SIZE) == 0) {
+ if (file->details->size == -1) {
return UNKNOWABLE;
}
/* We have a size! */
- *size = file->details->info->size;
+ *size = file->details->size;
return KNOWN;
}
static Knowledge
get_time (NautilusFile *file,
- time_t *time,
+ time_t *time_out,
NautilusDateType type)
{
- GnomeVFSFileInfoFields field;
+ time_t time;
/* If we tried and failed, then treat it like there is no size
* to know.
@@ -1673,32 +1993,32 @@ get_time (NautilusFile *file,
/* If the info is NULL that means we haven't even tried yet,
* so it's just unknown, not unknowable.
*/
- if (file->details->info == NULL) {
+ if (!file->details->got_file_info) {
return UNKNOWN;
}
+ time = 0;
switch (type) {
case NAUTILUS_DATE_TYPE_MODIFIED:
- field = GNOME_VFS_FILE_INFO_FIELDS_MTIME;
- *time = file->details->info->mtime;
+ time = file->details->mtime;
break;
case NAUTILUS_DATE_TYPE_ACCESSED:
- field = GNOME_VFS_FILE_INFO_FIELDS_ATIME;
- *time = file->details->info->atime;
+ time = file->details->atime;
break;
default:
g_assert_not_reached ();
break;
}
+ *time_out = time;
+
/* If we got info with no modification time in it, it means
* there is no such thing as a modification time as far as
* gnome-vfs is concerned, so "unknowable".
*/
- if ((file->details->info->valid_fields & field) == 0) {
+ if (time == 0) {
return UNKNOWABLE;
}
-
return KNOWN;
}
@@ -1753,7 +2073,7 @@ compare_files_by_size (NautilusFile *file_1, NautilusFile *file_2)
*/
Knowledge size_known_1, size_known_2;
- GnomeVFSFileSize size_1, size_2;
+ goffset size_1, size_2;
size_known_1 = get_size (file_1, &size_1);
size_known_2 = get_size (file_2, &size_2);
@@ -1818,13 +2138,13 @@ compare_by_size (NautilusFile *file_1, NautilusFile *file_2)
static int
compare_by_display_name (NautilusFile *file_1, NautilusFile *file_2)
{
- char *name_1, *name_2;
- char *key_1, *key_2;
+ const char *name_1, *name_2;
+ const char *key_1, *key_2;
gboolean sort_last_1, sort_last_2;
int compare;
- name_1 = nautilus_file_get_display_name_nocopy (file_1);
- name_2 = nautilus_file_get_display_name_nocopy (file_2);
+ name_1 = nautilus_file_peek_display_name (file_1);
+ name_2 = nautilus_file_peek_display_name (file_2);
sort_last_1 = name_1[0] == SORT_LAST_CHAR1 || name_1[0] == SORT_LAST_CHAR2;
sort_last_2 = name_2[0] == SORT_LAST_CHAR1 || name_2[0] == SORT_LAST_CHAR2;
@@ -1834,8 +2154,8 @@ compare_by_display_name (NautilusFile *file_1, NautilusFile *file_2)
} else if (!sort_last_1 && sort_last_2) {
compare = -1;
} else {
- key_1 = nautilus_file_get_display_name_collation_key (file_1);
- key_2 = nautilus_file_get_display_name_collation_key (file_2);
+ key_1 = nautilus_file_peek_display_name_collation_key (file_1);
+ key_2 = nautilus_file_peek_display_name_collation_key (file_2);
compare = strcmp (key_1, key_2);
}
@@ -1855,7 +2175,7 @@ compare_by_directory_name (NautilusFile *file_1, NautilusFile *file_2)
directory_1 = nautilus_file_get_parent_uri_for_display (file_1);
directory_2 = nautilus_file_get_parent_uri_for_display (file_2);
- compare = eel_strcoll (directory_1, directory_2);
+ compare = g_utf8_collate (directory_1, directory_2);
g_free (directory_1);
g_free (directory_2);
@@ -1877,8 +2197,8 @@ file_has_note (NautilusFile *file)
}
static GList *
-prepend_automatic_emblem_names (NautilusFile *file,
- GList *names)
+prepend_automatic_keywords (NautilusFile *file,
+ GList *names)
{
/* Prepend in reverse order. */
@@ -1964,7 +2284,7 @@ compare_by_emblems (NautilusFile *file_1, NautilusFile *file_2)
keyword_cache_1 = file_1->details->compare_by_emblem_cache->emblem_keywords;
keyword_cache_2 = file_2->details->compare_by_emblem_cache->emblem_keywords;
for (; *keyword_cache_1 != '\0' && *keyword_cache_2 != '\0';) {
- compare_result = eel_strcoll (keyword_cache_1, keyword_cache_2);
+ compare_result = g_utf8_collate (keyword_cache_1, keyword_cache_2);
if (compare_result != 0) {
return compare_result;
}
@@ -2016,17 +2336,17 @@ compare_by_type (NautilusFile *file_1, NautilusFile *file_2)
return +1;
}
- if (file_1->details->info != NULL
- && file_2->details->info != NULL
- && eel_strcmp (file_1->details->info->mime_type,
- file_2->details->info->mime_type) == 0) {
+ if (file_1->details->mime_type != NULL &&
+ file_2->details->mime_type != NULL &&
+ strcmp (eel_ref_str_peek (file_1->details->mime_type),
+ eel_ref_str_peek (file_2->details->mime_type)) == 0) {
return 0;
}
type_string_1 = nautilus_file_get_type_as_string (file_1);
type_string_2 = nautilus_file_get_type_as_string (file_2);
- result = eel_strcoll (type_string_1, type_string_2);
+ result = g_utf8_collate (type_string_1, type_string_2);
g_free (type_string_1);
g_free (type_string_2);
@@ -2091,10 +2411,6 @@ nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
NautilusFile *file_2,
gboolean directories_first)
{
- int compare;
- GnomeVFSDrive *drive1, *drive2;
- GnomeVFSVolume *volume1, *volume2;
-
gboolean is_directory_1, is_directory_2;
if (directories_first) {
@@ -2110,37 +2426,10 @@ nautilus_file_compare_for_sort_internal (NautilusFile *file_1,
}
}
- /* Always sort drives/volumes separately: */
- if (file_1->details->has_drive != file_2->details->has_drive) {
- if (file_1->details->has_drive) {
- return -1;
- } else {
- return 1;
- }
- }
- if (file_1->details->has_drive) {
- drive1 = nautilus_file_get_drive (file_1);
- drive2 = nautilus_file_get_drive (file_2);
- compare = gnome_vfs_drive_compare (drive1, drive2);
- if (compare != 0) {
- return compare;
- }
- }
-
- if (file_1->details->has_volume != file_2->details->has_volume) {
- if (file_1->details->has_volume) {
- return -1;
- } else {
- return 1;
- }
- }
- if (file_1->details->has_volume) {
- volume1 = nautilus_file_get_volume (file_1);
- volume2 = nautilus_file_get_volume (file_2);
- compare = gnome_vfs_volume_compare (volume1, volume2);
- if (compare != 0) {
- return compare;
- }
+ if (file_1->details->sort_order < file_2->details->sort_order) {
+ return -1;
+ } else if (file_1->details->sort_order > file_2->details->sort_order) {
+ return 1;
}
return 0;
@@ -2327,14 +2616,13 @@ int
nautilus_file_compare_display_name (NautilusFile *file,
const char *pattern)
{
- char *name;
+ const char *name;
int result;
g_return_val_if_fail (pattern != NULL, -1);
- name = nautilus_file_get_display_name (file);
- result = eel_strcoll (name, pattern);
- g_free (name);
+ name = nautilus_file_peek_display_name (file);
+ result = g_utf8_collate (name, pattern);
return result;
}
@@ -2342,22 +2630,21 @@ nautilus_file_compare_display_name (NautilusFile *file,
gboolean
nautilus_file_is_hidden_file (NautilusFile *file)
{
- return nautilus_file_name_matches_hidden_pattern
- (file->details->relative_uri);
+ return file->details->is_hidden;
}
gboolean
nautilus_file_is_backup_file (NautilusFile *file)
{
- return nautilus_file_name_matches_backup_pattern
- (file->details->relative_uri);
+ return file->details->is_backup;
}
static gboolean
is_file_hidden (NautilusFile *file)
{
- return g_hash_table_lookup (file->details->directory->details->hidden_file_hash,
- file->details->relative_uri) != NULL;
+ return file->details->directory->details->hidden_file_hash != NULL &&
+ g_hash_table_lookup (file->details->directory->details->hidden_file_hash,
+ eel_ref_str_peek (file->details->name)) != NULL;
}
@@ -2374,26 +2661,35 @@ nautilus_file_should_show (NautilusFile *file,
gboolean
nautilus_file_is_home (NautilusFile *file)
{
- GnomeVFSURI *dir_vfs_uri;
+ GFile *dir;
- dir_vfs_uri = file->details->directory->details->vfs_uri;
-
- if (dir_vfs_uri == NULL ||
- strcmp (dir_vfs_uri->method_string, "file") != 0) {
+ dir = file->details->directory->details->location;
+ if (dir == NULL) {
return FALSE;
}
- return nautilus_is_home_directory_file_escaped (dir_vfs_uri->text,
- file->details->relative_uri);
+ return nautilus_is_home_directory_file (dir,
+ eel_ref_str_peek (file->details->name));
}
gboolean
nautilus_file_is_in_desktop (NautilusFile *file)
{
+ char *path;
+ gboolean res;
+
/* This handles visiting other people's desktops, but it can arguably
* be said that this might break and that we should lookup the passwd table.
*/
- return strstr (file->details->directory->details->uri, "/Desktop") != NULL;
+ /* TODO: This is totally broken with translated desktop dirs, and the dup is slow */
+ path = g_file_get_path (file->details->directory->details->location);
+ res = FALSE;
+ if (path) {
+ res = (strstr (path, "/Desktop") != NULL);
+ }
+ g_free (path);
+ return res;
+
}
static gboolean
@@ -2447,7 +2743,7 @@ get_metadata_name (NautilusFile *file)
if (nautilus_file_is_self_owned (file)) {
return FILE_NAME_FOR_DIRECTORY_METADATA;
}
- return file->details->relative_uri;
+ return eel_ref_str_peek (file->details->name);
}
char *
@@ -2604,132 +2900,68 @@ nautilus_file_set_integer_metadata (NautilusFile *file,
metadata);
}
-void
-nautilus_file_clear_cached_display_name (NautilusFile *file)
-{
- g_return_if_fail (NAUTILUS_IS_FILE (file));
-
- g_free (file->details->cached_display_name);
- file->details->cached_display_name = NULL;
- g_free (file->details->display_name_collation_key);
- file->details->display_name_collation_key = NULL;
-}
-
-static char *
-nautilus_file_get_display_name_collation_key (NautilusFile *file)
+static const char *
+nautilus_file_peek_display_name_collation_key (NautilusFile *file)
{
- char *display_name;
-
- if (file == NULL) {
- return NULL;
- }
-
- if (file->details->display_name_collation_key != NULL) {
- return file->details->display_name_collation_key;
- }
+ const char *res;
- display_name = nautilus_file_get_display_name_nocopy (file);
-#if GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 7
- file->details->display_name_collation_key = g_utf8_collate_key_for_filename (display_name, -1);
-#else
- file->details->display_name_collation_key = g_utf8_collate_key (display_name, -1);
-#endif
+ res = file->details->display_name_collation_key;
+ if (res == NULL)
+ res = "";
- return file->details->display_name_collation_key;
+ return res;
}
-static char *
-nautilus_file_get_display_name_nocopy (NautilusFile *file)
+static const char *
+nautilus_file_peek_display_name (NautilusFile *file)
{
- char *name, *utf8_name, *short_name;
- gboolean validated;
- GnomeVFSURI *vfs_uri;
- const char *method;
- char *uri, *local_file;
-
- if (file == NULL) {
- return NULL;
- }
+ const char *name;
+ char *escaped_name;
- if (file->details->cached_display_name != NULL) {
- return file->details->cached_display_name;
- }
-
- validated = FALSE;
+ /* Default to display name based on filename if its not set yet */
- if (file->details->got_link_info && file->details->display_name != NULL) {
- name = g_strdup (file->details->display_name);
- } else {
- name = nautilus_file_get_name (file);
- if (name == NULL) {
- /* Fall back to the escaped form if the unescaped form is no
- * good. This is dangerous for people who code with the name,
- * but convenient for people who just want to display it.
- */
- name = g_strdup (file->details->relative_uri);
+ if (file->details->display_name == NULL) {
+ name = eel_ref_str_peek (file->details->name);
+ if (g_utf8_validate (name, -1, NULL)) {
+ nautilus_file_set_display_name (file,
+ name,
+ NULL,
+ FALSE);
} else {
- /* Support the G_BROKEN_FILENAMES feature of
- * glib by using g_filename_to_utf8 to convert
- * local filenames to UTF-8. Also do the same
- * thing with any local filename that does not
- * validate as good UTF-8.
- */
- /* Keep in sync with nautilus_get_uri_shortname_for_display */
- if (has_local_path (file)) {
- g_free (name);
- uri = nautilus_file_get_uri (file);
- local_file = gnome_vfs_get_local_path_from_uri (uri);
- if (local_file == NULL) { /* Happens for e.g. file:///# */
- local_file = g_strdup ("/");
- }
- name = g_filename_display_basename (local_file);
- g_free (local_file);
- g_free (uri);
- validated = TRUE;
- } else if (strcmp (name, "/") == 0) {
- /* Special-case the display name for roots that are not local files */
- g_free (name);
-
- vfs_uri = gnome_vfs_uri_new (file->details->directory->details->uri);
- method = nautilus_get_vfs_method_display_name (vfs_uri->method_string);
- if (method == NULL) {
- method = vfs_uri->method_string;
- }
-
- short_name = gnome_vfs_uri_extract_short_name (vfs_uri);
- if (short_name == NULL ||
- strcmp (short_name, GNOME_VFS_URI_PATH_STR) == 0) {
- name = g_strdup (method);
- } else {
- name = g_strdup_printf ("%s: %s", method, short_name);
- }
- g_free (short_name);
-
- gnome_vfs_uri_unref (vfs_uri);
- }
+ escaped_name = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
+ nautilus_file_set_display_name (file,
+ escaped_name,
+ NULL,
+ FALSE);
+ g_free (escaped_name);
}
}
-
- if (!validated && !g_utf8_validate (name, -1, NULL)) {
- utf8_name = eel_make_valid_utf8 (name);
- g_free (name);
- name = utf8_name;
- }
- file->details->cached_display_name = name;
- return name;
+ return eel_ref_str_peek (file->details->display_name);
}
char *
nautilus_file_get_display_name (NautilusFile *file)
{
- return g_strdup (nautilus_file_get_display_name_nocopy (file));
+ return g_strdup (nautilus_file_peek_display_name (file));
+}
+
+char *
+nautilus_file_get_edit_name (NautilusFile *file)
+{
+ const char *res;
+
+ res = eel_ref_str_peek (file->details->edit_name);
+ if (res == NULL)
+ res = "";
+
+ return g_strdup (res);
}
char *
nautilus_file_get_name (NautilusFile *file)
{
- return gnome_vfs_unescape_string (file->details->relative_uri, "/");
+ return g_strdup (eel_ref_str_peek (file->details->name));
}
void
@@ -2767,12 +2999,8 @@ nautilus_file_get_activation_uri (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- if (!file->details->got_link_info) {
- return NULL;
- }
-
- if (file->details->activation_uri != NULL) {
- return g_strdup (file->details->activation_uri);
+ if (file->details->activation_location != NULL) {
+ return g_file_get_uri (file->details->activation_location);
}
return nautilus_file_get_uri (file);
@@ -2783,6 +3011,7 @@ char *
nautilus_file_get_drop_target_uri (NautilusFile *file)
{
char *uri, *target_uri;
+ GFile *location;
NautilusDesktopLink *link;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
@@ -2791,106 +3020,349 @@ nautilus_file_get_drop_target_uri (NautilusFile *file)
link = nautilus_desktop_icon_file_get_link (NAUTILUS_DESKTOP_ICON_FILE (file));
if (link != NULL) {
- uri = nautilus_desktop_link_get_activation_uri (link);
+ location = nautilus_desktop_link_get_activation_location (link);
g_object_unref (link);
- if (uri != NULL) {
+ if (location != NULL) {
+ uri = g_file_get_uri (location);
+ g_object_unref (location);
return uri;
}
}
}
uri = nautilus_file_get_uri (file);
-
+
/* Check for Nautilus link */
if (nautilus_file_is_nautilus_link (file)) {
+ location = nautilus_file_get_location (file);
/* FIXME bugzilla.gnome.org 43020: This does sync. I/O and works only locally. */
- if (!eel_vfs_has_capability (uri, EEL_VFS_CAPABILITY_IS_REMOTE_AND_SLOW)) {
+ if (g_file_is_native (location)) {
target_uri = nautilus_link_local_get_link_uri (uri);
if (target_uri != NULL) {
g_free (uri);
uri = target_uri;
}
}
+ g_object_unref (location);
}
return uri;
}
-char *
-nautilus_file_get_custom_icon (NautilusFile *file)
+static gboolean
+is_uri_relative (const char *uri)
{
- char *uri;
- char *dir_uri;
- char *custom_icon;
- char *tmp;
+ char *scheme;
- g_assert (NAUTILUS_IS_FILE (file));
+ scheme = g_uri_get_scheme (uri);
+ g_free (scheme);
+ return scheme == NULL;
+}
- /* Metadata takes precedence */
+static char *
+get_custom_icon_metadata_uri (NautilusFile *file)
+{
+ char *custom_icon_uri;
+ char *uri;
+ char *dir_uri;
+
uri = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL);
- if (uri != NULL && nautilus_file_is_directory (file)) {
- /* The relative concatenation code will truncate
- * the URI basename without a trailing "/".
- * */
- tmp = nautilus_file_get_uri (file);
- dir_uri = g_strconcat (tmp, "/", NULL);
- g_free (tmp);
-
- custom_icon = gnome_vfs_uri_make_full_from_relative (dir_uri, uri);
-
+ if (uri != NULL &&
+ nautilus_file_is_directory (file) &&
+ is_uri_relative (uri)) {
+ dir_uri = nautilus_file_get_uri (file);
+ custom_icon_uri = g_build_filename (dir_uri, uri, NULL);
g_free (dir_uri);
g_free (uri);
} else {
- custom_icon = uri;
+ custom_icon_uri = uri;
+ }
+ return custom_icon_uri;
+}
+
+static GIcon *
+get_custom_icon (NautilusFile *file)
+{
+ char *custom_icon_uri;
+ GFile *icon_file;
+ GIcon *icon;
+
+ if (file == NULL) {
+ return NULL;
+ }
+
+ icon = NULL;
+
+ /* Metadata takes precedence */
+ custom_icon_uri = get_custom_icon_metadata_uri (file);
+
+ if (custom_icon_uri) {
+ icon_file = g_file_new_for_uri (custom_icon_uri);
+ icon = g_file_icon_new (icon_file);
+ g_object_unref (icon_file);
}
- if (custom_icon == NULL && file->details->got_link_info) {
- custom_icon = g_strdup (file->details->custom_icon);
+ if (icon == NULL && file->details->got_link_info && file->details->custom_icon != NULL) {
+ if (g_path_is_absolute (file->details->custom_icon)) {
+ icon_file = g_file_new_for_path (file->details->custom_icon);
+ icon = g_file_icon_new (icon_file);
+ g_object_unref (icon_file);
+ } else {
+ icon = g_themed_icon_new (file->details->custom_icon);
+ }
}
- return custom_icon;
+ return icon;
}
-/* Return the actual uri associated with the passed-in file. */
-char *
-nautilus_file_get_uri (NautilusFile *file)
+static int cached_thumbnail_limit;
+static int cached_thumbnail_size;
+static int show_image_thumbs;
+
+static gboolean
+mimetype_limited_by_size (const char *mime_type)
{
- GnomeVFSURI *vfs_uri;
- char *uri;
+ /* TODO: re-add */
+ /*
+ if (g_hash_table_lookup (factory->image_mime_types, mime_type)) {
+ return TRUE;
+ }
+ */
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
+ return FALSE;
+}
- if (nautilus_file_is_self_owned (file)) {
- return g_strdup (file->details->directory->details->uri);
+gboolean
+nautilus_file_should_show_thumbnail (NautilusFile *file)
+{
+ const char *mime_type;
+
+ mime_type = eel_ref_str_peek (file->details->mime_type);
+ if (mime_type == NULL) {
+ mime_type = "application/octet-stream";
+ }
+
+ if (mimetype_limited_by_size (mime_type) &&
+ nautilus_file_get_size (file) > (unsigned int)cached_thumbnail_limit) {
+ return FALSE;
+ }
+
+ if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
+ return TRUE;
+ } else if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_NEVER) {
+ return FALSE;
+ } else {
+ /* only local files */
+ return nautilus_file_is_local (file);
+ }
+
+ return FALSE;
+}
+
+GIcon *
+nautilus_file_get_gicon (NautilusFile *file,
+ NautilusFileIconFlags flags)
+{
+ const char * const * names;
+ const char *name;
+ GPtrArray *array;
+ GIcon *icon;
+ int i;
+ gboolean changed;
+
+ if (file->details->icon) {
+ icon = NULL;
+
+ if (((flags & NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT) ||
+ (flags & NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT) ||
+ (flags & NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER) ||
+ ((flags & NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING) == 0 &&
+ nautilus_file_has_open_window (file))) &&
+ G_IS_THEMED_ICON (file->details->icon)) {
+ names = g_themed_icon_get_names (G_THEMED_ICON (file->details->icon));
+ array = g_ptr_array_new ();
+
+ changed = TRUE;
+ for (i = 0; names[i] != NULL; i++) {
+ name = names[i];
+
+ if (strcmp (name, "folder") == 0 &&
+ (flags & NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING) == 0 &&
+ nautilus_file_has_open_window (file)) {
+ changed = TRUE;
+ g_ptr_array_add (array, "folder-visiting");
+ }
+ if (strcmp (name, "folder") == 0 &&
+ (flags & NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT)) {
+ changed = TRUE;
+ g_ptr_array_add (array, "folder-drag-accept");
+ }
+ if (strcmp (name, "folder") == 0 &&
+ (flags & NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER)) {
+ changed = TRUE;
+ g_ptr_array_add (array, "folder-open");
+ }
+ if (strcmp (name, "text-x-generic") == 0 &&
+ (flags & NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT)) {
+ changed = TRUE;
+ g_ptr_array_add (array, "text-x-preview");
+ }
+ g_ptr_array_add (array, (char *)name);
+ }
+
+ if (changed) {
+ icon = g_themed_icon_new_from_names ((char **)array->pdata, array->len);
+ }
+
+ g_ptr_array_free (array, TRUE);
+ }
+
+ if (icon == NULL) {
+ icon = g_object_ref (file->details->icon);
+ }
+
+ return icon;
+ }
+
+ return g_themed_icon_new ("text-x-generic");
+}
+
+NautilusIconInfo *
+nautilus_file_get_icon (NautilusFile *file,
+ int size,
+ NautilusFileIconFlags flags)
+{
+ NautilusIconInfo *icon;
+ GIcon *gicon;
+ GdkPixbuf *raw_pixbuf, *scaled_pixbuf;
+ int modified_size;
+
+ if (file == NULL) {
+ return NULL;
+ }
+
+ gicon = get_custom_icon (file);
+ if (gicon) {
+ icon = nautilus_icon_info_lookup (gicon, size);
+ g_object_unref (gicon);
+ return icon;
}
- vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
- if (vfs_uri != NULL) {
- uri = gnome_vfs_uri_to_string (vfs_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (vfs_uri);
- return uri;
+ modified_size = size * cached_thumbnail_size / NAUTILUS_ICON_SIZE_STANDARD;
+
+ if (flags & NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS &&
+ nautilus_file_should_show_thumbnail (file)) {
+ if (file->details->thumbnail) {
+ if (file->details->thumbnail_size == modified_size) {
+ scaled_pixbuf = g_object_ref (file->details->thumbnail);
+ } else {
+ int w, h, s;
+ double scale;
+
+ if (file->details->thumbnail_size == 0) {
+ raw_pixbuf = g_object_ref (file->details->thumbnail);
+ } else {
+ raw_pixbuf = nautilus_thumbnail_unframe_image (file->details->thumbnail);
+ }
+
+ w = gdk_pixbuf_get_width (raw_pixbuf);
+ h = gdk_pixbuf_get_height (raw_pixbuf);
+
+ /* These compensates for frame size which will be added on the raw image */
+ s = MAX (NAUTILUS_THUMBNAIL_FRAME_LEFT + w + NAUTILUS_THUMBNAIL_FRAME_RIGHT,
+ NAUTILUS_THUMBNAIL_FRAME_TOP + h + NAUTILUS_THUMBNAIL_FRAME_BOTTOM);
+
+ scale = (double)modified_size / s;
+
+ scaled_pixbuf = gdk_pixbuf_scale_simple (raw_pixbuf,
+ w * scale, h * scale,
+ GDK_INTERP_HYPER);
+ nautilus_thumbnail_frame_image (&scaled_pixbuf);
+
+ g_object_unref (raw_pixbuf);
+
+ if (modified_size > file->details->thumbnail_size) {
+ /* Invalidate if we resize upward (and the
+ loaded was not the original raw version, w/ size 0).
+ */
+ if (file->details->thumbnail_size != 0 ||
+ (modified_size > 128 && !file->details->thumbnail_tried_original)) {
+ nautilus_file_invalidate_attributes (file, NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL);
+ }
+ file->details->thumbnail_size = modified_size;
+ g_object_unref (file->details->thumbnail);
+ file->details->thumbnail = g_object_ref (scaled_pixbuf);
+ }
+ }
+
+ icon = nautilus_icon_info_new_for_pixbuf (scaled_pixbuf);
+ g_object_unref (scaled_pixbuf);
+ return icon;
+ } else if (file->details->thumbnail_path == NULL &&
+ !file->details->thumbnailing_failed &&
+ !file->details->is_thumbnailing) {
+ if (nautilus_can_thumbnail (file)) {
+ nautilus_create_thumbnail (file);
+ }
+ }
+ }
+
+ if (file->details->is_thumbnailing &&
+ flags & NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS)
+ gicon = g_themed_icon_new (ICON_NAME_THUMBNAIL_LOADING);
+ else
+ gicon = nautilus_file_get_gicon (file, flags);
+
+ if (gicon) {
+ icon = nautilus_icon_info_lookup (gicon, size);
+ g_object_unref (gicon);
+ return icon;
}
- return g_strconcat (file->details->directory->details->uri,
- file->details->relative_uri,
- NULL);
+ return nautilus_icon_info_new_for_pixbuf (NULL);
}
-char *
-nautilus_file_get_uri_scheme (NautilusFile *file)
+GdkPixbuf *
+nautilus_file_get_icon_pixbuf (NautilusFile *file,
+ int size,
+ gboolean force_size,
+ NautilusFileIconFlags flags)
{
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
+ info = nautilus_file_get_icon (file, size, flags);
+ if (force_size) {
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, size);
+ } else {
+ pixbuf = nautilus_icon_info_get_pixbuf (info);
+ }
+ g_object_unref (info);
+
+ return pixbuf;
+}
- if (file->details->directory == NULL ||
- file->details->directory->details->uri == NULL) {
+char *
+nautilus_file_get_custom_icon (NautilusFile *file)
+{
+ char *custom_icon;
+
+ if (file == NULL) {
return NULL;
}
- return gnome_vfs_get_uri_scheme (file->details->directory->details->uri);
+ /* Metadata takes precedence */
+ custom_icon = get_custom_icon_metadata_uri (file);
+
+ if (custom_icon == NULL && file->details->got_link_info) {
+ custom_icon = g_strdup (file->details->custom_icon);
+ }
+
+ return custom_icon;
}
+
gboolean
nautilus_file_get_date (NautilusFile *file,
NautilusDateType date_type,
@@ -3198,8 +3670,8 @@ nautilus_file_should_show_directory_item_count (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- if (file->details->guessed_mime_type &&
- strcmp (file->details->guessed_mime_type, "x-directory/smb-share") == 0) {
+ if (file->details->mime_type &&
+ strcmp (eel_ref_str_peek (file->details->mime_type), "x-directory/smb-share") == 0) {
return FALSE;
}
@@ -3324,7 +3796,7 @@ nautilus_file_get_deep_counts (NautilusFile *file,
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size,
+ goffset *total_size,
gboolean force)
{
if (directory_count != NULL) {
@@ -3371,12 +3843,6 @@ nautilus_file_recompute_deep_counts (NautilusFile *file)
}
}
-GnomeVFSFileInfo *
-nautilus_file_peek_vfs_file_info (NautilusFile *file)
-{
- return file->details->info;
-}
-
/**
* nautilus_file_get_directory_item_mime_types
@@ -3406,6 +3872,13 @@ nautilus_file_get_directory_item_mime_types (NautilusFile *file,
return TRUE;
}
+gboolean
+nautilus_file_can_get_size (NautilusFile *file)
+{
+ return file->details->size == -1;
+}
+
+
/**
* nautilus_file_get_size
*
@@ -3415,14 +3888,99 @@ nautilus_file_get_directory_item_mime_types (NautilusFile *file,
* Returns: Size in bytes.
*
**/
-GnomeVFSFileSize
+goffset
nautilus_file_get_size (NautilusFile *file)
{
/* Before we have info on the file, we don't know the size. */
- return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)
- ? 0 : file->details->info->size;
+ if (file->details->size == -1)
+ return 0;
+ return file->details->size;
+}
+
+time_t
+nautilus_file_get_mtime (NautilusFile *file)
+{
+ return file->details->mtime;
+}
+
+
+static void
+set_attributes_get_info_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GFileInfo *new_info;
+ GError *error;
+
+ op = callback_data;
+
+ error = NULL;
+ new_info = g_file_query_info_finish (G_FILE (source_object), res, &error);
+ if (new_info != NULL) {
+ nautilus_file_update_info (op->file, new_info);
+ g_object_unref (new_info);
+ }
+ nautilus_file_operation_complete (op, NULL, error);
+ if (error) {
+ g_error_free (error);
+ }
+}
+
+
+static void
+set_attributes_callback (GObject *source_object,
+ GAsyncResult *result,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GError *error;
+ gboolean res;
+
+ op = callback_data;
+
+ error = NULL;
+ res = g_file_set_attributes_finish (G_FILE (source_object),
+ result,
+ NULL,
+ &error);
+
+ if (res) {
+ g_file_query_info_async (G_FILE (source_object),
+ NAUTILUS_FILE_DEFAULT_ATTRIBUTES,
+ 0,
+ G_PRIORITY_DEFAULT,
+ op->cancellable,
+ set_attributes_get_info_callback, op);
+ } else {
+ nautilus_file_operation_complete (op, NULL, error);
+ g_error_free (error);
+ }
}
+void
+nautilus_file_set_attributes (NautilusFile *file,
+ GFileInfo *attributes,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GFile *location;
+
+ op = nautilus_file_operation_new (file, callback, callback_data);
+
+ location = nautilus_file_get_location (file);
+ g_file_set_attributes_async (location,
+ attributes,
+ 0,
+ G_PRIORITY_DEFAULT,
+ op->cancellable,
+ set_attributes_callback,
+ op);
+ g_object_unref (location);
+}
+
+
/**
* nautilus_file_can_get_permissions:
*
@@ -3436,7 +3994,7 @@ nautilus_file_get_size (NautilusFile *file)
gboolean
nautilus_file_can_get_permissions (NautilusFile *file)
{
- return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS);
+ return file->details->has_permissions;
}
/**
@@ -3456,12 +4014,12 @@ nautilus_file_can_set_permissions (NautilusFile *file)
{
uid_t user_id;
- if (file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_IDS) {
+ if (file->details->uid != -1) {
/* Check the user. */
user_id = geteuid();
/* Owner is allowed to set permissions. */
- if (user_id == (uid_t) file->details->info->uid) {
+ if (user_id == (uid_t) file->details->uid) {
return TRUE;
}
@@ -3479,29 +4037,12 @@ nautilus_file_can_set_permissions (NautilusFile *file)
return TRUE;
}
-GnomeVFSFilePermissions
+guint
nautilus_file_get_permissions (NautilusFile *file)
{
g_return_val_if_fail (nautilus_file_can_get_permissions (file), 0);
- return file->details->info->permissions;
-}
-
-static void
-set_permissions_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GnomeVFSFileInfo *new_info,
- gpointer callback_data)
-{
- Operation *op;
-
- op = callback_data;
- g_assert (handle == op->handle);
-
- if (result == GNOME_VFS_OK && new_info != NULL) {
- nautilus_file_update_info (op->file, new_info, op->use_slow_mime);
- }
- operation_complete (op, result);
+ return file->details->permissions;
}
/**
@@ -3516,14 +4057,12 @@ set_permissions_callback (GnomeVFSAsyncHandle *handle,
**/
void
nautilus_file_set_permissions (NautilusFile *file,
- GnomeVFSFilePermissions new_permissions,
+ guint32 new_permissions,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
- Operation *op;
- GnomeVFSURI *vfs_uri;
- GnomeVFSFileInfo *partial_file_info;
- GnomeVFSFileInfoOptions options;
+ GFileInfo *info;
+ GError *error;
if (!nautilus_file_can_set_permissions (file)) {
/* Claim that something changed even if the permission change failed.
@@ -3531,7 +4070,10 @@ nautilus_file_set_permissions (NautilusFile *file,
* to the old permissions as "changing back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_ACCESS_DENIED, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
+ _("Not allowed to set permissions"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
@@ -3539,31 +4081,15 @@ nautilus_file_set_permissions (NautilusFile *file,
* because we don't want to send the file-changed signal if
* nothing changed.
*/
- if (new_permissions == file->details->info->permissions) {
- (* callback) (file, GNOME_VFS_OK, callback_data);
+ if (new_permissions == file->details->permissions) {
+ (* callback) (file, NULL, NULL, callback_data);
return;
}
- /* Set up a permission change operation. */
- op = operation_new (file, callback, callback_data);
- op->use_slow_mime = file->details->got_slow_mime_type;
-
- options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS;
- if (op->use_slow_mime) {
- options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE;
- }
- /* Change the file-on-disk permissions. */
- partial_file_info = gnome_vfs_file_info_new ();
- partial_file_info->permissions = new_permissions;
- vfs_uri = nautilus_file_get_gnome_vfs_uri (file);
- gnome_vfs_async_set_file_info (&op->handle,
- vfs_uri, partial_file_info,
- GNOME_VFS_SET_FILE_INFO_PERMISSIONS,
- options,
- GNOME_VFS_PRIORITY_DEFAULT,
- set_permissions_callback, op);
- gnome_vfs_file_info_unref (partial_file_info);
- gnome_vfs_uri_unref (vfs_uri);
+ info = g_file_info_new ();
+ g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE, new_permissions);
+ nautilus_file_set_attributes (file, info, callback, callback_data);
+ g_object_unref (info);
}
/**
@@ -3580,7 +4106,7 @@ nautilus_file_set_permissions (NautilusFile *file,
gboolean
nautilus_file_can_get_selinux_context (NautilusFile *file)
{
- return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SELINUX_CONTEXT);
+ return file->details->selinux_context != NULL;
}
@@ -3606,7 +4132,7 @@ nautilus_file_get_selinux_context (NautilusFile *file)
return NULL;
}
- raw = file->details->info->selinux_context;
+ raw = file->details->selinux_context;
#ifdef HAVE_SELINUX
if (selinux_raw_to_trans_context (raw, &translated) == 0) {
@@ -3774,7 +4300,7 @@ gboolean
nautilus_file_can_get_owner (NautilusFile *file)
{
/* Before we have info on a file, the owner is unknown. */
- return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_IDS);
+ return file->details->uid != -1;
}
/**
@@ -3821,60 +4347,6 @@ nautilus_file_can_set_owner (NautilusFile *file)
return geteuid() == 0;
}
-static void
-set_owner_and_group_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- GnomeVFSFileInfo *new_info,
- gpointer callback_data)
-{
- Operation *op;
-
- op = callback_data;
- g_assert (handle == op->handle);
-
- if (result == GNOME_VFS_OK && new_info != NULL) {
- nautilus_file_update_info (op->file, new_info, op->use_slow_mime);
- }
- operation_complete (op, result);
-}
-
-static void
-set_owner_and_group (NautilusFile *file,
- uid_t owner,
- uid_t group,
- NautilusFileOperationCallback callback,
- gpointer callback_data)
-{
- Operation *op;
- GnomeVFSURI *uri;
- GnomeVFSFileInfo *partial_file_info;
- GnomeVFSFileInfoOptions options;
-
- /* Set up a owner-change operation. */
- op = operation_new (file, callback, callback_data);
- op->use_slow_mime = file->details->got_slow_mime_type;
-
- options = NAUTILUS_FILE_DEFAULT_FILE_INFO_OPTIONS;
- if (op->use_slow_mime) {
- options |= GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE;
- }
-
- /* Change the file-on-disk owner. */
- partial_file_info = gnome_vfs_file_info_new ();
- partial_file_info->uid = owner;
- partial_file_info->gid = group;
-
- uri = nautilus_file_get_gnome_vfs_uri (file);
- gnome_vfs_async_set_file_info (&op->handle,
- uri, partial_file_info,
- GNOME_VFS_SET_FILE_INFO_OWNER,
- options,
- GNOME_VFS_PRIORITY_DEFAULT,
- set_owner_and_group_callback, op);
- gnome_vfs_file_info_unref (partial_file_info);
- gnome_vfs_uri_unref (uri);
-}
-
/**
* nautilus_file_set_owner:
*
@@ -3895,6 +4367,8 @@ nautilus_file_set_owner (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
+ GError *error;
+ GFileInfo *info;
uid_t new_id;
if (!nautilus_file_can_set_owner (file)) {
@@ -3904,7 +4378,10 @@ nautilus_file_set_owner (NautilusFile *file,
* "changing back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_ACCESS_DENIED, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
+ _("Not allowed to set owner"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
@@ -3919,7 +4396,10 @@ nautilus_file_set_owner (NautilusFile *file,
* "changing back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_BAD_PARAMETERS, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Specified owner '%s' doesn't exist"), user_name_or_id);
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
@@ -3927,20 +4407,15 @@ nautilus_file_set_owner (NautilusFile *file,
* don't want to send the file-changed signal if nothing
* changed.
*/
- if (new_id == (uid_t) file->details->info->uid) {
- (* callback) (file, GNOME_VFS_OK, callback_data);
+ if (new_id == (uid_t) file->details->uid) {
+ (* callback) (file, NULL, NULL, callback_data);
return;
}
- /* FIXME bugzilla.gnome.org 42427:
- * We can't assume that the gid is already good/read,
- * can we? Maybe we have to precede the set_file_info with a
- * get_file_info to fix this?
- */
- set_owner_and_group (file,
- new_id,
- file->details->info->gid,
- callback, callback_data);
+ info = g_file_info_new ();
+ g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID, new_id);
+ nautilus_file_set_attributes (file, info, callback, callback_data);
+ g_object_unref (info);
}
/**
@@ -3992,7 +4467,7 @@ gboolean
nautilus_file_can_get_group (NautilusFile *file)
{
/* Before we have info on a file, the group is unknown. */
- return !nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_IDS);
+ return file->details->gid != -1;
}
/**
@@ -4012,16 +4487,16 @@ nautilus_file_get_group_name (NautilusFile *file)
char *group_name;
/* Before we have info on a file, the owner is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_IDS)) {
+ if (file->details->gid == -1) {
return NULL;
}
- group_name = nautilus_groups_cache_get_name ((gid_t) file->details->info->gid);
+ group_name = nautilus_groups_cache_get_name ((gid_t) file->details->gid);
if (group_name == NULL) {
/* In the oddball case that the group name has been set to an id for which
* there is no defined group, return the id in string form.
*/
- group_name = g_strdup_printf ("%d", file->details->info->gid);
+ group_name = g_strdup_printf ("%d", file->details->gid);
}
return group_name;
@@ -4056,7 +4531,7 @@ nautilus_file_can_set_group (NautilusFile *file)
user_id = geteuid();
/* Owner is allowed to set group (with restrictions). */
- if (user_id == (uid_t) file->details->info->uid) {
+ if (user_id == (uid_t) file->details->uid) {
return TRUE;
}
@@ -4143,7 +4618,7 @@ nautilus_file_get_settable_group_names (NautilusFile *file)
if (user_id == 0) {
/* Root is allowed to set group to anything. */
result = nautilus_get_all_group_names ();
- } else if (user_id == (uid_t) file->details->info->uid) {
+ } else if (user_id == (uid_t) file->details->uid) {
/* Owner is allowed to set group to any that owner is member of. */
result = nautilus_get_group_names_for_user ();
} else {
@@ -4174,6 +4649,8 @@ nautilus_file_set_group (NautilusFile *file,
NautilusFileOperationCallback callback,
gpointer callback_data)
{
+ GError *error;
+ GFileInfo *info;
uid_t new_id;
if (!nautilus_file_can_set_group (file)) {
@@ -4183,7 +4660,10 @@ nautilus_file_set_group (NautilusFile *file,
* "changing back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_ACCESS_DENIED, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED,
+ _("Not allowed to set group"));
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
@@ -4198,23 +4678,23 @@ nautilus_file_set_group (NautilusFile *file,
* "changing back".
*/
nautilus_file_changed (file);
- (* callback) (file, GNOME_VFS_ERROR_BAD_PARAMETERS, callback_data);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
+ _("Specified group '%s' doesn't exist"), group_name_or_id);
+ (* callback) (file, NULL, error, callback_data);
+ g_error_free (error);
return;
}
- if (new_id == (gid_t) file->details->info->gid) {
- (* callback) (file, GNOME_VFS_OK, callback_data);
+ if (new_id == (gid_t) file->details->gid) {
+ (* callback) (file, NULL, NULL, callback_data);
return;
}
- /* FIXME bugzilla.gnome.org 42427: We can't assume that the gid is already good/read,
- * can we? Maybe we have to precede the set_file_info with a
- * get_file_info to fix this?
- */
- set_owner_and_group (file,
- file->details->info->uid,
- new_id,
- callback, callback_data);
+
+ info = g_file_info_new ();
+ g_file_info_set_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID, new_id);
+ nautilus_file_set_attributes (file, info, callback, callback_data);
+ g_object_unref (info);
}
/**
@@ -4231,7 +4711,7 @@ nautilus_file_set_group (NautilusFile *file,
static char *
nautilus_file_get_octal_permissions_as_string (NautilusFile *file)
{
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
@@ -4239,8 +4719,8 @@ nautilus_file_get_octal_permissions_as_string (NautilusFile *file)
return NULL;
}
- permissions = file->details->info->permissions;
- return g_strdup_printf ("%03o", permissions & 07777);
+ permissions = file->details->permissions;
+ return g_strdup_printf ("%03o", permissions);
}
/**
@@ -4256,7 +4736,7 @@ nautilus_file_get_octal_permissions_as_string (NautilusFile *file)
static char *
nautilus_file_get_permissions_as_string (NautilusFile *file)
{
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
gboolean is_directory;
gboolean is_link;
gboolean suid, sgid, sticky;
@@ -4267,30 +4747,30 @@ nautilus_file_get_permissions_as_string (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- permissions = file->details->info->permissions;
+ permissions = file->details->permissions;
is_directory = nautilus_file_is_directory (file);
is_link = nautilus_file_is_symbolic_link (file);
/* We use ls conventions for displaying these three obscure flags */
- suid = permissions & GNOME_VFS_PERM_SUID;
- sgid = permissions & GNOME_VFS_PERM_SGID;
- sticky = permissions & GNOME_VFS_PERM_STICKY;
+ suid = permissions & S_ISGID;
+ sgid = permissions & S_ISGID;
+ sticky = permissions & S_ISVTX;
return g_strdup_printf ("%c%c%c%c%c%c%c%c%c%c",
is_link ? 'l' : is_directory ? 'd' : '-',
- permissions & GNOME_VFS_PERM_USER_READ ? 'r' : '-',
- permissions & GNOME_VFS_PERM_USER_WRITE ? 'w' : '-',
- permissions & GNOME_VFS_PERM_USER_EXEC
+ permissions & S_IRUSR ? 'r' : '-',
+ permissions & S_IWUSR ? 'w' : '-',
+ permissions & S_IXUSR
? (suid ? 's' : 'x')
: (suid ? 'S' : '-'),
- permissions & GNOME_VFS_PERM_GROUP_READ ? 'r' : '-',
- permissions & GNOME_VFS_PERM_GROUP_WRITE ? 'w' : '-',
- permissions & GNOME_VFS_PERM_GROUP_EXEC
+ permissions & S_IRGRP ? 'r' : '-',
+ permissions & S_IWGRP ? 'w' : '-',
+ permissions & S_IXGRP
? (sgid ? 's' : 'x')
: (sgid ? 'S' : '-'),
- permissions & GNOME_VFS_PERM_OTHER_READ ? 'r' : '-',
- permissions & GNOME_VFS_PERM_OTHER_WRITE ? 'w' : '-',
- permissions & GNOME_VFS_PERM_OTHER_EXEC
+ permissions & S_IROTH ? 'r' : '-',
+ permissions & S_IWOTH ? 'w' : '-',
+ permissions & S_IXOTH
? (sticky ? 't' : 'x')
: (sticky ? 'T' : '-'));
}
@@ -4313,21 +4793,21 @@ nautilus_file_get_owner_as_string (NautilusFile *file, gboolean include_real_nam
char *user_name;
/* Before we have info on a file, the owner is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_IDS)) {
+ if (file->details->uid == -1) {
return NULL;
}
if (include_real_name) {
- user_name = get_user_and_real_name_from_id (file->details->info->uid);
+ user_name = get_user_and_real_name_from_id (file->details->uid);
} else {
- user_name = nautilus_users_cache_get_name (file->details->info->uid);
+ user_name = nautilus_users_cache_get_name (file->details->uid);
}
if (user_name == NULL) {
/* In the oddball case that the user name has been set to an id for which
* there is no defined user, return the id in string form.
*/
- user_name = g_strdup_printf ("%d", file->details->info->uid);
+ user_name = g_strdup_printf ("%d", file->details->uid);
}
return user_name;
@@ -4377,10 +4857,10 @@ nautilus_file_get_size_as_string (NautilusFile *file)
return format_item_count_for_display (item_count, TRUE, TRUE);
}
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
+ if (file->details->size == -1) {
return NULL;
}
- return gnome_vfs_format_file_size_for_display (file->details->info->size);
+ return g_format_file_size_for_display (file->details->size);
}
/**
@@ -4416,14 +4896,13 @@ nautilus_file_get_size_as_string_with_real_size (NautilusFile *file)
return format_item_count_for_display (item_count, TRUE, TRUE);
}
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
+ if (file->details->size == -1) {
return NULL;
}
- formated = gnome_vfs_format_file_size_for_display (file->details->info->size);
- /* FIXME: We should use GNOME_VFS_SIZE_FORMAT_STR instead of the explicit format here. */
- formated_plus_real = g_strdup_printf (_("%s (%lld bytes)"), formated,
- (long long) file->details->info->size);
+ formated = g_format_file_size_for_display (file->details->size);
+ formated_plus_real = g_strdup_printf (_("%s (%"G_GUINT64_FORMAT" bytes)"), formated,
+ (guint64) file->details->size);
g_free (formated);
return formated_plus_real;
}
@@ -4440,7 +4919,7 @@ nautilus_file_get_deep_count_as_string_internal (NautilusFile *file,
guint file_count;
guint unreadable_count;
guint total_count;
- GnomeVFSFileSize total_size;
+ goffset total_size;
/* Must ask for size or some kind of count, but not both. */
g_return_val_if_fail (!report_size || (!report_directory_count && !report_file_count), NULL);
@@ -4485,7 +4964,7 @@ nautilus_file_get_deep_count_as_string_internal (NautilusFile *file,
* directly if desired.
*/
if (report_size) {
- return gnome_vfs_format_file_size_for_display (total_size);
+ return g_format_file_size_for_display (total_size);
}
return format_item_count_for_display (report_directory_count
@@ -4773,21 +5252,17 @@ get_description (NautilusFile *file)
g_assert (NAUTILUS_IS_FILE (file));
- if (file->details->info == NULL) {
- return NULL;
- }
-
- mime_type = file->details->info->mime_type;
+ mime_type = eel_ref_str_peek (file->details->mime_type);
if (eel_str_is_empty (mime_type)) {
return NULL;
}
- if (g_ascii_strcasecmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0
- && nautilus_file_is_executable (file)) {
+ if (g_content_type_is_unknown (mime_type) &&
+ nautilus_file_is_executable (file)) {
return _("program");
}
- description = gnome_vfs_mime_get_description (mime_type);
+ description = g_content_type_get_description (mime_type);
if (!eel_str_is_empty (description)) {
return description;
}
@@ -4809,7 +5284,7 @@ get_description (NautilusFile *file)
g_warning (_("No description found for mime type \"%s\" (file is \"%s\"), "
"please tell the gnome-vfs mailing list."),
mime_type,
- file->details->relative_uri);
+ eel_ref_str_peek (file->details->name));
}
g_hash_table_insert (warned, g_strdup (mime_type), GINT_TO_POINTER (1));
}
@@ -4857,23 +5332,14 @@ nautilus_file_get_type_as_string (NautilusFile *file)
* Returns: The type.
*
**/
-GnomeVFSFileType
+GFileType
nautilus_file_get_file_type (NautilusFile *file)
{
if (file == NULL) {
- return GNOME_VFS_FILE_TYPE_UNKNOWN;
+ return G_FILE_TYPE_UNKNOWN;
}
- /* Don't use EEL_CALL_METHOD_WITH_RETURN_VALUE here, because the
- typechecking was showing up a lot on the profiles, since this
- is called from the sorting code */
- return ((NautilusFileClass*)G_OBJECT_GET_CLASS (file))->get_file_type (file);
-}
-
-gboolean
-nautilus_file_needs_slow_mime_type (NautilusFile *file)
-{
- return !file->details->got_slow_mime_type &&
- has_local_path (file);
+
+ return file->details->type;
}
/**
@@ -4890,33 +5356,11 @@ nautilus_file_get_mime_type (NautilusFile *file)
{
if (file != NULL) {
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- if (file->details->info != NULL
- && file->details->info->mime_type != NULL) {
- return g_strdup (file->details->info->mime_type);
- }
- }
- return g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
-}
-
-/**
- * nautilus_file_get_guessed_mime_type
- *
- * Return the mime type that was guessed based on the extension.
- * @file: NautilusFile representing the file in question.
- *
- * Returns: The mime type.
- *
- **/
-char *
-nautilus_file_get_guessed_mime_type (NautilusFile *file)
-{
- if (file != NULL) {
- g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
- if (file->details->guessed_mime_type != NULL) {
- return g_strdup (file->details->guessed_mime_type);
+ if (file->details->mime_type != NULL) {
+ return g_strdup (eel_ref_str_peek (file->details->mime_type));
}
}
- return g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN);
+ return g_strdup ("application/octet-stream");
}
/**
@@ -4937,15 +5381,34 @@ nautilus_file_is_mime_type (NautilusFile *file, const char *mime_type)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
g_return_val_if_fail (mime_type != NULL, FALSE);
- if (file->details->info == NULL || file->details->info->mime_type == NULL) {
+ if (file->details->mime_type == NULL) {
return FALSE;
}
- return (gnome_vfs_mime_type_get_equivalence (file->details->info->mime_type,
- mime_type) != GNOME_VFS_MIME_UNRELATED);
+ return g_content_type_is_a (eel_ref_str_peek (file->details->mime_type),
+ mime_type);
}
+gboolean
+nautilus_file_is_launchable (NautilusFile *file)
+{
+ gboolean type_can_be_executable;
+
+ type_can_be_executable = FALSE;
+ if (file->details->mime_type != NULL) {
+ type_can_be_executable =
+ g_content_type_can_be_executable (eel_ref_str_peek (file->details->mime_type));
+ }
+
+ return type_can_be_executable &&
+ nautilus_file_can_get_permissions (file) &&
+ nautilus_file_can_execute (file) &&
+ nautilus_file_is_executable (file) &&
+ !nautilus_file_is_directory (file);
+}
+
+
/**
- * nautilus_file_get_emblem_names
+ * nautilus_file_get_emblem_icons
*
* Return the list of names of emblems that this file should display,
* in canonical order.
@@ -4955,16 +5418,101 @@ nautilus_file_is_mime_type (NautilusFile *file, const char *mime_type)
*
**/
GList *
-nautilus_file_get_emblem_names (NautilusFile *file)
+nautilus_file_get_emblem_icons (NautilusFile *file,
+ char **exclude)
{
+ GList *keywords, *l;
+ GList *icons;
+ char *icon_name;
+ char *keyword;
+ int i;
+ GIcon *icon;
+
if (file == NULL) {
return NULL;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
+
+ keywords = nautilus_file_get_keywords (file);
+ keywords = prepend_automatic_keywords (file, keywords);
+
+ icons = NULL;
+ for (l = keywords; l != NULL; l = l->next) {
+ keyword = l->data;
+
+#ifdef TRASH_IS_FAST_ENOUGH
+ if (strcmp (keyword, NAUTILUS_FILE_EMBLEM_NAME_TRASH) == 0) {
+ char *uri;
+ gboolean file_is_trash;
+ /* Leave out the trash emblem for the trash itself, since
+ * putting a trash emblem on a trash icon is gilding the
+ * lily.
+ */
+ uri = nautilus_file_get_uri (file);
+ file_is_trash = strcmp (uri, EEL_TRASH_URI) == 0;
+ g_free (uri);
+ if (file_is_trash) {
+ continue;
+ }
+ }
+#endif
+ if (exclude) {
+ for (i = 0; exclude[i] != NULL; i++) {
+ if (strcmp (exclude[i], keyword) == 0) {
+ continue;
+ }
+ }
+ }
+
+ icon_name = nautilus_icon_get_emblem_icon_by_name (keyword);
+ icon = g_themed_icon_new (icon_name);
+ g_free (icon_name);
+ icons = g_list_prepend (icons, icon);
+ }
+
+ eel_g_list_free_deep (keywords);
+
+ return icons;
+}
+
+GList *
+nautilus_file_get_emblem_pixbufs (NautilusFile *file,
+ int size,
+ gboolean force_size,
+ char **exclude)
+{
+ GList *icons, *l;
+ GList *pixbufs;
+ GIcon *icon;
+ GdkPixbuf *pixbuf;
+ NautilusIconInfo *icon_info;
+
+ icons = nautilus_file_get_emblem_icons (file, exclude);
+ pixbufs = NULL;
+
+ for (l = icons; l != NULL; l = l->next) {
+ icon = l->data;
+
+ icon_info = nautilus_icon_info_lookup (icon, size);
+ if (force_size) {
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (icon_info, size);
+ } else {
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault (icon_info);
+ }
+
+ if (pixbuf) {
+ pixbufs = g_list_prepend (pixbufs, pixbuf);
+ }
+
+
+ g_object_unref (icon);
+ }
+ g_list_free (icons);
+
+ return g_list_reverse (pixbufs);
+
- return prepend_automatic_emblem_names
- (file, nautilus_file_get_keywords (file));
}
static GList *
@@ -5059,10 +5607,16 @@ nautilus_file_set_keywords (NautilusFile *file, GList *keywords)
gboolean
nautilus_file_is_symbolic_link (NautilusFile *file)
{
- return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_FLAGS)
- ? FALSE : (file->details->info->flags & GNOME_VFS_FILE_FLAGS_SYMLINK);
+ return file->details->is_symlink;
+}
+
+gboolean
+nautilus_file_is_mountpoint (NautilusFile *file)
+{
+ return file->details->is_mountpoint;
}
+
/**
* nautilus_file_is_broken_symbolic_link
*
@@ -5082,7 +5636,7 @@ nautilus_file_is_broken_symbolic_link (NautilusFile *file)
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
/* Non-broken symbolic links return the target's type for get_file_type. */
- return nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK;
+ return nautilus_file_get_file_type (file) == G_FILE_TYPE_SYMBOLIC_LINK;
}
/**
@@ -5095,32 +5649,25 @@ nautilus_file_is_broken_symbolic_link (NautilusFile *file)
char *
nautilus_file_get_volume_free_space (NautilusFile *file)
{
- char * file_uri;
- GnomeVFSFileSize free_space;
- GnomeVFSResult result;
- GnomeVFSURI * vfs_uri;
+ goffset free_space;
+ GFileInfo *info;
+ GFile *location;
+ char *res;
- file_uri = nautilus_file_get_uri (file);
+ res = NULL;
- if (file_uri == NULL) {
- return NULL;
- }
-
- vfs_uri = gnome_vfs_uri_new (file_uri);
- g_free (file_uri);
-
- if (vfs_uri == NULL) {
- return NULL;
+ location = nautilus_file_get_location (file);
+ info = g_file_query_filesystem_info (location, G_FILE_ATTRIBUTE_FS_FREE, NULL, NULL);
+ if (info) {
+ if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FS_FREE)) {
+ free_space = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FS_FREE);
+ res = g_format_file_size_for_display (free_space);
+ }
+ g_object_unref (info);
}
+ g_object_unref (location);
- result = gnome_vfs_get_volume_free_space (vfs_uri, &free_space);
- gnome_vfs_uri_unref (vfs_uri);
-
- if (result == GNOME_VFS_OK) {
- return gnome_vfs_format_file_size_for_display (free_space);
- } else {
- return NULL;
- }
+ return res;
}
/**
@@ -5134,29 +5681,21 @@ nautilus_file_get_volume_free_space (NautilusFile *file)
char *
nautilus_file_get_volume_name (NautilusFile *file)
{
- char *local_path;
- char *file_uri;
- char *volume_name;
- GnomeVFSVolume *volume;
- file_uri = nautilus_file_get_uri (file);
+ GFile *location;
+ char *res;
+ GVolume *volume;
- volume = NULL;
-
- local_path = gnome_vfs_get_local_path_from_uri (file_uri);
- if (local_path != NULL) {
- volume = gnome_vfs_volume_monitor_get_volume_for_path (gnome_vfs_get_volume_monitor (), local_path);
- }
+ res = NULL;
- g_free (file_uri);
- g_free (local_path);
-
- if (volume != NULL) {
- volume_name = gnome_vfs_volume_get_display_name (volume);
- gnome_vfs_volume_unref (volume);
- return volume_name;
- } else {
- return NULL;
+ location = nautilus_file_get_location (file);
+ volume = g_file_find_enclosing_volume (location, NULL, NULL);
+ if (volume) {
+ res = g_strdup (g_volume_get_name (volume));
+ g_object_unref (volume);
}
+ g_object_unref (location);
+
+ return res;
}
/**
@@ -5173,9 +5712,7 @@ nautilus_file_get_symbolic_link_target_path (NautilusFile *file)
{
g_return_val_if_fail (nautilus_file_is_symbolic_link (file), NULL);
- return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)
- ? NULL
- : g_strdup (file->details->info->symlink_name);
+ return g_strdup (file->details->symlink_name);
}
/**
@@ -5190,24 +5727,30 @@ nautilus_file_get_symbolic_link_target_path (NautilusFile *file)
char *
nautilus_file_get_symbolic_link_target_uri (NautilusFile *file)
{
- char *file_uri;
- char *target;
- char *escaped_name;
+ GFile *location, *parent, *target;
+ char *target_uri;
g_return_val_if_fail (nautilus_file_is_symbolic_link (file), NULL);
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SYMLINK_NAME)) {
+ if (file->details->symlink_name == NULL) {
return NULL;
} else {
- file_uri = nautilus_file_get_uri (file);
- escaped_name = gnome_vfs_escape_path_string
- (file->details->info->symlink_name);
-
- target = gnome_vfs_uri_make_full_from_relative
- (file_uri, escaped_name);
- g_free (file_uri);
- g_free (escaped_name);
- return target;
+ target = NULL;
+
+ location = nautilus_file_get_location (file);
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
+ if (parent) {
+ target = g_file_resolve_relative_path (parent, file->details->symlink_name);
+ g_object_unref (parent);
+ }
+
+ target_uri = NULL;
+ if (target) {
+ target_uri = g_file_get_uri (target);
+ g_object_unref (target);
+ }
+ return target_uri;
}
}
@@ -5241,7 +5784,7 @@ nautilus_file_is_nautilus_link (NautilusFile *file)
gboolean
nautilus_file_is_directory (NautilusFile *file)
{
- return nautilus_file_get_file_type (file) == GNOME_VFS_FILE_TYPE_DIRECTORY;
+ return nautilus_file_get_file_type (file) == G_FILE_TYPE_DIRECTORY;
}
/**
@@ -5261,11 +5804,11 @@ nautilus_file_is_in_trash (NautilusFile *file)
return nautilus_directory_is_in_trash (file->details->directory);
}
-GnomeVFSResult
-nautilus_file_get_file_info_result (NautilusFile *file)
+GError *
+nautilus_file_get_file_info_error (NautilusFile *file)
{
if (!file->details->get_info_failed) {
- return GNOME_VFS_OK;
+ return NULL;
}
return file->details->get_info_error;
@@ -5305,15 +5848,14 @@ nautilus_file_contains_text (NautilusFile *file)
gboolean
nautilus_file_is_executable (NautilusFile *file)
{
- if (!nautilus_file_can_get_permissions (file)) {
+ if (!file->details->has_permissions) {
/* File's permissions field is not valid.
* Can't access specific permissions, so return FALSE.
*/
return FALSE;
}
- return ((file->details->info->permissions
- & GNOME_VFS_PERM_ACCESS_EXECUTABLE) != 0);
+ return file->details->can_execute;
}
/**
@@ -5398,11 +5940,7 @@ nautilus_file_mark_gone (NautilusFile *file)
nautilus_directory_remove_file (directory, file);
}
- /* Drop away all the old file information. */
- if (file->details->info != NULL) {
- gnome_vfs_file_info_unref (file->details->info);
- file->details->info = NULL;
- }
+ nautilus_file_clear_info (file);
/* FIXME bugzilla.gnome.org 42429:
* Maybe we can get rid of the name too eventually, but
@@ -5527,7 +6065,7 @@ nautilus_file_is_not_yet_confirmed (NautilusFile *file)
{
g_return_val_if_fail (NAUTILUS_IS_FILE (file), FALSE);
- return file->details->info == NULL;
+ return !file->details->got_file_info;
}
/**
@@ -5631,15 +6169,15 @@ invalidate_file_info (NautilusFile *file)
}
static void
-invalidate_slow_mime_type (NautilusFile *file)
+invalidate_link_info (NautilusFile *file)
{
- file->details->file_info_is_up_to_date = FALSE;
+ file->details->link_info_is_up_to_date = FALSE;
}
static void
-invalidate_link_info (NautilusFile *file)
+invalidate_thumbnail (NautilusFile *file)
{
- file->details->link_info_is_up_to_date = FALSE;
+ file->details->thumbnail_is_up_to_date = FALSE;
}
void
@@ -5687,9 +6225,6 @@ nautilus_file_invalidate_attributes_internal (NautilusFile *file,
if (request.file_info) {
invalidate_file_info (file);
}
- if (request.slow_mime_type) {
- invalidate_slow_mime_type (file);
- }
if (request.top_left_text) {
invalidate_top_left_text (file);
}
@@ -5699,6 +6234,9 @@ nautilus_file_invalidate_attributes_internal (NautilusFile *file,
if (request.extension_info) {
nautilus_file_invalidate_extension_info_internal (file);
}
+ if (request.thumbnail) {
+ invalidate_thumbnail (file);
+ }
/* FIXME bugzilla.gnome.org 45075: implement invalidating metadata */
}
@@ -5769,20 +6307,16 @@ nautilus_file_invalidate_attributes (NautilusFile *file,
NautilusFileAttributes
nautilus_file_get_all_attributes (void)
{
- return NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
- NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES |
- NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON |
+ return NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS |
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES |
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME |
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_VOLUMES;
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES |
+ NAUTILUS_FILE_ATTRIBUTE_METADATA |
+ NAUTILUS_FILE_ATTRIBUTE_TOP_LEFT_TEXT |
+ NAUTILUS_FILE_ATTRIBUTE_LARGE_TOP_LEFT_TEXT |
+ NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL;
}
void
@@ -5812,42 +6346,33 @@ nautilus_file_dump (NautilusFile *file)
uri = nautilus_file_get_uri (file);
g_print ("uri: %s \n", uri);
- if (file->details->info == NULL) {
+ if (!file->details->got_file_info) {
g_print ("no file info \n");
} else if (file->details->get_info_failed) {
g_print ("failed to get file info \n");
} else {
g_print ("size: %ld \n", size);
- switch (file->details->info->type) {
- case GNOME_VFS_FILE_TYPE_REGULAR:
+ switch (file->details->type) {
+ case G_FILE_TYPE_REGULAR:
file_kind = "regular file";
break;
- case GNOME_VFS_FILE_TYPE_DIRECTORY:
+ case G_FILE_TYPE_DIRECTORY:
file_kind = "folder";
break;
- case GNOME_VFS_FILE_TYPE_FIFO:
- file_kind = "fifo";
- break;
- case GNOME_VFS_FILE_TYPE_SOCKET:
- file_kind = "socket";
- break;
- case GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE:
- file_kind = "character device";
+ case G_FILE_TYPE_SPECIAL:
+ file_kind = "special";
break;
- case GNOME_VFS_FILE_TYPE_BLOCK_DEVICE:
- file_kind = "block device";
- break;
- case GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK:
+ case G_FILE_TYPE_SYMBOLIC_LINK:
file_kind = "symbolic link";
break;
- case GNOME_VFS_FILE_TYPE_UNKNOWN:
+ case G_FILE_TYPE_UNKNOWN:
default:
file_kind = "unknown";
break;
}
g_print ("kind: %s \n", file_kind);
- if (file->details->info->type == GNOME_VFS_FILE_TYPE_SYMBOLIC_LINK) {
- g_print ("link to %s \n", file->details->info->symlink_name);
+ if (file->details->type == G_FILE_TYPE_SYMBOLIC_LINK) {
+ g_print ("link to %s \n", file->details->symlink_name);
/* FIXME bugzilla.gnome.org 42430: add following of symlinks here */
}
/* FIXME bugzilla.gnome.org 42431: add permissions and other useful stuff here */
@@ -6173,11 +6698,74 @@ nautilus_extract_top_left_text (const char *text,
}
static void
+thumbnail_limit_changed_callback (gpointer user_data)
+{
+ cached_thumbnail_limit = eel_preferences_get_integer (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT);
+
+ /* Tell the world that icons might have changed. We could invent a narrower-scope
+ * signal to mean only "thumbnails might have changed" if this ends up being slow
+ * for some reason.
+ */
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
+thumbnail_size_changed_callback (gpointer user_data)
+{
+ cached_thumbnail_size = eel_preferences_get_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
+
+ /* Tell the world that icons might have changed. We could invent a narrower-scope
+ * signal to mean only "thumbnails might have changed" if this ends up being slow
+ * for some reason.
+ */
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
+show_thumbnails_changed_callback (gpointer user_data)
+{
+ show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
+
+ /* Tell the world that icons might have changed. We could invent a narrower-scope
+ * signal to mean only "thumbnails might have changed" if this ends up being slow
+ * for some reason.
+ */
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
+mime_type_data_changed_callback (GObject *signaller, gpointer user_data)
+{
+ /* Tell the world that icons might have changed. We could invent a narrower-scope
+ * signal to mean only "thumbnails might have changed" if this ends up being slow
+ * for some reason.
+ */
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
+icon_theme_changed_callback (GtkIconTheme *icon_theme,
+ gpointer user_data)
+{
+ /* Clear all pixmap caches as the icon => pixmap lookup changed */
+ nautilus_icon_info_clear_caches ();
+
+ /* Tell the world that icons might have changed. We could invent a narrower-scope
+ * signal to mean only "thumbnails might have changed" if this ends up being slow
+ * for some reason.
+ */
+ emit_change_signals_for_all_files_in_all_directories ();
+}
+
+static void
nautilus_file_class_init (NautilusFileClass *class)
{
+ GtkIconTheme *icon_theme;
+
parent_class = g_type_class_peek_parent (class);
G_OBJECT_CLASS (class)->finalize = finalize;
+ G_OBJECT_CLASS (class)->constructor = nautilus_file_constructor;
signals[CHANGED] =
g_signal_new ("changed",
@@ -6202,15 +6790,30 @@ nautilus_file_class_init (NautilusFileClass *class)
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_DATE_FORMAT,
&date_format_pref);
-}
-
-static GnomeVFSFileInfo *
-nautilus_file_get_vfs_file_info (NautilusFile *file)
-{
- if (file->details->info) {
- return gnome_vfs_file_info_dup (file->details->info);
- }
- return NULL;
+
+ thumbnail_limit_changed_callback (NULL);
+ eel_preferences_add_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
+ thumbnail_limit_changed_callback,
+ NULL);
+ thumbnail_size_changed_callback (NULL);
+ eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
+ thumbnail_size_changed_callback,
+ NULL);
+ show_thumbnails_changed_callback (NULL);
+ eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
+ show_thumbnails_changed_callback,
+ NULL);
+
+ icon_theme = gtk_icon_theme_get_default ();
+ g_signal_connect_object (icon_theme,
+ "changed",
+ G_CALLBACK (icon_theme_changed_callback),
+ NULL, 0);
+
+ g_signal_connect (nautilus_signaller_get_current (),
+ "mime_data_changed",
+ G_CALLBACK (mime_type_data_changed_callback),
+ NULL);
}
static void
@@ -6281,15 +6884,10 @@ nautilus_file_info_iface_init (NautilusFileInfoIface *iface)
iface->get_mime_type = nautilus_file_get_mime_type;
iface->is_mime_type = nautilus_file_is_mime_type;
iface->is_directory = nautilus_file_is_directory;
- iface->get_vfs_file_info = nautilus_file_get_vfs_file_info;
iface->add_emblem = nautilus_file_add_emblem;
iface->get_string_attribute = nautilus_file_get_string_attribute;
iface->add_string_attribute = nautilus_file_add_string_attribute;
iface->invalidate_extension_info = nautilus_file_invalidate_extension_info;
- iface->has_volume = nautilus_file_has_volume;
- iface->has_drive = nautilus_file_has_drive;
- iface->get_volume = nautilus_file_get_volume;
- iface->get_drive = nautilus_file_get_drive;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
@@ -6305,7 +6903,7 @@ nautilus_self_check_file (void)
EEL_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
- file_1 = nautilus_file_get ("file:///home/");
+ file_1 = nautilus_file_get_by_uri ("file:///home/");
EEL_CHECK_INTEGER_RESULT (G_OBJECT (file_1)->ref_count, 1);
EEL_CHECK_INTEGER_RESULT (G_OBJECT (file_1->details->directory)->ref_count, 1);
@@ -6315,8 +6913,8 @@ nautilus_self_check_file (void)
EEL_CHECK_INTEGER_RESULT (nautilus_directory_number_outstanding (), 0);
- file_1 = nautilus_file_get ("file:///etc");
- file_2 = nautilus_file_get ("file:///usr");
+ file_1 = nautilus_file_get_by_uri ("file:///etc");
+ file_2 = nautilus_file_get_by_uri ("file:///usr");
list = NULL;
list = g_list_prepend (list, file_1);
@@ -6338,19 +6936,19 @@ nautilus_self_check_file (void)
/* name checks */
- file_1 = nautilus_file_get ("file:///home/");
+ file_1 = nautilus_file_get_by_uri ("file:///home/");
EEL_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
- EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home/") == file_1, TRUE);
+ EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get_by_uri ("file:///home/") == file_1, TRUE);
nautilus_file_unref (file_1);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get ("file:///home") == file_1, TRUE);
+ EEL_CHECK_BOOLEAN_RESULT (nautilus_file_get_by_uri ("file:///home") == file_1, TRUE);
nautilus_file_unref (file_1);
nautilus_file_unref (file_1);
- file_1 = nautilus_file_get ("file:///home");
+ file_1 = nautilus_file_get_by_uri ("file:///home");
EEL_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "home");
nautilus_file_unref (file_1);
@@ -6359,22 +6957,22 @@ nautilus_self_check_file (void)
* It used to work, but when canonical uris changed from
* foo: to foo:/// it broke. I don't expect it to matter
* in real life */
- file_1 = nautilus_file_get (":");
+ file_1 = nautilus_file_get_by_uri (":");
EEL_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), ":");
nautilus_file_unref (file_1);
#endif
- file_1 = nautilus_file_get ("eazel:");
+ file_1 = nautilus_file_get_by_uri ("eazel:");
EEL_CHECK_STRING_RESULT (nautilus_file_get_name (file_1), "eazel");
nautilus_file_unref (file_1);
- file_1 = nautilus_file_get (EEL_TRASH_URI);
+ file_1 = nautilus_file_get_by_uri (EEL_TRASH_URI);
EEL_CHECK_STRING_RESULT (nautilus_file_get_display_name (file_1), _("Trash"));
nautilus_file_unref (file_1);
/* sorting */
- file_1 = nautilus_file_get ("file:///etc");
- file_2 = nautilus_file_get ("file:///usr");
+ file_1 = nautilus_file_get_by_uri ("file:///etc");
+ file_2 = nautilus_file_get_by_uri ("file:///usr");
EEL_CHECK_INTEGER_RESULT (G_OBJECT (file_1)->ref_count, 1);
EEL_CHECK_INTEGER_RESULT (G_OBJECT (file_2)->ref_count, 1);
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 532d8c945..e0895f6ac 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -26,9 +26,11 @@
#define NAUTILUS_FILE_H
#include <gtk/gtkobject.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
+#include <gio/gfileinfo.h>
+#include <gio/gfile.h>
+#include <gio/gioerror.h>
#include <libnautilus-private/nautilus-file-attributes.h>
+#include <libnautilus-private/nautilus-icon-info.h>
/* NautilusFile is an object used to represent a single element of a
* NautilusDirectory. It's lightweight and relies on NautilusDirectory
@@ -51,6 +53,8 @@ typedef struct NautilusFile NautilusFile;
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_FILE))
#define NAUTILUS_IS_FILE_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_FILE))
+#define NAUTILUS_FILE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_FILE, NautilusFileClass))
typedef enum {
NAUTILUS_FILE_SORT_NONE,
@@ -69,6 +73,15 @@ typedef enum {
NAUTILUS_REQUEST_DONE
} NautilusRequestStatus;
+typedef enum {
+ NAUTILUS_FILE_ICON_FLAGS_NONE = 0,
+ NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS = (1<<0),
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING = (1<<1),
+ NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT = (1<<2),
+ NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT = (1<<3),
+ NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER = (1<<4)
+} NautilusFileIconFlags;
+
/* Emblems sometimes displayed for NautilusFiles. Do not localize. */
#define NAUTILUS_FILE_EMBLEM_NAME_SYMBOLIC_LINK "symbolic-link"
#define NAUTILUS_FILE_EMBLEM_NAME_CANT_READ "noread"
@@ -82,7 +95,8 @@ typedef void (*NautilusFileCallback) (NautilusFile *file,
typedef void (*NautilusFileListCallback) (GList *file_list,
gpointer callback_data);
typedef void (*NautilusFileOperationCallback) (NautilusFile *file,
- GnomeVFSResult result,
+ GFile *result_location,
+ GError *error,
gpointer callback_data);
typedef int (*NautilusWidthMeasureCallback) (const char *string,
void *context);
@@ -90,16 +104,21 @@ typedef char * (*NautilusTruncateCallback) (const char *string,
int width,
void *context);
+
+#define NAUTILUS_FILE_ATTRIBUTES_FOR_ICON (NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |NAUTILUS_FILE_ATTRIBUTE_METADATA | NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL)
+
typedef void NautilusFileListHandle;
/* GObject requirements. */
GType nautilus_file_get_type (void);
/* Getting at a single file. */
-NautilusFile * nautilus_file_get (const char *uri);
+NautilusFile * nautilus_file_get (GFile *location);
+NautilusFile * nautilus_file_get_by_uri (const char *uri);
/* Get a file only if the nautilus version already exists */
-NautilusFile * nautilus_file_get_existing (const char *uri);
+NautilusFile * nautilus_file_get_existing (GFile *location);
+NautilusFile * nautilus_file_get_existing_by_uri (const char *uri);
/* Covers for gtk_object_ref and gtk_object_unref that provide two conveniences:
* 1) You don't have to cast to GtkObject *, so using these is type safe.
@@ -135,20 +154,25 @@ void nautilus_file_invalidate_all_attributes (Nautilu
/* Basic attributes for file objects. */
gboolean nautilus_file_contains_text (NautilusFile *file);
char * nautilus_file_get_display_name (NautilusFile *file);
+char * nautilus_file_get_edit_name (NautilusFile *file);
char * nautilus_file_get_name (NautilusFile *file);
+GFile * nautilus_file_get_location (NautilusFile *file);
char * nautilus_file_get_uri (NautilusFile *file);
char * nautilus_file_get_uri_scheme (NautilusFile *file);
NautilusFile * nautilus_file_get_parent (NautilusFile *file);
+GFile * nautilus_file_get_parent_location (NautilusFile *file);
char * nautilus_file_get_parent_uri (NautilusFile *file);
char * nautilus_file_get_parent_uri_for_display (NautilusFile *file);
-GnomeVFSFileSize nautilus_file_get_size (NautilusFile *file);
-GnomeVFSFileType nautilus_file_get_file_type (NautilusFile *file);
-char * nautilus_file_get_guessed_mime_type (NautilusFile *file);
+gboolean nautilus_file_can_get_size (NautilusFile *file);
+goffset nautilus_file_get_size (NautilusFile *file);
+time_t nautilus_file_get_mtime (NautilusFile *file);
+GFileType nautilus_file_get_file_type (NautilusFile *file);
char * nautilus_file_get_mime_type (NautilusFile *file);
gboolean nautilus_file_is_mime_type (NautilusFile *file,
const char *mime_type);
-gboolean nautilus_file_needs_slow_mime_type (NautilusFile *file);
+gboolean nautilus_file_is_launchable (NautilusFile *file);
gboolean nautilus_file_is_symbolic_link (NautilusFile *file);
+gboolean nautilus_file_is_mountpoint (NautilusFile *file);
char * nautilus_file_get_volume_free_space (NautilusFile *file);
char * nautilus_file_get_volume_name (NautilusFile *file);
char * nautilus_file_get_symbolic_link_target_path (NautilusFile *file);
@@ -161,7 +185,7 @@ gboolean nautilus_file_is_in_trash (Nautilu
gboolean nautilus_file_is_in_desktop (NautilusFile *file);
gboolean nautilus_file_is_home (NautilusFile *file);
gboolean nautilus_file_is_desktop_directory (NautilusFile *file);
-GnomeVFSResult nautilus_file_get_file_info_result (NautilusFile *file);
+GError * nautilus_file_get_file_info_error (NautilusFile *file);
gboolean nautilus_file_get_directory_item_count (NautilusFile *file,
guint *count,
gboolean *count_unreadable);
@@ -170,14 +194,20 @@ NautilusRequestStatus nautilus_file_get_deep_counts (Nautilu
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size,
+ goffset *total_size,
gboolean force);
+gboolean nautilus_file_should_show_thumbnail (NautilusFile *file);
gboolean nautilus_file_should_show_directory_item_count (NautilusFile *file);
gboolean nautilus_file_should_show_type (NautilusFile *file);
GList * nautilus_file_get_keywords (NautilusFile *file);
void nautilus_file_set_keywords (NautilusFile *file,
GList *keywords);
-GList * nautilus_file_get_emblem_names (NautilusFile *file);
+GList * nautilus_file_get_emblem_icons (NautilusFile *file,
+ char **exclude);
+GList * nautilus_file_get_emblem_pixbufs (NautilusFile *file,
+ int size,
+ gboolean force_size,
+ char **exclude);
char * nautilus_file_get_top_left_text (NautilusFile *file);
char * nautilus_file_peek_top_left_text (NautilusFile *file,
gboolean need_large_text,
@@ -185,10 +215,15 @@ char * nautilus_file_peek_top_left_text (Nautilu
gboolean nautilus_file_get_directory_item_mime_types (NautilusFile *file,
GList **mime_list);
+void nautilus_file_set_attributes (NautilusFile *file,
+ GFileInfo *attributes,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+
/* Permissions. */
gboolean nautilus_file_can_get_permissions (NautilusFile *file);
gboolean nautilus_file_can_set_permissions (NautilusFile *file);
-GnomeVFSFilePermissions nautilus_file_get_permissions (NautilusFile *file);
+guint nautilus_file_get_permissions (NautilusFile *file);
gboolean nautilus_file_can_get_owner (NautilusFile *file);
gboolean nautilus_file_can_set_owner (NautilusFile *file);
gboolean nautilus_file_can_get_group (NautilusFile *file);
@@ -206,12 +241,23 @@ gboolean nautilus_file_can_read (Nautilu
gboolean nautilus_file_can_write (NautilusFile *file);
gboolean nautilus_file_can_execute (NautilusFile *file);
gboolean nautilus_file_can_rename (NautilusFile *file);
+gboolean nautilus_file_can_delete (NautilusFile *file);
+gboolean nautilus_file_can_trash (NautilusFile *file);
-/* Volumes. */
-gboolean nautilus_file_has_volume (NautilusFile *file);
-gboolean nautilus_file_has_drive (NautilusFile *file);
-GnomeVFSVolume * nautilus_file_get_volume (NautilusFile *file);
-GnomeVFSDrive * nautilus_file_get_drive (NautilusFile *file);
+gboolean nautilus_file_can_mount (NautilusFile *file);
+gboolean nautilus_file_can_unmount (NautilusFile *file);
+gboolean nautilus_file_can_eject (NautilusFile *file);
+
+void nautilus_file_mount (NautilusFile *file,
+ GMountOperation *mount_op,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+void nautilus_file_unmount (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+void nautilus_file_eject (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
/* Basic operations for file objects. */
void nautilus_file_set_owner (NautilusFile *file,
@@ -223,7 +269,7 @@ void nautilus_file_set_group (Nautilu
NautilusFileOperationCallback callback,
gpointer callback_data);
void nautilus_file_set_permissions (NautilusFile *file,
- GnomeVFSFilePermissions permissions,
+ guint32 permissions,
NautilusFileOperationCallback callback,
gpointer callback_data);
void nautilus_file_rename (NautilusFile *file,
@@ -333,6 +379,16 @@ char * nautilus_file_get_drop_target_uri (Nautilu
char * nautilus_file_get_custom_icon (NautilusFile *file);
+GIcon * nautilus_file_get_gicon (NautilusFile *file,
+ NautilusFileIconFlags flags);
+NautilusIconInfo * nautilus_file_get_icon (NautilusFile *file,
+ int size,
+ NautilusFileIconFlags flags);
+GdkPixbuf * nautilus_file_get_icon_pixbuf (NautilusFile *file,
+ int size,
+ gboolean force_size,
+ NautilusFileIconFlags flags);
+
gboolean nautilus_file_has_open_window (NautilusFile *file);
void nautilus_file_set_has_open_window (NautilusFile *file,
gboolean has_open_window);
@@ -377,6 +433,12 @@ typedef enum {
typedef struct {
GObjectClass parent_slot;
+
+ /* Subclasses can set this to something other than G_FILE_TYPE_UNKNOWN and
+ it will be used as the default file type. This is useful when creating
+ a "virtual" NautilusFile subclass that you can't actually get real
+ information about. For exaple NautilusDesktopDirectoryFile. */
+ GFileType default_file_type;
/* Called when the file notices any change. */
void (* changed) (NautilusFile *file);
@@ -399,7 +461,6 @@ typedef struct {
gpointer callback_data);
gboolean (* check_if_ready) (NautilusFile *file,
NautilusFileAttributes attributes);
- GnomeVFSFileType (* get_file_type) (NautilusFile *file);
gboolean (* get_item_count) (NautilusFile *file,
guint *count,
gboolean *count_unreadable);
@@ -407,11 +468,22 @@ typedef struct {
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size);
+ goffset *total_size);
gboolean (* get_date) (NautilusFile *file,
NautilusDateType type,
time_t *date);
char * (* get_where_string) (NautilusFile *file);
+
+ void (* mount) (NautilusFile *file,
+ GMountOperation *mount_op,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+ void (* unmount) (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
+ void (* eject) (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data);
} NautilusFileClass;
#endif /* NAUTILUS_FILE_H */
diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c
index 2f125f53e..0ec8fcf51 100644
--- a/libnautilus-private/nautilus-global-preferences.c
+++ b/libnautilus-private/nautilus-global-preferences.c
@@ -28,7 +28,6 @@
#include "nautilus-file-utilities.h"
#include "nautilus-file.h"
-#include "nautilus-icon-factory.h"
#include <eel/eel-enumeration.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
@@ -36,11 +35,9 @@
#include <eel/eel-string.h>
#include <glib/gi18n.h>
#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
/* Constants */
-#define STRING_LIST_DEFAULT_TOKENS_DELIMETER ","
+#define STRING_ARRAY_DEFAULT_TOKENS_DELIMETER ","
#define PREFERENCES_SORT_ORDER_MANUALLY 100
/* Path for gnome-vfs preferences */
@@ -64,15 +61,14 @@ typedef enum
PREFERENCE_BOOLEAN = 1,
PREFERENCE_INTEGER,
PREFERENCE_STRING,
- PREFERENCE_STRING_LIST
+ PREFERENCE_STRING_ARRAY
} PreferenceType;
/* Enumerations used to qualify some INTEGER preferences */
static EelEnumerationEntry speed_tradeoff_enum_entries[] = {
{ "always", N_("_Always"), NAUTILUS_SPEED_TRADEOFF_ALWAYS },
{ "local_only", N_("_Local File Only"), NAUTILUS_SPEED_TRADEOFF_LOCAL_ONLY },
- { "never", N_("_Never"), NAUTILUS_SPEED_TRADEOFF_NEVER },
- { NULL }
+ { "never", N_("_Never"), NAUTILUS_SPEED_TRADEOFF_NEVER }
};
static EelEnumerationEntry default_zoom_level_enum_entries[] = {
@@ -89,8 +85,7 @@ static EelEnumerationEntry default_zoom_level_enum_entries[] = {
/* xgettext:no-c-format */
{ "larger", N_("200%"), NAUTILUS_ZOOM_LEVEL_LARGER },
/* xgettext:no-c-format */
- { "largest", N_("400%"), NAUTILUS_ZOOM_LEVEL_LARGEST },
- { NULL }
+ { "largest", N_("400%"), NAUTILUS_ZOOM_LEVEL_LARGEST }
};
static EelEnumerationEntry file_size_enum_entries[] = {
@@ -100,8 +95,7 @@ static EelEnumerationEntry file_size_enum_entries[] = {
{ "3145728", N_("3 MB"), 3145728 },
{ "5242880", N_("5 MB"), 5242880 },
{ "10485760", N_("10 MB"), 10485760 },
- { "104857600", N_("100 MB"), 104857600 },
- { NULL }
+ { "104857600", N_("100 MB"), 104857600 }
};
static EelEnumerationEntry click_policy_enum_entries[] = {
@@ -112,8 +106,7 @@ static EelEnumerationEntry click_policy_enum_entries[] = {
{ "double",
N_("Activate items with a _double click"),
NAUTILUS_CLICK_POLICY_DOUBLE
- },
- { NULL }
+ }
};
static EelEnumerationEntry executable_text_activation_enum_entries[] = {
@@ -128,8 +121,7 @@ static EelEnumerationEntry executable_text_activation_enum_entries[] = {
{ "ask",
N_("_Ask each time"),
NAUTILUS_EXECUTABLE_TEXT_ASK
- },
- { NULL }
+ }
};
static EelEnumerationEntry search_bar_type_enum_entries[] = {
@@ -140,14 +132,12 @@ static EelEnumerationEntry search_bar_type_enum_entries[] = {
{ "search by text and properties",
N_("Search for files by file name and file properties"),
NAUTILUS_COMPLEX_SEARCH_BAR
- },
- { NULL }
+ }
};
static EelEnumerationEntry default_folder_viewer_enum_entries[] = {
{ "icon_view", N_("Icon View"), NAUTILUS_DEFAULT_FOLDER_VIEWER_ICON_VIEW },
- { "list_view", N_("List View"), NAUTILUS_DEFAULT_FOLDER_VIEWER_LIST_VIEW },
- { NULL }
+ { "list_view", N_("List View"), NAUTILUS_DEFAULT_FOLDER_VIEWER_LIST_VIEW }
};
static EelEnumerationEntry default_icon_view_sort_order_enum_entries[] = {
@@ -157,8 +147,7 @@ static EelEnumerationEntry default_icon_view_sort_order_enum_entries[] = {
{ "size", N_("By Size"), NAUTILUS_FILE_SORT_BY_SIZE },
{ "type", N_("By Type"), NAUTILUS_FILE_SORT_BY_TYPE },
{ "modification_date", N_("By Modification Date"), NAUTILUS_FILE_SORT_BY_MTIME },
- { "emblems", N_("By Emblems"), NAUTILUS_FILE_SORT_BY_EMBLEMS },
- { NULL }
+ { "emblems", N_("By Emblems"), NAUTILUS_FILE_SORT_BY_EMBLEMS }
};
static EelEnumerationEntry standard_font_size_entries[] = {
@@ -170,34 +159,14 @@ static EelEnumerationEntry standard_font_size_entries[] = {
{ "18", N_("18"), 18 },
{ "20", N_("20"), 20 },
{ "22", N_("22"), 22 },
- { "24", N_("24"), 24 },
- { NULL }
+ { "24", N_("24"), 24 }
};
/* These are not translated, because the text is not used in the ui */
static EelEnumerationEntry date_format_entries[] = {
{ "locale", "Locale Default", NAUTILUS_DATE_FORMAT_LOCALE },
{ "iso", "ISO Format", NAUTILUS_DATE_FORMAT_ISO },
- { "informal", "Informal", NAUTILUS_DATE_FORMAT_INFORMAL },
- { NULL }
-};
-
-/* These enumerations are used in the preferences dialog to
- * populate widgets and route preferences changes between the
- * storage (GConf) and the displayed values.
- */
-static EelEnumerationInfo enumerations[] = {
- { "click_policy", click_policy_enum_entries },
- { "default_folder_viewer", default_folder_viewer_enum_entries },
- { "default_icon_view_sort_order", default_icon_view_sort_order_enum_entries },
- { "default_zoom_level", default_zoom_level_enum_entries },
- { "executable_text_activation", executable_text_activation_enum_entries },
- { "file_size", file_size_enum_entries },
- { "search_bar_type", search_bar_type_enum_entries },
- { "speed_tradeoff", speed_tradeoff_enum_entries },
- { "standard_font_size", standard_font_size_entries },
- { "date_format", date_format_entries },
- { NULL }
+ { "informal", "Informal", NAUTILUS_DATE_FORMAT_INFORMAL }
};
/*
@@ -236,7 +205,7 @@ typedef struct
* PREFERENCE_BOOLEAN
* PREFERENCE_INTEGER
* PREFERENCE_STRING
- * PREFERENCE_STRING_LIST
+ * PREFERENCE_STRING_ARRAY
*
* 3. fallback_value
* Emergency fallback value if our gconf schemas are hosed somehow.
@@ -348,7 +317,7 @@ static const PreferenceDefault preference_defaults[] = {
"search_bar_type"
},
{ NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
- PREFERENCE_STRING_LIST,
+ PREFERENCE_STRING_ARRAY,
"size,date_modified,type",
NULL, NULL,
NULL
@@ -566,14 +535,47 @@ global_preferences_register_enumerations (void)
{
guint i;
- /* Register the enumerations */
- eel_enumeration_register (enumerations);
+ /* Register the enumerations.
+ * These enumerations are used in the preferences dialog to
+ * populate widgets and route preferences changes between the
+ * storage (GConf) and the displayed values.
+ */
+ eel_enumeration_register ("click_policy",
+ click_policy_enum_entries,
+ G_N_ELEMENTS (click_policy_enum_entries));
+ eel_enumeration_register ("default_folder_viewer",
+ default_folder_viewer_enum_entries,
+ G_N_ELEMENTS (default_folder_viewer_enum_entries));
+ eel_enumeration_register ("default_icon_view_sort_order",
+ default_icon_view_sort_order_enum_entries,
+ G_N_ELEMENTS (default_icon_view_sort_order_enum_entries));
+ eel_enumeration_register ("default_zoom_level",
+ default_zoom_level_enum_entries,
+ G_N_ELEMENTS (default_zoom_level_enum_entries));
+ eel_enumeration_register ("executable_text_activation",
+ executable_text_activation_enum_entries,
+ G_N_ELEMENTS (executable_text_activation_enum_entries));
+ eel_enumeration_register ("file_size",
+ file_size_enum_entries,
+ G_N_ELEMENTS (file_size_enum_entries));
+ eel_enumeration_register ("search_bar_type",
+ search_bar_type_enum_entries,
+ G_N_ELEMENTS (search_bar_type_enum_entries));
+ eel_enumeration_register ("speed_tradeoff",
+ speed_tradeoff_enum_entries,
+ G_N_ELEMENTS (speed_tradeoff_enum_entries));
+ eel_enumeration_register ("standard_font_size",
+ standard_font_size_entries,
+ G_N_ELEMENTS (standard_font_size_entries));
+ eel_enumeration_register ("date_format",
+ date_format_entries,
+ G_N_ELEMENTS (date_format_entries));
/* Set the enumeration ids for preferences that need them */
for (i = 0; preference_defaults[i].name != NULL; i++) {
if (eel_strlen (preference_defaults[i].enumeration_id) > 0) {
g_assert (preference_defaults[i].type == PREFERENCE_STRING
- || preference_defaults[i].type == PREFERENCE_STRING_LIST
+ || preference_defaults[i].type == PREFERENCE_STRING_ARRAY
|| preference_defaults[i].type == PREFERENCE_INTEGER);
eel_preferences_set_enumeration_id (preference_defaults[i].name,
preference_defaults[i].enumeration_id);
@@ -587,11 +589,11 @@ global_preferences_install_one_default (const char *preference_name,
const PreferenceDefault *preference_default)
{
gpointer value = NULL;
- EelStringList *string_list_value;
-
+ char **string_array_value;
+
g_return_if_fail (preference_name != NULL);
g_return_if_fail (preference_type >= PREFERENCE_BOOLEAN);
- g_return_if_fail (preference_type <= PREFERENCE_STRING_LIST);
+ g_return_if_fail (preference_type <= PREFERENCE_STRING_ARRAY);
g_return_if_fail (preference_default != NULL);
/* If a callback is given, use that to fetch the default value */
@@ -617,14 +619,14 @@ global_preferences_install_one_default (const char *preference_name,
eel_preferences_set_emergency_fallback_string (preference_name,
value);
break;
-
- case PREFERENCE_STRING_LIST:
- string_list_value = eel_string_list_new_from_tokens (value,
- STRING_LIST_DEFAULT_TOKENS_DELIMETER,
- TRUE);
- eel_preferences_set_emergency_fallback_string_list (preference_name,
- string_list_value);
- eel_string_list_free (string_list_value);
+
+ case PREFERENCE_STRING_ARRAY:
+ string_array_value = g_strsplit (value,
+ STRING_ARRAY_DEFAULT_TOKENS_DELIMETER,
+ -1);
+ eel_preferences_set_emergency_fallback_string_array (preference_name,
+ string_array_value);
+ g_strfreev (string_array_value);
break;
default:
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index 13149b5b7..9054b3353 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -30,7 +30,6 @@
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
-#include "nautilus-icon-factory.h"
#include "nautilus-icon-private.h"
#include <eel/eel-art-extensions.h>
#include <eel/eel-gdk-extensions.h>
@@ -45,10 +44,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtksignal.h>
#include <gdk/gdk.h>
-#include <libart_lgpl/art_rgb.h>
-#include <libart_lgpl/art_rgb_affine.h>
-#include <libart_lgpl/art_rgb_rgba_affine.h>
-#include <libart_lgpl/art_svp_vpath.h>
#include <librsvg/rsvg.h>
#include <glib/gi18n.h>
#include <eel/eel-canvas-util.h>
@@ -77,7 +72,8 @@ struct NautilusIconCanvasItemDetails {
GList *emblem_pixbufs;
char *editable_text; /* Text that can be modified by a renaming function */
char *additional_text; /* Text that cannot be modifed, such as file size, etc. */
- NautilusEmblemAttachPoints *attach_points;
+ GdkPoint *attach_points;
+ int n_attach_points;
/* Size of the text at current font. */
int text_dx;
@@ -115,11 +111,11 @@ struct NautilusIconCanvasItemDetails {
PangoLayout *embedded_text_layout;
/* Cached rectangle in canvas coordinates */
- ArtIRect canvas_rect;
- ArtIRect text_rect;
- ArtIRect emblem_rect;
+ EelIRect canvas_rect;
+ EelIRect text_rect;
+ EelIRect emblem_rect;
- ArtIRect bounds_cache;
+ EelIRect bounds_cache;
/* Accessibility bits */
GailTextUtil *text_util;
@@ -161,7 +157,7 @@ typedef struct {
typedef struct {
NautilusIconCanvasItem *icon_item;
- ArtIRect icon_rect;
+ EelIRect icon_rect;
RectangleSide side;
int position;
int index;
@@ -178,21 +174,21 @@ static void nautilus_icon_canvas_item_init (NautilusIconCanvasItem
static void draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
gboolean create_mask,
- ArtIRect icon_rect);
+ EelIRect icon_rect);
static void draw_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
gboolean create_mask,
- ArtIRect icon_rect);
+ EelIRect icon_rect);
static void measure_label_text (NautilusIconCanvasItem *item);
static void get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
- ArtIRect *rect);
+ EelIRect *rect);
static void emblem_layout_reset (EmblemLayout *layout,
NautilusIconCanvasItem *icon_item,
- ArtIRect icon_rect,
+ EelIRect icon_rect,
gboolean is_rtl);
static gboolean emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
- ArtIRect *emblem_rect,
+ EelIRect *emblem_rect,
gboolean is_rtl);
static void draw_pixbuf (GdkPixbuf *pixbuf,
GdkDrawable *drawable,
@@ -210,7 +206,7 @@ static void draw_label_layout (NautilusIconCanvasItem
int y,
GdkGC *gc);
static gboolean hit_test_stretch_handle (NautilusIconCanvasItem *item,
- ArtIRect canvas_rect,
+ EelIRect canvas_rect,
GtkCornerType *corner);
static void draw_embedded_text (NautilusIconCanvasItem *icon_item,
GdkDrawable *drawable,
@@ -467,8 +463,8 @@ nautilus_icon_canvas_item_get_image (NautilusIconCanvasItem *item,
GdkGC *gc;
int width, height;
int item_offset_x, item_offset_y;
- ArtIRect icon_rect;
- ArtIRect emblem_rect;
+ EelIRect icon_rect;
+ EelIRect emblem_rect;
GdkPixbuf *pixbuf;
GdkPixbuf *emblem_pixbuf;
EmblemLayout emblem_layout;
@@ -635,14 +631,16 @@ nautilus_icon_canvas_item_set_emblems (NautilusIconCanvasItem *item,
void
nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item,
- NautilusEmblemAttachPoints *attach_points)
+ GdkPoint *attach_points,
+ int n_attach_points)
{
g_free (item->details->attach_points);
item->details->attach_points = NULL;
+ item->details->n_attach_points = 0;
- if (attach_points != NULL && attach_points->num_points != 0) {
- item->details->attach_points = g_new (NautilusEmblemAttachPoints, 1);
- *item->details->attach_points = *attach_points;
+ if (attach_points != NULL && n_attach_points != 0) {
+ item->details->attach_points = g_memdup (attach_points, n_attach_points * sizeof (GdkPoint));
+ item->details->n_attach_points = n_attach_points;
}
nautilus_icon_canvas_item_invalidate_bounds_cache (item);
@@ -691,7 +689,7 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item,
*/
EelCanvasItem *item;
- ArtPoint top_left, bottom_right;
+ EelDPoint top_left, bottom_right;
item = EEL_CANVAS_ITEM (icon_item);
@@ -711,12 +709,12 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item,
&item->x2, &item->y2);
}
-static ArtIRect
+static EelIRect
compute_text_rectangle (const NautilusIconCanvasItem *item,
- ArtIRect icon_rectangle,
+ EelIRect icon_rectangle,
gboolean canvas_coords)
{
- ArtIRect text_rectangle;
+ EelIRect text_rectangle;
double pixels_per_unit;
double text_width, text_height, text_dx;
@@ -751,12 +749,12 @@ compute_text_rectangle (const NautilusIconCanvasItem *item,
return text_rectangle;
}
-static ArtIRect
+static EelIRect
get_current_canvas_bounds (EelCanvasItem *item)
{
- ArtIRect bounds;
+ EelIRect bounds;
- g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), eel_art_irect_empty);
+ g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), eel_irect_empty);
bounds.x0 = item->x1;
bounds.y0 = item->y1;
@@ -770,7 +768,7 @@ void
nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
double i2w_dx, double i2w_dy)
{
- ArtIRect before, after, emblem_rect;
+ EelIRect before, after, emblem_rect;
EmblemLayout emblem_layout;
EelCanvasItem *canvas_item;
GdkPixbuf *emblem_pixbuf;
@@ -784,7 +782,7 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
after = get_current_canvas_bounds (canvas_item);
/* If the bounds didn't change, we are done. */
- if (eel_art_irect_equal (before, after)) {
+ if (eel_irect_equal (before, after)) {
return;
}
@@ -801,7 +799,7 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
item->details->emblem_rect.y1 = 0;
emblem_layout_reset (&emblem_layout, item, item->details->canvas_rect, is_rtl);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) {
- art_irect_union (&item->details->emblem_rect, &item->details->emblem_rect, &emblem_rect);
+ eel_irect_union (&item->details->emblem_rect, &item->details->emblem_rect, &emblem_rect);
}
/* queue a redraw. */
@@ -947,7 +945,7 @@ static void
draw_or_measure_label_text (NautilusIconCanvasItem *item,
GdkDrawable *drawable,
gboolean create_mask,
- ArtIRect icon_rect)
+ EelIRect icon_rect)
{
NautilusIconCanvasItemDetails *details;
NautilusIconContainer *container;
@@ -962,7 +960,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
int max_text_width;
int x;
GdkGC *gc;
- ArtIRect text_rect;
+ EelIRect text_rect;
int text_back_padding_x, text_back_padding_y;
icon_width = 0;
@@ -1166,7 +1164,7 @@ draw_or_measure_label_text (NautilusIconCanvasItem *item,
static void
measure_label_text (NautilusIconCanvasItem *item)
{
- ArtIRect rect = {0, };
+ EelIRect rect = {0, };
/* check to see if the cached values are still valid; if so, there's
* no work necessary
@@ -1181,7 +1179,7 @@ measure_label_text (NautilusIconCanvasItem *item)
static void
draw_label_text (NautilusIconCanvasItem *item, GdkDrawable *drawable,
- gboolean create_mask, ArtIRect icon_rect)
+ gboolean create_mask, EelIRect icon_rect)
{
draw_or_measure_label_text (item, drawable, create_mask, icon_rect);
}
@@ -1232,7 +1230,7 @@ get_knob_pixbuf (void)
static void
draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
- const ArtIRect *rect)
+ const EelIRect *rect)
{
GtkWidget *widget;
GdkGC *gc;
@@ -1285,7 +1283,7 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
}
static void
-emblem_layout_reset (EmblemLayout *layout, NautilusIconCanvasItem *icon_item, ArtIRect icon_rect, gboolean is_rtl)
+emblem_layout_reset (EmblemLayout *layout, NautilusIconCanvasItem *icon_item, EelIRect icon_rect, gboolean is_rtl)
{
layout->icon_item = icon_item;
layout->icon_rect = icon_rect;
@@ -1298,12 +1296,12 @@ emblem_layout_reset (EmblemLayout *layout, NautilusIconCanvasItem *icon_item, Ar
static gboolean
emblem_layout_next (EmblemLayout *layout,
GdkPixbuf **emblem_pixbuf,
- ArtIRect *emblem_rect,
+ EelIRect *emblem_rect,
gboolean is_rtl)
{
GdkPixbuf *pixbuf;
int width, height, x, y;
- NautilusEmblemAttachPoints *attach_points;
+ GdkPoint *attach_points;
/* Check if we have layed out all of the pixbufs. */
if (layout->emblem == NULL) {
@@ -1321,12 +1319,12 @@ emblem_layout_next (EmblemLayout *layout,
attach_points = layout->icon_item->details->attach_points;
if (attach_points != NULL) {
- if (layout->index >= attach_points->num_points) {
+ if (layout->index >= layout->icon_item->details->n_attach_points) {
return FALSE;
}
- x = layout->icon_rect.x0 + attach_points->points[layout->index].x;
- y = layout->icon_rect.y0 + attach_points->points[layout->index].y;
+ x = layout->icon_rect.x0 + attach_points[layout->index].x;
+ y = layout->icon_rect.y0 + attach_points[layout->index].y;
layout->index += 1;
@@ -1602,9 +1600,9 @@ real_map_pixbuf (NautilusIconCanvasItem *icon_item)
audio_filename = nautilus_pixmap_file ("audio.svg");
if (audio_filename != NULL) {
audio_pixbuf = rsvg_pixbuf_from_file_at_zoom_with_max (audio_filename, zoom, zoom,
- NAUTILUS_ICON_MAXIMUM_SIZE,
- NAUTILUS_ICON_MAXIMUM_SIZE,
- NULL);
+ NAUTILUS_ICON_MAXIMUM_SIZE,
+ NAUTILUS_ICON_MAXIMUM_SIZE,
+ NULL);
} else {
audio_pixbuf = NULL;
}
@@ -1754,7 +1752,7 @@ nautilus_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
{
NautilusIconCanvasItem *icon_item;
NautilusIconCanvasItemDetails *details;
- ArtIRect icon_rect, emblem_rect;
+ EelIRect icon_rect, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf, *temp_pixbuf;
GdkRectangle draw_rect, pixbuf_rect;
@@ -2017,9 +2015,9 @@ nautilus_icon_canvas_item_event (EelCanvasItem *item, GdkEvent *event)
}
static gboolean
-hit_test_pixbuf (GdkPixbuf *pixbuf, ArtIRect pixbuf_location, ArtIRect probe_rect)
+hit_test_pixbuf (GdkPixbuf *pixbuf, EelIRect pixbuf_location, EelIRect probe_rect)
{
- ArtIRect relative_rect, pixbuf_rect;
+ EelIRect relative_rect, pixbuf_rect;
int x, y;
guint8 *pixel;
@@ -2037,8 +2035,8 @@ hit_test_pixbuf (GdkPixbuf *pixbuf, ArtIRect pixbuf_location, ArtIRect probe_rec
pixbuf_rect.y0 = 0;
pixbuf_rect.x1 = gdk_pixbuf_get_width (pixbuf);
pixbuf_rect.y1 = gdk_pixbuf_get_height (pixbuf);
- art_irect_intersect (&relative_rect, &relative_rect, &pixbuf_rect);
- if (art_irect_empty (&relative_rect)) {
+ eel_irect_intersect (&relative_rect, &relative_rect, &pixbuf_rect);
+ if (eel_irect_is_empty (&relative_rect)) {
return FALSE;
}
@@ -2063,10 +2061,10 @@ hit_test_pixbuf (GdkPixbuf *pixbuf, ArtIRect pixbuf_location, ArtIRect probe_rec
}
static gboolean
-hit_test (NautilusIconCanvasItem *icon_item, ArtIRect canvas_rect)
+hit_test (NautilusIconCanvasItem *icon_item, EelIRect canvas_rect)
{
NautilusIconCanvasItemDetails *details;
- ArtIRect emblem_rect;
+ EelIRect emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
gboolean is_rtl;
@@ -2074,9 +2072,9 @@ hit_test (NautilusIconCanvasItem *icon_item, ArtIRect canvas_rect)
details = icon_item->details;
/* Quick check to see if the rect hits the icon, text or emblems at all. */
- if (!eel_art_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect)
- && (!eel_art_irect_hits_irect (details->text_rect, canvas_rect))
- && (!eel_art_irect_hits_irect (details->emblem_rect, canvas_rect))) {
+ if (!eel_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect)
+ && (!eel_irect_hits_irect (details->text_rect, canvas_rect))
+ && (!eel_irect_hits_irect (details->emblem_rect, canvas_rect))) {
return FALSE;
}
@@ -2086,12 +2084,12 @@ hit_test (NautilusIconCanvasItem *icon_item, ArtIRect canvas_rect)
}
/* Check for hit in the icon. */
- if (eel_art_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect)) {
+ if (eel_irect_hits_irect (icon_item->details->canvas_rect, canvas_rect)) {
return TRUE;
}
/* Check for hit in the text. */
- if (eel_art_irect_hits_irect (details->text_rect, canvas_rect)
+ if (eel_irect_hits_irect (details->text_rect, canvas_rect)
&& !icon_item->details->is_renaming) {
return TRUE;
}
@@ -2114,7 +2112,7 @@ static double
nautilus_icon_canvas_item_point (EelCanvasItem *item, double x, double y, int cx, int cy,
EelCanvasItem **actual_item)
{
- ArtIRect canvas_rect;
+ EelIRect canvas_rect;
*actual_item = item;
canvas_rect.x0 = cx;
@@ -2151,7 +2149,7 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item,
{
NautilusIconCanvasItem *icon_item;
NautilusIconCanvasItemDetails *details;
- ArtIRect icon_rect, text_rect, total_rect, emblem_rect;
+ EelIRect icon_rect, text_rect, total_rect, emblem_rect;
double pixels_per_unit;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf;
@@ -2189,7 +2187,7 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item,
is_rtl = nautilus_icon_container_is_layout_rtl (NAUTILUS_ICON_CONTAINER (item->canvas));
/* Compute total rectangle, adding in emblem rectangles. */
- art_irect_union (&total_rect, &icon_rect, &text_rect);
+ eel_irect_union (&total_rect, &icon_rect, &text_rect);
emblem_layout_reset (&emblem_layout, icon_item, icon_rect, is_rtl);
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) {
emblem_rect.x0 = floor (emblem_rect.x0 / pixels_per_unit);
@@ -2197,7 +2195,7 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item,
emblem_rect.x1 = ceil (emblem_rect.x1 / pixels_per_unit);
emblem_rect.y1 = ceil (emblem_rect.y1 / pixels_per_unit);
- art_irect_union (&total_rect, &total_rect, &emblem_rect);
+ eel_irect_union (&total_rect, &total_rect, &emblem_rect);
}
details->bounds_cache = total_rect;
@@ -2212,14 +2210,14 @@ nautilus_icon_canvas_item_bounds (EelCanvasItem *item,
}
/* Get the rectangle of the icon only, in world coordinates. */
-ArtDRect
+EelDRect
nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item)
{
- ArtDRect rectangle;
+ EelDRect rectangle;
double pixels_per_unit;
GdkPixbuf *pixbuf;
- g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_art_drect_empty);
+ g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_drect_empty);
rectangle.x0 = item->details->x;
rectangle.y0 = item->details->y;
@@ -2240,17 +2238,17 @@ nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item
return rectangle;
}
-ArtDRect
+EelDRect
nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item)
{
/* FIXME */
- ArtIRect icon_rectangle;
- ArtIRect text_rectangle;
- ArtDRect ret;
+ EelIRect icon_rectangle;
+ EelIRect text_rectangle;
+ EelDRect ret;
double pixels_per_unit;
GdkPixbuf *pixbuf;
- g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_art_drect_empty);
+ g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), eel_drect_empty);
icon_rectangle.x0 = item->details->x;
icon_rectangle.y0 = item->details->y;
@@ -2283,7 +2281,7 @@ nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item)
/* Get the rectangle of the icon only, in canvas coordinates. */
static void
get_icon_canvas_rectangle (NautilusIconCanvasItem *item,
- ArtIRect *rect)
+ EelIRect *rect)
{
GdkPixbuf *pixbuf;
@@ -2320,10 +2318,10 @@ nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item
/* Check if one of the stretch handles was hit. */
static gboolean
hit_test_stretch_handle (NautilusIconCanvasItem *item,
- ArtIRect probe_canvas_rect,
+ EelIRect probe_canvas_rect,
GtkCornerType *corner)
{
- ArtIRect icon_rect;
+ EelIRect icon_rect;
GdkPixbuf *knob_pixbuf;
int knob_width, knob_height;
int hit_corner;
@@ -2337,7 +2335,7 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item,
/* Quick check to see if the rect hits the icon at all. */
icon_rect = item->details->canvas_rect;
- if (!eel_art_irect_hits_irect (probe_canvas_rect, icon_rect)) {
+ if (!eel_irect_hits_irect (probe_canvas_rect, icon_rect)) {
return FALSE;
}
@@ -2368,10 +2366,10 @@ hit_test_stretch_handle (NautilusIconCanvasItem *item,
gboolean
nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
- ArtPoint world_point,
+ EelDPoint world_point,
GtkCornerType *corner)
{
- ArtIRect canvas_rect;
+ EelIRect canvas_rect;
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
@@ -2391,7 +2389,7 @@ nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item
* canvas rect.
*/
gboolean
-nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, ArtIRect canvas_rect)
+nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item, EelIRect canvas_rect)
{
g_return_val_if_fail (NAUTILUS_IS_ICON_CANVAS_ITEM (item), FALSE);
diff --git a/libnautilus-private/nautilus-icon-canvas-item.h b/libnautilus-private/nautilus-icon-canvas-item.h
index d55c4f706..db0544763 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.h
+++ b/libnautilus-private/nautilus-icon-canvas-item.h
@@ -25,10 +25,8 @@
#ifndef NAUTILUS_ICON_CANVAS_ITEM_H
#define NAUTILUS_ICON_CANVAS_ITEM_H
-#include <libart_lgpl/art_rect.h>
-#include <libart_lgpl/art_point.h>
#include <eel/eel-canvas.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <eel/eel-art-extensions.h>
G_BEGIN_DECLS
@@ -70,7 +68,8 @@ void nautilus_icon_canvas_item_set_emblems (NautilusIconCanv
void nautilus_icon_canvas_item_set_show_stretch_handles (NautilusIconCanvasItem *item,
gboolean show_stretch_handles);
void nautilus_icon_canvas_item_set_attach_points (NautilusIconCanvasItem *item,
- NautilusEmblemAttachPoints *attach_points);
+ GdkPoint *attach_points,
+ int n_attach_points);
void nautilus_icon_canvas_item_set_embedded_text_rect (NautilusIconCanvasItem *item,
const GdkRectangle *text_rect);
void nautilus_icon_canvas_item_set_embedded_text (NautilusIconCanvasItem *item,
@@ -82,13 +81,13 @@ void nautilus_icon_canvas_item_set_renaming (NautilusIconCanv
/* geometry and hit testing */
gboolean nautilus_icon_canvas_item_hit_test_rectangle (NautilusIconCanvasItem *item,
- ArtIRect canvas_rect);
+ EelIRect canvas_rect);
gboolean nautilus_icon_canvas_item_hit_test_stretch_handles (NautilusIconCanvasItem *item,
- ArtPoint world_point,
- GtkCornerType *corner);
+ EelDPoint world_point,
+ GtkCornerType *corner);
void nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item);
-ArtDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item);
-ArtDRect nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item);
+EelDRect nautilus_icon_canvas_item_get_icon_rectangle (const NautilusIconCanvasItem *item);
+EelDRect nautilus_icon_canvas_item_get_text_rectangle (NautilusIconCanvasItem *item);
void nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item,
double i2w_dx, double i2w_dy);
void nautilus_icon_canvas_item_set_is_visible (NautilusIconCanvasItem *item,
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 2e3947250..cb8a87e82 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -41,6 +41,7 @@
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-gtk-extensions.h>
+#include <eel/eel-art-extensions.h>
#include <eel/eel-editable-label.h>
#include <eel/eel-marshal.h>
#include <eel/eel-string.h>
@@ -299,7 +300,7 @@ icon_set_position (NautilusIcon *icon,
int left, top, right, bottom;
int width;
int container_x, container_y, container_width, container_height;
- ArtDRect icon_bounds;
+ EelDRect icon_bounds;
if (icon->x == x && icon->y == y) {
return;
@@ -585,9 +586,9 @@ set_pending_icon_to_reveal (NautilusIconContainer *container, NautilusIcon *icon
}
static void
-item_get_canvas_bounds (EelCanvasItem *item, ArtIRect *bounds)
+item_get_canvas_bounds (EelCanvasItem *item, EelIRect *bounds)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
eel_canvas_item_get_bounds (item,
&world_rect.x0,
@@ -619,7 +620,7 @@ reveal_icon (NautilusIconContainer *container,
NautilusIconContainerDetails *details;
GtkAllocation *allocation;
GtkAdjustment *hadj, *vadj;
- ArtIRect bounds;
+ EelIRect bounds;
if (!icon_is_positioned (icon)) {
set_pending_icon_to_reveal (container, icon);
@@ -1008,9 +1009,9 @@ lay_down_icons_horizontal (NautilusIconContainer *container,
double canvas_width, y, canvas_height;
GArray *positions;
IconPositions *position;
- ArtDRect bounds;
- ArtDRect icon_bounds;
- ArtDRect text_bounds;
+ EelDRect bounds;
+ EelDRect icon_bounds;
+ EelDRect text_bounds;
EelCanvasItem *item;
double max_height_above, max_height_below;
double height_above, height_below;
@@ -1168,7 +1169,7 @@ snap_position (NautilusIconContainer *container,
int baseline_y;
int icon_width;
int icon_height;
- ArtDRect icon_position;
+ EelDRect icon_position;
icon_position = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
icon_width = icon_position.x1 - icon_position.x0;
@@ -1263,7 +1264,7 @@ placement_grid_free (PlacementGrid *grid)
}
static gboolean
-placement_grid_position_is_free (PlacementGrid *grid, ArtIRect pos)
+placement_grid_position_is_free (PlacementGrid *grid, EelIRect pos)
{
int x, y;
@@ -1284,7 +1285,7 @@ placement_grid_position_is_free (PlacementGrid *grid, ArtIRect pos)
}
static void
-placement_grid_mark (PlacementGrid *grid, ArtIRect pos)
+placement_grid_mark (PlacementGrid *grid, EelIRect pos)
{
int x, y;
@@ -1302,8 +1303,8 @@ placement_grid_mark (PlacementGrid *grid, ArtIRect pos)
static void
canvas_position_to_grid_position (PlacementGrid *grid,
- ArtIRect canvas_position,
- ArtIRect *grid_position)
+ EelIRect canvas_position,
+ EelIRect *grid_position)
{
/* The first causes minimal moving around during a snap, but
* can end up with partially overlapping icons. The second one won't
@@ -1330,8 +1331,8 @@ canvas_position_to_grid_position (PlacementGrid *grid,
static void
placement_grid_mark_icon (PlacementGrid *grid, NautilusIcon *icon)
{
- ArtIRect icon_pos;
- ArtIRect grid_pos;
+ EelIRect icon_pos;
+ EelIRect grid_pos;
icon_get_bounding_box (icon,
&icon_pos.x0, &icon_pos.y0,
@@ -1354,8 +1355,8 @@ find_empty_location (NautilusIconContainer *container,
double icon_width, icon_height;
int canvas_width;
int canvas_height;
- ArtIRect icon_position;
- ArtDRect pixbuf_rect;
+ EelIRect icon_position;
+ EelDRect pixbuf_rect;
gboolean collision;
/* Get container dimensions */
@@ -1379,7 +1380,7 @@ find_empty_location (NautilusIconContainer *container,
icon_position.y1 = icon_position.y0 + icon_height;
do {
- ArtIRect grid_position;
+ EelIRect grid_position;
collision = FALSE;
@@ -1458,9 +1459,10 @@ align_icons (NautilusIconContainer *container)
}
static double
-get_mirror_x_position (NautilusIconContainer *container, NautilusIcon *icon, double x) {
- ArtDRect icon_bounds;
-
+get_mirror_x_position (NautilusIconContainer *container, NautilusIcon *icon, double x)
+{
+ EelDRect icon_bounds;
+
icon_bounds = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
return CANVAS_WIDTH(container) - x - (icon_bounds.x1 - icon_bounds.x0);
@@ -1492,7 +1494,7 @@ lay_down_icons_vertical (NautilusIconContainer *container, GList *icons)
NautilusIcon *icon;
int width, height, max_width, column_width, icon_width, icon_height;
int x, y, x1, x2, y1, y2;
- ArtDRect icon_rect;
+ EelDRect icon_rect;
/* Get container dimensions */
width = CANVAS_WIDTH(container);
@@ -1746,7 +1748,7 @@ reload_icon_positions (NautilusIconContainer *container)
NautilusIcon *icon;
gboolean have_stored_position;
NautilusIconPosition position;
- ArtDRect bounds;
+ EelDRect bounds;
double bottom;
EelCanvasItem *item;
@@ -1961,13 +1963,13 @@ nautilus_icon_container_move_icon (NautilusIconContainer *container,
/* Implementation of rubberband selection. */
static void
rubberband_select (NautilusIconContainer *container,
- const ArtDRect *previous_rect,
- const ArtDRect *current_rect)
+ const EelDRect *previous_rect,
+ const EelDRect *current_rect)
{
GList *p;
gboolean selection_changed, is_in, canvas_rect_calculated;
NautilusIcon *icon;
- ArtIRect canvas_rect;
+ EelIRect canvas_rect;
EelCanvas *canvas;
selection_changed = FALSE;
@@ -2022,7 +2024,7 @@ rubberband_timeout_callback (gpointer data)
int adj_y;
gboolean adj_changed;
- ArtDRect selection_rect;
+ EelDRect selection_rect;
widget = GTK_WIDGET (data);
container = NAUTILUS_ICON_CONTAINER (data);
@@ -2301,7 +2303,7 @@ compare_icons_by_uri (NautilusIconContainer *container,
static int
get_cmp_point_x (NautilusIconContainer *container,
- ArtDRect icon_rect)
+ EelDRect icon_rect)
{
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
if (gtk_widget_get_direction (GTK_WIDGET (container)) == GTK_TEXT_DIR_RTL) {
@@ -2316,7 +2318,7 @@ get_cmp_point_x (NautilusIconContainer *container,
static int
get_cmp_point_y (NautilusIconContainer *container,
- ArtDRect icon_rect)
+ EelDRect icon_rect)
{
if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
return (icon_rect.y0 + icon_rect.y1)/2;
@@ -2330,7 +2332,7 @@ compare_icons_horizontal_first (NautilusIconContainer *container,
NautilusIcon *icon_a,
NautilusIcon *icon_b)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
int ax, ay, bx, by;
world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item);
@@ -2368,7 +2370,7 @@ compare_icons_vertical_first_reverse_horizontal (NautilusIconContainer *containe
NautilusIcon *icon_a,
NautilusIcon *icon_b)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
int ax, ay, bx, by;
world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item);
@@ -2407,7 +2409,7 @@ compare_icons_vertical_first (NautilusIconContainer *container,
NautilusIcon *icon_a,
NautilusIcon *icon_b)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
int ax, ay, bx, by;
world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon_a->item);
@@ -2631,7 +2633,7 @@ closest_in_90_degrees (NautilusIconContainer *container,
NautilusIcon *candidate,
void *data)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
int x, y;
int dx, dy;
int dist;
@@ -2694,13 +2696,13 @@ closest_in_90_degrees (NautilusIconContainer *container,
return FALSE;
}
-static ArtDRect
+static EelDRect
get_rubberband (NautilusIcon *icon1,
NautilusIcon *icon2)
{
- ArtDRect rect1;
- ArtDRect rect2;
- ArtDRect ret;
+ EelDRect rect1;
+ EelDRect rect2;
+ EelDRect ret;
eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (icon1->item),
&rect1.x0, &rect1.y0,
@@ -2709,7 +2711,7 @@ get_rubberband (NautilusIcon *icon1,
&rect2.x0, &rect2.y0,
&rect2.x1, &rect2.y1);
- art_drect_union (&ret, &rect1, &rect2);
+ eel_drect_union (&ret, &rect1, &rect2);
return ret;
}
@@ -2732,7 +2734,7 @@ keyboard_move_to (NautilusIconContainer *container,
container->details->keyboard_rubberband_start = NULL;
} else if ((event->state & GDK_SHIFT_MASK) != 0) {
/* Do rubberband selection */
- ArtDRect rect;
+ EelDRect rect;
if (from && !container->details->keyboard_rubberband_start) {
set_keyboard_rubberband_start (container, from);
@@ -2804,7 +2806,7 @@ record_arrow_key_start (NautilusIconContainer *container,
NautilusIcon *icon,
GtkDirectionType direction)
{
- ArtDRect world_rect;
+ EelDRect world_rect;
world_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
eel_canvas_w2c
@@ -3420,7 +3422,7 @@ start_stretching (NautilusIconContainer *container)
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
- ArtPoint world_point;
+ EelDPoint world_point;
GtkWidget *toplevel;
GtkCornerType corner;
GdkCursor *cursor;
@@ -5095,13 +5097,6 @@ nautilus_icon_container_instance_init (NautilusIconContainer *container)
container->details = details;
- /* Make sure that we find out if the icons change. */
- g_signal_connect_object
- (nautilus_icon_factory_get (),
- "icons_changed",
- G_CALLBACK (nautilus_icon_container_request_update_all),
- container, G_CONNECT_SWAPPED);
-
/* when the background changes, we must set up the label text color */
background = eel_get_widget_background (GTK_WIDGET (container));
@@ -5582,11 +5577,13 @@ get_icon_being_renamed (NautilusIconContainer *container)
return rename_icon;
}
-static char *
+static NautilusIconInfo *
nautilus_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusIconData *data,
- GList **emblem_icons,
+ int size,
+ GList **emblem_pixbufs,
char **embedded_text,
+ gboolean for_drag_accept,
gboolean need_large_embeddded_text,
gboolean *embedded_text_needs_loading,
gboolean *has_open_window)
@@ -5596,7 +5593,7 @@ nautilus_icon_container_get_icon_images (NautilusIconContainer *container,
klass = NAUTILUS_ICON_CONTAINER_GET_CLASS (container);
g_return_val_if_fail (klass->get_icon_images != NULL, NULL);
- return klass->get_icon_images (container, data, emblem_icons, embedded_text, need_large_embeddded_text, embedded_text_needs_loading, has_open_window);
+ return klass->get_icon_images (container, data, size, emblem_pixbufs, embedded_text, for_drag_accept, need_large_embeddded_text, embedded_text_needs_loading, has_open_window);
}
@@ -5732,90 +5729,6 @@ handle_vadjustment_changed (GtkAdjustment *adjustment,
nautilus_icon_container_update_visible_icons (container);
}
-/*
- * used to resize ICON_NAME_THUMBNAIL_LOADING to the expected thumbnail size.
- */
-static void
-sanitize_loading_thumbnail_image_size (NautilusIconContainer *container,
- const char *mime_type,
- GdkPixbuf **image,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect)
-{
- NautilusIconContainerDetails *details;
- double pixels_per_unit;
-
- details = container->details;
- pixels_per_unit = (double) nautilus_get_icon_size_for_zoom_level (container->details->zoom_level)
- / NAUTILUS_ICON_SIZE_STANDARD;
-
- if (gdk_pixbuf_get_width (*image) < NAUTILUS_ICON_SIZE_THUMBNAIL * pixels_per_unit &&
- gdk_pixbuf_get_height (*image) < NAUTILUS_ICON_SIZE_THUMBNAIL * pixels_per_unit) {
- /* TODO? this only handles icons smaller than the expected thumbnail size ATM.
- * Should not be a common problem, though */
- GdkPixbuf *new_image;
- double x_size;
- double y_size;
- double x_offset;
- double y_offset;
- int i;
-
- if (g_str_has_prefix (mime_type, "video/")) {
- /* assume 4:3 aspect ratio for videos i.e. we'll always occupy the full width. */
- x_size = NAUTILUS_ICON_SIZE_THUMBNAIL * pixels_per_unit;
- y_size = 3./4 * x_size;
- } else {
- /* scale up to the max. thumbnail size.
- * This is correct at least in one dimension, and prevents the icons from jumping
- * around as the thumbnail is created, if it is tall for text below icon, and if it
- * is wide for text beside icon.
- */
- x_size = NAUTILUS_ICON_SIZE_THUMBNAIL * pixels_per_unit;
- y_size = NAUTILUS_ICON_SIZE_THUMBNAIL * pixels_per_unit;
- }
-
- /* maybe the estimated size was smaller than the input pixbuf, so size the surrounding
- * image up. This only seems to be relevant in the 4:3 case, for y_size.
- */
- x_size = MAX (x_size, gdk_pixbuf_get_width (*image));
- y_size = MAX (y_size, gdk_pixbuf_get_height (*image));
-
- x_offset = x_size - gdk_pixbuf_get_width (*image);
- y_offset = y_size - gdk_pixbuf_get_height (*image);
-
- /* center wrt "minor" dimension, i.e. horizontally for text below
- * and vertically for text besides icon */
- if (details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE)
- y_offset /= 2;
- else
- x_offset /= 2;
-
- new_image = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE,
- gdk_pixbuf_get_bits_per_sample (*image),
- x_size, y_size);
-
- gdk_pixbuf_fill (new_image, 0x00000000);
- gdk_pixbuf_copy_area (*image,
- 0, 0,
- gdk_pixbuf_get_width (*image),
- gdk_pixbuf_get_height (*image),
- new_image,
- x_offset, y_offset);
-
- g_object_unref (*image);
- *image = new_image;
-
- for (i = 0; i < attach_points->num_points; i++) {
- attach_points->points[i].x += x_offset;
- attach_points->points[i].y += y_offset;
- }
-
- embedded_text_rect->x += x_offset;
- embedded_text_rect->y += y_offset;
- }
-}
-
-
void
nautilus_icon_container_update_icon (NautilusIconContainer *container,
NautilusIcon *icon)
@@ -5823,18 +5736,18 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
NautilusIconContainerDetails *details;
guint icon_size;
guint min_image_size, max_image_size;
- char *icon_name;
- NautilusEmblemAttachPoints attach_points;
- GdkPixbuf *pixbuf, *emblem_pixbuf;
- GList *emblem_icon_names, *emblem_pixbufs, *p;
+ NautilusIconInfo *icon_info;
+ GdkPoint *attach_points;
+ int n_attach_points;
+ gboolean has_embedded_text_rect;
+ GdkPixbuf *pixbuf;
+ GList *emblem_pixbufs;
char *editable_text, *additional_text;
char *embedded_text;
- guint emblem_size;
GdkRectangle embedded_text_rect;
gboolean large_embedded_text;
gboolean embedded_text_needs_loading;
gboolean has_open_window;
- char *modifier;
if (icon == NULL) {
return;
@@ -5853,62 +5766,29 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
icon_size = MIN (icon_size, max_image_size);
/* Get the icons. */
- emblem_icon_names = NULL;
+ emblem_pixbufs = NULL;
embedded_text = NULL;
large_embedded_text = icon_size > ICON_SIZE_FOR_LARGE_EMBEDDED_TEXT;
- icon_name = nautilus_icon_container_get_icon_images (
- container, icon->data,
- &emblem_icon_names,
- &embedded_text, large_embedded_text, &embedded_text_needs_loading,
- &has_open_window);
-
- modifier = NULL;
- if (has_open_window) {
- modifier = "visiting";
- }
- if (icon == details->drop_target) {
- modifier = "accept";
- }
-
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file_with_icon
- ((NautilusFile *) icon->data,
- icon_name,
- modifier,
- icon_size,
- &attach_points,
- &embedded_text_rect,
- FALSE, TRUE, NULL);
-
- if (embedded_text_rect.width > MINIMUM_EMBEDDED_TEXT_RECT_WIDTH &&
- embedded_text_rect.height > MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT &&
- embedded_text_needs_loading) {
+ icon_info = nautilus_icon_container_get_icon_images (container, icon->data, icon_size,
+ &emblem_pixbufs,
+ &embedded_text,
+ icon == details->drop_target,
+ large_embedded_text, &embedded_text_needs_loading,
+ &has_open_window);
+
+
+ pixbuf = nautilus_icon_info_get_pixbuf (icon_info);
+ nautilus_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points);
+ has_embedded_text_rect = nautilus_icon_info_get_embedded_rect (icon_info,
+ &embedded_text_rect);
+
+ if (has_embedded_text_rect && embedded_text_needs_loading) {
icon->is_monitored = TRUE;
nautilus_icon_container_start_monitor_top_left (container, icon->data, icon, large_embedded_text);
}
- emblem_pixbufs = NULL;
-
icon_size = MAX (nautilus_get_icon_size_for_zoom_level (container->details->zoom_level)
- * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST);
- emblem_size = nautilus_icon_factory_get_emblem_size_for_icon_size (icon_size);
- if (emblem_size != 0) {
- for (p = emblem_icon_names; p != NULL; p = p->next) {
- emblem_pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
- (p->data,
- NULL,
- emblem_size,
- NULL,
- NULL,
- FALSE, FALSE, NULL);
- if (emblem_pixbuf != NULL) {
- emblem_pixbufs = g_list_prepend
- (emblem_pixbufs, emblem_pixbuf);
- }
- }
- }
- emblem_pixbufs = g_list_reverse (emblem_pixbufs);
-
- eel_g_list_free_deep (emblem_icon_names);
+ * icon->scale, NAUTILUS_ICON_SIZE_SMALLEST);
nautilus_icon_container_get_icon_text (container,
icon->data,
@@ -5932,19 +5812,8 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
"highlighted_for_drop", icon == details->drop_target,
NULL);
- if (nautilus_file_is_thumbnailing ((NautilusFile *) icon->data)) {
- char* mime_type;
- mime_type = nautilus_file_get_mime_type ((NautilusFile *)icon->data);
- sanitize_loading_thumbnail_image_size (container,
- mime_type,
- &pixbuf,
- &attach_points,
- &embedded_text_rect);
- g_free (mime_type);
- }
-
nautilus_icon_canvas_item_set_image (icon->item, pixbuf);
- nautilus_icon_canvas_item_set_attach_points (icon->item, &attach_points);
+ nautilus_icon_canvas_item_set_attach_points (icon->item, attach_points, n_attach_points);
nautilus_icon_canvas_item_set_emblems (icon->item, emblem_pixbufs);
nautilus_icon_canvas_item_set_embedded_text_rect (icon->item, &embedded_text_rect);
nautilus_icon_canvas_item_set_embedded_text (icon->item, embedded_text);
@@ -5956,7 +5825,7 @@ nautilus_icon_container_update_icon (NautilusIconContainer *container,
g_free (editable_text);
g_free (additional_text);
- g_free (icon_name);
+ g_object_unref (icon_info);
}
static gboolean
@@ -7060,8 +6929,8 @@ nautilus_icon_container_start_renaming_selected_item (NautilusIconContainer *con
{
NautilusIconContainerDetails *details;
NautilusIcon *icon;
- ArtDRect icon_rect;
- ArtDRect text_rect;
+ EelDRect icon_rect;
+ EelDRect text_rect;
PangoContext *context;
PangoFontDescription *desc;
const char *editable_text;
diff --git a/libnautilus-private/nautilus-icon-container.h b/libnautilus-private/nautilus-icon-container.h
index 36e0ddb25..7f0bbc303 100644
--- a/libnautilus-private/nautilus-icon-container.h
+++ b/libnautilus-private/nautilus-icon-container.h
@@ -27,7 +27,7 @@
#define NAUTILUS_ICON_CONTAINER_H
#include <eel/eel-canvas.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <libnautilus-private/nautilus-icon-info.h>
#define NAUTILUS_ICON_CONTAINER(obj) \
GTK_CHECK_CAST (obj, nautilus_icon_container_get_type (), NautilusIconContainer)
@@ -128,10 +128,12 @@ typedef struct {
* These must be implemented. The default "do nothing" is not
* good enough, these are _not_ signals.
*/
- char * (* get_icon_images) (NautilusIconContainer *container,
+ NautilusIconInfo *(* get_icon_images) (NautilusIconContainer *container,
NautilusIconData *data,
- GList **emblem_icons,
+ int icon_size,
+ GList **emblem_pixbufs,
char **embedded_text,
+ gboolean for_drag_accept,
gboolean need_large_embeddded_text,
gboolean *embedded_text_needs_loading,
gboolean *has_window_open);
diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c
index 07bbadafe..111130e08 100644
--- a/libnautilus-private/nautilus-icon-dnd.c
+++ b/libnautilus-private/nautilus-icon-dnd.c
@@ -59,9 +59,6 @@
#include <eel/eel-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file-changes-queue.h>
#include <stdio.h>
@@ -193,10 +190,10 @@ typedef struct {
static void
canvas_rect_world_to_widget (EelCanvas *canvas,
- ArtDRect *world_rect,
- ArtIRect *widget_rect)
+ EelDRect *world_rect,
+ EelIRect *widget_rect)
{
- ArtDRect window_rect;
+ EelDRect window_rect;
eel_canvas_world_to_window (canvas,
world_rect->x0, world_rect->y0,
@@ -225,8 +222,8 @@ static gboolean
icon_get_data_binder (NautilusIcon *icon, gpointer data)
{
IconGetDataBinderContext *context;
- ArtDRect world_rect;
- ArtIRect widget_rect;
+ EelDRect world_rect;
+ EelIRect widget_rect;
char *uri;
NautilusIconContainer *container;
@@ -246,11 +243,11 @@ icon_get_data_binder (NautilusIcon *icon, gpointer data)
return TRUE;
}
- widget_rect = eel_art_irect_offset_by (widget_rect,
+ widget_rect = eel_irect_offset_by (widget_rect,
- container->details->dnd_info->drag_info.start_x,
- container->details->dnd_info->drag_info.start_y);
- widget_rect = eel_art_irect_scale_by (widget_rect,
+ widget_rect = eel_irect_scale_by (widget_rect,
1 / EEL_CANVAS (container)->pixels_per_unit);
/* pass the uri, mouse-relative x/y and icon width/height */
@@ -409,7 +406,7 @@ get_direct_save_filename (GdkDragContext *context)
static void
set_direct_save_uri (GtkWidget *widget, GdkDragContext *context, NautilusDragInfo *drag_info, int x, int y)
{
- GnomeVFSURI *base, *file_uri;
+ GFile *base, *child;
char *filename, *drop_target;
gchar *uri;
@@ -433,11 +430,11 @@ set_direct_save_uri (GtkWidget *widget, GdkDragContext *context, NautilusDragInf
if (filename != NULL && drop_target != NULL) {
/* Resolve relative path */
- base = gnome_vfs_uri_new (drop_target);
- file_uri = gnome_vfs_uri_append_file_name (base, (const gchar *) filename);
- uri = gnome_vfs_uri_to_string (file_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (base);
- gnome_vfs_uri_unref (file_uri);
+ base = g_file_new_for_uri (drop_target);
+ child = g_file_get_child (base, filename);
+ uri = g_file_get_uri (child);
+ g_object_unref (base);
+ g_object_unref (child);
/* Change the uri property */
gdk_property_change (GDK_DRAWABLE (context->source_window),
@@ -541,8 +538,8 @@ nautilus_icon_container_item_at (NautilusIconContainer *container,
{
GList *p;
int size;
- ArtDRect point;
- ArtIRect canvas_point;
+ EelDRect point;
+ EelIRect canvas_point;
/* build the hit-test rectangle. Base the size on the scale factor to ensure that it is
* non-empty even at the smallest scale factor
@@ -602,12 +599,7 @@ nautilus_icon_container_selection_items_local (NautilusIconContainer *container,
/* get the URI associated with the container */
container_uri_string = get_container_uri (container);
- if (eel_uri_is_trash (container_uri_string)) {
- /* Special-case "trash:" because the nautilus_drag_items_local
- * would not work for it.
- */
- result = nautilus_drag_items_in_trash (items);
- } else if (eel_uri_is_desktop (container_uri_string)) {
+ if (eel_uri_is_desktop (container_uri_string)) {
result = nautilus_drag_items_on_desktop (items);
} else {
result = nautilus_drag_items_local (container_uri_string, items);
@@ -716,7 +708,7 @@ receive_dropped_keyword (NautilusIconContainer *container, const char *keyword,
"dropped emblem '%s' on icon container URI: %s",
keyword, uri);
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
g_free (uri);
nautilus_drag_file_receive_dropped_keyword (file, keyword);
@@ -960,7 +952,7 @@ handle_local_move (NautilusIconContainer *container,
* this screen
*/
- file = nautilus_file_get (item->uri);
+ file = nautilus_file_get_by_uri (item->uri);
screen = gtk_widget_get_screen (GTK_WIDGET (container));
screen_string = g_strdup_printf ("%d",
@@ -1097,7 +1089,7 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
if (drop_target_icon != NULL) {
icon_uri = nautilus_icon_container_get_icon_uri (container, drop_target_icon);
if (icon_uri != NULL) {
- file = nautilus_file_get (icon_uri);
+ file = nautilus_file_get_by_uri (icon_uri);
if (!nautilus_drag_can_accept_info (file,
container->details->dnd_info->drag_info.data_type,
@@ -1130,9 +1122,11 @@ nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
static gboolean
selection_is_image_file (GList *selection_list)
{
- char *mime_type;
+ const char *mime_type;
NautilusDragSelectionItem *selected_item;
gboolean result;
+ GFile *location;
+ GFileInfo *info;
/* Make sure only one item is selected */
if (selection_list == NULL ||
@@ -1142,11 +1136,22 @@ selection_is_image_file (GList *selection_list)
selected_item = selection_list->data;
- mime_type = gnome_vfs_get_mime_type (selected_item->uri);
+ mime_type = NULL;
+
+ location = g_file_new_for_uri (selected_item->uri);
+ info = g_file_query_info (location,
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE,
+ 0, NULL, NULL);
+ if (info) {
+ mime_type = g_file_info_get_content_type (info);
+ }
result = eel_istr_has_prefix (mime_type, "image/");
-
- g_free (mime_type);
+
+ if (info) {
+ g_object_unref (info);
+ }
+ g_object_unref (location);
return result;
}
@@ -1339,7 +1344,7 @@ nautilus_icon_dnd_update_drop_target (NautilusIconContainer *container,
/* Find if target icon accepts our drop. */
if (icon != NULL && (container->details->dnd_info->drag_info.data_type != NAUTILUS_ICON_DND_KEYWORD)) {
uri = nautilus_icon_container_get_icon_uri (container, icon);
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
g_free (uri);
if (!nautilus_drag_can_accept_info (file,
@@ -1633,74 +1638,6 @@ nautilus_icon_dnd_end_drag (NautilusIconContainer *container)
*/
}
-/**
- * implements the gnome 1.x gnome_vfs_uri_list_extract_uris(), which
- * returns a GList of char *uris.
- **/
-GList *
-nautilus_icon_dnd_uri_list_extract_uris (const char *uri_list)
-{
- /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */
-
- const gchar *p, *q;
- gchar *retval;
- GList *result = NULL;
-
- g_return_val_if_fail (uri_list != NULL, NULL);
-
- p = uri_list;
-
- /* We don't actually try to validate the URI according to RFC
- * 2396, or even check for allowed characters - we just ignore
- * comments and trim whitespace off the ends. We also
- * allow LF delimination as well as the specified CRLF.
- */
- while (p != NULL) {
- if (*p != '#') {
- while (g_ascii_isspace (*p))
- p++;
-
- q = p;
- while ((*q != '\0')
- && (*q != '\n')
- && (*q != '\r'))
- q++;
-
- if (q > p) {
- q--;
- while (q > p
- && g_ascii_isspace (*q))
- q--;
-
- retval = g_malloc (q - p + 2);
- strncpy (retval, p, q - p + 1);
- retval[q - p + 1] = '\0';
-
- result = g_list_prepend (result, retval);
- }
- }
- p = strchr (p, '\n');
- if (p != NULL)
- p++;
- }
-
- return g_list_reverse (result);
-}
-
-/**
- * nautilus_icon_dnd_uri_list_free_strings:
- * @list: A GList returned by nautilus_icon_dnd_uri_list_extract_uris()
- *
- * Releases all of the resources allocated by @list.
- *
- * stolen from gnome-mime.c
- */
-void
-nautilus_icon_dnd_uri_list_free_strings (GList *list)
-{
- eel_g_list_free_deep (list);
-}
-
/** this callback is called in 2 cases.
It is called upon drag_motion events to get the actual data
In that case, it just makes sure it gets the data.
@@ -1833,12 +1770,16 @@ drag_data_received_callback (GtkWidget *widget,
drag_info->selection_data->data[0] == 'S' &&
drag_info->direct_save_uri != NULL) {
GdkPoint p;
+ GFile *location;
+
+ location = g_file_new_for_uri (drag_info->direct_save_uri);
- nautilus_file_changes_queue_file_added (drag_info->direct_save_uri);
+ nautilus_file_changes_queue_file_added (location);
p.x = x; p.y = y;
- nautilus_file_changes_queue_schedule_position_set (drag_info->direct_save_uri,
+ nautilus_file_changes_queue_schedule_position_set (location,
p,
gdk_screen_get_number (gtk_widget_get_screen (widget)));
+ g_object_unref (location);
nautilus_file_changes_consume_changes (TRUE);
}
success = TRUE;
diff --git a/libnautilus-private/nautilus-icon-dnd.h b/libnautilus-private/nautilus-icon-dnd.h
index 15af849c0..72c8616cf 100644
--- a/libnautilus-private/nautilus-icon-dnd.h
+++ b/libnautilus-private/nautilus-icon-dnd.h
@@ -59,7 +59,4 @@ void nautilus_icon_dnd_begin_drag (NautilusIconContainer *container
int start_y);
void nautilus_icon_dnd_end_drag (NautilusIconContainer *container);
-GList *nautilus_icon_dnd_uri_list_extract_uris (const char *uri_list);
-void nautilus_icon_dnd_uri_list_free_strings (GList *list);
-
#endif /* NAUTILUS_ICON_DND_H */
diff --git a/libnautilus-private/nautilus-icon-factory-private.h b/libnautilus-private/nautilus-icon-factory-private.h
deleted file mode 100644
index f47a3757f..000000000
--- a/libnautilus-private/nautilus-icon-factory-private.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-icon-factory-private.h: Private interface for use within
- the icon factory code.
-
- Copyright (C) 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Darin Adler <darin@bentspoon.com>
-*/
-
-#ifndef NAUTILUS_ICON_FACTORY_PRIVATE_H
-#define NAUTILUS_ICON_FACTORY_PRIVATE_H
-
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-/* Convenience routine to return the appropriate thumbnail frame. */
-GdkPixbuf *nautilus_icon_factory_get_thumbnail_frame (void);
-
-#endif /* NAUTILUS_ICON_FACTORY_PRIVATE_H */
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
deleted file mode 100644
index c0bdef82a..000000000
--- a/libnautilus-private/nautilus-icon-factory.c
+++ /dev/null
@@ -1,1886 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-icon-factory.c: Class for obtaining icons for files and other objects.
-
- Copyright (C) 1999, 2000 Red Hat Inc.
- Copyright (C) 1999, 2000, 2001 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: John Sullivan <sullivan@eazel.com>,
- Darin Adler <darin@bentspoon.com>,
- Andy Hertzfeld <andy@eazel.com>
-*/
-
-#include <config.h>
-#include "nautilus-icon-factory.h"
-
-#include "nautilus-default-file-icon.h"
-#include "nautilus-directory-notify.h"
-#include "nautilus-file-attributes.h"
-#include "nautilus-file-private.h"
-#include "nautilus-file-utilities.h"
-#include "nautilus-global-preferences.h"
-#include "nautilus-icon-factory-private.h"
-#include "nautilus-lib-self-check-functions.h"
-#include "nautilus-link.h"
-#include "nautilus-thumbnails.h"
-#include "nautilus-trash-monitor.h"
-#include <eel/eel-debug.h>
-#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-pango-extensions.h>
-#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
-#include <gtk/gtksettings.h>
-#include <gtk/gtksignal.h>
-#include <gtk/gtkiconfactory.h>
-#include <gtk/gtkicontheme.h>
-#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnomeui/gnome-icon-lookup.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-mime-monitor.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <librsvg/rsvg.h>
-#include <math.h>
-#include <stdio.h>
-#include <string.h>
-
-#define CACHE_SELF_CHECKS 0
-
-#define ICON_NAME_THUMBNAIL_LOADING "gnome-fs-loading-icon"
-#define ICON_NAME_TRASH_EMPTY "user-trash"
-#define ICON_NAME_TRASH_FULL "user-trash-full"
-#define ICON_NAME_HOME "user-home"
-
-#define NAUTILUS_EMBLEM_NAME_PREFIX "emblem-"
-
-/* This used to be called ICON_CACHE_MAX_ENTRIES, but it's misleading
- * to call it that, since we can have any number of entries in the
- * cache if the caller keeps the pixbuf around (we only get rid of
- * items from the cache after the caller unref's them).
-*/
-#define ICON_CACHE_COUNT 20
-
-/* This is the number of milliseconds we wait before sweeping out
- * items from the cache.
- */
-#define ICON_CACHE_SWEEP_TIMEOUT (10 * 1000)
-
-/* After a pixmap goes out of the recently used queue, and the pixbuf are not
- * referenced outside the cache this is the number of sweeps an object lives.
- */
-#define ICON_MAX_AGE 10
-
-/* This circular doubly-linked list structure is used to keep a list
- * of the most recently used items in the cache.
- */
-typedef struct CircularList CircularList;
-struct CircularList {
- CircularList *next;
- CircularList *prev;
-};
-
-/* The key to a hash table that holds CacheIcons. */
-typedef struct {
- char *name; /* Icon name or absolute filename */
- char *modifier;
- guint nominal_size;
- gboolean force_nominal;
-} CacheKey;
-
-/* The value in the same table. */
-typedef struct {
- guint ref_count;
-
- GdkPixbuf *pixbuf;
- GdkRectangle *embedded_text_rect;
-
- GdkPoint *attach_points;
- int n_attach_points;
-
- char *display_name;
-
- time_t mtime; /* Only used for absolute filenames */
-
- CircularList recently_used_node;
- int age; /* zero:ed on access, incremented each sweep */
-} CacheIcon;
-
-/* The icon factory.
- * These are just globals, but they're in an object so we can
- * connect signals and have multiple icon factories some day
- * if we want to.
- */
-typedef struct {
- GObject object;
-
- /* A hash table that contains the icons. A circular list of
- * the most recently used icons is kept around, and we don't
- * let them go when we sweep the cache.
- */
- GHashTable *icon_cache;
-
- /* frames to use for thumbnail icons */
- GdkPixbuf *thumbnail_frame;
-
- /* Used for icon themes according to the freedesktop icon spec. */
- GtkIconTheme *icon_theme;
- GnomeThumbnailFactory *thumbnail_factory;
-
- CircularList recently_used_dummy_head;
- guint recently_used_count;
- guint sweep_timer;
-
- CacheIcon *fallback_icon;
- GHashTable *image_mime_types;
-
- GList *async_thumbnail_load_handles;
-} NautilusIconFactory;
-
-#define NAUTILUS_ICON_FACTORY(obj) \
- GTK_CHECK_CAST (obj, nautilus_icon_factory_get_type (), NautilusIconFactory)
-
-typedef struct {
- GObjectClass parent_class;
-} NautilusIconFactoryClass;
-
-enum {
- ICONS_CHANGED,
- LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL];
-
-
-static int cached_thumbnail_limit;
-static int cached_thumbnail_size;
-static int show_image_thumbs;
-
-/* forward declarations */
-
-static GType nautilus_icon_factory_get_type (void);
-static void nautilus_icon_factory_class_init (NautilusIconFactoryClass *class);
-static void nautilus_icon_factory_instance_init (NautilusIconFactory *factory);
-static void nautilus_icon_factory_finalize (GObject *object);
-static void thumbnail_limit_changed_callback (gpointer user_data);
-static void thumbnail_size_changed_callback (gpointer user_data);
-static void show_thumbnails_changed_callback (gpointer user_data);
-static void mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor,
- gpointer user_data);
-static guint cache_key_hash (gconstpointer p);
-static gboolean cache_key_equal (gconstpointer a,
- gconstpointer b);
-static void cache_key_destroy (CacheKey *key);
-static void cache_icon_unref (CacheIcon *icon);
-static CacheIcon *cache_icon_new (GdkPixbuf *pixbuf,
- GtkIconInfo *icon_info,
- double scale_x,
- double scale_y);
-static CacheIcon *get_icon_from_cache (const char *icon,
- const char *modifier,
- guint nominal_size,
- gboolean force_nominal);
-static void nautilus_icon_factory_clear (gboolean clear_pathnames);
-
-GNOME_CLASS_BOILERPLATE (NautilusIconFactory,
- nautilus_icon_factory,
- GObject, G_TYPE_OBJECT);
-
-static NautilusIconFactory *global_icon_factory = NULL;
-
-static void
-destroy_icon_factory (void)
-{
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
- thumbnail_limit_changed_callback,
- NULL);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
- thumbnail_size_changed_callback,
- NULL);
- eel_preferences_remove_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
- show_thumbnails_changed_callback,
- NULL);
- g_object_unref (global_icon_factory);
-}
-
-/* Return a pointer to the single global icon factory. */
-static NautilusIconFactory *
-get_icon_factory (void)
-{
- if (global_icon_factory == NULL) {
- nautilus_global_preferences_init ();
-
- global_icon_factory = NAUTILUS_ICON_FACTORY
- (g_object_new (nautilus_icon_factory_get_type (), NULL));
-
- thumbnail_limit_changed_callback (NULL);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT,
- thumbnail_limit_changed_callback,
- NULL);
-
- thumbnail_size_changed_callback (NULL);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE,
- thumbnail_size_changed_callback,
- NULL);
-
- show_thumbnails_changed_callback (NULL);
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS,
- show_thumbnails_changed_callback,
- NULL);
-
- g_signal_connect (gnome_vfs_mime_monitor_get (),
- "data_changed",
- G_CALLBACK (mime_type_data_changed_callback),
- NULL);
-
- eel_debug_call_at_shutdown (destroy_icon_factory);
- }
- return global_icon_factory;
-}
-
-GObject *
-nautilus_icon_factory_get (void)
-{
- return G_OBJECT (get_icon_factory ());
-}
-
-static void
-icon_theme_changed_callback (GnomeIconTheme *icon_theme,
- gpointer user_data)
-{
- NautilusIconFactory *factory;
-
- nautilus_icon_factory_clear (FALSE);
-
- factory = user_data;
-
- g_signal_emit (factory,
- signals[ICONS_CHANGED], 0);
-}
-
-GtkIconTheme *
-nautilus_icon_factory_get_icon_theme (void)
-{
- NautilusIconFactory *factory;
-
- factory = get_icon_factory ();
-
- return g_object_ref (factory->icon_theme);
-}
-
-GnomeThumbnailFactory *
-nautilus_icon_factory_get_thumbnail_factory (void)
-{
- NautilusIconFactory *factory;
-
- factory = get_icon_factory ();
-
- return g_object_ref (factory->thumbnail_factory);
-}
-
-
-static void
-check_recently_used_list (void)
-{
-#if CACHE_SELF_CHECKS
- NautilusIconFactory *factory;
- CircularList *head, *node, *next;
- guint count;
-
- factory = get_icon_factory ();
-
- head = &factory->recently_used_dummy_head;
-
- count = 0;
-
- node = head;
- while (1) {
- next = node->next;
- g_assert (next != NULL);
- g_assert (next->prev == node);
-
- if (next == head) {
- break;
- }
-
- count += 1;
-
- node = next;
- }
-
- g_assert (count == factory->recently_used_count);
-#endif
-}
-
-
-/* load the thumbnail frame */
-static void
-load_thumbnail_frame (NautilusIconFactory *factory)
-{
- char *image_path;
-
- image_path = nautilus_pixmap_file ("thumbnail_frame.png");
- if (factory->thumbnail_frame != NULL) {
- g_object_unref (factory->thumbnail_frame);
- }
- if (image_path != NULL) {
- factory->thumbnail_frame = gdk_pixbuf_new_from_file (image_path, NULL);
- }
- g_free (image_path);
-}
-
-typedef struct {
- NautilusFile *file;
- char *modifier;
- guint nominal_size;
- gboolean force_nominal;
-} AsnycThumbnailLoadFuncData;
-
-static void
-async_thumbnail_load_func (NautilusThumbnailAsyncLoadHandle *handle,
- const char *path,
- GdkPixbuf *pixbuf,
- double scale_x,
- double scale_y,
- gpointer user_data)
-{
- NautilusIconFactory *factory;
- GHashTable *hash_table;
- CacheKey *key;
- CacheIcon *cached_icon;
- struct stat statbuf;
- AsnycThumbnailLoadFuncData *data = user_data;
-
- factory = get_icon_factory ();
- hash_table = factory->icon_cache;
-
- nautilus_file_set_is_thumbnailing (data->file, FALSE);
- factory->async_thumbnail_load_handles =
- g_list_remove (factory->async_thumbnail_load_handles, handle);
-
- if (stat (path, &statbuf) != 0 ||
- !S_ISREG (statbuf.st_mode)) {
- g_message ("NautilusIconFactory: Failed to determine mtime for %s. Aborting thumbnailing request.", path);
- goto out;
- }
-
- if (!gdk_pixbuf_get_has_alpha (pixbuf)) {
- /* we don't own the pixbuf, but nautilus_thumbnail_frame_image() assumes so and unrefs it. */
- g_object_ref (pixbuf);
-
- nautilus_thumbnail_frame_image (&pixbuf);
- /* at this point, we own a pixbuf, which is the framed version of the passed-in pixbuf. */
- }
-
- cached_icon = cache_icon_new (pixbuf, NULL, scale_x, scale_y);
- cached_icon->mtime = statbuf.st_mtime;
-
- if (!gdk_pixbuf_get_has_alpha (pixbuf)) {
- g_object_unref (pixbuf);
- }
-
- if (cached_icon != NULL) {
- key = g_new (CacheKey, 1);
- key->name = g_strdup (path);
- key->modifier = g_strdup (data->modifier);
- key->nominal_size = data->nominal_size;
- key->force_nominal = data->force_nominal;
-
- g_hash_table_insert (hash_table, key, cached_icon);
-
- nautilus_file_changed (data->file);
- }
-
-out:
- nautilus_file_unref (data->file);
- g_free (data->modifier);
- g_free (data);
-}
-
-
-
-static void
-nautilus_icon_factory_instance_init (NautilusIconFactory *factory)
-{
- GdkPixbuf *pixbuf;
- guint i;
- static const char *types [] = {
- "image/x-bmp", "image/x-ico", "image/jpeg", "image/gif",
- "image/png", "image/pnm", "image/ras", "image/tga",
- "image/tiff", "image/wbmp", "image/bmp", "image/x-xbitmap",
- "image/x-xpixmap"
- };
-
-
- factory->icon_cache = g_hash_table_new_full (cache_key_hash,
- cache_key_equal,
- (GDestroyNotify)cache_key_destroy,
- (GDestroyNotify)cache_icon_unref);
-
- factory->icon_theme = gtk_icon_theme_get_default ();
- g_signal_connect_object (factory->icon_theme,
- "changed",
- G_CALLBACK (icon_theme_changed_callback),
- factory, 0);
-
-
- factory->thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
- load_thumbnail_frame (factory);
-
- /* Empty out the recently-used list. */
- factory->recently_used_dummy_head.next = &factory->recently_used_dummy_head;
- factory->recently_used_dummy_head.prev = &factory->recently_used_dummy_head;
-
- pixbuf = gdk_pixbuf_new_from_data (nautilus_default_file_icon,
- GDK_COLORSPACE_RGB,
- TRUE,
- 8,
- nautilus_default_file_icon_width,
- nautilus_default_file_icon_height,
- nautilus_default_file_icon_width * 4, /* stride */
- NULL, /* don't destroy data */
- NULL);
-
- factory->fallback_icon = cache_icon_new (pixbuf, NULL, 1.0, 1.0);
-
- g_object_unref(pixbuf);
-
- factory->image_mime_types = g_hash_table_new (g_str_hash, g_str_equal);
- for (i = 0; i < G_N_ELEMENTS (types); i++) {
- g_hash_table_insert (factory->image_mime_types,
- (gpointer) types [i],
- GUINT_TO_POINTER (1));
- }
-}
-
-static void
-nautilus_icon_factory_class_init (NautilusIconFactoryClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
-
- signals[ICONS_CHANGED]
- = g_signal_new ("icons_changed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- object_class->finalize = nautilus_icon_factory_finalize;
-}
-
-static void
-cache_key_destroy (CacheKey *key)
-{
- g_free (key->name);
- g_free (key->modifier);
- g_free (key);
-}
-
-static CacheIcon *
-cache_icon_new (GdkPixbuf *pixbuf,
- GtkIconInfo *info,
- double scale_x, double scale_y)
-{
- CacheIcon *icon;
- GdkRectangle rect;
- int i;
-
- /* Grab the pixbuf since we are keeping it. */
- g_object_ref (pixbuf);
-
- /* Make the icon. */
- icon = g_new0 (CacheIcon, 1);
- icon->ref_count = 1;
- icon->pixbuf = pixbuf;
- icon->mtime = 0;
-
- if (info) {
- icon->display_name = g_strdup (gtk_icon_info_get_display_name (info));
-
- if (gtk_icon_info_get_embedded_rect (info, &rect)) {
- rect.x *= scale_x;
- rect.width *= scale_x;
- rect.y *= scale_y;
- rect.height *= scale_y;
- icon->embedded_text_rect = g_memdup (&rect, sizeof (rect));
-
- }
-
- if (gtk_icon_info_get_attach_points (info,
- &icon->attach_points,
- &icon->n_attach_points)) {
- for (i = 0; i < icon->n_attach_points; i++) {
- icon->attach_points[i].x *= scale_x;
- icon->attach_points[i].y *= scale_x;
- }
- }
-
- }
-
- return icon;
-}
-
-static void
-cache_icon_ref (CacheIcon *icon)
-{
- g_assert (icon != NULL);
- g_assert (icon->ref_count >= 1);
-
- icon->ref_count++;
-}
-
-static void
-cache_icon_unref (CacheIcon *icon)
-{
- CircularList *node;
- NautilusIconFactory *factory;
-
- g_assert (icon != NULL);
- g_assert (icon->ref_count >= 1);
-
- if (icon->ref_count > 1) {
- icon->ref_count--;
- return;
- }
-
- icon->ref_count = 0;
-
- factory = get_icon_factory ();
-
- check_recently_used_list ();
-
- /* If it's in the recently used list, free it from there */
- node = &icon->recently_used_node;
- if (node->next != NULL) {
-#if CACHE_SELF_CHECKS
- g_assert (factory->recently_used_count >= 1);
-
- g_assert (node->next->prev == node);
- g_assert (node->prev->next == node);
- g_assert (node->next != node);
- g_assert (node->prev != node);
-#endif
- node->next->prev = node->prev;
- node->prev->next = node->next;
-
- node->next = NULL;
- node->prev = NULL;
-
- factory->recently_used_count -= 1;
- }
-
- check_recently_used_list ();
-
- g_object_unref (icon->pixbuf);
-
- g_free (icon->display_name);
- g_free (icon->embedded_text_rect);
- g_free (icon->attach_points);
-
- g_free (icon);
-}
-
-
-static gboolean
-nautilus_icon_factory_possibly_free_cached_icon (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- CacheIcon *icon;
-
- icon = value;
-
- /* Don't free a cache entry that is in the recently used list. */
- if (icon->recently_used_node.next != NULL) {
- return FALSE;
- }
-
- /* Don't free a cache entry if the pixbuf is still in use. */
- if (G_OBJECT (icon->pixbuf)->ref_count > 1) {
- return FALSE;
- }
-
- icon->age++;
-
- if (icon->age > ICON_MAX_AGE) {
- return TRUE;
- }
-
- /* Free the item. */
- return TRUE;
-}
-
-
-/* Sweep the cache, freeing any icons that are not in use and are
- * also not recently used.
- */
-static gboolean
-nautilus_icon_factory_sweep (gpointer user_data)
-{
- NautilusIconFactory *factory;
-
- factory = user_data;
-
- g_hash_table_foreach_remove (factory->icon_cache,
- nautilus_icon_factory_possibly_free_cached_icon,
- NULL);
-
- factory->sweep_timer = 0;
- return FALSE;
-}
-
-/* Schedule a timer to do a sweep. */
-static void
-nautilus_icon_factory_schedule_sweep (NautilusIconFactory *factory)
-{
- if (factory->sweep_timer != 0) {
- return;
- }
-
- factory->sweep_timer = g_timeout_add (ICON_CACHE_SWEEP_TIMEOUT,
- nautilus_icon_factory_sweep,
- factory);
-}
-
-/* Move this item to the head of the recently-used list,
- * bumping the last item off that list if necessary.
- */
-static void
-mark_recently_used (CircularList *node)
-{
- NautilusIconFactory *factory;
- CircularList *head, *last_node;
-
- check_recently_used_list ();
-
- factory = get_icon_factory ();
- head = &factory->recently_used_dummy_head;
-
- /* Move the node to the start of the list. */
- if (node->prev != head) {
- if (node->next != NULL) {
- /* Remove the node from its current position in the list. */
- node->next->prev = node->prev;
- node->prev->next = node->next;
- } else {
- /* Node was not already in the list, so add it.
- * If the list is already full, remove the last node.
- */
- if (factory->recently_used_count < ICON_CACHE_COUNT) {
- factory->recently_used_count += 1;
- } else {
- /* Remove the last node. */
- last_node = head->prev;
-
-#if CACHE_SELF_CHECKS
- g_assert (last_node != head);
- g_assert (last_node != node);
-#endif
-
- head->prev = last_node->prev;
- last_node->prev->next = head;
-
- last_node->prev = NULL;
- last_node->next = NULL;
- }
- }
-
- /* Insert the node at the head of the list. */
- node->prev = head;
- node->next = head->next;
- node->next->prev = node;
- head->next = node;
- }
-
- check_recently_used_list ();
-}
-
-static gboolean
-remove_all (gpointer key, gpointer value, gpointer user_data)
-{
- /* Tell the caller to remove the hash table entry. */
- return TRUE;
-}
-
-static gboolean
-remove_non_pathnames (gpointer _key, gpointer value, gpointer user_data)
-{
- CacheKey *key = _key;
-
- if (key->name && key->name[0] == '/') {
- return FALSE;
- }
-
- return TRUE; /* Tell the caller to remove the hash table entry. */
-}
-
-/* Reset the cache to the default state.
- Clear pathnames can be set to FALSE which means we only clear icon names, not
- absolute pathnames. This is useful to avoid throwing away all loaded thumbnails. */
-static void
-nautilus_icon_factory_clear (gboolean clear_pathnames)
-{
- NautilusIconFactory *factory;
- CircularList *head;
-
- factory = get_icon_factory ();
-
- g_hash_table_foreach_remove (factory->icon_cache,
- clear_pathnames ? remove_all : remove_non_pathnames,
- NULL);
-
- /* Empty out the recently-used list. */
- head = &factory->recently_used_dummy_head;
-
- if (clear_pathnames) {
- /* fallback_icon hangs around, but we don't know if it
- * was ever inserted in the list
- */
- g_assert (factory->recently_used_count == 0 ||
- factory->recently_used_count == 1);
- if (factory->recently_used_count == 1) {
- /* make sure this one is the fallback_icon */
- g_assert (head->next == head->prev);
- g_assert (&factory->fallback_icon->recently_used_node == head->next);
- }
- }
-
-}
-
-static void
-cancel_thumbnail_read_foreach (gpointer data,
- gpointer user_data)
-{
- NautilusThumbnailAsyncLoadHandle *handle = data;
- nautilus_thumbnail_load_image_cancel (handle);
-}
-
-static void
-nautilus_icon_factory_finalize (GObject *object)
-{
- NautilusIconFactory *factory;
-
- factory = NAUTILUS_ICON_FACTORY (object);
-
- g_list_foreach (factory->async_thumbnail_load_handles, cancel_thumbnail_read_foreach, NULL);
- g_list_free (factory->async_thumbnail_load_handles);
-
- if (factory->icon_cache) {
- g_hash_table_destroy (factory->icon_cache);
- factory->icon_cache = NULL;
- }
-
- if (factory->thumbnail_frame != NULL) {
- g_object_unref (factory->thumbnail_frame);
- factory->thumbnail_frame = NULL;
- }
-
- if (factory->fallback_icon) {
- g_assert (factory->fallback_icon->ref_count == 1);
- cache_icon_unref (factory->fallback_icon);
- }
-
- if (factory->image_mime_types) {
- g_hash_table_destroy (factory->image_mime_types);
- factory->image_mime_types = NULL;
- }
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-thumbnail_limit_changed_callback (gpointer user_data)
-{
- cached_thumbnail_limit = eel_preferences_get_integer (NAUTILUS_PREFERENCES_IMAGE_FILE_THUMBNAIL_LIMIT);
-
- /* Tell the world that icons might have changed. We could invent a narrower-scope
- * signal to mean only "thumbnails might have changed" if this ends up being slow
- * for some reason.
- */
- nautilus_icon_factory_clear (TRUE);
- g_signal_emit (global_icon_factory,
- signals[ICONS_CHANGED], 0);
-}
-
-static void
-thumbnail_size_changed_callback (gpointer user_data)
-{
- cached_thumbnail_size = eel_preferences_get_integer (NAUTILUS_PREFERENCES_ICON_VIEW_THUMBNAIL_SIZE);
-
- /* Tell the world that icons might have changed. We could invent a narrower-scope
- * signal to mean only "thumbnails might have changed" if this ends up being slow
- * for some reason.
- */
- nautilus_icon_factory_clear (TRUE);
- g_signal_emit (global_icon_factory,
- signals[ICONS_CHANGED], 0);
-}
-
-static void
-show_thumbnails_changed_callback (gpointer user_data)
-{
- show_image_thumbs = eel_preferences_get_enum (NAUTILUS_PREFERENCES_SHOW_IMAGE_FILE_THUMBNAILS);
-
- nautilus_icon_factory_clear (TRUE);
- /* If the user disabled thumbnailing, remove all outstanding thumbnails */
- if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_NEVER) {
- nautilus_thumbnail_remove_all_from_queue ();
- }
- g_signal_emit (global_icon_factory,
- signals[ICONS_CHANGED], 0);
-}
-
-static void
-mime_type_data_changed_callback (GnomeVFSMIMEMonitor *monitor, gpointer user_data)
-{
- g_assert (monitor != NULL);
- g_assert (user_data == NULL);
-
- /* We don't know which data changed, so we have to assume that
- * any or all icons might have changed.
- */
- nautilus_icon_factory_clear (FALSE);
- g_signal_emit (get_icon_factory (),
- signals[ICONS_CHANGED], 0);
-}
-
-static char *
-nautilus_remove_icon_file_name_suffix (const char *icon_name)
-{
- guint i;
- const char *suffix;
- static const char *icon_file_name_suffixes[] = { ".svg", ".svgz", ".png", ".jpg", ".xpm" };
-
- for (i = 0; i < G_N_ELEMENTS (icon_file_name_suffixes); i++) {
- suffix = icon_file_name_suffixes[i];
- if (eel_str_has_suffix (icon_name, suffix)) {
- return eel_str_strip_trailing_str (icon_name, suffix);
- }
- }
- return g_strdup (icon_name);
-}
-
-static char *
-image_uri_to_name_or_uri (const char *image_uri)
-{
- char *icon_path;
-
- icon_path = gnome_vfs_get_local_path_from_uri (image_uri);
- if (icon_path == NULL && image_uri[0] == '/') {
- icon_path = g_strdup (image_uri);
- }
- if (icon_path != NULL) {
- return icon_path;
- } else if (strpbrk (image_uri, ":/") == NULL) {
- return nautilus_remove_icon_file_name_suffix (image_uri);
- }
- return NULL;
-}
-
-static gboolean
-mimetype_limited_by_size (const char *mime_type)
-{
- NautilusIconFactory *factory;
-
- factory = get_icon_factory();
-
- if (g_hash_table_lookup (factory->image_mime_types, mime_type)) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-static gboolean
-should_show_thumbnail (NautilusFile *file, const char *mime_type)
-{
- if (mimetype_limited_by_size (mime_type) &&
- nautilus_file_get_size (file) > (unsigned int)cached_thumbnail_limit) {
- return FALSE;
- }
-
- if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_ALWAYS) {
- return TRUE;
- } else if (show_image_thumbs == NAUTILUS_SPEED_TRADEOFF_NEVER) {
- return FALSE;
- } else {
- /* only local files */
- return nautilus_file_is_local (file);
- }
-
- return FALSE;
-}
-
-static char *
-get_special_icon_for_file (NautilusFile *file)
-{
- char *uri, *ret;
-
- if (file == NULL) {
- return NULL;
- }
-
- if (nautilus_file_is_home (file)) {
- return ICON_NAME_HOME;
- }
-
- ret = NULL;
- uri = nautilus_file_get_uri (file);
-
- if (strcmp (uri, "burn:///") == 0) {
- ret = "nautilus-cd-burner";
- } else if (strcmp (uri, "computer:///") == 0) {
- ret = "gnome-fs-client";
- } else if ((strcmp (uri, "network:///") == 0)
- || (strcmp (uri, "smb:///") == 0)) {
- ret = "gnome-fs-network";
- } else if (strcmp (uri, EEL_TRASH_URI) == 0) {
- if (nautilus_trash_monitor_is_empty ()) {
- ret = ICON_NAME_TRASH_EMPTY;
- } else {
- ret = ICON_NAME_TRASH_FULL;
- }
- } else if (eel_uri_is_search (uri)) {
- /* FIXME: We really need a better icon than this */
- ret = "gnome-searchtool";
- }
-
- g_free (uri);
-
- return ret;
-}
-
-static gint
-gtk_icon_size_to_nominal_size (GtkIconSize icon_size)
-{
- gint ret;
-
- g_assert (gtk_icon_size_lookup (icon_size, &ret, NULL));
-
- return ret;
-}
-
-/* key routine to get the icon for a file */
-char *
-nautilus_icon_factory_get_icon_for_file (NautilusFile *file, gboolean embedd_text)
-{
- char *custom_uri, *file_uri, *icon_name, *mime_type, *custom_icon, *special_icon;
- NautilusIconFactory *factory;
- GnomeIconLookupResultFlags lookup_result;
- GnomeVFSFileInfo *file_info;
- GnomeThumbnailFactory *thumb_factory;
- gboolean show_thumb;
- GnomeIconLookupFlags lookup_flags;
-
- if (file == NULL) {
- return NULL;
- }
-
- factory = get_icon_factory ();
-
- custom_icon = NULL;
-
- /* Custom icon set by user, taken from metadata */
- custom_uri = nautilus_file_get_custom_icon (file);
- if (custom_uri) {
- custom_icon = image_uri_to_name_or_uri (custom_uri);
- }
- g_free (custom_uri);
-
- /* Icon for "special files" (burn, computer, network, smb, trash) */
- special_icon = get_special_icon_for_file (file);
- if (special_icon != NULL) {
- return g_strdup (special_icon);
- }
-
- file_uri = nautilus_file_get_uri (file);
-
- mime_type = nautilus_file_get_mime_type (file);
-
- file_info = nautilus_file_peek_vfs_file_info (file);
-
- show_thumb = should_show_thumbnail (file, mime_type);
-
- if (show_thumb) {
- thumb_factory = factory->thumbnail_factory;
- } else {
- thumb_factory = NULL;
- }
-
- lookup_flags = GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES;
- if (embedd_text) {
- lookup_flags |= GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT;
- }
- icon_name = gnome_icon_lookup (factory->icon_theme,
- thumb_factory,
- file_uri,
- custom_icon,
- nautilus_file_peek_vfs_file_info (file),
- mime_type,
- lookup_flags,
- &lookup_result);
-
-
- /* Create thumbnails if we can, and if the looked up icon isn't a thumbnail
- or an absolute pathname (custom icon or image as itself) */
- if (show_thumb &&
- !(lookup_result & GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL) &&
- icon_name[0] != '/' && file_info &&
- gnome_thumbnail_factory_can_thumbnail (factory->thumbnail_factory,
- file_uri,
- mime_type,
- file_info->mtime)) {
- nautilus_create_thumbnail (file);
- g_free (icon_name);
- icon_name = g_strdup (ICON_NAME_THUMBNAIL_LOADING);
- }
-
- g_free (file_uri);
- g_free (custom_icon);
- g_free (mime_type);
-
- return icon_name;
-}
-
-/**
- * nautilus_icon_factory_get_required_file_attributes
- *
- * Get the file attributes required to obtain a file's icon.
- */
-NautilusFileAttributes
-nautilus_icon_factory_get_required_file_attributes (void)
-{
- return NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE;
-}
-
-
-/**
- * nautilus_icon_factory_is_icon_ready_for_file
- *
- * Check whether a NautilusFile has enough information to report
- * what its icon should be.
- *
- * @file: The NautilusFile in question.
- */
-gboolean
-nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file)
-{
- NautilusFileAttributes attributes;
- gboolean result;
-
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- result = nautilus_file_check_if_ready (file, attributes) ||
- (get_special_icon_for_file (file) != NULL);
-
- return result;
-}
-
-char *
-nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name)
-{
- char *name_with_prefix;
-
- name_with_prefix = g_strconcat (NAUTILUS_EMBLEM_NAME_PREFIX, emblem_name, NULL);
-
- return name_with_prefix;
-}
-
-guint
-nautilus_icon_factory_get_emblem_size_for_icon_size (guint size)
-{
- if (size >= 96)
- return 48;
- if (size >= 64)
- return 32;
- if (size >= 48)
- return 24;
- if (size >= 32)
- return 16;
-
- return 0; /* no emblems for smaller sizes */
-}
-
-GList *
-nautilus_icon_factory_get_emblem_icons_for_file (NautilusFile *file,
- EelStringList *exclude)
-{
- GList *icons, *emblem_names, *node;
- char *uri, *name;
- char *icon;
- gboolean file_is_trash;
-
- icons = NULL;
-
- emblem_names = nautilus_file_get_emblem_names (file);
- for (node = emblem_names; node != NULL; node = node->next) {
- name = node->data;
- if (strcmp (name, NAUTILUS_FILE_EMBLEM_NAME_TRASH) == 0) {
- /* Leave out the trash emblem for the trash itself, since
- * putting a trash emblem on a trash icon is gilding the
- * lily.
- */
- uri = nautilus_file_get_uri (file);
- file_is_trash = strcmp (uri, EEL_TRASH_URI) == 0;
- g_free (uri);
- if (file_is_trash) {
- continue;
- }
- }
- if (eel_string_list_contains (exclude, name)) {
- continue;
- }
- icon = nautilus_icon_factory_get_emblem_icon_by_name (name);
- icons = g_list_prepend (icons, icon);
- }
- eel_g_list_free_deep (emblem_names);
-
- return g_list_reverse (icons);
-}
-
-guint
-nautilus_icon_factory_get_larger_icon_size (guint size)
-{
- if (size < NAUTILUS_ICON_SIZE_SMALLEST) {
- return NAUTILUS_ICON_SIZE_SMALLEST;
- }
- if (size < NAUTILUS_ICON_SIZE_SMALLER) {
- return NAUTILUS_ICON_SIZE_SMALLER;
- }
- if (size < NAUTILUS_ICON_SIZE_SMALL) {
- return NAUTILUS_ICON_SIZE_SMALL;
- }
- if (size < NAUTILUS_ICON_SIZE_STANDARD) {
- return NAUTILUS_ICON_SIZE_STANDARD;
- }
- if (size < NAUTILUS_ICON_SIZE_LARGE) {
- return NAUTILUS_ICON_SIZE_LARGE;
- }
- if (size < NAUTILUS_ICON_SIZE_LARGER) {
- return NAUTILUS_ICON_SIZE_LARGER;
- }
- return NAUTILUS_ICON_SIZE_LARGEST;
-}
-
-guint
-nautilus_icon_factory_get_smaller_icon_size (guint size)
-{
- if (size > NAUTILUS_ICON_SIZE_LARGEST) {
- return NAUTILUS_ICON_SIZE_LARGEST;
- }
- if (size > NAUTILUS_ICON_SIZE_LARGER) {
- return NAUTILUS_ICON_SIZE_LARGER;
- }
- if (size > NAUTILUS_ICON_SIZE_LARGE) {
- return NAUTILUS_ICON_SIZE_LARGE;
- }
- if (size > NAUTILUS_ICON_SIZE_STANDARD) {
- return NAUTILUS_ICON_SIZE_STANDARD;
- }
- if (size > NAUTILUS_ICON_SIZE_SMALL) {
- return NAUTILUS_ICON_SIZE_SMALL;
- }
- if (size > NAUTILUS_ICON_SIZE_SMALLER) {
- return NAUTILUS_ICON_SIZE_SMALLER;
- }
- return NAUTILUS_ICON_SIZE_SMALLEST;
-}
-
-
-
-/* This loads an SVG image, scaling it to the appropriate size. */
-static GdkPixbuf *
-load_pixbuf_svg (const char *path,
- guint size_in_pixels,
- guint base_size,
- double *scale_x,
- double *scale_y)
-{
- double zoom;
- int width, height;
- GdkPixbuf *pixbuf;
-
- if (base_size != 0) {
- zoom = (double)size_in_pixels / base_size;
-
- pixbuf = rsvg_pixbuf_from_file_at_zoom_with_max (path, zoom, zoom, size_in_pixels, size_in_pixels, NULL);
- } else {
- pixbuf = rsvg_pixbuf_from_file_at_max_size (path,
- size_in_pixels,
- size_in_pixels,
- NULL);
- }
-
- if (pixbuf == NULL) {
- return NULL;
- }
-
- width = gdk_pixbuf_get_width (pixbuf);
- height = gdk_pixbuf_get_height (pixbuf);
- *scale_x = width / 1000.0;
- *scale_y = height / 1000.0;
-
- return pixbuf;
-}
-
-static gboolean
-path_represents_svg_image (const char *path)
-{
- /* Synchronous mime sniffing is a really bad idea here
- * since it's only useful for people adding custom icons,
- * and if they're doing that, they can behave themselves
- * and use a .svg extension.
- */
- return path != NULL && (g_str_has_suffix (path, ".svg") || g_str_has_suffix (path, ".svgz"));
-}
-
-static GdkPixbuf *
-load_icon_file (const char *filename,
- guint base_size,
- guint nominal_size,
- gboolean force_nominal,
- double *scale_x,
- double *scale_y)
-{
- GdkPixbuf *pixbuf;
- gboolean add_frame;
-
- add_frame = FALSE;
-
- *scale_x = 1.0;
- *scale_y = 1.0;
-
- if (path_represents_svg_image (filename)) {
- pixbuf = load_pixbuf_svg (filename,
- nominal_size,
- force_nominal ? 0 : base_size,
- scale_x, scale_y);
- } else {
- int original_size;
- gboolean is_thumbnail;
-
- /* FIXME: Maybe we shouldn't have to load the file each time
- * Not sure if that is important */
- pixbuf = nautilus_thumbnail_load_image (filename,
- base_size,
- nominal_size,
- force_nominal,
- scale_x,
- scale_y);
-
- if (pixbuf == NULL) {
- return NULL;
- }
-
- is_thumbnail = strstr (filename, "/.thumbnails/") != NULL;
-
- original_size = ceil (MAX (gdk_pixbuf_get_width (pixbuf) / *scale_x, gdk_pixbuf_get_height (pixbuf) / *scale_y));
-
- if ((is_thumbnail || (!force_nominal && base_size == 0 && original_size > cached_thumbnail_size))
- && !gdk_pixbuf_get_has_alpha (pixbuf)) {
- add_frame = TRUE;
- }
- }
-
- if (add_frame) {
- nautilus_thumbnail_frame_image(&pixbuf);
- }
-
- return pixbuf;
-}
-
-static CacheIcon *
-create_normal_cache_icon (const char *icon,
- const char *modifier,
- guint nominal_size,
- gboolean force_nominal)
-{
- NautilusIconFactory *factory;
- const char *filename;
- char *name_with_modifier;
- GtkIconInfo *info;
- CacheIcon *cache_icon;
- GdkPixbuf *pixbuf;
- int base_size;
- struct stat statbuf;
- time_t mtime;
- double scale_x, scale_y;
-
- factory = get_icon_factory ();
-
- info = NULL;
- filename = NULL;
-
- mtime = 0;
-
- base_size = 0;
- if (icon[0] == '/') {
- /* FIXME: maybe we should add modifier to the filename
- * before the extension */
- if (stat (icon, &statbuf) == 0 &&
- S_ISREG (statbuf.st_mode)) {
- filename = icon;
- mtime = statbuf.st_mtime;
- }
- } else {
- if (modifier) {
- name_with_modifier = g_strconcat (icon, "-", modifier, NULL);
- } else {
- name_with_modifier = (char *)icon;
- }
-
- info = gtk_icon_theme_lookup_icon (factory->icon_theme,
- name_with_modifier,
- nominal_size,
- GTK_ICON_LOOKUP_FORCE_SVG);
- if (name_with_modifier != icon) {
- g_free (name_with_modifier);
- }
-
- if (info == NULL) {
- return NULL;
- }
-
- gtk_icon_info_set_raw_coordinates (info, TRUE);
- base_size = gtk_icon_info_get_base_size (info);
- filename = gtk_icon_info_get_filename (info);
- }
-
- /* If e.g. the absolute filename doesn't exist */
- if (filename == NULL) {
- return NULL;
- }
-
- pixbuf = load_icon_file (filename,
- base_size,
- nominal_size,
- force_nominal,
- &scale_x, &scale_y);
- if (pixbuf == NULL) {
- if (info) {
- gtk_icon_info_free (info);
- }
- return NULL;
- }
-
- cache_icon = cache_icon_new (pixbuf, info, scale_x, scale_y);
- cache_icon->mtime = mtime;
-
- if (info) {
- gtk_icon_info_free (info);
- }
- g_object_unref (pixbuf);
-
- return cache_icon;
-}
-
-static CacheIcon *
-lookup_icon_from_cache (const char *icon,
- const char *modifier,
- guint nominal_size,
- gboolean force_nominal)
-{
- NautilusIconFactory *factory;
- GHashTable *hash_table;
- CacheKey lookup_key, *key;
- CacheIcon *value;
-
- lookup_key.name = (char *)icon;
- lookup_key.modifier = (char *)modifier;
- lookup_key.nominal_size = nominal_size;
- lookup_key.force_nominal = force_nominal;
-
- factory = get_icon_factory ();
- hash_table = factory->icon_cache;
-
- if (g_hash_table_lookup_extended (hash_table, &lookup_key,
- (gpointer *) &key, (gpointer *) &value)) {
- /* Found it in the table. */
- g_assert (key != NULL);
- g_assert (value != NULL);
- } else {
- key = NULL;
- value = NULL;
- }
-
- return value;
-}
-
-
-/* Get the icon, handling the caching.
- * If @picky is true, then only an unscaled icon is acceptable.
- * Also, if @picky is true, the icon must be a custom icon if
- * @custom is true or a standard icon is @custom is false.
- * If @force_nominal is #TRUE, the returned icon will be guaranteed
- * to be smaller than the nominal size
- */
-static CacheIcon *
-get_icon_from_cache (const char *icon,
- const char *modifier,
- guint nominal_size,
- gboolean force_nominal)
-{
- NautilusIconFactory *factory;
- GHashTable *hash_table;
- CacheKey *key;
- CacheIcon *cached_icon;
- struct stat statbuf;
-
- g_return_val_if_fail (icon != NULL, NULL);
-
- factory = get_icon_factory ();
- hash_table = factory->icon_cache;
-
- /* Check to see if it's already in the table. */
- cached_icon = lookup_icon_from_cache (icon, modifier, nominal_size, force_nominal);
-
- /* Make sure that thumbnails and image-as-itself icons gets
- reloaded when they change: */
- if (cached_icon && icon[0] == '/') {
- if (stat (icon, &statbuf) != 0 ||
- !S_ISREG (statbuf.st_mode) ||
- statbuf.st_mtime != cached_icon->mtime) {
- cached_icon = NULL;
- }
- }
-
- if (cached_icon == NULL) {
- /* Not in the table, so load the image. */
-
- /*
- g_print ("cache miss for %s:%s:%s:%d\n",
- icon, modifier?modifier:"", embedded_text?"<tl>":"", nominal_size);
- */
-
- cached_icon = create_normal_cache_icon (icon,
- modifier,
- nominal_size,
- force_nominal);
- /* Try to fallback without modifier */
- if (cached_icon == NULL && modifier != NULL) {
- cached_icon = create_normal_cache_icon (icon,
- NULL,
- nominal_size,
- force_nominal);
- }
-
- if (cached_icon == NULL) {
- cached_icon = factory->fallback_icon;
- cache_icon_ref (cached_icon);
- }
-
- /* Create the key and icon for the hash table. */
- key = g_new (CacheKey, 1);
- key->name = g_strdup (icon);
- key->modifier = g_strdup (modifier);
- key->nominal_size = nominal_size;
- key->force_nominal = force_nominal;
-
- g_hash_table_insert (hash_table, key, cached_icon);
- }
-
- /* Hand back a ref to the caller. */
- cache_icon_ref (cached_icon);
-
- /* Since this item was used, keep it in the cache longer. */
- mark_recently_used (&cached_icon->recently_used_node);
- cached_icon->age = 0;
-
- /* Come back later and sweep the cache. */
- nautilus_icon_factory_schedule_sweep (factory);
-
- return cached_icon;
-}
-
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_for_icon (const char *icon,
- const char *modifier,
- guint nominal_size,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean force_size,
- gboolean wants_default,
- char **display_name)
-{
- NautilusIconFactory *factory;
- CacheIcon *cached_icon;
- GdkPixbuf *pixbuf;
- int i;
-
- factory = get_icon_factory ();
- cached_icon = get_icon_from_cache (icon,
- modifier,
- nominal_size,
- force_size);
-
- if (attach_points != NULL) {
- if (cached_icon->attach_points != NULL) {
- attach_points->num_points = MIN (cached_icon->n_attach_points,
- MAX_ATTACH_POINTS);
- for (i = 0; i < attach_points->num_points; i++) {
- attach_points->points[i].x = cached_icon->attach_points[i].x;
- attach_points->points[i].y = cached_icon->attach_points[i].y;
- }
- } else {
- attach_points->num_points = 0;
- }
- }
- if (embedded_text_rect) {
- if (cached_icon->embedded_text_rect != NULL) {
- *embedded_text_rect = *cached_icon->embedded_text_rect;
- } else {
- embedded_text_rect->x = 0;
- embedded_text_rect->y = 0;
- embedded_text_rect->width = 0;
- embedded_text_rect->height = 0;
- }
- }
-
- if (display_name != NULL) {
- *display_name = g_strdup (cached_icon->display_name);
- }
-
- /* if we don't want a default icon and one is returned, return NULL instead */
- if (!wants_default && cached_icon == factory->fallback_icon) {
- cache_icon_unref (cached_icon);
- return NULL;
- }
-
- pixbuf = cached_icon->pixbuf;
- g_object_ref (pixbuf);
- cache_icon_unref (cached_icon);
-
- return pixbuf;
-}
-
-
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_for_icon_with_stock_size (const char *icon,
- const char *modifier,
- GtkIconSize stock_size,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean wants_default,
- char **display_name)
-{
- return nautilus_icon_factory_get_pixbuf_for_icon (icon, modifier,
- gtk_icon_size_to_nominal_size (stock_size),
- attach_points, embedded_text_rect,
- TRUE /* force_size*/, wants_default,
- display_name);
-}
-
-static guint
-cache_key_hash (gconstpointer p)
-{
- const CacheKey *key;
- guint hash;
-
- key = p;
-
- hash = g_str_hash (key->name) ^
- ((key->nominal_size << 4) + (gint)key->force_nominal);
-
- if (key->modifier) {
- hash ^= g_str_hash (key->modifier);
- }
-
- return hash;
-}
-
-static gboolean
-cache_key_equal (gconstpointer a, gconstpointer b)
-{
- const CacheKey *key_a, *key_b;
-
- key_a = a;
- key_b = b;
-
- return eel_strcmp (key_a->name, key_b->name) == 0 &&
- key_a->nominal_size == key_b->nominal_size &&
- key_a->force_nominal == key_b->force_nominal &&
- eel_strcmp (key_a->modifier, key_b->modifier) == 0;
-}
-
-/* Return nominal icon size for given zoom level.
- * @zoom_level: zoom level for which to find matching icon size.
- *
- * Return value: icon size between NAUTILUS_ICON_SIZE_SMALLEST and
- * NAUTILUS_ICON_SIZE_LARGEST, inclusive.
- */
-guint
-nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
-{
- switch (zoom_level) {
- case NAUTILUS_ZOOM_LEVEL_SMALLEST:
- return NAUTILUS_ICON_SIZE_SMALLEST;
- case NAUTILUS_ZOOM_LEVEL_SMALLER:
- return NAUTILUS_ICON_SIZE_SMALLER;
- case NAUTILUS_ZOOM_LEVEL_SMALL:
- return NAUTILUS_ICON_SIZE_SMALL;
- case NAUTILUS_ZOOM_LEVEL_STANDARD:
- return NAUTILUS_ICON_SIZE_STANDARD;
- case NAUTILUS_ZOOM_LEVEL_LARGE:
- return NAUTILUS_ICON_SIZE_LARGE;
- case NAUTILUS_ZOOM_LEVEL_LARGER:
- return NAUTILUS_ICON_SIZE_LARGER;
- case NAUTILUS_ZOOM_LEVEL_LARGEST:
- return NAUTILUS_ICON_SIZE_LARGEST;
- }
- g_return_val_if_reached (NAUTILUS_ICON_SIZE_STANDARD);
-}
-
-float
-nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
-{
- return (float)nautilus_get_icon_size_for_zoom_level (zoom_level) / NAUTILUS_ICON_SIZE_STANDARD;
-}
-
-/* Convenience cover for nautilus_icon_factory_get_icon_for_file
- * and nautilus_icon_factory_get_pixbuf_for_icon.
- *
- * If a file has an associated thumbnail, the thumb is loaded asynchronously,
- * a loading thumbnail image is returned
- * and the file will receive a "changed" event once the thumbnail has been loaded.
- *
- * The "file" parameter is only used for thumbnailing,
- * for the file change notification once the actual thumbnail
- * has been loaded.
- */
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_for_file_with_icon (NautilusFile *file,
- const char *icon,
- const char *modifier,
- guint size_in_pixels,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean force_size,
- gboolean wants_default,
- char **display_name)
-{
- GdkPixbuf *pixbuf;
- NautilusIconFactory *factory;
- gboolean is_thumbnail;
-
- factory = get_icon_factory ();
-
- is_thumbnail = strstr (icon, "/.thumbnails/") != NULL;
-
- if (is_thumbnail &&
- !lookup_icon_from_cache (icon, modifier, size_in_pixels, force_size)) {
- AsnycThumbnailLoadFuncData *data;
-
- /* Asynchronous thumbnail loading.
- *
- * This heavily improves performance for folders containing lots of
- * previously thumbnailed files.
- *
- * Note: We do not pass the additional thumbnail parameters (attach points etc.)
- * to the thread as we don't need them for the cache. The API user may herself
- * re-request the loaded thumbnail with the correct parameters, which will be set
- * accordingly in nautilus_icon_factory_get_pixbuf_for_icon() on cache hit
- * once it is filled.
- */
-
- data = g_new (AsnycThumbnailLoadFuncData, 1);
- data->file = nautilus_file_ref (file);
- data->modifier = g_strdup (modifier);
- data->nominal_size = size_in_pixels;
- data->force_nominal = force_size;
-
- nautilus_file_set_is_thumbnailing (file, TRUE);
-
- factory->async_thumbnail_load_handles = g_list_prepend (
- factory->async_thumbnail_load_handles,
- nautilus_thumbnail_load_image_async (icon,
- 0, /* base_size */
- size_in_pixels,
- force_size,
- async_thumbnail_load_func,
- data));
-
- icon = ICON_NAME_THUMBNAIL_LOADING;
- }
-
-
- pixbuf = nautilus_icon_factory_get_pixbuf_for_icon (icon,
- modifier, size_in_pixels,
- attach_points, embedded_text_rect,
- force_size,
- wants_default, display_name);
-
- return pixbuf;
-}
-
-/*
- * like nautilus_icon_factory_get_pixbuf_for_file_with_icon() but does the icon lookup itself,
- * doesn't allow emblem and text rect fetching.
- */
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_for_file (NautilusFile *file,
- const char *modifier,
- guint size_in_pixels,
- gboolean force_size)
-{
- GdkPixbuf *pixbuf;
- NautilusIconFactory *factory;
- char *icon;
-
- factory = get_icon_factory ();
-
- /* Get the pixbuf for this file. */
- icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- if (icon == NULL) {
- return NULL;
- }
-
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file_with_icon (file,
- icon, modifier,
- size_in_pixels,
- NULL, NULL,
- force_size,
- TRUE, NULL);
- g_free (icon);
-
- return pixbuf;
-}
-
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_for_file_with_stock_size (NautilusFile *file,
- const char *modifier,
- GtkIconSize stock_size)
-{
- return nautilus_icon_factory_get_pixbuf_for_file (file, modifier,
- gtk_icon_size_to_nominal_size (stock_size),
- TRUE /* force_size */);
-
-}
-
-/* Convenience routine for getting a pixbuf from an icon name. */
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
- const char *modifier,
- guint size_in_pixels,
- gboolean force_size,
- char **display_name)
-{
- return nautilus_icon_factory_get_pixbuf_for_icon (icon_name, modifier,
- size_in_pixels,
- NULL, NULL,
- force_size, TRUE,
- display_name);
-}
-
-GdkPixbuf *
-nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (const char *icon_name,
- const char *modifier,
- GtkIconSize stock_size,
- char **display_name)
-{
- return nautilus_icon_factory_get_pixbuf_from_name (icon_name, modifier,
- gtk_icon_size_to_nominal_size (stock_size),
- TRUE, display_name);
-}
-
-
-GdkPixbuf *
-nautilus_icon_factory_get_thumbnail_frame (void)
-{
- return get_icon_factory ()->thumbnail_frame;
-}
-
-gboolean
-nautilus_icon_factory_remove_from_cache (const char *icon_name,
- const char *modifier,
- guint size)
-{
- GHashTable *hash_table;
- NautilusIconFactory *factory;
- CacheKey lookup_key;
-
- factory = get_icon_factory ();
- hash_table = factory->icon_cache;
-
- /* Check to see if it's already in the table. */
- lookup_key.name = (char *)icon_name;
- lookup_key.modifier = (char *)modifier;
- lookup_key.nominal_size = size;
-
- return g_hash_table_remove (hash_table, &lookup_key);
-}
-
-#if ! defined (NAUTILUS_OMIT_SELF_CHECK)
-
-void
-nautilus_self_check_icon_factory (void)
-{
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (0), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (1), 24);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (2), 32);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (3), 48);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (4), 72);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (5), 96);
- EEL_CHECK_INTEGER_RESULT (nautilus_get_icon_size_for_zoom_level (6), 192);
-
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (0), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (1), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (15), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (16), 24);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (23), 24);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (24), 32);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (31), 32);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (32), 48);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (47), 48);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (48), 72);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (71), 72);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (72), 96);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (95), 96);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (96), 192);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (191), 192);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (192), 192);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_larger_icon_size (0xFFFFFFFF), 192);
-
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (0), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (1), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (11), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (12), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (24), 16);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (25), 24);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (32), 24);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (33), 32);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (48), 32);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (49), 48);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (72), 48);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (73), 72);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (96), 72);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (97), 96);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (192), 96);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (193), 192);
- EEL_CHECK_INTEGER_RESULT (nautilus_icon_factory_get_smaller_icon_size (0xFFFFFFFF), 192);
-}
-
-#endif /* ! NAUTILUS_OMIT_SELF_CHECK */
diff --git a/libnautilus-private/nautilus-icon-factory.h b/libnautilus-private/nautilus-icon-factory.h
deleted file mode 100644
index 673172125..000000000
--- a/libnautilus-private/nautilus-icon-factory.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-icon-factory.h: Class for obtaining icons for files and other objects.
-
- Copyright (C) 1999, 2000 Red Hat Inc.
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: John Sullivan <sullivan@eazel.com>
-*/
-
-#ifndef NAUTILUS_ICON_FACTORY_H
-#define NAUTILUS_ICON_FACTORY_H
-
-#include <eel/eel-string-list.h>
-#include <gdk/gdktypes.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <gtk/gtkobject.h>
-#include <libnautilus-private/nautilus-file.h>
-#include <libgnomeui/gnome-icon-theme.h>
-#include <libgnomeui/gnome-thumbnail.h>
-
-/* NautilusIconFactory is a class that knows how to hand out icons to be
- * used for representing files and some other objects. It was designed
- * specifically to be useful for the Nautilus file browser, but could be
- * used by any program that wants to display the standard icon for a
- * file.
- *
- * The most common usage is to get a NautilusIconFactory object with
- * nautilus_get_current_icon_factory, then ask for an icon for a specific
- * file with nautilus_icon_factory_get_icon_for_file. The caller can ask
- * for any size icon, but normally will use one of the defined
- * NAUTILUS_ICON_SIZE macros.
- */
-
-/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
-typedef enum {
- NAUTILUS_ZOOM_LEVEL_SMALLEST,
- NAUTILUS_ZOOM_LEVEL_SMALLER,
- NAUTILUS_ZOOM_LEVEL_SMALL,
- NAUTILUS_ZOOM_LEVEL_STANDARD,
- NAUTILUS_ZOOM_LEVEL_LARGE,
- NAUTILUS_ZOOM_LEVEL_LARGER,
- NAUTILUS_ZOOM_LEVEL_LARGEST
-} NautilusZoomLevel;
-
-/* Nominal icon sizes for each Nautilus zoom level.
- * This scheme assumes that icons are designed to
- * fit in a square space, though each image needn't
- * be square. Since individual icons can be stretched,
- * each icon is not constrained to this nominal size.
- */
-#define NAUTILUS_ICON_SIZE_SMALLEST 16
-#define NAUTILUS_ICON_SIZE_SMALLER 24
-#define NAUTILUS_ICON_SIZE_SMALL 32
-#define NAUTILUS_ICON_SIZE_STANDARD 48
-#define NAUTILUS_ICON_SIZE_LARGE 72
-#define NAUTILUS_ICON_SIZE_LARGER 96
-#define NAUTILUS_ICON_SIZE_LARGEST 192
-
-#define NAUTILUS_ICON_SIZE_THUMBNAIL 96
-
-/* Maximum size of an icon that the icon factory will ever produce */
-#define NAUTILUS_ICON_MAXIMUM_SIZE 320
-
-/* here's a structure to hold the emblem attach points */
-
-#define MAX_ATTACH_POINTS 12
-
-typedef struct {
- int num_points;
- GdkPoint points[MAX_ATTACH_POINTS];
-} NautilusEmblemAttachPoints;
-
-/* Instead of a class declaration here, I will just document
- * the signals.
- *
- * "icons_changed", no parameters
- */
-
-/* There's a single NautilusIconFactory object.
- * The only thing you need it for is to connect to its signals.
- */
-GObject * nautilus_icon_factory_get (void);
-
-/* Relationship between zoom levels and icons sizes. */
-guint nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
-float nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
-
-/* Choose the appropriate icon, but don't render it yet. */
-char * nautilus_icon_factory_get_icon_for_file (NautilusFile *file,
- gboolean embedd_text);
-gboolean nautilus_icon_factory_is_icon_ready_for_file (NautilusFile *file);
-NautilusFileAttributes nautilus_icon_factory_get_required_file_attributes (void);
-
-GList * nautilus_icon_factory_get_emblem_icons_for_file (NautilusFile *file,
- EelStringList *exclude);
-char * nautilus_icon_factory_get_emblem_icon_by_name (const char *emblem_name);
-guint nautilus_icon_factory_get_emblem_size_for_icon_size (guint size);
-
-guint nautilus_icon_factory_get_larger_icon_size (guint size);
-guint nautilus_icon_factory_get_smaller_icon_size (guint size);
-
-/* Render an icon to a particular size.
- * Ownership of a ref. count in this pixbuf comes with the deal.
- * This allows scaling in both dimensions. All other calls assume
- * that X and Y scaling are the same. Optionally, we also pass
- * back an array of emblem attach points, if the pointer is non-null
- * If the wants_default boolean is set, return a default icon instead
- * of NULL if we can't find anything
- */
-GdkPixbuf *nautilus_icon_factory_get_pixbuf_for_icon (const char *icon,
- const char *modifier,
- guint nominal_size,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean force_size,
- gboolean wants_default,
- char **display_name);
-GdkPixbuf *nautilus_icon_factory_get_pixbuf_for_icon_with_stock_size (const char *icon,
- const char *modifier,
- GtkIconSize stock_size,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean wants_default,
- char **display_name);
-
-
-/* Convenience functions for the common case where you want to choose
- * and render the icon into a pixbuf all at once.
- */
-GdkPixbuf *nautilus_icon_factory_get_pixbuf_for_file (NautilusFile *file,
- const char *modifer,
- guint size_in_pixels,
- gboolean force_size);
-GdkPixbuf *nautilus_icon_factory_get_pixbuf_for_file_with_stock_size (NautilusFile *file,
- const char *modifier,
- GtkIconSize stock_size);
-
-GdkPixbuf * nautilus_icon_factory_get_pixbuf_for_file_with_icon (NautilusFile *file,
- const char *icon,
- const char *modifier,
- guint size_in_pixels,
- NautilusEmblemAttachPoints *attach_points,
- GdkRectangle *embedded_text_rect,
- gboolean force_size,
- gboolean wants_default,
- char **display_name);
-
-
-/* Convenience routine for getting a pixbuf from an icon name
- */
-GdkPixbuf * nautilus_icon_factory_get_pixbuf_from_name (const char *icon_name,
- const char *modifer,
- guint size_in_pixels,
- gboolean force_size,
- char **display_name);
-GdkPixbuf * nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (const char *icon_name,
- const char *modifer,
- GtkIconSize stock_size,
- char **display_name);
-
-GtkIconTheme * nautilus_icon_factory_get_icon_theme (void);
-GnomeThumbnailFactory *nautilus_icon_factory_get_thumbnail_factory (void);
-gboolean nautilus_icon_factory_remove_from_cache (const char *icon_name,
- const char *modifier,
- guint size);
-
-
-#endif /* NAUTILUS_ICON_FACTORY_H */
-
diff --git a/libnautilus-private/nautilus-icon-info.c b/libnautilus-private/nautilus-icon-info.c
new file mode 100644
index 000000000..cbf387eed
--- /dev/null
+++ b/libnautilus-private/nautilus-icon-info.c
@@ -0,0 +1,666 @@
+/* nautilus-icon-info.c
+ * Copyright (C) 2007 Red Hat, Inc., Alexander Larsson <alexl@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <string.h>
+#include "nautilus-icon-info.h"
+#include "nautilus-default-file-icon.h"
+#include <gtk/gtkicontheme.h>
+#include <gtk/gtkiconfactory.h>
+#include <gio/gloadableicon.h>
+#include <gio/gthemedicon.h>
+#include <eel/eel-gdk-pixbuf-extensions.h>
+
+#define NAUTILUS_EMBLEM_NAME_PREFIX "emblem-"
+
+struct _NautilusIconInfo
+{
+ GObject parent;
+
+ gboolean sole_owner;
+ guint64 last_use_time;
+ GdkPixbuf *pixbuf;
+
+ gboolean got_embedded_rect;
+ GdkRectangle embedded_rect;
+ gint n_attach_points;
+ GdkPoint *attach_points;
+ char *display_name;
+ char *icon_name;
+};
+
+struct _NautilusIconInfoClass
+{
+ GObjectClass parent_class;
+};
+
+static void schedule_reap_cache (void);
+
+G_DEFINE_TYPE (NautilusIconInfo,
+ nautilus_icon_info,
+ G_TYPE_OBJECT);
+
+static void
+nautilus_icon_info_init (NautilusIconInfo *icon)
+{
+ icon->last_use_time = g_thread_gettime ();
+ icon->sole_owner = TRUE;
+}
+
+static void
+pixbuf_toggle_notify (gpointer info,
+ GObject *object,
+ gboolean is_last_ref)
+{
+ NautilusIconInfo *icon = info;
+
+ if (is_last_ref) {
+ icon->sole_owner = TRUE;
+ g_object_remove_toggle_ref (object,
+ pixbuf_toggle_notify,
+ info);
+ icon->last_use_time = g_thread_gettime ();
+ schedule_reap_cache ();
+ }
+}
+
+static void
+nautilus_icon_info_finalize (GObject *object)
+{
+ NautilusIconInfo *icon;
+
+ icon = NAUTILUS_ICON_INFO (object);
+
+ if (!icon->sole_owner && icon->pixbuf) {
+ g_object_remove_toggle_ref (G_OBJECT (icon->pixbuf),
+ pixbuf_toggle_notify,
+ icon);
+ }
+
+ if (icon->pixbuf) {
+ g_object_unref (icon->pixbuf);
+ }
+ g_free (icon->attach_points);
+ g_free (icon->display_name);
+ g_free (icon->icon_name);
+
+ G_OBJECT_CLASS (nautilus_icon_info_parent_class)->finalize (object);
+}
+
+static void
+nautilus_icon_info_class_init (NautilusIconInfoClass *icon_info_class)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = (GObjectClass *) icon_info_class;
+
+ gobject_class->finalize = nautilus_icon_info_finalize;
+
+}
+
+NautilusIconInfo *
+nautilus_icon_info_new_for_pixbuf (GdkPixbuf *pixbuf)
+{
+ NautilusIconInfo *icon;
+
+ icon = g_object_new (NAUTILUS_TYPE_ICON_INFO, NULL);
+
+ if (pixbuf) {
+ icon->pixbuf = g_object_ref (pixbuf);
+ }
+
+ return icon;
+}
+
+static NautilusIconInfo *
+nautilus_icon_info_new_for_icon_info (GtkIconInfo *icon_info)
+{
+ NautilusIconInfo *icon;
+ GdkPoint *points;
+ gint n_points;
+ const char *filename;
+ char *basename, *p;
+
+ icon = g_object_new (NAUTILUS_TYPE_ICON_INFO, NULL);
+
+ icon->pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+
+ icon->got_embedded_rect = gtk_icon_info_get_embedded_rect (icon_info,
+ &icon->embedded_rect);
+
+ if (gtk_icon_info_get_attach_points (icon_info, &points, &n_points)) {
+ icon->n_attach_points = n_points;
+ icon->attach_points = points;
+ }
+
+ icon->display_name = g_strdup (gtk_icon_info_get_display_name (icon_info));
+
+ filename = gtk_icon_info_get_display_name (icon_info);
+ if (filename != NULL) {
+ basename = g_path_get_basename (filename);
+ p = strrchr (basename, '.');
+ if (p) {
+ *p = 0;
+ }
+ icon->icon_name = basename;
+ }
+
+ return icon;
+}
+
+
+typedef struct {
+ GIcon *icon;
+ int size;
+} LoadableIconKey;
+
+typedef struct {
+ char *filename;
+ int size;
+} ThemedIconKey;
+
+static GHashTable *loadable_icon_cache = NULL;
+static GHashTable *themed_icon_cache = NULL;
+static guint reap_cache_timeout = 0;
+
+#define NSEC_PER_SEC ((guint64)1000000000L)
+
+static guint time_now;
+
+static gboolean
+reap_old_icon (gpointer key,
+ gpointer value,
+ gpointer user_info)
+{
+ NautilusIconInfo *icon = value;
+ gboolean *reapable_icons_left = user_info;
+
+ if (icon->sole_owner) {
+ if (time_now - icon->last_use_time > 30 * NSEC_PER_SEC) {
+ /* This went unused 30 secs ago. reap */
+ return TRUE;
+ } else {
+ /* We can reap this soon */
+ *reapable_icons_left = TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+reap_cache (gpointer data)
+{
+ gboolean reapable_icons_left;
+
+ reapable_icons_left = TRUE;
+
+ time_now = g_thread_gettime ();
+
+ if (loadable_icon_cache) {
+ g_hash_table_foreach_remove (loadable_icon_cache,
+ reap_old_icon,
+ &reapable_icons_left);
+ }
+
+ if (themed_icon_cache) {
+ g_hash_table_foreach_remove (themed_icon_cache,
+ reap_old_icon,
+ &reapable_icons_left);
+ }
+
+ if (reapable_icons_left) {
+ return TRUE;
+ } else {
+ reap_cache_timeout = 0;
+ return FALSE;
+ }
+}
+
+static void
+schedule_reap_cache (void)
+{
+ if (reap_cache_timeout == 0) {
+ reap_cache_timeout = g_timeout_add_seconds_full (0, 5,
+ reap_cache,
+ NULL, NULL);
+ }
+}
+
+void
+nautilus_icon_info_clear_caches (void)
+{
+ if (loadable_icon_cache) {
+ g_hash_table_remove_all (loadable_icon_cache);
+ }
+
+ if (themed_icon_cache) {
+ g_hash_table_remove_all (themed_icon_cache);
+ }
+}
+
+static guint
+loadable_icon_key_hash (LoadableIconKey *key)
+{
+ return g_icon_hash (key->icon) ^ key->size;
+}
+
+static gboolean
+loadable_icon_key_equal (const LoadableIconKey *a,
+ const LoadableIconKey *b)
+{
+ return a->size == b->size &&
+ g_icon_equal (a->icon, b->icon);
+}
+
+static LoadableIconKey *
+loadable_icon_key_new (GIcon *icon, int size)
+{
+ LoadableIconKey *key;
+
+ key = g_slice_new (LoadableIconKey);
+ key->icon = g_object_ref (icon);
+ key->size = size;
+
+ return key;
+}
+
+static void
+loadable_icon_key_free (LoadableIconKey *key)
+{
+ g_object_unref (key->icon);
+ g_slice_free (LoadableIconKey, key);
+}
+
+static guint
+themed_icon_key_hash (ThemedIconKey *key)
+{
+ return g_str_hash (key->filename) ^ key->size;
+}
+
+static gboolean
+themed_icon_key_equal (const ThemedIconKey *a,
+ const ThemedIconKey *b)
+{
+ return a->size == b->size &&
+ g_str_equal (a->filename, b->filename);
+}
+
+static ThemedIconKey *
+themed_icon_key_new (const char *filename, int size)
+{
+ ThemedIconKey *key;
+
+ key = g_slice_new (ThemedIconKey);
+ key->filename = g_strdup (filename);
+ key->size = size;
+
+ return key;
+}
+
+static void
+themed_icon_key_free (ThemedIconKey *key)
+{
+ g_free (key->filename);
+ g_slice_free (ThemedIconKey, key);
+}
+
+NautilusIconInfo *
+nautilus_icon_info_lookup (GIcon *icon,
+ int size)
+{
+ NautilusIconInfo *icon_info;
+ GdkPixbuf *pixbuf;
+
+ if (G_IS_LOADABLE_ICON (icon)) {
+ LoadableIconKey lookup_key;
+ LoadableIconKey *key;
+ GInputStream *stream;
+
+ if (loadable_icon_cache == NULL) {
+ loadable_icon_cache =
+ g_hash_table_new_full ((GHashFunc)loadable_icon_key_hash,
+ (GEqualFunc)loadable_icon_key_equal,
+ (GDestroyNotify) loadable_icon_key_free,
+ (GDestroyNotify) g_object_unref);
+ }
+
+ lookup_key.icon = icon;
+ lookup_key.size = size;
+
+ icon_info = g_hash_table_lookup (loadable_icon_cache, &lookup_key);
+ if (icon_info) {
+ return g_object_ref (icon_info);
+ }
+
+ pixbuf = NULL;
+ stream = g_loadable_icon_load (G_LOADABLE_ICON (icon),
+ size,
+ NULL, NULL, NULL);
+ if (stream) {
+ pixbuf = eel_gdk_pixbuf_load_from_stream (stream);
+
+ /* TODO: resize icon? */
+
+ g_object_unref (stream);
+ }
+
+ icon_info = nautilus_icon_info_new_for_pixbuf (pixbuf);
+
+ key = loadable_icon_key_new (icon, size);
+ g_hash_table_insert (loadable_icon_cache, key, icon_info);
+
+ return g_object_ref (icon_info);
+ } else if (G_IS_THEMED_ICON (icon)) {
+ const char * const *names;
+ ThemedIconKey lookup_key;
+ ThemedIconKey *key;
+ GtkIconTheme *icon_theme;
+ GtkIconInfo *gtkicon_info;
+ const char *filename;
+
+ if (themed_icon_cache == NULL) {
+ themed_icon_cache =
+ g_hash_table_new_full ((GHashFunc)themed_icon_key_hash,
+ (GEqualFunc)themed_icon_key_equal,
+ (GDestroyNotify) themed_icon_key_free,
+ (GDestroyNotify) g_object_unref);
+ }
+
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+
+ icon_theme = gtk_icon_theme_get_default ();
+ gtkicon_info = gtk_icon_theme_choose_icon (icon_theme, (const char **)names, size, 0);
+
+ if (gtkicon_info == NULL) {
+ return nautilus_icon_info_new_for_pixbuf (NULL);
+ }
+
+ filename = gtk_icon_info_get_filename (gtkicon_info);
+
+ lookup_key.filename = (char *)filename;
+ lookup_key.size = size;
+
+ icon_info = g_hash_table_lookup (themed_icon_cache, &lookup_key);
+ if (icon_info) {
+ gtk_icon_info_free (gtkicon_info);
+ return g_object_ref (icon_info);
+ }
+
+ icon_info = nautilus_icon_info_new_for_icon_info (gtkicon_info);
+
+ key = themed_icon_key_new (filename, size);
+ g_hash_table_insert (themed_icon_cache, key, icon_info);
+
+ gtk_icon_info_free (gtkicon_info);
+
+ return g_object_ref (icon_info);
+ }
+ return nautilus_icon_info_new_for_pixbuf (NULL);
+}
+
+NautilusIconInfo *
+nautilus_icon_info_lookup_from_name (const char *name,
+ int size)
+{
+ GIcon *icon;
+ NautilusIconInfo *info;
+
+ icon = g_themed_icon_new (name);
+ info = nautilus_icon_info_lookup (icon, size);
+ g_object_unref (icon);
+ return info;
+}
+
+
+GdkPixbuf *
+nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon)
+{
+ GdkPixbuf *res;
+
+ if (icon->pixbuf == NULL) {
+ res = NULL;
+ } else {
+ res = g_object_ref (icon->pixbuf);
+ icon->sole_owner = FALSE;
+
+ g_object_add_toggle_ref (G_OBJECT (res),
+ pixbuf_toggle_notify,
+ icon);
+ }
+
+ return res;
+}
+
+
+GdkPixbuf *
+nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon)
+{
+ GdkPixbuf *res;
+
+ res = nautilus_icon_info_get_pixbuf_nodefault (icon);
+ if (res == NULL) {
+ res = gdk_pixbuf_new_from_data (nautilus_default_file_icon,
+ GDK_COLORSPACE_RGB,
+ TRUE,
+ 8,
+ nautilus_default_file_icon_width,
+ nautilus_default_file_icon_height,
+ nautilus_default_file_icon_width * 4, /* stride */
+ NULL, /* don't destroy info */
+ NULL);
+ }
+
+ return res;
+}
+
+GdkPixbuf *
+nautilus_icon_info_get_pixbuf_nodefault_at_size (NautilusIconInfo *icon,
+ gsize forced_size)
+{
+ GdkPixbuf *pixbuf, *scaled_pixbuf;
+ int w, h, s;
+ double scale;
+
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault (icon);
+
+ if (pixbuf == NULL)
+ return NULL;
+
+ w = gdk_pixbuf_get_width (pixbuf);
+ h = gdk_pixbuf_get_height (pixbuf);
+ s = MAX (w, h);
+ scale = (double)forced_size / s;
+ scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+ w * scale, h * scale,
+ GDK_INTERP_HYPER);
+ g_object_unref (pixbuf);
+ return scaled_pixbuf;
+}
+
+
+GdkPixbuf *
+nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon,
+ gsize forced_size)
+{
+ GdkPixbuf *pixbuf, *scaled_pixbuf;
+ int w, h, s;
+ double scale;
+
+ pixbuf = nautilus_icon_info_get_pixbuf (icon);
+
+ w = gdk_pixbuf_get_width (pixbuf);
+ h = gdk_pixbuf_get_height (pixbuf);
+ s = MAX (w, h);
+ scale = (double)forced_size / s;
+ scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+ w * scale, h * scale,
+ GDK_INTERP_HYPER);
+ g_object_unref (pixbuf);
+ return scaled_pixbuf;
+}
+
+gboolean
+nautilus_icon_info_get_embedded_rect (NautilusIconInfo *icon,
+ GdkRectangle *rectangle)
+{
+ *rectangle = icon->embedded_rect;
+ return icon->got_embedded_rect;
+}
+
+gboolean
+nautilus_icon_info_get_attach_points (NautilusIconInfo *icon,
+ GdkPoint **points,
+ gint *n_points)
+{
+ *n_points = icon->n_attach_points;
+ *points = icon->attach_points;
+ return icon->n_attach_points != 0;
+}
+
+G_CONST_RETURN char *
+nautilus_icon_info_get_display_name (NautilusIconInfo *icon)
+{
+ return icon->display_name;
+}
+
+G_CONST_RETURN char *
+nautilus_icon_info_get_used_name (NautilusIconInfo *icon)
+{
+ return icon->icon_name;
+}
+
+/* Return nominal icon size for given zoom level.
+ * @zoom_level: zoom level for which to find matching icon size.
+ *
+ * Return value: icon size between NAUTILUS_ICON_SIZE_SMALLEST and
+ * NAUTILUS_ICON_SIZE_LARGEST, inclusive.
+ */
+guint
+nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
+{
+ switch (zoom_level) {
+ case NAUTILUS_ZOOM_LEVEL_SMALLEST:
+ return NAUTILUS_ICON_SIZE_SMALLEST;
+ case NAUTILUS_ZOOM_LEVEL_SMALLER:
+ return NAUTILUS_ICON_SIZE_SMALLER;
+ case NAUTILUS_ZOOM_LEVEL_SMALL:
+ return NAUTILUS_ICON_SIZE_SMALL;
+ case NAUTILUS_ZOOM_LEVEL_STANDARD:
+ return NAUTILUS_ICON_SIZE_STANDARD;
+ case NAUTILUS_ZOOM_LEVEL_LARGE:
+ return NAUTILUS_ICON_SIZE_LARGE;
+ case NAUTILUS_ZOOM_LEVEL_LARGER:
+ return NAUTILUS_ICON_SIZE_LARGER;
+ case NAUTILUS_ZOOM_LEVEL_LARGEST:
+ return NAUTILUS_ICON_SIZE_LARGEST;
+ }
+ g_return_val_if_reached (NAUTILUS_ICON_SIZE_STANDARD);
+}
+
+float
+nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
+{
+ return (float)nautilus_get_icon_size_for_zoom_level (zoom_level) / NAUTILUS_ICON_SIZE_STANDARD;
+}
+
+guint
+nautilus_icon_get_larger_icon_size (guint size)
+{
+ if (size < NAUTILUS_ICON_SIZE_SMALLEST) {
+ return NAUTILUS_ICON_SIZE_SMALLEST;
+ }
+ if (size < NAUTILUS_ICON_SIZE_SMALLER) {
+ return NAUTILUS_ICON_SIZE_SMALLER;
+ }
+ if (size < NAUTILUS_ICON_SIZE_SMALL) {
+ return NAUTILUS_ICON_SIZE_SMALL;
+ }
+ if (size < NAUTILUS_ICON_SIZE_STANDARD) {
+ return NAUTILUS_ICON_SIZE_STANDARD;
+ }
+ if (size < NAUTILUS_ICON_SIZE_LARGE) {
+ return NAUTILUS_ICON_SIZE_LARGE;
+ }
+ if (size < NAUTILUS_ICON_SIZE_LARGER) {
+ return NAUTILUS_ICON_SIZE_LARGER;
+ }
+ return NAUTILUS_ICON_SIZE_LARGEST;
+}
+
+guint
+nautilus_icon_get_smaller_icon_size (guint size)
+{
+ if (size > NAUTILUS_ICON_SIZE_LARGEST) {
+ return NAUTILUS_ICON_SIZE_LARGEST;
+ }
+ if (size > NAUTILUS_ICON_SIZE_LARGER) {
+ return NAUTILUS_ICON_SIZE_LARGER;
+ }
+ if (size > NAUTILUS_ICON_SIZE_LARGE) {
+ return NAUTILUS_ICON_SIZE_LARGE;
+ }
+ if (size > NAUTILUS_ICON_SIZE_STANDARD) {
+ return NAUTILUS_ICON_SIZE_STANDARD;
+ }
+ if (size > NAUTILUS_ICON_SIZE_SMALL) {
+ return NAUTILUS_ICON_SIZE_SMALL;
+ }
+ if (size > NAUTILUS_ICON_SIZE_SMALLER) {
+ return NAUTILUS_ICON_SIZE_SMALLER;
+ }
+ return NAUTILUS_ICON_SIZE_SMALLEST;
+}
+
+gint
+nautilus_get_icon_size_for_stock_size (GtkIconSize size)
+{
+ gint w, h;
+
+ if (gtk_icon_size_lookup (size, &w, &h)) {
+ return MAX (w, h);
+ }
+ return NAUTILUS_ZOOM_LEVEL_STANDARD;
+}
+
+
+char *
+nautilus_icon_get_emblem_icon_by_name (const char *emblem_name)
+{
+ char *name_with_prefix;
+
+ name_with_prefix = g_strconcat (NAUTILUS_EMBLEM_NAME_PREFIX, emblem_name, NULL);
+
+ return name_with_prefix;
+}
+
+guint
+nautilus_icon_get_emblem_size_for_icon_size (guint size)
+{
+ if (size >= 96)
+ return 48;
+ if (size >= 64)
+ return 32;
+ if (size >= 48)
+ return 24;
+ if (size >= 32)
+ return 16;
+
+ return 0; /* no emblems for smaller sizes */
+}
diff --git a/libnautilus-private/nautilus-icon-info.h b/libnautilus-private/nautilus-icon-info.h
new file mode 100644
index 000000000..55cda6c51
--- /dev/null
+++ b/libnautilus-private/nautilus-icon-info.h
@@ -0,0 +1,90 @@
+#ifndef NAUTILUS_ICON_INFO_H
+#define NAUTILUS_ICON_INFO_H
+
+#include <glib-object.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdktypes.h>
+#include <gio/gicon.h>
+#include <gtk/gtkstock.h>
+
+G_BEGIN_DECLS
+
+/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
+typedef enum {
+ NAUTILUS_ZOOM_LEVEL_SMALLEST,
+ NAUTILUS_ZOOM_LEVEL_SMALLER,
+ NAUTILUS_ZOOM_LEVEL_SMALL,
+ NAUTILUS_ZOOM_LEVEL_STANDARD,
+ NAUTILUS_ZOOM_LEVEL_LARGE,
+ NAUTILUS_ZOOM_LEVEL_LARGER,
+ NAUTILUS_ZOOM_LEVEL_LARGEST
+} NautilusZoomLevel;
+
+/* Nominal icon sizes for each Nautilus zoom level.
+ * This scheme assumes that icons are designed to
+ * fit in a square space, though each image needn't
+ * be square. Since individual icons can be stretched,
+ * each icon is not constrained to this nominal size.
+ */
+#define NAUTILUS_ICON_SIZE_SMALLEST 16
+#define NAUTILUS_ICON_SIZE_SMALLER 24
+#define NAUTILUS_ICON_SIZE_SMALL 32
+#define NAUTILUS_ICON_SIZE_STANDARD 48
+#define NAUTILUS_ICON_SIZE_LARGE 72
+#define NAUTILUS_ICON_SIZE_LARGER 96
+#define NAUTILUS_ICON_SIZE_LARGEST 192
+
+/* Maximum size of an icon that the icon factory will ever produce */
+#define NAUTILUS_ICON_MAXIMUM_SIZE 320
+
+typedef struct _NautilusIconInfo NautilusIconInfo;
+typedef struct _NautilusIconInfoClass NautilusIconInfoClass;
+
+
+#define NAUTILUS_TYPE_ICON_INFO (nautilus_icon_info_get_type ())
+#define NAUTILUS_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ICON_INFO, NautilusIconInfo))
+#define NAUTILUS_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ICON_INFO, NautilusIconInfoClass))
+#define NAUTILUS_IS_ICON_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ICON_INFO))
+#define NAUTILUS_IS_ICON_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ICON_INFO))
+#define NAUTILUS_ICON_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NAUTILUS_TYPE_ICON_INFO, NautilusIconInfoClass))
+
+
+GType nautilus_icon_info_get_type (void) G_GNUC_CONST;
+
+NautilusIconInfo * nautilus_icon_info_new_for_pixbuf (GdkPixbuf *pixbuf);
+NautilusIconInfo * nautilus_icon_info_lookup (GIcon *icon,
+ int size);
+NautilusIconInfo * nautilus_icon_info_lookup_from_name (const char *name,
+ int size);
+GdkPixbuf * nautilus_icon_info_get_pixbuf (NautilusIconInfo *icon);
+GdkPixbuf * nautilus_icon_info_get_pixbuf_nodefault (NautilusIconInfo *icon);
+GdkPixbuf * nautilus_icon_info_get_pixbuf_nodefault_at_size (NautilusIconInfo *icon,
+ gsize forced_size);
+GdkPixbuf * nautilus_icon_info_get_pixbuf_at_size (NautilusIconInfo *icon,
+ gsize forced_size);
+gboolean nautilus_icon_info_get_embedded_rect (NautilusIconInfo *icon,
+ GdkRectangle *rectangle);
+gboolean nautilus_icon_info_get_attach_points (NautilusIconInfo *icon,
+ GdkPoint **points,
+ gint *n_points);
+G_CONST_RETURN char *nautilus_icon_info_get_display_name (NautilusIconInfo *icon);
+G_CONST_RETURN char *nautilus_icon_info_get_used_name (NautilusIconInfo *icon);
+
+void nautilus_icon_info_clear_caches (void);
+
+/* Relationship between zoom levels and icons sizes. */
+guint nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
+float nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
+
+guint nautilus_icon_get_larger_icon_size (guint size);
+guint nautilus_icon_get_smaller_icon_size (guint size);
+
+gint nautilus_get_icon_size_for_stock_size (GtkIconSize size);
+char *nautilus_icon_get_emblem_icon_by_name (const char *emblem_name);
+guint nautilus_icon_get_emblem_size_for_icon_size (guint size);
+
+
+G_END_DECLS
+
+#endif /* NAUTILUS_ICON_INFO_H */
+
diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h
index 70cc1c1e7..d125a631f 100644
--- a/libnautilus-private/nautilus-icon-private.h
+++ b/libnautilus-private/nautilus-icon-private.h
@@ -30,7 +30,6 @@
#include <libnautilus-private/nautilus-icon-canvas-item.h>
#include <libnautilus-private/nautilus-icon-container.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
/* An Icon. */
@@ -83,7 +82,7 @@ typedef struct {
guint timer_id;
guint prev_x, prev_y;
- ArtDRect prev_rect;
+ EelDRect prev_rect;
int last_adj_y;
} NautilusIconRubberbandInfo;
diff --git a/libnautilus-private/nautilus-lib-self-check-functions.h b/libnautilus-private/nautilus-lib-self-check-functions.h
index b27db7b8a..7a376ee86 100644
--- a/libnautilus-private/nautilus-lib-self-check-functions.h
+++ b/libnautilus-private/nautilus-lib-self-check-functions.h
@@ -44,7 +44,6 @@ void nautilus_run_lib_self_checks (void);
macro (nautilus_self_check_directory) \
macro (nautilus_self_check_file) \
macro (nautilus_self_check_icon_container) \
- macro (nautilus_self_check_icon_factory) \
/* Add new self-check functions to the list above this line. */
/* Generate prototypes for all the functions. */
diff --git a/libnautilus-private/nautilus-link-desktop-file.c b/libnautilus-private/nautilus-link-desktop-file.c
deleted file mode 100644
index bea0fdec2..000000000
--- a/libnautilus-private/nautilus-link-desktop-file.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-link-desktop-file.c: .desktop link files.
-
- Copyright (C) 2001 Red Hat, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the historicalied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Jonathan Blandford <jrb@redhat.com>
- Alexander Larsson <alexl@redhat.com>
-*/
-
-#include <config.h>
-#include "nautilus-link-desktop-file.h"
-
-#include "nautilus-directory-notify.h"
-#include "nautilus-directory.h"
-#include "nautilus-file-attributes.h"
-#include "nautilus-file-utilities.h"
-#include "nautilus-icon-factory.h"
-#include "nautilus-file.h"
-#include "nautilus-metadata.h"
-#include "nautilus-program-choosing.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
-#include <eel/eel-xml-extensions.h>
-#include <eel/eel-vfs-extensions.h>
-#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libxml/parser.h>
-#include <stdlib.h>
-
-#define NAUTILUS_LINK_GENERIC_TAG "Link"
-#define NAUTILUS_LINK_TRASH_TAG "X-nautilus-trash"
-#define NAUTILUS_LINK_MOUNT_TAG "FSDevice"
-#define NAUTILUS_LINK_HOME_TAG "X-nautilus-home"
-
-static char *
-slurp_key_string (const char *uri,
- const char *keyname,
- gboolean localize)
-{
- GnomeDesktopItem *desktop_file;
- const char *text;
- char *result;
-
- desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
- if (desktop_file == NULL) {
- return NULL;
- }
-
- if (localize) {
- text = gnome_desktop_item_get_localestring (desktop_file, keyname);
- } else {
- text = gnome_desktop_item_get_string (desktop_file, keyname);
- }
-
- result = g_strdup (text);
- gnome_desktop_item_unref (desktop_file);
-
- return result;
-}
-
-gboolean
-nautilus_link_desktop_file_local_create (const char *directory_uri,
- const char *base_name,
- const char *display_name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- int screen,
- gboolean unique_filename)
-{
- char *real_directory_uri;
- char *uri, *contents, *escaped_name;
- GnomeDesktopItem *desktop_item;
- GList dummy_list;
- NautilusFileChangesQueuePosition item;
-
- g_return_val_if_fail (directory_uri != NULL, FALSE);
- g_return_val_if_fail (base_name != NULL, FALSE);
- g_return_val_if_fail (display_name != NULL, FALSE);
- g_return_val_if_fail (target_uri != NULL, FALSE);
-
- if (eel_uri_is_trash (directory_uri) ||
- eel_uri_is_search (directory_uri)) {
- return FALSE;
- }
-
- if (eel_uri_is_desktop (directory_uri)) {
- real_directory_uri = nautilus_get_desktop_directory_uri ();
- } else {
- real_directory_uri = g_strdup (directory_uri);
- }
-
- if (unique_filename) {
- uri = nautilus_ensure_unique_file_name (real_directory_uri,
- base_name, ".desktop");
- if (uri == NULL) {
- g_free (real_directory_uri);
- return FALSE;
- }
- } else {
- escaped_name = gnome_vfs_escape_string (base_name);
- uri = g_strdup_printf ("%s/%s.desktop", real_directory_uri, escaped_name);
- g_free (escaped_name);
- }
-
- g_free (real_directory_uri);
-
- contents = g_strdup_printf ("[Desktop Entry]\n"
- "Encoding=UTF-8\n"
- "Name=%s\n"
- "Type=Link\n"
- "URL=%s\n"
- "%s%s\n",
- display_name,
- target_uri,
- image != NULL ? "Icon=" : "",
- image != NULL ? image : "");
-
- desktop_item = gnome_desktop_item_new_from_string (uri,
- contents,
- strlen (contents),
- 0,
- NULL);
- if (!desktop_item) {
- g_free (contents);
- g_free (uri);
- return FALSE;
- }
-
- if (!gnome_desktop_item_save (desktop_item, uri, TRUE, NULL)) {
- gnome_desktop_item_unref (desktop_item);
- g_free (contents);
- g_free (uri);
- return FALSE;
- }
-
- dummy_list.data = uri;
- dummy_list.next = NULL;
- dummy_list.prev = NULL;
- nautilus_directory_notify_files_added (&dummy_list);
- nautilus_directory_schedule_metadata_remove (&dummy_list);
-
- if (point != NULL) {
- item.uri = uri;
- item.set = TRUE;
- item.point.x = point->x;
- item.point.y = point->y;
- item.screen = screen;
- dummy_list.data = &item;
- dummy_list.next = NULL;
- dummy_list.prev = NULL;
-
- nautilus_directory_schedule_position_set (&dummy_list);
- }
-
- gnome_desktop_item_unref (desktop_item);
- g_free (contents);
- g_free (uri);
- return TRUE;
-}
-
-gboolean
-nautilus_link_desktop_file_local_set_text (const char *uri,
- const char *text)
-{
- GnomeDesktopItem *desktop_file;
- gboolean success;
-
- desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
- if (desktop_file == NULL) {
- return FALSE;
- }
-
- gnome_desktop_item_set_localestring (desktop_file, "Name", text);
- success = gnome_desktop_item_save (desktop_file, NULL, FALSE, NULL);
- gnome_desktop_item_unref (desktop_file);
-
- return success;
-}
-
-char *
-nautilus_link_desktop_file_local_get_text (const char *path)
-{
- return slurp_key_string (path, "Name", TRUE);
-}
-
-char *
-nautilus_link_desktop_file_local_get_additional_text (const char *path)
-{
- /* The comment field of current .desktop files is often bad.
- * It just contains a copy of the name. This is probably because the
- * panel shows the comment field as a tooltip.
- */
- return NULL;
-#ifdef THIS_IS_NOT_USED_RIGHT_NOW
- char *type;
- char *retval;
-
- type = slurp_key_string (path, "Type", FALSE);
- retval = NULL;
- if (type == NULL) {
- return NULL;
- }
-
- if (strcmp (type, "Application") == 0) {
- retval = slurp_key_string (path, "Comment", TRUE);
- }
-
- g_free (type);
-
- return retval;
-#endif
-}
-
-
-static char *
-nautilus_link_desktop_file_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
-{
- const char *launch_string;
- const char *type;
- char *retval;
-
- retval = NULL;
-
- type = gnome_desktop_item_get_string (desktop_file, "Type");
- if (type == NULL) {
- return NULL;
- }
-
- if (strcmp (type, "Application") == 0) {
- launch_string = gnome_desktop_item_get_string (desktop_file, "Exec");
- if (launch_string == NULL) {
- return NULL;
- }
-
- launch_string = gnome_desktop_item_get_location (desktop_file);
- retval = g_strconcat (NAUTILUS_DESKTOP_COMMAND_SPECIFIER, launch_string, NULL);
- } else if (strcmp (type, "URL") == 0) {
- /* Some old broken desktop files use this nonstandard feature, we need handle it though */
- retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "Exec"));
- } else if ((strcmp (type, NAUTILUS_LINK_GENERIC_TAG) == 0) ||
- (strcmp (type, NAUTILUS_LINK_MOUNT_TAG) == 0) ||
- (strcmp (type, NAUTILUS_LINK_TRASH_TAG) == 0) ||
- (strcmp (type, NAUTILUS_LINK_HOME_TAG) == 0)) {
- retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "URL"));
- }
-
- return retval;
-}
-
-static char *
-nautilus_link_desktop_file_get_link_name_from_desktop (GnomeDesktopItem *desktop_file)
-{
- return g_strdup (gnome_desktop_item_get_localestring (desktop_file, "Name"));
-}
-
-static char *
-nautilus_link_desktop_file_get_link_icon_from_desktop (GnomeDesktopItem *desktop_file)
-{
- char *icon_uri;
- const char *icon;
- GnomeDesktopItemType desktop_type;
-
- icon_uri = g_strdup (gnome_desktop_item_get_string (desktop_file, "X-Nautilus-Icon"));
- if (icon_uri != NULL) {
- return icon_uri;
- }
-
- icon = gnome_desktop_item_get_string (desktop_file, GNOME_DESKTOP_ITEM_ICON);
- if (icon != NULL) {
- return g_strdup (icon);
- }
-
- desktop_type = gnome_desktop_item_get_entry_type (desktop_file);
- switch (desktop_type) {
- case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
- return g_strdup ("gnome-fs-executable");
-
- case GNOME_DESKTOP_ITEM_TYPE_LINK:
- return g_strdup ("gnome-dev-symlink");
-
- case GNOME_DESKTOP_ITEM_TYPE_FSDEVICE:
- return g_strdup ("gnome-dev-harddisk");
-
- case GNOME_DESKTOP_ITEM_TYPE_DIRECTORY:
- return g_strdup ("gnome-fs-directory");
-
- case GNOME_DESKTOP_ITEM_TYPE_SERVICE:
- case GNOME_DESKTOP_ITEM_TYPE_SERVICE_TYPE:
- return g_strdup ("gnome-fs-web");
-
- default:
- return g_strdup ("gnome-fs-regular");
- }
-
- g_assert_not_reached ();
- return NULL;
-}
-
-char *
-nautilus_link_desktop_file_local_get_link_uri (const char *uri)
-{
- GnomeDesktopItem *desktop_file;
- char *retval;
-
- desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
- if (desktop_file == NULL) {
- return NULL;
- }
-
- retval = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
- gnome_desktop_item_unref (desktop_file);
-
- return retval;
-}
-
-void
-nautilus_link_desktop_file_get_link_info_given_file_contents (const char *file_contents,
- int link_file_size,
- char **uri,
- char **name,
- char **icon,
- gulong *drive_id,
- gulong *volume_id)
-{
- GnomeDesktopItem *desktop_file;
- const char *id;
-
- desktop_file = gnome_desktop_item_new_from_string (NULL, file_contents, link_file_size, 0, NULL);
- if (desktop_file == NULL) {
- return;
- }
-
- *uri = nautilus_link_desktop_file_get_link_uri_from_desktop (desktop_file);
- *name = nautilus_link_desktop_file_get_link_name_from_desktop (desktop_file);
- *icon = nautilus_link_desktop_file_get_link_icon_from_desktop (desktop_file);
-
- id = gnome_desktop_item_get_string (desktop_file, "X-Gnome-Volume");
- if (id != NULL) {
- *volume_id = atol (id);
- }
-
- id = gnome_desktop_item_get_string (desktop_file, "X-Gnome-Drive");
- if (id != NULL) {
- *drive_id = atol (id);
- }
-
- gnome_desktop_item_unref (desktop_file);
-}
-
-
-void
-nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
- const char *dest_uri,
- const GdkPoint *position,
- int screen)
-{
- GList dummy_list;
- NautilusFileChangesQueuePosition item;
- GnomeDesktopItem *new_entry;
- char *file_uri;
- const char *name;
-
- name = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_NAME);
- file_uri = g_strdup_printf ("%s/%s.desktop", dest_uri, name);
-
- new_entry = gnome_desktop_item_copy (entry);
- gnome_desktop_item_save (new_entry, file_uri, TRUE, NULL);
-
- dummy_list.data = file_uri;
- dummy_list.next = NULL;
- dummy_list.prev = NULL;
- nautilus_directory_notify_files_added (&dummy_list);
- nautilus_directory_schedule_metadata_remove (&dummy_list);
-
- if (position != NULL) {
- item.uri = file_uri;
- item.set = TRUE;
- item.point.x = position->x;
- item.point.y = position->y;
- item.screen = screen;
-
- dummy_list.data = &item;
- dummy_list.next = NULL;
- dummy_list.prev = NULL;
-
- nautilus_directory_schedule_position_set (&dummy_list);
- }
- gnome_desktop_item_unref (new_entry);
-}
diff --git a/libnautilus-private/nautilus-link-desktop-file.h b/libnautilus-private/nautilus-link-desktop-file.h
deleted file mode 100644
index a0ab05700..000000000
--- a/libnautilus-private/nautilus-link-desktop-file.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-link-desktop-file.h: .
-
- Copyright (C) 2001 Red Hat, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Jonathan Blandford <jrb@redhat.com>
-*/
-
-#ifndef NAUTILUS_LINK_DESKTOP_FILE_H
-#define NAUTILUS_LINK_DESKTOP_FILE_H
-
-#include <libnautilus-private/nautilus-link.h>
-
-gboolean nautilus_link_desktop_file_local_create (const char *directory_uri,
- const char *base_name,
- const char *display_name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- int screen,
- gboolean unique_filename);
-gboolean nautilus_link_desktop_file_local_set_text (const char *uri,
- const char *text);
-char * nautilus_link_desktop_file_local_get_text (const char *uri);
-char * nautilus_link_desktop_file_local_get_additional_text (const char *uri);
-char * nautilus_link_desktop_file_local_get_link_uri (const char *uri);
-void nautilus_link_desktop_file_get_link_info_given_file_contents (const char *file_contents,
- int link_file_size,
- char **uri,
- char **name,
- char **icon,
- gulong *drive_id,
- gulong *volume_id);
-void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
- const char *dest_uri,
- const GdkPoint *position,
- int screen);
-
-#endif /* NAUTILUS_LINK_DESKTOP_FILE_H */
diff --git a/libnautilus-private/nautilus-link.c b/libnautilus-private/nautilus-link.c
index 70f31b39e..ccf6f9d89 100644
--- a/libnautilus-private/nautilus-link.c
+++ b/libnautilus-private/nautilus-link.c
@@ -1,8 +1,8 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
- nautilus-link.c: xml-based link files.
+ nautilus-link.c: .desktop link files.
- Copyright (C) 1999, 2000, 2001 Eazel, Inc.
+ Copyright (C) 2001 Red Hat, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -10,7 +10,7 @@
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
+ but WITHOUT ANY WARRANTY; without even the historicalied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
@@ -19,39 +19,30 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- Author: Andy Hertzfeld <andy@eazel.com>
+ Authors: Jonathan Blandford <jrb@redhat.com>
+ Alexander Larsson <alexl@redhat.com>
*/
#include <config.h>
#include "nautilus-link.h"
-#include "nautilus-link-desktop-file.h"
#include "nautilus-directory-notify.h"
#include "nautilus-directory.h"
-#include "nautilus-file-attributes.h"
-#include "nautilus-file.h"
#include "nautilus-file-utilities.h"
-#include "nautilus-global-preferences.h"
-#include "nautilus-metadata.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
+#include "nautilus-file.h"
+#include "nautilus-program-choosing.h"
#include <eel/eel-vfs-extensions.h>
-#include <eel/eel-xml-extensions.h>
-#include <libxml/parser.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
+#include <gio/gfile.h>
+#include <gio/gfileinfo.h>
+#include <gio/gcontenttype.h>
#include <stdlib.h>
+#include <string.h>
-/* NOTE: This is pretty ugly.
- * We once supported another type of link, "historical" links, which were xml files.
- * I've now removed that code, but that makes this file sort of unnecessary, and we
- * could clean up the code a lot since we know we're dealing with desktop files.
- */
+#define NAUTILUS_LINK_GENERIC_TAG "Link"
+#define NAUTILUS_LINK_TRASH_TAG "X-nautilus-trash"
+#define NAUTILUS_LINK_MOUNT_TAG "FSDevice"
+#define NAUTILUS_LINK_HOME_TAG "X-nautilus-home"
static gboolean
is_link_mime_type (const char *mime_type)
@@ -61,37 +52,36 @@ is_link_mime_type (const char *mime_type)
g_ascii_strcasecmp (mime_type, "application/x-desktop") == 0)) {
return TRUE;
}
-
+
return FALSE;
}
static gboolean
-is_local_file_a_link (const char *uri, GnomeVFSFileInfo *opt_info)
+is_local_file_a_link (const char *uri)
{
gboolean link;
- GnomeVFSResult result;
- GnomeVFSFileInfo *info;
-
- if (!(info = opt_info)) {
- info = gnome_vfs_file_info_new ();
-
- result = gnome_vfs_get_file_info (uri, info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- if (result != GNOME_VFS_OK) {
- gnome_vfs_file_info_unref (info);
- info = NULL;
- }
- }
+ GFile *file;
+ GFileInfo *info;
+ GError *error;
- if (info && info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) {
- link = is_link_mime_type (info->mime_type);
- } else {
- link = FALSE;
+ error = NULL;
+ link = FALSE;
+
+ file = g_file_new_for_uri (uri);
+
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE,
+ 0, NULL, &error);
+ if (info) {
+ link = is_link_mime_type (g_file_info_get_content_type (info));
+ g_object_unref (info);
+ }
+ else {
+ g_warning ("Error getting info: %s\n", error->message);
+ g_error_free (error);
}
- if (!opt_info && info)
- gnome_vfs_file_info_unref (info);
+ g_object_unref (file);
return link;
}
@@ -99,74 +89,380 @@ is_local_file_a_link (const char *uri, GnomeVFSFileInfo *opt_info)
static gboolean
is_link_data (const char *file_contents, int file_size)
{
- return is_link_mime_type
- (gnome_vfs_get_mime_type_for_data (file_contents, file_size));
+ char *mimetype;
+ gboolean res;
+
+ mimetype = g_content_type_guess (NULL, file_contents, file_size, NULL);
+ res = is_link_mime_type (mimetype);
+ g_free (mimetype);
+ return res;
+}
+
+static char *
+slurp_key_string (const char *uri,
+ const char *keyname,
+ gboolean localize)
+{
+ GnomeDesktopItem *desktop_file;
+ const char *text;
+ char *result;
+
+ desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
+ if (desktop_file == NULL) {
+ return NULL;
+ }
+
+ if (localize) {
+ text = gnome_desktop_item_get_localestring (desktop_file, keyname);
+ } else {
+ text = gnome_desktop_item_get_string (desktop_file, keyname);
+ }
+
+ result = g_strdup (text);
+ gnome_desktop_item_unref (desktop_file);
+
+ return result;
}
gboolean
-nautilus_link_local_create (const char *directory_uri,
- const char *file_name,
- const char *display_name,
- const char *image,
- const char *target_uri,
+nautilus_link_local_create (const char *directory_uri,
+ const char *base_name,
+ const char *display_name,
+ const char *image,
+ const char *target_uri,
const GdkPoint *point,
- int screen,
- gboolean unique_filename)
+ int screen,
+ gboolean unique_filename)
+{
+ char *real_directory_uri;
+ char *uri, *contents;
+ GnomeDesktopItem *desktop_item;
+ GList dummy_list;
+ NautilusFileChangesQueuePosition item;
+
+ g_return_val_if_fail (directory_uri != NULL, FALSE);
+ g_return_val_if_fail (base_name != NULL, FALSE);
+ g_return_val_if_fail (display_name != NULL, FALSE);
+ g_return_val_if_fail (target_uri != NULL, FALSE);
+
+ if (eel_uri_is_trash (directory_uri) ||
+ eel_uri_is_search (directory_uri)) {
+ return FALSE;
+ }
+
+ if (eel_uri_is_desktop (directory_uri)) {
+ real_directory_uri = nautilus_get_desktop_directory_uri ();
+ } else {
+ real_directory_uri = g_strdup (directory_uri);
+ }
+
+ if (unique_filename) {
+ uri = nautilus_ensure_unique_file_name (real_directory_uri,
+ base_name, ".desktop");
+ if (uri == NULL) {
+ g_free (real_directory_uri);
+ return FALSE;
+ }
+ } else {
+ char *link_name;
+ GFile *dir, *link;
+
+ link_name = g_strdup_printf ("%s.desktop", base_name);
+
+ /* replace '/' with '-', just in case */
+ g_strdelimit (link_name, "/", '-');
+
+ dir = g_file_new_for_uri (directory_uri);
+ link = g_file_get_child (dir, link_name);
+
+ uri = g_file_get_uri (link);
+
+ g_free (link_name);
+ g_object_unref (dir);
+ g_object_unref (link);
+ }
+
+ g_free (real_directory_uri);
+
+ contents = g_strdup_printf ("[Desktop Entry]\n"
+ "Encoding=UTF-8\n"
+ "Name=%s\n"
+ "Type=Link\n"
+ "URL=%s\n"
+ "%s%s\n",
+ display_name,
+ target_uri,
+ image != NULL ? "Icon=" : "",
+ image != NULL ? image : "");
+
+ desktop_item = gnome_desktop_item_new_from_string (uri,
+ contents,
+ strlen (contents),
+ 0,
+ NULL);
+ if (!desktop_item) {
+ g_free (contents);
+ g_free (uri);
+ return FALSE;
+ }
+
+ if (!gnome_desktop_item_save (desktop_item, uri, TRUE, NULL)) {
+ gnome_desktop_item_unref (desktop_item);
+ g_free (contents);
+ g_free (uri);
+ return FALSE;
+ }
+
+ dummy_list.data = uri;
+ dummy_list.next = NULL;
+ dummy_list.prev = NULL;
+ nautilus_directory_notify_files_added_by_uri (&dummy_list);
+ nautilus_directory_schedule_metadata_remove_by_uri (&dummy_list);
+
+ if (point != NULL) {
+ item.location = g_file_new_for_uri (uri);
+ item.set = TRUE;
+ item.point.x = point->x;
+ item.point.y = point->y;
+ item.screen = screen;
+ dummy_list.data = &item;
+ dummy_list.next = NULL;
+ dummy_list.prev = NULL;
+
+ nautilus_directory_schedule_position_set (&dummy_list);
+ g_object_unref (item.location);
+ }
+
+ gnome_desktop_item_unref (desktop_item);
+ g_free (contents);
+ g_free (uri);
+ return TRUE;
+}
+
+gboolean
+nautilus_link_local_set_text (const char *uri,
+ const char *text)
{
- return nautilus_link_desktop_file_local_create (directory_uri,
- file_name,
- display_name, image,
- target_uri,
- point, screen,
- unique_filename);
+ GnomeDesktopItem *desktop_file;
+ gboolean success;
+
+ desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
+ if (desktop_file == NULL) {
+ return FALSE;
+ }
+
+ gnome_desktop_item_set_localestring (desktop_file, "Name", text);
+ success = gnome_desktop_item_save (desktop_file, NULL, FALSE, NULL);
+ gnome_desktop_item_unref (desktop_file);
+
+ return success;
}
-/* returns additional text to display under the name, NULL if none */
char *
-nautilus_link_local_get_additional_text (const char *uri)
+nautilus_link_local_get_text (const char *path)
{
- if (!is_local_file_a_link (uri, NULL)) {
+ return slurp_key_string (path, "Name", TRUE);
+}
+
+char *
+nautilus_link_local_get_additional_text (const char *path)
+{
+ /* The comment field of current .desktop files is often bad.
+ * It just contains a copy of the name. This is probably because the
+ * panel shows the comment field as a tooltip.
+ */
+ return NULL;
+#ifdef THIS_IS_NOT_USED_RIGHT_NOW
+ char *type;
+ char *retval;
+
+ if (!is_local_file_a_link (uri)) {
+ return NULL;
+ }
+
+ type = slurp_key_string (path, "Type", FALSE);
+ retval = NULL;
+ if (type == NULL) {
return NULL;
}
+
+ if (strcmp (type, "Application") == 0) {
+ retval = slurp_key_string (path, "Comment", TRUE);
+ }
- return nautilus_link_desktop_file_local_get_additional_text (uri);
+ g_free (type);
+
+ return retval;
+#endif
+}
+
+static char *
+nautilus_link_get_link_uri_from_desktop (GnomeDesktopItem *desktop_file)
+{
+ const char *launch_string;
+ const char *type;
+ char *retval;
+
+ retval = NULL;
+
+ type = gnome_desktop_item_get_string (desktop_file, "Type");
+ if (type == NULL) {
+ return NULL;
+ }
+
+ if (strcmp (type, "Application") == 0) {
+ launch_string = gnome_desktop_item_get_string (desktop_file, "Exec");
+ if (launch_string == NULL) {
+ return NULL;
+ }
+
+ launch_string = gnome_desktop_item_get_location (desktop_file);
+ retval = g_strconcat (NAUTILUS_DESKTOP_COMMAND_SPECIFIER, launch_string, NULL);
+ } else if (strcmp (type, "URL") == 0) {
+ /* Some old broken desktop files use this nonstandard feature, we need handle it though */
+ retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "Exec"));
+ } else if ((strcmp (type, NAUTILUS_LINK_GENERIC_TAG) == 0) ||
+ (strcmp (type, NAUTILUS_LINK_MOUNT_TAG) == 0) ||
+ (strcmp (type, NAUTILUS_LINK_TRASH_TAG) == 0) ||
+ (strcmp (type, NAUTILUS_LINK_HOME_TAG) == 0)) {
+ retval = g_strdup (gnome_desktop_item_get_string (desktop_file, "URL"));
+ }
+
+ return retval;
+}
+
+static char *
+nautilus_link_get_link_name_from_desktop (GnomeDesktopItem *desktop_file)
+{
+ return g_strdup (gnome_desktop_item_get_localestring (desktop_file, "Name"));
+}
+
+static char *
+nautilus_link_get_link_icon_from_desktop (GnomeDesktopItem *desktop_file)
+{
+ char *icon_uri;
+ const char *icon;
+ GnomeDesktopItemType desktop_type;
+
+ icon_uri = g_strdup (gnome_desktop_item_get_string (desktop_file, "X-Nautilus-Icon"));
+ if (icon_uri != NULL) {
+ return icon_uri;
+ }
+
+ icon = gnome_desktop_item_get_string (desktop_file, GNOME_DESKTOP_ITEM_ICON);
+ if (icon != NULL) {
+ return g_strdup (icon);
+ }
+
+ desktop_type = gnome_desktop_item_get_entry_type (desktop_file);
+ switch (desktop_type) {
+ case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
+ return g_strdup ("gnome-fs-executable");
+
+ case GNOME_DESKTOP_ITEM_TYPE_LINK:
+ return g_strdup ("gnome-dev-symlink");
+
+ case GNOME_DESKTOP_ITEM_TYPE_FSDEVICE:
+ return g_strdup ("gnome-dev-harddisk");
+
+ case GNOME_DESKTOP_ITEM_TYPE_DIRECTORY:
+ return g_strdup ("gnome-fs-directory");
+
+ case GNOME_DESKTOP_ITEM_TYPE_SERVICE:
+ case GNOME_DESKTOP_ITEM_TYPE_SERVICE_TYPE:
+ return g_strdup ("gnome-fs-web");
+
+ default:
+ return g_strdup ("gnome-fs-regular");
+ }
+
+ g_assert_not_reached ();
+ return NULL;
}
-/* Returns the link uri associated with a link file. */
char *
nautilus_link_local_get_link_uri (const char *uri)
{
- if (!is_local_file_a_link (uri, NULL)) {
+ GnomeDesktopItem *desktop_file;
+ char *retval;
+
+ if (!is_local_file_a_link (uri)) {
+ return NULL;
+ }
+
+ desktop_file = gnome_desktop_item_new_from_uri (uri, 0, NULL);
+ if (desktop_file == NULL) {
return NULL;
}
- return nautilus_link_desktop_file_local_get_link_uri (uri);
+
+ retval = nautilus_link_get_link_uri_from_desktop (desktop_file);
+ gnome_desktop_item_unref (desktop_file);
+
+ return retval;
}
void
-nautilus_link_get_link_info_given_file_contents (const char *file_contents,
- int link_file_size,
- char **uri,
- char **name,
- char **icon,
- gulong *drive_id,
- gulong *volume_id)
+nautilus_link_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon)
{
- *uri = NULL;
- *name = NULL;
- *icon = NULL;
- *drive_id = 0;
- *volume_id = 0;
-
- if (is_link_data (file_contents, link_file_size)) {
- nautilus_link_desktop_file_get_link_info_given_file_contents (file_contents, link_file_size, uri, name, icon, drive_id, volume_id);
+ GnomeDesktopItem *desktop_file;
+
+ if (!is_link_data (file_contents, link_file_size)) {
+ return;
}
+
+ desktop_file = gnome_desktop_item_new_from_string (NULL, file_contents, link_file_size, 0, NULL);
+ if (desktop_file == NULL) {
+ return;
+ }
+
+ *uri = nautilus_link_get_link_uri_from_desktop (desktop_file);
+ *name = nautilus_link_get_link_name_from_desktop (desktop_file);
+ *icon = nautilus_link_get_link_icon_from_desktop (desktop_file);
+
+ gnome_desktop_item_unref (desktop_file);
}
void
-nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *item,
- const char *dest_uri,
- const GdkPoint *position,
- int screen)
+nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *entry,
+ const char *dest_uri,
+ const GdkPoint *position,
+ int screen)
{
- nautilus_link_desktop_file_local_create_from_gnome_entry (item, dest_uri, position, screen);
+ GList dummy_list;
+ NautilusFileChangesQueuePosition item;
+ GnomeDesktopItem *new_entry;
+ char *file_uri;
+ const char *name;
+
+ name = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_NAME);
+ file_uri = g_strdup_printf ("%s/%s.desktop", dest_uri, name);
+
+ new_entry = gnome_desktop_item_copy (entry);
+ gnome_desktop_item_save (new_entry, file_uri, TRUE, NULL);
+
+ dummy_list.data = file_uri;
+ dummy_list.next = NULL;
+ dummy_list.prev = NULL;
+ nautilus_directory_notify_files_added_by_uri (&dummy_list);
+ nautilus_directory_schedule_metadata_remove_by_uri (&dummy_list);
+
+ if (position != NULL) {
+ item.location = g_file_new_for_uri (file_uri);
+ item.set = TRUE;
+ item.point.x = position->x;
+ item.point.y = position->y;
+ item.screen = screen;
+
+ dummy_list.data = &item;
+ dummy_list.next = NULL;
+ dummy_list.prev = NULL;
+
+ nautilus_directory_schedule_position_set (&dummy_list);
+ g_object_unref (item.location);
+ }
+ gnome_desktop_item_unref (new_entry);
}
diff --git a/libnautilus-private/nautilus-link.h b/libnautilus-private/nautilus-link.h
index c825ce3b9..5c855d568 100644
--- a/libnautilus-private/nautilus-link.h
+++ b/libnautilus-private/nautilus-link.h
@@ -1,9 +1,8 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
- nautilus-link.h: xml-based link files that control their appearance
- and behavior.
+ nautilus-link.h: .
- Copyright (C) 2000 Eazel, Inc.
+ Copyright (C) 2001 Red Hat, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -20,7 +19,7 @@
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
- Authors: Andy Hertzfeld <andy@eazel.com>
+ Authors: Jonathan Blandford <jrb@redhat.com>
*/
#ifndef NAUTILUS_LINK_H
@@ -28,44 +27,28 @@
#include <gdk/gdktypes.h>
#include <libgnome/gnome-desktop-item.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-/* Create a new link file. Takes a path, works locally, and uses sync. I/O.
- * Returns TRUE if it succeeds, FALSE if it fails.
- */
-gboolean nautilus_link_local_create (const char *directory_uri,
- const char *file_name,
- const char *display_name,
- const char *image,
- const char *target_uri,
- const GdkPoint *point,
- int screen,
- gboolean unique_filename);
-
-/* Returns additional text to display under the name, NULL if
- * none. Despite the fact that it takes a URI parameter, works only if
- * the file is local and does sync. I/O.
- */
-char * nautilus_link_local_get_additional_text (const char *uri);
-
-
-
-/* Returns the link uri associated with a link file. The first version
- * works only if the file is local and does sync. I/O, despite the
- * fact that it takes a URI parameter. The second version takes the
- * contents of a file already in memory.
- */
-char * nautilus_link_local_get_link_uri (const char *uri);
-void nautilus_link_get_link_info_given_file_contents (const char *file_contents,
- int link_file_size,
- char **uri,
- char **name,
- char **icon,
- gulong *drive_id,
- gulong *volume_id);
-void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *item,
- const char *dest_uri,
- const GdkPoint *position,
- int screen);
+gboolean nautilus_link_local_create (const char *directory_uri,
+ const char *base_name,
+ const char *display_name,
+ const char *image,
+ const char *target_uri,
+ const GdkPoint *point,
+ int screen,
+ gboolean unique_filename);
+gboolean nautilus_link_local_set_text (const char *uri,
+ const char *text);
+char * nautilus_link_local_get_text (const char *uri);
+char * nautilus_link_local_get_additional_text (const char *uri);
+char * nautilus_link_local_get_link_uri (const char *uri);
+void nautilus_link_get_link_info_given_file_contents (const char *file_contents,
+ int link_file_size,
+ char **uri,
+ char **name,
+ char **icon);
+void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *entry,
+ const char *dest_uri,
+ const GdkPoint *position,
+ int screen);
#endif /* NAUTILUS_LINK_H */
diff --git a/libnautilus-private/nautilus-merged-directory.c b/libnautilus-private/nautilus-merged-directory.c
index 80016772a..8b4667b99 100644
--- a/libnautilus-private/nautilus-merged-directory.c
+++ b/libnautilus-private/nautilus-merged-directory.c
@@ -559,7 +559,7 @@ real_directory_notify_files_removed (NautilusDirectory *real_directory)
}
if (files) {
- nautilus_directory_notify_files_removed (files);
+ nautilus_directory_notify_files_removed_by_uri (files);
}
eel_g_list_free_deep (files);
diff --git a/libnautilus-private/nautilus-metafile.c b/libnautilus-private/nautilus-metafile.c
index c1e2e82e3..1d445882a 100644
--- a/libnautilus-private/nautilus-metafile.c
+++ b/libnautilus-private/nautilus-metafile.c
@@ -36,12 +36,9 @@
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-xml-extensions.h>
+#include <glib/gurifuncs.h>
#include <libxml/parser.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
@@ -110,14 +107,13 @@ BONOBO_CLASS_BOILERPLATE_FULL (NautilusMetafile, nautilus_metafile,
BonoboObject, BONOBO_OBJECT_TYPE)
typedef struct MetafileReadState {
- EelReadFileHandle *handle;
- GnomeVFSAsyncHandle *get_file_info_handle;
+ NautilusMetafile *metafile;
+ GCancellable *cancellable;
} MetafileReadState;
typedef struct MetafileWriteState {
- GnomeVFSAsyncHandle *handle;
xmlChar *buffer;
- GnomeVFSFileSize size;
+ goffset size;
gboolean write_again;
} MetafileWriteState;
@@ -137,7 +133,6 @@ struct NautilusMetafileDetails {
char *private_uri;
char *directory_uri;
- GnomeVFSURI *directory_vfs_uri;
};
static GHashTable *metafiles;
@@ -162,9 +157,6 @@ finalize (GObject *object)
async_read_cancel (metafile);
g_assert (metafile->details->read_state == NULL);
- if (metafile->details->directory_vfs_uri != NULL) {
- gnome_vfs_uri_unref (metafile->details->directory_vfs_uri);
- }
g_hash_table_remove (metafiles, metafile->details->directory_uri);
@@ -182,6 +174,43 @@ finalize (GObject *object)
}
static char *
+escape_slashes (const char *str)
+{
+ int n_reserved;
+ const char *p;
+ char *escaped, *e;
+
+ n_reserved = 0;
+ for (p = str; *p != 0; p++) {
+ if (*p == '%' || *p == '/') {
+ n_reserved++;
+ }
+ }
+
+ escaped = g_malloc (strlen (str) + 2*n_reserved + 1);
+
+ e = escaped;
+
+ for (p = str; *p != 0; p++) {
+ if (*p == '%') {
+ *e++ = '%';
+ *e++ = '2';
+ *e++ = '5';
+ } else if (*p == '/') {
+ *e++ = '%';
+ *e++ = '2';
+ *e++ = 'f';
+ } else {
+ *e++ = *p;
+ }
+ }
+ *e = 0;
+
+ return escaped;
+}
+
+
+static char *
construct_private_metafile_uri (const char *uri)
{
char *user_directory, *metafiles_directory;
@@ -195,7 +224,7 @@ construct_private_metafile_uri (const char *uri)
mkdir (metafiles_directory, 0700);
/* Construct a file name from the URI. */
- escaped_uri = gnome_vfs_escape_slashes (uri);
+ escaped_uri = escape_slashes (uri);
file_name = g_strconcat (escaped_uri, ".xml", NULL);
g_free (escaped_uri);
@@ -203,7 +232,7 @@ construct_private_metafile_uri (const char *uri)
alternate_path = g_build_filename (metafiles_directory, file_name, NULL);
g_free (metafiles_directory);
g_free (file_name);
- alternate_uri = gnome_vfs_get_uri_from_local_path (alternate_path);
+ alternate_uri = g_filename_to_uri (alternate_path, NULL, NULL);
g_free (alternate_path);
return alternate_uri;
@@ -220,11 +249,6 @@ nautilus_metafile_set_directory_uri (NautilusMetafile *metafile,
g_free (metafile->details->directory_uri);
metafile->details->directory_uri = g_strdup (directory_uri);
- if (metafile->details->directory_vfs_uri != NULL) {
- gnome_vfs_uri_unref (metafile->details->directory_vfs_uri);
- }
- metafile->details->directory_vfs_uri = gnome_vfs_uri_new (directory_uri);
-
g_free (metafile->details->private_uri);
metafile->details->private_uri
= construct_private_metafile_uri (directory_uri);
@@ -247,6 +271,7 @@ nautilus_metafile_get (const char *directory_uri)
{
NautilusMetafile *metafile;
char *canonical_uri;
+ GFile *file;
g_return_val_if_fail (directory_uri != NULL, NULL);
@@ -259,8 +284,11 @@ nautilus_metafile_get (const char *directory_uri)
metafiles = eel_g_hash_table_new_free_at_exit
(g_str_hash, g_str_equal, __FILE__ ": metafiles");
}
-
- canonical_uri = nautilus_directory_make_uri_canonical (directory_uri);
+
+
+ file = g_file_new_for_uri (directory_uri);
+ canonical_uri = g_file_get_uri (file);
+ g_object_unref (file);
metafile = g_hash_table_lookup (metafiles, canonical_uri);
@@ -992,6 +1020,7 @@ get_file_node (NautilusMetafile *metafile,
{
GHashTable *hash;
xmlNode *root, *node;
+ char *escaped_file_name;
g_assert (NAUTILUS_IS_METAFILE (metafile));
@@ -1004,7 +1033,9 @@ get_file_node (NautilusMetafile *metafile,
if (create) {
root = create_metafile_root (metafile);
node = xmlNewChild (root, NULL, "file", NULL);
- xmlSetProp (node, "name", file_name);
+ escaped_file_name = g_uri_escape_string (file_name, NULL, 0);
+ xmlSetProp (node, "name", escaped_file_name);
+ g_free (escaped_file_name);
g_hash_table_insert (hash, xmlMemStrdup (file_name), node);
return node;
}
@@ -1523,10 +1554,16 @@ static char *
metafile_get_file_uri (NautilusMetafile *metafile,
const char *file_name)
{
+ char *escaped_file_name, *uri;
+
g_return_val_if_fail (NAUTILUS_IS_METAFILE (metafile), NULL);
g_return_val_if_fail (file_name != NULL, NULL);
-
- return g_build_filename (metafile->details->directory_uri, file_name, NULL);
+
+ escaped_file_name = g_uri_escape_string (file_name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
+
+ uri = g_build_filename (metafile->details->directory_uri, escaped_file_name, NULL);
+ g_free (escaped_file_name);
+ return uri;
}
static void
@@ -1539,6 +1576,7 @@ rename_file_metadata (NautilusMetafile *metafile,
xmlNode *file_node;
GHashTable *hash;
char *old_file_uri, *new_file_uri;
+ char *escaped;
g_return_if_fail (NAUTILUS_IS_METAFILE (metafile));
g_return_if_fail (old_file_name != NULL);
@@ -1559,7 +1597,9 @@ rename_file_metadata (NautilusMetafile *metafile,
xmlFree (key);
g_hash_table_insert (hash,
xmlMemStrdup (new_file_name), value);
- xmlSetProp (file_node, "name", new_file_name);
+ escaped = g_uri_escape_string (new_file_name, NULL, FALSE);
+ xmlSetProp (file_node, "name", escaped);
+ g_free (escaped);
directory_request_write_metafile (metafile);
}
} else {
@@ -1667,6 +1707,7 @@ real_copy_file_metadata (NautilusMetafile *source_metafile,
{
xmlNodePtr source_node, node, root;
GHashTable *hash, *changes;
+ char *escaped;
real_remove_file_metadata (destination_metafile, destination_file_name);
g_assert (get_file_node (destination_metafile, destination_file_name, FALSE) == NULL);
@@ -1676,7 +1717,9 @@ real_copy_file_metadata (NautilusMetafile *source_metafile,
node = xmlCopyNode (source_node, TRUE);
root = create_metafile_root (destination_metafile);
xmlAddChild (root, node);
- xmlSetProp (node, "name", destination_file_name);
+ escaped = g_uri_escape_string (destination_file_name, NULL, FALSE);
+ xmlSetProp (node, "name", escaped);
+ g_free (escaped);
set_file_node_timestamp (node);
g_hash_table_insert (destination_metafile->details->node_hash,
xmlMemStrdup (destination_file_name), node);
@@ -1803,6 +1846,7 @@ set_metafile_contents (NautilusMetafile *metafile,
GHashTable *hash;
xmlNodePtr node;
xmlChar *name;
+ char *unescaped_name;
g_return_if_fail (NAUTILUS_IS_METAFILE (metafile));
g_return_if_fail (metafile->details->xml == NULL);
@@ -1819,11 +1863,13 @@ set_metafile_contents (NautilusMetafile *metafile,
node != NULL; node = node->next) {
if (strcmp (node->name, "file") == 0) {
name = xmlGetProp (node, "name");
- if (g_hash_table_lookup (hash, name) != NULL) {
+ unescaped_name = g_uri_unescape_string (name, "/");
+ if (unescaped_name == NULL ||
+ g_hash_table_lookup (hash, unescaped_name) != NULL) {
xmlFree (name);
/* FIXME: Should we delete duplicate nodes as we discover them? */
} else {
- g_hash_table_insert (hash, name, node);
+ g_hash_table_insert (hash, unescaped_name, node);
}
}
}
@@ -1833,21 +1879,23 @@ static void
metafile_read_cancel (NautilusMetafile *metafile)
{
if (metafile->details->read_state != NULL) {
- if (metafile->details->read_state->handle != NULL) {
- eel_read_file_cancel (metafile->details->read_state->handle);
- }
- if (metafile->details->read_state->get_file_info_handle != NULL) {
- gnome_vfs_async_cancel (metafile->details->read_state->get_file_info_handle);
- }
- g_free (metafile->details->read_state);
+ g_cancellable_cancel (metafile->details->read_state->cancellable);
+ metafile->details->read_state->metafile = NULL;
metafile->details->read_state = NULL;
}
}
static void
+metafile_read_state_free (MetafileReadState *state)
+{
+ g_object_unref (state->cancellable);
+ g_free (state);
+}
+
+static void
metafile_read_mark_done (NautilusMetafile *metafile)
{
- g_free (metafile->details->read_state);
+ metafile_read_state_free (metafile->details->read_state);
metafile->details->read_state = NULL;
metafile->details->is_read = TRUE;
@@ -1862,8 +1910,34 @@ metafile_read_mark_done (NautilusMetafile *metafile)
}
static void
-metafile_read_done (NautilusMetafile *metafile)
+metafile_read_done_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
+ MetafileReadState *state;
+ NautilusMetafile *metafile;
+ gsize file_size;
+ char *file_contents;
+
+ state = user_data;
+
+ if (state->metafile == NULL) {
+ /* Operation was cancelled. Bail out */
+ metafile_read_state_free (state);
+ return;
+ }
+
+ metafile = state->metafile;
+ g_assert (metafile->details->xml == NULL);
+
+ if (g_file_load_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL)) {
+ set_metafile_contents (metafile, xmlParseMemory (file_contents, file_size));
+ g_free (file_contents);
+ }
+
metafile_read_mark_done (metafile);
nautilus_metadata_process_ready_copies ();
@@ -1871,57 +1945,23 @@ metafile_read_done (NautilusMetafile *metafile)
}
static void
-metafile_read_failed (NautilusMetafile *metafile)
+metafile_read_restart (NautilusMetafile *metafile)
{
- g_assert (NAUTILUS_IS_METAFILE (metafile));
+ GFile *location;
+ MetafileReadState *state;
- metafile->details->read_state->handle = NULL;
+ state = g_new0 (MetafileReadState, 1);
+ state->metafile = metafile;
+ state->cancellable = g_cancellable_new ();
- metafile_read_done (metafile);
-}
+ metafile->details->read_state = state;
-static void
-metafile_read_done_callback (GnomeVFSResult result,
- GnomeVFSFileSize file_size,
- char *file_contents,
- gpointer callback_data)
-{
- NautilusMetafile *metafile;
- int size;
- char *buffer;
+ location = g_file_new_for_uri (metafile->details->private_uri);
- metafile = NAUTILUS_METAFILE (callback_data);
- g_assert (metafile->details->xml == NULL);
-
- if (result != GNOME_VFS_OK) {
- g_assert (file_contents == NULL);
- metafile_read_failed (metafile);
- return;
- }
-
- size = file_size;
- if ((GnomeVFSFileSize) size != file_size) {
- g_free (file_contents);
- metafile_read_failed (metafile);
- return;
- }
+ g_file_load_contents_async (location, state->cancellable,
+ metafile_read_done_callback, state);
- /* The libxml parser requires a zero-terminated array. */
- buffer = g_realloc (file_contents, size + 1);
- buffer[size] = '\0';
- set_metafile_contents (metafile, xmlParseMemory (buffer, size));
- g_free (buffer);
-
- metafile_read_done (metafile);
-}
-
-static void
-metafile_read_restart (NautilusMetafile *metafile)
-{
- metafile->details->read_state->handle = eel_read_entire_file_async
- (metafile->details->private_uri,
- GNOME_VFS_PRIORITY_DEFAULT,
- metafile_read_done_callback, metafile);
+ g_object_unref (location);
}
static gboolean
@@ -1973,7 +2013,6 @@ metafile_read_start (NautilusMetafile *metafile)
if (!allow_metafile (metafile)) {
metafile_read_mark_done (metafile);
} else {
- metafile->details->read_state = g_new0 (MetafileReadState, 1);
metafile_read_restart (metafile);
}
}
@@ -2083,7 +2122,7 @@ metafile_write_start (NautilusMetafile *metafile)
metafile_uri = metafile->details->private_uri;
- metafile_path = gnome_vfs_get_local_path_from_uri (metafile_uri);
+ metafile_path = g_filename_from_uri (metafile_uri, NULL, NULL);
g_assert (metafile_path != NULL);
metafile_write_local (metafile, metafile_path);
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index 7a2f91c2a..0f34eca43 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -24,27 +24,118 @@
#include <config.h>
#include "nautilus-mime-actions.h"
-
+
+#include <eel/eel-glib-extensions.h>
+#include <eel/eel-stock-dialogs.h>
+#include <eel/eel-string.h>
+#include <eel/eel-mount-operation.h>
+#include <glib/gi18n.h>
+#include <string.h>
+#include <unistd.h>
+
#include "nautilus-file-attributes.h"
#include "nautilus-file.h"
+#include "nautilus-file-operations.h"
#include "nautilus-metadata.h"
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <string.h>
+#include "nautilus-program-choosing.h"
+#include "nautilus-desktop-icon-file.h"
+#include "nautilus-global-preferences.h"
+#include "nautilus-debug-log.h"
+
+typedef enum {
+ ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE,
+ ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND,
+ ACTIVATION_ACTION_ASK,
+ ACTIVATION_ACTION_LAUNCH,
+ ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
+ ACTIVATION_ACTION_OPEN_IN_VIEW,
+ ACTIVATION_ACTION_OPEN_IN_APPLICATION,
+ ACTIVATION_ACTION_DO_NOTHING,
+} ActivationAction;
+
+typedef struct {
+ GAppInfo *application;
+ GList *files;
+} ApplicationLaunchParameters;
+
+typedef struct {
+ NautilusWindowInfo *window_info;
+ GtkWindow *parent_window;
+ GCancellable *cancellable;
+ GList *files;
+ GList *mountables;
+ GList *not_mounted;
+ NautilusWindowOpenMode mode;
+ NautilusWindowOpenFlags flags;
+ char *timed_wait_prompt;
+ NautilusFileListHandle *files_handle;
+ gboolean tried_mounting;
+ char *activation_directory;
+} ActivateParameters;
+
+/* Number of seconds until cancel dialog shows up */
+#define DELAY_UNTIL_CANCEL_MSECS 5000
+
+#define RESPONSE_RUN 1000
+#define RESPONSE_DISPLAY 1001
+#define RESPONSE_RUN_IN_TERMINAL 1002
+
+#define SILENT_WINDOW_OPEN_LIMIT 5
+
+/* This number controls a maximum character count for a URL that is
+ * displayed as part of a dialog. It's fairly arbitrary -- big enough
+ * to allow most "normal" URIs to display in full, but small enough to
+ * prevent the dialog from getting insanely wide.
+ */
+#define MAX_URI_IN_DIALOG_LENGTH 60
+
+static void cancel_activate_callback (gpointer callback_data);
+static void activate_activation_uris_ready_callback (GList *files,
+ gpointer callback_data);
+static void activation_mount_mountables (ActivateParameters *parameters);
+static void activate_callback (GList *files,
+ gpointer callback_data);
+static void activation_mount_not_mounted (ActivateParameters *parameters);
+
+
+
+
+static ApplicationLaunchParameters *
+application_launch_parameters_new (GAppInfo *application,
+ GList *files)
+{
+ ApplicationLaunchParameters *result;
+
+ result = g_new0 (ApplicationLaunchParameters, 1);
+ result->application = g_object_ref (application);
+ result->files = nautilus_file_list_copy (files);
+
+ return result;
+}
+
+static void
+application_launch_parameters_free (ApplicationLaunchParameters *parameters)
+{
+ g_object_unref (parameters->application);
+ nautilus_file_list_free (parameters->files);
+
+ g_free (parameters);
+}
static GList*
filter_nautilus_handler (GList *apps)
{
GList *l, *next;
- GnomeVFSMimeApplication *application;
+ GAppInfo *application;
l = apps;
while (l != NULL) {
- application = (GnomeVFSMimeApplication *) l->data;
+ application = (GAppInfo *) l->data;
next = l->next;
- if (strcmp (gnome_vfs_mime_application_get_desktop_id (application),
- "nautilus-folder-handler.desktop") == 0) {
- gnome_vfs_mime_application_free (application);
+ if (strcmp (g_app_info_get_id (application),
+ "nautilus-folder-handler.desktop") == 0) {
+ g_object_unref (application);
apps = g_list_delete_link (apps, l);
}
@@ -54,71 +145,87 @@ filter_nautilus_handler (GList *apps)
return apps;
}
+static GList*
+filter_non_uri_apps (GList *apps)
+{
+ GList *l, *next;
+ GAppInfo *app;
+
+ for (l = apps; l != NULL; l = next) {
+ app = l->data;
+ next = l->next;
+
+ if (!g_app_info_supports_uris (app)) {
+ apps = g_list_delete_link (apps, l);
+ g_object_unref (app);
+ }
+ }
+ return apps;
+}
+
+
static gboolean
-nautilus_mime_actions_check_if_minimum_attributes_ready (NautilusFile *file)
+nautilus_mime_actions_check_if_required_attributes_ready (NautilusFile *file)
{
NautilusFileAttributes attributes;
gboolean ready;
- attributes = nautilus_mime_actions_get_minimum_file_attributes ();
+ attributes = nautilus_mime_actions_get_required_file_attributes ();
ready = nautilus_file_check_if_ready (file, attributes);
return ready;
}
NautilusFileAttributes
-nautilus_mime_actions_get_minimum_file_attributes (void)
+nautilus_mime_actions_get_required_file_attributes (void)
{
- return NAUTILUS_FILE_ATTRIBUTE_VOLUMES |
- NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
- NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE;
-}
-
-static NautilusFileAttributes
-nautilus_mime_actions_get_open_with_file_attributes (void)
-{
- return NAUTILUS_FILE_ATTRIBUTE_VOLUMES |
- NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
- NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE;
+ return NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_METADATA;
}
static gboolean
-nautilus_mime_actions_check_if_open_with_attributes_ready (NautilusFile *file)
+file_has_local_path (NautilusFile *file)
{
- NautilusFileAttributes attributes;
- gboolean ready;
+ GFile *location;
+ char *path;
+ gboolean res;
- attributes = nautilus_mime_actions_get_open_with_file_attributes ();
- ready = nautilus_file_check_if_ready (file, attributes);
+ /* Don't check _is_native, because we want to support
+ using the fuse path */
+ location = nautilus_file_get_location (file);
+ path = g_file_get_path (location);
- return ready;
-}
+ res = path != NULL;
+
+ g_free (path);
+ g_object_unref (location);
-NautilusFileAttributes
-nautilus_mime_actions_get_full_file_attributes (void)
-{
- return nautilus_mime_actions_get_minimum_file_attributes ();
+ return res;
}
-GnomeVFSMimeApplication *
+GAppInfo *
nautilus_mime_get_default_application_for_file (NautilusFile *file)
{
- GnomeVFSMimeApplication *app;
- char *uri, *mime_type;
+ GAppInfo *app;
+ char *mime_type;
+ char *uri_scheme;
- if (!nautilus_mime_actions_check_if_open_with_attributes_ready (file)) {
+ if (!nautilus_mime_actions_check_if_required_attributes_ready (file)) {
return NULL;
}
-
- uri = nautilus_file_get_uri (file);
+
mime_type = nautilus_file_get_mime_type (file);
- app = gnome_vfs_mime_get_default_application_for_uri (uri, mime_type);
-
- g_free (uri);
+ app = g_app_info_get_default_for_type (mime_type, file_has_local_path (file));
g_free (mime_type);
+
+ if (app == NULL) {
+ uri_scheme = nautilus_file_get_uri_scheme (file);
+ if (uri_scheme != NULL) {
+ app = g_app_info_get_default_for_uri_scheme (uri_scheme);
+ g_free (uri_scheme);
+ }
+ }
return app;
}
@@ -142,23 +249,6 @@ file_compare_by_mime_type (NautilusFile *file_a,
}
static int
-file_compare_by_guessed_mime_type (NautilusFile *file_a,
- NautilusFile *file_b) {
- char *guessed_mime_type_a, *guessed_mime_type_b;
- int ret;
-
- guessed_mime_type_a = nautilus_file_get_guessed_mime_type (file_a);
- guessed_mime_type_b = nautilus_file_get_guessed_mime_type (file_b);
-
- ret = strcmp (guessed_mime_type_a, guessed_mime_type_b);
-
- g_free (guessed_mime_type_a);
- g_free (guessed_mime_type_b);
-
- return ret;
-}
-
-static int
file_compare_by_parent_uri (NautilusFile *file_a,
NautilusFile *file_b) {
char *parent_uri_a, *parent_uri_b;
@@ -176,84 +266,49 @@ file_compare_by_parent_uri (NautilusFile *file_a,
}
static int
-application_compare_by_name (const GnomeVFSMimeApplication *app_a,
- const GnomeVFSMimeApplication *app_b)
+application_compare_by_name (const GAppInfo *app_a,
+ const GAppInfo *app_b)
{
- return g_utf8_collate (app_a->name, app_b->name);
+ return g_utf8_collate (g_app_info_get_name ((GAppInfo *)app_a),
+ g_app_info_get_name ((GAppInfo *)app_b));
}
static int
-application_compare_by_id (const GnomeVFSMimeApplication *app_a,
- const GnomeVFSMimeApplication *app_b)
+application_compare_by_id (const GAppInfo *app_a,
+ const GAppInfo *app_b)
{
- return strcmp (app_a->id, app_b->id);
-}
-
-static GList *
-get_open_with_mime_applications (NautilusFile *file)
-{
- char *guessed_mime_type;
- char *mime_type, *uri;
- GList *result;
-
- guessed_mime_type = nautilus_file_get_guessed_mime_type (file);
- mime_type = nautilus_file_get_mime_type (file);
- uri = nautilus_file_get_uri (file);
-
- result = gnome_vfs_mime_get_all_applications_for_uri (uri, mime_type);
- result = g_list_sort (result, (GCompareFunc) application_compare_by_name);
-
- if (strcmp (guessed_mime_type, mime_type) != 0) {
- GList *result_2;
- GList *l;
-
- result_2 = gnome_vfs_mime_get_all_applications (guessed_mime_type);
- for (l = result_2; l != NULL; l = l->next) {
- if (!g_list_find_custom (result, l->data,
- (GCompareFunc) application_compare_by_id)) {
- result = g_list_insert_sorted (result, l->data,
- (GCompareFunc) application_compare_by_name);
- }
- }
- g_list_free (result_2);
- }
-
- g_free (mime_type);
- g_free (uri);
- g_free (guessed_mime_type);
-
- return result;
-}
-
-/* Get a list of applications for the Open With menu. This is
- * different than nautilus_mime_get_applications_for_file()
- * because this function will merge the lists of the fast and slow
- * mime types for the file */
-GList *
-nautilus_mime_get_open_with_applications_for_file (NautilusFile *file)
-{
- GList *result;
-
- if (!nautilus_mime_actions_check_if_open_with_attributes_ready (file)) {
- return NULL;
- }
-
- result = get_open_with_mime_applications (file);
-
- return filter_nautilus_handler (result);
+ return g_utf8_collate (g_app_info_get_id ((GAppInfo *)app_a),
+ g_app_info_get_id ((GAppInfo *)app_b));
}
GList *
nautilus_mime_get_applications_for_file (NautilusFile *file)
{
char *mime_type;
+ char *uri_scheme;
GList *result;
+ GAppInfo *uri_handler;
- if (!nautilus_mime_actions_check_if_minimum_attributes_ready (file)) {
+ if (!nautilus_mime_actions_check_if_required_attributes_ready (file)) {
return NULL;
}
mime_type = nautilus_file_get_mime_type (file);
- result = gnome_vfs_mime_get_all_applications (mime_type);
+ result = g_app_info_get_all_for_type (mime_type);
+
+ uri_scheme = nautilus_file_get_uri_scheme (file);
+ if (uri_scheme != NULL) {
+ uri_handler = g_app_info_get_default_for_uri_scheme (uri_scheme);
+ if (uri_handler) {
+ result = g_list_prepend (result, uri_handler);
+ }
+ g_free (uri_scheme);
+ }
+
+ if (!file_has_local_path (file)) {
+ /* Filter out non-uri supporting apps */
+ result = filter_non_uri_apps (result);
+ }
+
result = g_list_sort (result, (GCompareFunc) application_compare_by_name);
g_free (mime_type);
@@ -264,34 +319,48 @@ gboolean
nautilus_mime_has_any_applications_for_file (NautilusFile *file)
{
GList *apps;
- char *uri, *mime_type;
+ char *mime_type;
gboolean result;
+ char *uri_scheme;
+ GAppInfo *uri_handler;
- uri = nautilus_file_get_uri (file);
mime_type = nautilus_file_get_mime_type (file);
- apps = gnome_vfs_mime_get_all_applications_for_uri (uri, mime_type);
+ apps = g_app_info_get_all_for_type (mime_type);
+
+ uri_scheme = nautilus_file_get_uri_scheme (file);
+ if (uri_scheme != NULL) {
+ uri_handler = g_app_info_get_default_for_uri_scheme (uri_scheme);
+ if (uri_handler) {
+ apps = g_list_prepend (apps, uri_handler);
+ }
+ g_free (uri_scheme);
+ }
+
+ if (!file_has_local_path (file)) {
+ /* Filter out non-uri supporting apps */
+ apps = filter_non_uri_apps (apps);
+ }
apps = filter_nautilus_handler (apps);
if (apps) {
result = TRUE;
- gnome_vfs_mime_application_list_free (apps);
+ eel_g_object_list_free (apps);
} else {
result = FALSE;
}
g_free (mime_type);
- g_free (uri);
return result;
}
-GnomeVFSMimeApplication *
+GAppInfo *
nautilus_mime_get_default_application_for_files (GList *files)
{
GList *l, *sorted_files;
NautilusFile *file;
- GnomeVFSMimeApplication *app, *one_app;
+ GAppInfo *app, *one_app;
g_assert (files != NULL);
@@ -308,9 +377,13 @@ nautilus_mime_get_default_application_for_files (GList *files)
}
one_app = nautilus_mime_get_default_application_for_file (file);
- if (one_app == NULL || (app != NULL && !gnome_vfs_mime_application_equal (app, one_app))) {
- gnome_vfs_mime_application_free (app);
- gnome_vfs_mime_application_free (one_app);
+ if (one_app == NULL || (app != NULL && !g_app_info_equal (app, one_app))) {
+ if (app) {
+ g_object_unref (app);
+ }
+ if (one_app) {
+ g_object_unref (one_app);
+ }
app = NULL;
break;
}
@@ -318,7 +391,7 @@ nautilus_mime_get_default_application_for_files (GList *files)
if (app == NULL) {
app = one_app;
} else {
- gnome_vfs_mime_application_free (one_app);
+ g_object_unref (one_app);
}
}
@@ -337,7 +410,7 @@ intersect_application_lists (GList *a,
{
GList *l, *m;
GList *ret;
- GnomeVFSMimeApplication *a_app, *b_app;
+ GAppInfo *a_app, *b_app;
int cmp;
ret = NULL;
@@ -346,26 +419,27 @@ intersect_application_lists (GList *a,
m = b;
while (l != NULL && m != NULL) {
- a_app = (GnomeVFSMimeApplication *) l->data;
- b_app = (GnomeVFSMimeApplication *) m->data;
+ a_app = (GAppInfo *) l->data;
+ b_app = (GAppInfo *) m->data;
- cmp = strcmp (a_app->id, b_app->id);
+ cmp = strcmp (g_app_info_get_id (a_app),
+ g_app_info_get_id (b_app));
if (cmp > 0) {
- gnome_vfs_mime_application_free (b_app);
+ g_object_unref (b_app);
m = m->next;
} else if (cmp < 0) {
- gnome_vfs_mime_application_free (a_app);
+ g_object_unref (a_app);
l = l->next;
} else {
- gnome_vfs_mime_application_free (b_app);
+ g_object_unref (b_app);
ret = g_list_prepend (ret, a_app);
l = l->next;
m = m->next;
}
}
- g_list_foreach (l, (GFunc) gnome_vfs_mime_application_free, NULL);
- g_list_foreach (m, (GFunc) gnome_vfs_mime_application_free, NULL);
+ g_list_foreach (l, (GFunc) g_object_unref, NULL);
+ g_list_foreach (m, (GFunc) g_object_unref, NULL);
g_list_free (a);
g_list_free (b);
@@ -374,7 +448,7 @@ intersect_application_lists (GList *a,
}
GList *
-nautilus_mime_get_open_with_applications_for_files (GList *files)
+nautilus_mime_get_applications_for_files (GList *files)
{
GList *l, *sorted_files;
NautilusFile *file;
@@ -390,12 +464,12 @@ nautilus_mime_get_open_with_applications_for_files (GList *files)
if (l->prev &&
file_compare_by_mime_type (file, l->prev->data) == 0 &&
- file_compare_by_guessed_mime_type (file, l->prev->data) == 0 &&
file_compare_by_parent_uri (file, l->prev->data) == 0) {
continue;
}
- one_ret = nautilus_mime_get_open_with_applications_for_file (file);
+ one_ret = nautilus_mime_get_applications_for_file (file);
+ one_ret = g_list_sort (one_ret, (GCompareFunc) application_compare_by_id);
if (ret != NULL) {
ret = intersect_application_lists (ret, one_ret);
} else {
@@ -409,37 +483,34 @@ nautilus_mime_get_open_with_applications_for_files (GList *files)
g_list_free (sorted_files);
+ ret = g_list_sort (ret, (GCompareFunc) application_compare_by_name);
+
return ret;
}
-GList *
-nautilus_mime_get_applications_for_files (GList *files)
+gboolean
+nautilus_mime_has_any_applications_for_files (GList *files)
{
GList *l, *sorted_files;
NautilusFile *file;
- GList *one_ret, *ret;
+ gboolean ret;
g_assert (files != NULL);
sorted_files = g_list_sort (g_list_copy (files), (GCompareFunc) file_compare_by_mime_type);
- ret = NULL;
+ ret = TRUE;
for (l = sorted_files; l != NULL; l = l->next) {
- file = l->data;
+ file = NAUTILUS_FILE (l->data);
if (l->prev &&
- file_compare_by_mime_type (file, l->prev->data) == 0) {
+ file_compare_by_mime_type (file, l->prev->data) == 0 &&
+ file_compare_by_parent_uri (file, l->prev->data) == 0) {
continue;
}
- one_ret = nautilus_mime_get_applications_for_file (file);
- if (ret != NULL) {
- ret = intersect_application_lists (ret, one_ret);
- } else {
- ret = one_ret;
- }
-
- if (ret == NULL) {
+ if (!nautilus_mime_has_any_applications_for_file (file)) {
+ ret = FALSE;
break;
}
}
@@ -449,34 +520,1049 @@ nautilus_mime_get_applications_for_files (GList *files)
return ret;
}
+
+
+static void
+trash_or_delete_files (GtkWindow *parent_window,
+ const GList *files,
+ gboolean delete_if_all_already_in_trash)
+{
+ GList *locations;
+ const GList *node;
+
+ locations = NULL;
+ for (node = files; node != NULL; node = node->next) {
+ locations = g_list_prepend (locations,
+ nautilus_file_get_location ((NautilusFile *) node->data));
+ }
+
+ locations = g_list_reverse (locations);
+
+ nautilus_file_operations_trash_or_delete (locations,
+ parent_window,
+ NULL, NULL);
+ eel_g_object_list_free (locations);
+}
+
+static void
+report_broken_symbolic_link (GtkWindow *parent_window, NautilusFile *file)
+{
+ char *target_path;
+ char *display_name;
+ char *prompt;
+ char *detail;
+ GtkDialog *dialog;
+ GList file_as_list;
+ int response;
+
+ g_assert (nautilus_file_is_broken_symbolic_link (file));
+
+ display_name = nautilus_file_get_display_name (file);
+ if (nautilus_file_is_in_trash (file)) {
+ prompt = g_strdup_printf (_("The Link \"%s\" is Broken."), display_name);
+ } else {
+ prompt = g_strdup_printf (_("The Link \"%s\" is Broken. Move it to Trash?"), display_name);
+ }
+ g_free (display_name);
+
+ target_path = nautilus_file_get_symbolic_link_target_path (file);
+ if (target_path == NULL) {
+ detail = g_strdup (_("This link can't be used, because it has no target."));
+ } else {
+ detail = g_strdup_printf (_("This link can't be used, because its target "
+ "\"%s\" doesn't exist."), target_path);
+ }
+
+ if (nautilus_file_is_in_trash (file)) {
+ eel_run_simple_dialog (GTK_WIDGET (parent_window), FALSE, GTK_MESSAGE_WARNING,
+ prompt, detail, GTK_STOCK_CANCEL, NULL);
+ goto out;
+ }
+
+ dialog = eel_show_yes_no_dialog (prompt, detail, _("Mo_ve to Trash"), GTK_STOCK_CANCEL,
+ parent_window);
+
+ gtk_dialog_set_default_response (dialog, GTK_RESPONSE_YES);
+
+ /* Make this modal to avoid problems with reffing the view & file
+ * to keep them around in case the view changes, which would then
+ * cause the old view not to be destroyed, which would cause its
+ * merged Bonobo items not to be un-merged. Maybe we need to unmerge
+ * explicitly when disconnecting views instead of relying on the
+ * unmerge in Destroy. But since BonoboUIHandler is probably going
+ * to change wildly, I don't want to mess with this now.
+ */
+
+ response = gtk_dialog_run (dialog);
+ gtk_object_destroy (GTK_OBJECT (dialog));
+
+ if (response == GTK_RESPONSE_YES) {
+ file_as_list.data = file;
+ file_as_list.next = NULL;
+ file_as_list.prev = NULL;
+ trash_or_delete_files (parent_window, &file_as_list, TRUE);
+ }
+
+out:
+ g_free (prompt);
+ g_free (target_path);
+ g_free (detail);
+}
+
+static ActivationAction
+get_executable_text_file_action (GtkWindow *parent_window, NautilusFile *file)
+{
+ GtkDialog *dialog;
+ char *file_name;
+ char *prompt;
+ char *detail;
+ int preferences_value;
+ int response;
+
+ g_assert (nautilus_file_contains_text (file));
+
+ preferences_value = eel_preferences_get_enum
+ (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
+ switch (preferences_value) {
+ case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
+ return ACTIVATION_ACTION_LAUNCH;
+ case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
+ return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
+ case NAUTILUS_EXECUTABLE_TEXT_ASK:
+ break;
+ default:
+ /* Complain non-fatally, since preference data can't be trusted */
+ g_warning ("Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION",
+ preferences_value);
+
+ }
+
+
+ file_name = nautilus_file_get_display_name (file);
+ prompt = g_strdup_printf (_("Do you want to run \"%s\", or display its contents?"),
+ file_name);
+ detail = g_strdup_printf (_("\"%s\" is an executable text file."),
+ file_name);
+ g_free (file_name);
+
+ dialog = eel_create_question_dialog (prompt,
+ detail,
+ _("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL,
+ _("_Display"), RESPONSE_DISPLAY,
+ parent_window);
+ gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (dialog, _("_Run"), RESPONSE_RUN);
+ gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
+ gtk_widget_show (GTK_WIDGET (dialog));
+
+ g_free (prompt);
+ g_free (detail);
+
+ response = gtk_dialog_run (dialog);
+ gtk_object_destroy (GTK_OBJECT (dialog));
+
+ switch (response) {
+ case RESPONSE_RUN:
+ return ACTIVATION_ACTION_LAUNCH;
+ case RESPONSE_RUN_IN_TERMINAL:
+ return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL;
+ case RESPONSE_DISPLAY:
+ return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
+ default:
+ return ACTIVATION_ACTION_DO_NOTHING;
+ }
+}
+
+static ActivationAction
+get_default_executable_text_file_action (void)
+{
+ int preferences_value;
+
+ preferences_value = eel_preferences_get_enum
+ (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
+ switch (preferences_value) {
+ case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
+ return ACTIVATION_ACTION_LAUNCH;
+ case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
+ return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
+ case NAUTILUS_EXECUTABLE_TEXT_ASK:
+ default:
+ return ACTIVATION_ACTION_ASK;
+ }
+}
+
gboolean
-nautilus_mime_has_any_applications_for_files (GList *files)
+nautilus_mime_file_opens_in_view (NautilusFile *file)
{
- GList *l, *sorted_files;
+ return (nautilus_file_is_directory (file) ||
+ NAUTILUS_IS_DESKTOP_ICON_FILE (file) ||
+ nautilus_file_is_nautilus_link (file));
+}
+
+static ActivationAction
+get_activation_action (NautilusFile *file)
+{
+ ActivationAction action;
+ char *activation_uri;
+
+ activation_uri = nautilus_file_get_activation_uri (file);
+ if (activation_uri == NULL) {
+ activation_uri = nautilus_file_get_uri (file);
+ }
+
+ action = ACTIVATION_ACTION_DO_NOTHING;
+
+ if (eel_str_has_prefix (activation_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
+ action = ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE;
+ } else if (eel_str_has_prefix (activation_uri, NAUTILUS_COMMAND_SPECIFIER)) {
+ action = ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND;
+ } else if (nautilus_file_is_launchable (file)) {
+ char *executable_path;
+
+ action = ACTIVATION_ACTION_LAUNCH;
+
+ executable_path = g_filename_from_uri (activation_uri, NULL, NULL);
+ if (!executable_path) {
+ action = ACTIVATION_ACTION_DO_NOTHING;
+ } else if (nautilus_file_contains_text (file)) {
+ action = get_default_executable_text_file_action ();
+ }
+ g_free (executable_path);
+ }
+
+ if (action == ACTIVATION_ACTION_DO_NOTHING) {
+ if (nautilus_mime_file_opens_in_view (file)) {
+ action = ACTIVATION_ACTION_OPEN_IN_VIEW;
+ } else {
+ action = ACTIVATION_ACTION_OPEN_IN_APPLICATION;
+ }
+ }
+ g_free (activation_uri);
+
+ return action;
+}
+
+gboolean
+nautilus_mime_file_opens_in_external_app (NautilusFile *file)
+{
+ ActivationAction activation_action;
+
+ activation_action = get_activation_action (file);
+
+ return (activation_action == ACTIVATION_ACTION_OPEN_IN_APPLICATION);
+}
+
+
+static unsigned int
+mime_application_hash (GAppInfo *app)
+{
+ return g_str_hash (g_app_info_get_id (app));
+}
+
+static void
+list_to_parameters_foreach (GAppInfo *application,
+ GList *files,
+ GList **ret)
+{
+ ApplicationLaunchParameters *parameters;
+
+ files = g_list_reverse (files);
+
+ parameters = application_launch_parameters_new
+ (application, files);
+ *ret = g_list_prepend (*ret, parameters);
+}
+
+
+/**
+ * fm_directory_view_make_activation_parameters
+ *
+ * Construct a list of ApplicationLaunchParameters from a list of NautilusFiles,
+ * where files that have the same default application are put into the same
+ * launch parameter, and others are put into the unhandled_files list.
+ *
+ * @files: Files to use for construction.
+ * @unhandled_files: Files without any default application will be put here.
+ *
+ * Return value: Newly allocated list of ApplicationLaunchParameters.
+ **/
+static GList *
+fm_directory_view_make_activation_parameters (GList *files,
+ GList **unhandled_files)
+{
+ GList *ret, *l, *app_files;
NautilusFile *file;
- gboolean ret;
+ GAppInfo *app, *old_app;
+ GHashTable *app_table;
- g_assert (files != NULL);
+ ret = NULL;
+ *unhandled_files = NULL;
- sorted_files = g_list_sort (g_list_copy (files), (GCompareFunc) file_compare_by_mime_type);
+ app_table = g_hash_table_new_full
+ ((GHashFunc) mime_application_hash,
+ (GEqualFunc) g_app_info_equal,
+ (GDestroyNotify) g_object_unref,
+ (GDestroyNotify) g_list_free);
- ret = TRUE;
- for (l = sorted_files; l != NULL; l = l->next) {
+ for (l = files; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
- if (l->prev &&
- file_compare_by_mime_type (file, l->prev->data) == 0 &&
- file_compare_by_parent_uri (file, l->prev->data) == 0) {
+ app = nautilus_mime_get_default_application_for_file (file);
+ if (app != NULL) {
+ app_files = NULL;
+
+ if (g_hash_table_lookup_extended (app_table, app,
+ (gpointer *) &old_app,
+ (gpointer *) &app_files)) {
+ g_hash_table_steal (app_table, old_app);
+
+ app_files = g_list_prepend (app_files, file);
+
+ g_object_unref (app);
+ app = old_app;
+ } else {
+ app_files = g_list_prepend (NULL, file);
+ }
+
+ g_hash_table_insert (app_table, app, app_files);
+ } else {
+ *unhandled_files = g_list_prepend (*unhandled_files, file);
+ }
+ }
+
+ g_hash_table_foreach (app_table,
+ (GHFunc) list_to_parameters_foreach,
+ &ret);
+
+ g_hash_table_destroy (app_table);
+
+ *unhandled_files = g_list_reverse (*unhandled_files);
+
+ return g_list_reverse (ret);
+}
+
+static gboolean
+file_was_cancelled (NautilusFile *file)
+{
+ GError *error;
+
+ error = nautilus_file_get_file_info_error (file);
+ return
+ error != NULL &&
+ error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_CANCELLED;
+
+}
+
+
+static gboolean
+file_was_not_mounted (NautilusFile *file)
+{
+ GError *error;
+
+ error = nautilus_file_get_file_info_error (file);
+ return
+ error != NULL &&
+ error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_NOT_MOUNTED;
+}
+
+static void
+activation_parameters_free (ActivateParameters *parameters)
+{
+ if (parameters->window_info) {
+ g_object_remove_weak_pointer (G_OBJECT (parameters->window_info), (gpointer *)&parameters->window_info);
+ }
+ if (parameters->parent_window) {
+ g_object_remove_weak_pointer (G_OBJECT (parameters->parent_window), (gpointer *)&parameters->parent_window);
+ }
+ g_object_unref (parameters->cancellable);
+ nautilus_file_list_free (parameters->files);
+ nautilus_file_list_free (parameters->mountables);
+ nautilus_file_list_free (parameters->not_mounted);
+ g_free (parameters->activation_directory);
+ g_free (parameters->timed_wait_prompt);
+ g_assert (parameters->files_handle == NULL);
+ g_free (parameters);
+}
+
+static void
+cancel_activate_callback (gpointer callback_data)
+{
+ /* TODO-gio */
+}
+
+static void
+activation_start_timed_cancel (ActivateParameters *parameters)
+{
+ eel_timed_wait_start_with_duration
+ (DELAY_UNTIL_CANCEL_MSECS,
+ cancel_activate_callback,
+ parameters,
+ parameters->timed_wait_prompt,
+ parameters->parent_window);
+}
+
+static void
+activate_mount_op_active (EelMountOperation *operation,
+ gboolean is_active,
+ ActivateParameters *parameters)
+{
+ if (is_active) {
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ } else {
+ activation_start_timed_cancel (parameters);
+ }
+}
+
+static gboolean
+confirm_multiple_windows (GtkWindow *parent_window, int count)
+{
+ GtkDialog *dialog;
+ char *prompt;
+ char *detail;
+ int response;
+
+ if (count <= SILENT_WINDOW_OPEN_LIMIT) {
+ return TRUE;
+ }
+
+ prompt = _("Are you sure you want to open all files?");
+ detail = g_strdup_printf (ngettext("This will open %d separate window.",
+ "This will open %d separate windows.", count), count);
+ dialog = eel_show_yes_no_dialog (prompt, detail,
+ GTK_STOCK_OK, GTK_STOCK_CANCEL,
+ parent_window);
+ g_free (detail);
+
+ response = gtk_dialog_run (dialog);
+ gtk_object_destroy (GTK_OBJECT (dialog));
+
+ return response == GTK_RESPONSE_YES;
+}
+
+static void
+activate_files (ActivateParameters *parameters)
+{
+ NautilusFile *file;
+ GList *launch_desktop_files;
+ GList *launch_from_command_files;
+ GList *launch_files;
+ GList *launch_in_terminal_files;
+ GList *open_in_app_files;
+ GList *open_in_app_parameters;
+ GList *unhandled_open_in_app_files;
+ ApplicationLaunchParameters *one_parameters;
+ GList *open_in_view_files;
+ GList *l;
+ int count;
+ char *uri;
+ char *executable_path, *quoted_path, *name;
+ char *old_working_dir;
+ ActivationAction action;
+ GdkScreen *screen;
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));
+
+ launch_desktop_files = NULL;
+ launch_from_command_files = NULL;
+ launch_files = NULL;
+ launch_in_terminal_files = NULL;
+ open_in_app_files = NULL;
+ open_in_view_files = NULL;
+
+ for (l = parameters->files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ if (file_was_cancelled (file)) {
continue;
}
- if (!nautilus_mime_has_any_applications_for_file (file)) {
- ret = FALSE;
+ action = get_activation_action (file);
+ if (action == ACTIVATION_ACTION_ASK) {
+ /* Special case for executable text files, since it might be
+ * dangerous & unexpected to launch these.
+ */
+ action = get_executable_text_file_action (parameters->parent_window, file);
+ }
+
+ switch (action) {
+ case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE :
+ launch_desktop_files = g_list_prepend (launch_desktop_files, file);
+ break;
+ case ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND :
+ launch_from_command_files = g_list_prepend (launch_from_command_files, file);
+ break;
+ case ACTIVATION_ACTION_LAUNCH :
+ launch_files = g_list_prepend (launch_files, file);
+ break;
+ case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL :
+ launch_in_terminal_files = g_list_prepend (launch_in_terminal_files, file);
+ break;
+ case ACTIVATION_ACTION_OPEN_IN_VIEW :
+ open_in_view_files = g_list_prepend (open_in_view_files, file);
+ break;
+ case ACTIVATION_ACTION_OPEN_IN_APPLICATION :
+ open_in_app_files = g_list_prepend (open_in_app_files, file);
+ break;
+ case ACTIVATION_ACTION_DO_NOTHING :
+ break;
+ case ACTIVATION_ACTION_ASK :
+ g_assert_not_reached ();
break;
}
}
- g_list_free (sorted_files);
+ launch_desktop_files = g_list_reverse (launch_desktop_files);
+ for (l = launch_desktop_files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ uri = nautilus_file_get_uri (file);
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+ "directory view activate_callback launch_desktop_file window=%p: %s",
+ parameters->parent_window, uri);
+ nautilus_launch_desktop_file (screen, uri, NULL,
+ parameters->parent_window);
+ g_free (uri);
+ }
- return ret;
+ launch_from_command_files = g_list_reverse (launch_from_command_files);
+ for (l = launch_from_command_files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ uri = nautilus_file_get_activation_uri (file);
+
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+ "directory view activate_callback launch_application_from_command window=%p: %s",
+ parameters->parent_window, uri);
+
+ nautilus_launch_application_from_command (
+ screen, NULL, uri + strlen (NAUTILUS_COMMAND_SPECIFIER),
+ NULL, FALSE);
+ g_free (uri);
+ }
+
+ old_working_dir = NULL;
+ if (parameters->activation_directory &&
+ (launch_files != NULL || launch_in_terminal_files != NULL)) {
+ old_working_dir = g_get_current_dir ();
+ chdir (parameters->activation_directory);
+
+ }
+
+ launch_files = g_list_reverse (launch_files);
+ for (l = launch_files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ uri = nautilus_file_get_activation_uri (file);
+ executable_path = g_filename_from_uri (uri, NULL, NULL);
+ quoted_path = g_shell_quote (executable_path);
+ name = nautilus_file_get_name (file);
+
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+ "directory view activate_callback launch_file window=%p: %s",
+ parameters->parent_window, quoted_path);
+
+ nautilus_launch_application_from_command (screen, name, quoted_path, NULL, FALSE);
+ g_free (name);
+ g_free (quoted_path);
+ g_free (executable_path);
+ g_free (uri);
+
+ }
+
+ launch_in_terminal_files = g_list_reverse (launch_in_terminal_files);
+ for (l = launch_in_terminal_files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ uri = nautilus_file_get_activation_uri (file);
+ executable_path = g_filename_from_uri (uri, NULL, NULL);
+ quoted_path = g_shell_quote (executable_path);
+ name = nautilus_file_get_name (file);
+
+ nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
+ "directory view activate_callback launch_in_terminal window=%p: %s",
+ parameters->parent_window, quoted_path);
+
+ nautilus_launch_application_from_command (screen, name, quoted_path, NULL, TRUE);
+ g_free (name);
+ g_free (quoted_path);
+ g_free (executable_path);
+ g_free (uri);
+ }
+
+ if (old_working_dir != NULL) {
+ chdir (old_working_dir);
+ g_free (old_working_dir);
+ }
+
+ open_in_view_files = g_list_reverse (open_in_view_files);
+ count = g_list_length (open_in_view_files);
+ if (parameters->window_info != NULL &&
+ confirm_multiple_windows (parameters->parent_window, count)) {
+ NautilusWindowOpenFlags flags;
+
+ flags = parameters->flags;
+ if (count > 1) {
+ flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
+ }
+
+ for (l = open_in_view_files; l != NULL; l = l->next) {
+ GFile *f;
+ /* The ui should ask for navigation or object windows
+ * depending on what the current one is */
+ file = NAUTILUS_FILE (l->data);
+
+ uri = nautilus_file_get_activation_uri (file);
+ f = g_file_new_for_uri (uri);
+ nautilus_window_info_open_location (parameters->window_info,
+ f, parameters->mode, flags, NULL);
+ g_object_unref (f);
+ g_free (uri);
+ }
+ }
+
+ open_in_app_parameters = NULL;
+ unhandled_open_in_app_files = NULL;
+
+ if (open_in_app_files != NULL) {
+ open_in_app_files = g_list_reverse (open_in_app_files);
+
+ open_in_app_parameters = fm_directory_view_make_activation_parameters
+ (open_in_app_files, &unhandled_open_in_app_files);
+ }
+
+ for (l = open_in_app_parameters; l != NULL; l = l->next) {
+ one_parameters = l->data;
+
+ nautilus_launch_application (one_parameters->application,
+ one_parameters->files,
+ parameters->parent_window);
+ application_launch_parameters_free (one_parameters);
+ }
+
+ for (l = unhandled_open_in_app_files; l != NULL; l = l->next) {
+ GFile *location;
+ char *full_uri_for_display;
+ char *uri_for_display;
+ char *error_message;
+
+ file = NAUTILUS_FILE (l->data);
+
+ location = nautilus_file_get_location (file);
+ full_uri_for_display = g_file_get_parse_name (location);
+ g_object_unref (location);
+
+ /* Truncate the URI so it doesn't get insanely wide. Note that even
+ * though the dialog uses wrapped text, if the URI doesn't contain
+ * white space then the text-wrapping code is too stupid to wrap it.
+ */
+ uri_for_display = eel_str_middle_truncate
+ (full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH);
+ g_free (full_uri_for_display);
+
+ error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
+ uri_for_display);
+
+ g_free (uri_for_display);
+
+ eel_show_error_dialog (error_message,
+ _("There is no application installed for this file type"),
+ parameters->parent_window);
+ g_free (error_message);
+ }
+
+ if (open_in_app_parameters != NULL ||
+ unhandled_open_in_app_files != NULL) {
+ if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0 &&
+ parameters->window_info != NULL &&
+ nautilus_window_info_get_window_type (parameters->window_info) == NAUTILUS_WINDOW_SPATIAL) {
+ nautilus_window_info_close (parameters->window_info);
+ }
+ }
+
+ g_list_free (launch_desktop_files);
+ g_list_free (launch_from_command_files);
+ g_list_free (launch_files);
+ g_list_free (launch_in_terminal_files);
+ g_list_free (open_in_view_files);
+ g_list_free (open_in_app_files);
+ g_list_free (open_in_app_parameters);
+ g_list_free (unhandled_open_in_app_files);
+
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ activation_parameters_free (parameters);
+}
+
+static void
+activation_mount_not_mounted_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ ActivateParameters *parameters = user_data;
+ GError *error;
+ NautilusFile *file;
+
+ file = parameters->not_mounted->data;
+
+ error = NULL;
+ if (!g_mount_for_location_finish (G_FILE (source_object), res, &error)) {
+ if (error->domain != G_IO_ERROR &&
+ error->code != G_IO_ERROR_CANCELLED &&
+ error->code != G_IO_ERROR_ALREADY_MOUNTED) {
+ eel_show_error_dialog (_("Unable to mount location"),
+ error->message, NULL);
+ }
+
+ if (error->domain != G_IO_ERROR &&
+ error->code != G_IO_ERROR_ALREADY_MOUNTED) {
+ parameters->files = g_list_remove (parameters->files, file);
+ nautilus_file_unref (file);
+ }
+
+ g_error_free (error);
+ }
+
+ parameters->not_mounted = g_list_delete_link (parameters->not_mounted,
+ parameters->not_mounted);
+ nautilus_file_unref (file);
+
+ activation_mount_not_mounted (parameters);
+}
+
+static void
+activation_mount_not_mounted (ActivateParameters *parameters)
+{
+ NautilusFile *file;
+ GFile *location;
+ GMountOperation *mount_op;
+
+ if (parameters->not_mounted != NULL) {
+ file = parameters->not_mounted->data;
+ mount_op = eel_mount_operation_new (parameters->parent_window);
+ g_signal_connect (mount_op, "active_changed", (GCallback)activate_mount_op_active, parameters);
+ location = nautilus_file_get_location (file);
+ g_mount_for_location (location, mount_op, parameters->cancellable,
+ activation_mount_not_mounted_callback, parameters);
+ g_object_unref (location);
+ g_object_unref (mount_op);
+ return;
+ }
+
+ parameters->tried_mounting = TRUE;
+ nautilus_file_list_call_when_ready
+ (parameters->files,
+ nautilus_mime_actions_get_required_file_attributes () | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO,
+ &parameters->files_handle,
+ activate_callback, parameters);
+}
+
+
+static void
+activate_callback (GList *files, gpointer callback_data)
+{
+ ActivateParameters *parameters = callback_data;
+ GList *l, *next;
+ NautilusFile *file;
+
+ parameters->files_handle = NULL;
+
+ for (l = parameters->files; l != NULL; l = next) {
+ file = NAUTILUS_FILE (l->data);
+ next = l->next;
+
+ if (file_was_cancelled (file)) {
+ nautilus_file_unref (file);
+ parameters->files = g_list_delete_link (parameters->files, l);
+ continue;
+ }
+
+ if (file_was_not_mounted (file)) {
+ if (parameters->tried_mounting) {
+ nautilus_file_unref (file);
+ parameters->files = g_list_delete_link (parameters->files, l);
+ } else {
+ parameters->not_mounted = g_list_prepend (parameters->not_mounted,
+ nautilus_file_ref (file));
+ }
+ continue;
+ }
+ }
+
+
+ if (parameters->not_mounted != NULL) {
+ activation_mount_not_mounted (parameters);
+ } else {
+ activate_files (parameters);
+ }
+}
+
+static void
+activate_activation_uris_ready_callback (GList *files_ignore,
+ gpointer callback_data)
+{
+ ActivateParameters *parameters = callback_data;
+ GList *l, *next;
+ NautilusFile *file;
+
+ parameters->files_handle = NULL;
+
+ for (l = parameters->files; l != NULL; l = next) {
+ file = NAUTILUS_FILE (l->data);
+ next = l->next;
+
+ if (file_was_cancelled (file)) {
+ nautilus_file_unref (file);
+ parameters->files = g_list_delete_link (parameters->files, l);
+ continue;
+ }
+
+ if (nautilus_file_is_broken_symbolic_link (file)) {
+ nautilus_file_unref (file);
+ parameters->files = g_list_delete_link (parameters->files, l);
+ report_broken_symbolic_link (parameters->parent_window, file);
+ continue;
+ }
+ }
+
+ if (parameters->files == NULL) {
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ activation_parameters_free (parameters);
+ return;
+ }
+
+ /* Convert the files to the actual activation uri files */
+ for (l = parameters->files; l != NULL; l = l->next) {
+ char *uri;
+ file = NAUTILUS_FILE (l->data);
+
+ /* We want the file for the activation URI since we care
+ * about the attributes for that, not for the original file.
+ */
+ uri = nautilus_file_get_activation_uri (file);
+ if (uri != NULL &&
+ !(g_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ||
+ g_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER))) {
+ NautilusFile *actual_file;
+
+ actual_file = nautilus_file_get_by_uri (uri);
+ if (actual_file != NULL) {
+ nautilus_file_unref (file);
+ l->data = actual_file;
+ }
+ }
+ g_free (uri);
+ }
+
+
+ /* get the parameters for the actual files */
+ nautilus_file_list_call_when_ready
+ (parameters->files,
+ nautilus_mime_actions_get_required_file_attributes () | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO,
+ &parameters->files_handle,
+ activate_callback, parameters);
+}
+
+static void
+activation_get_activation_uris (ActivateParameters *parameters)
+{
+ GList *l;
+ NautilusFile *file;
+
+ /* link target info might be stale, re-read it */
+ for (l = parameters->files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ if (file_was_cancelled (file)) {
+ nautilus_file_unref (file);
+ parameters->files = g_list_delete_link (parameters->files, l);
+ continue;
+ }
+
+ if (nautilus_file_is_symbolic_link (file)) {
+ nautilus_file_invalidate_attributes
+ (file,
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO);
+ }
+ }
+
+ if (parameters->files == NULL) {
+ eel_timed_wait_stop (cancel_activate_callback, parameters);
+ activation_parameters_free (parameters);
+ return;
+ }
+
+ nautilus_file_list_call_when_ready
+ (parameters->files,
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO,
+ &parameters->files_handle,
+ activate_activation_uris_ready_callback, parameters);
+}
+
+
+static void
+activation_mountable_mounted (NautilusFile *file,
+ GFile *result_location,
+ GError *error,
+ gpointer callback_data)
+{
+ ActivateParameters *parameters = callback_data;
+ NautilusFile *target_file;
+
+ /* Remove from list of files that have to be mounted */
+ parameters->mountables = g_list_remove (parameters->mountables, file);
+ nautilus_file_unref (file);
+
+ if (error == NULL) {
+ /* Replace file with the result of the mount */
+
+ target_file = nautilus_file_get (result_location);
+
+ parameters->files = g_list_remove (parameters->files, file);
+ nautilus_file_unref (file);
+
+ parameters->files = g_list_prepend (parameters->files, target_file);
+ } else {
+ /* Remove failed file */
+
+ if (error->domain != G_IO_ERROR &&
+ error->code != G_IO_ERROR_ALREADY_MOUNTED) {
+ parameters->files = g_list_remove (parameters->files, file);
+ nautilus_file_unref (file);
+ }
+
+ if (error->domain != G_IO_ERROR &&
+ error->code != G_IO_ERROR_CANCELLED &&
+ error->code != G_IO_ERROR_ALREADY_MOUNTED) {
+ eel_show_error_dialog (_("Unable to mount location"),
+ error->message, NULL);
+ }
+ }
+
+ /* Mount more mountables */
+ activation_mount_mountables (parameters);
+}
+
+
+static void
+activation_mount_mountables (ActivateParameters *parameters)
+{
+ NautilusFile *file;
+ GMountOperation *mount_op;
+
+ if (parameters->mountables != NULL) {
+ file = parameters->mountables->data;
+ mount_op = eel_mount_operation_new (parameters->parent_window);
+ g_signal_connect (mount_op, "active_changed", (GCallback)activate_mount_op_active, parameters);
+ nautilus_file_mount (file,
+ mount_op,
+ activation_mountable_mounted,
+ parameters);
+ g_object_unref (mount_op);
+ return;
+ }
+
+ activation_get_activation_uris (parameters);
+}
+
+
+/**
+ * fm_directory_view_activate_files:
+ *
+ * Activate a list of files. Each one might launch with an application or
+ * with a component. This is normally called only by subclasses.
+ * @view: FMDirectoryView in question.
+ * @files: A GList of NautilusFiles to activate.
+ *
+ **/
+void
+nautilus_mime_activate_files (GtkWindow *parent_window,
+ NautilusWindowInfo *window_info,
+ GList *files,
+ const char *launch_directory,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags)
+{
+ ActivateParameters *parameters;
+ char *file_name;
+ int file_count;
+ GList *l, *next;
+ NautilusFile *file;
+
+ if (files == NULL) {
+ return;
+ }
+
+ nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, files,
+ "fm_directory_view_activate_files window=%p",
+ parent_window);
+
+ parameters = g_new0 (ActivateParameters, 1);
+ parameters->window_info = window_info;
+ g_object_add_weak_pointer (G_OBJECT (parameters->window_info), (gpointer *)&parameters->window_info);
+ if (parent_window) {
+ parameters->parent_window = parent_window;
+ g_object_add_weak_pointer (G_OBJECT (parameters->parent_window), (gpointer *)&parameters->parent_window);
+ }
+ parameters->cancellable = g_cancellable_new ();
+ parameters->activation_directory = g_strdup (launch_directory);
+ parameters->files = nautilus_file_list_copy (files);
+ parameters->mode = mode;
+ parameters->flags = flags;
+
+ file_count = g_list_length (files);
+ if (file_count == 1) {
+ file_name = nautilus_file_get_display_name (files->data);
+ parameters->timed_wait_prompt = g_strdup_printf (_("Opening \"%s\"."), file_name);
+ g_free (file_name);
+ } else {
+ parameters->timed_wait_prompt = g_strdup_printf (ngettext ("Opening %d item.",
+ "Opening %d items.",
+ file_count),
+ file_count);
+ }
+
+
+ for (l = parameters->files; l != NULL; l = next) {
+ file = NAUTILUS_FILE (l->data);
+ next = l->next;
+
+ if (nautilus_file_can_mount (file)) {
+ parameters->mountables = g_list_prepend (parameters->mountables,
+ nautilus_file_ref (file));
+ }
+ }
+
+ activation_start_timed_cancel (parameters);
+ activation_mount_mountables (parameters);
+}
+
+/**
+ * fm_directory_view_activate_file:
+ *
+ * Activate a file in this view. This might involve switching the displayed
+ * location for the current window, or launching an application.
+ * @view: FMDirectoryView in question.
+ * @file: A NautilusFile representing the file in this view to activate.
+ * @use_new_window: Should this item be opened in a new window?
+ *
+ **/
+
+void
+nautilus_mime_activate_file (GtkWindow *parent_window,
+ NautilusWindowInfo *window_info,
+ NautilusFile *file,
+ const char *launch_directory,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags)
+{
+ GList *files;
+
+ g_return_if_fail (NAUTILUS_IS_FILE (file));
+
+ files = g_list_prepend (NULL, file);
+ nautilus_mime_activate_files (parent_window, window_info, files, launch_directory, mode, flags);
+ g_list_free (files);
}
diff --git a/libnautilus-private/nautilus-mime-actions.h b/libnautilus-private/nautilus-mime-actions.h
index d108bf7b7..888fc5646 100644
--- a/libnautilus-private/nautilus-mime-actions.h
+++ b/libnautilus-private/nautilus-mime-actions.h
@@ -25,22 +25,36 @@
#ifndef NAUTILUS_MIME_ACTIONS_H
#define NAUTILUS_MIME_ACTIONS_H
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <gio/gappinfo.h>
#include <libnautilus-private/nautilus-file.h>
+#include <libnautilus-private/nautilus-window-info.h>
+
+NautilusFileAttributes nautilus_mime_actions_get_required_file_attributes (void);
+
+GAppInfo * nautilus_mime_get_default_application_for_file (NautilusFile *file);
+GList * nautilus_mime_get_applications_for_file (NautilusFile *file);
+
+GAppInfo * nautilus_mime_get_default_application_for_files (GList *files);
+GList * nautilus_mime_get_applications_for_files (GList *file);
+
+gboolean nautilus_mime_has_any_applications_for_file (NautilusFile *file);
+gboolean nautilus_mime_has_any_applications_for_files (GList *files);
+
+gboolean nautilus_mime_file_opens_in_view (NautilusFile *file);
+gboolean nautilus_mime_file_opens_in_external_app (NautilusFile *file);
+void nautilus_mime_activate_files (GtkWindow *parent_window,
+ NautilusWindowInfo *window_info,
+ GList *files,
+ const char *launch_directory,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags);
+void nautilus_mime_activate_file (GtkWindow *parent_window,
+ NautilusWindowInfo *window_info,
+ NautilusFile *file,
+ const char *launch_directory,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags);
-NautilusFileAttributes nautilus_mime_actions_get_minimum_file_attributes (void);
-NautilusFileAttributes nautilus_mime_actions_get_full_file_attributes (void);
-
-GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_file (NautilusFile *file);
-GList * nautilus_mime_get_open_with_applications_for_file (NautilusFile *file);
-GList * nautilus_mime_get_applications_for_file (NautilusFile *file);
-
-GnomeVFSMimeApplication *nautilus_mime_get_default_application_for_files (GList *files);
-GList * nautilus_mime_get_open_with_applications_for_files (GList *files);
-GList * nautilus_mime_get_applications_for_files (GList *file);
-
-gboolean nautilus_mime_has_any_applications_for_file (NautilusFile *file);
-gboolean nautilus_mime_has_any_applications_for_files (GList *files);
#endif /* NAUTILUS_MIME_ACTIONS_H */
diff --git a/libnautilus-private/nautilus-mime-application-chooser.c b/libnautilus-private/nautilus-mime-application-chooser.c
new file mode 100644
index 000000000..92adbebd9
--- /dev/null
+++ b/libnautilus-private/nautilus-mime-application-chooser.c
@@ -0,0 +1,676 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ nautilus-mime-application-chooser.c: an mime-application chooser
+
+ Copyright (C) 2004 Novell, Inc.
+ Copyright (C) 2007 Red Hat, Inc.
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but APPLICATIONOUT ANY WARRANTY; applicationout even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along application the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: Dave Camp <dave@novell.com>
+ Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+#include "nautilus-mime-application-chooser.h"
+
+#include "nautilus-open-with-dialog.h"
+#include "nautilus-signaller.h"
+#include <eel/eel-stock-dialogs.h>
+#include <eel/eel-glib-extensions.h>
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbox.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkcellrenderertoggle.h>
+#include <gtk/gtkcellrendererpixbuf.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkhbbox.h>
+#include <gtk/gtkimage.h>
+#include <gtk/gtkicontheme.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkliststore.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtktreeview.h>
+#include <gtk/gtktreeselection.h>
+#include <gtk/gtkvbox.h>
+#include <gio/gcontenttype.h>
+#include <gio/gthemedicon.h>
+#include <gio/gfileicon.h>
+
+struct _NautilusMimeApplicationChooserDetails {
+ char *uri;
+
+ char *content_type;
+ char *extension;
+ char *type_description;
+ char *orig_mime_type;
+
+ guint refresh_timeout;
+
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *treeview;
+ GtkWidget *remove_button;
+
+ GtkListStore *model;
+ GtkCellRenderer *toggle_renderer;
+};
+
+enum {
+ COLUMN_APPINFO,
+ COLUMN_DEFAULT,
+ COLUMN_ICON,
+ COLUMN_NAME,
+ NUM_COLUMNS
+};
+
+static void refresh_model (NautilusMimeApplicationChooser *chooser);
+static void refresh_model_soon (NautilusMimeApplicationChooser *chooser);
+
+static gpointer parent_class;
+
+static void
+nautilus_mime_application_chooser_finalize (GObject *object)
+{
+ NautilusMimeApplicationChooser *chooser;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (object);
+
+ if (chooser->details->refresh_timeout) {
+ g_source_remove (chooser->details->refresh_timeout);
+ }
+
+ g_free (chooser->details->uri);
+ g_free (chooser->details->content_type);
+ g_free (chooser->details->extension);
+ g_free (chooser->details->type_description);
+ g_free (chooser->details->orig_mime_type);
+
+ g_free (chooser->details);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+nautilus_mime_application_chooser_destroy (GtkObject *object)
+{
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+static void
+nautilus_mime_application_chooser_class_init (NautilusMimeApplicationChooserClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = nautilus_mime_application_chooser_finalize;
+
+ object_class = GTK_OBJECT_CLASS (class);
+ object_class->destroy = nautilus_mime_application_chooser_destroy;
+}
+
+static void
+default_toggled_cb (GtkCellRendererToggle *renderer,
+ const char *path_str,
+ gpointer user_data)
+{
+ NautilusMimeApplicationChooser *chooser;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GError *error;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);
+
+ path = gtk_tree_path_new_from_string (path_str);
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (chooser->details->model),
+ &iter, path)) {
+ gboolean is_default;
+ gboolean success;
+ GAppInfo *info;
+ char *message;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (chooser->details->model),
+ &iter,
+ COLUMN_DEFAULT, &is_default,
+ COLUMN_APPINFO, &info,
+ -1);
+
+ if (!is_default && info != NULL) {
+ error = NULL;
+ if (chooser->details->extension) {
+ success = g_app_info_set_as_default_for_extension (info,
+ chooser->details->extension,
+ &error);
+ } else {
+ success = g_app_info_set_as_default_for_type (info,
+ chooser->details->content_type,
+ &error);
+ }
+
+ if (!success) {
+ message = g_strdup_printf (_("Could not set application as the default: %s"), error->message);
+ eel_show_error_dialog (_("Could not set as default application"),
+ message,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
+ g_free (message);
+ g_error_free (error);
+ }
+
+ g_signal_emit_by_name (nautilus_signaller_get_current (),
+ "mime_data_changed");
+ }
+ g_object_unref (info);
+ }
+ gtk_tree_path_free (path);
+}
+
+static GAppInfo *
+get_selected_application (NautilusMimeApplicationChooser *chooser)
+{
+ GtkTreeIter iter;
+ GtkTreeSelection *selection;
+ GAppInfo *info;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (chooser->details->treeview));
+
+ info = NULL;
+ if (gtk_tree_selection_get_selected (selection,
+ NULL,
+ &iter)) {
+ gtk_tree_model_get (GTK_TREE_MODEL (chooser->details->model),
+ &iter,
+ COLUMN_APPINFO, &info,
+ -1);
+ }
+
+ return info;
+}
+
+static void
+selection_changed_cb (GtkTreeSelection *selection,
+ gpointer user_data)
+{
+ NautilusMimeApplicationChooser *chooser;
+ GAppInfo *info;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);
+
+ info = get_selected_application (chooser);
+ if (info) {
+ gtk_widget_set_sensitive (chooser->details->remove_button,
+ g_app_info_can_remove_supports_type (info));
+
+ g_object_unref (info);
+ } else {
+ gtk_widget_set_sensitive (chooser->details->remove_button,
+ FALSE);
+ }
+}
+
+static GtkWidget *
+create_tree_view (NautilusMimeApplicationChooser *chooser)
+{
+ GtkWidget *treeview;
+ GtkListStore *store;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ GtkTreeSelection *selection;
+
+ treeview = gtk_tree_view_new ();
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+
+ store = gtk_list_store_new (NUM_COLUMNS,
+ G_TYPE_APP_INFO,
+ G_TYPE_BOOLEAN,
+ GDK_TYPE_PIXBUF,
+ G_TYPE_STRING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ COLUMN_NAME,
+ GTK_SORT_ASCENDING);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),
+ GTK_TREE_MODEL (store));
+ chooser->details->model = store;
+
+ renderer = gtk_cell_renderer_toggle_new ();
+ g_signal_connect (renderer, "toggled",
+ G_CALLBACK (default_toggled_cb),
+ chooser);
+ gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE (renderer),
+ TRUE);
+
+ column = gtk_tree_view_column_new_with_attributes (_("Default"),
+ renderer,
+ "active",
+ COLUMN_DEFAULT,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Icon"),
+ renderer,
+ "pixbuf",
+ COLUMN_ICON,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ chooser->details->toggle_renderer = renderer;
+ renderer = gtk_cell_renderer_text_new ();
+ column = gtk_tree_view_column_new_with_attributes (_("Name"),
+ renderer,
+ "markup",
+ COLUMN_NAME,
+ NULL);
+ gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (selection_changed_cb),
+ chooser);
+
+ return treeview;
+}
+
+static void
+add_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ NautilusMimeApplicationChooser *chooser;
+ GtkWidget *dialog;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);
+
+ dialog = nautilus_add_application_dialog_new (chooser->details->uri,
+ chooser->details->orig_mime_type);
+ gtk_window_set_screen (GTK_WINDOW (dialog),
+ gtk_widget_get_screen (GTK_WIDGET (chooser)));
+ gtk_widget_show (dialog);
+}
+
+static void
+remove_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ NautilusMimeApplicationChooser *chooser;
+ GError *error;
+ GAppInfo *info;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);
+
+ info = get_selected_application (chooser);
+
+ if (info) {
+ error = NULL;
+ if (!g_app_info_remove_supports_type (info,
+ chooser->details->content_type,
+ &error)) {
+ eel_show_error_dialog (_("Could not remove application"),
+ error->message,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
+ g_error_free (error);
+
+ }
+ g_signal_emit_by_name (nautilus_signaller_get_current (),
+ "mime_data_changed");
+ g_object_unref (info);
+ }
+}
+
+static void
+mime_type_data_changed_cb (GObject *signaller,
+ gpointer user_data)
+{
+ NautilusMimeApplicationChooser *chooser;
+
+ chooser = NAUTILUS_MIME_APPLICATION_CHOOSER (user_data);
+
+ refresh_model_soon (chooser);
+}
+
+static void
+nautilus_mime_application_chooser_instance_init (NautilusMimeApplicationChooser *chooser)
+{
+ GtkWidget *box;
+ GtkWidget *scrolled;
+ GtkWidget *button;
+
+ chooser->details = g_new0 (NautilusMimeApplicationChooserDetails, 1);
+
+ gtk_container_set_border_width (GTK_CONTAINER (chooser), 8);
+ gtk_box_set_spacing (GTK_BOX (chooser), 0);
+ gtk_box_set_homogeneous (GTK_BOX (chooser), FALSE);
+
+ chooser->details->label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (chooser->details->label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (chooser->details->label), TRUE);
+ gtk_label_set_line_wrap_mode (GTK_LABEL (chooser->details->label),
+ PANGO_WRAP_WORD_CHAR);
+ gtk_box_pack_start (GTK_BOX (chooser), chooser->details->label,
+ FALSE, FALSE, 0);
+
+ gtk_widget_show (chooser->details->label);
+
+ scrolled = gtk_scrolled_window_new (NULL, NULL);
+
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled),
+ GTK_SHADOW_IN);
+
+ gtk_widget_show (scrolled);
+ gtk_box_pack_start (GTK_BOX (chooser), scrolled, TRUE, TRUE, 6);
+
+ chooser->details->treeview = create_tree_view (chooser);
+ gtk_widget_show (chooser->details->treeview);
+
+ gtk_container_add (GTK_CONTAINER (scrolled),
+ chooser->details->treeview);
+
+ box = gtk_hbutton_box_new ();
+ gtk_box_set_spacing (GTK_BOX (box), 6);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (box), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (GTK_BOX (chooser), box, FALSE, FALSE, 6);
+ gtk_widget_show (box);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_ADD);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (add_clicked_cb),
+ chooser);
+
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (remove_clicked_cb),
+ chooser);
+
+ gtk_widget_show (button);
+ gtk_container_add (GTK_CONTAINER (box), button);
+
+ chooser->details->remove_button = button;
+
+ g_signal_connect (nautilus_signaller_get_current (),
+ "mime_data_changed",
+ G_CALLBACK (mime_type_data_changed_cb),
+ chooser);
+}
+
+static char *
+get_extension (const char *basename)
+{
+ char *p;
+
+ p = strrchr (basename, '.');
+
+ if (p && *(p + 1) != '\0') {
+ return g_strdup (p + 1);
+ } else {
+ return NULL;
+ }
+}
+
+static GdkPixbuf *
+get_pixbuf_for_icon (GIcon *icon)
+{
+ GdkPixbuf *pixbuf;
+ char *filename;
+
+ pixbuf = NULL;
+ if (G_IS_FILE_ICON (icon)) {
+ filename = g_file_get_path (g_file_icon_get_file (G_FILE_ICON (icon)));
+ if (filename) {
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 24, 24, NULL);
+ }
+ g_free (filename);
+ } else if (G_IS_THEMED_ICON (icon)) {
+ const char * const *names;
+ char *icon_no_extension;
+ char *p;
+
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+
+ if (names != NULL && names[0] != NULL) {
+ icon_no_extension = g_strdup (names[0]);
+ p = strrchr (icon_no_extension, '.');
+ if (p &&
+ (strcmp (p, ".png") == 0 ||
+ strcmp (p, ".xpm") == 0 ||
+ strcmp (p, ".svg") == 0)) {
+ *p = 0;
+ }
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon_no_extension, 24, 0, NULL);
+ g_free (icon_no_extension);
+ }
+ }
+ return pixbuf;
+}
+
+static gboolean
+refresh_model_timeout (gpointer data)
+{
+ NautilusMimeApplicationChooser *chooser = data;
+
+ chooser->details->refresh_timeout = 0;
+
+ refresh_model (chooser);
+
+ return FALSE;
+}
+
+/* This adds a slight delay so that we're sure the mime data is
+ done writing */
+static void
+refresh_model_soon (NautilusMimeApplicationChooser *chooser)
+{
+ if (chooser->details->refresh_timeout != 0)
+ return;
+
+ chooser->details->refresh_timeout =
+ g_timeout_add (300,
+ refresh_model_timeout,
+ chooser);
+}
+
+static void
+refresh_model (NautilusMimeApplicationChooser *chooser)
+{
+ GList *applications;
+ GAppInfo *default_app;
+ GList *l;
+ GtkTreeSelection *selection;
+ GtkTreeViewColumn *column;
+
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (chooser->details->treeview), 0);
+ gtk_tree_view_column_set_visible (column, TRUE);
+
+ gtk_list_store_clear (chooser->details->model);
+
+ applications = g_app_info_get_all_for_type (chooser->details->content_type);
+ default_app = g_app_info_get_default_for_type (chooser->details->content_type, FALSE);
+
+ for (l = applications; l != NULL; l = l->next) {
+ GtkTreeIter iter;
+ gboolean is_default;
+ GAppInfo *application;
+ char *escaped;
+ GIcon *icon;
+ GdkPixbuf *pixbuf;
+
+ pixbuf = NULL;
+
+ application = l->data;
+
+ is_default = default_app && g_app_info_equal (default_app, application);
+
+ escaped = g_markup_escape_text (g_app_info_get_name (application), -1);
+
+ icon = g_app_info_get_icon (application);
+
+ if (icon != NULL) {
+ pixbuf = get_pixbuf_for_icon (icon);
+ }
+
+ gtk_list_store_append (chooser->details->model, &iter);
+ gtk_list_store_set (chooser->details->model, &iter,
+ COLUMN_APPINFO, application,
+ COLUMN_DEFAULT, is_default,
+ COLUMN_ICON, pixbuf,
+ COLUMN_NAME, escaped,
+ -1);
+
+ g_free (escaped);
+ if (pixbuf != NULL) {
+ g_object_unref (pixbuf);
+ }
+ }
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (chooser->details->treeview));
+
+ if (applications) {
+ g_object_set (chooser->details->toggle_renderer,
+ "visible", TRUE,
+ NULL);
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ } else {
+ GtkTreeIter iter;
+ char *name;
+
+ gtk_tree_view_column_set_visible (column, FALSE);
+ gtk_list_store_append (chooser->details->model, &iter);
+ name = g_strdup_printf ("<i>%s</i>", _("No applications selected"));
+ gtk_list_store_set (chooser->details->model, &iter,
+ COLUMN_NAME, name,
+ COLUMN_APPINFO, NULL,
+ -1);
+ g_free (name);
+
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
+ }
+
+ if (default_app) {
+ g_object_unref (default_app);
+ }
+
+ eel_g_object_list_free (applications);
+}
+
+static gboolean
+set_uri_and_type (NautilusMimeApplicationChooser *chooser,
+ const char *uri,
+ const char *mime_type)
+{
+ char *label;
+ char *name;
+ char *emname;
+ char *extension;
+ GFile *file;
+
+ chooser->details->uri = g_strdup (uri);
+
+ file = g_file_new_for_uri (uri);
+ name = g_file_get_basename (file);
+ g_object_unref (file);
+
+ chooser->details->orig_mime_type = g_strdup (mime_type);
+
+ extension = get_extension (name);
+ if (extension != NULL &&
+ g_content_type_is_unknown (mime_type)) {
+ chooser->details->extension = g_strdup (extension);
+ chooser->details->content_type = g_strdup_printf ("application/x-extension-%s", extension);
+ /* the %s here is a file extension */
+ chooser->details->type_description =
+ g_strdup_printf (_("%s document"), extension);
+ } else {
+ char *description;
+
+ chooser->details->content_type = g_strdup (mime_type);
+ description = g_content_type_get_description (mime_type);
+
+ if (description == NULL) {
+ description = g_strdup (_("Unknown"));
+ }
+
+ chooser->details->type_description = description;
+ }
+ g_free (extension);
+
+ /* first %s is filename, second %s is mime-type description */
+ emname = g_strdup_printf ("<i>%s</i>", name);
+ label = g_strdup_printf (_("Select an application to open %s and other files of type \"%s\""),
+ emname, chooser->details->type_description);
+ g_free (emname);
+
+ gtk_label_set_markup (GTK_LABEL (chooser->details->label), label);
+
+ g_free (label);
+ g_free (name);
+
+ refresh_model (chooser);
+
+ return TRUE;
+}
+
+GtkWidget *
+nautilus_mime_application_chooser_new (const char *uri,
+ const char *mime_type)
+{
+ GtkWidget *chooser;
+
+ chooser = gtk_widget_new (NAUTILUS_TYPE_MIME_APPLICATION_CHOOSER, NULL);
+
+ set_uri_and_type (NAUTILUS_MIME_APPLICATION_CHOOSER (chooser), uri, mime_type);
+
+ return chooser;
+}
+
+GType
+nautilus_mime_application_chooser_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ const GTypeInfo info = {
+ sizeof (NautilusMimeApplicationChooserClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)nautilus_mime_application_chooser_class_init,
+ NULL,
+ NULL,
+ sizeof (NautilusMimeApplicationChooser),
+ 0,
+ (GInstanceInitFunc)nautilus_mime_application_chooser_instance_init,
+ };
+
+ type = g_type_register_static (GTK_TYPE_VBOX,
+ "NautilusMimeApplicationChooser",
+ &info, 0);
+ }
+
+ return type;
+}
diff --git a/libnautilus-private/nautilus-mime-application-chooser.h b/libnautilus-private/nautilus-mime-application-chooser.h
new file mode 100644
index 000000000..ec8547fd6
--- /dev/null
+++ b/libnautilus-private/nautilus-mime-application-chooser.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ nautilus-mime-application-chooser.c: Manages applications for mime types
+
+ Copyright (C) 2004 Novell, Inc.
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but APPLICATIONOUT ANY WARRANTY; applicationout even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along application the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: Dave Camp <dave@novell.com>
+*/
+
+#ifndef NAUTILUS_MIME_APPLICATION_CHOOSER_H
+#define NAUTILUS_MIME_APPLICATION_CHOOSER_H
+
+#include <gtk/gtkvbox.h>
+
+#define NAUTILUS_TYPE_MIME_APPLICATION_CHOOSER (nautilus_mime_application_chooser_get_type ())
+#define NAUTILUS_MIME_APPLICATION_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_MIME_APPLICATION_CHOOSER, NautilusMimeApplicationChooser))
+#define NAUTILUS_MIME_APPLICATION_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_MIME_APPLICATION_CHOOSER, NautilusMimeApplicationChooserClass))
+#define NAUTILUS_IS_MIME_APPLICATION_CHOOSER(obj) (G_TYPE_INSTANCE_CHECK_TYPE ((obj), NAUTILUS_TYPE_MIME_APPLICATION_CHOOSER)
+
+typedef struct _NautilusMimeApplicationChooser NautilusMimeApplicationChooser;
+typedef struct _NautilusMimeApplicationChooserClass NautilusMimeApplicationChooserClass;
+typedef struct _NautilusMimeApplicationChooserDetails NautilusMimeApplicationChooserDetails;
+
+struct _NautilusMimeApplicationChooser {
+ GtkVBox parent;
+ NautilusMimeApplicationChooserDetails *details;
+};
+
+struct _NautilusMimeApplicationChooserClass {
+ GtkVBoxClass parent_class;
+};
+
+GType nautilus_mime_application_chooser_get_type (void);
+GtkWidget* nautilus_mime_application_chooser_new (const char *uri,
+ const char *mime_type);
+
+#endif /* NAUTILUS_MIME_APPLICATION_CHOOSER_H */
diff --git a/libnautilus-private/nautilus-monitor.c b/libnautilus-private/nautilus-monitor.c
index 2a38bf7de..63c07e327 100644
--- a/libnautilus-private/nautilus-monitor.c
+++ b/libnautilus-private/nautilus-monitor.c
@@ -29,13 +29,11 @@
#include "nautilus-file-changes-queue.h"
#include "nautilus-file-utilities.h"
+#include <gio/gdirectorymonitor.h>
#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
struct NautilusMonitor {
- GnomeVFSMonitorHandle *handle;
+ GDirectoryMonitor *monitor;
};
gboolean
@@ -43,49 +41,25 @@ nautilus_monitor_active (void)
{
static gboolean tried_monitor = FALSE;
static gboolean monitor_success;
- char *desktop_directory, *uri;
- NautilusMonitor *monitor;
+ GDirectoryMonitor *dir_monitor;
+ GFile *file;
if (tried_monitor == FALSE) {
- desktop_directory = nautilus_get_desktop_directory ();
- uri = gnome_vfs_get_uri_from_local_path (desktop_directory);
-
- monitor = nautilus_monitor_directory (uri);
- monitor_success = (monitor != NULL);
-
- if (monitor != NULL) {
- nautilus_monitor_cancel (monitor);
+ file = g_file_new_for_path (g_get_home_dir ());
+ dir_monitor = g_file_monitor_directory (file, G_FILE_MONITOR_FLAGS_NONE, NULL);
+ g_object_unref (file);
+
+ monitor_success = (dir_monitor != NULL);
+ if (dir_monitor) {
+ g_object_unref (dir_monitor);
}
- g_free (desktop_directory);
- g_free (uri);
-
tried_monitor = TRUE;
}
return monitor_success;
}
-static gboolean
-path_is_on_readonly_volume (const char *path)
-{
- GnomeVFSVolumeMonitor *volume_monitor;
- GnomeVFSVolume *volume;
- gboolean res;
-
- g_assert (path != NULL);
-
- volume_monitor = gnome_vfs_get_volume_monitor ();
- volume = gnome_vfs_volume_monitor_get_volume_for_path (volume_monitor,
- path);
- res = FALSE;
- if (volume != NULL) {
- res = gnome_vfs_volume_is_read_only (volume);
- gnome_vfs_volume_unref (volume);
- }
- return res;
-}
-
static gboolean call_consume_changes_idle_id = 0;
static gboolean
@@ -96,92 +70,81 @@ call_consume_changes_idle_cb (gpointer not_used)
return FALSE;
}
-static void
-monitor_notify_cb (GnomeVFSMonitorHandle *handle,
- const gchar *monitor_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer user_data)
+static void
+dir_changed (GDirectoryMonitor* monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
{
+ char *uri, *to_uri;
+
+ uri = g_file_get_uri (child);
+ to_uri = NULL;
+ if (other_file) {
+ to_uri = g_file_get_uri (other_file);
+ }
+
switch (event_type) {
- case GNOME_VFS_MONITOR_EVENT_CHANGED:
- nautilus_file_changes_queue_file_changed (info_uri);
+ default:
+ case G_FILE_MONITOR_EVENT_CHANGED:
+ /* ignore */
break;
- case GNOME_VFS_MONITOR_EVENT_DELETED:
- nautilus_file_changes_queue_schedule_metadata_remove (info_uri);
- nautilus_file_changes_queue_file_removed (info_uri);
+ case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ nautilus_file_changes_queue_file_changed (child);
break;
- case GNOME_VFS_MONITOR_EVENT_CREATED:
- nautilus_file_changes_queue_file_added (info_uri);
+ case G_FILE_MONITOR_EVENT_DELETED:
+ nautilus_file_changes_queue_file_removed (child);
break;
-
- /* None of the following are supported yet */
- case GNOME_VFS_MONITOR_EVENT_STARTEXECUTING:
- case GNOME_VFS_MONITOR_EVENT_STOPEXECUTING:
- case GNOME_VFS_MONITOR_EVENT_METADATA_CHANGED:
+ case G_FILE_MONITOR_EVENT_CREATED:
+ nautilus_file_changes_queue_file_added (child);
+ break;
+
+ case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
+ /* TODO: Do something */
+ break;
+ case G_FILE_MONITOR_EVENT_UNMOUNTED:
+ /* TODO: Do something */
break;
}
+ g_free (uri);
+ g_free (to_uri);
+
if (call_consume_changes_idle_id == 0) {
call_consume_changes_idle_id =
g_idle_add (call_consume_changes_idle_cb, NULL);
}
}
-
-static NautilusMonitor *
-monitor_add_internal (const char *uri, gboolean is_directory)
+
+NautilusMonitor *
+nautilus_monitor_directory (GFile *location)
{
- gchar *path;
+ GDirectoryMonitor *dir_monitor;
NautilusMonitor *ret;
- GnomeVFSResult result;
- path = gnome_vfs_get_local_path_from_uri (uri);
+ dir_monitor = g_file_monitor_directory (location, G_FILE_MONITOR_FLAGS_MONITOR_MOUNTS, NULL);
- /*
- * Don't monitor URIs on a read-only volume.
- * This is a hack to avoid FAM keeping open fds to CD-ROMs,
- * causing unmount/eject to fail.
- */
- if (path != NULL && path_is_on_readonly_volume (path) == TRUE) {
- g_free (path);
+ if (dir_monitor == NULL) {
return NULL;
}
- g_free (path);
ret = g_new0 (NautilusMonitor, 1);
+ ret->monitor = dir_monitor;
- result = gnome_vfs_monitor_add (&ret->handle,
- uri,
- is_directory == TRUE ?
- GNOME_VFS_MONITOR_DIRECTORY :
- GNOME_VFS_MONITOR_FILE,
- monitor_notify_cb,
- NULL);
- if (result != GNOME_VFS_OK) {
- g_free (ret);
- return NULL;
- }
+ g_signal_connect (ret->monitor, "changed", (GCallback)dir_changed, ret);
return ret;
}
-NautilusMonitor *
-nautilus_monitor_directory (const char *uri)
-{
- return monitor_add_internal (uri, TRUE);
-}
-
-NautilusMonitor *
-nautilus_monitor_file (const char *uri)
-{
- return monitor_add_internal (uri, FALSE);
-}
-
void
nautilus_monitor_cancel (NautilusMonitor *monitor)
{
- if (monitor->handle != NULL) {
- gnome_vfs_monitor_cancel (monitor->handle);
+ if (monitor->monitor != NULL) {
+ g_signal_handlers_disconnect_by_func (monitor->monitor, dir_changed, monitor);
+ g_directory_monitor_cancel (monitor->monitor);
+ g_object_unref (monitor->monitor);
}
g_free (monitor);
diff --git a/libnautilus-private/nautilus-monitor.h b/libnautilus-private/nautilus-monitor.h
index df85a4901..17781eebd 100644
--- a/libnautilus-private/nautilus-monitor.h
+++ b/libnautilus-private/nautilus-monitor.h
@@ -27,12 +27,12 @@
#define NAUTILUS_MONITOR_H
#include <glib/gtypes.h>
+#include <gio/gfile.h>
typedef struct NautilusMonitor NautilusMonitor;
gboolean nautilus_monitor_active (void);
-NautilusMonitor *nautilus_monitor_file (const char *uri);
-NautilusMonitor *nautilus_monitor_directory (const char *uri);
+NautilusMonitor *nautilus_monitor_directory (GFile *location);
void nautilus_monitor_cancel (NautilusMonitor *monitor);
#endif /* NAUTILUS_MONITOR_H */
diff --git a/libnautilus-private/nautilus-open-with-dialog.c b/libnautilus-private/nautilus-open-with-dialog.c
new file mode 100644
index 000000000..efebec17d
--- /dev/null
+++ b/libnautilus-private/nautilus-open-with-dialog.c
@@ -0,0 +1,982 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ eel-open-with-dialog.c: an open-with dialog
+
+ Copyright (C) 2004 Novell, Inc.
+ Copyright (C) 2007 Red Hat, Inc.
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: Dave Camp <dave@novell.com>
+ Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+#include "nautilus-open-with-dialog.h"
+#include "nautilus-signaller.h"
+
+#include <eel/eel-stock-dialogs.h>
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtkalignment.h>
+#include <gtk/gtkbox.h>
+#include <gtk/gtkexpander.h>
+#include <gtk/gtkbutton.h>
+#include <gtk/gtkdialog.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkfilechooserdialog.h>
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkicontheme.h>
+#include <gtk/gtkiconfactory.h>
+#include <gtk/gtklabel.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkstock.h>
+#include <gtk/gtktreeview.h>
+#include <gtk/gtktreeselection.h>
+#include <gtk/gtkcellrenderertext.h>
+#include <gtk/gtkcellrendererpixbuf.h>
+#include <gtk/gtkvbox.h>
+#include <gio/gcontenttype.h>
+#include <gio/gthemedicon.h>
+#include <gio/gfileicon.h>
+
+#define sure_string(s) ((const char *)((s)!=NULL?(s):""))
+#define DESKTOP_ENTRY_GROUP "Desktop Entry"
+
+struct _NautilusOpenWithDialogDetails {
+ GAppInfo *selected_app_info;
+
+ char *content_type;
+ char *extension;
+ char *type_description;
+
+ GtkWidget *label;
+ GtkWidget *entry;
+ GtkWidget *button;
+
+ GtkWidget *desc_label;
+
+ GtkWidget *open_label;
+
+ GtkWidget *program_list;
+ GtkListStore *program_list_store;
+ GSList *add_icon_paths;
+ gint add_items_idle_id;
+ gint add_icons_idle_id;
+};
+
+enum {
+ COLUMN_APP_INFO,
+ COLUMN_ICON,
+ COLUMN_GICON,
+ COLUMN_NAME,
+ COLUMN_COMMENT,
+ COLUMN_EXEC,
+ NUM_COLUMNS
+};
+
+enum {
+ RESPONSE_OPEN
+};
+
+enum {
+ APPLICATION_SELECTED,
+ LAST_SIGNAL
+};
+
+static gpointer parent_class;
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+nautilus_open_with_dialog_finalize (GObject *object)
+{
+ NautilusOpenWithDialog *dialog;
+
+ dialog = NAUTILUS_OPEN_WITH_DIALOG (object);
+
+ if (dialog->details->add_icons_idle_id) {
+ g_source_remove (dialog->details->add_icons_idle_id);
+ }
+
+ if (dialog->details->add_items_idle_id) {
+ g_source_remove (dialog->details->add_items_idle_id);
+ }
+
+ if (dialog->details->selected_app_info) {
+ g_object_unref (dialog->details->selected_app_info);
+ }
+ g_free (dialog->details->content_type);
+ g_free (dialog->details->extension);
+ g_free (dialog->details->type_description);
+
+ g_free (dialog->details);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+nautilus_open_with_dialog_destroy (GtkObject *object)
+{
+ GTK_OBJECT_CLASS (parent_class)->destroy (object);
+}
+
+/* An application is valid if:
+ *
+ * 1) The file exists
+ * 2) The user has permissions to run the file
+ */
+static gboolean
+check_application (NautilusOpenWithDialog *dialog)
+{
+ char *command;
+ char *path = NULL;
+ char **argv = NULL;
+ int argc;
+ GError *error = NULL;
+ gint retval = TRUE;
+
+ command = NULL;
+ if (dialog->details->selected_app_info != NULL) {
+ command = g_strdup (g_app_info_get_executable (dialog->details->selected_app_info));
+ }
+
+ if (command == NULL) {
+ command = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->details->entry)));
+ }
+
+ g_shell_parse_argv (command, &argc, &argv, &error);
+ if (error) {
+ eel_show_error_dialog (_("Could not run application"),
+ error->message,
+ GTK_WINDOW (dialog));
+ g_error_free (error);
+ retval = FALSE;
+ goto cleanup;
+ }
+
+ path = g_find_program_in_path (argv[0]);
+ if (!path) {
+ char *error_message;
+
+ error_message = g_strdup_printf (_("Could not find '%s'"),
+ argv[0]);
+
+ eel_show_error_dialog (_("Could not find application"),
+ error_message,
+ GTK_WINDOW (dialog));
+ g_free (error_message);
+ retval = FALSE;
+ goto cleanup;
+ }
+
+ cleanup:
+ g_strfreev (argv);
+ g_free (path);
+ g_free (command);
+
+ return retval;
+}
+
+/* Only called for non-desktop files */
+static char *
+get_app_name (const char *commandline, GError **error)
+{
+ char *basename;
+ char *unquoted;
+ char **argv;
+ int argc;
+
+ if (!g_shell_parse_argv (commandline,
+ &argc, &argv, error)) {
+ return NULL;
+ }
+
+ unquoted = g_shell_unquote (argv[0], NULL);
+ if (unquoted) {
+ basename = g_path_get_basename (unquoted);
+ } else {
+ basename = g_strdup (argv[0]);
+ }
+
+ g_free (unquoted);
+ g_strfreev (argv);
+
+ return basename;
+}
+
+/* This will check if the application the user wanted exists will return that
+ * application. If it doesn't exist, it will create one and return that.
+ * It also sets the app info as the default for this type.
+ */
+static GAppInfo *
+add_or_find_application (NautilusOpenWithDialog *dialog)
+{
+ GAppInfo *app;
+ char *app_name;
+ const char *commandline;
+ GError *error;
+ gboolean success;
+ char *message;
+
+ error = NULL;
+ app = NULL;
+ if (dialog->details->selected_app_info) {
+ app = g_object_ref (dialog->details->selected_app_info);
+ } else {
+ commandline = gtk_entry_get_text (GTK_ENTRY (dialog->details->entry));
+ app_name = get_app_name (commandline, &error);
+ if (app_name != NULL) {
+ app = g_app_info_create_from_commandline (commandline,
+ app_name,
+ G_APP_INFO_CREATE_FLAGS_NONE,
+ &error);
+ }
+ }
+
+ if (app == NULL) {
+ message = g_strdup_printf (_("Could not add application to the application database: %s"), error->message);
+ eel_show_error_dialog (_("Could not add application"),
+ message,
+ GTK_WINDOW (dialog));
+ g_free (message);
+ g_error_free (error);
+ return NULL;
+ }
+
+
+ if (dialog->details->content_type) {
+ success = g_app_info_set_as_default_for_type (app,
+ dialog->details->content_type,
+ &error);
+ } else {
+ success = g_app_info_set_as_default_for_extension (app,
+ dialog->details->extension,
+ &error);
+ }
+
+ if (!success) {
+ message = g_strdup_printf (_("Could not set application as the default: %s"), error->message);
+ eel_show_error_dialog (_("Could not set as default application"),
+ message,
+ GTK_WINDOW (dialog));
+ g_free (message);
+ g_error_free (error);
+ }
+
+ g_signal_emit_by_name (nautilus_signaller_get_current (),
+ "mime_data_changed");
+
+ return app;
+}
+
+static void
+emit_application_selected (NautilusOpenWithDialog *dialog,
+ GAppInfo *application)
+{
+ g_signal_emit (G_OBJECT (dialog), signals[APPLICATION_SELECTED], 0,
+ application);
+}
+
+static void
+response_cb (NautilusOpenWithDialog *dialog,
+ int response_id,
+ gpointer data)
+{
+ GAppInfo *application;
+
+ switch (response_id) {
+ case RESPONSE_OPEN:
+ if (check_application (dialog)) {
+ application = add_or_find_application (dialog);
+
+ if (application) {
+ emit_application_selected (dialog, application);
+ g_object_unref (application);
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ }
+ }
+
+ break;
+ case GTK_RESPONSE_NONE:
+ case GTK_RESPONSE_DELETE_EVENT:
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+ default :
+ g_assert_not_reached ();
+ }
+
+}
+
+
+static void
+nautilus_open_with_dialog_class_init (NautilusOpenWithDialogClass *class)
+{
+ GObjectClass *gobject_class;
+ GtkObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ gobject_class = G_OBJECT_CLASS (class);
+ gobject_class->finalize = nautilus_open_with_dialog_finalize;
+
+ object_class = GTK_OBJECT_CLASS (class);
+ object_class->destroy = nautilus_open_with_dialog_destroy;
+
+ signals[APPLICATION_SELECTED] =
+ g_signal_new ("application_selected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusOpenWithDialogClass,
+ application_selected),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+}
+
+static void
+chooser_response_cb (GtkFileChooser *chooser,
+ int response,
+ gpointer user_data)
+{
+ NautilusOpenWithDialog *dialog;
+
+ dialog = NAUTILUS_OPEN_WITH_DIALOG (user_data);
+
+ if (response == GTK_RESPONSE_OK) {
+ char *filename;
+
+ filename = gtk_file_chooser_get_filename (chooser);
+
+ if (filename) {
+ char *quoted_text;
+
+ quoted_text = g_shell_quote (filename);
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->details->entry),
+ quoted_text);
+ gtk_entry_set_position (GTK_ENTRY (dialog->details->entry), -1);
+ g_free (quoted_text);
+ g_free (filename);
+ }
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (chooser));
+}
+
+static void
+browse_clicked_cb (GtkWidget *button,
+ gpointer user_data)
+{
+ NautilusOpenWithDialog *dialog;
+ GtkWidget *chooser;
+
+ dialog = NAUTILUS_OPEN_WITH_DIALOG (user_data);
+
+ chooser = gtk_file_chooser_dialog_new (_("Select an Application"),
+ GTK_WINDOW (dialog),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN,
+ GTK_RESPONSE_OK,
+ NULL);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser), TRUE);
+ g_signal_connect (chooser, "response",
+ G_CALLBACK (chooser_response_cb), dialog);
+ gtk_dialog_set_default_response (GTK_DIALOG (chooser),
+ GTK_RESPONSE_OK);
+ gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
+ gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser),
+ FALSE);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser),
+ "/usr/bin");
+
+ gtk_widget_show (chooser);
+}
+
+static void
+entry_changed_cb (GtkWidget *entry,
+ NautilusOpenWithDialog *dialog)
+{
+ /* We are writing in the entry, so we are not using a known appinfo anymore */
+ if (dialog->details->selected_app_info != NULL) {
+ g_object_unref (dialog->details->selected_app_info);
+ dialog->details->selected_app_info = NULL;
+ }
+
+ if (gtk_entry_get_text (GTK_ENTRY (dialog->details->entry))[0] == '\000') {
+ gtk_widget_set_sensitive (dialog->details->button, FALSE);
+ } else {
+ gtk_widget_set_sensitive (dialog->details->button, TRUE);
+ }
+}
+
+static GdkPixbuf *
+get_pixbuf_for_icon (GIcon *icon)
+{
+ GdkPixbuf *pixbuf;
+ char *filename;
+
+ pixbuf = NULL;
+ if (G_IS_FILE_ICON (icon)) {
+ filename = g_file_get_path (g_file_icon_get_file (G_FILE_ICON (icon)));
+ if (filename) {
+ pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 24, 24, NULL);
+ }
+ g_free (filename);
+ } else if (G_IS_THEMED_ICON (icon)) {
+ const char * const *names;
+ char *icon_no_extension;
+ char *p;
+
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+
+ if (names != NULL && names[0] != NULL) {
+ icon_no_extension = g_strdup (names[0]);
+ p = strrchr (icon_no_extension, '.');
+ if (p &&
+ (strcmp (p, ".png") == 0 ||
+ strcmp (p, ".xpm") == 0 ||
+ strcmp (p, ".svg") == 0)) {
+ *p = 0;
+ }
+ pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+ icon_no_extension, 24, 0, NULL);
+ g_free (icon_no_extension);
+ }
+ }
+ return pixbuf;
+}
+
+static gboolean
+nautilus_open_with_dialog_add_icon_idle (NautilusOpenWithDialog *dialog)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GdkPixbuf *pixbuf;
+ GIcon *icon;
+ gboolean long_operation;
+
+ long_operation = FALSE;
+ do {
+ if (!dialog->details->add_icon_paths) {
+ dialog->details->add_icons_idle_id = 0;
+ return FALSE;
+ }
+
+ path = dialog->details->add_icon_paths->data;
+ dialog->details->add_icon_paths->data = NULL;
+ dialog->details->add_icon_paths = g_slist_delete_link (dialog->details->add_icon_paths,
+ dialog->details->add_icon_paths);
+
+ if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->details->program_list_store),
+ &iter, path)) {
+ gtk_tree_path_free (path);
+ continue;
+ }
+
+ gtk_tree_path_free (path);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (dialog->details->program_list_store), &iter,
+ COLUMN_GICON, &icon, -1);
+
+ if (icon == NULL) {
+ continue;
+ }
+
+ pixbuf = get_pixbuf_for_icon (icon);
+ if (pixbuf) {
+ long_operation = TRUE;
+ gtk_list_store_set (dialog->details->program_list_store, &iter, COLUMN_ICON, pixbuf, -1);
+ g_object_unref (pixbuf);
+ }
+
+ /* don't go back into the main loop if this wasn't very hard to do */
+ } while (!long_operation);
+
+ return TRUE;
+}
+
+
+static gboolean
+nautilus_open_with_search_equal_func (GtkTreeModel *model,
+ int column,
+ const char *key,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ char *normalized_key;
+ char *name, *normalized_name;
+ char *path, *normalized_path;
+ char *basename, *normalized_basename;
+ gboolean ret;
+
+ if (key != NULL) {
+ normalized_key = g_utf8_casefold (key, -1);
+ g_assert (normalized_key != NULL);
+
+ ret = TRUE;
+
+ gtk_tree_model_get (model, iter,
+ COLUMN_NAME, &name,
+ COLUMN_EXEC, &path,
+ -1);
+
+ if (name != NULL) {
+ normalized_name = g_utf8_casefold (name, -1);
+ g_assert (normalized_name != NULL);
+
+ if (strncmp (normalized_name, normalized_key, strlen (normalized_key)) == 0) {
+ ret = FALSE;
+ }
+
+ g_free (normalized_name);
+ }
+
+ if (ret && path != NULL) {
+ normalized_path = g_utf8_casefold (path, -1);
+ g_assert (normalized_path != NULL);
+
+ basename = g_path_get_basename (path);
+ g_assert (basename != NULL);
+
+ normalized_basename = g_utf8_casefold (basename, -1);
+ g_assert (normalized_basename != NULL);
+
+ if (strncmp (normalized_path, normalized_key, strlen (normalized_key)) == 0 ||
+ strncmp (normalized_basename, normalized_key, strlen (normalized_key)) == 0) {
+ ret = FALSE;
+ }
+
+ g_free (basename);
+ g_free (normalized_basename);
+ g_free (normalized_path);
+ }
+
+ g_free (name);
+ g_free (path);
+ g_free (normalized_key);
+
+ return ret;
+ } else {
+ return TRUE;
+ }
+}
+
+
+
+static gboolean
+nautilus_open_with_dialog_add_items_idle (NautilusOpenWithDialog *dialog)
+{
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ GList *all_applications;
+ GList *l;
+ const char *prev_name;
+
+ /* create list store */
+ dialog->details->program_list_store = gtk_list_store_new (NUM_COLUMNS,
+ G_TYPE_APP_INFO,
+ GDK_TYPE_PIXBUF,
+ G_TYPE_ICON,
+ G_TYPE_STRING,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
+ all_applications = g_app_info_get_all ();
+
+ prev_name = NULL;
+ for (l = all_applications; l; l = l->next) {
+ GAppInfo *app = l->data;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ gtk_list_store_append (dialog->details->program_list_store, &iter);
+ gtk_list_store_set (dialog->details->program_list_store, &iter,
+ COLUMN_APP_INFO, app,
+ COLUMN_ICON, NULL,
+ COLUMN_GICON, g_app_info_get_icon (app),
+ COLUMN_NAME, g_app_info_get_name (app),
+ COLUMN_COMMENT, g_app_info_get_description (app),
+ COLUMN_EXEC, g_app_info_get_executable,
+ -1);
+
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->details->program_list_store), &iter);
+ if (path != NULL) {
+ dialog->details->add_icon_paths = g_slist_prepend (dialog->details->add_icon_paths, path);
+ }
+ }
+ g_list_free (all_applications);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->details->program_list),
+ GTK_TREE_MODEL (dialog->details->program_list_store));
+ gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (dialog->details->program_list),
+ nautilus_open_with_search_equal_func,
+ NULL, NULL);
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ column = gtk_tree_view_column_new ();
+ gtk_tree_view_column_pack_start (column, renderer, FALSE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "pixbuf", COLUMN_ICON,
+ NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer,
+ "text", COLUMN_NAME,
+ NULL);
+
+ gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->details->program_list), column);
+
+ dialog->details->add_icon_paths = g_slist_reverse (dialog->details->add_icon_paths);
+
+ if (!dialog->details->add_icons_idle_id) {
+ dialog->details->add_icons_idle_id =
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, (GSourceFunc) nautilus_open_with_dialog_add_icon_idle,
+ dialog, NULL);
+ }
+
+ dialog->details->add_items_idle_id = 0;
+ return FALSE;
+}
+
+static void
+program_list_selection_changed (GtkTreeSelection *selection,
+ NautilusOpenWithDialog *dialog)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GAppInfo *info;
+
+ if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+ gtk_widget_set_sensitive (dialog->details->button, FALSE);
+ return;
+ }
+
+ info = NULL;
+ gtk_tree_model_get (model, &iter,
+ COLUMN_APP_INFO, &info,
+ -1);
+
+ if (info == NULL) {
+ return;
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (dialog->details->entry),
+ sure_string (g_app_info_get_executable (info)));
+ gtk_label_set_text (GTK_LABEL (dialog->details->desc_label),
+ sure_string (g_app_info_get_description (info)));
+ gtk_widget_set_sensitive (dialog->details->button, TRUE);
+
+ if (dialog->details->selected_app_info) {
+ g_object_unref (dialog->details->selected_app_info);
+ }
+
+ dialog->details->selected_app_info = info;
+}
+
+static void
+program_list_selection_activated (GtkTreeView *view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ NautilusOpenWithDialog *dialog)
+{
+ GtkTreeSelection *selection;
+
+ /* update the entry with the info from the selection */
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->details->program_list));
+ program_list_selection_changed (selection, dialog);
+
+ gtk_dialog_response (GTK_DIALOG (&dialog->parent), RESPONSE_OPEN);
+}
+
+static void
+expander_toggled (GtkWidget *expander, NautilusOpenWithDialog *dialog)
+{
+ if (gtk_expander_get_expanded (GTK_EXPANDER (expander)) == TRUE) {
+ gtk_widget_grab_focus (dialog->details->entry);
+ gtk_window_resize (GTK_WINDOW (dialog), 400, 1);
+ } else {
+ GtkTreeSelection *selection;
+
+ gtk_widget_grab_focus (dialog->details->program_list);
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->details->program_list));
+ program_list_selection_changed (selection, dialog);
+ }
+}
+
+static void
+nautilus_open_with_dialog_instance_init (NautilusOpenWithDialog *dialog)
+{
+ GtkWidget *hbox;
+ GtkWidget *vbox;
+ GtkWidget *vbox2;
+ GtkWidget *label;
+ GtkWidget *align;
+ GtkWidget *scrolled_window;
+ GtkWidget *expander;
+ GtkTreeSelection *selection;
+
+ dialog->details = g_new0 (NautilusOpenWithDialogDetails, 1);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Open With"));
+ gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+ gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+ gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
+
+ gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 5);
+
+ vbox2 = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (vbox), vbox2, TRUE, TRUE, 0);
+
+ dialog->details->label = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (dialog->details->label), 0.0, 0.5);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->details->label), TRUE);
+ gtk_box_pack_start (GTK_BOX (vbox2), dialog->details->label,
+ FALSE, FALSE, 0);
+ gtk_widget_show (dialog->details->label);
+
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_widget_set_size_request (scrolled_window, 400, 300);
+
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ dialog->details->program_list = gtk_tree_view_new ();
+ gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->details->program_list),
+ FALSE);
+ gtk_container_add (GTK_CONTAINER (scrolled_window), dialog->details->program_list);
+
+ gtk_box_pack_start (GTK_BOX (vbox2), scrolled_window, TRUE, TRUE, 0);
+
+ dialog->details->desc_label = gtk_label_new (_("Select an application to view its description."));
+ gtk_misc_set_alignment (GTK_MISC (dialog->details->desc_label), 0.0, 0.5);
+ gtk_label_set_justify (GTK_LABEL (dialog->details->desc_label), GTK_JUSTIFY_LEFT);
+ gtk_label_set_line_wrap (GTK_LABEL (dialog->details->desc_label), TRUE);
+ gtk_label_set_single_line_mode (GTK_LABEL (dialog->details->desc_label), FALSE);
+ gtk_box_pack_start (GTK_BOX (vbox2), dialog->details->desc_label, FALSE, FALSE, 0);
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->details->program_list));
+ gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
+ g_signal_connect (selection, "changed",
+ G_CALLBACK (program_list_selection_changed),
+ dialog);
+ g_signal_connect (dialog->details->program_list, "row-activated",
+ G_CALLBACK (program_list_selection_activated),
+ dialog);
+
+ dialog->details->add_items_idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ (GSourceFunc) nautilus_open_with_dialog_add_items_idle,
+ dialog, NULL);
+
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_widget_show_all (vbox);
+
+
+ expander = gtk_expander_new_with_mnemonic (_("_Use a custom command"));
+ gtk_box_pack_start (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
+ g_signal_connect_after (expander, "activate", G_CALLBACK (expander_toggled), dialog);
+
+ gtk_widget_show (expander);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_container_add (GTK_CONTAINER (expander), hbox);
+ gtk_widget_show (hbox);
+
+ dialog->details->entry = gtk_entry_new ();
+ gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->entry), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->details->entry,
+ TRUE, TRUE, 0);
+ gtk_widget_show (dialog->details->entry);
+
+ dialog->details->button = gtk_button_new_with_mnemonic (_("_Browse..."));
+ g_signal_connect (dialog->details->button, "clicked",
+ G_CALLBACK (browse_clicked_cb), dialog);
+ gtk_box_pack_start (GTK_BOX (hbox), dialog->details->button, FALSE, FALSE, 0);
+ gtk_widget_show (dialog->details->button);
+
+ gtk_dialog_add_button (GTK_DIALOG (dialog),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+
+
+ /* Create a custom stock icon */
+ dialog->details->button = gtk_button_new ();
+
+ /* Hook up the entry to the button */
+ gtk_widget_set_sensitive (dialog->details->button, FALSE);
+ g_signal_connect (G_OBJECT (dialog->details->entry), "changed",
+ G_CALLBACK (entry_changed_cb), dialog);
+
+ hbox = gtk_hbox_new (FALSE, 2);
+ gtk_widget_show (hbox);
+
+ label = gtk_label_new_with_mnemonic (_("_Open"));
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), GTK_WIDGET (dialog->details->button));
+ gtk_widget_show (label);
+ dialog->details->open_label = label;
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ gtk_widget_show (align);
+
+ gtk_widget_show (dialog->details->button);
+ GTK_WIDGET_SET_FLAGS (dialog->details->button, GTK_CAN_DEFAULT);
+
+
+ gtk_container_add (GTK_CONTAINER (align), hbox);
+ gtk_container_add (GTK_CONTAINER (dialog->details->button), align);
+
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
+ dialog->details->button, RESPONSE_OPEN);
+
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+ RESPONSE_OPEN);
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (response_cb),
+ dialog);
+}
+
+static char *
+get_extension (const char *basename)
+{
+ char *p;
+
+ p = strrchr (basename, '.');
+
+ if (p && *(p + 1) != '\0') {
+ return g_strdup (p + 1);
+ } else {
+ return NULL;
+ }
+}
+
+static void
+set_uri_and_type (NautilusOpenWithDialog *dialog,
+ const char *uri,
+ const char *mime_type)
+{
+ char *label;
+ char *name;
+ char *emname;
+ GFile *file;
+ char *extension;
+ const char *description;
+
+ file = g_file_new_for_uri (uri);
+ name = g_file_get_basename (file);
+ g_object_unref (file);
+
+ extension = get_extension (name);
+ if (extension != NULL &&
+ g_content_type_is_unknown (mime_type)) {
+ dialog->details->extension = g_strdup (extension);
+ /* the %s here is a file extension */
+ dialog->details->type_description =
+ g_strdup_printf (_("%s document"), extension);
+ } else {
+ dialog->details->content_type = g_strdup (mime_type);
+ description = g_content_type_get_description (mime_type);
+
+ if (description == NULL) {
+ description = _("Unknown");
+ }
+
+ dialog->details->type_description = g_strdup (description);
+ }
+ g_free (extension);
+
+ emname = g_strdup_printf ("<i>%s</i>", name);
+ label = g_strdup_printf (_("Open %s and other files of type \"%s\" with:"), emname, dialog->details->type_description);
+ g_free (emname);
+
+ gtk_label_set_markup (GTK_LABEL (dialog->details->label), label);
+
+ g_free (label);
+ g_free (name);
+}
+
+GtkWidget *
+nautilus_open_with_dialog_new (const char *uri,
+ const char *mime_type)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_widget_new (NAUTILUS_TYPE_OPEN_WITH_DIALOG, NULL);
+
+ set_uri_and_type (NAUTILUS_OPEN_WITH_DIALOG (dialog), uri, mime_type);
+
+ return dialog;
+}
+
+GtkWidget*
+nautilus_add_application_dialog_new (const char *uri,
+ const char *mime_type)
+{
+ NautilusOpenWithDialog *dialog;
+
+ dialog = NAUTILUS_OPEN_WITH_DIALOG (nautilus_open_with_dialog_new (uri, mime_type));
+
+ gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->details->open_label),
+ _("_Add"));
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Add Application"));
+
+ return GTK_WIDGET (dialog);
+}
+
+GType
+nautilus_open_with_dialog_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ const GTypeInfo info = {
+ sizeof (NautilusOpenWithDialogClass),
+ NULL,
+ NULL,
+ (GClassInitFunc)nautilus_open_with_dialog_class_init,
+ NULL,
+ NULL,
+ sizeof (NautilusOpenWithDialog),
+ 0,
+ (GInstanceInitFunc)nautilus_open_with_dialog_instance_init,
+ };
+
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "NautilusOpenWithDialog",
+ &info, 0);
+ }
+
+ return type;
+}
diff --git a/libnautilus-private/nautilus-open-with-dialog.h b/libnautilus-private/nautilus-open-with-dialog.h
new file mode 100644
index 000000000..b8d3d10ff
--- /dev/null
+++ b/libnautilus-private/nautilus-open-with-dialog.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ nautilus-open-with-dialog.c: an open-with dialog
+
+ Copyright (C) 2004 Novell, Inc.
+
+ The Gnome Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Authors: Dave Camp <dave@novell.com>
+*/
+
+#ifndef NAUTILUS_OPEN_WITH_DIALOG_H
+#define NAUTILUS_OPEN_WITH_DIALOG_H
+
+#include <gtk/gtkdialog.h>
+#include <gio/gappinfo.h>
+
+#define NAUTILUS_TYPE_OPEN_WITH_DIALOG (nautilus_open_with_dialog_get_type ())
+#define NAUTILUS_OPEN_WITH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_OPEN_WITH_DIALOG, NautilusOpenWithDialog))
+#define NAUTILUS_OPEN_WITH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_OPEN_WITH_DIALOG, NautilusOpenWithDialogClass))
+#define NAUTILUS_IS_OPEN_WITH_DIALOG(obj) (G_TYPE_INSTANCE_CHECK_TYPE ((obj), NAUTILUS_TYPE_OPEN_WITH_DIALOG)
+
+typedef struct _NautilusOpenWithDialog NautilusOpenWithDialog;
+typedef struct _NautilusOpenWithDialogClass NautilusOpenWithDialogClass;
+typedef struct _NautilusOpenWithDialogDetails NautilusOpenWithDialogDetails;
+
+struct _NautilusOpenWithDialog {
+ GtkDialog parent;
+ NautilusOpenWithDialogDetails *details;
+};
+
+struct _NautilusOpenWithDialogClass {
+ GtkDialogClass parent_class;
+
+ void (*application_selected) (NautilusOpenWithDialog *dialog,
+ GAppInfo *application);
+};
+
+GType nautilus_open_with_dialog_get_type (void);
+GtkWidget* nautilus_open_with_dialog_new (const char *uri,
+ const char *mime_type);
+GtkWidget* nautilus_add_application_dialog_new (const char *uri,
+ const char *mime_type);
+
+
+
+#endif /* NAUTILUS_OPEN_WITH_DIALOG_H */
diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c
index 25f78e281..7bb7d9e40 100644
--- a/libnautilus-private/nautilus-program-choosing.c
+++ b/libnautilus-private/nautilus-program-choosing.c
@@ -28,38 +28,27 @@
#include "nautilus-mime-actions.h"
#include "nautilus-global-preferences.h"
-#include "nautilus-icon-factory.h"
+#include "nautilus-icon-info.h"
+#include "nautilus-recent.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-preferences.h>
#include <eel/eel-string.h>
+#include <eel/eel-app-launch-context.h>
#include <gtk/gtk.h>
#include <libgnome/gnome-config.h>
#include <glib/gi18n.h>
+#include <gio/gfileicon.h>
+#include <gio/gthemedicon.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-desktop-item.h>
#include <libgnome/gnome-url.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <stdlib.h>
-/* This number controls a maximum character count for a URL that is
- * displayed as part of a dialog. It's fairly arbitrary -- big enough
- * to allow most "normal" URIs to display in full, but small enough to
- * prevent the dialog from getting insanely wide.
- */
-#define MAX_URI_IN_DIALOG_LENGTH 60
-
-
-#ifdef HAVE_STARTUP_NOTIFICATION
-#define SN_API_NOT_YET_FROZEN
-#include <libsn/sn.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-#endif
extern char **environ;
@@ -116,7 +105,7 @@ my_gdk_spawn_make_environment_for_screen (GdkScreen *screen,
* @parent_window: A window to use as the parent for any error dialogs.
* */
static void
-application_cannot_open_location (GnomeVFSMimeApplication *application,
+application_cannot_open_location (GAppInfo *application,
NautilusFile *file,
const char *uri_scheme,
GtkWindow *parent_window)
@@ -136,8 +125,8 @@ application_cannot_open_location (GnomeVFSMimeApplication *application,
prompt = _("Open Failed, would you like to choose another application?");
message = g_strdup_printf (_("\"%s\" can't open \"%s\" because \"%s\" can't access files at \"%s\" "
"locations."),
- application->name, file_name,
- application->name, uri_scheme);
+ g_app_info_get_name (application), file_name,
+ g_app_info_get_name (application), uri_scheme);
} else {
prompt = _("Open Failed, would you like to choose another action?");
message = g_strdup_printf (_("The default action can't open \"%s\" because it can't access files at \"%s\" "
@@ -166,8 +155,8 @@ application_cannot_open_location (GnomeVFSMimeApplication *application,
} else {
if (application != NULL) {
prompt = g_strdup_printf (_("\"%s\" can't open \"%s\" because \"%s\" can't access files at \"%s\" "
- "locations."), application->name, file_name,
- application->name, uri_scheme);
+ "locations."), g_app_info_get_name (application), file_name,
+ g_app_info_get_name (application), uri_scheme);
message = _("No other applications are available to view this file. "
"If you copy this file onto your computer, you may be able to open "
"it.");
@@ -187,179 +176,6 @@ application_cannot_open_location (GnomeVFSMimeApplication *application,
#endif
}
-#ifdef HAVE_STARTUP_NOTIFICATION
-static void
-sn_error_trap_push (SnDisplay *display,
- Display *xdisplay)
-{
- gdk_error_trap_push ();
-}
-
-static void
-sn_error_trap_pop (SnDisplay *display,
- Display *xdisplay)
-{
- gdk_error_trap_pop ();
-}
-
-extern char **environ;
-
-static char **
-make_spawn_environment_for_sn_context (SnLauncherContext *sn_context,
- char **envp)
-{
- char **retval;
- int i, j;
-
- retval = NULL;
-
- if (envp == NULL) {
- envp = environ;
- }
-
- for (i = 0; envp[i]; i++) {
- /* Count length */
- }
-
- retval = g_new (char *, i + 2);
-
- for (i = 0, j = 0; envp[i]; i++) {
- if (!g_str_has_prefix (envp[i], "DESKTOP_STARTUP_ID=")) {
- retval[j] = g_strdup (envp[i]);
- ++j;
- }
- }
-
- retval[j] = g_strdup_printf ("DESKTOP_STARTUP_ID=%s",
- sn_launcher_context_get_startup_id (sn_context));
- ++j;
- retval[j] = NULL;
-
- return retval;
-}
-
-/* This should be fairly long, as it's confusing to users if a startup
- * ends when it shouldn't (it appears that the startup failed, and
- * they have to relaunch the app). Also the timeout only matters when
- * there are bugs and apps don't end their own startup sequence.
- *
- * This timeout is a "last resort" timeout that ignores whether the
- * startup sequence has shown activity or not. Metacity and the
- * tasklist have smarter, and correspondingly able-to-be-shorter
- * timeouts. The reason our timeout is dumb is that we don't monitor
- * the sequence (don't use an SnMonitorContext)
- */
-#define STARTUP_TIMEOUT_LENGTH (30 /* seconds */ * 1000)
-
-typedef struct
-{
- GdkScreen *screen;
- GSList *contexts;
- guint timeout_id;
-} StartupTimeoutData;
-
-static void
-free_startup_timeout (void *data)
-{
- StartupTimeoutData *std;
-
- std = data;
-
- g_slist_foreach (std->contexts,
- (GFunc) sn_launcher_context_unref,
- NULL);
- g_slist_free (std->contexts);
-
- if (std->timeout_id != 0) {
- g_source_remove (std->timeout_id);
- std->timeout_id = 0;
- }
-
- g_free (std);
-}
-
-static gboolean
-startup_timeout (void *data)
-{
- StartupTimeoutData *std;
- GSList *tmp;
- GTimeVal now;
- int min_timeout;
-
- std = data;
-
- min_timeout = STARTUP_TIMEOUT_LENGTH;
-
- g_get_current_time (&now);
-
- tmp = std->contexts;
- while (tmp != NULL) {
- SnLauncherContext *sn_context;
- GSList *next;
- long tv_sec, tv_usec;
- double elapsed;
-
- sn_context = tmp->data;
- next = tmp->next;
-
- sn_launcher_context_get_last_active_time (sn_context,
- &tv_sec, &tv_usec);
-
- elapsed =
- ((((double)now.tv_sec - tv_sec) * G_USEC_PER_SEC +
- (now.tv_usec - tv_usec))) / 1000.0;
-
- if (elapsed >= STARTUP_TIMEOUT_LENGTH) {
- std->contexts = g_slist_remove (std->contexts,
- sn_context);
- sn_launcher_context_complete (sn_context);
- sn_launcher_context_unref (sn_context);
- } else {
- min_timeout = MIN (min_timeout, (STARTUP_TIMEOUT_LENGTH - elapsed));
- }
-
- tmp = next;
- }
-
- if (std->contexts == NULL) {
- std->timeout_id = 0;
- } else {
- std->timeout_id = g_timeout_add (min_timeout,
- startup_timeout,
- std);
- }
-
- /* always remove this one, but we may have reinstalled another one. */
- return FALSE;
-}
-
-static void
-add_startup_timeout (GdkScreen *screen,
- SnLauncherContext *sn_context)
-{
- StartupTimeoutData *data;
-
- data = g_object_get_data (G_OBJECT (screen), "nautilus-startup-data");
- if (data == NULL) {
- data = g_new (StartupTimeoutData, 1);
- data->screen = screen;
- data->contexts = NULL;
- data->timeout_id = 0;
-
- g_object_set_data_full (G_OBJECT (screen), "nautilus-startup-data",
- data, free_startup_timeout);
- }
-
- sn_launcher_context_ref (sn_context);
- data->contexts = g_slist_prepend (data->contexts, sn_context);
-
- if (data->timeout_id == 0) {
- data->timeout_id = g_timeout_add (STARTUP_TIMEOUT_LENGTH,
- startup_timeout,
- data);
- }
-}
-
/* FIXME: This is the wrong way to do this; there should be some event
* (e.g. button press) available with a good time. A function like
* this should not be needed.
@@ -411,249 +227,7 @@ slowly_and_stupidly_obtain_timestamp (Display *xdisplay)
return event.xproperty.time;
}
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
-
-
-
-
-/**
- * nautilus_launch_show_file:
- *
- * Shows a file using gnome_url_show.
- *
- * @file: the file whose uri will be shown.
- * @parent_window: window to use as parent for error dialog.
- */
-void nautilus_launch_show_file (NautilusFile *file,
- GtkWindow *parent_window)
-{
- GnomeVFSResult result;
- GnomeVFSMimeApplication *application;
- GdkScreen *screen;
- char **envp;
- char *uri, *uri_scheme;
- char *error_message, *detail_message;
- char *full_uri_for_display;
- char *uri_for_display;
- GnomeVFSURI *vfs_uri;
-#ifdef HAVE_STARTUP_NOTIFICATION
- SnLauncherContext *sn_context;
- SnDisplay *sn_display;
- gboolean startup_notify;
-
- startup_notify = FALSE;
-#endif
-
- uri = NULL;
- if (nautilus_file_is_nautilus_link (file)) {
- uri = nautilus_file_get_activation_uri (file);
- }
-
- if (uri == NULL) {
- uri = nautilus_file_get_uri (file);
- }
-
- application = nautilus_mime_get_default_application_for_file (file);
-
- screen = gtk_window_get_screen (parent_window);
- envp = my_gdk_spawn_make_environment_for_screen (screen, NULL);
-
-#ifdef HAVE_STARTUP_NOTIFICATION
- sn_display = sn_display_new (gdk_display,
- sn_error_trap_push,
- sn_error_trap_pop);
-
- /* Only initiate notification if application supports it. */
- if (application) {
- startup_notify = gnome_vfs_mime_application_supports_startup_notification (application);
- } else {
- startup_notify = FALSE;
- }
-
- if (startup_notify == TRUE) {
- char *name;
- char *icon;
- sn_context = sn_launcher_context_new (sn_display,
- screen ? gdk_screen_get_number (screen) :
- DefaultScreen (gdk_display));
-
- name = nautilus_file_get_display_name (file);
-
- if (name != NULL) {
- char *description;
-
- sn_launcher_context_set_name (sn_context, name);
-
- description = g_strdup_printf (_("Opening %s"), name);
-
- sn_launcher_context_set_description (sn_context, description);
-
- g_free (name);
- g_free (description);
- }
-
- icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- if (icon != NULL) {
- sn_launcher_context_set_icon_name (sn_context, icon);
- g_free (icon);
- }
-
- if (!sn_launcher_context_get_initiated (sn_context)) {
- const char *binary_name;
- char **old_envp;
- Time timestamp;
-
- timestamp = slowly_and_stupidly_obtain_timestamp (GDK_WINDOW_XDISPLAY (GTK_WIDGET (parent_window)->window));
-
- binary_name = gnome_vfs_mime_application_get_binary_name (application);
-
- sn_launcher_context_set_binary_name (sn_context,
- binary_name);
-
- sn_launcher_context_initiate (sn_context,
- g_get_prgname () ? g_get_prgname () : "unknown",
- binary_name,
- timestamp);
-
- old_envp = envp;
- envp = make_spawn_environment_for_sn_context (sn_context, envp);
- g_strfreev (old_envp);
- }
- } else {
- sn_context = NULL;
- }
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
- result = gnome_vfs_url_show_with_env (uri, envp);
-
-#ifdef HAVE_STARTUP_NOTIFICATION
- if (sn_context != NULL) {
- if (result != GNOME_VFS_OK) {
- sn_launcher_context_complete (sn_context); /* end sequence */
- } else {
- add_startup_timeout (screen ? screen :
- gdk_display_get_default_screen (gdk_display_get_default ()),
- sn_context);
- }
- sn_launcher_context_unref (sn_context);
- }
-
- sn_display_unref (sn_display);
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
- full_uri_for_display = eel_format_uri_for_display (uri);
- /* Truncate the URI so it doesn't get insanely wide. Note that even
- * though the dialog uses wrapped text, if the URI doesn't contain
- * white space then the text-wrapping code is too stupid to wrap it.
- */
- uri_for_display = eel_str_middle_truncate
- (full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH);
- g_free (full_uri_for_display);
-
- error_message = detail_message = NULL;
-
- switch (result) {
- case GNOME_VFS_OK:
- break;
-
- case GNOME_VFS_ERROR_NOT_SUPPORTED:
- uri_scheme = nautilus_file_get_uri_scheme (file);
- application_cannot_open_location (NULL,
- file,
- uri_scheme,
- parent_window);
- g_free (uri_scheme);
- break;
-
- case GNOME_VFS_ERROR_NO_DEFAULT:
- case GNOME_VFS_ERROR_NO_HANDLER:
-#ifdef NEW_MIME_COMPLETE
- nautilus_program_chooser_show_no_choices_message
- (action_type, file, parent_window);
- break;
-#endif
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- /* TODO: This really needs to be something saying "no app
- * handling this file type", but there is a string freeze. */
- detail_message = g_strdup ("");
- break;
-
- case GNOME_VFS_ERROR_LAUNCH:
- /* TODO: These strings suck pretty badly, but we're in string-freeze,
- * and I found these in other places to reuse. We should make them
- * better later. */
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("There was an error launching the application."));
- break;
- default:
-
- switch (nautilus_file_get_file_info_result (file)) {
- case GNOME_VFS_ERROR_ACCESS_DENIED:
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("The attempt to log in failed."));
- break;
- case GNOME_VFS_ERROR_NOT_PERMITTED:
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("Access was denied."));
- break;
- case GNOME_VFS_ERROR_INVALID_HOST_NAME:
- case GNOME_VFS_ERROR_HOST_NOT_FOUND:
- vfs_uri = gnome_vfs_uri_new (uri);
- error_message = g_strdup_printf (_("Couldn't display \"%s\", because no host \"%s\" could be found."),
- uri_for_display,
- gnome_vfs_uri_get_host_name (vfs_uri));
- detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct."));
- gnome_vfs_uri_unref (vfs_uri);
- break;
- case GNOME_VFS_ERROR_INVALID_URI:
- error_message = g_strdup_printf
- (_("\"%s\" is not a valid location."),
- uri_for_display);
- detail_message = g_strdup
- (_("Please check the spelling and try again."));
- break;
- case GNOME_VFS_ERROR_NOT_FOUND:
- error_message = g_strdup_printf
- (_("Couldn't find \"%s\"."),
- uri_for_display);
- detail_message = g_strdup
- (_("Please check the spelling and try again."));
- break;
- case GNOME_VFS_ERROR_CANCELLED:
- break;
- case GNOME_VFS_OK:
- default:
-#ifdef NEW_MIME_COMPLETE
- nautilus_program_chooser_show_invalid_message
- (action_type, file, parent_window);
-#endif
- break;
- }
-
-
- }
-
- if (error_message != NULL) {
- eel_show_error_dialog (error_message, detail_message, parent_window);
-
- g_free (error_message);
- g_free (detail_message);
- }
-
- g_free (uri_for_display);
-
- if (application != NULL)
- gnome_vfs_mime_application_free (application);
-
- g_strfreev (envp);
- g_free (uri);
-}
/**
* nautilus_launch_application:
@@ -666,166 +240,89 @@ void nautilus_launch_show_file (NautilusFile *file,
* @parent_window: A window to use as the parent for any error dialogs.
*/
void
-nautilus_launch_application (GnomeVFSMimeApplication *application,
+nautilus_launch_application (GAppInfo *application,
GList *files,
GtkWindow *parent_window)
{
- GdkScreen *screen;
char *uri;
char *uri_scheme;
- GList *uris, *l;
+ GList *locations, *l;
+ GFile *location;
NautilusFile *file;
- char **envp;
- GnomeVFSResult result;
-#ifdef HAVE_STARTUP_NOTIFICATION
- SnLauncherContext *sn_context;
- SnDisplay *sn_display;
-#endif
+ gboolean result;
+ GError *error;
+ EelAppLaunchContext *launch_context;
+ NautilusIconInfo *icon;
g_assert (files != NULL);
- uris = NULL;
+ locations = NULL;
for (l = files; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
-
- uri = NULL;
+
+ location = NULL;
if (nautilus_file_is_nautilus_link (file)) {
uri = nautilus_file_get_activation_uri (file);
+ location = g_file_new_for_uri (uri);
+ g_free (uri);
}
- if (uri == NULL) {
- uri = nautilus_file_get_uri (file);
+ if (location == NULL) {
+ location = nautilus_file_get_location (file);
}
- uris = g_list_prepend (uris, uri);
+ locations = g_list_prepend (locations, location);
+ }
+ locations = g_list_reverse (locations);
+
+ launch_context = eel_app_launch_context_new ();
+ if (parent_window)
+ eel_app_launch_context_set_screen (launch_context,
+ gtk_window_get_screen (parent_window));
+
+ file = NAUTILUS_FILE (files->data);
+ icon = nautilus_file_get_icon (file, 48, 0);
+ if (icon) {
+ eel_app_launch_context_set_icon_name (launch_context,
+ nautilus_icon_info_get_used_name (icon));
+ g_object_unref (icon);
}
- uris = g_list_reverse (uris);
-
- screen = gtk_window_get_screen (parent_window);
- envp = my_gdk_spawn_make_environment_for_screen (screen, NULL);
-#ifdef HAVE_STARTUP_NOTIFICATION
- sn_display = sn_display_new (gdk_display,
- sn_error_trap_push,
- sn_error_trap_pop);
+ error = NULL;
+ result = g_app_info_launch (application,
+ locations,
+ G_APP_LAUNCH_CONTEXT (launch_context),
+ &error);
+ g_object_unref (launch_context);
- /* Only initiate notification if application supports it. */
- if (gnome_vfs_mime_application_supports_startup_notification (application))
- {
- char *name;
- char *description;
- char *icon;
- int files_count;
-
- file = NAUTILUS_FILE (files->data);
-
- sn_context = sn_launcher_context_new (sn_display,
- screen ? gdk_screen_get_number (screen) :
- DefaultScreen (gdk_display));
-
- files_count = g_list_length (files);
- if (files_count == 1) {
- name = nautilus_file_get_display_name (file);
- description = g_strdup_printf (_("Opening %s"), name);
+ if (!result) {
+ if (error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_NOT_SUPPORTED) {
+ uri_scheme = nautilus_file_get_uri_scheme (NAUTILUS_FILE (files->data));
+ application_cannot_open_location (application,
+ file,
+ uri_scheme,
+ parent_window);
+ g_free (uri_scheme);
} else {
- name = NULL;
- description = g_strdup_printf (ngettext ("Opening %d Item",
- "Opening %d Items",
- files_count),
- files_count);
- }
-
- if (name != NULL) {
- sn_launcher_context_set_name (sn_context, name);
- g_free (name);
- }
-
- if (description != NULL) {
- sn_launcher_context_set_description (sn_context, description);
- g_free (description);
- }
-
- icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
-
- if (icon == NULL) {
- icon = g_strdup (gnome_vfs_mime_application_get_icon (application));
- }
-
- if (icon != NULL) {
- sn_launcher_context_set_icon_name (sn_context, icon);
- g_free (icon);
- }
-
- if (!sn_launcher_context_get_initiated (sn_context)) {
- const char *binary_name;
- char **old_envp;
- Time timestamp;
-
- timestamp = slowly_and_stupidly_obtain_timestamp (GDK_WINDOW_XDISPLAY (GTK_WIDGET (parent_window)->window));
-
- binary_name = gnome_vfs_mime_application_get_binary_name (application);
-
- sn_launcher_context_set_binary_name (sn_context,
- binary_name);
-
- sn_launcher_context_initiate (sn_context,
- g_get_prgname () ? g_get_prgname () : "unknown",
- binary_name,
- timestamp);
-
- old_envp = envp;
- envp = make_spawn_environment_for_sn_context (sn_context, envp);
- g_strfreev (old_envp);
+#ifdef NEW_MIME_COMPLETE
+ nautilus_program_chooser_show_invalid_message
+ (GNOME_VFS_MIME_ACTION_TYPE_APPLICATION, file, parent_window);
+#else
+ g_warning ("Can't open app: %s\n", error->message);
+#endif
}
} else {
- sn_context = NULL;
- }
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
- result = gnome_vfs_mime_application_launch_with_env (application, uris, envp);
-
-#ifdef HAVE_STARTUP_NOTIFICATION
- if (sn_context != NULL) {
- if (result != GNOME_VFS_OK) {
- sn_launcher_context_complete (sn_context); /* end sequence */
- } else {
- add_startup_timeout (screen ? screen :
- gdk_display_get_default_screen (gdk_display_get_default ()),
- sn_context);
+ for (l = files; l != NULL; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+
+ nautilus_recent_add_file (file, application);
}
- sn_launcher_context_unref (sn_context);
}
-
- sn_display_unref (sn_display);
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
- switch (result) {
- case GNOME_VFS_OK:
- break;
-
- case GNOME_VFS_ERROR_NOT_SUPPORTED:
- uri_scheme = nautilus_file_get_uri_scheme (NAUTILUS_FILE (files->data));
- application_cannot_open_location (application,
- file,
- uri_scheme,
- parent_window);
- g_free (uri_scheme);
-
- break;
- default:
-#ifdef NEW_MIME_COMPLETE
- nautilus_program_chooser_show_invalid_message
- (GNOME_VFS_MIME_ACTION_TYPE_APPLICATION, file, parent_window);
-
-#endif
- break;
- }
-
- eel_g_list_free_deep (uris);
- g_strfreev (envp);
+ eel_g_object_list_free (locations);
}
/**
@@ -859,7 +356,7 @@ nautilus_launch_application_from_command (GdkScreen *screen,
if (use_terminal) {
eel_gnome_open_terminal_on_screen (full_command, screen);
} else {
- eel_gnome_shell_execute_on_screen (full_command, screen);
+ gdk_spawn_command_line_on_screen (screen, full_command, NULL);
}
g_free (full_command);
@@ -879,9 +376,8 @@ nautilus_launch_desktop_file (GdkScreen *screen,
const GList *p;
int total, count;
char **envp;
-#ifdef HAVE_STARTUP_NOTIFICATION
+ GFile *file;
Time timestamp;
-#endif
/* strip the leading command specifier */
if (eel_str_has_prefix (desktop_file_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
@@ -893,8 +389,9 @@ nautilus_launch_desktop_file (GdkScreen *screen,
* nfs are treated as remote) to partially mitigate the security
* risk of executing arbitrary commands.
*/
- if (!eel_vfs_has_capability (desktop_file_uri,
- EEL_VFS_CAPABILITY_SAFE_TO_EXECUTE)) {
+ file = g_file_new_for_uri (desktop_file_uri);
+ if (!g_file_is_native (file)) {
+ g_object_unref (file);
eel_show_error_dialog
(_("Sorry, but you can't execute commands from "
"a remote site."),
@@ -903,6 +400,7 @@ nautilus_launch_desktop_file (GdkScreen *screen,
return;
}
+ g_object_unref (file);
error = NULL;
ditem = gnome_desktop_item_new_from_uri (desktop_file_uri, 0,
@@ -923,7 +421,7 @@ nautilus_launch_desktop_file (GdkScreen *screen,
count = 0;
total = g_list_length ((GList *) parameter_uris);
for (p = parameter_uris; p != NULL; p = p->next) {
- local_path = gnome_vfs_get_local_path_from_uri ((const char *) p->data);
+ local_path = g_filename_from_uri ((const char *) p->data, NULL, NULL);
if (local_path != NULL) {
g_free (local_path);
count++;
@@ -968,10 +466,8 @@ nautilus_launch_desktop_file (GdkScreen *screen,
error = NULL;
-#ifdef HAVE_STARTUP_NOTIFICATION
timestamp = slowly_and_stupidly_obtain_timestamp (GDK_WINDOW_XDISPLAY (GTK_WIDGET (parent_window)->window));
gnome_desktop_item_set_launch_time (ditem, timestamp);
-#endif
gnome_desktop_item_launch_with_env (ditem, (GList *) parameter_uris,
flags, envp,
&error);
diff --git a/libnautilus-private/nautilus-program-choosing.h b/libnautilus-private/nautilus-program-choosing.h
index 002073eb6..796d3a376 100644
--- a/libnautilus-private/nautilus-program-choosing.h
+++ b/libnautilus-private/nautilus-program-choosing.h
@@ -27,16 +27,16 @@
#define NAUTILUS_PROGRAM_CHOOSING_H
#include <gtk/gtkwindow.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <gio/gappinfo.h>
#include <libnautilus-private/nautilus-file.h>
#define NAUTILUS_COMMAND_SPECIFIER "command:"
#define NAUTILUS_DESKTOP_COMMAND_SPECIFIER "desktop-file:"
-typedef void (*NautilusApplicationChoiceCallback) (GnomeVFSMimeApplication *application,
+typedef void (*NautilusApplicationChoiceCallback) (GAppInfo *application,
gpointer callback_data);
-void nautilus_launch_application (GnomeVFSMimeApplication *application,
+void nautilus_launch_application (GAppInfo *application,
GList *files,
GtkWindow *parent_window);
void nautilus_launch_application_from_command (GdkScreen *screen,
@@ -48,7 +48,5 @@ void nautilus_launch_desktop_file (GdkScreen *screen,
const char *desktop_file_uri,
const GList *parameter_uris,
GtkWindow *parent_window);
-void nautilus_launch_show_file (NautilusFile *file,
- GtkWindow *parent_window);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */
diff --git a/libnautilus-private/nautilus-progress-info.c b/libnautilus-private/nautilus-progress-info.c
new file mode 100644
index 000000000..2c1ceefaa
--- /dev/null
+++ b/libnautilus-private/nautilus-progress-info.c
@@ -0,0 +1,752 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-progress-info.h: file operation progress info.
+
+ Copyright (C) 2007 Red Hat, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+#include <math.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <eel/eel-string.h>
+#include <eel/eel-glib-extensions.h>
+#include "nautilus-progress-info.h"
+
+enum {
+ CHANGED,
+ PROGRESS_CHANGED,
+ STARTED,
+ FINISHED,
+ LAST_SIGNAL
+};
+
+/* TODO:
+ * Want an icon for the operation.
+ * Add and implement cancel button
+ */
+
+#define SIGNAL_DELAY_MSEC 100
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+struct _NautilusProgressInfo
+{
+ GObject parent_instance;
+
+ GCancellable *cancellable;
+
+ char *status;
+ char *details;
+ double progress;
+ gboolean activity_mode;
+ gboolean started;
+ gboolean finished;
+
+ GSource *idle_source;
+ gboolean source_is_now;
+
+ gboolean start_at_idle;
+ gboolean finish_at_idle;
+ gboolean changed_at_idle;
+ gboolean progress_at_idle;
+};
+
+struct _NautilusProgressInfoClass
+{
+ GObjectClass parent_class;
+};
+
+static GList *active_progress_infos = NULL;
+
+static GtkStatusIcon *status_icon = NULL;
+static int n_progress_ops = 0;
+
+
+G_LOCK_DEFINE_STATIC(progress_info);
+
+G_DEFINE_TYPE (NautilusProgressInfo, nautilus_progress_info, G_TYPE_OBJECT)
+
+GList *
+nautilus_get_all_progress_info (void)
+{
+ GList *l;
+
+ G_LOCK (progress_info);
+
+ l = eel_g_object_list_copy (active_progress_infos);
+
+ G_UNLOCK (progress_info);
+
+ return l;
+}
+
+static void
+nautilus_progress_info_finalize (GObject *object)
+{
+ NautilusProgressInfo *info;
+
+ info = NAUTILUS_PROGRESS_INFO (object);
+
+ g_free (info->status);
+ g_free (info->details);
+ g_object_unref (info->cancellable);
+
+ if (G_OBJECT_CLASS (nautilus_progress_info_parent_class)->finalize) {
+ (*G_OBJECT_CLASS (nautilus_progress_info_parent_class)->finalize) (object);
+ }
+}
+
+static void
+nautilus_progress_info_dispose (GObject *object)
+{
+ NautilusProgressInfo *info;
+
+ info = NAUTILUS_PROGRESS_INFO (object);
+
+ G_LOCK (progress_info);
+
+ /* Remove from active list in dispose, since a get_all_progress_info()
+ call later could revive the object */
+ active_progress_infos = g_list_remove (active_progress_infos, object);
+
+ /* Destroy source in dispose, because the callback
+ could come here before the destroy, which should
+ ressurect the object for a while */
+ if (info->idle_source) {
+ g_source_destroy (info->idle_source);
+ g_source_unref (info->idle_source);
+ info->idle_source = NULL;
+ }
+ G_UNLOCK (progress_info);
+}
+
+static void
+nautilus_progress_info_class_init (NautilusProgressInfoClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ gobject_class->finalize = nautilus_progress_info_finalize;
+ gobject_class->dispose = nautilus_progress_info_dispose;
+
+ signals[CHANGED] =
+ g_signal_new ("changed",
+ NAUTILUS_TYPE_PROGRESS_INFO,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[PROGRESS_CHANGED] =
+ g_signal_new ("progress-changed",
+ NAUTILUS_TYPE_PROGRESS_INFO,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[STARTED] =
+ g_signal_new ("started",
+ NAUTILUS_TYPE_PROGRESS_INFO,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[FINISHED] =
+ g_signal_new ("finished",
+ NAUTILUS_TYPE_PROGRESS_INFO,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+}
+
+static gboolean
+delete_event (GtkWidget *widget,
+ GdkEventAny *event)
+{
+ gtk_widget_hide (widget);
+ return TRUE;
+}
+
+static GtkWidget *
+get_progress_window (void)
+{
+ static GtkWidget *progress_window = NULL;
+ GtkWidget *vbox;
+
+ if (progress_window != NULL) {
+ return progress_window;
+ }
+
+ progress_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_resizable (GTK_WINDOW (progress_window),
+ FALSE);
+
+ gtk_window_set_title (GTK_WINDOW (progress_window),
+ _("File operations"));
+ gtk_window_set_wmclass (GTK_WINDOW (progress_window),
+ "file_progress", "Nautilus");
+ gtk_window_set_type_hint (GTK_WINDOW (progress_window),
+ GDK_WINDOW_TYPE_HINT_DIALOG);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ gtk_widget_show (vbox);
+
+ gtk_container_add (GTK_CONTAINER (progress_window),
+ vbox);
+
+ g_signal_connect (progress_window, "delete_event", (GCallback)delete_event, NULL);
+
+ status_icon = gtk_status_icon_new_from_icon_name ("stock_folder-copy");
+ g_signal_connect_swapped (status_icon, "activate", (GCallback)gtk_window_present, progress_window);
+
+ gtk_status_icon_set_visible (status_icon, FALSE);
+
+ return progress_window;
+}
+
+
+typedef struct {
+ GtkWidget *widget;
+ NautilusProgressInfo *info;
+ GtkLabel *status;
+ GtkLabel *details;
+ GtkProgressBar *progress_bar;
+} ProgressWidgetData;
+
+static void
+progress_widget_data_free (ProgressWidgetData *data)
+{
+ g_object_unref (data->info);
+ g_free (data);
+}
+
+static void
+update_data (ProgressWidgetData *data)
+{
+ char *status, *details;
+ char *markup;
+
+ status = nautilus_progress_info_get_status (data->info);
+ gtk_label_set_text (data->status, status);
+ g_free (status);
+
+ details = nautilus_progress_info_get_details (data->info);
+ markup = g_markup_printf_escaped ("<span size='small'>%s</span>", details);
+ gtk_label_set_markup (data->details, markup);
+ g_free (details);
+ g_free (markup);
+}
+
+static void
+update_progress (ProgressWidgetData *data)
+{
+ double progress;
+
+ progress = nautilus_progress_info_get_progress (data->info);
+ if (progress < 0) {
+ gtk_progress_bar_pulse (data->progress_bar);
+ } else {
+ gtk_progress_bar_set_fraction (data->progress_bar, progress);
+ }
+}
+
+static void
+update_status_icon_and_window (void)
+{
+ char *tooltip;
+
+ tooltip = g_strdup_printf (_("%d file operations active"),
+ n_progress_ops);
+ gtk_status_icon_set_tooltip (status_icon, tooltip);
+ g_free (tooltip);
+
+ if (n_progress_ops == 0) {
+ gtk_status_icon_set_visible (status_icon, FALSE);
+ gtk_widget_hide (get_progress_window ());
+ } else {
+ gtk_status_icon_set_visible (status_icon, TRUE);
+ }
+}
+
+static void
+op_finished (ProgressWidgetData *data)
+{
+ gtk_widget_destroy (data->widget);
+
+ n_progress_ops--;
+ update_status_icon_and_window ();
+}
+
+static GtkWidget *
+progress_widget_new (NautilusProgressInfo *info)
+{
+ ProgressWidgetData *data;
+ GtkWidget *label, *bar;
+
+ data = g_new0 (ProgressWidgetData, 1);
+ data->info = g_object_ref (info);
+
+ data->widget = gtk_vbox_new (FALSE, 0);
+
+ g_object_set_data_full (G_OBJECT (data->widget),
+ "data", data, (GDestroyNotify)progress_widget_data_free);
+
+ label = gtk_label_new ("details");
+ gtk_widget_set_size_request (label,
+ 400, -1);
+ data->status = GTK_LABEL (label);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (data->widget),
+ label,
+ FALSE, FALSE,
+ 2);
+
+ bar = gtk_progress_bar_new ();
+ data->progress_bar = GTK_PROGRESS_BAR (bar);
+ gtk_progress_bar_set_pulse_step (data->progress_bar, 0.05);
+
+ gtk_widget_show (bar);
+ gtk_box_pack_start (GTK_BOX (data->widget),
+ bar,
+ FALSE, FALSE,
+ 2);
+
+ label = gtk_label_new ("status");
+ gtk_widget_set_size_request (label,
+ 400, -1);
+ data->details = GTK_LABEL (label);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (data->widget),
+ label,
+ FALSE, FALSE,
+ 0);
+
+ update_data (data);
+ update_progress (data);
+
+ g_signal_connect_swapped (data->info, "changed", (GCallback)update_data, data);
+ g_signal_connect_swapped (data->info, "progress_changed", (GCallback)update_progress, data);
+ g_signal_connect_swapped (data->info, "finished", (GCallback)op_finished, data);
+
+ gtk_widget_show (data->widget);
+
+ return data->widget;
+}
+
+static void
+handle_new_progress_info (NautilusProgressInfo *info)
+{
+ GtkWidget *window, *progress;
+
+ window = get_progress_window ();
+
+ progress = progress_widget_new (info);
+ gtk_box_pack_start (GTK_BOX (GTK_BIN (window)->child),
+ progress,
+ FALSE, FALSE, 6);
+
+ gtk_window_present (GTK_WINDOW (window));
+
+ n_progress_ops++;
+ update_status_icon_and_window ();
+}
+
+static gboolean
+new_op_started_timeout (NautilusProgressInfo *info)
+{
+ if (!nautilus_progress_info_get_is_finished (info)) {
+ handle_new_progress_info (info);
+ }
+ g_object_unref (info);
+ return FALSE;
+}
+
+static void
+new_op_started (NautilusProgressInfo *info)
+{
+ g_signal_handlers_disconnect_by_func (info, (GCallback)new_op_started, NULL);
+ g_timeout_add_seconds (2,
+ (GSourceFunc)new_op_started_timeout,
+ g_object_ref (info));
+}
+
+static void
+nautilus_progress_info_init (NautilusProgressInfo *info)
+{
+ info->cancellable = g_cancellable_new ();
+
+ G_LOCK (progress_info);
+ active_progress_infos = g_list_append (active_progress_infos, info);
+ G_UNLOCK (progress_info);
+
+ g_signal_connect (info, "started", (GCallback)new_op_started, NULL);
+}
+
+NautilusProgressInfo *
+nautilus_progress_info_new (void)
+{
+ NautilusProgressInfo *info;
+
+ info = g_object_new (NAUTILUS_TYPE_PROGRESS_INFO, NULL);
+
+ return info;
+}
+
+char *
+nautilus_progress_info_get_status (NautilusProgressInfo *info)
+{
+ char *res;
+
+ G_LOCK (progress_info);
+
+ if (info->status) {
+ res = g_strdup (info->status);
+ } else {
+ res = g_strdup (_("Preparing"));
+ }
+
+ G_UNLOCK (progress_info);
+
+ return res;
+}
+
+char *
+nautilus_progress_info_get_details (NautilusProgressInfo *info)
+{
+ char *res;
+
+ G_LOCK (progress_info);
+
+ if (info->details) {
+ res = g_strdup (info->details);
+ } else {
+ res = g_strdup (_("Preparing"));
+ }
+
+ G_UNLOCK (progress_info);
+
+ return res;
+}
+
+double
+nautilus_progress_info_get_progress (NautilusProgressInfo *info)
+{
+ double res;
+
+ G_LOCK (progress_info);
+
+ if (info->activity_mode) {
+ res = -1.0;
+ } else {
+ res = info->progress;
+ }
+
+ G_UNLOCK (progress_info);
+
+ return res;
+}
+
+GCancellable *
+nautilus_progress_info_get_cancellable (NautilusProgressInfo *info)
+{
+ GCancellable *c;
+
+ G_LOCK (progress_info);
+
+ c = g_object_ref (info->cancellable);
+
+ G_UNLOCK (progress_info);
+
+ return c;
+}
+
+gboolean
+nautilus_progress_info_get_is_started (NautilusProgressInfo *info)
+{
+ gboolean res;
+
+ G_LOCK (progress_info);
+
+ res = info->started;
+
+ G_UNLOCK (progress_info);
+
+ return res;
+}
+
+gboolean
+nautilus_progress_info_get_is_finished (NautilusProgressInfo *info)
+{
+ gboolean res;
+
+ G_LOCK (progress_info);
+
+ res = info->finished;
+
+ G_UNLOCK (progress_info);
+
+ return res;
+}
+
+static gboolean
+idle_callback (gpointer data)
+{
+ NautilusProgressInfo *info = data;
+ gboolean start_at_idle;
+ gboolean finish_at_idle;
+ gboolean changed_at_idle;
+ gboolean progress_at_idle;
+ GSource *source;
+
+ source = g_main_current_source ();
+
+ G_LOCK (progress_info);
+
+ /* Protect agains races where the source has
+ been destroyed on another thread while it
+ was being dispatched.
+ Similar to what gdk_threads_add_idle does.
+ */
+ if (g_source_is_destroyed (source)) {
+ G_UNLOCK (progress_info);
+ return FALSE;
+ }
+
+ /* We hadn't destroyed the source, so take a ref.
+ * This might ressurect the object from dispose, but
+ * that should be ok.
+ */
+ g_object_ref (info);
+
+ g_assert (source == info->idle_source);
+
+ g_source_unref (source);
+ info->idle_source = NULL;
+
+ start_at_idle = info->start_at_idle;
+ finish_at_idle = info->finish_at_idle;
+ changed_at_idle = info->changed_at_idle;
+ progress_at_idle = info->progress_at_idle;
+
+ info->start_at_idle = FALSE;
+ info->finish_at_idle = FALSE;
+ info->changed_at_idle = FALSE;
+ info->progress_at_idle = FALSE;
+
+ G_UNLOCK (progress_info);
+
+ if (start_at_idle) {
+ g_signal_emit (info,
+ signals[STARTED],
+ 0);
+ }
+
+ if (changed_at_idle) {
+ g_signal_emit (info,
+ signals[CHANGED],
+ 0);
+ }
+
+ if (progress_at_idle) {
+ g_signal_emit (info,
+ signals[PROGRESS_CHANGED],
+ 0);
+ }
+
+ if (finish_at_idle) {
+ g_signal_emit (info,
+ signals[FINISHED],
+ 0);
+ }
+
+ g_object_unref (info);
+
+ return FALSE;
+}
+
+/* Called with lock held */
+static void
+queue_idle (NautilusProgressInfo *info, gboolean now)
+{
+ if (info->idle_source == NULL ||
+ (now && !info->source_is_now)) {
+ if (info->idle_source) {
+ g_source_destroy (info->idle_source);
+ g_source_unref (info->idle_source);
+ info->idle_source = NULL;
+ }
+
+ info->source_is_now = now;
+ if (now) {
+ info->idle_source = g_idle_source_new ();
+ } else {
+ info->idle_source = g_timeout_source_new (SIGNAL_DELAY_MSEC);
+ }
+ g_source_set_callback (info->idle_source, idle_callback, info, NULL);
+ g_source_attach (info->idle_source, NULL);
+ }
+}
+
+void
+nautilus_progress_info_start (NautilusProgressInfo *info)
+{
+ G_LOCK (progress_info);
+
+ if (!info->started) {
+ info->started = TRUE;
+
+ info->start_at_idle = TRUE;
+ queue_idle (info, TRUE);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_finish (NautilusProgressInfo *info)
+{
+ G_LOCK (progress_info);
+
+ if (!info->finished) {
+ info->finished = TRUE;
+
+ info->finish_at_idle = TRUE;
+ queue_idle (info, TRUE);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_take_status (NautilusProgressInfo *info,
+ char *status)
+{
+ G_LOCK (progress_info);
+
+ if (eel_strcmp (info->status, status) != 0) {
+ g_free (info->status);
+ info->status = status;
+
+ info->changed_at_idle = TRUE;
+ queue_idle (info, FALSE);
+ } else {
+ g_free (status);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_set_status (NautilusProgressInfo *info,
+ const char *status)
+{
+ G_LOCK (progress_info);
+
+ if (eel_strcmp (info->status, status) != 0) {
+ g_free (info->status);
+ info->status = g_strdup (status);
+
+ info->changed_at_idle = TRUE;
+ queue_idle (info, FALSE);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+
+void
+nautilus_progress_info_take_details (NautilusProgressInfo *info,
+ char *details)
+{
+ G_LOCK (progress_info);
+
+ if (eel_strcmp (info->details, details) != 0) {
+ g_free (info->details);
+ info->details = details;
+
+ info->changed_at_idle = TRUE;
+ queue_idle (info, FALSE);
+ } else {
+ g_free (details);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_set_details (NautilusProgressInfo *info,
+ const char *details)
+{
+ G_LOCK (progress_info);
+
+ if (eel_strcmp (info->details, details) != 0) {
+ g_free (info->details);
+ info->details = g_strdup (details);
+
+ info->changed_at_idle = TRUE;
+ queue_idle (info, FALSE);
+ }
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_pulse_progress (NautilusProgressInfo *info)
+{
+ G_LOCK (progress_info);
+
+ info->activity_mode = TRUE;
+ info->progress = 0.0;
+ info->progress_at_idle = TRUE;
+ queue_idle (info, FALSE);
+
+ G_UNLOCK (progress_info);
+}
+
+void
+nautilus_progress_info_set_progress (NautilusProgressInfo *info,
+ double current_percent)
+{
+ G_LOCK (progress_info);
+
+ if (info->activity_mode || /* emit on switch from activity mode */
+ fabs (current_percent - info->progress) > 0.005 /* Emit on change of 0.5 percent */
+ ) {
+ info->activity_mode = FALSE;
+ info->progress = current_percent;
+ info->progress_at_idle = TRUE;
+ queue_idle (info, FALSE);
+ }
+
+ G_UNLOCK (progress_info);
+}
diff --git a/libnautilus-private/nautilus-progress-info.h b/libnautilus-private/nautilus-progress-info.h
new file mode 100644
index 000000000..878406cdd
--- /dev/null
+++ b/libnautilus-private/nautilus-progress-info.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-progress-info.h: file operation progress info.
+
+ Copyright (C) 2007 Red Hat, Inc.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Alexander Larsson <alexl@redhat.com>
+*/
+
+#ifndef NAUTILUS_PROGRESS_INFO_H
+#define NAUTILUS_PROGRESS_INFO_H
+
+#include <glib-object.h>
+#include <gio/gcancellable.h>
+
+#define NAUTILUS_TYPE_PROGRESS_INFO (nautilus_progress_info_get_type ())
+#define NAUTILUS_PROGRESS_INFO(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_PROGRESS_INFO, NautilusProgressInfo))
+#define NAUTILUS_PROGRESS_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_PROGRESS_INFO, NautilusProgressInfoClass))
+#define NAUTILUS_IS_PROGRESS_INFO(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_PROGRESS_INFO))
+#define NAUTILUS_IS_PROGRESS_INFO_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_PROGRESS_INFO))
+#define NAUTILUS_PROGRESS_INFO_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_PROGRESS_INFO, NautilusProgressInfoClass))
+
+typedef struct _NautilusProgressInfo NautilusProgressInfo;
+typedef struct _NautilusProgressInfoClass NautilusProgressInfoClass;
+
+GType nautilus_progress_info_get_type (void) G_GNUC_CONST;
+
+/* Signals:
+ "changed" - status or details changed
+ "progress-changed" - the percentage progress changed (or we pulsed if in activity_mode
+ "started" - emited on job start
+ "finished" - emitted when job is done
+
+ All signals are emitted from idles in main loop.
+ All methods are threadsafe.
+ */
+
+NautilusProgressInfo *nautilus_progress_info_new (void);
+
+GList * nautilus_get_all_progress_info (void);
+
+char * nautilus_progress_info_get_status (NautilusProgressInfo *info);
+char * nautilus_progress_info_get_details (NautilusProgressInfo *info);
+double nautilus_progress_info_get_progress (NautilusProgressInfo *info);
+GCancellable *nautilus_progress_info_get_cancellable (NautilusProgressInfo *info);
+gboolean nautilus_progress_info_get_is_started (NautilusProgressInfo *info);
+gboolean nautilus_progress_info_get_is_finished (NautilusProgressInfo *info);
+
+void nautilus_progress_info_start (NautilusProgressInfo *info);
+void nautilus_progress_info_finish (NautilusProgressInfo *info);
+void nautilus_progress_info_set_status (NautilusProgressInfo *info,
+ const char *status);
+void nautilus_progress_info_take_status (NautilusProgressInfo *info,
+ char *status);
+void nautilus_progress_info_set_details (NautilusProgressInfo *info,
+ const char *details);
+void nautilus_progress_info_take_details (NautilusProgressInfo *info,
+ char *details);
+void nautilus_progress_info_set_progress (NautilusProgressInfo *info,
+ double current_percent);
+void nautilus_progress_info_pulse_progress (NautilusProgressInfo *info);
+
+
+
+#endif /* NAUTILUS_PROGRESS_INFO_H */
diff --git a/libnautilus-private/nautilus-query.h b/libnautilus-private/nautilus-query.h
index fae278042..8d92c3ddf 100644
--- a/libnautilus-private/nautilus-query.h
+++ b/libnautilus-private/nautilus-query.h
@@ -25,7 +25,6 @@
#define NAUTILUS_QUERY_H
#include <glib-object.h>
-#include <libgnomevfs/gnome-vfs-result.h>
#define NAUTILUS_TYPE_QUERY (nautilus_query_get_type ())
#define NAUTILUS_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_QUERY, NautilusQuery))
diff --git a/libnautilus-private/nautilus-recent.c b/libnautilus-private/nautilus-recent.c
index 8c6fd6e4e..3a4458550 100644
--- a/libnautilus-private/nautilus-recent.c
+++ b/libnautilus-private/nautilus-recent.c
@@ -20,6 +20,8 @@
#include "nautilus-recent.h"
+#include <eel/eel-vfs-extensions.h>
+
#define DEFAULT_APP_EXEC "gnome-open %u"
static GtkRecentManager *
@@ -37,23 +39,21 @@ nautilus_recent_get_manager (void)
void
nautilus_recent_add_file (NautilusFile *file,
- GnomeVFSMimeApplication *application)
+ GAppInfo *application)
{
GtkRecentData recent_data;
char *uri;
- GnomeVFSURI *vfs_uri;
uri = nautilus_file_get_uri (file);
-
- /* Only add real gnome-vfs uris to recent. Not things like
- trash:// and x-nautilus-desktop:// */
- vfs_uri = gnome_vfs_uri_new (uri);
- if (vfs_uri == NULL) {
+
+ /* do not add trash:// etc */
+ if (eel_uri_is_trash (uri) ||
+ eel_uri_is_search (uri) ||
+ eel_uri_is_desktop (uri)) {
g_free (uri);
return;
}
- gnome_vfs_uri_unref (vfs_uri);
-
+
recent_data.display_name = NULL;
recent_data.description = NULL;
@@ -61,7 +61,7 @@ nautilus_recent_add_file (NautilusFile *file,
recent_data.app_name = g_strdup (g_get_application_name ());
if (application != NULL)
- recent_data.app_exec = g_strdup (gnome_vfs_mime_application_get_exec (application));
+ recent_data.app_exec = g_strdup (g_app_info_get_executable (application));
else
recent_data.app_exec = g_strdup (DEFAULT_APP_EXEC);
diff --git a/libnautilus-private/nautilus-recent.h b/libnautilus-private/nautilus-recent.h
index c241acc7b..706329b15 100644
--- a/libnautilus-private/nautilus-recent.h
+++ b/libnautilus-private/nautilus-recent.h
@@ -5,9 +5,9 @@
#include <gtk/gtkrecentmanager.h>
#include <libnautilus-private/nautilus-file.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
+#include <gio/gappinfo.h>
void nautilus_recent_add_file (NautilusFile *file,
- GnomeVFSMimeApplication *application);
+ GAppInfo *application);
#endif
diff --git a/libnautilus-private/nautilus-saved-search-file.c b/libnautilus-private/nautilus-saved-search-file.c
index 35ce6d6a3..3bbbc0857 100644
--- a/libnautilus-private/nautilus-saved-search-file.c
+++ b/libnautilus-private/nautilus-saved-search-file.c
@@ -24,39 +24,26 @@
*/
#include <config.h>
#include "nautilus-saved-search-file.h"
-#include <eel/eel-gtk-macros.h>
-
-static void nautilus_saved_search_file_init (gpointer object, gpointer klass);
-static void nautilus_saved_search_file_class_init (gpointer klass);
-
-EEL_CLASS_BOILERPLATE (NautilusSavedSearchFile,
- nautilus_saved_search_file,
- NAUTILUS_TYPE_VFS_FILE)
+#include "nautilus-file-private.h"
+G_DEFINE_TYPE(NautilusSavedSearchFile, nautilus_saved_search_file, NAUTILUS_TYPE_VFS_FILE)
static void
-nautilus_saved_search_file_init (gpointer object, gpointer klass)
+nautilus_saved_search_file_init (NautilusSavedSearchFile *search_file)
{
- NautilusVFSFile *file;
-
- file = NAUTILUS_VFS_FILE (object);
+ NautilusFile *file;
-}
-
-static GnomeVFSFileType
-saved_search_get_file_type (NautilusFile *file)
-{
- return GNOME_VFS_FILE_TYPE_DIRECTORY;
+ file = NAUTILUS_FILE (search_file);
}
static void
-nautilus_saved_search_file_class_init (gpointer klass)
+nautilus_saved_search_file_class_init (NautilusSavedSearchFileClass * klass)
{
NautilusFileClass *file_class;
file_class = NAUTILUS_FILE_CLASS (klass);
- file_class->get_file_type = saved_search_get_file_type;
+ file_class->default_file_type = G_FILE_TYPE_DIRECTORY;
}
diff --git a/libnautilus-private/nautilus-search-directory-file.c b/libnautilus-private/nautilus-search-directory-file.c
index 93e070efa..598d5af56 100644
--- a/libnautilus-private/nautilus-search-directory-file.c
+++ b/libnautilus-private/nautilus-search-directory-file.c
@@ -32,24 +32,18 @@
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include "nautilus-search-directory.h"
#include <gtk/gtksignal.h>
#include <glib/gi18n.h>
#include <string.h>
-static void nautilus_search_directory_file_init (gpointer object,
- gpointer klass);
-static void nautilus_search_directory_file_class_init (gpointer klass);
-
-EEL_CLASS_BOILERPLATE (NautilusSearchDirectoryFile,
- nautilus_search_directory_file,
- NAUTILUS_TYPE_FILE);
-
struct NautilusSearchDirectoryFileDetails {
NautilusSearchDirectory *search_directory;
};
+G_DEFINE_TYPE(NautilusSearchDirectoryFile, nautilus_search_directory_file, NAUTILUS_TYPE_FILE);
+
+
static void
search_directory_file_monitor_add (NautilusFile *file,
gconstpointer client,
@@ -57,6 +51,9 @@ search_directory_file_monitor_add (NautilusFile *file,
{
/* No need for monitoring, we always emit changed when files
are added/removed, and no other metadata changes */
+
+ /* Update display name, in case this didn't happen yet */
+ nautilus_search_directory_file_update_display_name (NAUTILUS_SEARCH_DIRECTORY_FILE (file));
}
static void
@@ -73,6 +70,9 @@ search_directory_file_call_when_ready (NautilusFile *file,
gpointer callback_data)
{
+ /* Update display name, in case this didn't happen yet */
+ nautilus_search_directory_file_update_display_name (NAUTILUS_SEARCH_DIRECTORY_FILE (file));
+
/* All data for directory-as-file is always uptodate */
(* callback) (file, callback_data);
}
@@ -85,7 +85,6 @@ search_directory_file_cancel_call_when_ready (NautilusFile *file,
/* Do nothing here, we don't have any pending calls */
}
-
static gboolean
search_directory_file_check_if_ready (NautilusFile *file,
NautilusFileAttributes attributes)
@@ -93,12 +92,6 @@ search_directory_file_check_if_ready (NautilusFile *file,
return TRUE;
}
-static GnomeVFSFileType
-search_directory_file_get_file_type (NautilusFile *file)
-{
- return GNOME_VFS_FILE_TYPE_DIRECTORY;
-}
-
static gboolean
search_directory_file_get_item_count (NautilusFile *file,
guint *count,
@@ -125,13 +118,13 @@ search_directory_file_get_deep_counts (NautilusFile *file,
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size)
+ goffset *total_size)
{
NautilusSearchDirectory *search_dir;
NautilusFile *dir_file;
GList *file_list, *l;
guint dirs, files;
- GnomeVFSFileType type;
+ GFileType type;
search_dir = NAUTILUS_SEARCH_DIRECTORY (file->details->directory);
@@ -141,7 +134,7 @@ search_directory_file_get_deep_counts (NautilusFile *file,
for (l = file_list; l != NULL; l = l->next) {
dir_file = NAUTILUS_FILE (l->data);
type = nautilus_file_get_file_type (dir_file);
- if (type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (type == G_FILE_TYPE_DIRECTORY) {
dirs++;
} else {
files++;
@@ -172,54 +165,67 @@ search_directory_file_get_where_string (NautilusFile *file)
{
return g_strdup (_("Search"));
}
-
-static void
-nautilus_search_directory_file_init (gpointer object, gpointer klass)
+
+void
+nautilus_search_directory_file_update_display_name (NautilusSearchDirectoryFile *search_file)
{
- NautilusSearchDirectoryFile *search_file;
NautilusFile *file;
- GnomeVFSFileInfo *file_info;
-
- search_file = NAUTILUS_SEARCH_DIRECTORY_FILE (object);
- file = NAUTILUS_FILE(object);
-
- file_info = file->details->info = gnome_vfs_file_info_new ();
-
- file_info->name = g_strdup (_("Search"));
- file_info->mime_type = g_strdup ("x-directory/normal");
- file_info->type = GNOME_VFS_FILE_TYPE_DIRECTORY;
- file_info->flags = GNOME_VFS_FILE_FLAGS_NONE;
- file_info->link_count = 1;
- file_info->size = 0;
- file_info->permissions =
- GNOME_VFS_PERM_OTHER_WRITE |
- GNOME_VFS_PERM_GROUP_WRITE |
- GNOME_VFS_PERM_USER_READ |
- GNOME_VFS_PERM_OTHER_READ |
- GNOME_VFS_PERM_GROUP_READ;
+ NautilusSearchDirectory *search_dir;
+ NautilusQuery *query;
+ char *display_name;
+ gboolean changed;
+
+
+ display_name = NULL;
+ file = NAUTILUS_FILE (search_file);
+ if (file->details->directory) {
+ search_dir = NAUTILUS_SEARCH_DIRECTORY (file->details->directory);
+ query = nautilus_search_directory_get_query (search_dir);
- file_info->valid_fields = GNOME_VFS_FILE_INFO_FIELDS_TYPE |
- GNOME_VFS_FILE_INFO_FIELDS_FLAGS |
- GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FIELDS_SIZE |
- GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS |
- GNOME_VFS_FILE_INFO_FIELDS_LINK_COUNT;
+ if (query != NULL) {
+ display_name = nautilus_query_to_readable_string (query);
+ g_object_unref (query);
+ }
+ }
+
+ if (display_name == NULL) {
+ display_name = g_strdup (_("Search"));
+ }
+
+ changed = nautilus_file_set_display_name (file, display_name, NULL, FALSE);
+ if (changed) {
+ nautilus_file_emit_changed (file);
+ }
+}
+
+static void
+nautilus_search_directory_file_init (NautilusSearchDirectoryFile *search_file)
+{
+ NautilusFile *file;
+
+ file = NAUTILUS_FILE (search_file);
+
+ file->details->got_file_info = TRUE;
+ file->details->mime_type = eel_ref_str_get_unique ("x-directory/normal");
+ file->details->type = G_FILE_TYPE_DIRECTORY;
+ file->details->size = 0;
file->details->file_info_is_up_to_date = TRUE;
- file->details->display_name = g_strdup (_("Search"));
file->details->custom_icon = NULL;
- file->details->activation_uri = NULL;
+ file->details->activation_location = NULL;
file->details->got_link_info = TRUE;
file->details->link_info_is_up_to_date = TRUE;
file->details->directory_count = 0;
file->details->got_directory_count = TRUE;
file->details->directory_count_is_up_to_date = TRUE;
+
+ nautilus_file_set_display_name (file, _("Search"), NULL, FALSE);
}
static void
-nautilus_search_directory_file_class_init (gpointer klass)
+nautilus_search_directory_file_class_init (NautilusSearchDirectoryFileClass *klass)
{
GObjectClass *object_class;
NautilusFileClass *file_class;
@@ -227,11 +233,12 @@ nautilus_search_directory_file_class_init (gpointer klass)
object_class = G_OBJECT_CLASS (klass);
file_class = NAUTILUS_FILE_CLASS (klass);
+ file_class->default_file_type = G_FILE_TYPE_DIRECTORY;
+
file_class->monitor_add = search_directory_file_monitor_add;
file_class->monitor_remove = search_directory_file_monitor_remove;
file_class->call_when_ready = search_directory_file_call_when_ready;
file_class->cancel_call_when_ready = search_directory_file_cancel_call_when_ready;
- file_class->get_file_type = search_directory_file_get_file_type;
file_class->check_if_ready = search_directory_file_check_if_ready;
file_class->get_item_count = search_directory_file_get_item_count;
file_class->get_deep_counts = search_directory_file_get_deep_counts;
diff --git a/libnautilus-private/nautilus-search-directory-file.h b/libnautilus-private/nautilus-search-directory-file.h
index 57432f887..e56a79fce 100644
--- a/libnautilus-private/nautilus-search-directory-file.h
+++ b/libnautilus-private/nautilus-search-directory-file.h
@@ -51,5 +51,6 @@ typedef struct {
} NautilusSearchDirectoryFileClass;
GType nautilus_search_directory_file_get_type (void);
+void nautilus_search_directory_file_update_display_name (NautilusSearchDirectoryFile *search_file);
#endif /* NAUTILUS_SEARCH_DIRECTORY_FILE_H */
diff --git a/libnautilus-private/nautilus-search-directory.c b/libnautilus-private/nautilus-search-directory.c
index 2172bc245..3341cfb1f 100644
--- a/libnautilus-private/nautilus-search-directory.c
+++ b/libnautilus-private/nautilus-search-directory.c
@@ -22,6 +22,7 @@
#include <config.h>
#include "nautilus-search-directory.h"
+#include "nautilus-search-directory-file.h"
#include "nautilus-directory-private.h"
#include "nautilus-file.h"
@@ -29,8 +30,8 @@
#include "nautilus-file-utilities.h"
#include "nautilus-search-engine.h"
#include <eel/eel-glib-extensions.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <gtk/gtksignal.h>
+#include <gio/gioerror.h>
#include <libgnome/gnome-macros.h>
#include <string.h>
#include <sys/time.h>
@@ -484,7 +485,7 @@ search_engine_hits_added (NautilusSearchEngine *engine, GList *hits,
continue;
}
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
for (monitor_list = search->details->monitor_list; monitor_list; monitor_list = monitor_list->next) {
monitor = monitor_list->data;
@@ -522,7 +523,7 @@ search_engine_hits_subtracted (NautilusSearchEngine *engine, GList *hits,
for (hit_list = hits; hit_list != NULL; hit_list = hit_list->next) {
uri = hit_list->data;
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
for (monitor_list = search->details->monitor_list; monitor_list;
monitor_list = monitor_list->next) {
@@ -559,8 +560,13 @@ search_callback_add_pending_file_callbacks (SearchCallback *callback)
static void
search_engine_error (NautilusSearchEngine *engine, const char *error_message, NautilusSearchDirectory *search)
{
+ GError *error;
+
+ error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED,
+ error_message);
nautilus_directory_emit_load_error (NAUTILUS_DIRECTORY (search),
- -1, error_message);
+ error);
+ g_error_free (error);
}
static void
@@ -746,12 +752,9 @@ char *
nautilus_search_directory_generate_new_uri (void)
{
static int counter = 0;
- struct timeval tv;
char *uri;
- gettimeofday (&tv, NULL);
-
- uri = g_strdup_printf (EEL_SEARCH_URI"///%ld-%ld-%d/", tv.tv_sec, tv.tv_usec, counter++);
+ uri = g_strdup_printf (EEL_SEARCH_URI"//%d/", counter++);
return uri;
}
@@ -761,10 +764,13 @@ void
nautilus_search_directory_set_query (NautilusSearchDirectory *search,
NautilusQuery *query)
{
+ NautilusDirectory *dir;
+ NautilusFile *as_file;
+
if (search->details->query != query) {
search->details->modified = TRUE;
}
-
+
if (query) {
g_object_ref (query);
}
@@ -774,6 +780,12 @@ nautilus_search_directory_set_query (NautilusSearchDirectory *search,
}
search->details->query = query;
+
+ dir = NAUTILUS_DIRECTORY (search);
+ as_file = dir->details->as_file;
+ if (as_file != NULL) {
+ nautilus_search_directory_file_update_display_name (NAUTILUS_SEARCH_DIRECTORY_FILE (as_file));
+ }
}
NautilusQuery *
@@ -797,7 +809,7 @@ nautilus_search_directory_new_from_saved_search (const char *uri)
search->details->saved_search_uri = g_strdup (uri);
- file = gnome_vfs_get_local_path_from_uri (uri);
+ file = g_filename_from_uri (uri, NULL, NULL);
if (file != NULL) {
query = nautilus_query_load (file);
if (query != NULL) {
@@ -839,7 +851,7 @@ nautilus_search_directory_save_to_file (NautilusSearchDirectory *search,
{
char *file;
- file = gnome_vfs_get_local_path_from_uri (save_file_uri);
+ file = g_filename_from_uri (save_file_uri, NULL, NULL);
if (file == NULL) {
return;
}
diff --git a/libnautilus-private/nautilus-search-engine-simple.c b/libnautilus-private/nautilus-search-engine-simple.c
index 897503bdd..56108674c 100644
--- a/libnautilus-private/nautilus-search-engine-simple.c
+++ b/libnautilus-private/nautilus-search-engine-simple.c
@@ -28,23 +28,26 @@
#include <glib/gstrfuncs.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
-#include <libgnomevfs/gnome-vfs-directory.h>
+#include <gio/gfile.h>
+#include <gio/gfileenumerator.h>
+#include <gio/gcontenttype.h>
#define BATCH_SIZE 500
typedef struct {
NautilusSearchEngineSimple *engine;
+ GCancellable *cancellable;
- GnomeVFSURI *uri;
GList *mime_types;
char **words;
GList *found_list;
+
+ GQueue *directories; /* GFiles */
+
+ GHashTable *visited;
gint n_processed_files;
GList *uri_hits;
-
- /* accessed on both threads: */
- volatile gboolean cancelled;
} SearchThreadData;
@@ -89,18 +92,23 @@ search_thread_data_new (NautilusSearchEngineSimple *engine,
{
SearchThreadData *data;
char *text, *lower, *normalized, *uri;
-
+ GFile *location;
+
data = g_new0 (SearchThreadData, 1);
data->engine = engine;
+ data->directories = g_queue_new ();
+ data->visited = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
uri = nautilus_query_get_location (query);
+ location = NULL;
if (uri != NULL) {
- data->uri = gnome_vfs_uri_new (uri);
+ location = g_file_new_for_uri (uri);
g_free (uri);
}
- if (data->uri == NULL) {
- data->uri = gnome_vfs_uri_new ("file:///");
+ if (location == NULL) {
+ location = g_file_new_for_path ("/");
}
+ g_queue_push_tail (data->directories, location);
text = nautilus_query_get_text (query);
normalized = g_utf8_normalize (text, -1, G_NORMALIZE_NFD);
@@ -112,15 +120,22 @@ search_thread_data_new (NautilusSearchEngineSimple *engine,
data->mime_types = nautilus_query_get_mime_types (query);
+ data->cancellable = g_cancellable_new ();
+
return data;
}
static void
search_thread_data_free (SearchThreadData *data)
{
- gnome_vfs_uri_unref (data->uri);
+ g_queue_foreach (data->directories,
+ (GFunc)g_object_unref, NULL);
+ g_queue_free (data->directories);
+ g_hash_table_destroy (data->visited);
+ g_object_unref (data->cancellable);
g_strfreev (data->words);
eel_g_list_free_deep (data->mime_types);
+ eel_g_list_free_deep (data->uri_hits);
g_free (data);
}
@@ -131,7 +146,7 @@ search_thread_done_idle (gpointer user_data)
data = user_data;
- if (!data->cancelled) {
+ if (!g_cancellable_is_cancelled (data->cancellable)) {
nautilus_search_engine_finished (NAUTILUS_SEARCH_ENGINE (data->engine));
data->engine->details->active_search = NULL;
}
@@ -154,7 +169,7 @@ search_thread_add_hits_idle (gpointer user_data)
hits = user_data;
- if (!hits->thread_data->cancelled) {
+ if (!g_cancellable_is_cancelled (hits->thread_data->cancellable)) {
nautilus_search_engine_hits_added (NAUTILUS_SEARCH_ENGINE (hits->thread_data->engine),
hits->uris);
}
@@ -181,46 +196,54 @@ send_batch (SearchThreadData *data)
data->uri_hits = NULL;
}
-static gboolean
-search_visit_func (const gchar *rel_path,
- GnomeVFSFileInfo *info,
- gboolean recursing_will_loop,
- gpointer user_data,
- gboolean *recurse)
+#define STD_ATTRIBUTES \
+ G_FILE_ATTRIBUTE_STD_NAME "," \
+ G_FILE_ATTRIBUTE_STD_DISPLAY_NAME "," \
+ G_FILE_ATTRIBUTE_STD_IS_HIDDEN "," \
+ G_FILE_ATTRIBUTE_STD_TYPE "," \
+ G_FILE_ATTRIBUTE_ID_FILE
+
+static void
+visit_directory (GFile *dir, SearchThreadData *data)
{
- SearchThreadData *data;
- int i;
+ GFileEnumerator *enumerator;
+ GFileInfo *info;
+ GFile *child;
+ const char *mime_type, *display_name;
char *lower_name, *normalized;
- GnomeVFSURI *uri;
gboolean hit;
+ int i;
GList *l;
- gboolean is_hidden;
+ const char *id;
+ gboolean visited;
+
+ enumerator = g_file_enumerate_children (dir,
+ data->mime_types != NULL ?
+ STD_ATTRIBUTES ","
+ G_FILE_ATTRIBUTE_STD_CONTENT_TYPE
+ :
+ STD_ATTRIBUTES
+ ,
+ 0, data->cancellable, NULL);
- data = user_data;
-
- if (data->cancelled) {
- return FALSE;
- }
-
- is_hidden = *info->name == '.';
-
- if (recursing_will_loop || is_hidden) {
- *recurse = FALSE;
- } else {
- *recurse = TRUE;
+ if (enumerator == NULL) {
+ return;
}
- hit = FALSE;
-
- if (!is_hidden) {
- if (g_utf8_validate (info->name, -1, NULL)) {
- normalized = g_utf8_normalize (info->name, -1, G_NORMALIZE_NFD);
- lower_name = g_utf8_strdown (normalized, -1);
- g_free (normalized);
- } else {
- lower_name = g_ascii_strdown (info->name, -1);
+ while ((info = g_file_enumerator_next_file (enumerator, data->cancellable, NULL)) != NULL) {
+ if (g_file_info_get_is_hidden (info)) {
+ goto next;
+ }
+
+ display_name = g_file_info_get_display_name (info);
+ if (display_name == NULL) {
+ goto next;
}
+ normalized = g_utf8_normalize (display_name, -1, G_NORMALIZE_NFD);
+ lower_name = g_utf8_strdown (normalized, -1);
+ g_free (normalized);
+
hit = TRUE;
for (i = 0; data->words[i] != NULL; i++) {
if (strstr (lower_name, data->words[i]) == NULL) {
@@ -229,56 +252,82 @@ search_visit_func (const gchar *rel_path,
}
}
g_free (lower_name);
- }
-
- if (hit && data->mime_types != NULL) {
- hit = FALSE;
-
- if (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) {
- for (l = data->mime_types; l != NULL; l = l->next) {
- if (strcmp (info->mime_type, l->data) == 0) {
+
+ if (hit && data->mime_types) {
+ mime_type = g_file_info_get_content_type (info);
+ hit = FALSE;
+
+ for (l = data->mime_types; mime_type != NULL && l != NULL; l = l->next) {
+ if (g_content_type_equals (mime_type, l->data) == 0) {
hit = TRUE;
break;
}
}
}
- }
+
+ child = g_file_get_child (dir, g_file_info_get_name (info));
+
+ if (hit) {
+ data->uri_hits = g_list_prepend (data->uri_hits, g_file_get_uri (child));
+ }
+
+ data->n_processed_files++;
+ if (data->n_processed_files > BATCH_SIZE) {
+ send_batch (data);
+ }
- if (hit) {
- uri = gnome_vfs_uri_append_string (data->uri, rel_path);
- data->uri_hits = g_list_prepend (data->uri_hits, gnome_vfs_uri_to_string (uri, 0));
- gnome_vfs_uri_unref (uri);
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY) {
+ id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILE);
+ visited = FALSE;
+ if (id) {
+ if (g_hash_table_lookup_extended (data->visited,
+ id, NULL, NULL)) {
+ visited = TRUE;
+ } else {
+ g_hash_table_insert (data->visited, g_strdup (id), NULL);
+ }
+ }
+
+ if (!visited) {
+ g_queue_push_tail (data->directories, g_object_ref (child));
+ }
+ }
+
+ g_object_unref (child);
+ next:
+ g_object_unref (info);
}
- data->n_processed_files++;
-
- if (data->n_processed_files > BATCH_SIZE) {
- send_batch (data);
- }
-
-
- return TRUE;
+ g_object_unref (enumerator);
}
-
static gpointer
search_thread_func (gpointer user_data)
{
SearchThreadData *data;
- GnomeVFSResult res;
- GnomeVFSDirectoryVisitOptions visit_options;
+ GFile *dir;
+ GFileInfo *info;
+ const char *id;
data = user_data;
- visit_options = GNOME_VFS_DIRECTORY_VISIT_LOOPCHECK |
- GNOME_VFS_DIRECTORY_VISIT_IGNORE_RECURSE_ERROR;
-
- res = gnome_vfs_directory_visit_uri (data->uri,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE,
- visit_options,
- search_visit_func,
- data);
+ /* Insert id for toplevel directory into visited */
+ dir = g_queue_peek_head (data->directories);
+ info = g_file_query_info (dir, G_FILE_ATTRIBUTE_ID_FILE, 0, data->cancellable, NULL);
+ if (info) {
+ id = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_ID_FILE);
+ if (id) {
+ g_hash_table_insert (data->visited, g_strdup (id), NULL);
+ }
+ g_object_unref (info);
+ }
+
+ while (!g_cancellable_is_cancelled (data->cancellable) &&
+ (dir = g_queue_pop_head (data->directories)) != NULL) {
+ visit_directory (dir, data);
+ g_object_unref (dir);
+ }
send_batch (data);
g_idle_add (search_thread_done_idle, data);
@@ -317,7 +366,7 @@ nautilus_search_engine_simple_stop (NautilusSearchEngine *engine)
simple = NAUTILUS_SEARCH_ENGINE_SIMPLE (engine);
if (simple->details->active_search != NULL) {
- simple->details->active_search->cancelled = TRUE;
+ g_cancellable_cancel (simple->details->active_search->cancellable);
simple->details->active_search = NULL;
}
}
diff --git a/libnautilus-private/nautilus-search-engine-tracker.c b/libnautilus-private/nautilus-search-engine-tracker.c
index 6799c053a..80c2f6664 100644
--- a/libnautilus-private/nautilus-search-engine-tracker.c
+++ b/libnautilus-private/nautilus-search-engine-tracker.c
@@ -24,7 +24,6 @@
#include <config.h>
#include "nautilus-search-engine-tracker.h"
#include <tracker.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
@@ -92,7 +91,7 @@ search_callback (char **results, GError *error, gpointer user_data)
char *uri;
- uri = gnome_vfs_get_uri_from_local_path ((char *)*results_p);
+ uri = g_filename_to_uri ((char *)*results_p);
if (uri) {
hit_uris = g_list_prepend (hit_uris, (char *)uri);
}
@@ -132,7 +131,7 @@ nautilus_search_engine_tracker_start (NautilusSearchEngine *engine)
location_uri = nautilus_query_get_location (tracker->details->query);
if (location_uri) {
- location = gnome_vfs_get_local_path_from_uri (location_uri);
+ location = g_filename_from_uri (location_uri, NULL, NULL);
g_free (location_uri);
} else {
location = NULL;
diff --git a/libnautilus-private/nautilus-search-engine.h b/libnautilus-private/nautilus-search-engine.h
index 79e68aeb3..2be4c1e13 100644
--- a/libnautilus-private/nautilus-search-engine.h
+++ b/libnautilus-private/nautilus-search-engine.h
@@ -25,7 +25,6 @@
#define NAUTILUS_SEARCH_ENGINE_H
#include <glib-object.h>
-#include <libgnomevfs/gnome-vfs-result.h>
#include <libnautilus-private/nautilus-query.h>
#define NAUTILUS_TYPE_SEARCH_ENGINE (nautilus_search_engine_get_type ())
diff --git a/libnautilus-private/nautilus-signaller.c b/libnautilus-private/nautilus-signaller.c
index a10e27d87..93037ad1b 100644
--- a/libnautilus-private/nautilus-signaller.c
+++ b/libnautilus-private/nautilus-signaller.c
@@ -40,6 +40,7 @@ enum {
EMBLEMS_CHANGED,
POPUP_MENU_CHANGED,
USER_DIRS_CHANGED,
+ MIME_DATA_CHANGED,
LAST_SIGNAL
};
@@ -103,4 +104,12 @@ nautilus_signaller_class_init (NautilusSignallerClass *class)
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[MIME_DATA_CHANGED] =
+ g_signal_new ("mime_data_changed",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
}
diff --git a/libnautilus-private/nautilus-theme.c b/libnautilus-private/nautilus-theme.c
deleted file mode 100644
index a2cc5d56e..000000000
--- a/libnautilus-private/nautilus-theme.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-theme.c: theme framework with xml-based theme definition files
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Andy Hertzfeld <andy@eazel.com>
-*/
-
-#include <config.h>
-#include "nautilus-theme.h"
-
-#include "nautilus-file-utilities.h"
-#include "nautilus-file.h"
-#include "nautilus-global-preferences.h"
-#include "nautilus-metadata.h"
-#include <eel/eel-debug.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string-list.h>
-#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
-#include <eel/eel-xml-extensions.h>
-#include <libxml/parser.h>
-#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <librsvg/rsvg.h>
-
-/* static globals to hold the last accessed theme files */
-static char *last_theme_name = NULL;
-static xmlDocPtr last_theme_document = NULL;
-
-static char *theme_from_preferences = NULL;
-
-#define THEME_PREVIEW_ICON_WIDTH 70
-#define THEME_PREVIEW_ICON_HEIGHT 48
-
-static void
-theme_changed_callback (gpointer callback_data)
-{
- g_free (theme_from_preferences);
- theme_from_preferences = eel_preferences_get (NAUTILUS_PREFERENCES_THEME);
-}
-
-/* return the current theme by asking the preferences machinery */
-char *
-nautilus_theme_get_theme (void)
-{
- static gboolean theme_changed_callback_installed = FALSE;
-
- /* Add the callback once for the life of our process */
- if (!theme_changed_callback_installed) {
- eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
- theme_changed_callback,
- NULL);
- theme_changed_callback_installed = TRUE;
-
- /* Peek for the first time */
- theme_changed_callback (NULL);
- }
-
- return g_strdup (theme_from_preferences);
-}
-
-/* load and parse a theme file */
-static xmlDocPtr
-load_theme_document (const char *theme_name)
-{
- xmlDocPtr theme_document;
- char *theme_path, *temp_str;
- char *user_themes_directory;
-
- temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
- theme_path = nautilus_pixmap_file (temp_str);
- g_free(temp_str);
-
- /* if we can't find the theme document in the global area, try in the user's home */
- if (theme_path == NULL) {
- user_themes_directory = nautilus_theme_get_user_themes_directory ();
- temp_str = g_strdup_printf("%s/%s.xml", theme_name, theme_name);
- theme_path = g_build_filename (user_themes_directory, temp_str, NULL);
-
- g_free (user_themes_directory);
- g_free (temp_str);
-
- if (!g_file_test (theme_path, G_FILE_TEST_EXISTS)) {
- g_free (theme_path);
- theme_path = NULL;
- }
- }
-
- /* if the file cannot be found, return NULL for no document */
- if (theme_path == NULL) {
- return NULL;
- }
-
- /* load and parse the theme file */
- theme_document = xmlParseFile (theme_path);
- g_free (theme_path);
-
- return theme_document;
-}
-
-static void
-free_last_theme (void)
-{
- if (last_theme_document != NULL) {
- xmlFreeDoc (last_theme_document);
- }
- g_free (last_theme_name);
-}
-
-/* Fetch data from the specified theme. Cache the last theme file as a parsed xml document
- */
-char *
-nautilus_theme_get_theme_data_from_theme (const char *resource_name, const char *property_name, const char *theme_name)
-{
- char *temp_str;
- char *theme_data;
- xmlDocPtr theme_document;
- xmlNodePtr resource_node;
- static gboolean did_set_up_free_last_theme = FALSE;
-
- /* fetch the current theme name */
- theme_data = NULL;
-
- if (eel_strcmp (theme_name, last_theme_name) == 0) {
- theme_document = last_theme_document;
- } else {
- /* release the old saved data, since the theme changed */
- if (!did_set_up_free_last_theme) {
- eel_debug_call_at_shutdown (free_last_theme);
- did_set_up_free_last_theme = TRUE;
- }
- free_last_theme ();
-
- last_theme_name = g_strdup (theme_name);
- last_theme_document = load_theme_document (theme_name);
- theme_document = last_theme_document;
- }
-
- if (theme_document != NULL) {
- /* fetch the resource node */
- resource_node = eel_xml_get_child_by_name (xmlDocGetRootElement (theme_document), resource_name);
- if (resource_node != NULL) {
- temp_str = xmlGetProp (resource_node, property_name);
- if (temp_str != NULL) {
- theme_data = g_strdup (temp_str);
- xmlFree (temp_str);
- }
- }
- }
-
- return theme_data;
-}
-
-/* Fetch data from the current theme.
- */
-char *
-nautilus_theme_get_theme_data (const char *resource_name, const char *property_name)
-{
- char *result;
- char *theme_name;
- theme_name = nautilus_theme_get_theme ();
- result = nautilus_theme_get_theme_data_from_theme (resource_name, property_name, theme_name);
- g_free (theme_name);
- return result;
-}
-
-/* utility routine to return the full path to a themed image that
- searches the local themes if it can't find it in the shared space */
-static char *
-nautilus_pixmap_file_may_be_local (const char *themed_image)
-{
- char *image_path, *user_themes_directory;
-
- image_path = nautilus_pixmap_file (themed_image);
- if (image_path == NULL) {
- user_themes_directory = nautilus_theme_get_user_themes_directory ();
-
- image_path = g_build_filename (user_themes_directory, themed_image, NULL);
- if (!g_file_test (image_path, G_FILE_TEST_EXISTS)) {
- g_free (image_path);
- image_path = NULL;
- }
-
- g_free (user_themes_directory);
- }
- return image_path;
-}
-
-/* given a theme, fetch the full path name of an image with the passed-in name */
-/* return NULL if there isn't a corresponding image. Optionally, add a .png suffix if we */
-/* cant otherwise find one. */
-
-char *
-nautilus_theme_get_image_path_from_theme (const char *image_name, const char* theme_name)
-{
- char *image_path, *png_string, *temp_str;
-
- temp_str = g_strdup_printf ("%s/%s", theme_name, image_name);
- image_path = nautilus_pixmap_file_may_be_local (temp_str);
-
- /* see if a theme-specific image exists; if so, return it */
- if (image_path != NULL) {
- g_free (temp_str);
- return image_path;
- }
-
- /* try if with a .png extension if it doesn't already have one */
- if (!eel_istr_has_suffix (image_name, ".png")) {
- png_string = g_strconcat (temp_str, ".png", NULL);
- image_path = nautilus_pixmap_file_may_be_local (png_string);
- g_free (png_string);
-
- if (image_path) {
- g_free (temp_str);
- return image_path;
- }
- }
- g_free (temp_str);
-
-
- /* we couldn't find a theme specific one, so look for a general image */
- image_path = nautilus_pixmap_file (image_name);
- if (image_path != NULL) {
- return image_path;
- }
-
- /* if it doesn't have a .png extension, try it with that */
- if (!eel_istr_has_suffix (image_name, ".png")) {
- png_string = g_strconcat (image_name, ".png", NULL);
- image_path = nautilus_pixmap_file (png_string);
- g_free (png_string);
-
- if (image_path) {
- return image_path;
- }
- }
-
- /* we couldn't find anything, so return NULL */
- g_free (image_path);
- return NULL;
-}
-
-/* commonly used cover to get_image_path_from_theme to return an image path using the current theme */
-char *
-nautilus_theme_get_image_path (const char *image_name)
-{
- char *theme_name, *image_path;
-
- theme_name = nautilus_theme_get_theme ();
- image_path = nautilus_theme_get_image_path_from_theme (image_name, theme_name);
- g_free (theme_name);
-
- return image_path;
-}
-
-char *
-nautilus_theme_get_user_themes_directory (void)
-{
- char *user_directory;
- char *user_themes_directory;
-
- user_directory = nautilus_get_user_directory ();
- user_themes_directory = g_build_filename (user_directory, "themes", NULL);
- g_free (user_directory);
-
- return user_themes_directory;
-}
diff --git a/libnautilus-private/nautilus-theme.h b/libnautilus-private/nautilus-theme.h
deleted file mode 100644
index 5c04560b8..000000000
--- a/libnautilus-private/nautilus-theme.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-theme.h: theme framework with xml-based theme definition files
-
- Copyright (C) 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Authors: Andy Hertzfeld <andy@eazel.com>
-*/
-
-#ifndef NAUTILUS_THEME_H
-#define NAUTILUS_THEME_H
-
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-
-/* A callback which can be invoked for each available theme. */
-typedef void (*NautilusThemeCallback) (const char *name,
- const char *path,
- const char *display_name,
- const char *description,
- GdkPixbuf *preview_pixbuf,
- gboolean builtin,
- gpointer callback_data);
-
-/* get the current theme */
-char *nautilus_theme_get_theme (void);
-
-
-/* fetch data from the current theme */
-char *nautilus_theme_get_theme_data (const char *resource_name,
- const char *property_name);
-
-/* fetch data from the specified theme */
-char *nautilus_theme_get_theme_data_from_theme (const char *resource_name,
- const char *property_name,
- const char *theme_name);
-
-/* given the current theme, get the path name of an image with the passed-in name */
-char *nautilus_theme_get_image_path (const char *image_name);
-
-/* like get_image_path, put use the passed in theme instead of the current one */
-char *nautilus_theme_get_image_path_from_theme (const char *image_name,
- const char *theme_name);
-/* Return the directory where user themes are stored */
-char *nautilus_theme_get_user_themes_directory (void);
-
-#endif /* NAUTILUS_THEME_H */
diff --git a/libnautilus-private/nautilus-thumbnails.c b/libnautilus-private/nautilus-thumbnails.c
index 91f79718f..1b6cc9014 100644
--- a/libnautilus-private/nautilus-thumbnails.c
+++ b/libnautilus-private/nautilus-thumbnails.c
@@ -28,15 +28,13 @@
#include "nautilus-directory-notify.h"
#include "nautilus-global-preferences.h"
-#include "nautilus-icon-factory-private.h"
-#include "nautilus-icon-factory.h"
+#include "nautilus-file-utilities.h"
#include <math.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <librsvg/rsvg.h>
#include <errno.h>
#include <stdio.h>
@@ -45,6 +43,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
+#include <libgnomeui/gnome-thumbnail.h>
#include "nautilus-file-private.h"
@@ -70,7 +69,7 @@ typedef struct {
} NautilusThumbnailInfo;
struct NautilusThumbnailAsyncLoadHandle {
- EelReadFileHandle *eel_read_handle;
+ GCancellable *cancellable;
char *file_path;
guint base_size;
guint nominal_size;
@@ -120,18 +119,17 @@ static int thumbnail_icon_size = 0;
static gboolean
get_file_mtime (const char *file_uri, time_t* mtime)
{
- GnomeVFSFileInfo *file_info;
+ GFile *file;
+ GFileInfo *info;
- /* gather the info and then compare modification times */
- file_info = gnome_vfs_file_info_new ();
- gnome_vfs_get_file_info (file_uri, file_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
+ *mtime = INVALID_MTIME;
- if (file_info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MTIME)
- *mtime = file_info->mtime;
- else
- *mtime = INVALID_MTIME;
-
- gnome_vfs_file_info_unref (file_info);
+ file = g_file_new_for_uri (file_uri);
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
+ if (info) {
+ *mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ g_object_unref (info);
+ }
return TRUE;
}
@@ -144,6 +142,19 @@ free_thumbnail_info (NautilusThumbnailInfo *info)
g_free (info);
}
+static GnomeThumbnailFactory *
+get_thumbnail_factory (void)
+{
+ static GnomeThumbnailFactory *thumbnail_factory = NULL;
+
+ if (thumbnail_factory == NULL) {
+ thumbnail_factory = gnome_thumbnail_factory_new (GNOME_THUMBNAIL_SIZE_NORMAL);
+ }
+
+ return thumbnail_factory;
+}
+
+
/* This function is added as a very low priority idle function to start the
thread to create any needed thumbnails. It is added with a very low priority
so that it doesn't delay showing the directory in the icon/list views.
@@ -156,7 +167,7 @@ thumbnail_thread_starter_cb (gpointer data)
/* Don't do this in thread, since g_object_ref is not threadsafe */
if (thumbnail_factory == NULL) {
- thumbnail_factory = nautilus_icon_factory_get_thumbnail_factory ();
+ thumbnail_factory = get_thumbnail_factory ();
}
/* We create the thread in the detached state, as we don't need/want
@@ -190,33 +201,32 @@ nautilus_update_thumbnail_file_copied (const char *source_file_uri,
{
char *old_thumbnail_path;
GdkPixbuf *pixbuf;
- GnomeVFSFileInfo *file_info;
+ GFileInfo *file_info;
GnomeThumbnailFactory *factory;
+ GFile *destination_file;
old_thumbnail_path = gnome_thumbnail_path_for_uri (source_file_uri, GNOME_THUMBNAIL_SIZE_NORMAL);
if (old_thumbnail_path != NULL &&
g_file_test (old_thumbnail_path, G_FILE_TEST_EXISTS)) {
- file_info = gnome_vfs_file_info_new ();
- if (gnome_vfs_get_file_info (destination_file_uri,
- file_info,
- GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK) {
+ destination_file = g_file_new_for_uri (destination_file_uri);
+ file_info = g_file_query_info (destination_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
+ g_object_unref (destination_file);
+ if (file_info != NULL) {
pixbuf = gdk_pixbuf_new_from_file (old_thumbnail_path, NULL);
if (pixbuf && gnome_thumbnail_has_uri (pixbuf, source_file_uri)) {
- factory = nautilus_icon_factory_get_thumbnail_factory ();
+ factory = get_thumbnail_factory ();
gnome_thumbnail_factory_save_thumbnail (factory,
pixbuf,
destination_file_uri,
- file_info->mtime);
- g_object_unref (factory);
+ g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED));
}
if (pixbuf) {
g_object_unref (pixbuf);
}
-
+ g_object_unref (file_info);
}
- gnome_vfs_file_info_unref (file_info);
}
g_free (old_thumbnail_path);
@@ -242,6 +252,24 @@ nautilus_remove_thumbnail_for_file (const char *file_uri)
g_free (thumbnail_path);
}
+static GdkPixbuf *
+nautilus_get_thumbnail_frame (void)
+{
+ char *image_path;
+ static GdkPixbuf *thumbnail_frame = NULL;
+
+ if (thumbnail_frame == NULL) {
+ image_path = nautilus_pixmap_file ("thumbnail_frame.png");
+ if (image_path != NULL) {
+ thumbnail_frame = gdk_pixbuf_new_from_file (image_path, NULL);
+ }
+ g_free (image_path);
+ }
+
+ return thumbnail_frame;
+}
+
+
void
nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf)
{
@@ -252,22 +280,59 @@ nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf)
* an old Nautilus), so we must embed it in a frame.
*/
- frame = nautilus_icon_factory_get_thumbnail_frame ();
+ frame = nautilus_get_thumbnail_frame ();
if (frame == NULL) {
return;
}
- left_offset = 3;
- top_offset = 3;
- right_offset = 6;
- bottom_offset = 6;
+ left_offset = NAUTILUS_THUMBNAIL_FRAME_LEFT;
+ top_offset = NAUTILUS_THUMBNAIL_FRAME_TOP;
+ right_offset = NAUTILUS_THUMBNAIL_FRAME_RIGHT;
+ bottom_offset = NAUTILUS_THUMBNAIL_FRAME_BOTTOM;
pixbuf_with_frame = eel_embed_image_in_frame
(*pixbuf, frame,
left_offset, top_offset, right_offset, bottom_offset);
g_object_unref (*pixbuf);
- *pixbuf=pixbuf_with_frame;
+ *pixbuf = pixbuf_with_frame;
+}
+
+GdkPixbuf *
+nautilus_thumbnail_unframe_image (GdkPixbuf *pixbuf)
+{
+ GdkPixbuf *pixbuf_without_frame, *frame;
+ int left_offset, top_offset, right_offset, bottom_offset;
+ int w, h;
+
+ /* The pixbuf isn't already framed (i.e., it was not made by
+ * an old Nautilus), so we must embed it in a frame.
+ */
+
+ frame = nautilus_get_thumbnail_frame ();
+ if (frame == NULL) {
+ return NULL;
+ }
+
+ left_offset = NAUTILUS_THUMBNAIL_FRAME_LEFT;
+ top_offset = NAUTILUS_THUMBNAIL_FRAME_TOP;
+ right_offset = NAUTILUS_THUMBNAIL_FRAME_RIGHT;
+ bottom_offset = NAUTILUS_THUMBNAIL_FRAME_BOTTOM;
+
+ w = gdk_pixbuf_get_width (pixbuf) - left_offset - right_offset;
+ h = gdk_pixbuf_get_height (pixbuf) - top_offset - bottom_offset;
+ pixbuf_without_frame =
+ gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf),
+ gdk_pixbuf_get_has_alpha (pixbuf),
+ gdk_pixbuf_get_bits_per_sample (pixbuf),
+ w, h);
+
+ gdk_pixbuf_copy_area (pixbuf,
+ left_offset, top_offset,
+ w, h,
+ pixbuf_without_frame, 0, 0);
+
+ return pixbuf_without_frame;
}
typedef struct {
@@ -443,26 +508,30 @@ nautilus_thumbnail_load_image (const char *path,
}
static void
-async_thumbnail_read_image (GnomeVFSResult result,
- GnomeVFSFileSize file_size,
- char *file_contents,
+async_thumbnail_read_image (GObject *source_object,
+ GAsyncResult *res,
gpointer callback_data)
{
+ NautilusThumbnailAsyncLoadHandle *handle = callback_data;
GdkPixbuf *pixbuf;
double scale_x, scale_y;
-
- NautilusThumbnailAsyncLoadHandle *handle = callback_data;
+ gsize file_size;
+ char *file_contents;
pixbuf = NULL;
scale_x = scale_y = 1.0;
- if (result == GNOME_VFS_OK) {
+ if (g_file_load_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL)) {
pixbuf = get_pixbuf_from_data (file_contents, file_size,
handle->file_path,
handle->base_size,
handle->nominal_size,
handle->force_nominal,
&scale_x, &scale_y);
+ g_free (file_contents);
}
handle->load_func (handle,
@@ -472,6 +541,7 @@ async_thumbnail_read_image (GnomeVFSResult result,
gdk_pixbuf_unref (pixbuf);
+ g_object_unref (handle->cancellable);
g_free (handle->file_path);
g_free (handle);
}
@@ -485,18 +555,11 @@ nautilus_thumbnail_load_image_async (const char *path,
gpointer load_func_user_data)
{
NautilusThumbnailAsyncLoadHandle *handle;
- char *uri;
+ GFile *location;
- uri = gnome_vfs_get_uri_from_local_path (path);
- if (uri == NULL) {
- return NULL;
- }
handle = g_new (NautilusThumbnailAsyncLoadHandle, 1);
- handle->eel_read_handle =
- eel_read_entire_file_async (uri, GNOME_VFS_PRIORITY_DEFAULT,
- (EelReadFileCallback) async_thumbnail_read_image,
- handle);
+ handle->cancellable = g_cancellable_new ();
handle->file_path = g_strdup (path);
handle->base_size = base_size;
handle->nominal_size = nominal_size;
@@ -504,8 +567,13 @@ nautilus_thumbnail_load_image_async (const char *path,
handle->load_func = load_func;
handle->load_func_user_data = load_func_user_data;
- g_free (uri);
+ location = g_file_new_for_path (path);
+ g_file_load_contents_async (location, handle->cancellable,
+ async_thumbnail_read_image,
+ handle);
+ g_object_unref (location);
+
return handle;
}
@@ -514,9 +582,7 @@ nautilus_thumbnail_load_image_cancel (NautilusThumbnailAsyncLoadHandle *handle)
{
g_assert (handle != NULL);
- eel_read_file_cancel (handle->eel_read_handle);
- g_free (handle->file_path);
- g_free (handle);
+ g_cancellable_cancel (handle->cancellable);
}
void
@@ -642,14 +708,16 @@ thumbnail_thread_notify_file_changed (gpointer image_uri)
GDK_THREADS_ENTER ();
- file = nautilus_file_get ((char *) image_uri);
+ file = nautilus_file_get_by_uri ((char *) image_uri);
#ifdef DEBUG_THUMBNAILS
g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri);
#endif
if (file != NULL) {
nautilus_file_set_is_thumbnailing (file, FALSE);
- nautilus_file_changed (file);
+ nautilus_file_invalidate_attributes (file,
+ NAUTILUS_FILE_ATTRIBUTE_THUMBNAIL |
+ NAUTILUS_FILE_ATTRIBUTE_INFO);
nautilus_file_unref (file);
}
g_free (image_uri);
@@ -659,6 +727,30 @@ thumbnail_thread_notify_file_changed (gpointer image_uri)
return FALSE;
}
+gboolean
+nautilus_can_thumbnail (NautilusFile *file)
+{
+ GnomeThumbnailFactory *factory;
+ gboolean res;
+ char *uri;
+ time_t mtime;
+ char *mime_type;
+
+ uri = nautilus_file_get_uri (file);
+ mime_type = nautilus_file_get_mime_type (file);
+ mtime = nautilus_file_get_mtime (file);
+
+ factory = get_thumbnail_factory ();
+ res = gnome_thumbnail_factory_can_thumbnail (factory,
+ uri,
+ mime_type,
+ mtime);
+ g_free (mime_type);
+ g_free (uri);
+
+ return res;
+}
+
void
nautilus_create_thumbnail (NautilusFile *file)
{
@@ -675,10 +767,10 @@ nautilus_create_thumbnail (NautilusFile *file)
/* Hopefully the NautilusFile will already have the image file mtime,
so we can just use that. Otherwise we have to get it ourselves. */
- if (file->details->info
- && file->details->file_info_is_up_to_date
- && file->details->info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MTIME) {
- file_mtime = file->details->info->mtime;
+ if (file->details->got_file_info &&
+ file->details->file_info_is_up_to_date &&
+ file->details->mtime != 0) {
+ file_mtime = file->details->mtime;
} else {
get_file_mtime (info->image_uri, &file_mtime);
}
diff --git a/libnautilus-private/nautilus-thumbnails.h b/libnautilus-private/nautilus-thumbnails.h
index 6e463b59e..26755ad2b 100644
--- a/libnautilus-private/nautilus-thumbnails.h
+++ b/libnautilus-private/nautilus-thumbnails.h
@@ -37,9 +37,17 @@ typedef void (* NautilusThumbnailAsyncLoadFunc) (NautilusThumbnailAsyncLoadHandl
double scale_y,
gpointer user_data);
+
+#define NAUTILUS_THUMBNAIL_FRAME_LEFT 3
+#define NAUTILUS_THUMBNAIL_FRAME_TOP 3
+#define NAUTILUS_THUMBNAIL_FRAME_RIGHT 6
+#define NAUTILUS_THUMBNAIL_FRAME_BOTTOM 6
+
/* Returns NULL if there's no thumbnail yet. */
void nautilus_create_thumbnail (NautilusFile *file);
+gboolean nautilus_can_thumbnail (NautilusFile *file);
void nautilus_thumbnail_frame_image (GdkPixbuf **pixbuf);
+GdkPixbuf *nautilus_thumbnail_unframe_image (GdkPixbuf *pixbuf);
GdkPixbuf *nautilus_thumbnail_load_image (const char *path,
guint base_size,
guint nominal_size,
diff --git a/libnautilus-private/nautilus-trash-directory.c b/libnautilus-private/nautilus-trash-directory.c
deleted file mode 100644
index 153049306..000000000
--- a/libnautilus-private/nautilus-trash-directory.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-trash-directory.c: Subclass of NautilusDirectory to implement the
- virtual trash directory.
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Darin Adler <darin@bentspoon.com>
-*/
-
-#include <config.h>
-#include "nautilus-trash-directory.h"
-
-#include "nautilus-directory-private.h"
-#include "nautilus-trash-monitor.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-stock-dialogs.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtksignal.h>
-#include <glib/gi18n.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-
-struct NautilusTrashDirectoryDetails {
- GHashTable *volumes;
-};
-
-typedef struct {
- NautilusTrashDirectory *trash;
- GnomeVFSVolume *volume;
-
- GnomeVFSAsyncHandle *handle;
- NautilusDirectory *real_directory;
-} TrashVolume;
-
-static void add_volume (NautilusTrashDirectory *trash,
- GnomeVFSVolume *volume);
-
-GNOME_CLASS_BOILERPLATE (NautilusTrashDirectory, nautilus_trash_directory,
- NautilusMergedDirectory, NAUTILUS_TYPE_MERGED_DIRECTORY)
-
-static void
-find_directory_callback (GnomeVFSAsyncHandle *handle,
- GList *results,
- gpointer callback_data)
-{
- TrashVolume *trash_volume;
- GnomeVFSFindDirectoryResult *result;
- char *uri;
- NautilusDirectory *directory;
-
- trash_volume = callback_data;
-
- g_assert (eel_g_list_exactly_one_item (results));
- g_assert (trash_volume != NULL);
- g_assert (NAUTILUS_IS_TRASH_DIRECTORY (trash_volume->trash));
- g_assert (trash_volume->real_directory == NULL);
- g_assert (trash_volume->handle == handle);
-
- /* We are done with the async. I/O. */
- trash_volume->handle = NULL;
-
- /* If we can't find the trash, ignore it silently. */
- result = results->data;
- if (result->result != GNOME_VFS_OK) {
- return;
- }
-
- /* If we can't make a directory object, ignore it silently. */
- uri = gnome_vfs_uri_to_string (result->uri,
- GNOME_VFS_URI_HIDE_NONE);
- directory = nautilus_directory_get (uri);
- g_free (uri);
- if (directory == NULL) {
- return;
- }
-
- /* Add the directory object. */
- trash_volume->real_directory = directory;
- nautilus_merged_directory_add_real_directory
- (NAUTILUS_MERGED_DIRECTORY (trash_volume->trash),
- directory);
-}
-
-static gboolean
-get_trash_volume (NautilusTrashDirectory *trash,
- GnomeVFSVolume *volume,
- TrashVolume **trash_volume,
- GnomeVFSURI **volume_mount_uri)
-{
- char *uri_str;
-
- /* Quick out if we already know about this volume. */
- *trash_volume = g_hash_table_lookup (trash->details->volumes,
- volume);
-
- if (*trash_volume != NULL && (*trash_volume)->real_directory != NULL) {
- return FALSE;
- }
-
- if (!gnome_vfs_volume_handles_trash (volume)) {
- return FALSE;
- }
-
- uri_str = gnome_vfs_volume_get_activation_uri (volume);
- *volume_mount_uri = gnome_vfs_uri_new (uri_str);
- g_free (uri_str);
-
- if (*trash_volume == NULL) {
- /* Make the structure used to track the trash for this volume. */
- *trash_volume = g_new0 (TrashVolume, 1);
- (*trash_volume)->trash = trash;
- (*trash_volume)->volume = gnome_vfs_volume_ref (volume);
- g_hash_table_insert (trash->details->volumes, volume, *trash_volume);
- }
-
- return TRUE;
-}
-
-static void
-add_volume (NautilusTrashDirectory *trash,
- GnomeVFSVolume *volume)
-{
- TrashVolume *trash_volume;
- GnomeVFSURI *volume_mount_uri;
- GList vfs_uri_as_list;
-
- if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
- return;
- }
-
- if (trash_volume->handle) {
- /* Already searching for trash */
- gnome_vfs_uri_unref (volume_mount_uri);
- return;
- }
-
- /* Find the real trash directory for this one. */
- vfs_uri_as_list.data = volume_mount_uri;
- vfs_uri_as_list.next = NULL;
- vfs_uri_as_list.prev = NULL;
-
- /* Search for Trash directories but don't create new ones. */
- gnome_vfs_async_find_directory
- (&trash_volume->handle, &vfs_uri_as_list,
- GNOME_VFS_DIRECTORY_KIND_TRASH, FALSE, TRUE, 0777,
- GNOME_VFS_PRIORITY_DEFAULT,
- find_directory_callback, trash_volume);
-
- gnome_vfs_uri_unref (volume_mount_uri);
-}
-
-static void
-check_trash_created (NautilusTrashDirectory *trash,
- GnomeVFSVolume *volume)
-{
- GnomeVFSResult result;
- TrashVolume *trash_volume;
- GnomeVFSURI *volume_mount_uri;
- GnomeVFSURI *trash_uri;
- char *uri;
-
- if (!get_trash_volume (trash, volume, &trash_volume, &volume_mount_uri)) {
- return;
- }
-
- /* Do a synch trash lookup -- if the trash directory was just created, it's location will
- * be known and returned immediately without any blocking.
- */
- result = gnome_vfs_find_directory (volume_mount_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_uri, FALSE, FALSE, 077);
-
- gnome_vfs_uri_unref (volume_mount_uri);
- if (result != GNOME_VFS_OK) {
- return;
- }
-
- uri = gnome_vfs_uri_to_string (trash_uri,
- GNOME_VFS_URI_HIDE_NONE);
- trash_volume->real_directory = nautilus_directory_get (uri);
- g_free (uri);
- gnome_vfs_uri_unref (trash_uri);
- if (trash_volume->real_directory == NULL) {
- return;
- }
-
- /* Add the directory object. */
- nautilus_merged_directory_add_real_directory
- (NAUTILUS_MERGED_DIRECTORY (trash_volume->trash),
- trash_volume->real_directory);
-}
-
-static void
-remove_trash_volume (TrashVolume *trash_volume, gboolean finalizing)
-{
- g_hash_table_remove (trash_volume->trash->details->volumes,
- trash_volume->volume);
-
- if (trash_volume->handle != NULL) {
- gnome_vfs_async_cancel (trash_volume->handle);
- }
- if (trash_volume->real_directory != NULL) {
- if (! finalizing) {
- nautilus_merged_directory_remove_real_directory
- (NAUTILUS_MERGED_DIRECTORY (trash_volume->trash),
- trash_volume->real_directory);
- }
- nautilus_directory_unref (trash_volume->real_directory);
- }
- gnome_vfs_volume_unref (trash_volume->volume);
- g_free (trash_volume);
-}
-
-static void
-remove_volume (NautilusTrashDirectory *trash,
- GnomeVFSVolume *volume)
-{
- TrashVolume *trash_volume;
-
- /* Quick out if don't already know about this volume. */
- trash_volume = g_hash_table_lookup (trash->details->volumes, volume);
- if (trash_volume != NULL) {
- remove_trash_volume (trash_volume, FALSE);
- }
-}
-
-static void
-check_trash_directory_added_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- NautilusTrashDirectory *trash)
-{
- check_trash_created (trash, volume);
-}
-
-static void
-volume_unmount_started_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- NautilusTrashDirectory *trash)
-{
- remove_volume (trash, volume);
-}
-
-static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- NautilusTrashDirectory *trash)
-{
- add_volume (trash, volume);
-}
-
-static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
- NautilusTrashDirectory *trash)
-{
- remove_volume (trash, volume);
-}
-
-static void
-nautilus_trash_directory_instance_init (NautilusTrashDirectory *trash)
-{
- GnomeVFSVolumeMonitor *volume_monitor;
-
- trash->details = g_new0 (NautilusTrashDirectoryDetails, 1);
- trash->details->volumes = g_hash_table_new (NULL, NULL);
-
- volume_monitor = gnome_vfs_get_volume_monitor ();
-
- g_signal_connect_object (volume_monitor, "volume_mounted",
- G_CALLBACK (volume_mounted_callback), trash, 0);
- g_signal_connect_object (volume_monitor, "volume_pre_unmount",
- G_CALLBACK (volume_unmount_started_callback), trash, 0);
- g_signal_connect_object (volume_monitor, "volume_unmounted",
- G_CALLBACK (volume_unmounted_callback), trash, 0);
-}
-
-/* Finish initializing a new NautilusTrashDirectory. We have to do the
- * remaining initialization here rather than in nautilus_trash_directory_init
- * because of a cyclic dependency between the NautilusTrashDirectory and
- * NautilusTrashMonitor instances.
- */
-void
-nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash)
-{
- GnomeVFSVolumeMonitor *volume_monitor;
- GList *volumes, *l;
-
- volume_monitor = gnome_vfs_get_volume_monitor ();
-
- g_signal_connect_object (nautilus_trash_monitor_get (), "check_trash_directory_added",
- G_CALLBACK (check_trash_directory_added_callback), trash, 0);
-
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- for (l = volumes; l != NULL; l = l->next) {
- add_volume (trash, l->data);
- gnome_vfs_volume_unref (l->data);
- }
- g_list_free (volumes);
-}
-
-static void
-remove_trash_volume_finalizing_cover (gpointer key, gpointer value, gpointer callback_data)
-{
- TrashVolume *trash_volume;
-
- g_assert (key != NULL);
- g_assert (value != NULL);
- g_assert (callback_data == NULL);
-
- trash_volume = value;
-
- g_assert (NAUTILUS_IS_TRASH_DIRECTORY (trash_volume->trash));
- g_assert (trash_volume->volume == key);
-
- remove_trash_volume (trash_volume, TRUE);
-}
-
-static void
-trash_finalize (GObject *object)
-{
- NautilusTrashDirectory *trash;
-
- trash = NAUTILUS_TRASH_DIRECTORY (object);
-
- eel_g_hash_table_safe_for_each (trash->details->volumes,
- remove_trash_volume_finalizing_cover, NULL);
- g_hash_table_destroy (trash->details->volumes);
- g_free (trash->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static char *
-trash_get_name_for_self_as_new_file (NautilusDirectory *directory)
-{
- g_assert (NAUTILUS_IS_TRASH_DIRECTORY (directory));
- return g_strdup (_("Trash"));
-}
-
-static void
-nautilus_trash_directory_class_init (NautilusTrashDirectoryClass *class)
-{
- G_OBJECT_CLASS (class)->finalize = trash_finalize;
- NAUTILUS_DIRECTORY_CLASS (class)->get_name_for_self_as_new_file = trash_get_name_for_self_as_new_file;
-}
-
diff --git a/libnautilus-private/nautilus-trash-directory.h b/libnautilus-private/nautilus-trash-directory.h
deleted file mode 100644
index 9da49e41c..000000000
--- a/libnautilus-private/nautilus-trash-directory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-trash-directory.h: Subclass of NautilusDirectory to implement
- the virtual trash directory.
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Darin Adler <darin@bentspoon.com>
-*/
-
-#ifndef NAUTILUS_TRASH_DIRECTORY_H
-#define NAUTILUS_TRASH_DIRECTORY_H
-
-#include <libnautilus-private/nautilus-merged-directory.h>
-
-#define NAUTILUS_TYPE_TRASH_DIRECTORY \
- (nautilus_trash_directory_get_type ())
-#define NAUTILUS_TRASH_DIRECTORY(obj) \
- (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectory))
-#define NAUTILUS_TRASH_DIRECTORY_CLASS(klass) \
- (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY, NautilusTrashDirectoryClass))
-#define NAUTILUS_IS_TRASH_DIRECTORY(obj) \
- (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TRASH_DIRECTORY))
-#define NAUTILUS_IS_TRASH_DIRECTORY_CLASS(klass) \
- (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TRASH_DIRECTORY))
-
-typedef struct NautilusTrashDirectoryDetails NautilusTrashDirectoryDetails;
-
-typedef struct {
- NautilusMergedDirectory parent_slot;
- NautilusTrashDirectoryDetails *details;
-} NautilusTrashDirectory;
-
-typedef struct {
- NautilusMergedDirectoryClass parent_slot;
-} NautilusTrashDirectoryClass;
-
-GType nautilus_trash_directory_get_type (void);
-void nautilus_trash_directory_finish_initializing (NautilusTrashDirectory *trash);
-
-#endif /* NAUTILUS_TRASH_DIRECTORY_H */
diff --git a/libnautilus-private/nautilus-trash-file.c b/libnautilus-private/nautilus-trash-file.c
deleted file mode 100644
index 0e145e239..000000000
--- a/libnautilus-private/nautilus-trash-file.c
+++ /dev/null
@@ -1,784 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-trash-file.c: Subclass of NautilusFile to help implement the
- virtual trash directory.
-
- Copyright (C) 1999, 2000, 2001 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Darin Adler <darin@bentspoon.com>
-*/
-
-#include <config.h>
-#include "nautilus-trash-file.h"
-
-#include "nautilus-directory-notify.h"
-#include "nautilus-directory-private.h"
-#include "nautilus-file-attributes.h"
-#include "nautilus-file-private.h"
-#include "nautilus-file-utilities.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
-#include "nautilus-trash-directory.h"
-#include <gtk/gtksignal.h>
-#include <glib/gi18n.h>
-#include <string.h>
-
-struct NautilusTrashFileDetails {
- NautilusTrashDirectory *trash_directory;
-
- GList *files;
-
- GHashTable *callbacks;
- GHashTable *monitors;
-};
-
-typedef struct {
- NautilusTrashFile *trash;
- NautilusFileCallback callback;
- gpointer callback_data;
-
- NautilusFileAttributes delegated_attributes;
- NautilusFileAttributes non_delegated_attributes;
-
- GList *non_ready_files;
-
- gboolean initializing;
-} TrashCallback;
-
-typedef struct {
- NautilusTrashFile *trash;
-
- NautilusFileAttributes delegated_attributes;
- NautilusFileAttributes non_delegated_attributes;
-} TrashMonitor;
-
-static void nautilus_trash_file_init (gpointer object,
- gpointer klass);
-static void nautilus_trash_file_class_init (gpointer klass);
-
-EEL_CLASS_BOILERPLATE (NautilusTrashFile,
- nautilus_trash_file,
- NAUTILUS_TYPE_FILE)
-
-static NautilusFileAttributes
-get_delegated_attributes_mask (void)
-{
- return NAUTILUS_FILE_ATTRIBUTE_DEEP_COUNTS |
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
- NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_MIME_TYPES;
-}
-
-static void
-partition_attributes (NautilusFileAttributes attributes,
- NautilusFileAttributes *delegated_attributes,
- NautilusFileAttributes *non_delegated_attributes)
-{
- NautilusFileAttributes mask;
-
- mask = get_delegated_attributes_mask ();
-
- *delegated_attributes = attributes & mask;
- *non_delegated_attributes = attributes & ~mask;
-}
-
-static void
-real_monitor_add (NautilusFile *file,
- gconstpointer client,
- NautilusFileAttributes attributes)
-{
- nautilus_directory_monitor_add_internal
- (file->details->directory, file,
- client, TRUE, TRUE, attributes, NULL, NULL);
-}
-
-static void
-real_monitor_remove (NautilusFile *file,
- gconstpointer client)
-{
- nautilus_directory_monitor_remove_internal
- (file->details->directory, file, client);
-}
-
-static void
-real_call_when_ready (NautilusFile *file,
- NautilusFileAttributes attributes,
- NautilusFileCallback callback,
- gpointer callback_data)
-
-{
- nautilus_directory_call_when_ready_internal
- (file->details->directory, file,
- attributes, FALSE, NULL, callback, callback_data);
-}
-
-static void
-real_cancel_call_when_ready (NautilusFile *file,
- NautilusFileCallback callback,
- gpointer callback_data)
-{
- nautilus_directory_cancel_callback_internal
- (file->details->directory, file,
- NULL, callback, callback_data);
-}
-
-static gboolean
-real_check_if_ready (NautilusFile *file,
- NautilusFileAttributes attributes)
-{
- return nautilus_directory_check_if_ready_internal
- (file->details->directory, file,
- attributes);
-}
-
-static guint
-trash_callback_hash (gconstpointer trash_callback_as_pointer)
-{
- const TrashCallback *trash_callback;
-
- trash_callback = trash_callback_as_pointer;
- return GPOINTER_TO_UINT (trash_callback->callback)
- ^ GPOINTER_TO_UINT (trash_callback->callback_data);
-}
-
-static gboolean
-trash_callback_equal (gconstpointer trash_callback_as_pointer,
- gconstpointer trash_callback_as_pointer_2)
-{
- const TrashCallback *trash_callback, *trash_callback_2;
-
- trash_callback = trash_callback_as_pointer;
- trash_callback_2 = trash_callback_as_pointer_2;
-
- return trash_callback->callback == trash_callback_2->callback
- && trash_callback->callback_data == trash_callback_2->callback_data;
-}
-
-static void
-trash_callback_destroy (TrashCallback *trash_callback)
-{
- g_assert (trash_callback != NULL);
- g_assert (NAUTILUS_IS_TRASH_FILE (trash_callback->trash));
-
- nautilus_file_unref (NAUTILUS_FILE (trash_callback->trash));
- g_list_free (trash_callback->non_ready_files);
- g_free (trash_callback);
-}
-
-static void
-trash_callback_check_done (TrashCallback *trash_callback)
-{
- /* Check if we are ready. */
- if (trash_callback->initializing || trash_callback->non_ready_files != NULL) {
- return;
- }
-
- /* Remove from the hash table before sending it. */
- g_hash_table_remove (trash_callback->trash->details->callbacks,
- trash_callback);
-
- /* We are ready, so do the real callback. */
- (* trash_callback->callback) (NAUTILUS_FILE (trash_callback->trash),
- trash_callback->callback_data);
-
- /* And we are done. */
- trash_callback_destroy (trash_callback);
-}
-
-static void
-trash_callback_remove_file (TrashCallback *trash_callback,
- NautilusFile *file)
-{
- trash_callback->non_ready_files = g_list_remove
- (trash_callback->non_ready_files, file);
- trash_callback_check_done (trash_callback);
-}
-
-static void
-ready_callback (NautilusFile *file,
- gpointer callback_data)
-{
- TrashCallback *trash_callback;
-
- g_assert (NAUTILUS_IS_FILE (file));
- g_assert (callback_data != NULL);
-
- trash_callback = callback_data;
- g_assert (g_list_find (trash_callback->non_ready_files, file) != NULL);
-
- trash_callback_remove_file (trash_callback, file);
-}
-
-static void
-real_file_changed_callback (NautilusFile *real_file,
- gpointer callback_data)
-{
- NautilusTrashFile *trash_file;
-
- trash_file = NAUTILUS_TRASH_FILE (callback_data);
- nautilus_file_changed (NAUTILUS_FILE (trash_file));
-}
-
-static void
-monitor_add_file (gpointer key,
- gpointer value,
- gpointer callback_data)
-{
- TrashMonitor *monitor;
-
- monitor = value;
- nautilus_file_monitor_add
- (NAUTILUS_FILE (callback_data),
- monitor,
- monitor->delegated_attributes);
-}
-
-static void
-add_real_file (NautilusTrashFile *trash,
- NautilusFile *real_file)
-{
- g_return_if_fail (NAUTILUS_IS_TRASH_FILE (trash));
- g_return_if_fail (NAUTILUS_IS_FILE (real_file));
- g_return_if_fail (!NAUTILUS_IS_TRASH_FILE (real_file));
- g_return_if_fail (g_list_find (trash->details->files, real_file) == NULL);
-
- nautilus_file_ref (real_file);
- trash->details->files = g_list_prepend
- (trash->details->files, real_file);
-
- g_signal_connect_object (real_file, "changed",
- G_CALLBACK (real_file_changed_callback), trash, 0);
-
- /* Add the file to any extant monitors. */
- g_hash_table_foreach (trash->details->monitors,
- monitor_add_file,
- real_file);
-}
-
-static void
-trash_callback_remove_file_cover (gpointer key,
- gpointer value,
- gpointer callback_data)
-{
- trash_callback_remove_file
- (value, NAUTILUS_FILE (callback_data));
-}
-
-static void
-monitor_remove_file (gpointer key,
- gpointer value,
- gpointer callback_data)
-{
- nautilus_file_monitor_remove
- (NAUTILUS_FILE (callback_data), value);
-}
-
-static void
-remove_real_file (NautilusTrashFile *trash,
- NautilusFile *real_file)
-{
- g_return_if_fail (NAUTILUS_IS_TRASH_FILE (trash));
- g_return_if_fail (NAUTILUS_IS_FILE (real_file));
- g_return_if_fail (g_list_find (trash->details->files, real_file) != NULL);
-
- eel_g_hash_table_safe_for_each
- (trash->details->callbacks,
- trash_callback_remove_file_cover,
- real_file);
- g_hash_table_foreach
- (trash->details->monitors,
- monitor_remove_file,
- real_file);
-
- g_signal_handlers_disconnect_by_func
- (real_file, G_CALLBACK (real_file_changed_callback), trash);
-
- trash->details->files = g_list_remove
- (trash->details->files, real_file);
- nautilus_file_unref (real_file);
-}
-
-static void
-add_real_file_given_directory (NautilusTrashFile *trash_file,
- NautilusDirectory *real_directory)
-{
- NautilusFile *real_file;
-
- real_file = nautilus_directory_get_corresponding_file (real_directory);
- add_real_file (trash_file, real_file);
- nautilus_file_unref (real_file);
-}
-
-static void
-add_directory_callback (NautilusTrashDirectory *trash_directory,
- NautilusDirectory *real_directory,
- NautilusTrashFile *trash_file)
-{
- g_assert (NAUTILUS_IS_TRASH_DIRECTORY (trash_directory));
- g_assert (NAUTILUS_IS_DIRECTORY (real_directory));
- g_assert (!NAUTILUS_IS_MERGED_DIRECTORY (real_directory));
- g_assert (NAUTILUS_IS_TRASH_FILE (trash_file));
- g_assert (trash_file->details->trash_directory == trash_directory);
-
- add_real_file_given_directory (trash_file, real_directory);
-
- nautilus_file_changed (NAUTILUS_FILE (trash_file));
-}
-
-static void
-remove_directory_callback (NautilusTrashDirectory *trash_directory,
- NautilusDirectory *real_directory,
- NautilusTrashFile *trash_file)
-{
- NautilusFile *real_file;
-
- g_assert (NAUTILUS_IS_TRASH_DIRECTORY (trash_directory));
- g_assert (NAUTILUS_IS_DIRECTORY (real_directory));
- g_assert (!NAUTILUS_IS_MERGED_DIRECTORY (real_directory));
- g_assert (NAUTILUS_IS_TRASH_FILE (trash_file));
- g_assert (trash_file->details->trash_directory == trash_directory);
-
- real_file = nautilus_directory_get_corresponding_file (real_directory);
- remove_real_file (trash_file, real_file);
- nautilus_file_unref (real_file);
-
- nautilus_file_changed (NAUTILUS_FILE (trash_file));
-}
-
-static void
-trash_file_call_when_ready (NautilusFile *file,
- NautilusFileAttributes attributes,
- NautilusFileCallback callback,
- gpointer callback_data)
-
-{
- NautilusTrashFile *trash;
- TrashCallback search_key, *trash_callback;
- GList *node;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- /* Check to be sure we aren't overwriting. */
- search_key.callback = callback;
- search_key.callback_data = callback_data;
- if (g_hash_table_lookup (trash->details->callbacks, &search_key) != NULL) {
- g_warning ("tried to add a new callback while an old one was pending");
- return;
- }
-
- /* Create a trash_callback record. */
- trash_callback = g_new0 (TrashCallback, 1);
- nautilus_file_ref (file);
- trash_callback->trash = trash;
- trash_callback->callback = callback;
- trash_callback->callback_data = callback_data;
- trash_callback->initializing = TRUE;
-
- partition_attributes (attributes,
- &trash_callback->delegated_attributes,
- &trash_callback->non_delegated_attributes);
-
- trash_callback->non_ready_files = g_list_prepend
- (trash_callback->non_ready_files, file);
- for (node = trash->details->files; node != NULL; node = node->next) {
- trash_callback->non_ready_files = g_list_prepend
- (trash_callback->non_ready_files, node->data);
- }
-
- /* Put it in the hash table. */
- g_hash_table_insert (trash->details->callbacks,
- trash_callback, trash_callback);
-
- /* Now connect to each file's call_when_ready. */
- real_call_when_ready
- (file, trash_callback->non_delegated_attributes,
- ready_callback, trash_callback);
- for (node = trash->details->files; node != NULL; node = node->next) {
- nautilus_file_call_when_ready
- (node->data, trash_callback->delegated_attributes,
- ready_callback, trash_callback);
- }
-
- trash_callback->initializing = FALSE;
-
- /* Check if any files became read while we were connecting up
- * the call_when_ready callbacks (also handles the pathological
- * case where there are no files at all).
- */
- trash_callback_check_done (trash_callback);
-}
-
-static void
-trash_file_cancel_call_when_ready (NautilusFile *file,
- NautilusFileCallback callback,
- gpointer callback_data)
-{
- NautilusTrashFile *trash;
- TrashCallback search_key, *trash_callback;
- GList *node;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- /* Find the entry in the table. */
- search_key.callback = callback;
- search_key.callback_data = callback_data;
- trash_callback = g_hash_table_lookup (trash->details->callbacks, &search_key);
- if (trash_callback == NULL) {
- return;
- }
-
- /* Remove from the hash table before working with it. */
- g_hash_table_remove (trash_callback->trash->details->callbacks, trash_callback);
-
- /* Tell all the directories to cancel the call. */
- real_cancel_call_when_ready (file, ready_callback, trash_callback);
- for (node = trash_callback->non_ready_files; node != NULL; node = node->next) {
- nautilus_file_cancel_call_when_ready
- (node->data, ready_callback, trash_callback);
- }
- trash_callback_destroy (trash_callback);
-}
-
-static gboolean
-trash_file_check_if_ready (NautilusFile *file,
- NautilusFileAttributes attributes)
-{
- NautilusFileAttributes delegated_attributes, non_delegated_attributes;
- NautilusTrashFile *trash;
- GList *node;
- gboolean ready;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- partition_attributes (attributes,
- &delegated_attributes,
- &non_delegated_attributes);
-
- ready = real_check_if_ready (file, non_delegated_attributes);
-
- if (ready) {
- for (node = trash->details->files; node != NULL; node = node->next) {
- if (!nautilus_file_check_if_ready (node->data,
- delegated_attributes)) {
- ready = FALSE;
- break;
- }
- }
- }
-
- return ready;
-}
-
-static void
-trash_file_monitor_add (NautilusFile *file,
- gconstpointer client,
- NautilusFileAttributes attributes)
-{
- NautilusTrashFile *trash;
- TrashMonitor *monitor;
- GList *node;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- /* Map the client to a unique value so this doesn't interfere
- * with direct monitoring of the file by the same client.
- */
- monitor = g_hash_table_lookup (trash->details->monitors, client);
- if (monitor != NULL) {
- g_assert (monitor->trash == trash);
- } else {
- monitor = g_new0 (TrashMonitor, 1);
- monitor->trash = trash;
- g_hash_table_insert (trash->details->monitors,
- (gpointer) client, monitor);
- }
-
- partition_attributes (attributes,
- &monitor->delegated_attributes,
- &monitor->non_delegated_attributes);
-
- real_monitor_add (file, monitor,
- monitor->non_delegated_attributes);
- for (node = trash->details->files; node != NULL; node = node->next) {
- nautilus_file_monitor_add (node->data, monitor,
- monitor->delegated_attributes);
- }
-}
-
-static void
-trash_file_monitor_remove (NautilusFile *file,
- gconstpointer client)
-{
- NautilusTrashFile *trash;
- TrashMonitor *monitor;
- GList *node;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- /* Map the client to the value used by the earlier add call. */
- monitor = g_hash_table_lookup (trash->details->monitors, client);
- if (monitor == NULL) {
- return;
- }
- g_hash_table_remove (trash->details->monitors, client);
-
- /* Call through to the real file remove calls. */
- real_monitor_remove (file, monitor);
- for (node = trash->details->files; node != NULL; node = node->next) {
- nautilus_file_monitor_remove (node->data, monitor);
- }
-
- g_free (monitor);
-}
-
-static GnomeVFSFileType
-trash_file_get_file_type (NautilusFile *file)
-{
- return GNOME_VFS_FILE_TYPE_DIRECTORY;
-}
-
-static gboolean
-trash_file_get_item_count (NautilusFile *file,
- guint *count,
- gboolean *count_unreadable)
-{
- NautilusTrashFile *trash;
- GList *node;
- guint one_count;
- int one_unreadable;
- gboolean got_count;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- got_count = TRUE;
- if (count != NULL) {
- *count = 0;
- }
- if (count_unreadable != NULL) {
- *count_unreadable = FALSE;
- }
-
- for (node = trash->details->files; node != NULL; node = node->next) {
- if (!nautilus_file_get_directory_item_count (node->data,
- &one_count,
- &one_unreadable)) {
- got_count = FALSE;
- }
-
- if (count != NULL) {
- *count += one_count;
- }
- if (count_unreadable != NULL && one_unreadable) {
- *count_unreadable = TRUE;
- }
- }
-
- return got_count;
-}
-
-static NautilusRequestStatus
-trash_file_get_deep_counts (NautilusFile *file,
- guint *directory_count,
- guint *file_count,
- guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size)
-{
- NautilusTrashFile *trash;
- GList *node;
- NautilusRequestStatus status, one_status;
- guint one_directory_count, one_file_count, one_unreadable_directory_count;
- GnomeVFSFileSize one_total_size;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- status = NAUTILUS_REQUEST_DONE;
- if (directory_count != NULL) {
- *directory_count = 0;
- }
- if (file_count != NULL) {
- *file_count = 0;
- }
- if (unreadable_directory_count != NULL) {
- *unreadable_directory_count = 0;
- }
- if (total_size != NULL) {
- *total_size = 0;
- }
-
- for (node = trash->details->files; node != NULL; node = node->next) {
- one_status = nautilus_file_get_deep_counts
- (node->data,
- &one_directory_count,
- &one_file_count,
- &one_unreadable_directory_count,
- &one_total_size,
- TRUE);
-
- if (one_status < status) {
- status = one_status;
- }
- if (directory_count != NULL) {
- *directory_count += one_directory_count;
- }
- if (file_count != NULL) {
- *file_count += one_file_count;
- }
- if (unreadable_directory_count != NULL) {
- *unreadable_directory_count += one_unreadable_directory_count;
- }
- if (total_size != NULL) {
- *total_size += one_total_size;
- }
- }
-
- return status;
-}
-
-static gboolean
-trash_file_get_date (NautilusFile *file,
- NautilusDateType date_type,
- time_t *date)
-{
- NautilusTrashFile *trash;
- GList *node;
- gboolean got_at_least_one;
- gboolean got_all;
- time_t one_date;
-
- trash = NAUTILUS_TRASH_FILE (file);
-
- got_at_least_one = FALSE;
- got_all = TRUE;
-
- for (node = trash->details->files; node != NULL; node = node->next) {
- if (nautilus_file_get_date (node->data,
- date_type,
- &one_date)) {
- if (!got_at_least_one) {
- got_at_least_one = TRUE;
- if (date != NULL) {
- *date = one_date;
- }
- } else {
- if (date != NULL && one_date > *date) {
- *date = one_date;
- }
- }
- } else {
- got_all = FALSE;
- }
- }
-
- return got_at_least_one && got_all;
-}
-
-static char *
-trash_file_get_where_string (NautilusFile *file)
-{
- return g_strdup (_("on the desktop"));
-}
-
-
-static void
-remove_all_real_files (NautilusTrashFile *trash)
-{
- while (trash->details->files != NULL) {
- remove_real_file (trash, trash->details->files->data);
- }
-}
-
-static void
-nautilus_trash_file_init (gpointer object, gpointer klass)
-{
- NautilusTrashFile *trash_file;
- NautilusTrashDirectory *trash_directory;
- GList *real_directories, *node;
-
- trash_file = NAUTILUS_TRASH_FILE (object);
-
- trash_directory = NAUTILUS_TRASH_DIRECTORY (nautilus_directory_get (EEL_TRASH_URI));
-
- trash_file->details = g_new0 (NautilusTrashFileDetails, 1);
- trash_file->details->trash_directory = trash_directory;
-
- trash_file->details->callbacks = g_hash_table_new
- (trash_callback_hash, trash_callback_equal);
- trash_file->details->monitors = g_hash_table_new (NULL, NULL);
-
- g_signal_connect_object (trash_directory, "add_real_directory",
- G_CALLBACK (add_directory_callback), trash_file, 0);
- g_signal_connect_object (trash_directory, "remove_real_directory",
- G_CALLBACK (remove_directory_callback), trash_file, 0);
-
- real_directories = nautilus_merged_directory_get_real_directories
- (NAUTILUS_MERGED_DIRECTORY (trash_directory));
- for (node = real_directories; node != NULL; node = node->next) {
- add_real_file_given_directory (trash_file, node->data);
- }
- g_list_free (real_directories);
-}
-
-static void
-trash_finalize (GObject *object)
-{
- NautilusTrashFile *trash_file;
- NautilusTrashDirectory *trash_directory;
-
- trash_file = NAUTILUS_TRASH_FILE (object);
- trash_directory = trash_file->details->trash_directory;
-
- remove_all_real_files (trash_file);
-
- if (g_hash_table_size (trash_file->details->callbacks) != 0) {
- g_warning ("call_when_ready still pending when trash virtual file is destroyed");
- }
- if (g_hash_table_size (trash_file->details->monitors) != 0) {
- g_warning ("file monitor still active when trash virtual file is destroyed");
- }
-
- g_hash_table_destroy (trash_file->details->callbacks);
- g_hash_table_destroy (trash_file->details->monitors);
-
- g_free (trash_file->details);
-
- nautilus_directory_unref (NAUTILUS_DIRECTORY (trash_directory));
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
-}
-
-static void
-nautilus_trash_file_class_init (gpointer klass)
-{
- GObjectClass *object_class;
- NautilusFileClass *file_class;
-
- object_class = G_OBJECT_CLASS (klass);
- file_class = NAUTILUS_FILE_CLASS (klass);
-
- object_class->finalize = trash_finalize;
-
- file_class->monitor_add = trash_file_monitor_add;
- file_class->monitor_remove = trash_file_monitor_remove;
- file_class->call_when_ready = trash_file_call_when_ready;
- file_class->cancel_call_when_ready = trash_file_cancel_call_when_ready;
- file_class->check_if_ready = trash_file_check_if_ready;
- file_class->get_file_type = trash_file_get_file_type;
- file_class->get_item_count = trash_file_get_item_count;
- file_class->get_deep_counts = trash_file_get_deep_counts;
- file_class->get_date = trash_file_get_date;
- file_class->get_where_string = trash_file_get_where_string;
-}
diff --git a/libnautilus-private/nautilus-trash-file.h b/libnautilus-private/nautilus-trash-file.h
deleted file mode 100644
index b339d7b97..000000000
--- a/libnautilus-private/nautilus-trash-file.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
-
- nautilus-trash-file.h: Subclass of NautilusFile to implement the
- the case of a TRASH file.
-
- Copyright (C) 1999, 2000 Eazel, Inc.
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Darin Adler <darin@bentspoon.com>
-*/
-
-#ifndef NAUTILUS_TRASH_FILE_H
-#define NAUTILUS_TRASH_FILE_H
-
-#include <libnautilus-private/nautilus-file.h>
-
-#define NAUTILUS_TYPE_TRASH_FILE \
- (nautilus_trash_file_get_type ())
-#define NAUTILUS_TRASH_FILE(obj) \
- (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TRASH_FILE, NautilusTrashFile))
-#define NAUTILUS_TRASH_FILE_CLASS(klass) \
- (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TRASH_FILE, NautilusTrashFileClass))
-#define NAUTILUS_IS_TRASH_FILE(obj) \
- (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TRASH_FILE))
-#define NAUTILUS_IS_TRASH_FILE_CLASS(klass) \
- (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TRASH_FILE))
-
-typedef struct NautilusTrashFileDetails NautilusTrashFileDetails;
-
-typedef struct {
- NautilusFile parent_slot;
- NautilusTrashFileDetails *details;
-} NautilusTrashFile;
-
-typedef struct {
- NautilusFileClass parent_slot;
-} NautilusTrashFileClass;
-
-GType nautilus_trash_file_get_type (void);
-
-#endif /* NAUTILUS_TRASH_FILE_H */
diff --git a/libnautilus-private/nautilus-trash-monitor.c b/libnautilus-private/nautilus-trash-monitor.c
index 0ed96af5d..54f2551f5 100644
--- a/libnautilus-private/nautilus-trash-monitor.c
+++ b/libnautilus-private/nautilus-trash-monitor.c
@@ -29,46 +29,52 @@
#include "nautilus-directory-notify.h"
#include "nautilus-directory.h"
#include "nautilus-file-attributes.h"
-#include "nautilus-trash-directory.h"
#include <eel/eel-debug.h>
-#include <eel/eel-gtk-macros.h>
-#include <eel/eel-vfs-extensions.h>
-#include <gtk/gtksignal.h>
-#include <libgnomevfs/gnome-vfs-find-directory.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gthemedicon.h>
+#include <gio/gfilemonitor.h>
+#include <string.h>
struct NautilusTrashMonitorDetails {
- NautilusDirectory *trash_directory;
gboolean empty;
+ GIcon *icon;
+ GFileMonitor *file_monitor;
};
enum {
TRASH_STATE_CHANGED,
- CHECK_TRASH_DIRECTORY_ADDED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
-static NautilusTrashMonitor *nautilus_trash_monitor;
+static NautilusTrashMonitor *nautilus_trash_monitor = NULL;
-static void nautilus_trash_monitor_class_init (NautilusTrashMonitorClass *klass);
-static void nautilus_trash_monitor_init (gpointer object,
- gpointer klass);
-static void destroy (GtkObject *object);
+G_DEFINE_TYPE(NautilusTrashMonitor, nautilus_trash_monitor, G_TYPE_OBJECT)
-EEL_CLASS_BOILERPLATE (NautilusTrashMonitor, nautilus_trash_monitor, GTK_TYPE_OBJECT)
+static void
+nautilus_trash_monitor_finalize (GObject *object)
+{
+ NautilusTrashMonitor *trash_monitor;
+
+ trash_monitor = NAUTILUS_TRASH_MONITOR (object);
+
+ if (trash_monitor->details->icon) {
+ g_object_unref (trash_monitor->details->icon);
+ }
+ if (trash_monitor->details->file_monitor) {
+ g_object_unref (trash_monitor->details->file_monitor);
+ }
+
+ G_OBJECT_CLASS (nautilus_trash_monitor_parent_class)->finalize (object);
+}
static void
nautilus_trash_monitor_class_init (NautilusTrashMonitorClass *klass)
{
- GtkObjectClass *object_class;
+ GObjectClass *object_class;
- object_class = GTK_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (klass);
- object_class->destroy = destroy;
+ object_class->finalize = nautilus_trash_monitor_finalize;
signals[TRASH_STATE_CHANGED] = g_signal_new
("trash_state_changed",
@@ -80,89 +86,105 @@ nautilus_trash_monitor_class_init (NautilusTrashMonitorClass *klass)
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
- signals[CHECK_TRASH_DIRECTORY_ADDED] = g_signal_new
- ("check_trash_directory_added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NautilusTrashMonitorClass, check_trash_directory_added),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
+ g_type_class_add_private (object_class, sizeof(NautilusTrashMonitorDetails));
}
static void
-nautilus_trash_files_changed_callback (NautilusDirectory *directory, GList *files,
- gpointer callback_data)
+update_info_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
NautilusTrashMonitor *trash_monitor;
- gboolean old_empty_state;
- NautilusFile *file;
+ GFileInfo *info;
+ GIcon *icon;
+ const char * const *names;
+ gboolean empty;
+ int i;
+
+ trash_monitor = NAUTILUS_TRASH_MONITOR (user_data);
- trash_monitor = callback_data;
- g_assert (NAUTILUS_IS_TRASH_MONITOR (trash_monitor));
- g_assert (trash_monitor->details->trash_directory == directory);
-
- /* Something about the Trash NautilusDirectory changed, find out if
- * it affected the empty state.
- */
- old_empty_state = trash_monitor->details->empty;
- trash_monitor->details->empty = !nautilus_directory_is_not_empty (directory);
-
- if (old_empty_state != trash_monitor->details->empty) {
- file = nautilus_file_get (EEL_TRASH_URI);
- nautilus_file_changed (file);
- nautilus_file_unref (file);
-
- /* trash got empty or full, notify everyone who cares */
- g_signal_emit (trash_monitor,
- signals[TRASH_STATE_CHANGED], 0,
- trash_monitor->details->empty);
+ info = g_file_query_info_finish (G_FILE (source_object),
+ res, NULL);
+
+ if (info != NULL) {
+ icon = g_file_info_get_icon (info);
+
+ if (icon) {
+ g_object_unref (trash_monitor->details->icon);
+ trash_monitor->details->icon = g_object_ref (icon);
+ empty = TRUE;
+ if (G_IS_THEMED_ICON (icon)) {
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+ for (i = 0; names[i] != NULL; i++) {
+ if (strcmp (names[i], "user-trash-full") == 0) {
+ empty = FALSE;
+ break;
+ }
+ }
+ }
+ trash_monitor->details->empty = empty;
+
+ /* trash got empty or full, notify everyone who cares */
+ g_signal_emit (trash_monitor,
+ signals[TRASH_STATE_CHANGED], 0,
+ trash_monitor->details->empty);
+ }
}
+
+ g_object_unref (trash_monitor);
}
static void
-nautilus_trash_monitor_init (gpointer object, gpointer klass)
+schedule_update_info (NautilusTrashMonitor *trash_monitor)
{
- NautilusDirectory *trash_directory;
- NautilusTrashMonitor *trash_monitor;
- NautilusFileAttributes attributes;
-
- trash_monitor = NAUTILUS_TRASH_MONITOR (object);
-
- /* set up a NautilusDirectory for the Trash directory to monitor */
+ GFile *location;
- trash_directory = nautilus_directory_get (EEL_TRASH_URI);
+ location = g_file_new_for_uri ("trash:///");
- trash_monitor->details = g_new0 (NautilusTrashMonitorDetails, 1);
- trash_monitor->details->trash_directory = trash_directory;
- trash_monitor->details->empty = TRUE;
+ g_file_query_info_async (location,
+ G_FILE_ATTRIBUTE_STD_ICON,
+ 0, 0, NULL,
+ update_info_cb, g_object_ref (trash_monitor));
+
+ g_object_unref (location);
+}
- attributes = NAUTILUS_FILE_ATTRIBUTE_METADATA;
+static void
+file_changed (GDirectoryMonitor* monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ NautilusTrashMonitor *trash_monitor;
- /* Make sure we get notified about changes */
- nautilus_directory_file_monitor_add
- (trash_directory, trash_monitor, TRUE, TRUE, attributes,
- nautilus_trash_files_changed_callback, trash_monitor);
+ trash_monitor = NAUTILUS_TRASH_MONITOR (user_data);
- g_signal_connect_object (trash_directory, "files_added",
- G_CALLBACK (nautilus_trash_files_changed_callback), trash_monitor, 0);
- g_signal_connect_object (trash_directory, "files_changed",
- G_CALLBACK (nautilus_trash_files_changed_callback), trash_monitor, 0);
+ schedule_update_info (trash_monitor);
}
static void
-destroy (GtkObject *object)
+nautilus_trash_monitor_init (NautilusTrashMonitor *trash_monitor)
{
- NautilusTrashMonitor *trash_monitor;
+ GFile *location;
- trash_monitor = NAUTILUS_TRASH_MONITOR (object);
+ trash_monitor->details = G_TYPE_INSTANCE_GET_PRIVATE (trash_monitor,
+ NAUTILUS_TYPE_TRASH_MONITOR,
+ NautilusTrashMonitorDetails);
+
+ trash_monitor->details->empty = TRUE;
+ trash_monitor->details->icon = g_themed_icon_new ("user-trash");
+
+ location = g_file_new_for_uri ("trash:///");
+
+ trash_monitor->details->file_monitor = g_file_monitor_file (location, 0, NULL);
- nautilus_directory_file_monitor_remove
- (trash_monitor->details->trash_directory,
- trash_monitor);
- nautilus_directory_unref (trash_monitor->details->trash_directory);
- g_free (trash_monitor->details);
+ g_signal_connect (trash_monitor->details->file_monitor, "changed",
+ (GCallback)file_changed, trash_monitor);
+
+ g_object_unref (location);
+
+ schedule_update_info (trash_monitor);
}
static void
@@ -174,25 +196,12 @@ unref_trash_monitor (void)
NautilusTrashMonitor *
nautilus_trash_monitor_get (void)
{
- NautilusDirectory *trash_directory;
-
if (nautilus_trash_monitor == NULL) {
/* not running yet, start it up */
- /* the trash directory object will get created by this */
- trash_directory = nautilus_directory_get (EEL_TRASH_URI);
-
nautilus_trash_monitor = NAUTILUS_TRASH_MONITOR
(g_object_new (NAUTILUS_TYPE_TRASH_MONITOR, NULL));
- g_object_ref (nautilus_trash_monitor);
- gtk_object_sink (GTK_OBJECT (nautilus_trash_monitor));
eel_debug_call_at_shutdown (unref_trash_monitor);
-
- /* make sure we get signalled when trash directories get added */
- nautilus_trash_directory_finish_initializing
- (NAUTILUS_TRASH_DIRECTORY (trash_directory));
-
- nautilus_directory_unref (trash_directory);
}
return nautilus_trash_monitor;
@@ -201,76 +210,26 @@ nautilus_trash_monitor_get (void)
gboolean
nautilus_trash_monitor_is_empty (void)
{
- return nautilus_trash_monitor_get ()->details->empty;
+ NautilusTrashMonitor *monitor;
+
+ monitor = nautilus_trash_monitor_get ();
+ return monitor->details->empty;
}
-GList *
-nautilus_trash_monitor_get_trash_directories (void)
+GIcon *
+nautilus_trash_monitor_get_icon (void)
{
- GList *result;
- char *uri_str;
- GnomeVFSURI *volume_mount_point_uri;
- GnomeVFSURI *trash_uri;
- GnomeVFSVolume *volume;
- GList *l, *volumes;
-
- result = NULL;
-
- /* Collect the trash directories on all the mounted volumes. */
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
- for (l = volumes; l != NULL; l = l->next) {
- volume = l->data;
- if (gnome_vfs_volume_handles_trash (volume)) {
-
- /* Get the uri of the volume mount point as the place
- * "near" which to look for trash on the given volume.
- */
- uri_str = gnome_vfs_volume_get_activation_uri (volume);
- volume_mount_point_uri = gnome_vfs_uri_new (uri_str);
- g_free (uri_str);
-
- g_assert (volume_mount_point_uri != NULL);
-
- /* Look for trash. It is OK to use a sync call here because
- * the options we use (don't create, don't look for it if we
- * already don't know where it is) do not cause any IO.
- */
- if (gnome_vfs_find_directory (volume_mount_point_uri,
- GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
- FALSE, FALSE, 0777) == GNOME_VFS_OK) {
-
- /* found trash, put it on the list */
- result = g_list_prepend (result, trash_uri);
- }
-
- gnome_vfs_uri_unref (volume_mount_point_uri);
- }
-
- gnome_vfs_volume_unref (volume);
+ NautilusTrashMonitor *monitor;
+
+ monitor = nautilus_trash_monitor_get ();
+ if (monitor->details->icon) {
+ return g_object_ref (monitor->details->icon);
}
- g_list_free (volumes);
-
- return result;
+ return NULL;
}
-void
+void
nautilus_trash_monitor_add_new_trash_directories (void)
{
- NautilusTrashMonitor *trash_monitor;
- GList *l, *volumes;
- GnomeVFSVolume *volume;
-
- trash_monitor = nautilus_trash_monitor_get ();
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
- for (l = volumes; l != NULL; l = l->next) {
- volume = l->data;
-
- g_signal_emit (trash_monitor,
- signals[CHECK_TRASH_DIRECTORY_ADDED], 0,
- volume);
-
- gnome_vfs_volume_unref (volume);
- }
- g_list_free (volumes);
+ /* We trashed something... */
}
-
diff --git a/libnautilus-private/nautilus-trash-monitor.h b/libnautilus-private/nautilus-trash-monitor.h
index d7e055976..838e2f328 100644
--- a/libnautilus-private/nautilus-trash-monitor.h
+++ b/libnautilus-private/nautilus-trash-monitor.h
@@ -27,7 +27,7 @@
#define NAUTILUS_TRASH_MONITOR_H
#include <gtk/gtkobject.h>
-#include <libgnomevfs/gnome-vfs-volume.h>
+#include <gio/gicon.h>
typedef struct NautilusTrashMonitor NautilusTrashMonitor;
typedef struct NautilusTrashMonitorClass NautilusTrashMonitorClass;
@@ -45,24 +45,23 @@ typedef struct NautilusTrashMonitorDetails NautilusTrashMonitorDetails;
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TRASH_MONITOR))
struct NautilusTrashMonitor {
- GtkObject object;
+ GObject object;
NautilusTrashMonitorDetails *details;
};
struct NautilusTrashMonitorClass {
- GtkObjectClass parent_class;
+ GObjectClass parent_class;
void (* trash_state_changed) (NautilusTrashMonitor *trash_monitor,
gboolean new_state);
- void (* check_trash_directory_added) (NautilusTrashMonitor *trash_monitor,
- GnomeVFSVolume *volume);
};
GtkType nautilus_trash_monitor_get_type (void);
NautilusTrashMonitor *nautilus_trash_monitor_get (void);
gboolean nautilus_trash_monitor_is_empty (void);
-GList * nautilus_trash_monitor_get_trash_directories (void);
-void nautilus_trash_monitor_add_new_trash_directories (void);
+GIcon *nautilus_trash_monitor_get_icon (void);
+
+void nautilus_trash_monitor_add_new_trash_directories (void);
#endif
diff --git a/libnautilus-private/nautilus-tree-view-drag-dest.c b/libnautilus-private/nautilus-tree-view-drag-dest.c
index ebbfecf12..0394dd3ff 100644
--- a/libnautilus-private/nautilus-tree-view-drag-dest.c
+++ b/libnautilus-private/nautilus-tree-view-drag-dest.c
@@ -34,7 +34,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "nautilus-file-dnd.h"
#include "nautilus-icon-dnd.h"
#include "nautilus-link.h"
@@ -290,7 +289,7 @@ file_for_path (NautilusTreeViewDragDest *dest, GtkTreePath *path)
file = NULL;
if (uri != NULL) {
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
}
g_free (uri);
@@ -706,7 +705,7 @@ receive_dropped_keyword (NautilusTreeViewDragDest *dest,
drop_target_uri = get_drop_target_uri_at_pos (dest, x, y);
g_assert (drop_target_uri != NULL);
- drop_target_file = nautilus_file_get (drop_target_uri);
+ drop_target_file = nautilus_file_get_by_uri (drop_target_uri);
if (drop_target_file != NULL) {
nautilus_drag_file_receive_dropped_keyword (drop_target_file,
diff --git a/libnautilus-private/nautilus-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
index a3a833d96..f5c0d5269 100644
--- a/libnautilus-private/nautilus-ui-utilities.c
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -24,7 +24,8 @@
#include <config.h>
#include "nautilus-ui-utilities.h"
-#include "nautilus-icon-factory.h"
+#include "nautilus-icon-info.h"
+#include <gio/gthemedicon.h>
#include <gtk/gtkenums.h>
#include <eel/eel-debug.h>
@@ -116,14 +117,15 @@ extension_action_callback (GtkAction *action,
GtkAction *
nautilus_action_from_menu_item (NautilusMenuItem *item)
{
- char *name, *label, *tip, *icon;
+ char *name, *label, *tip, *icon_name;
gboolean sensitive, priority;
GtkAction *action;
GdkPixbuf *pixbuf;
+ NautilusIconInfo *info;
g_object_get (G_OBJECT (item),
"name", &name, "label", &label,
- "tip", &tip, "icon", &icon,
+ "tip", &tip, "icon", &icon_name,
"sensitive", &sensitive,
"priority", &priority,
NULL);
@@ -131,21 +133,20 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
action = gtk_action_new (name,
label,
tip,
- icon);
+ icon_name);
- /* TODO: This should really use themed icons, but that
- doesn't work here yet */
- if (icon != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size
- (icon,
- NULL,
- GTK_ICON_SIZE_MENU,
- NULL);
+ if (icon_name != NULL) {
+ info = nautilus_icon_info_lookup_from_name (icon_name,
+ nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU));
+
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info,
+ nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU));
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "menu-icon",
pixbuf,
g_object_unref);
}
+ g_object_unref (info);
}
gtk_action_set_sensitive (action, sensitive);
@@ -159,7 +160,7 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
g_free (name);
g_free (label);
g_free (tip);
- g_free (icon);
+ g_free (icon_name);
return action;
}
@@ -167,14 +168,15 @@ nautilus_action_from_menu_item (NautilusMenuItem *item)
GtkAction *
nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item)
{
- char *name, *label, *tip, *icon;
+ char *name, *label, *tip, *icon_name;
gboolean sensitive, priority;
GtkAction *action;
GdkPixbuf *pixbuf;
+ NautilusIconInfo *info;
g_object_get (G_OBJECT (item),
"name", &name, "label", &label,
- "tip", &tip, "icon", &icon,
+ "tip", &tip, "icon", &icon_name,
"sensitive", &sensitive,
"priority", &priority,
NULL);
@@ -182,21 +184,18 @@ nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item)
action = gtk_action_new (name,
label,
tip,
- icon);
+ icon_name);
- /* TODO: This should really use themed icons, but that
- doesn't work here yet */
- if (icon != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name
- (icon,
- NULL,
- 24, TRUE,
- NULL);
+ if (icon_name != NULL) {
+ info = nautilus_icon_info_lookup_from_name (icon_name, 24);
+
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, 24);
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "toolbar-icon",
pixbuf,
g_object_unref);
}
+ g_object_unref (info);
}
gtk_action_set_sensitive (action, sensitive);
@@ -210,7 +209,7 @@ nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item)
g_free (name);
g_free (label);
g_free (tip);
- g_free (icon);
+ g_free (icon_name);
return action;
}
diff --git a/libnautilus-private/nautilus-vfs-file.c b/libnautilus-private/nautilus-vfs-file.c
index dfe3555b5..09f4e386d 100644
--- a/libnautilus-private/nautilus-vfs-file.c
+++ b/libnautilus-private/nautilus-vfs-file.c
@@ -29,6 +29,8 @@
#include "nautilus-directory-private.h"
#include "nautilus-file-private.h"
#include <eel/eel-gtk-macros.h>
+#include <eel/eel-mount-operation.h>
+#include <glib/gi18n.h>
static void nautilus_vfs_file_init (gpointer object,
gpointer klass);
@@ -87,13 +89,6 @@ vfs_file_check_if_ready (NautilusFile *file,
file_attributes);
}
-static GnomeVFSFileType
-vfs_file_get_file_type (NautilusFile *file)
-{
- return nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_TYPE)
- ? GNOME_VFS_FILE_TYPE_UNKNOWN : file->details->info->type;
-}
-
static gboolean
vfs_file_get_item_count (NautilusFile *file,
guint *count,
@@ -119,9 +114,9 @@ vfs_file_get_deep_counts (NautilusFile *file,
guint *directory_count,
guint *file_count,
guint *unreadable_directory_count,
- GnomeVFSFileSize *total_size)
+ goffset *total_size)
{
- GnomeVFSFileType type;
+ GFileType type;
if (directory_count != NULL) {
*directory_count = 0;
@@ -158,8 +153,8 @@ vfs_file_get_deep_counts (NautilusFile *file,
/* For directories, or before we know the type, we haven't started. */
type = nautilus_file_get_file_type (file);
- if (type == GNOME_VFS_FILE_TYPE_UNKNOWN
- || type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (type == G_FILE_TYPE_UNKNOWN
+ || type == G_FILE_TYPE_DIRECTORY) {
return NAUTILUS_REQUEST_NOT_STARTED;
}
@@ -175,35 +170,34 @@ vfs_file_get_date (NautilusFile *file,
switch (date_type) {
case NAUTILUS_DATE_TYPE_CHANGED:
/* Before we have info on a file, the date is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_CTIME)) {
+ if (file->details->ctime == 0) {
return FALSE;
}
if (date != NULL) {
- *date = file->details->info->ctime;
+ *date = file->details->ctime;
}
return TRUE;
case NAUTILUS_DATE_TYPE_ACCESSED:
/* Before we have info on a file, the date is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_ATIME)) {
+ if (file->details->atime == 0) {
return FALSE;
}
if (date != NULL) {
- *date = file->details->info->atime;
+ *date = file->details->atime;
}
return TRUE;
case NAUTILUS_DATE_TYPE_MODIFIED:
/* Before we have info on a file, the date is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MTIME)) {
+ if (file->details->mtime == 0) {
return FALSE;
}
if (date != NULL) {
- *date = file->details->info->mtime;
+ *date = file->details->mtime;
}
return TRUE;
case NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED:
/* Before we have info on a file, the date is unknown. */
- if (nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_MTIME) ||
- nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_CTIME)) {
+ if (file->details->mtime == 0 || file->details->ctime == 0) {
return FALSE;
}
/* mtime is when the contents changed; ctime is when the
@@ -211,11 +205,11 @@ vfs_file_get_date (NautilusFile *file,
* So we can only know when the permissions changed if mtime
* and ctime are different.
*/
- if (file->details->info->mtime == file->details->info->ctime) {
+ if (file->details->mtime == file->details->ctime) {
return FALSE;
}
if (date != NULL) {
- *date = file->details->info->ctime;
+ *date = file->details->ctime;
}
return TRUE;
}
@@ -229,6 +223,71 @@ vfs_file_get_where_string (NautilusFile *file)
}
static void
+vfs_file_mount_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GFile *mounted_on;
+ GError *error;
+
+ op = callback_data;
+
+ error = NULL;
+ mounted_on = g_file_mount_mountable_finish (G_FILE (source_object),
+ res, &error);
+
+ nautilus_file_operation_complete (op, mounted_on, error);
+ if (mounted_on) {
+ g_object_unref (mounted_on);
+ }
+ if (error) {
+ g_error_free (error);
+ }
+}
+
+
+static void
+vfs_file_mount (NautilusFile *file,
+ GMountOperation *mount_op,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+ NautilusFileOperation *op;
+ GError *error;
+ GFile *location;
+
+ if (file->details->type != G_FILE_TYPE_MOUNTABLE) {
+ if (callback) {
+ error = NULL;
+ g_set_error (&error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+ _("This file cannot be mounted"));
+ callback (file, NULL, error, callback_data);
+ g_error_free (error);
+ }
+ return;
+ }
+
+ op = nautilus_file_operation_new (file, callback, callback_data);
+
+ location = nautilus_file_get_location (file);
+ g_file_mount_mountable (location,
+ mount_op,
+ op->cancellable,
+ vfs_file_mount_callback,
+ op);
+ g_object_unref (location);
+}
+
+static void
+vfs_file_unmount (NautilusFile *file,
+ NautilusFileOperationCallback callback,
+ gpointer callback_data)
+{
+}
+
+
+static void
nautilus_vfs_file_init (gpointer object, gpointer klass)
{
NautilusVFSFile *file;
@@ -249,9 +308,10 @@ nautilus_vfs_file_class_init (gpointer klass)
file_class->call_when_ready = vfs_file_call_when_ready;
file_class->cancel_call_when_ready = vfs_file_cancel_call_when_ready;
file_class->check_if_ready = vfs_file_check_if_ready;
- file_class->get_file_type = vfs_file_get_file_type;
file_class->get_item_count = vfs_file_get_item_count;
file_class->get_deep_counts = vfs_file_get_deep_counts;
file_class->get_date = vfs_file_get_date;
file_class->get_where_string = vfs_file_get_where_string;
+ file_class->mount = vfs_file_mount;
+ file_class->unmount = vfs_file_unmount;
}
diff --git a/libnautilus-private/nautilus-view-factory.c b/libnautilus-private/nautilus-view-factory.c
index 11850cc6c..fa134a0c8 100644
--- a/libnautilus-private/nautilus-view-factory.c
+++ b/libnautilus-private/nautilus-view-factory.c
@@ -71,24 +71,28 @@ nautilus_view_factory_create (const char *id,
gboolean
nautilus_view_factory_view_supports_uri (const char *id,
- const char *uri,
- GnomeVFSFileType file_type,
+ GFile *location,
+ GFileType file_type,
const char *mime_type)
{
const NautilusViewInfo *view_info;
+ char *uri;
+ gboolean res;
view_info = nautilus_view_factory_lookup (id);
if (view_info == NULL) {
return FALSE;
}
-
- return view_info->supports_uri (uri, file_type, mime_type);
+ uri = g_file_get_uri (location);
+ res = view_info->supports_uri (uri, file_type, mime_type);
+ g_free (uri);
+ return res;
}
GList *
nautilus_view_factory_get_views_for_uri (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type)
{
GList *l, *res;
diff --git a/libnautilus-private/nautilus-view-factory.h b/libnautilus-private/nautilus-view-factory.h
index 80ebadcdf..07315c58d 100644
--- a/libnautilus-private/nautilus-view-factory.h
+++ b/libnautilus-private/nautilus-view-factory.h
@@ -29,7 +29,7 @@
#include <libnautilus-private/nautilus-view.h>
#include <libnautilus-private/nautilus-window-info.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
+#include <gio/gfileinfo.h>
G_BEGIN_DECLS
@@ -46,7 +46,7 @@ struct _NautilusViewInfo {
NautilusView * (*create) (NautilusWindowInfo *window);
/* BONOBOTODO: More args here */
gboolean (*supports_uri) (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type);
};
@@ -56,11 +56,11 @@ const NautilusViewInfo *nautilus_view_factory_lookup (const char
NautilusView * nautilus_view_factory_create (const char *id,
NautilusWindowInfo *window);
gboolean nautilus_view_factory_view_supports_uri (const char *id,
- const char *uri,
- GnomeVFSFileType file_type,
+ GFile *location,
+ GFileType file_type,
const char *mime_type);
GList * nautilus_view_factory_get_views_for_uri (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type);
diff --git a/libnautilus-private/nautilus-view.h b/libnautilus-private/nautilus-view.h
index 8f425a2b4..2ef5fa912 100644
--- a/libnautilus-private/nautilus-view.h
+++ b/libnautilus-private/nautilus-view.h
@@ -29,7 +29,7 @@
#include <gtk/gtkwidget.h>
/* For NautilusZoomLevel */
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <libnautilus-private/nautilus-icon-info.h>
G_BEGIN_DECLS
diff --git a/libnautilus-private/nautilus-window-info.c b/libnautilus-private/nautilus-window-info.c
index 56649865b..5c55bdf00 100644
--- a/libnautilus-private/nautilus-window-info.c
+++ b/libnautilus-private/nautilus-window-info.c
@@ -153,7 +153,7 @@ nautilus_window_info_report_selection_changed (NautilusWindowInfo *window)
void
nautilus_window_info_open_location (NautilusWindowInfo *window,
- const char *location,
+ GFile *location,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags,
GList *selection)
diff --git a/libnautilus-private/nautilus-window-info.h b/libnautilus-private/nautilus-window-info.h
index 0519e1c8d..ff05e73c0 100644
--- a/libnautilus-private/nautilus-window-info.h
+++ b/libnautilus-private/nautilus-window-info.h
@@ -129,7 +129,7 @@ struct _NautilusWindowInfoIface
NautilusWindowShowHiddenFilesMode mode);
void (* open_location) (NautilusWindowInfo *window,
- const char *location,
+ GFile *location,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags,
GList *selection);
@@ -147,7 +147,7 @@ void nautilus_window_info_report_view_failed
NautilusView *view);
void nautilus_window_info_report_selection_changed (NautilusWindowInfo *window);
void nautilus_window_info_open_location (NautilusWindowInfo *window,
- const char *location,
+ GFile *location,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags,
GList *selection);
diff --git a/src/Makefile.am b/src/Makefile.am
index 63a3c8b55..7ac77c2d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,9 +5,10 @@ SUBDIRS=file-manager
bin_PROGRAMS= \
nautilus \
nautilus-file-management-properties \
- nautilus-connect-server \
$(NULL)
+# nautilus-connect-server
+
INCLUDES = \
-I$(top_srcdir) \
-I$(top_srcdir)/cut-n-paste-code \
@@ -65,9 +66,6 @@ nautilus_SOURCES = \
nautilus-bookmark-list.h \
nautilus-bookmarks-window.c \
nautilus-bookmarks-window.h \
- nautilus-connect-server-dialog.c \
- nautilus-connect-server-dialog.h \
- nautilus-connect-server-dialog-nonmain.c\
nautilus-desktop-window.c \
nautilus-desktop-window.h \
nautilus-emblem-sidebar.c \
@@ -142,13 +140,14 @@ nautilus_file_management_properties_SOURCES= \
nautilus-file-management-properties-main.c \
$(NULL)
-nautilus_connect_server_SOURCES= \
- nautilus-connect-server-dialog.c \
- nautilus-connect-server-dialog.h \
- nautilus-connect-server-dialog-main.c \
- nautilus-location-entry.c \
- nautilus-location-entry.h \
- $(NULL)
+# Disabled for now in the gio world
+#nautilus_connect_server_SOURCES= \
+# nautilus-connect-server-dialog.c \
+# nautilus-connect-server-dialog.h \
+# nautilus-connect-server-dialog-main.c \
+# nautilus-location-entry.c \
+# nautilus-location-entry.h \
+# $(NULL)
$(nautilus_shell_interface_idl_sources): nautilus_shell_interface_idl_stamp
nautilus_shell_interface_idl_stamp: nautilus-shell-interface.idl $(ORBIT_IDL)
diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am
index 824ca07ab..9ac5098be 100644
--- a/src/file-manager/Makefile.am
+++ b/src/file-manager/Makefile.am
@@ -38,6 +38,7 @@ libnautilus_file_manager_la_SOURCES= \
fm-tree-model.h \
fm-tree-view.c \
fm-tree-view.h \
+ nautilus-audio-mime-types.h \
$(NULL)
EMPTY_VIEW_SOURCES = \
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index aedaf5337..a34820ffc 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -44,7 +44,6 @@
#include <gtk/gtkcheckmenuitem.h>
#include <glib/gi18n.h>
#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-desktop-icon-file.h>
#include <libnautilus-private/nautilus-directory-background.h>
#include <libnautilus-private/nautilus-directory-notify.h>
@@ -784,8 +783,8 @@ fm_desktop_icon_view_create (NautilusWindowInfo *window)
static gboolean
fm_desktop_icon_view_supports_uri (const char *uri,
- GnomeVFSFileType file_type,
- const char *mime_type)
+ GFileType file_type,
+ const char *mime_type)
{
if (g_str_has_prefix (uri, EEL_DESKTOP_URI)) {
return TRUE;
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 32bde0edd..3f8d05e45 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -36,18 +36,20 @@
#include "fm-actions.h"
#include "fm-error-reporting.h"
#include "fm-properties-window.h"
+#include "libnautilus-private/nautilus-open-with-dialog.h"
+
#include <libgnome/gnome-url.h>
-#include <eel/eel-alert-dialog.h>
+#include <eel/eel-mount-operation.h>
#include <eel/eel-background.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-open-with-dialog.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
#include <eel/eel-marshal.h>
+#include <gdk/gdkkeysyms.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkclipboard.h>
#include <gtk/gtkiconfactory.h>
@@ -55,7 +57,6 @@
#include <gtk/gtkmain.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkselection.h>
-#include <gtk/gtksignal.h>
#include <gtk/gtkstock.h>
#include <gtk/gtktable.h>
#include <gtk/gtkmessagedialog.h>
@@ -66,17 +67,9 @@
#include <gtk/gtkenums.h>
#include <gtk/gtkbindings.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomeui/gnome-uidefs.h>
+#include <gio/gioerror.h>
+#include <gio/gcontenttype.h>
#include <libgnomeui/gnome-help.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-result.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libnautilus-private/nautilus-recent.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-private/nautilus-clipboard-monitor.h>
@@ -92,24 +85,19 @@
#include <libnautilus-private/nautilus-file-dnd.h>
#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-file-private.h> /* for nautilus_file_get_existing */
+#include <libnautilus-private/nautilus-file-private.h> /* for nautilus_file_get_existing_by_uri */
#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-link.h>
#include <libnautilus-private/nautilus-marshal.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-program-choosing.h>
-#include <libnautilus-private/nautilus-trash-directory.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
#include <libnautilus-private/nautilus-signaller.h>
#include <unistd.h>
-/* Number of seconds until cancel dialog shows up */
-#define DELAY_UNTIL_CANCEL_MSECS 5000
-
/* Minimum starting update inverval */
#define UPDATE_INTERVAL_MIN 100
/* Maximum update interval */
@@ -126,10 +114,6 @@
#define DUPLICATE_HORIZONTAL_ICON_OFFSET 70
#define DUPLICATE_VERTICAL_ICON_OFFSET 30
-#define RESPONSE_RUN 1000
-#define RESPONSE_DISPLAY 1001
-#define RESPONSE_RUN_IN_TERMINAL 1002
-
#define MAX_QUEUED_UPDATES 500
#define FM_DIRECTORY_VIEW_MENU_PATH_APPLICATIONS_SUBMENU_PLACEHOLDER "/MenuBar/File/Open Placeholder/Open With/Applications Placeholder"
@@ -153,6 +137,9 @@
#define MAX_MENU_LEVELS 5
#define TEMPLATE_LIMIT 30
+/* Directory where user scripts are placed */
+#define NAUTILUS_SCRIPTS_DIR ".gnome2/nautilus-scripts"
+
enum {
ADD_FILE,
BEGIN_FILE_CHANGES,
@@ -272,7 +259,6 @@ struct FMDirectoryViewDetails
gboolean selection_change_is_due_to_shell;
gboolean send_selection_change_to_shell;
- NautilusFile *file_monitored_for_open_with;
GtkActionGroup *open_with_action_group;
guint open_with_merge_id;
@@ -283,28 +269,6 @@ struct FMDirectoryViewDetails
GdkPoint context_menu_position;
};
-typedef enum {
- ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE,
- ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND,
- ACTIVATION_ACTION_ASK,
- ACTIVATION_ACTION_LAUNCH,
- ACTIVATION_ACTION_LAUNCH_IN_TERMINAL,
- ACTIVATION_ACTION_OPEN_IN_VIEW,
- ACTIVATION_ACTION_OPEN_IN_APPLICATION,
- ACTIVATION_ACTION_DO_NOTHING,
-} ActivationAction;
-
-typedef struct {
- FMDirectoryView *view;
- GList *files;
- NautilusFileListHandle *files_handle;
- NautilusWindowOpenMode mode;
- NautilusWindowOpenFlags flags;
- gboolean mount_success;
- unsigned int pending_mounts;
- gboolean cancelled;
-} ActivateParameters;
-
typedef struct {
NautilusFile *file;
NautilusDirectory *directory;
@@ -322,31 +286,22 @@ static const GtkTargetEntry clipboard_targets[] = {
/* forward declarations */
-static void cancel_activate_callback (gpointer callback_data);
static gboolean display_selection_info_idle_callback (gpointer data);
-static gboolean file_is_launchable (NautilusFile *file);
static void fm_directory_view_class_init (FMDirectoryViewClass *klass);
static void fm_directory_view_init (FMDirectoryView *view);
static void fm_directory_view_duplicate_selection (FMDirectoryView *view,
GList *files,
GArray *item_locations);
-static gboolean fm_directory_view_confirm_deletion (FMDirectoryView *view,
- GList *uris,
- gboolean all);
static void fm_directory_view_create_links_for_files (FMDirectoryView *view,
GList *files,
GArray *item_locations);
-static void trash_or_delete_files (FMDirectoryView *view,
- const GList *files);
-static void fm_directory_view_activate_file (FMDirectoryView *view,
- NautilusFile *file,
- NautilusWindowOpenMode mode,
- NautilusWindowOpenFlags flags);
+static void trash_or_delete_files (GtkWindow *parent_window,
+ const GList *files,
+ gboolean delete_if_all_already_in_trash);
static void load_directory (FMDirectoryView *view,
NautilusDirectory *directory);
static void fm_directory_view_merge_menus (FMDirectoryView *view);
static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view);
-static char * file_name_from_uri (const char *uri);
static void fm_directory_view_load_location (NautilusView *nautilus_view,
const char *location);
static void fm_directory_view_stop_loading (NautilusView *nautilus_view);
@@ -376,26 +331,11 @@ static void fm_directory_view_trash_state_changed_callback (NautilusTrashMon
gpointer callback_data);
static void fm_directory_view_select_file (FMDirectoryView *view,
NautilusFile *file);
-static void monitor_file_for_open_with (FMDirectoryView *view,
- NautilusFile *file);
-static void create_scripts_directory (void);
-static void activate_activation_uris_ready_callback (GList *files,
- gpointer callback_data);
-static gboolean can_show_default_app (FMDirectoryView *view,
- NautilusFile *file);
-static gboolean can_delete_uri_without_confirm (const char *uri);
-static gboolean activate_check_mime_types (FMDirectoryView *view,
- NautilusFile *file,
- gboolean warn_on_mismatch);
static GdkDragAction ask_link_action (FMDirectoryView *view);
static void update_templates_directory (FMDirectoryView *view);
static void user_dirs_changed (FMDirectoryView *view);
-static void file_get_volume_and_drive (NautilusFile *file,
- GnomeVFSVolume **volume,
- GnomeVFSDrive **drive);
-
static void action_open_scripts_folder_callback (GtkAction *action,
gpointer callback_data);
static void action_cut_files_callback (GtkAction *action,
@@ -458,7 +398,7 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, zoom_to_level)
EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_zoom_level)
typedef struct {
- GnomeVFSMimeApplication *application;
+ GAppInfo *application;
GList *files;
FMDirectoryView *directory_view;
} ApplicationLaunchParameters;
@@ -473,7 +413,37 @@ typedef struct {
FMDirectoryView *directory_view;
} CreateTemplateParameters;
+static ApplicationLaunchParameters *
+application_launch_parameters_new (GAppInfo *application,
+ GList *files,
+ FMDirectoryView *directory_view)
+{
+ ApplicationLaunchParameters *result;
+
+ result = g_new0 (ApplicationLaunchParameters, 1);
+ result->application = g_object_ref (application);
+ result->files = nautilus_file_list_copy (files);
+
+ if (directory_view != NULL) {
+ g_object_ref (directory_view);
+ result->directory_view = directory_view;
+ }
+
+ return result;
+}
+static void
+application_launch_parameters_free (ApplicationLaunchParameters *parameters)
+{
+ g_object_unref (parameters->application);
+ nautilus_file_list_free (parameters->files);
+
+ if (parameters->directory_view != NULL) {
+ g_object_unref (parameters->directory_view);
+ }
+
+ g_free (parameters);
+}
static GList *
file_and_directory_list_to_files (GList *fad_list)
@@ -549,37 +519,6 @@ file_and_directory_hash (gconstpointer v)
}
-static ApplicationLaunchParameters *
-application_launch_parameters_new (GnomeVFSMimeApplication *application,
- GList *files,
- FMDirectoryView *directory_view)
-{
- ApplicationLaunchParameters *result;
-
- result = g_new0 (ApplicationLaunchParameters, 1);
- result->application = gnome_vfs_mime_application_copy (application);
- result->files = nautilus_file_list_copy (files);
-
- if (directory_view != NULL) {
- g_object_ref (directory_view);
- result->directory_view = directory_view;
- }
-
- return result;
-}
-
-static void
-application_launch_parameters_free (ApplicationLaunchParameters *parameters)
-{
- gnome_vfs_mime_application_free (parameters->application);
- nautilus_file_list_free (parameters->files);
-
- if (parameters->directory_view != NULL) {
- g_object_unref (parameters->directory_view);
- }
-
- g_free (parameters);
-}
static ScriptLaunchParameters *
@@ -658,7 +597,7 @@ fm_directory_view_get_containing_window (FMDirectoryView *view)
}
gboolean
-fm_directory_view_confirm_multiple_windows (FMDirectoryView *view, int count)
+fm_directory_view_confirm_multiple_windows (GtkWindow *parent_window, int count)
{
GtkDialog *dialog;
char *prompt;
@@ -674,7 +613,7 @@ fm_directory_view_confirm_multiple_windows (FMDirectoryView *view, int count)
"This will open %d separate windows.", count), count);
dialog = eel_show_yes_no_dialog (prompt, detail,
GTK_STOCK_OK, GTK_STOCK_CANCEL,
- fm_directory_view_get_containing_window (view));
+ parent_window);
g_free (detail);
response = gtk_dialog_run (dialog);
@@ -720,6 +659,64 @@ selection_not_empty_in_menu_callback (FMDirectoryView *view, GList *selection)
return FALSE;
}
+static char *
+get_view_directory (FMDirectoryView *view)
+{
+ char *uri, *path;
+ GFile *f;
+
+ uri = nautilus_directory_get_uri (view->details->model);
+ if (eel_uri_is_desktop (uri)) {
+ g_free (uri);
+ uri = nautilus_get_desktop_directory_uri ();
+
+ }
+ f = g_file_new_for_uri (uri);
+ path = g_file_get_path (f);
+ g_object_unref (f);
+ g_free (uri);
+
+ return path;
+}
+
+void
+fm_directory_view_activate_files (FMDirectoryView *view,
+ GList *files,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags)
+{
+ char *path;
+
+ path = get_view_directory (view);
+ nautilus_mime_activate_files (fm_directory_view_get_containing_window (view),
+ view->details->window,
+ files,
+ path,
+ mode,
+ flags);
+
+ g_free (path);
+}
+
+void
+fm_directory_view_activate_file (FMDirectoryView *view,
+ NautilusFile *file,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags)
+{
+ char *path;
+
+ path = get_view_directory (view);
+ nautilus_mime_activate_file (fm_directory_view_get_containing_window (view),
+ view->details->window,
+ file,
+ path,
+ mode,
+ flags);
+
+ g_free (path);
+}
+
static void
action_open_callback (GtkAction *action,
gpointer callback_data)
@@ -730,7 +727,8 @@ action_open_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- fm_directory_view_activate_files (view, selection,
+ fm_directory_view_activate_files (view,
+ selection,
NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
0);
nautilus_file_list_free (selection);
@@ -746,7 +744,8 @@ action_open_close_parent_callback (GtkAction *action,
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- fm_directory_view_activate_files (view, selection,
+ fm_directory_view_activate_files (view,
+ selection,
NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND);
nautilus_file_list_free (selection);
@@ -759,11 +758,14 @@ action_open_alternate_callback (GtkAction *action,
{
FMDirectoryView *view;
GList *selection;
+ GtkWindow *window;
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- if (fm_directory_view_confirm_multiple_windows (view, g_list_length (selection))) {
+ window = fm_directory_view_get_containing_window (view);
+
+ if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
g_list_foreach (selection, open_one_in_new_window, view);
}
@@ -772,15 +774,18 @@ action_open_alternate_callback (GtkAction *action,
static void
action_open_folder_window_callback (GtkAction *action,
- gpointer callback_data)
+ gpointer callback_data)
{
FMDirectoryView *view;
GList *selection;
+ GtkWindow *window;
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- if (fm_directory_view_confirm_multiple_windows (view, g_list_length (selection))) {
+ window = fm_directory_view_get_containing_window (view);
+
+ if (fm_directory_view_confirm_multiple_windows (window, g_list_length (selection))) {
g_list_foreach (selection, open_one_in_folder_window, view);
}
@@ -788,102 +793,43 @@ action_open_folder_window_callback (GtkAction *action,
}
static void
-fm_directory_view_launch_application (GnomeVFSMimeApplication *application,
- GList *files,
- FMDirectoryView *directory_view)
-{
- NautilusFile *file;
- GList *l;
- GtkWindow *window;
-
- g_assert (application != NULL);
- g_assert (NAUTILUS_IS_FILE (files->data));
- g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
-
- window = fm_directory_view_get_containing_window (directory_view);
-
- nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, files,
- "fm_directory_view_launch_application window=%p", window);
-
- nautilus_launch_application (application, files, window);
-
- for (l = files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- nautilus_recent_add_file (file, application);
- }
-}
-
-#ifdef NEW_MIME_COMPLETE
-static void
-fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *application,
- gpointer callback_data)
-{
- ApplicationLaunchParameters *launch_parameters;
-
- g_assert (callback_data != NULL);
-
- launch_parameters = (ApplicationLaunchParameters *)callback_data;
- g_assert (launch_parameters->application == NULL);
-
- if (application != NULL) {
- fm_directory_view_launch_application
- (application, /* NOT the (empty) application in launch_parameters */
- launch_parameters->files,
- launch_parameters->directory_view);
- }
-
- application_launch_parameters_free (launch_parameters);
-}
-#endif
-
-static void
open_location (FMDirectoryView *directory_view,
const char *new_uri,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags)
{
- NautilusFile *file;
GtkWindow *window;
+ GFile *location;
g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
g_assert (new_uri != NULL);
- /* We want to avoid reloading the mime list for the
- * file if its invalidated when force-reload opening.
- * eventually the open will cause the file to change, and we'll re-set
- * the monitor for the selected file then.
- */
- file = nautilus_file_get (new_uri);
- if (file == directory_view->details->file_monitored_for_open_with) {
- monitor_file_for_open_with (directory_view, NULL);
- }
- nautilus_file_unref (file);
-
window = fm_directory_view_get_containing_window (directory_view);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"directory view open_location window=%p: %s", window, new_uri);
+ location = g_file_new_for_uri (new_uri);
nautilus_window_info_open_location (directory_view->details->window,
- new_uri, mode, flags, NULL);
+ location, mode, flags, NULL);
+ g_object_unref (location);
}
static void
-application_selected_cb (EelOpenWithDialog *dialog,
- GnomeVFSMimeApplication *app,
+application_selected_cb (NautilusOpenWithDialog *dialog,
+ GAppInfo *app,
gpointer user_data)
{
- FMDirectoryView *view;
+ GtkWindow *parent_window;
NautilusFile *file;
- GList uris;
+ GList files;
- view = FM_DIRECTORY_VIEW (user_data);
+ parent_window = GTK_WINDOW (user_data);
file = g_object_get_data (G_OBJECT (dialog), "directory-view:file");
- uris.next = NULL;
- uris.prev = NULL;
- uris.data = file;
- fm_directory_view_launch_application (app, &uris, view);
+ files.next = NULL;
+ files.prev = NULL;
+ files.data = file;
+ nautilus_launch_application (app, &files, parent_window);
}
static void
@@ -901,7 +847,7 @@ choose_program (FMDirectoryView *view,
uri = nautilus_file_get_uri (file);
mime_type = nautilus_file_get_mime_type (file);
- dialog = eel_open_with_dialog_new (uri, mime_type);
+ dialog = nautilus_open_with_dialog_new (uri, mime_type);
g_object_set_data_full (G_OBJECT (dialog),
"directory-view:file",
g_object_ref (file),
@@ -914,7 +860,7 @@ choose_program (FMDirectoryView *view,
g_signal_connect_object (dialog,
"application_selected",
G_CALLBACK (application_selected_cb),
- view,
+ fm_directory_view_get_containing_window (view),
0);
g_free (uri);
@@ -958,7 +904,7 @@ trash_or_delete_selected_files (FMDirectoryView *view)
*/
if (!view->details->selection_was_removed) {
selection = fm_directory_view_get_selection_for_file_transfer (view);
- trash_or_delete_files (view, selection);
+ trash_or_delete_files (fm_directory_view_get_containing_window (view), selection, TRUE);
nautilus_file_list_free (selection);
view->details->selection_was_removed = TRUE;
}
@@ -978,102 +924,28 @@ action_trash_callback (GtkAction *action,
trash_or_delete_selected_files (FM_DIRECTORY_VIEW (callback_data));
}
-static gboolean
-can_delete_uris_without_confirm (GList *uris)
-{
- g_assert (uris != NULL);
-
- while (uris != NULL) {
- if (!can_delete_uri_without_confirm (uris->data)) {
- return FALSE;
- }
-
- uris = uris->next;
- }
-
- return TRUE;
-}
-
-static gboolean
-confirm_delete_directly (FMDirectoryView *view,
- GList *uris)
-{
- GtkDialog *dialog;
- char *prompt;
- char *file_name;
- int uri_count;
- int response;
-
- g_assert (FM_IS_DIRECTORY_VIEW (view));
-
- /* Just Say Yes if the preference says not to confirm. */
- if (!confirm_trash_auto_value) {
- return TRUE;
- }
-
- uri_count = g_list_length (uris);
- g_assert (uri_count > 0);
-
- if (can_delete_uris_without_confirm (uris)) {
- return TRUE;
- }
-
- if (uri_count == 1) {
- file_name = file_name_from_uri ((char *) uris->data);
- prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
- file_name);
- g_free (file_name);
- } else {
- prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
- "the %d selected item?",
- "Are you sure you want to permanently delete "
- "the %d selected items?", uri_count), uri_count);
- }
-
- dialog = GTK_DIALOG (eel_alert_dialog_new (fm_directory_view_get_containing_window (view),
- 0,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- prompt,
- _("If you delete an item, it is permanently lost.")));
-
- gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_YES);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
-
- g_free (prompt);
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- return response == GTK_RESPONSE_YES;
-}
-
static void
delete_selected_files (FMDirectoryView *view)
{
GList *selection;
GList *node;
- GList *file_uris;
+ GList *locations;
selection = fm_directory_view_get_selection_for_file_transfer (view);
if (selection == NULL) {
return;
}
- file_uris = NULL;
+ locations = NULL;
for (node = selection; node != NULL; node = node->next) {
- file_uris = g_list_prepend (file_uris,
- nautilus_file_get_uri ((NautilusFile *) node->data));
+ locations = g_list_prepend (locations,
+ nautilus_file_get_location ((NautilusFile *) node->data));
}
- file_uris = g_list_reverse (file_uris);
+ locations = g_list_reverse (locations);
- if (confirm_delete_directly (view,
- file_uris)) {
- nautilus_file_operations_delete (file_uris, GTK_WIDGET (view), NULL, NULL);
- }
+ nautilus_file_operations_delete (locations, fm_directory_view_get_containing_window (view), NULL, NULL);
- eel_g_list_free_deep (file_uris);
+ eel_g_object_list_free (locations);
nautilus_file_list_free (selection);
}
@@ -1324,6 +1196,7 @@ action_save_search_as_callback (GtkAction *action,
GtkWidget *dialog, *table, *label, *entry, *chooser, *save_button;
const char *entry_text;
char *filename, *filename_utf8, *dirname, *path, *uri;
+ GFile *location;
directory_view = FM_DIRECTORY_VIEW (callback_data);
@@ -1397,11 +1270,13 @@ action_save_search_as_callback (GtkAction *action,
g_free (filename);
g_free (dirname);
- uri = gnome_vfs_get_uri_from_local_path (path);
+ uri = g_filename_to_uri (path, NULL, NULL);
g_free (path);
nautilus_search_directory_save_to_file (search, uri);
- nautilus_file_changes_queue_file_added (uri);
+ location = g_file_new_for_uri (uri);
+ nautilus_file_changes_queue_file_added (location);
+ g_object_unref (location);
nautilus_file_changes_consume_changes (TRUE);
g_free (uri);
}
@@ -1629,48 +1504,16 @@ set_up_scripts_directory_global (void)
return;
}
- scripts_directory_path = gnome_util_home_file ("nautilus-scripts");
-
- scripts_directory_uri = gnome_vfs_get_uri_from_local_path (scripts_directory_path);
- scripts_directory_uri_length = strlen (scripts_directory_uri);
-
- if (!g_file_test (scripts_directory_path, G_FILE_TEST_EXISTS)) {
- create_scripts_directory ();
- }
-
- g_free (scripts_directory_path);
-}
-
-static void
-create_scripts_directory (void)
-{
- char *gnome1_path, *gnome1_uri_str;
- GnomeVFSURI *gnome1_uri, *scripts_uri;
-
- scripts_uri = gnome_vfs_uri_new (scripts_directory_uri);
- /* try to migrate nautilus 1 scripts */
- gnome1_path = g_strconcat (g_get_home_dir(), "/.gnome/nautilus-scripts", NULL);
+ scripts_directory_path = g_build_filename (g_get_home_dir (),
+ NAUTILUS_SCRIPTS_DIR,
+ NULL);
- if (g_file_test (gnome1_path, G_FILE_TEST_EXISTS)) {
- gnome1_uri_str = gnome_vfs_get_uri_from_local_path (gnome1_path);
- gnome1_uri = gnome_vfs_uri_new (gnome1_uri_str);
- g_free (gnome1_uri_str);
- if (gnome_vfs_xfer_uri (gnome1_uri, scripts_uri,
- GNOME_VFS_XFER_DEFAULT,
- GNOME_VFS_XFER_ERROR_MODE_ABORT,
- GNOME_VFS_XFER_OVERWRITE_MODE_SKIP,
- NULL, NULL) != GNOME_VFS_OK) {
- g_warning ("Failed to migrate Nautilus1 scripts\n");
- }
- gnome_vfs_uri_unref (gnome1_uri);
+ if (g_mkdir_with_parents (scripts_directory_path, 0755) == 0) {
+ scripts_directory_uri = g_filename_to_uri (scripts_directory_path, NULL, NULL);
+ scripts_directory_uri_length = strlen (scripts_directory_uri);
}
- g_free (gnome1_path);
- /* make sure scripts directory is created */
- gnome_vfs_make_directory_for_uri (scripts_uri,
- GNOME_VFS_PERM_USER_ALL | GNOME_VFS_PERM_GROUP_ALL | GNOME_VFS_PERM_OTHER_READ);
-
- gnome_vfs_uri_unref (scripts_uri);
+ g_free (scripts_directory_path);
}
static void
@@ -1700,18 +1543,6 @@ templates_added_or_changed_callback (NautilusDirectory *directory,
}
static void
-icons_changed_callback (gpointer callback_data)
-{
- FMDirectoryView *view;
-
- view = FM_DIRECTORY_VIEW (callback_data);
-
- view->details->scripts_invalid = TRUE;
- view->details->templates_invalid = TRUE;
- schedule_update_menus (view);
-}
-
-static void
add_directory_to_directory_list (FMDirectoryView *view,
NautilusDirectory *directory,
GList **directory_list,
@@ -1722,8 +1553,9 @@ add_directory_to_directory_list (FMDirectoryView *view,
if (g_list_find (*directory_list, directory) == NULL) {
nautilus_directory_ref (directory);
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES |
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT;
nautilus_directory_file_monitor_add (directory, directory_list,
@@ -1850,15 +1682,16 @@ fm_directory_view_get_selection_uris (NautilusView *view)
}
static GList *
-file_list_from_uri_list (GList *uri_list)
+file_list_from_uri_list (const GList *uri_list)
{
- GList *file_list, *node;
+ GList *file_list;
+ const GList *node;
file_list = NULL;
for (node = uri_list; node != NULL; node = node->next) {
file_list = g_list_prepend
(file_list,
- nautilus_file_get (node->data));
+ nautilus_file_get_by_uri (node->data));
}
return g_list_reverse (file_list);
}
@@ -1949,13 +1782,13 @@ fm_directory_view_init (FMDirectoryView *view)
gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (view), NULL);
set_up_scripts_directory_global ();
- scripts_directory = nautilus_directory_get (scripts_directory_uri);
+ scripts_directory = nautilus_directory_get_by_uri (scripts_directory_uri);
add_directory_to_scripts_directory_list (view, scripts_directory);
nautilus_directory_unref (scripts_directory);
if (nautilus_should_use_templates_directory ()) {
templates_uri = nautilus_get_templates_directory_uri ();
- templates_directory = nautilus_directory_get (templates_uri);
+ templates_directory = nautilus_directory_get_by_uri (templates_uri);
g_free (templates_uri);
add_directory_to_templates_directory_list (view, templates_directory);
nautilus_directory_unref (templates_directory);
@@ -1972,11 +1805,6 @@ fm_directory_view_init (FMDirectoryView *view)
g_signal_connect_object (nautilus_trash_monitor_get (), "trash_state_changed",
G_CALLBACK (fm_directory_view_trash_state_changed_callback), view, 0);
- /* React to icon theme changes. */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (icons_changed_callback),
- view, G_CONNECT_SWAPPED);
-
/* React to clipboard changes */
g_signal_connect_object (nautilus_clipboard_monitor_get (), "clipboard_changed",
G_CALLBACK (clipboard_changed_callback), view, 0);
@@ -2048,8 +1876,6 @@ fm_directory_view_destroy (GtkObject *object)
/* We don't own the window, so no unref */
view->details->window = NULL;
- monitor_file_for_open_with (view, NULL);
-
fm_directory_view_stop (view);
fm_directory_view_clear (view);
@@ -2146,7 +1972,7 @@ void
fm_directory_view_display_selection_info (FMDirectoryView *view)
{
GList *selection;
- GnomeVFSFileSize non_folder_size;
+ goffset non_folder_size;
gboolean non_folder_size_known;
guint non_folder_count, folder_count, folder_item_count;
gboolean folder_item_count_known;
@@ -2185,7 +2011,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
}
} else {
non_folder_count++;
- if (!nautilus_file_info_missing (file, GNOME_VFS_FILE_INFO_FIELDS_SIZE)) {
+ if (!nautilus_file_can_get_size (file)) {
non_folder_size_known = TRUE;
non_folder_size += nautilus_file_get_size (file);
}
@@ -2260,7 +2086,7 @@ fm_directory_view_display_selection_info (FMDirectoryView *view)
if (non_folder_size_known) {
char *size_string;
- size_string = gnome_vfs_format_file_size_for_display (non_folder_size);
+ size_string = g_format_file_size_for_display (non_folder_size);
/* This is marked for translation in case a localiser
* needs to use something other than parentheses. The
* first message gives the number of items selected;
@@ -2358,7 +2184,7 @@ fm_directory_view_load_location (NautilusView *nautilus_view,
directory_view->details->allow_moves = TRUE;
}
- directory = nautilus_directory_get (location);
+ directory = nautilus_directory_get_by_uri (location);
load_directory (directory_view, directory);
nautilus_directory_unref (directory);
}
@@ -2485,14 +2311,14 @@ done_loading (FMDirectoryView *view)
typedef struct {
- GHashTable *debuting_uris;
+ GHashTable *debuting_files;
GList *added_files;
-} DebutingUriData;
+} DebutingFilesData;
static void
-debuting_uri_data_free (DebutingUriData *data)
+debuting_files_data_free (DebutingFilesData *data)
{
- g_hash_table_destroy (data->debuting_uris);
+ g_hash_table_unref (data->debuting_files);
nautilus_file_list_free (data->added_files);
g_free (data);
}
@@ -2502,29 +2328,29 @@ debuting_uri_data_free (DebutingUriData *data)
* it selects and reveals them all.
*/
static void
-debuting_uri_add_file_callback (FMDirectoryView *view,
- NautilusFile *new_file,
- NautilusDirectory *directory,
- DebutingUriData *data)
+debuting_files_add_file_callback (FMDirectoryView *view,
+ NautilusFile *new_file,
+ NautilusDirectory *directory,
+ DebutingFilesData *data)
{
- char *uri;
+ GFile *location;
- uri = nautilus_file_get_uri (new_file);
+ location = nautilus_file_get_location (new_file);
- if (g_hash_table_remove (data->debuting_uris, uri)) {
+ if (g_hash_table_remove (data->debuting_files, location)) {
nautilus_file_ref (new_file);
data->added_files = g_list_prepend (data->added_files, new_file);
- if (g_hash_table_size (data->debuting_uris) == 0) {
+ if (g_hash_table_size (data->debuting_files) == 0) {
fm_directory_view_set_selection (view, data->added_files);
fm_directory_view_reveal_selection (view);
g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (debuting_uri_add_file_callback),
+ G_CALLBACK (debuting_files_add_file_callback),
data);
}
}
- g_free (uri);
+ g_object_unref (location);
}
typedef struct {
@@ -2543,16 +2369,19 @@ copy_move_done_data_free (CopyMoveDoneData *data)
}
static void
-pre_copy_move_add_file_callback (FMDirectoryView *view, NautilusFile *new_file, NautilusDirectory *directory, CopyMoveDoneData *data)
+pre_copy_move_add_file_callback (FMDirectoryView *view,
+ NautilusFile *new_file,
+ NautilusDirectory *directory,
+ CopyMoveDoneData *data)
{
- g_object_ref (new_file);
+ nautilus_file_ref (new_file);
data->added_files = g_list_prepend (data->added_files, new_file);
}
/* This needs to be called prior to nautilus_file_operations_copy_move.
* It hooks up a signal handler to catch any icons that get added before
* the copy_done_callback is invoked. The return value should be passed
- * as the data for copy_move_done_callback.
+ * as the data for uri_copy_move_done_callback.
*/
static CopyMoveDoneData *
pre_copy_move (FMDirectoryView *directory_view)
@@ -2580,12 +2409,12 @@ pre_copy_move (FMDirectoryView *directory_view)
static gboolean
copy_move_done_partition_func (gpointer data, gpointer callback_data)
{
- char *uri;
+ GFile *location;
gboolean result;
- uri = nautilus_file_get_uri (NAUTILUS_FILE (data));
- result = g_hash_table_remove ((GHashTable *) callback_data, uri);
- g_free (uri);
+ location = nautilus_file_get_location (NAUTILUS_FILE (data));
+ result = g_hash_table_remove ((GHashTable *) callback_data, location);
+ g_object_unref (location);
return result;
}
@@ -2596,6 +2425,9 @@ remove_not_really_moved_files (gpointer key,
gpointer callback_data)
{
GList **added_files;
+ GFile *loc;
+
+ loc = key;
if (GPOINTER_TO_INT (value)) {
return FALSE;
@@ -2603,7 +2435,7 @@ remove_not_really_moved_files (gpointer key,
added_files = callback_data;
*added_files = g_list_prepend (*added_files,
- nautilus_file_get (key));
+ nautilus_file_get (loc));
return TRUE;
}
@@ -2616,11 +2448,11 @@ remove_not_really_moved_files (gpointer key,
* up a signal handler to await their arrival.
*/
static void
-copy_move_done_callback (GHashTable *debuting_uris, gpointer data)
+copy_move_done_callback (GHashTable *debuting_files, gpointer data)
{
FMDirectoryView *directory_view;
CopyMoveDoneData *copy_move_done_data;
- DebutingUriData *debuting_uri_data;
+ DebutingFilesData *debuting_files_data;
copy_move_done_data = (CopyMoveDoneData *) data;
directory_view = copy_move_done_data->directory_view;
@@ -2628,12 +2460,12 @@ copy_move_done_callback (GHashTable *debuting_uris, gpointer data)
if (directory_view != NULL) {
g_assert (FM_IS_DIRECTORY_VIEW (directory_view));
- debuting_uri_data = g_new (DebutingUriData, 1);
- debuting_uri_data->debuting_uris = debuting_uris;
- debuting_uri_data->added_files = eel_g_list_partition
+ debuting_files_data = g_new (DebutingFilesData, 1);
+ debuting_files_data->debuting_files = g_hash_table_ref (debuting_files);
+ debuting_files_data->added_files = eel_g_list_partition
(copy_move_done_data->added_files,
copy_move_done_partition_func,
- debuting_uris,
+ debuting_files,
&copy_move_done_data->added_files);
/* We're passed the same data used by pre_copy_move_add_file_callback, so disconnecting
@@ -2644,23 +2476,23 @@ copy_move_done_callback (GHashTable *debuting_uris, gpointer data)
G_CALLBACK (pre_copy_move_add_file_callback),
data);
- /* Any items in the debuting_uris hash table that have
+ /* Any items in the debuting_files hash table that have
* "FALSE" as their value aren't really being copied
* or moved, so we can't wait for an add_file signal
* to come in for those.
*/
- g_hash_table_foreach_remove (debuting_uris,
+ g_hash_table_foreach_remove (debuting_files,
remove_not_really_moved_files,
- &debuting_uri_data->added_files);
+ &debuting_files_data->added_files);
- if (g_hash_table_size (debuting_uris) == 0) {
+ if (g_hash_table_size (debuting_files) == 0) {
/* on the off-chance that all the icons have already been added */
- if (debuting_uri_data->added_files != NULL) {
+ if (debuting_files_data->added_files != NULL) {
fm_directory_view_set_selection (directory_view,
- debuting_uri_data->added_files);
+ debuting_files_data->added_files);
fm_directory_view_reveal_selection (directory_view);
}
- debuting_uri_data_free (debuting_uri_data);
+ debuting_files_data_free (debuting_files_data);
} else {
/* We need to run after the default handler adds the folder we want to
* operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we
@@ -2668,9 +2500,9 @@ copy_move_done_callback (GHashTable *debuting_uris, gpointer data)
*/
g_signal_connect_data (GTK_OBJECT (directory_view),
"add_file",
- G_CALLBACK (debuting_uri_add_file_callback),
- debuting_uri_data,
- (GClosureNotify) debuting_uri_data_free,
+ G_CALLBACK (debuting_files_add_file_callback),
+ debuting_files_data,
+ (GClosureNotify) debuting_files_data_free,
G_CONNECT_AFTER);
}
}
@@ -2699,7 +2531,8 @@ still_should_show_file (FMDirectoryView *view, NautilusFile *file, NautilusDirec
static gboolean
ready_to_load (NautilusFile *file)
{
- return nautilus_icon_factory_is_icon_ready_for_file (file);
+ return nautilus_file_check_if_ready (file,
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON);
}
static int
@@ -2912,7 +2745,6 @@ fm_directory_view_unfreeze_updates (FMDirectoryView *view)
}
}
-
static gboolean
display_selection_info_idle_callback (gpointer data)
{
@@ -2945,19 +2777,6 @@ remove_update_menus_timeout_callback (FMDirectoryView *view)
static void
update_menus_if_pending (FMDirectoryView *view)
{
- GList *selection;
-
- /* We need to monitor the mime list for the open with file
- * so we can get the menu right, but we only do this
- * on actual menu popup since this can do I/O.
- */
- selection = fm_directory_view_get_selection (view);
- if (eel_g_list_exactly_one_item (selection)) {
- monitor_file_for_open_with (view, NAUTILUS_FILE (selection->data));
- }
- nautilus_file_list_free (selection);
-
-
if (!view->details->menu_states_untrustworthy) {
return;
}
@@ -3222,8 +3041,7 @@ done_loading_callback (NautilusDirectory *directory,
static void
load_error_callback (NautilusDirectory *directory,
- GnomeVFSResult load_error_code,
- const char *load_error_message,
+ GError *error,
gpointer callback_data)
{
FMDirectoryView *view;
@@ -3239,14 +3057,12 @@ load_error_callback (NautilusDirectory *directory,
* occurred, so they can handle it in the UI.
*/
g_signal_emit (view,
- signals[LOAD_ERROR], 0, load_error_code, load_error_message);
+ signals[LOAD_ERROR], 0, error);
}
static void
-real_load_error (FMDirectoryView *view, GnomeVFSResult result, const char *error_message)
+real_load_error (FMDirectoryView *view, GError *error)
{
- g_assert (result != GNOME_VFS_OK);
-
/* Report only one error per failed directory load (from the UI
* point of view, not from the NautilusDirectory point of view).
* Otherwise you can get multiple identical errors caused by
@@ -3255,8 +3071,8 @@ real_load_error (FMDirectoryView *view, GnomeVFSResult result, const char *error
*/
if (!view->details->reported_load_error) {
fm_report_error_loading_directory
- (fm_directory_view_get_directory_as_file (view),
- result, error_message,
+ (fm_directory_view_get_directory_as_file (view),
+ error,
fm_directory_view_get_containing_window (view));
}
view->details->reported_load_error = TRUE;
@@ -3272,11 +3088,12 @@ fm_directory_view_add_subdirectory (FMDirectoryView *view,
nautilus_directory_ref (directory);
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME |
NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO;
nautilus_directory_file_monitor_add (directory,
@@ -3571,7 +3388,6 @@ fm_directory_view_get_selection_for_file_transfer (FMDirectoryView *view)
get_selection_for_file_transfer, (view));
}
-
guint
fm_directory_view_get_item_count (FMDirectoryView *view)
{
@@ -3772,263 +3588,26 @@ desktop_or_home_dir_in_selection (FMDirectoryView *view)
return saw_desktop_or_home_dir;
}
-static gboolean
-can_move_uri_to_trash (FMDirectoryView *view, const char *file_uri_string)
-{
- /* Return TRUE if we can get a trash directory on the same volume as this file. */
- GnomeVFSURI *file_uri;
- GnomeVFSURI *directory_uri;
- GnomeVFSURI *trash_dir_uri;
- gboolean result;
-
- g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
- g_return_val_if_fail (file_uri_string != NULL, FALSE);
-
- file_uri = gnome_vfs_uri_new (file_uri_string);
-
- if (file_uri == NULL) {
- return FALSE;
- }
-
- /* FIXME: Why can't we just pass file_uri to gnome_vfs_find_directory? */
- directory_uri = gnome_vfs_uri_get_parent (file_uri);
- gnome_vfs_uri_unref (file_uri);
-
- if (directory_uri == NULL) {
- return FALSE;
- }
-
- /*
- * Create a new trash if needed but don't go looking for an old Trash.
- * Passing 0 permissions as gnome-vfs would override the permissions
- * passed with 700 while creating .Trash directory
- */
- result = gnome_vfs_find_directory (directory_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_dir_uri, TRUE, FALSE, 0) == GNOME_VFS_OK;
- if (result) {
- gnome_vfs_uri_unref (trash_dir_uri);
- }
- gnome_vfs_uri_unref (directory_uri);
-
- return result;
-}
-
-static gboolean
-can_delete_uri_without_confirm (const char *file_uri_string)
-{
- if (eel_istr_has_prefix (file_uri_string, "burn:") != FALSE) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-static char *
-file_name_from_uri (const char *uri)
-{
- NautilusFile *file;
- char *file_name;
-
- file = nautilus_file_get (uri);
- file_name = nautilus_file_get_display_name (file);
- nautilus_file_unref (file);
-
- return file_name;
-}
-
-static gboolean
-fm_directory_view_confirm_deletion (FMDirectoryView *view, GList *uris, gboolean all)
-{
- GtkDialog *dialog;
- char *prompt;
- char *detail;
- int uri_count;
- char *uri;
- char *file_name;
- int response;
-
- g_assert (FM_IS_DIRECTORY_VIEW (view));
-
- uri_count = g_list_length (uris);
- g_assert (uri_count > 0);
-
- if (uri_count == 1) {
- uri = (char *) uris->data;
- if (eel_uri_is_desktop (uri)) {
- /* Don't ask for desktop icons */
- return TRUE;
- }
- file_name = file_name_from_uri (uri);
- prompt = _("Cannot move file to trash, do you want to delete immediately?");
- detail = g_strdup_printf (_("The file \"%s\" cannot be moved to the trash."), file_name);
- g_free (file_name);
- } else {
- if (all) {
- prompt = _("Cannot move items to trash, do you want to delete them immediately?");
- detail = g_strdup_printf (ngettext("The selected item could not be moved to the Trash",
- "The %d selected items could not be moved to the Trash",
- uri_count),
- uri_count);
- } else {
- prompt = _("Cannot move some items to trash, do you want to delete these immediately?");
- detail = g_strdup_printf (_("%d of the selected items cannot be moved to the Trash"), uri_count);
- }
- }
-
- dialog = eel_show_yes_no_dialog
- (prompt,
- detail, GTK_STOCK_DELETE, GTK_STOCK_CANCEL,
- fm_directory_view_get_containing_window (view));
-
- g_free (detail);
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- return response == GTK_RESPONSE_YES;
-}
-
-static gboolean
-confirm_delete_from_trash (FMDirectoryView *view, GList *uris)
-{
- GtkDialog *dialog;
- char *prompt;
- char *file_name;
- int uri_count;
- int response;
-
- g_assert (FM_IS_DIRECTORY_VIEW (view));
-
- /* Just Say Yes if the preference says not to confirm. */
- if (!confirm_trash_auto_value) {
- return TRUE;
- }
-
- uri_count = g_list_length (uris);
- g_assert (uri_count > 0);
-
- if (uri_count == 1) {
- file_name = file_name_from_uri ((char *) uris->data);
- prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\" "
- "from the trash?"), file_name);
- g_free (file_name);
- } else {
- prompt = g_strdup_printf (ngettext("Are you sure you want to permanently delete "
- "the %d selected item from the trash?",
- "Are you sure you want to permanently delete "
- "the %d selected items from the trash?",
- uri_count),
- uri_count);
- }
-
- dialog = GTK_DIALOG (eel_alert_dialog_new(fm_directory_view_get_containing_window (view),
- 0, GTK_MESSAGE_WARNING, GTK_BUTTONS_NONE,
- prompt,
- _("If you delete an item, it will be permanently lost.")));
- gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_YES);
-
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
-
- g_free (prompt);
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- return response == GTK_RESPONSE_YES;
-}
-
-static void
-trash_or_delete_files_common (FMDirectoryView *view,
- const GList *file_uris,
- GArray *relative_item_points,
- gboolean delete_if_all_already_in_trash)
-{
- const GList *file_node;
- char *file_uri;
- GList *moveable_uris;
- GList *unmoveable_uris;
- GList *in_trash_uris;
- GList *no_confirm_uris;
-
- g_assert (FM_IS_DIRECTORY_VIEW (view));
-
- /* Collect three lists: (1) items that can be moved to trash,
- * (2) items that can only be deleted in place, and (3) items that
- * are already in trash.
- *
- * Always move (1) to trash if non-empty.
- * Delete (3) only if (1) and (2) are non-empty, otherwise ignore (3).
- * Ask before deleting (2) if non-empty.
- * Ask before deleting (3) if non-empty.
- */
-
- moveable_uris = NULL;
- unmoveable_uris = NULL;
- in_trash_uris = NULL;
- no_confirm_uris = NULL;
-
- for (file_node = file_uris; file_node != NULL; file_node = file_node->next) {
- file_uri = (char *) file_node->data;
-
- if (delete_if_all_already_in_trash && eel_uri_is_in_trash (file_uri)) {
- in_trash_uris = g_list_prepend (in_trash_uris, g_strdup (file_uri));
- } else if (can_delete_uri_without_confirm (file_uri)) {
- no_confirm_uris = g_list_prepend (no_confirm_uris, g_strdup (file_uri));
- } else if (can_move_uri_to_trash (view, file_uri)) {
- moveable_uris = g_list_prepend (moveable_uris, g_strdup (file_uri));
- } else {
- unmoveable_uris = g_list_prepend (unmoveable_uris, g_strdup (file_uri));
- }
- }
-
- if (in_trash_uris != NULL && moveable_uris == NULL && unmoveable_uris == NULL) {
- if (confirm_delete_from_trash (view, in_trash_uris)) {
- nautilus_file_operations_delete (in_trash_uris, GTK_WIDGET (view),
- NULL, NULL);
- }
- } else {
- if (no_confirm_uris != NULL) {
- nautilus_file_operations_delete (no_confirm_uris,
- GTK_WIDGET (view), NULL, NULL);
- }
- if (moveable_uris != NULL) {
- nautilus_file_operations_copy_move (moveable_uris, relative_item_points,
- EEL_TRASH_URI, GDK_ACTION_MOVE, GTK_WIDGET (view),
- copy_move_done_callback, pre_copy_move (view));
- }
- if (unmoveable_uris != NULL) {
- if (fm_directory_view_confirm_deletion (view,
- unmoveable_uris,
- moveable_uris == NULL)) {
- nautilus_file_operations_delete (unmoveable_uris,
- GTK_WIDGET (view), NULL, NULL);
- }
- }
- }
-
- eel_g_list_free_deep (in_trash_uris);
- eel_g_list_free_deep (moveable_uris);
- eel_g_list_free_deep (unmoveable_uris);
- eel_g_list_free_deep (no_confirm_uris);
-}
-
static void
-trash_or_delete_files (FMDirectoryView *view,
- const GList *files)
+trash_or_delete_files (GtkWindow *parent_window,
+ const GList *files,
+ gboolean delete_if_all_already_in_trash)
{
- GList *file_uris;
+ GList *locations;
const GList *node;
- file_uris = NULL;
+ locations = NULL;
for (node = files; node != NULL; node = node->next) {
- file_uris = g_list_prepend (file_uris,
- nautilus_file_get_uri ((NautilusFile *) node->data));
+ locations = g_list_prepend (locations,
+ nautilus_file_get_location ((NautilusFile *) node->data));
}
- file_uris = g_list_reverse (file_uris);
- trash_or_delete_files_common (view, file_uris, NULL, TRUE);
- eel_g_list_free_deep (file_uris);
+ locations = g_list_reverse (locations);
+
+ nautilus_file_operations_trash_or_delete (locations,
+ parent_window,
+ NULL, NULL);
+ eel_g_object_list_free (locations);
}
static gboolean
@@ -4165,7 +3744,7 @@ new_folder_done (const char *new_folder_uri, gpointer user_data)
screen = gtk_widget_get_screen (GTK_WIDGET (directory_view));
screen_string = g_strdup_printf ("%d", gdk_screen_get_number (screen));
- file = nautilus_file_get (new_folder_uri);
+ file = nautilus_file_get_by_uri (new_folder_uri);
nautilus_file_set_metadata
(file, NAUTILUS_METADATA_KEY_SCREEN,
NULL,
@@ -4386,10 +3965,10 @@ open_with_launch_application_callback (GtkAction *action,
ApplicationLaunchParameters *launch_parameters;
launch_parameters = (ApplicationLaunchParameters *) callback_data;
- fm_directory_view_launch_application
+ nautilus_launch_application
(launch_parameters->application,
launch_parameters->files,
- launch_parameters->directory_view);
+ fm_directory_view_get_containing_window (launch_parameters->directory_view));
}
static char *
@@ -4510,7 +4089,7 @@ add_submenu (GtkUIManager *ui_manager,
static void
add_application_to_open_with_menu (FMDirectoryView *view,
- GnomeVFSMimeApplication *application,
+ GAppInfo *application,
GList *files,
int index,
const char *menu_placeholder,
@@ -4525,7 +4104,7 @@ add_application_to_open_with_menu (FMDirectoryView *view,
launch_parameters = application_launch_parameters_new
(application, files, view);
- escaped_app = eel_str_double_underscores (application->name);
+ escaped_app = eel_str_double_underscores (g_app_info_get_name (application));
label = g_strdup_printf (_("Open with \"%s\""), escaped_app);
tip = g_strdup_printf (ngettext ("Use \"%s\" to open the selected item",
"Use \"%s\" to open the selected items",
@@ -4571,139 +4150,6 @@ add_application_to_open_with_menu (FMDirectoryView *view,
}
-static ActivationAction
-get_default_executable_text_file_action (void)
-{
- int preferences_value;
-
- preferences_value = eel_preferences_get_enum
- (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
- switch (preferences_value) {
- case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
- return ACTIVATION_ACTION_LAUNCH;
- case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
- return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
- case NAUTILUS_EXECUTABLE_TEXT_ASK:
- default:
- return ACTIVATION_ACTION_ASK;
- }
-}
-
-static ActivationAction
-get_executable_text_file_action (FMDirectoryView *view, NautilusFile *file)
-{
- GtkDialog *dialog;
- char *file_name;
- char *prompt;
- char *detail;
- int preferences_value;
- int response;
-
- g_assert (nautilus_file_contains_text (file));
-
- preferences_value = eel_preferences_get_enum
- (NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION);
- switch (preferences_value) {
- case NAUTILUS_EXECUTABLE_TEXT_LAUNCH:
- return ACTIVATION_ACTION_LAUNCH;
- case NAUTILUS_EXECUTABLE_TEXT_DISPLAY:
- return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
- case NAUTILUS_EXECUTABLE_TEXT_ASK:
- break;
- default:
- /* Complain non-fatally, since preference data can't be trusted */
- g_warning ("Unknown value %d for NAUTILUS_PREFERENCES_EXECUTABLE_TEXT_ACTIVATION",
- preferences_value);
-
- }
-
-
- file_name = nautilus_file_get_display_name (file);
- prompt = g_strdup_printf (_("Do you want to run \"%s\", or display its contents?"),
- file_name);
- detail = g_strdup_printf (_("\"%s\" is an executable text file."),
- file_name);
- g_free (file_name);
-
- dialog = eel_create_question_dialog (prompt,
- detail,
- _("Run in _Terminal"), RESPONSE_RUN_IN_TERMINAL,
- _("_Display"), RESPONSE_DISPLAY,
- fm_directory_view_get_containing_window (view));
- gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (dialog, _("_Run"), RESPONSE_RUN);
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_CANCEL);
- gtk_widget_show (GTK_WIDGET (dialog));
-
- g_free (prompt);
- g_free (detail);
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- switch (response) {
- case RESPONSE_RUN:
- return ACTIVATION_ACTION_LAUNCH;
- case RESPONSE_RUN_IN_TERMINAL:
- return ACTIVATION_ACTION_LAUNCH_IN_TERMINAL;
- case RESPONSE_DISPLAY:
- return ACTIVATION_ACTION_OPEN_IN_APPLICATION;
- default:
- return ACTIVATION_ACTION_DO_NOTHING;
- }
-}
-
-static gboolean
-can_use_component_for_file (NautilusFile *file)
-{
- return (nautilus_file_is_directory (file) ||
- NAUTILUS_IS_DESKTOP_ICON_FILE (file) ||
- nautilus_file_is_nautilus_link (file));
-}
-
-static ActivationAction
-get_activation_action (NautilusFile *file)
-{
- ActivationAction action;
- char *activation_uri;
-
- activation_uri = nautilus_file_get_activation_uri (file);
- if (activation_uri == NULL) {
- activation_uri = nautilus_file_get_uri (file);
- }
-
- action = ACTIVATION_ACTION_DO_NOTHING;
-
- if (eel_str_has_prefix (activation_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
- action = ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE;
- } else if (eel_str_has_prefix (activation_uri, NAUTILUS_COMMAND_SPECIFIER)) {
- action = ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND;
- } else if (file_is_launchable (file)) {
- char *executable_path;
-
- action = ACTIVATION_ACTION_LAUNCH;
-
- executable_path = gnome_vfs_get_local_path_from_uri (activation_uri);
- if (!executable_path) {
- action = ACTIVATION_ACTION_DO_NOTHING;
- } else if (nautilus_file_contains_text (file)) {
- action = get_default_executable_text_file_action ();
- }
- g_free (executable_path);
- }
-
- if (action == ACTIVATION_ACTION_DO_NOTHING) {
- if (can_use_component_for_file (file)) {
- action = ACTIVATION_ACTION_OPEN_IN_VIEW;
- } else {
- action = ACTIVATION_ACTION_OPEN_IN_APPLICATION;
- }
- }
- g_free (activation_uri);
-
- return action;
-}
-
static void
reset_open_with_menu (FMDirectoryView *view, GList *selection)
{
@@ -4716,8 +4162,7 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
gboolean open_with_chooser_visible;
GtkUIManager *ui_manager;
GtkAction *action;
- GnomeVFSMimeApplication *default_app;
- ActivationAction activation_action;
+ GAppInfo *default_app;
/* Clear any previous inserted items in the applications and viewers placeholders */
@@ -4740,22 +4185,8 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
file = NAUTILUS_FILE (node->data);
other_applications_visible &=
- (!can_use_component_for_file (file) ||
+ (!nautilus_mime_file_opens_in_view (file) ||
nautilus_file_is_directory (file));
-
- activation_action = get_activation_action (file);
-
- /* Only use the default app for open if there is not
- a mime mismatch, otherwise we can't use it in the
- open with menu */
- if (activation_action == ACTIVATION_ACTION_OPEN_IN_APPLICATION &&
- !can_show_default_app (view, file)) {
- filter_default = TRUE;
- }
-
- if (filter_default && !other_applications_visible) {
- break;
- }
}
default_app = NULL;
@@ -4765,19 +4196,19 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
applications = NULL;
if (other_applications_visible) {
- applications = nautilus_mime_get_open_with_applications_for_files (selection);
+ applications = nautilus_mime_get_applications_for_files (selection);
}
num_applications = g_list_length (applications);
for (node = applications, index = 0; node != NULL; node = node->next, index++) {
- GnomeVFSMimeApplication *application;
+ GAppInfo *application;
char *menu_path;
char *popup_path;
application = node->data;
- if (default_app != NULL && gnome_vfs_mime_application_equal (default_app, application)) {
+ if (default_app != NULL && g_app_info_equal (default_app, application)) {
continue;
}
@@ -4803,8 +4234,10 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection)
index,
menu_path, popup_path);
}
- gnome_vfs_mime_application_list_free (applications);
- gnome_vfs_mime_application_free (default_app);
+ eel_g_object_list_free (applications);
+ if (default_app != NULL) {
+ g_object_unref (default_app);
+ }
submenu_visible = (num_applications > 3);
@@ -4874,8 +4307,8 @@ extension_action_callback_data_free (ExtensionActionCallbackData *data)
}
static void
-extension_action_slow_mime_types_ready_callback (GList *selection,
- gpointer callback_data)
+extension_action_callback (GtkAction *action,
+ gpointer callback_data)
{
ExtensionActionCallbackData *data;
char *item_name;
@@ -4915,26 +4348,38 @@ extension_action_slow_mime_types_ready_callback (GList *selection,
if (is_valid) {
nautilus_menu_item_activate (data->item);
}
-
- g_object_unref (data->action);
}
-static void
-extension_action_callback (GtkAction *action,
- gpointer callback_data)
+static GdkPixbuf *
+get_menu_icon (const char *icon_name)
{
- ExtensionActionCallbackData *data;
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int size;
- data = callback_data;
+ size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ info = nautilus_icon_info_lookup_from_name (icon_name, size);
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
+ g_object_unref (info);
+
+ return pixbuf;
+}
- g_object_ref (action);
+static GdkPixbuf *
+get_menu_icon_for_file (NautilusFile *file)
+{
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int size;
- nautilus_file_list_call_when_ready
- (data->selection,
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE,
- NULL,
- extension_action_slow_mime_types_ready_callback,
- callback_data);
+ size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ info = nautilus_file_get_icon (file, size, 0);
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
+ g_object_unref (info);
+
+ return pixbuf;
}
static GtkAction *
@@ -4963,8 +4408,7 @@ add_extension_action_for_files (FMDirectoryView *view,
/* TODO: This should really use themed icons, but that
doesn't work here yet */
if (icon != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size
- (icon, NULL, GTK_ICON_SIZE_MENU, NULL);
+ pixbuf = get_menu_icon (icon);
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "menu-icon",
pixbuf,
@@ -4999,126 +4443,6 @@ add_extension_action_for_files (FMDirectoryView *view,
}
static void
-warn_mismatched_mime_types_response_cb (GtkWidget *dialog,
- int response,
- gpointer user_data)
-{
- gtk_widget_destroy (dialog);
-}
-
-static void
-warn_mismatched_mime_types (FMDirectoryView *view,
- NautilusFile *file)
-{
- GtkWidget *dialog;
- char *guessed_mime_type;
- char *mime_type;
- const char *guessed_description;
- const char *real_description;
- char *primary;
- char *secondary;
- char *name;
-
- guessed_mime_type = nautilus_file_get_guessed_mime_type (file);
- mime_type = nautilus_file_get_mime_type (file);
-
- guessed_description = gnome_vfs_mime_get_description (guessed_mime_type);
- real_description = gnome_vfs_mime_get_description (mime_type);
-
- name = nautilus_file_get_name (file);
-
- primary = g_strdup_printf (_("Cannot open %s"), name);
-
- secondary = g_strdup_printf
- (_("The filename \"%s\" indicates that this file is of type \"%s\". "
- "The contents of the file indicate that the file is of type \"%s\". If "
- "you open this file, the file might present a security risk to your system.\n\n"
- "Do not open the file unless you created the file yourself, or received "
- "the file from a trusted source. To open the file, rename the file to the "
- "correct extension for \"%s\", then open the file normally. "
- "Alternatively, use the Open With menu to choose a specific application "
- "for the file. "),
- name,
- guessed_description ? guessed_description : guessed_mime_type,
- real_description ? real_description : mime_type,
- real_description ? real_description : mime_type);
-
- g_free (guessed_mime_type);
- g_free (mime_type);
-
- dialog = eel_alert_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))),
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_NONE,
- primary,
- secondary);
-
- g_free (primary);
- g_free (secondary);
- g_free (name);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_CANCEL);
-
- g_signal_connect (dialog,
- "response",
- G_CALLBACK (warn_mismatched_mime_types_response_cb),
- file);
-
- gtk_widget_show (dialog);
-}
-
-static gboolean
-can_show_default_app (FMDirectoryView *view, NautilusFile *file)
-{
- return (!nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE) || activate_check_mime_types (view, file, FALSE));
-
-}
-
-static gboolean
-activate_check_mime_types (FMDirectoryView *view,
- NautilusFile *file,
- gboolean warn_on_mismatch)
-{
- char *guessed_mime_type;
- char *mime_type;
- gboolean ret;
- GnomeVFSMimeApplication *default_app;
- GnomeVFSMimeApplication *guessed_default_app;
-
- if (!nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE)) {
- return FALSE;
- }
-
- ret = TRUE;
-
- guessed_mime_type = nautilus_file_get_guessed_mime_type (file);
- mime_type = nautilus_file_get_mime_type (file);
-
- if (gnome_vfs_mime_type_get_equivalence (mime_type, guessed_mime_type) == GNOME_VFS_MIME_UNRELATED) {
- default_app = gnome_vfs_mime_get_default_application
- (mime_type);
- guessed_default_app = gnome_vfs_mime_get_default_application
- (guessed_mime_type);
- if (default_app != NULL &&
- guessed_default_app != NULL &&
- !gnome_vfs_mime_application_equal (default_app, guessed_default_app)) {
- if (warn_on_mismatch) {
- warn_mismatched_mime_types (view, file);
- }
- ret = FALSE;
- }
- }
-
- g_free (guessed_mime_type);
- g_free (mime_type);
-
- return ret;
-}
-
-static void
add_extension_menu_items (FMDirectoryView *view,
GList *files,
GList *menu_items,
@@ -5215,26 +4539,18 @@ reset_extension_actions_menu (FMDirectoryView *view, GList *selection)
static char *
change_to_view_directory (FMDirectoryView *view)
{
- char *uri;
char *path;
char *old_path;
old_path = g_get_current_dir ();
- uri = nautilus_directory_get_uri (view->details->model);
- if (eel_uri_is_desktop (uri)) {
- g_free (uri);
- uri = nautilus_get_desktop_directory_uri ();
-
- }
- path = gnome_vfs_get_local_path_from_uri (uri);
+ path = get_view_directory (view);
/* FIXME: What to do about non-local directories? */
if (path != NULL) {
chdir (path);
}
- g_free (uri);
g_free (path);
return old_path;
@@ -5273,6 +4589,7 @@ get_file_paths_or_uris_as_newline_delimited_string (GList *selection, gboolean g
NautilusDesktopLink *link;
GString *expanding_string;
GList *node;
+ GFile *location;
expanding_string = g_string_new ("");
for (node = selection; node != NULL; node = node->next) {
@@ -5280,7 +4597,9 @@ get_file_paths_or_uris_as_newline_delimited_string (GList *selection, gboolean g
if (NAUTILUS_IS_DESKTOP_ICON_FILE (node->data)) {
link = nautilus_desktop_icon_file_get_link (NAUTILUS_DESKTOP_ICON_FILE (node->data));
if (link != NULL) {
- uri = nautilus_desktop_link_get_activation_uri (link);
+ location = nautilus_desktop_link_get_activation_location (link);
+ uri = g_file_get_uri (location);
+ g_object_unref (location);
g_object_unref (G_OBJECT (link));
}
} else {
@@ -5291,7 +4610,7 @@ get_file_paths_or_uris_as_newline_delimited_string (GList *selection, gboolean g
}
if (get_paths) {
- path = gnome_vfs_get_local_path_from_uri (uri);
+ path = g_filename_from_uri (uri, NULL, NULL);
if (path != NULL) {
g_string_append (expanding_string, path);
g_free (path);
@@ -5395,7 +4714,7 @@ run_script_callback (GtkAction *action, gpointer callback_data)
launch_parameters = (ScriptLaunchParameters *) callback_data;
file_uri = nautilus_file_get_uri (launch_parameters->file);
- local_file_path = gnome_vfs_get_local_path_from_uri (file_uri);
+ local_file_path = g_filename_from_uri (file_uri, NULL, NULL);
g_assert (local_file_path != NULL);
g_free (file_uri);
@@ -5464,8 +4783,7 @@ add_script_to_scripts_menus (FMDirectoryView *directory_view,
tip = g_strdup_printf (_("Run \"%s\" on any selected items"), name);
launch_parameters = script_launch_parameters_new (file, directory_view);
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file_with_stock_size
- (file, NULL, GTK_ICON_SIZE_MENU);
+ pixbuf = get_menu_icon_for_file (file);
action_name = escape_action_name (uri, "script_");
escaped_label = eel_str_double_underscores (name);
@@ -5538,8 +4856,7 @@ add_submenu_to_directory_menus (FMDirectoryView *directory_view,
ui_manager = nautilus_window_info_get_ui_manager (directory_view->details->window);
uri = nautilus_file_get_uri (file);
name = nautilus_file_get_display_name (file);
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file_with_stock_size
- (file, NULL, GTK_ICON_SIZE_MENU);
+ pixbuf = get_menu_icon_for_file (file);
add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, pixbuf);
add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, pixbuf);
add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, pixbuf);
@@ -5607,13 +4924,13 @@ update_directory_in_scripts_menu (FMDirectoryView *view, NautilusDirectory *dire
for (node = file_list; node != NULL; node = node->next) {
file = node->data;
- if (file_is_launchable (file)) {
+ if (nautilus_file_is_launchable (file)) {
add_script_to_scripts_menus (view, file, menu_path, popup_path, popup_bg_path);
any_scripts = TRUE;
} else if (nautilus_file_is_directory (file)) {
uri = nautilus_file_get_uri (file);
if (directory_belongs_in_scripts_menu (uri)) {
- dir = nautilus_directory_get (uri);
+ dir = nautilus_directory_get_by_uri (uri);
add_directory_to_scripts_directory_list (view, dir);
nautilus_directory_unref (dir);
@@ -5718,8 +5035,7 @@ add_template_to_templates_menus (FMDirectoryView *directory_view,
*dot = 0;
}
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file_with_stock_size
- (file, NULL, GTK_ICON_SIZE_MENU);
+ pixbuf = get_menu_icon_for_file (file);
action_name = escape_action_name (uri, "template_");
escaped_label = eel_str_double_underscores (name);
@@ -5784,7 +5100,7 @@ update_templates_directory (FMDirectoryView *view)
if (nautilus_should_use_templates_directory ()) {
templates_uri = nautilus_get_templates_directory_uri ();
- templates_directory = nautilus_directory_get (templates_uri);
+ templates_directory = nautilus_directory_get_by_uri (templates_uri);
g_free (templates_uri);
add_directory_to_templates_directory_list (view, templates_directory);
nautilus_directory_unref (templates_directory);
@@ -5870,7 +5186,7 @@ update_directory_in_templates_menu (FMDirectoryView *view,
if (nautilus_file_is_directory (file)) {
uri = nautilus_file_get_uri (file);
if (directory_belongs_in_templates_menu (templates_directory_uri, uri)) {
- dir = nautilus_directory_get (uri);
+ dir = nautilus_directory_get_by_uri (uri);
add_directory_to_templates_directory_list (view, dir);
nautilus_directory_unref (dir);
@@ -5987,12 +5303,6 @@ action_open_scripts_folder_callback (GtkAction *action,
fm_directory_view_get_containing_window (view));
}
-static void
-popup_menu_hidden (FMDirectoryView *view)
-{
- monitor_file_for_open_with (view, NULL);
-}
-
static GtkMenu *
create_popup_menu (FMDirectoryView *view, const char *popup_path)
{
@@ -6004,9 +5314,6 @@ create_popup_menu (FMDirectoryView *view, const char *popup_path)
gtk_widget_get_screen (GTK_WIDGET (view)));
gtk_widget_show (GTK_WIDGET (menu));
- g_signal_connect_object (menu, "hide",
- G_CALLBACK (popup_menu_hidden), G_OBJECT (view), G_CONNECT_SWAPPED);
-
return GTK_MENU (menu);
}
@@ -6023,6 +5330,7 @@ convert_file_list_to_string (GList *files,
GString *uris;
GList *node;
char *uri, *tmp;
+ GFile *f;
if (format_for_text) {
uris = g_string_new (NULL);
@@ -6034,7 +5342,9 @@ convert_file_list_to_string (GList *files,
uri = node->data;
if (format_for_text) {
- tmp = eel_format_uri_for_display (uri);
+ f = g_file_new_for_uri (uri);
+ tmp = g_file_get_parse_name (f);
+ g_object_unref (f);
if (tmp != NULL) {
g_string_append (uris, tmp);
@@ -6366,106 +5676,36 @@ action_rename_select_all_callback (GtkAction *action,
}
static void
-drive_mounted_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer data)
-{
- if (!succeeded) {
- if (*error == 0 &&
- detailed_error != NULL && *detailed_error == 0) {
- /* This means the mount command displays its own errors */
- return;
- }
- eel_show_error_dialog_with_details (error, NULL,
- detailed_error, NULL);
- }
-}
-
-
-static void
action_mount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
GList *selection, *l;
- GnomeVFSDrive *drive;
FMDirectoryView *view;
+ GMountOperation *mount_op;
view = FM_DIRECTORY_VIEW (data);
selection = fm_directory_view_get_selection (view);
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
-
- if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (drive != NULL) {
- gnome_vfs_drive_mount (drive, drive_mounted_callback, NULL);
- }
+
+ if (nautilus_file_can_mount (file)) {
+ mount_op = eel_mount_operation_new (fm_directory_view_get_containing_window (view));
+ nautilus_file_mount (file, mount_op,
+ NULL, NULL);
+ g_object_unref (mount_op);
}
}
nautilus_file_list_free (selection);
}
-static gboolean
-eject_for_type (GnomeVFSDeviceType type)
-{
- switch (type) {
- case GNOME_VFS_DEVICE_TYPE_CDROM:
- case GNOME_VFS_DEVICE_TYPE_ZIP:
- case GNOME_VFS_DEVICE_TYPE_JAZ:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-
-static void
-volume_or_drive_unmounted_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer data)
-{
- if (!succeeded) {
- if (*error == 0 &&
- detailed_error != NULL && *detailed_error == 0) {
- /* This means the unmount command displays its own errors */
- return;
- }
- eel_show_error_dialog_with_details (error, NULL,
- detailed_error, NULL);
- }
-}
-
-
-static void
-volume_or_drive_ejected_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer data)
-{
- if (!succeeded) {
- if (*error == 0 &&
- detailed_error != NULL && *detailed_error == 0) {
- /* This means the mount command displays its own errors */
- return;
- }
- eel_show_error_dialog_with_details (error, NULL,
- detailed_error, NULL);
- }
-}
-
-
static void
action_unmount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
GList *selection, *l;
- GnomeVFSDrive *drive;
- GnomeVFSVolume *volume;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6474,18 +5714,9 @@ action_unmount_volume_callback (GtkAction *action,
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
- if (nautilus_file_has_volume (file)) {
- volume = nautilus_file_get_volume (file);
- if (volume != NULL) {
- nautilus_file_operations_unmount_volume (GTK_WIDGET (view), volume,
- volume_or_drive_unmounted_callback, NULL);
- }
- } else if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (drive != NULL) {
- nautilus_file_operations_unmount_drive (GTK_WIDGET (view), drive,
- volume_or_drive_unmounted_callback, NULL);
- }
+ if (nautilus_file_can_unmount (file)) {
+ nautilus_file_unmount (file,
+ NULL, NULL);
}
}
nautilus_file_list_free (selection);
@@ -6495,9 +5726,9 @@ static void
action_format_volume_callback (GtkAction *action,
gpointer data)
{
+#ifdef TODO_GIO
NautilusFile *file;
GList *selection, *l;
- GnomeVFSDrive *drive;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6506,14 +5737,12 @@ action_format_volume_callback (GtkAction *action,
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
- if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY) {
- g_spawn_command_line_async ("gfloppy", NULL);
- }
+ if (something) {
+ g_spawn_command_line_async ("gfloppy", NULL);
}
}
nautilus_file_list_free (selection);
+#endif
}
static void
@@ -6522,8 +5751,6 @@ action_eject_volume_callback (GtkAction *action,
{
NautilusFile *file;
GList *selection, *l;
- GnomeVFSDrive *drive;
- GnomeVFSVolume *volume;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6532,16 +5759,8 @@ action_eject_volume_callback (GtkAction *action,
for (l = selection; l != NULL; l = l->next) {
file = NAUTILUS_FILE (l->data);
- if (nautilus_file_has_volume (file)) {
- volume = nautilus_file_get_volume (file);
- if (volume != NULL) {
- gnome_vfs_volume_eject (volume, volume_or_drive_ejected_callback, NULL);
- }
- } else if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (drive != NULL) {
- gnome_vfs_drive_eject (drive, volume_or_drive_ejected_callback, NULL);
- }
+ if (nautilus_file_can_eject (file)) {
+ nautilus_file_eject (file, NULL, NULL);
}
}
nautilus_file_list_free (selection);
@@ -6552,8 +5771,8 @@ action_self_mount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
- GnomeVFSDrive *drive;
FMDirectoryView *view;
+ GMountOperation *mount_op;
view = FM_DIRECTORY_VIEW (data);
@@ -6562,13 +5781,9 @@ action_self_mount_volume_callback (GtkAction *action,
return;
}
- file_get_volume_and_drive (file, NULL, &drive);
-
- if (drive != NULL) {
- gnome_vfs_drive_mount (drive, drive_mounted_callback, NULL);
- }
-
- gnome_vfs_drive_unref (drive);
+ mount_op = eel_mount_operation_new (fm_directory_view_get_containing_window (view));
+ nautilus_file_mount (file, mount_op, NULL, NULL);
+ g_object_unref (mount_op);
}
static void
@@ -6576,8 +5791,6 @@ action_self_unmount_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6587,18 +5800,7 @@ action_self_unmount_volume_callback (GtkAction *action,
return;
}
- file_get_volume_and_drive (file, &volume, &drive);
-
- if (volume != NULL) {
- nautilus_file_operations_unmount_volume (GTK_WIDGET (view), volume,
- volume_or_drive_unmounted_callback, NULL);
- } else if (drive != NULL) {
- nautilus_file_operations_unmount_drive (GTK_WIDGET (view), drive,
- volume_or_drive_unmounted_callback, NULL);
- }
-
- gnome_vfs_volume_unref (volume);
- gnome_vfs_drive_unref (drive);
+ nautilus_file_unmount (file, NULL, NULL);
}
static void
@@ -6606,8 +5808,6 @@ action_self_eject_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
- GnomeVFSDrive *drive;
- GnomeVFSVolume *volume;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6616,17 +5816,8 @@ action_self_eject_volume_callback (GtkAction *action,
if (file == NULL) {
return;
}
-
- file_get_volume_and_drive (file, &volume, &drive);
-
- if (volume != NULL) {
- gnome_vfs_volume_eject (volume, volume_or_drive_unmounted_callback, NULL);
- } else if (drive != NULL) {
- gnome_vfs_drive_eject (drive, volume_or_drive_unmounted_callback, NULL);
- }
-
- gnome_vfs_volume_unref (volume);
- gnome_vfs_drive_unref (drive);
+
+ nautilus_file_eject (file, NULL, NULL);
}
static void
@@ -6634,7 +5825,6 @@ action_self_format_volume_callback (GtkAction *action,
gpointer data)
{
NautilusFile *file;
- GnomeVFSDrive *drive;
FMDirectoryView *view;
view = FM_DIRECTORY_VIEW (data);
@@ -6644,14 +5834,11 @@ action_self_format_volume_callback (GtkAction *action,
return;
}
- file_get_volume_and_drive (file, NULL, &drive);
-
- if (drive != NULL &&
- gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY) {
+#ifdef TODO_GIO
+ if (something) {
g_spawn_command_line_async ("gfloppy", NULL);
}
-
- gnome_vfs_drive_unref (drive);
+#endif
}
static void
@@ -6671,7 +5858,9 @@ connect_to_server_response_callback (GtkDialog *dialog,
uri = g_object_get_data (G_OBJECT (dialog), "link-uri");
icon = g_object_get_data (G_OBJECT (dialog), "link-icon");
name = gtk_entry_get_text (entry);
+#ifdef GIO_CONVERSION_DONE
gnome_vfs_connect_to_server (uri, (char *)name, icon);
+#endif
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
case GTK_RESPONSE_NONE:
@@ -6702,7 +5891,8 @@ action_connect_to_server_link_callback (GtkAction *action,
GList *selection;
FMDirectoryView *view;
char *uri;
- char *icon;
+ NautilusIconInfo *icon;
+ const char *icon_name;
char *name;
GtkWidget *dialog;
GtkWidget *label;
@@ -6722,7 +5912,8 @@ action_connect_to_server_link_callback (GtkAction *action,
file = NAUTILUS_FILE (selection->data);
uri = nautilus_file_get_activation_uri (file);
- icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
+ icon = nautilus_file_get_icon (file, NAUTILUS_ICON_SIZE_STANDARD, 0);
+ icon_name = nautilus_icon_info_get_used_name (icon);
name = nautilus_file_get_display_name (file);
if (uri != NULL) {
@@ -6735,7 +5926,7 @@ action_connect_to_server_link_callback (GtkAction *action,
NULL);
g_object_set_data_full (G_OBJECT (dialog), "link-uri", g_strdup (uri), g_free);
- g_object_set_data_full (G_OBJECT (dialog), "link-icon", g_strdup (icon), g_free);
+ g_object_set_data_full (G_OBJECT (dialog), "link-icon", g_strdup (icon_name), g_free);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2);
@@ -6773,7 +5964,7 @@ action_connect_to_server_link_callback (GtkAction *action,
}
g_free (uri);
- g_free (icon);
+ g_object_unref (icon);
g_free (name);
}
@@ -6863,7 +6054,7 @@ action_location_trash_callback (GtkAction *action,
g_return_if_fail (file != NULL);
files = g_list_append (NULL, file);
- trash_or_delete_files (view, files);
+ trash_or_delete_files (fm_directory_view_get_containing_window (view), files, TRUE);
g_list_free (files);
}
@@ -6873,7 +6064,7 @@ action_location_delete_callback (GtkAction *action,
{
FMDirectoryView *view;
NautilusFile *file;
- char *file_uri;
+ GFile *location;
GList *files;
view = FM_DIRECTORY_VIEW (callback_data);
@@ -6881,16 +6072,13 @@ action_location_delete_callback (GtkAction *action,
file = fm_directory_view_get_directory_as_file (view);
g_return_if_fail (file != NULL);
- file_uri = nautilus_file_get_uri (file);
+ location = nautilus_file_get_location (file);
- files = g_list_append (NULL, file_uri);
- if (confirm_delete_directly (view, files)) {
- nautilus_file_operations_delete (files, GTK_WIDGET (view),
- NULL, NULL);
- }
+ files = g_list_append (NULL, location);
+ nautilus_file_operations_delete (files, fm_directory_view_get_containing_window (view),
+ NULL, NULL);
- g_free (file_uri);
- g_list_free (files);
+ eel_g_object_list_free (files);
}
static void
@@ -7152,8 +6340,7 @@ connect_proxy (FMDirectoryView *view,
if (strcmp (gtk_action_get_name (action), FM_ACTION_NEW_EMPTY_FILE) == 0 &&
GTK_IS_IMAGE_MENU_ITEM (proxy)) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size
- ("gnome-fs-regular", NULL, GTK_ICON_SIZE_MENU, NULL);
+ pixbuf = get_menu_icon ("text-x-generic");
if (pixbuf != NULL) {
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
@@ -7346,7 +6533,7 @@ file_list_all_are_folders (GList *file_list)
return FALSE;
}
- linked_file = nautilus_file_get_existing (activation_uri);
+ linked_file = nautilus_file_get_existing_by_uri (activation_uri);
/* We might not actually know the type of the linked file yet,
* however we don't want to schedule a read, since that might do things
@@ -7357,8 +6544,6 @@ file_list_all_are_folders (GList *file_list)
is_dir =
(linked_file != NULL &&
nautilus_file_is_directory (linked_file)) ||
- nautilus_file_has_volume (file) ||
- nautilus_file_has_drive (file) ||
(activation_uri != NULL &&
activation_uri[strlen (activation_uri) - 1] == '/');
@@ -7384,8 +6569,6 @@ file_should_show_foreach (NautilusFile *file,
gboolean *show_connect,
gboolean *show_format)
{
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
char *uri;
*show_mount = FALSE;
@@ -7394,26 +6577,24 @@ file_should_show_foreach (NautilusFile *file,
*show_connect = FALSE;
*show_format = FALSE;
- if (nautilus_file_has_volume (file)) {
+ if (nautilus_file_can_eject (file)) {
+ *show_eject = TRUE;
+ } else if (nautilus_file_can_unmount (file)) {
*show_unmount = TRUE;
+ }
- volume = nautilus_file_get_volume (file);
- *show_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
- } else if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- *show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
- if (gnome_vfs_drive_is_mounted (drive)) {
- *show_unmount = TRUE;
- } else {
- *show_mount = TRUE;
- }
+ if (nautilus_file_can_mount (file)) {
+ *show_unmount = TRUE;
- if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
- !gnome_vfs_drive_is_mounted (drive) &&
+#ifdef TODO_GIO
+ if (something &&
g_find_program_in_path ("gfloppy")) {
*show_format = TRUE;
}
- } else if (nautilus_file_is_nautilus_link (file)) {
+#endif
+ }
+
+ if (nautilus_file_is_nautilus_link (file)) {
uri = nautilus_file_get_activation_uri (file);
if (uri != NULL &&
(eel_istr_has_prefix (uri, "ftp:") ||
@@ -7422,70 +6603,7 @@ file_should_show_foreach (NautilusFile *file,
*show_connect = TRUE;
}
g_free (uri);
- } else if (nautilus_file_is_mime_type (file,
- "x-directory/smb-share")) {
- *show_connect = TRUE;
- }
-}
-
-static void
-file_get_volume_and_drive (NautilusFile *file,
- GnomeVFSVolume **volume,
- GnomeVFSDrive **drive)
-{
- GnomeVFSVolume *one_volume;
- GnomeVFSDrive *one_drive;
- GList *l, *list;
- char *uri, *one_uri;
-
- g_assert (file != NULL);
-
- uri = nautilus_file_get_uri (file);
- g_assert (uri != NULL);
-
- if (volume != NULL) {
- *volume = NULL;
-
- list = gnome_vfs_volume_monitor_get_mounted_volumes (gnome_vfs_get_volume_monitor ());
-
- for (l = list; l != NULL && *volume == NULL; l = l->next) {
- one_volume = l->data;
-
- one_uri = gnome_vfs_volume_get_activation_uri (one_volume);
- if (one_uri != NULL && (strcmp (uri, one_uri) == 0)) {
- *volume = gnome_vfs_volume_ref (one_volume);
- }
-
- g_free (one_uri);
- }
-
- g_list_foreach (list, (GFunc) gnome_vfs_volume_unref, NULL);
- g_list_free (list);
- }
-
- if (drive != NULL) {
- *drive = NULL;
-
- list = gnome_vfs_volume_monitor_get_connected_drives (gnome_vfs_get_volume_monitor ());
-
- for (l = list; l != NULL; l = l->next) {
- one_drive = l->data;
-
- one_uri = gnome_vfs_drive_get_activation_uri (one_drive);
- if (one_uri != NULL && (strcmp (uri, one_uri) == 0)) {
- *drive = gnome_vfs_drive_ref (one_drive);
- g_free (one_uri);
- break;
- }
-
- g_free (one_uri);
- }
-
- g_list_foreach (list, (GFunc) gnome_vfs_drive_unref, NULL);
- g_list_free (list);
- }
-
- g_free (uri);
+ }
}
static void
@@ -7495,9 +6613,6 @@ file_should_show_self (NautilusFile *file,
gboolean *show_eject,
gboolean *show_format)
{
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
-
*show_mount = FALSE;
*show_unmount = FALSE;
*show_eject = FALSE;
@@ -7506,29 +6621,22 @@ file_should_show_self (NautilusFile *file,
if (file == NULL) {
return;
}
-
- file_get_volume_and_drive (file, &volume, &drive);
-
- if (volume != NULL) {
+
+ if (nautilus_file_can_eject (file)) {
+ *show_eject = TRUE;
+ } else if (nautilus_file_can_unmount (file)) {
*show_unmount = TRUE;
- *show_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
- } else if (drive != NULL) {
- *show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
- if (gnome_vfs_drive_is_mounted (drive)) {
- *show_unmount = TRUE;
- } else {
- *show_mount = TRUE;
- }
-
- if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
- !gnome_vfs_drive_is_mounted (drive) &&
- g_find_program_in_path ("gfloppy")) {
- *show_format = TRUE;
- }
+ }
+
+ if (nautilus_file_can_mount (file)) {
+ *show_mount = TRUE;
}
- gnome_vfs_volume_unref (volume);
- gnome_vfs_drive_unref (drive);
+#ifdef TODO_GIO
+ if (something && g_find_program_in_path ("gfloppy")) {
+ *show_format = TRUE;
+ }
+#endif
}
@@ -7788,9 +6896,8 @@ real_update_menus (FMDirectoryView *view)
gboolean save_search_sensitive;
gboolean show_save_search_as;
gboolean show_open_folder_window;
- ActivationAction activation_action;
GtkAction *action;
- GnomeVFSMimeApplication *app;
+ GAppInfo *app;
selection = fm_directory_view_get_selection (view);
selection_count = g_list_length (selection);
@@ -7832,22 +6939,12 @@ real_update_menus (FMDirectoryView *view)
NautilusFile *file;
file = NAUTILUS_FILE (selection->data);
-
- activation_action = get_activation_action (file);
-
- /* Only use the default app for open if there is not
- a mime mismatch, otherwise we can't use it in the
- open with menu */
- if (activation_action == ACTIVATION_ACTION_OPEN_IN_APPLICATION &&
- !can_show_default_app (view, file)) {
- can_open = FALSE;
- }
- if (activation_action != ACTIVATION_ACTION_OPEN_IN_APPLICATION) {
+ if (!nautilus_mime_file_opens_in_external_app (file)) {
show_app = FALSE;
}
- if (!can_open && !show_app) {
+ if (!show_app) {
break;
}
}
@@ -7861,11 +6958,11 @@ real_update_menus (FMDirectoryView *view)
if (app != NULL) {
char *escaped_app;
- escaped_app = eel_str_double_underscores (app->name);
+ escaped_app = eel_str_double_underscores (g_app_info_get_name (app));
label_with_underscore = g_strdup_printf (_("_Open with \"%s\""),
escaped_app);
g_free (escaped_app);
- gnome_vfs_mime_application_free (app);
+ g_object_unref (app);
}
g_object_set (action, "label",
@@ -8212,7 +7309,6 @@ schedule_update_status (FMDirectoryView *view)
void
fm_directory_view_notify_selection_changed (FMDirectoryView *view)
{
- NautilusFile *file;
GList *selection;
GtkWindow *window;
@@ -8249,751 +7345,11 @@ fm_directory_view_notify_selection_changed (FMDirectoryView *view)
/* Schedule an update of menu item states to match selection */
schedule_update_menus (view);
-
- /* If there's exactly one item selected we sniff the slower attributes needed
- * to activate a file ahead of time to improve interactive response.
- */
-
- if (eel_g_list_exactly_one_item (selection)) {
- file = NAUTILUS_FILE (selection->data);
-
- if (nautilus_file_needs_slow_mime_type (file)) {
- nautilus_file_call_when_ready
- (file,
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE,
- NULL,
- NULL);
- }
-
- nautilus_file_call_when_ready
- (file,
- NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI,
- NULL,
- NULL);
- }
}
nautilus_file_list_free (selection);
}
-static gboolean
-file_is_launchable (NautilusFile *file)
-{
- char *mime_type;
- gboolean type_can_be_executable;
-
- mime_type = nautilus_file_get_mime_type (file);
- type_can_be_executable = gnome_vfs_mime_can_be_executable (mime_type);
- g_free (mime_type);
-
- return type_can_be_executable
- && nautilus_file_can_get_permissions (file)
- && nautilus_file_can_execute (file)
- && nautilus_file_is_executable (file)
- && !nautilus_file_is_directory (file);
-}
-
-static void
-report_broken_symbolic_link (FMDirectoryView *view, NautilusFile *file)
-{
- char *target_path;
- char *display_name;
- char *prompt;
- char *detail;
- GtkDialog *dialog;
- GList file_as_list;
- int response;
-
- g_assert (nautilus_file_is_broken_symbolic_link (file));
-
- display_name = nautilus_file_get_display_name (file);
- if (nautilus_file_is_in_trash (file)) {
- prompt = g_strdup_printf (_("The Link \"%s\" is Broken."), display_name);
- } else {
- prompt = g_strdup_printf (_("The Link \"%s\" is Broken. Move it to Trash?"), display_name);
- }
- g_free (display_name);
-
- target_path = nautilus_file_get_symbolic_link_target_path (file);
- if (target_path == NULL) {
- detail = g_strdup (_("This link can't be used, because it has no target."));
- } else {
- detail = g_strdup_printf (_("This link can't be used, because its target "
- "\"%s\" doesn't exist."), target_path);
- }
-
- if (nautilus_file_is_in_trash (file)) {
- eel_run_simple_dialog (GTK_WIDGET (view), FALSE, GTK_MESSAGE_WARNING,
- prompt, detail, GTK_STOCK_CANCEL, NULL);
- goto out;
- }
-
- dialog = eel_show_yes_no_dialog (prompt, detail, _("Mo_ve to Trash"), GTK_STOCK_CANCEL,
- fm_directory_view_get_containing_window (view));
-
- gtk_dialog_set_default_response (dialog, GTK_RESPONSE_YES);
-
- /* Make this modal to avoid problems with reffing the view & file
- * to keep them around in case the view changes, which would then
- * cause the old view not to be destroyed, which would cause its
- * merged Bonobo items not to be un-merged. Maybe we need to unmerge
- * explicitly when disconnecting views instead of relying on the
- * unmerge in Destroy. But since BonoboUIHandler is probably going
- * to change wildly, I don't want to mess with this now.
- */
-
- response = gtk_dialog_run (dialog);
- gtk_object_destroy (GTK_OBJECT (dialog));
-
- if (response == GTK_RESPONSE_YES) {
- file_as_list.data = file;
- file_as_list.next = NULL;
- file_as_list.prev = NULL;
- trash_or_delete_files (view, &file_as_list);
- }
-
-out:
- g_free (prompt);
- g_free (target_path);
- g_free (detail);
-}
-
-static void
-cancel_activate (gpointer callback_data)
-{
- ActivateParameters *parameters;
-
- parameters = (ActivateParameters *) callback_data;
-
- parameters->cancelled = TRUE;
-
- if (parameters->pending_mounts == 0) {
- nautilus_file_list_cancel_call_when_ready (parameters->files_handle);
- nautilus_file_list_free (parameters->files);
- g_free (parameters);
- }
-}
-
-
-static void
-activate_weak_notify (gpointer user_data,
- GObject *object)
-{
- eel_timed_wait_stop (cancel_activate_callback, user_data);
-
- cancel_activate (user_data);
-}
-
-static void
-cancel_activate_callback (gpointer callback_data)
-{
- ActivateParameters *parameters;
- parameters = (ActivateParameters *) callback_data;
-
- g_object_weak_unref (G_OBJECT (parameters->view),
- activate_weak_notify,
- parameters);
-
- cancel_activate (callback_data);
-}
-
-static void
-stop_activate (ActivateParameters *parameters)
-{
- eel_timed_wait_stop (cancel_activate_callback, parameters);
- g_object_weak_unref (G_OBJECT (parameters->view),
- activate_weak_notify,
- parameters);
-}
-
-static void
-list_to_parameters_foreach (GnomeVFSMimeApplication *application,
- GList *files,
- GList **ret)
-{
- ApplicationLaunchParameters *parameters;
-
- files = g_list_reverse (files);
-
- parameters = application_launch_parameters_new
- (application, files, NULL);
- *ret = g_list_prepend (*ret, parameters);
-}
-
-static unsigned int
-mime_application_hash (GnomeVFSMimeApplication *app)
-{
- return g_str_hash (app->id);
-}
-
-/**
- * fm_directory_view_make_activation_parameters
- *
- * Construct a list of ApplicationLaunchParameters from a list of NautilusFiles,
- * where files that have the same default application are put into the same
- * launch parameter, and others are put into the unhandled_files list.
- *
- * @files: Files to use for construction.
- * @unhandled_files: Files without any default application will be put here.
- *
- * Return value: Newly allocated list of ApplicationLaunchParameters.
- **/
-static GList *
-fm_directory_view_make_activation_parameters (GList *files,
- GList **unhandled_files)
-{
- GList *ret, *l, *app_files;
- NautilusFile *file;
- GnomeVFSMimeApplication *app, *old_app;
- GHashTable *app_table;
-
- ret = NULL;
- *unhandled_files = NULL;
-
- app_table = g_hash_table_new_full
- ((GHashFunc) mime_application_hash,
- (GEqualFunc) gnome_vfs_mime_application_equal,
- (GDestroyNotify) gnome_vfs_mime_application_free,
- (GDestroyNotify) g_list_free);
-
- for (l = files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- app = nautilus_mime_get_default_application_for_file (file);
- if (app != NULL) {
- app_files = NULL;
-
- if (g_hash_table_lookup_extended (app_table, app,
- (gpointer *) &old_app,
- (gpointer *) &app_files)) {
- g_hash_table_steal (app_table, old_app);
-
- app_files = g_list_prepend (app_files, file);
-
- gnome_vfs_mime_application_free (app);
- app = old_app;
- } else {
- app_files = g_list_prepend (NULL, file);
- }
-
- g_hash_table_insert (app_table, app, app_files);
- } else {
- *unhandled_files = g_list_prepend (*unhandled_files, file);
- }
- }
-
- g_hash_table_foreach (app_table,
- (GHFunc) list_to_parameters_foreach,
- &ret);
-
- g_hash_table_destroy (app_table);
-
- *unhandled_files = g_list_reverse (*unhandled_files);
-
- return g_list_reverse (ret);
-}
-
-static void
-activate_callback (GList *files, gpointer callback_data)
-{
- ActivateParameters *parameters;
- FMDirectoryView *view;
- NautilusFile *file;
- GList *launch_desktop_files;
- GList *launch_from_command_files;
- GList *launch_files;
- GList *launch_in_terminal_files;
- GList *open_in_app_files;
- GList *open_in_app_parameters;
- GList *unhandled_open_in_app_files;
- ApplicationLaunchParameters *one_parameters;
- GList *open_in_view_files;
- GList *l;
- int count;
- char *uri;
- char *executable_path, *quoted_path, *name;
- char *old_working_dir;
- ActivationAction action;
- GdkScreen *screen;
- GtkWindow *window;
-
- parameters = callback_data;
-
- view = FM_DIRECTORY_VIEW (parameters->view);
- g_object_ref (view);
-
- stop_activate (parameters);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (view));
-
- launch_desktop_files = NULL;
- launch_from_command_files = NULL;
- launch_files = NULL;
- launch_in_terminal_files = NULL;
- open_in_app_files = NULL;
- open_in_view_files = NULL;
-
- for (l = files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- if (!activate_check_mime_types (view, file, TRUE) ||
- nautilus_file_get_file_info_result (file) == GNOME_VFS_ERROR_CANCELLED) {
- continue;
- }
-
- action = get_activation_action (file);
- if (action == ACTIVATION_ACTION_ASK) {
- /* Special case for executable text files, since it might be
- * dangerous & unexpected to launch these.
- */
- action = get_executable_text_file_action (view, file);
- }
-
- switch (action) {
- case ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE :
- launch_desktop_files = g_list_prepend (launch_desktop_files, file);
- break;
- case ACTIVATION_ACTION_LAUNCH_APPLICATION_FROM_COMMAND :
- launch_from_command_files = g_list_prepend (launch_from_command_files, file);
- break;
- case ACTIVATION_ACTION_LAUNCH :
- launch_files = g_list_prepend (launch_files, file);
- break;
- case ACTIVATION_ACTION_LAUNCH_IN_TERMINAL :
- launch_in_terminal_files = g_list_prepend (launch_in_terminal_files, file);
- break;
- case ACTIVATION_ACTION_OPEN_IN_VIEW :
- open_in_view_files = g_list_prepend (open_in_view_files, file);
- break;
- case ACTIVATION_ACTION_OPEN_IN_APPLICATION :
- open_in_app_files = g_list_prepend (open_in_app_files, file);
- break;
- case ACTIVATION_ACTION_DO_NOTHING :
- break;
- case ACTIVATION_ACTION_ASK :
- g_assert_not_reached ();
- break;
- }
- }
-
- window = fm_directory_view_get_containing_window (parameters->view);
-
- launch_desktop_files = g_list_reverse (launch_desktop_files);
- for (l = launch_desktop_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_uri (file);
-
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "directory view activate_callback launch_desktop_file window=%p: %s",
- window, uri);
-
- nautilus_launch_desktop_file (
- screen, uri, NULL,
- fm_directory_view_get_containing_window (view));
- g_free (uri);
- }
-
- launch_from_command_files = g_list_reverse (launch_from_command_files);
- for (l = launch_from_command_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_activation_uri (file);
-
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "directory view activate_callback launch_application_from_command window=%p: %s",
- window, uri);
-
- nautilus_launch_application_from_command (
- screen, NULL, uri + strlen (NAUTILUS_COMMAND_SPECIFIER),
- NULL, FALSE);
- g_free (uri);
- }
-
- old_working_dir = NULL;
- if (launch_files != NULL || launch_in_terminal_files != NULL) {
- old_working_dir = change_to_view_directory (view);
- }
-
- launch_files = g_list_reverse (launch_files);
- for (l = launch_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_activation_uri (file);
- executable_path = gnome_vfs_get_local_path_from_uri (uri);
- quoted_path = g_shell_quote (executable_path);
- name = nautilus_file_get_name (file);
-
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "directory view activate_callback launch_file window=%p: %s",
- window, quoted_path);
-
- nautilus_launch_application_from_command (screen, name, quoted_path, NULL, FALSE);
- g_free (name);
- g_free (quoted_path);
- g_free (executable_path);
- g_free (uri);
-
- }
-
- launch_in_terminal_files = g_list_reverse (launch_in_terminal_files);
- for (l = launch_in_terminal_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_activation_uri (file);
- executable_path = gnome_vfs_get_local_path_from_uri (uri);
- quoted_path = g_shell_quote (executable_path);
- name = nautilus_file_get_name (file);
-
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "directory view activate_callback launch_in_terminal window=%p: %s",
- window, quoted_path);
-
- nautilus_launch_application_from_command (screen, name, quoted_path, NULL, TRUE);
- g_free (name);
- g_free (quoted_path);
- g_free (executable_path);
- g_free (uri);
- }
-
- if (old_working_dir != NULL) {
- chdir (old_working_dir);
- g_free (old_working_dir);
- }
-
- open_in_view_files = g_list_reverse (open_in_view_files);
- count = g_list_length (open_in_view_files);
- if (fm_directory_view_confirm_multiple_windows (view, count)) {
- NautilusWindowOpenFlags flags;
-
- flags = parameters->flags;
- if (count > 1) {
- flags |= NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
- }
-
- for (l = open_in_view_files; l != NULL; l = l->next) {
- /* The ui should ask for navigation or object windows
- * depending on what the current one is */
- file = NAUTILUS_FILE (l->data);
-
- uri = nautilus_file_get_activation_uri (file);
- open_location (view, uri, parameters->mode, flags);
- g_free (uri);
- }
- }
-
- open_in_app_parameters = NULL;
- unhandled_open_in_app_files = NULL;
-
- if (open_in_app_files != NULL) {
- open_in_app_files = g_list_reverse (open_in_app_files);
-
- open_in_app_parameters = fm_directory_view_make_activation_parameters
- (open_in_app_files, &unhandled_open_in_app_files);
- }
-
- for (l = open_in_app_parameters; l != NULL; l = l->next) {
- one_parameters = l->data;
-
- fm_directory_view_launch_application (
- one_parameters->application,
- one_parameters->files,
- view);
- application_launch_parameters_free (one_parameters);
- }
-
- for (l = unhandled_open_in_app_files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- nautilus_launch_show_file
- (file, fm_directory_view_get_containing_window (view));
-
- /* We should not add trash and directory uris.*/
- if ((!nautilus_file_is_in_trash (file)) &&
- (!nautilus_file_is_directory (file))) {
- nautilus_recent_add_file (file, NULL);
- }
- }
-
- if (open_in_app_parameters != NULL ||
- unhandled_open_in_app_files != NULL) {
- if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0 &&
- nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_SPATIAL) {
- nautilus_window_info_close (view->details->window);
- }
- }
-
- g_object_unref (view);
-
- g_list_free (launch_desktop_files);
- g_list_free (launch_from_command_files);
- g_list_free (launch_files);
- g_list_free (launch_in_terminal_files);
- g_list_free (open_in_view_files);
- g_list_free (open_in_app_files);
- g_list_free (open_in_app_parameters);
- g_list_free (unhandled_open_in_app_files);
-
- nautilus_file_list_free (parameters->files);
- g_free (parameters);
-}
-
-static void
-activation_drive_mounted_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer callback_data)
-{
- ActivateParameters *parameters;
-
- parameters = callback_data;
-
- parameters->mount_success &= succeeded;
-
- if (!succeeded && !parameters->cancelled) {
- if (*error == 0 &&
- detailed_error != NULL && *detailed_error == 0) {
- /* This means the mount command displays its own errors */
- } else {
- eel_show_error_dialog_with_details (error, NULL,
- detailed_error,
- NULL);
- }
- }
-
- if (--parameters->pending_mounts > 0) {
- /* wait for other mounts to finish... */
- return;
- }
-
- if (parameters->cancelled || !parameters->mount_success) {
- stop_activate (parameters);
-
- nautilus_file_list_free (parameters->files);
- g_free (parameters);
- return;
- }
-
- /* all drives were mounted successfully */
- activate_activation_uris_ready_callback (parameters->files,
- parameters);
-}
-
-static void
-mount_foreach (gpointer drive,
- gpointer callback_data)
-{
- gnome_vfs_drive_mount (drive, activation_drive_mounted_callback, callback_data);
-}
-
-static void
-activate_activation_uris_ready_callback (GList *files_ignore,
- gpointer callback_data)
-{
- ActivateParameters *parameters;
- GList *not_yet_mounted;
- GList *l, *next;
- NautilusFile *file;
- NautilusFile *actual_file;
- NautilusFileAttributes attributes;
- GnomeVFSDrive *drive;
- char *uri;
-
- parameters = callback_data;
- not_yet_mounted = NULL;
-
- for (l = parameters->files; l != NULL; l = next) {
- file = NAUTILUS_FILE (l->data);
- next = l->next;
-
- if (nautilus_file_get_file_info_result (file) == GNOME_VFS_ERROR_CANCELLED) {
- nautilus_file_unref (file);
- parameters->files = g_list_delete_link (parameters->files, l);
- continue;
- }
-
- if (nautilus_file_is_broken_symbolic_link (file)) {
- nautilus_file_unref (file);
- parameters->files = g_list_delete_link (parameters->files, l);
- report_broken_symbolic_link (parameters->view, file);
- continue;
- }
-
- if (!parameters->mount_success && nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (drive != NULL &&
- !gnome_vfs_drive_is_mounted (drive)) {
- not_yet_mounted = g_list_prepend (not_yet_mounted, drive);
- parameters->pending_mounts++;
- }
- }
- }
-
- if (parameters->files == NULL) {
- g_assert (not_yet_mounted == NULL);
-
- stop_activate (parameters);
- g_free (parameters);
- return;
- }
-
- if (not_yet_mounted != NULL) {
- not_yet_mounted = g_list_reverse (not_yet_mounted);
- g_list_foreach (not_yet_mounted, mount_foreach, callback_data);
- g_list_free (not_yet_mounted);
-
- /* activation_drive_mounted_callback will reveal whether all mounts were successful */
- parameters->mount_success = TRUE;
- return;
- }
-
- for (l = parameters->files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- /* We want the file for the activation URI since we care
- * about the attributes for that, not for the original file.
- */
- actual_file = NULL;
- uri = nautilus_file_get_activation_uri (file);
- if (!(eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER) ||
- eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER))) {
- actual_file = nautilus_file_get (uri);
- }
- g_free (uri);
-
- if (actual_file != NULL) {
- nautilus_file_unref (file);
- l->data = actual_file;
- }
- }
-
- /* get the parameters for the actual file */
- attributes = nautilus_mime_actions_get_minimum_file_attributes () |
- NAUTILUS_FILE_ATTRIBUTE_FILE_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI;
-
- nautilus_file_list_call_when_ready
- (parameters->files, attributes,
- &parameters->files_handle,
- activate_callback, parameters);
-}
-
-/**
- * fm_directory_view_activate_file:
- *
- * Activate a file in this view. This might involve switching the displayed
- * location for the current window, or launching an application.
- * @view: FMDirectoryView in question.
- * @file: A NautilusFile representing the file in this view to activate.
- * @use_new_window: Should this item be opened in a new window?
- *
- **/
-static void
-fm_directory_view_activate_file (FMDirectoryView *view,
- NautilusFile *file,
- NautilusWindowOpenMode mode,
- NautilusWindowOpenFlags flags)
-{
- GList *files;
-
- g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
- g_return_if_fail (NAUTILUS_IS_FILE (file));
-
- files = g_list_prepend (NULL, file);
- fm_directory_view_activate_files (view, files, mode, flags);
- g_list_free (files);
-}
-
-
-/**
- * fm_directory_view_activate_files:
- *
- * Activate a list of files. Each one might launch with an application or
- * with a component. This is normally called only by subclasses.
- * @view: FMDirectoryView in question.
- * @files: A GList of NautilusFiles to activate.
- *
- **/
-void
-fm_directory_view_activate_files (FMDirectoryView *view,
- GList *files,
- NautilusWindowOpenMode mode,
- NautilusWindowOpenFlags flags)
-{
-
- GList *l;
- ActivateParameters *parameters;
- NautilusFile *file;
- NautilusFileAttributes attributes;
- char *file_name;
- char *timed_wait_prompt;
- int file_count;
- GtkWindow *window;
-
- g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
-
- if (files == NULL) {
- return;
- }
-
- window = fm_directory_view_get_containing_window (view);
- nautilus_debug_log_with_file_list (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER, files,
- "fm_directory_view_activate_files window=%p",
- window);
-
- file_count = g_list_length (files);
-
- /* link target info might be stale, re-read it */
- for (l = files; l != NULL; l = l->next) {
- file = NAUTILUS_FILE (l->data);
-
- if (nautilus_file_is_symbolic_link (file)) {
- nautilus_file_invalidate_attributes
- (file, NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI);
- }
- }
-
- /* Might have to read some of the file to activate it. */
- attributes = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI |
- NAUTILUS_FILE_ATTRIBUTE_VOLUMES;
-
- parameters = g_new (ActivateParameters, 1);
- parameters->view = view;
- parameters->files = nautilus_file_list_copy (files);
- parameters->mode = mode;
- parameters->flags = flags;
- parameters->mount_success = FALSE;
- parameters->pending_mounts = 0;
- parameters->cancelled = FALSE;
-
- if (file_count == 1) {
- file_name = nautilus_file_get_display_name (files->data);
- timed_wait_prompt = g_strdup_printf (_("Opening \"%s\"."), file_name);
- g_free (file_name);
- } else {
- timed_wait_prompt = g_strdup_printf (ngettext ("Opening %d item.",
- "Opening %d items.",
- file_count),
- file_count);
- }
-
- eel_timed_wait_start_with_duration
- (DELAY_UNTIL_CANCEL_MSECS,
- cancel_activate_callback,
- parameters,
- timed_wait_prompt,
- fm_directory_view_get_containing_window (view));
- g_free (timed_wait_prompt);
-
- g_object_weak_ref (G_OBJECT (view), activate_weak_notify, parameters);
-
- nautilus_file_list_call_when_ready
- (parameters->files, attributes,
- &parameters->files_handle,
- activate_activation_uris_ready_callback, parameters);
-}
-
static void
file_changed_callback (NautilusFile *file, gpointer callback_data)
{
@@ -9080,7 +7436,7 @@ load_directory (FMDirectoryView *view,
/* If capabilities change, then we need to update the menus
* because of New Folder, and relative emblems.
*/
- attributes = NAUTILUS_FILE_ATTRIBUTE_CAPABILITIES;
+ attributes = NAUTILUS_FILE_ATTRIBUTE_INFO;
nautilus_file_monitor_add (view->details->directory_as_file,
&view->details->directory_as_file,
attributes);
@@ -9130,11 +7486,12 @@ finish_loading (FMDirectoryView *view)
* attribute is based on that, and the file's metadata
* and possible custom name.
*/
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+ NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME |
NAUTILUS_FILE_ATTRIBUTE_EXTENSION_INFO;
nautilus_directory_file_monitor_add (view->details->model,
@@ -9196,7 +7553,7 @@ metadata_for_files_in_directory_ready_callback (NautilusDirectory *directory,
finish_loading_if_all_metadata_loaded (view);
}
-EelStringList *
+char **
fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view)
{
g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL);
@@ -9206,28 +7563,26 @@ fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view)
get_emblem_names_to_exclude, (view));
}
-static void
-fm_directory_view_add_relative_emblems_to_exclude (FMDirectoryView *view,
- EelStringList *list)
-{
- if (!nautilus_file_can_write (view->details->directory_as_file)) {
- eel_string_list_prepend (list, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE);
- eel_string_list_remove_duplicates (list);
- }
-}
-
-static EelStringList *
+static char **
real_get_emblem_names_to_exclude (FMDirectoryView *view)
{
- EelStringList *list;
+ char **excludes;
+ int i;
g_assert (FM_IS_DIRECTORY_VIEW (view));
- list = eel_string_list_new_from_string (NAUTILUS_FILE_EMBLEM_NAME_TRASH, TRUE);
+ excludes = g_new (char *, 3);
+
+ i = 0;
+ excludes[i++] = g_strdup (NAUTILUS_FILE_EMBLEM_NAME_TRASH);
+
+ if (!nautilus_file_can_write (view->details->directory_as_file)) {
+ excludes[i++] = g_strdup (NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE);
+ }
- fm_directory_view_add_relative_emblems_to_exclude (view, list);
+ excludes[i++] = NULL;
- return list;
+ return excludes;
}
/**
@@ -9744,14 +8099,10 @@ fm_directory_view_move_copy_items (const GList *item_uris,
return;
}
- if (eel_uri_is_trash (target_uri) && copy_action == GDK_ACTION_MOVE) {
- trash_or_delete_files_common (view, item_uris, relative_item_points, FALSE);
- } else {
- nautilus_file_operations_copy_move
- (item_uris, relative_item_points,
- target_uri, copy_action, GTK_WIDGET (view),
- copy_move_done_callback, pre_copy_move (view));
- }
+ nautilus_file_operations_copy_move
+ (item_uris, relative_item_points,
+ target_uri, copy_action, GTK_WIDGET (view),
+ copy_move_done_callback, pre_copy_move (view));
}
gboolean
@@ -9801,38 +8152,6 @@ fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view)
}
static void
-monitor_file_for_open_with (FMDirectoryView *view, NautilusFile *file)
-{
- NautilusFile **file_spot;
- NautilusFile *old_file;
- NautilusFileAttributes attributes;
-
- /* Quick out when not changing. */
- file_spot = &view->details->file_monitored_for_open_with;
- old_file = *file_spot;
- if (old_file == file) {
- return;
- }
-
- /* Point at the new file. */
- nautilus_file_ref (file);
- *file_spot = file;
-
- /* Stop monitoring the old file. */
- if (old_file != NULL) {
- nautilus_file_monitor_remove (old_file, file_spot);
- nautilus_file_unref (old_file);
- }
-
- /* Start monitoring the new file. */
- if (file != NULL) {
- attributes = nautilus_mime_actions_get_full_file_attributes ();
- nautilus_file_monitor_add (file, file_spot, attributes);
- }
-}
-
-
-static void
revert_slashes (char *string)
{
while (*string != 0) {
@@ -9921,9 +8240,8 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
char *container_uri;
GArray *points;
char **bits;
- GnomeVFSResult result;
- GnomeVFSFileInfo *file_info;
GList *uri_list = NULL;
+ GFile *f;
if (encoded_url == NULL) {
return;
@@ -9935,14 +8253,16 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
g_assert (container_uri != NULL);
}
- if (eel_vfs_has_capability (target_uri != NULL ? target_uri : container_uri,
- EEL_VFS_CAPABILITY_IS_REMOTE_AND_SLOW)) {
+ f = g_file_new_for_uri (target_uri != NULL ? target_uri : container_uri);
+ if (!g_file_is_native (f)) {
eel_show_warning_dialog (_("Drag and drop is not supported."),
_("Drag and drop is only supported on local file systems."),
fm_directory_view_get_containing_window (view));
+ g_object_unref (f);
g_free (container_uri);
return;
}
+ g_object_unref (f);
/* _NETSCAPE_URL_ works like this: $URL\n$TITLE */
bits = g_strsplit (encoded_url, "\n", 0);
@@ -9961,22 +8281,33 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
}
if (action == GDK_ACTION_ASK) {
- file_info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info (url, file_info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
-
- if ( eel_strcasecmp (file_info->mime_type, "text/html") == 0 ||
- eel_strcasecmp (file_info->mime_type, "text/xml") == 0 ||
- eel_strcasecmp (file_info->mime_type, "application/xhtml+xml") == 0) {
+ GFileInfo *info;
+ GFile *f;
+ const char *mime_type;
+
+ f = g_file_new_for_uri (url);
+ info = g_file_query_info (f, G_FILE_ATTRIBUTE_STD_CONTENT_TYPE, 0, NULL, NULL);
+ mime_type = NULL;
+
+ if (info) {
+ mime_type = g_file_info_get_content_type (info);
+ }
+
+ if (mime_type != NULL &&
+ (g_content_type_equals (mime_type, "text/html") ||
+ g_content_type_equals (mime_type, "text/xml") ||
+ g_content_type_equals (mime_type, "application/xhtml+xml"))) {
action = GDK_ACTION_LINK;
- } else if (eel_strcasecmp (file_info->mime_type, "text/plain") == 0) {
+ } else if (mime_type != NULL &&
+ g_content_type_equals (mime_type, "text/plain")) {
action = ask_link_action (view);
} else {
action = GDK_ACTION_COPY;
}
- gnome_vfs_file_info_unref (file_info);
-
+ if (info) {
+ g_object_unref (info);
+ }
+
if (action == 0) {
g_free (container_uri);
return;
@@ -9998,7 +8329,11 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
if (action == GDK_ACTION_LINK) {
if (eel_str_is_empty (title)) {
- link_name = eel_uri_get_basename (url);
+ GFile *f;
+
+ f = g_file_new_for_uri (url);
+ link_name = g_file_get_basename (f);
+ g_object_unref (f);
} else {
link_name = g_strdup (title);
}
@@ -10097,22 +8432,13 @@ fm_directory_view_handle_uri_list_drop (FMDirectoryView *view,
return;
}
- /* Most of what comes in here is not really URIs, but rather paths that
- * have a file: prefix in them. We try to sanitize the uri list as a
- * result.
- */
n_uris = 0;
uri_list = g_uri_list_extract_uris (item_uris);
for (i = 0; uri_list[i] != NULL; i++) {
- char *sanitized_uri;
-
- sanitized_uri = eel_make_uri_from_half_baked_uri (uri_list[i]);
- if (sanitized_uri != NULL) {
- n_uris++;
- real_uri_list = g_list_append (real_uri_list, sanitized_uri);
- }
+ real_uri_list = g_list_append (real_uri_list, uri_list[i]);
+ n_uris++;
}
- g_strfreev (uri_list);
+ g_free (uri_list);
/* do nothing if no real uris are left */
if (n_uris == 0) {
@@ -10326,8 +8652,8 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass)
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (FMDirectoryViewClass, load_error),
NULL, NULL,
- nautilus_marshal_VOID__INT_STRING,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING);
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
signals[REMOVE_FILE] =
g_signal_new ("remove_file",
G_TYPE_FROM_CLASS (klass),
diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h
index 385586f56..b0d8932ff 100644
--- a/src/file-manager/fm-directory-view.h
+++ b/src/file-manager/fm-directory-view.h
@@ -40,6 +40,7 @@
#include <eel/eel-string-list.h>
#include <libnautilus-private/nautilus-view.h>
#include <libnautilus-private/nautilus-window-info.h>
+#include <gio/gappinfo.h>
typedef struct FMDirectoryView FMDirectoryView;
typedef struct FMDirectoryViewClass FMDirectoryViewClass;
@@ -121,8 +122,7 @@ struct FMDirectoryViewClass {
* load failures like ACCESS_DENIED.
*/
void (* load_error) (FMDirectoryView *view,
- GnomeVFSResult result,
- const char *error_message);
+ GError *error);
/* Function pointers that don't have corresponding signals */
@@ -226,7 +226,7 @@ struct FMDirectoryViewClass {
* be displayed with each file. By default, all emblems returned by
* NautilusFile are displayed.
*/
- EelStringList * (* get_emblem_names_to_exclude) (FMDirectoryView *view);
+ char ** (* get_emblem_names_to_exclude) (FMDirectoryView *view);
/* file_limit_reached is a function pointer that subclasses may
* override to control what happens when a directory is loaded
@@ -373,19 +373,23 @@ gboolean fm_directory_view_get_loading (FMDirect
/* Hooks for subclasses to call. These are normally called only by
* FMDirectoryView and its subclasses
*/
-void fm_directory_view_activate_files (FMDirectoryView *view,
- GList *files,
- NautilusWindowOpenMode mode,
+void fm_directory_view_activate_files (FMDirectoryView *view,
+ GList *files,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags);
+void fm_directory_view_activate_file (FMDirectoryView *view,
+ NautilusFile *file,
+ NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags);
void fm_directory_view_start_batching_selection_changes (FMDirectoryView *view);
void fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view);
-gboolean fm_directory_view_confirm_multiple_windows (FMDirectoryView *view,
+gboolean fm_directory_view_confirm_multiple_windows (GtkWindow *parent_window,
int window_count);
void fm_directory_view_queue_file_change (FMDirectoryView *view,
NautilusFile *file);
void fm_directory_view_notify_selection_changed (FMDirectoryView *view);
GtkUIManager * fm_directory_view_get_ui_manager (FMDirectoryView *view);
-EelStringList * fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view);
+char ** fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view);
NautilusDirectory *fm_directory_view_get_model (FMDirectoryView *view);
GtkWindow *fm_directory_view_get_containing_window (FMDirectoryView *view);
NautilusFile *fm_directory_view_get_directory_as_file (FMDirectoryView *view);
diff --git a/src/file-manager/fm-ditem-page.c b/src/file-manager/fm-ditem-page.c
index 23a615e25..fdb2e04f8 100644
--- a/src/file-manager/fm-ditem-page.c
+++ b/src/file-manager/fm-ditem-page.c
@@ -44,8 +44,6 @@
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libgnome/gnome-desktop-item.h>
-#include <eel/eel-vfs-extensions.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
static void fm_ditem_page_instance_init (FMDitemPage *provider);
static void fm_ditem_page_class_init (FMDitemPageClass *class);
@@ -110,7 +108,7 @@ fm_ditem_page_url_drag_data_received (GtkWidget *widget, GdkDragContext *context
return;
}
- path = gnome_vfs_get_local_path_from_uri (uris[0]);
+ path = g_filename_from_uri (uris[0], NULL, NULL);
if (path != NULL) {
gtk_entry_set_text (entry, path);
g_free (path);
@@ -122,41 +120,6 @@ fm_ditem_page_url_drag_data_received (GtkWidget *widget, GdkDragContext *context
}
static void
-mime_type_ready_cb (NautilusFile *file,
- gpointer user_data)
-{
- GnomeDesktopItem *item;
- GtkEntry *entry;
- char *uri;
- const char *exec;
-
- entry = GTK_ENTRY (user_data);
- uri = nautilus_file_get_uri (file);
-
- if (nautilus_file_is_mime_type (file, "application/x-desktop")) {
- item = gnome_desktop_item_new_from_uri (uri,
- GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
- NULL);
- if (item != NULL &&
- gnome_desktop_item_get_entry_type (item) == GNOME_DESKTOP_ITEM_TYPE_APPLICATION) {
-
- exec = gnome_desktop_item_get_string (item, GNOME_DESKTOP_ITEM_EXEC);
- gtk_entry_set_text (entry,
- exec?exec:"");
- gnome_desktop_item_unref (item);
-
- gtk_widget_grab_focus (GTK_WIDGET (entry));
- }
- } else {
- gtk_entry_set_text (entry,
- uri?uri:"");
- }
-
- g_free (uri);
- nautilus_file_unref (file);
-}
-
-static void
fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *context,
int x, int y,
GtkSelectionData *selection_data,
@@ -166,6 +129,9 @@ fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *contex
char **uris;
gboolean exactly_one;
NautilusFile *file;
+ GnomeDesktopItem *item;
+ char *uri;
+ const char *exec;
uris = g_strsplit (selection_data->data, "\r\n", 0);
exactly_one = uris[0] != NULL && (uris[1] == NULL || uris[1][0] == '\0');
@@ -175,13 +141,33 @@ fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *contex
return;
}
- file = nautilus_file_get (uris[0]);
+ file = nautilus_file_get_by_uri (uris[0]);
g_return_if_fail (file != NULL);
- nautilus_file_call_when_ready (file,
- NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE,
- mime_type_ready_cb, entry);
+ uri = nautilus_file_get_uri (file);
+ if (nautilus_file_is_mime_type (file, "application/x-desktop")) {
+ item = gnome_desktop_item_new_from_uri (uri,
+ GNOME_DESKTOP_ITEM_LOAD_ONLY_IF_EXISTS,
+ NULL);
+ if (item != NULL &&
+ gnome_desktop_item_get_entry_type (item) == GNOME_DESKTOP_ITEM_TYPE_APPLICATION) {
+
+ exec = gnome_desktop_item_get_string (item, GNOME_DESKTOP_ITEM_EXEC);
+ gtk_entry_set_text (entry,
+ exec?exec:"");
+ gnome_desktop_item_unref (item);
+
+ gtk_widget_grab_focus (GTK_WIDGET (entry));
+ }
+ } else {
+ gtk_entry_set_text (entry,
+ uri?uri:"");
+ }
+
+ g_free (uri);
+
+ nautilus_file_unref (file);
g_strfreev (uris);
}
@@ -372,30 +358,38 @@ create_page (GnomeDesktopItem *item, GtkWidget *box)
static void
-ditem_read_cb (GnomeVFSResult result,
- GnomeVFSFileSize file_size,
- char *file_contents,
+ditem_read_cb (GObject *source_object,
+ GAsyncResult *res,
gpointer user_data)
{
GnomeDesktopItem *item;
GtkWidget *box;
+ gsize file_size;
+ char *file_contents;
box = GTK_WIDGET (user_data);
- item = gnome_desktop_item_new_from_string (g_object_get_data (G_OBJECT (box),
- "uri"),
- file_contents,
- file_size,
- 0, NULL);
-
- if (item == NULL) {
- return;
+
+ if (g_file_load_contents_finish (G_FILE (source_object),
+ res,
+ &file_contents, &file_size,
+ NULL, NULL)) {
+ item = gnome_desktop_item_new_from_string (g_object_get_data (G_OBJECT (box),
+ "uri"),
+ file_contents,
+ file_size,
+ 0, NULL);
+ g_free (file_contents);
+ if (item == NULL) {
+ return;
+ }
+
+ /* for some reason, this isn't done automatically */
+ gnome_desktop_item_set_location (item, g_object_get_data (G_OBJECT (box), "uri"));
+
+ create_page (item, box);
+ gnome_desktop_item_unref (item);
}
-
- /* for some reason, this isn't done automatically */
- gnome_desktop_item_set_location (item, g_object_get_data (G_OBJECT (box), "uri"));
-
- create_page (item, box);
- gnome_desktop_item_unref (item);
+ g_object_unref (box);
}
static void
@@ -403,8 +397,12 @@ fm_ditem_page_create_begin (FMDitemPage *page,
const char *uri,
GtkWidget *box)
{
+ GFile *location;
+
+ location = g_file_new_for_uri (uri);
g_object_set_data_full (G_OBJECT (box), "uri", g_strdup (uri), g_free);
- eel_read_entire_file_async (uri, 0, ditem_read_cb, box);
+ g_file_load_contents_async (location, NULL, ditem_read_cb, g_object_ref (box));
+ g_object_unref (location);
}
static GList *
diff --git a/src/file-manager/fm-empty-view.c b/src/file-manager/fm-empty-view.c
index 0258a1a18..a28b289c0 100644
--- a/src/file-manager/fm-empty-view.c
+++ b/src/file-manager/fm-empty-view.c
@@ -61,7 +61,7 @@ fm_empty_view_add_file (FMDirectoryView *view, NautilusFile *file, NautilusDirec
if (!timer) timer = g_timer_new ();
g_timer_start (timer);
- icon = nautilus_icon_factory_get_pixbuf_for_file (file, NULL, nautilus_get_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_STANDARD), TRUE);
+ icon = nautilus_file_get_icon_pixbuf (file, nautilus_get_icon_size_for_zoom_level (NAUTILUS_ZOOM_LEVEL_STANDARD), TRUE, 0);
elaps = g_timer_elapsed (timer, NULL);
g_timer_stop (timer);
@@ -357,10 +357,10 @@ fm_empty_view_create (NautilusWindowInfo *window)
static gboolean
fm_empty_view_supports_uri (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type)
{
- if (file_type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (file_type == G_FILE_TYPE_DIRECTORY) {
return TRUE;
}
if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){
diff --git a/src/file-manager/fm-error-reporting.c b/src/file-manager/fm-error-reporting.c
index ab8051f8f..461717ffb 100644
--- a/src/file-manager/fm-error-reporting.c
+++ b/src/file-manager/fm-error-reporting.c
@@ -28,7 +28,6 @@
#include <string.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-result.h>
#include <libnautilus-private/nautilus-debug-log.h>
#include <libnautilus-private/nautilus-file.h>
#include <eel/eel-string.h>
@@ -37,41 +36,39 @@
#define NEW_NAME_TAG "Nautilus: new name"
#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH 50
-static void finish_rename (NautilusFile *file, gboolean stop_timer, GnomeVFSResult result);
+static void finish_rename (NautilusFile *file, gboolean stop_timer, GError *error);
void
fm_report_error_loading_directory (NautilusFile *file,
- GnomeVFSResult error,
- const char *error_message,
+ GError *error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
- if (error_message == NULL && error == GNOME_VFS_OK) {
+ if (error == NULL ||
+ error->message == NULL) {
return;
}
file_name = nautilus_file_get_display_name (file);
-
- if (!error_message) {
- switch (error) {
- case GNOME_VFS_ERROR_ACCESS_DENIED:
+
+ if (error->domain == G_IO_ERROR) {
+ switch (error->code) {
+ case G_IO_ERROR_PERMISSION_DENIED:
message = g_strdup_printf (_("You do not have the permissions necessary to view the contents of \"%s\"."),
file_name);
break;
- case GNOME_VFS_ERROR_NOT_FOUND:
+ case G_IO_ERROR_NOT_FOUND:
message = g_strdup_printf (_("\"%s\" couldn't be found. Perhaps it has recently been deleted."),
file_name);
break;
default:
- /* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d (%s) in fm_report_error_loading_directory",
- error, gnome_vfs_result_to_string (error));
- message = g_strdup_printf (_("Sorry, couldn't display all the contents of \"%s\"."), file_name);
+ message = g_strdup_printf (_("Sorry, couldn't display all the contents of \"%s\". %s"), file_name,
+ error->message);
}
} else {
- message = g_strdup (error_message);
+ message = g_strdup (error->message);
}
eel_show_error_dialog (_("The folder contents could not be displayed."), message, parent_window);
@@ -83,17 +80,13 @@ fm_report_error_loading_directory (NautilusFile *file,
void
fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
- GnomeVFSResult error,
+ GError *error,
GtkWindow *parent_window)
{
char *original_name, *original_name_truncated;
char *new_name_truncated;
char *message;
- if (error == GNOME_VFS_OK) {
- return;
- }
-
/* Truncate names for display since very long file names with no spaces
* in them won't get wrapped, and can create insanely wide dialog boxes.
*/
@@ -102,47 +95,50 @@ fm_report_error_renaming_file (NautilusFile *file,
g_free (original_name);
new_name_truncated = eel_str_middle_truncate (new_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
-
- switch (error) {
- case GNOME_VFS_ERROR_FILE_EXISTS:
- message = g_strdup_printf (_("The name \"%s\" is already used in this folder. "
- "Please use a different name."),
- new_name_truncated);
- break;
- case GNOME_VFS_ERROR_NOT_FOUND:
- message = g_strdup_printf (_("There is no \"%s\" in this folder. "
- "Perhaps it was just moved or deleted?"),
- original_name_truncated);
- break;
- case GNOME_VFS_ERROR_ACCESS_DENIED:
- message = g_strdup_printf (_("You do not have the permissions necessary to rename \"%s\"."),
- original_name_truncated);
- break;
- case GNOME_VFS_ERROR_NOT_PERMITTED:
- if (strchr (new_name, '/') != NULL) {
- message = g_strdup_printf (_("The name \"%s\" is not valid because it contains the character \"/\". "
- "Please use a different name."),
- new_name_truncated);
- } else {
- message = g_strdup_printf (_("The name \"%s\" is not valid. "
- "Please use a different name."),
+
+ message = NULL;
+ if (error->domain == G_IO_ERROR) {
+ switch (error->code) {
+ case G_IO_ERROR_EXISTS:
+ message = g_strdup_printf (_("The name \"%s\" is already used in this folder. "
+ "Please use a different name."),
new_name_truncated);
+ break;
+ case G_IO_ERROR_NOT_FOUND:
+ message = g_strdup_printf (_("There is no \"%s\" in this folder. "
+ "Perhaps it was just moved or deleted?"),
+ original_name_truncated);
+ break;
+ case G_IO_ERROR_PERMISSION_DENIED:
+ message = g_strdup_printf (_("You do not have the permissions necessary to rename \"%s\"."),
+ original_name_truncated);
+ break;
+ case G_IO_ERROR_INVALID_FILENAME:
+ if (strchr (new_name, '/') != NULL) {
+ message = g_strdup_printf (_("The name \"%s\" is not valid because it contains the character \"/\". "
+ "Please use a different name."),
+ new_name_truncated);
+ } else {
+ message = g_strdup_printf (_("The name \"%s\" is not valid. "
+ "Please use a different name."),
+ new_name_truncated);
+ }
+ break;
+ default:
+ break;
}
- break;
- case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM:
- message = g_strdup_printf (_("Couldn't change the name of \"%s\" because it is on a read-only disk"),
- original_name_truncated);
- break;
- default:
+ }
+
+ if (message == NULL) {
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d (%s) in fm_report_error_renaming_file",
- error, gnome_vfs_result_to_string (error));
+ g_warning ("Hit unhandled case %s:%d in fm_report_error_renaming_file",
+ g_quark_to_string (error->domain), error->code);
/* fall through */
- case GNOME_VFS_ERROR_GENERIC:
- message = g_strdup_printf (_("Sorry, couldn't rename \"%s\" to \"%s\"."),
- original_name_truncated, new_name_truncated);
+ message = g_strdup_printf (_("Sorry, couldn't rename \"%s\" to \"%s\". %s"),
+ original_name_truncated, new_name_truncated,
+ error->message);
}
-
+
g_free (original_name_truncated);
g_free (new_name_truncated);
@@ -152,67 +148,61 @@ fm_report_error_renaming_file (NautilusFile *file,
void
fm_report_error_setting_group (NautilusFile *file,
- GnomeVFSResult error,
+ GError *error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
- if (error == GNOME_VFS_OK) {
+ if (error == NULL) {
return;
}
file_name = nautilus_file_get_display_name (file);
- switch (error) {
- case GNOME_VFS_ERROR_NOT_PERMITTED:
- message = g_strdup_printf (_("You do not have the permissions necessary to change the group of \"%s\"."),
- file_name);
- break;
- case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM:
- message = g_strdup_printf (_("Couldn't change the group of \"%s\" because it is on a read-only disk"),
- file_name);
- break;
- default:
+ message = NULL;
+ if (error->domain == G_IO_ERROR) {
+ switch (error->code) {
+ case G_IO_ERROR_PERMISSION_DENIED:
+ message = g_strdup_printf (_("You do not have the permissions necessary to change the group of \"%s\"."),
+ file_name);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (message == NULL) {
/* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_group",
- error, gnome_vfs_result_to_string (error));
- file_name = nautilus_file_get_display_name (file);
- message = g_strdup_printf (_("Sorry, couldn't change the group of \"%s\"."), file_name);
- g_free (file_name);
+ g_warning ("Hit unhandled case %s:%d in fm_report_error_setting_group",
+ g_quark_to_string (error->domain), error->code);
+ /* fall through */
+ message = g_strdup_printf (_("Sorry, couldn't change the group of \"%s\". %s"), file_name,
+ error->message);
}
-
+
+
eel_show_error_dialog (_("The group could not be changed."), message, parent_window);
-
+
g_free (file_name);
g_free (message);
-}
+}
void
fm_report_error_setting_owner (NautilusFile *file,
- GnomeVFSResult error,
+ GError *error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
- if (error == GNOME_VFS_OK) {
+ if (error == NULL) {
return;
}
file_name = nautilus_file_get_display_name (file);
- switch (error) {
- case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM:
- message = g_strdup_printf (_("Couldn't change the owner of \"%s\" because it is on a read-only disk"),
- file_name);
- break;
- default:
- /* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_owner",
- error, gnome_vfs_result_to_string (error));
- message = g_strdup_printf (_("Sorry, couldn't change the owner of \"%s\"."), file_name);
- }
+ message = g_strdup_printf (_("Sorry, couldn't change the owner of \"%s\". %s"), file_name, error->message);
eel_show_error_dialog (_("The owner could not be changed."), message, parent_window);
@@ -222,29 +212,19 @@ fm_report_error_setting_owner (NautilusFile *file,
void
fm_report_error_setting_permissions (NautilusFile *file,
- GnomeVFSResult error,
+ GError *error,
GtkWindow *parent_window)
{
char *file_name;
char *message;
- if (error == GNOME_VFS_OK) {
+ if (error == NULL) {
return;
}
file_name = nautilus_file_get_display_name (file);
- switch (error) {
- case GNOME_VFS_ERROR_READ_ONLY_FILE_SYSTEM:
- message = g_strdup_printf (_("Couldn't change the permissions of \"%s\" because it is on a read-only disk"),
- file_name);
- break;
- default:
- /* We should invent decent error messages for every case we actually experience. */
- g_warning ("Hit unhandled case %d (%s) in fm_report_error_setting_permissions",
- error, gnome_vfs_result_to_string (error));
- message = g_strdup_printf (_("Sorry, couldn't change the permissions of \"%s\"."), file_name);
- }
+ message = g_strdup_printf (_("Sorry, couldn't change the permissions of \"%s\". %s"), file_name, error->message);
eel_show_error_dialog (_("The permissions could not be changed."), message, parent_window);
@@ -266,7 +246,8 @@ fm_rename_data_free (FMRenameData *data)
}
static void
-rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_data)
+rename_callback (NautilusFile *file, GFile *result_location,
+ GError *error, gpointer callback_data)
{
FMRenameData *data;
@@ -276,20 +257,27 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
data = g_object_get_data (G_OBJECT (file), NEW_NAME_TAG);
g_assert (data != NULL);
- /* If rename failed, notify the user. */
- fm_report_error_renaming_file (file, data->name, result, NULL);
+ if (error &&
+ !(error->domain == G_IO_ERROR && error->code == G_IO_ERROR_CANCELLED)) {
+ /* If rename failed, notify the user. */
+ fm_report_error_renaming_file (file, data->name, error, NULL);
+ }
- finish_rename (file, TRUE, result);
+ finish_rename (file, TRUE, error);
}
static void
cancel_rename_callback (gpointer callback_data)
{
- finish_rename (NAUTILUS_FILE (callback_data), FALSE, GNOME_VFS_ERROR_CANCELLED);
+ GError *error;
+
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
+ finish_rename (NAUTILUS_FILE (callback_data), FALSE, error);
+ g_error_free (error);
}
static void
-finish_rename (NautilusFile *file, gboolean stop_timer, GnomeVFSResult result)
+finish_rename (NautilusFile *file, gboolean stop_timer, GError *error)
{
FMRenameData *data;
@@ -305,7 +293,7 @@ finish_rename (NautilusFile *file, gboolean stop_timer, GnomeVFSResult result)
}
if (data->callback != NULL) {
- data->callback (file, result, data->callback_data);
+ data->callback (file, NULL, error, data->callback_data);
}
/* Let go of file name. */
@@ -321,12 +309,15 @@ fm_rename_file (NautilusFile *file,
char *old_name, *wait_message;
FMRenameData *data;
char *uri;
+ GError *error;
g_return_if_fail (NAUTILUS_IS_FILE (file));
g_return_if_fail (new_name != NULL);
/* Stop any earlier rename that's already in progress. */
- finish_rename (file, TRUE, GNOME_VFS_ERROR_CANCELLED);
+ error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
+ finish_rename (file, TRUE, error);
+ g_error_free (error);
data = g_new0 (FMRenameData, 1);
data->name = g_strdup (new_name);
diff --git a/src/file-manager/fm-error-reporting.h b/src/file-manager/fm-error-reporting.h
index 47295f23f..5d9b8765f 100644
--- a/src/file-manager/fm-error-reporting.h
+++ b/src/file-manager/fm-error-reporting.h
@@ -31,21 +31,20 @@
#include <libnautilus-private/nautilus-file.h>
void fm_report_error_loading_directory (NautilusFile *file,
- GnomeVFSResult error_code,
- const char *error_message,
+ GError *error,
GtkWindow *parent_window);
void fm_report_error_renaming_file (NautilusFile *file,
const char *new_name,
- GnomeVFSResult error_code,
+ GError *error,
GtkWindow *parent_window);
void fm_report_error_setting_permissions (NautilusFile *file,
- GnomeVFSResult error_code,
+ GError *error,
GtkWindow *parent_window);
void fm_report_error_setting_owner (NautilusFile *file,
- GnomeVFSResult error_code,
+ GError *error,
GtkWindow *parent_window);
void fm_report_error_setting_group (NautilusFile *file,
- GnomeVFSResult error_code,
+ GError *error,
GtkWindow *parent_window);
/* FIXME bugzilla.gnome.org 42394: Should this file be renamed or should this function be moved? */
diff --git a/src/file-manager/fm-icon-container.c b/src/file-manager/fm-icon-container.c
index 779da1339..ab10c6975 100644
--- a/src/file-manager/fm-icon-container.c
+++ b/src/file-manager/fm-icon-container.c
@@ -23,13 +23,10 @@
*/
#include <config.h>
+#include <string.h>
#include <libgnome/gnome-macros.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <eel/eel-string.h>
+#include <gio/gcontenttype.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-thumbnails.h>
@@ -51,19 +48,23 @@ get_icon_view (NautilusIconContainer *container)
return ((FMIconContainer *)container)->view;
}
-static char *
+static NautilusIconInfo *
fm_icon_container_get_icon_images (NautilusIconContainer *container,
NautilusIconData *data,
- GList **emblem_icons,
+ int size,
+ GList **emblem_pixbufs,
char **embedded_text,
+ gboolean for_drag_accept,
gboolean need_large_embeddded_text,
gboolean *embedded_text_needs_loading,
gboolean *has_window_open)
{
FMIconView *icon_view;
- EelStringList *emblems_to_ignore;
+ char **emblems_to_ignore;
NautilusFile *file;
gboolean use_embedding;
+ NautilusFileIconFlags flags;
+ guint emblem_size;
file = (NautilusFile *) data;
@@ -77,17 +78,29 @@ fm_icon_container_get_icon_images (NautilusIconContainer *container,
use_embedding = *embedded_text != NULL;
}
- if (emblem_icons != NULL) {
+ if (emblem_pixbufs != NULL) {
+ emblem_size = nautilus_icon_get_emblem_size_for_icon_size (size);
+
emblems_to_ignore = fm_directory_view_get_emblem_names_to_exclude
(FM_DIRECTORY_VIEW (icon_view));
- *emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file
- (file, emblems_to_ignore);
- eel_string_list_free (emblems_to_ignore);
+ *emblem_pixbufs = nautilus_file_get_emblem_pixbufs (file,
+ emblem_size,
+ FALSE,
+ emblems_to_ignore);
+ g_strfreev (emblems_to_ignore);
}
*has_window_open = nautilus_file_has_open_window (file);
+
+ flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS;
+ if (use_embedding) {
+ flags |= NAUTILUS_FILE_ICON_FLAGS_EMBEDDING_TEXT;
+ }
+ if (for_drag_accept) {
+ flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT;
+ }
- return nautilus_icon_factory_get_icon_for_file (file, use_embedding);
+ return nautilus_file_get_icon (file, size, flags);
}
static char *
@@ -106,7 +119,7 @@ fm_icon_container_get_icon_description (NautilusIconContainer *container,
}
mime_type = nautilus_file_get_mime_type (file);
- description = gnome_vfs_mime_get_description (mime_type);
+ description = g_content_type_get_description (mime_type);
g_free (mime_type);
return g_strdup (description);
}
@@ -163,19 +176,18 @@ fm_icon_container_prioritize_thumbnailing (NautilusIconContainer *container,
}
}
-
/*
* Get the preference for which caption text should appear
* beneath icons.
*/
-static const EelStringList *
+static char **
fm_icon_container_get_icon_text_attributes_from_preferences (void)
{
- static const EelStringList *attributes;
+ static char **attributes;
if (attributes == NULL) {
- eel_preferences_add_auto_string_list (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
- &attributes);
+ eel_preferences_add_auto_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+ &attributes);
}
/* We don't need to sanity check the attributes list even though it came
@@ -198,7 +210,7 @@ fm_icon_container_get_icon_text_attributes_from_preferences (void)
* duplicate attributes by making "bad" choices insensitive.
*
* In the second case, the preferences getter (and also the auto storage) for
- * string_list values are always valid members of the enumeration associated
+ * string_array values are always valid members of the enumeration associated
* with the preference.
*
* So, no more error checking on attributes is needed here and we can return
@@ -216,11 +228,11 @@ fm_icon_container_get_icon_text_attributes_from_preferences (void)
* @view: FMIconView to query.
*
**/
-static const EelStringList *
+static char **
fm_icon_container_get_icon_text_attribute_names (NautilusIconContainer *container,
int *len)
{
- const EelStringList *attributes;
+ char **attributes;
int piece_count;
const int pieces_by_level[] = {
@@ -234,11 +246,11 @@ fm_icon_container_get_icon_text_attribute_names (NautilusIconContainer *containe
};
piece_count = pieces_by_level[nautilus_icon_container_get_zoom_level (container)];
-
+
attributes = fm_icon_container_get_icon_text_attributes_from_preferences ();
- *len = MIN (piece_count, eel_string_list_get_length (attributes));
-
+ *len = MIN (piece_count, g_strv_length (attributes));
+
return attributes;
}
@@ -253,8 +265,7 @@ fm_icon_container_get_icon_text (NautilusIconContainer *container,
{
char *actual_uri;
gchar *description;
- const EelStringList *attribute_names;
- const char *attribute;
+ char **attribute_names;
char *text_array[4];
int i, j, num_attributes;
FMIconView *icon_view;
@@ -299,18 +310,21 @@ fm_icon_container_get_icon_text (NautilusIconContainer *container,
* make sense. */
return;
}
-
+
/* Find out what attributes go below each icon. */
- attribute_names = fm_icon_container_get_icon_text_attribute_names (container, &num_attributes);
+ attribute_names = fm_icon_container_get_icon_text_attribute_names (container,
+ &num_attributes);
/* Get the attributes. */
- for (i = 0, j = 0; i < num_attributes; i++) {
- attribute = eel_string_list_peek_nth (attribute_names, i);
- if (eel_strcmp (attribute, "none") == 0) {
+ j = 0;
+ for (i = 0; i < num_attributes; ++i)
+ {
+ if (strcmp (attribute_names[i], "none") == 0) {
continue;
}
+
text_array[j++] =
- nautilus_file_get_string_attribute_with_default (file, attribute);
+ nautilus_file_get_string_attribute_with_default (file, attribute_names[i]);
}
text_array[j] = NULL;
@@ -318,7 +332,7 @@ fm_icon_container_get_icon_text (NautilusIconContainer *container,
*additional_text = g_strjoinv ("\n", text_array);
for (i = 0; i < j; i++) {
- g_free(text_array[i]);
+ g_free (text_array[i]);
}
}
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index 01583fe8c..2caede7e9 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -48,16 +48,7 @@
#include <gtk/gtkwindow.h>
#include <gtk/gtkstock.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-config.h>
-#include <libgnome/gnome-desktop-item.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-xfer.h>
-#include <libnautilus-private/nautilus-audio-player.h>
+#include <gio/gcontenttype.h>
#include <libnautilus-private/nautilus-directory-background.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-dnd.h>
@@ -66,7 +57,6 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-icon-container.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-link.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-view-factory.h>
@@ -80,8 +70,7 @@
#include <unistd.h>
#include <esd.h>
-#define USE_OLD_AUDIO_PREVIEW 1
-#define READ_CHUNK_SIZE 16384
+#include "nautilus-audio-mime-types.h"
#define POPUP_PATH_ICON_APPEARANCE "/selection/Icon Appearance Items"
@@ -112,9 +101,10 @@ struct FMIconViewDetails
GtkActionGroup *icon_action_group;
guint icon_merge_id;
- NautilusAudioPlayerData *audio_player_data;
int audio_preview_timeout;
NautilusFile *audio_preview_file;
+ int audio_preview_child_watch;
+ GPid audio_preview_child_pid;
gboolean filter_by_screen;
int num_screens;
@@ -165,11 +155,6 @@ static const SortCriterion sort_criteria[] = {
static gboolean default_sort_in_reverse_order = FALSE;
static int preview_sound_auto_value;
-static gboolean gnome_esd_enabled_auto_value;
-
-#if USE_OLD_AUDIO_PREVIEW
-static pid_t audio_preview_pid = 0;
-#endif
static void fm_icon_view_set_directory_sort_by (FMIconView *icon_view,
NautilusFile *file,
@@ -538,7 +523,7 @@ file_has_lazy_position (FMDirectoryView *view,
* icon we don't overlap that one. We don't do this in general though,
* as it can cause icons moving around.
*/
- lazy_position = nautilus_file_has_volume (file);
+ lazy_position = nautilus_file_can_unmount (file);
if (lazy_position && fm_directory_view_get_loading (view)) {
/* if volumes are loaded during directory load, don't mark them
* as lazy. This is wrong for files that were mounted during user
@@ -1747,137 +1732,103 @@ band_select_ended_callback (NautilusIconContainer *container,
/* handle the preview signal by inspecting the mime type. For now, we only preview local sound files. */
+static char **
+get_preview_argv (char *uri)
+{
+ char *command;
+ char **argv;
+ int i;
+
+ command = g_find_program_in_path ("totem-audio-preview");
+ if (command) {
+ argv = g_new (char *, 3);
+ argv[0] = command;
+ argv[1] = g_strdup (uri);
+ argv[2] = NULL;
+
+ return argv;
+ }
+
+ command = g_find_program_in_path ("gst-launch-0.10");
+ if (command) {
+ argv = g_new (char *, 10);
+ i = 0;
+ argv[i++] = command;
+ argv[i++] = g_strdup ("uridecodebin");
+ argv[i++] = g_strconcat ("uri=", uri, NULL);
+ argv[i++] = g_strdup ("!");
+ argv[i++] = g_strdup ("audioconvert");
+ argv[i++] = g_strdup ("!");
+ argv[i++] = g_strdup ("audioresample");
+ argv[i++] = g_strdup ("!");
+ argv[i++] = g_strdup ("autoaudiosink");
+ argv[i++] = NULL;
+ return argv;
+ }
+
+ return NULL;
+}
+
+static void
+audio_child_died (GPid pid,
+ gint status,
+ gpointer data)
+{
+ FMIconView *icon_view;
+
+ icon_view = FM_ICON_VIEW (data);
+
+ icon_view->details->audio_preview_child_watch = 0;
+ icon_view->details->audio_preview_child_pid = 0;
+}
+
/* here's the timer task that actually plays the file using mpg123, ogg123 or play. */
/* FIXME bugzilla.gnome.org 41258: we should get the application from our mime-type stuff */
static gboolean
play_file (gpointer callback_data)
{
-#if USE_OLD_AUDIO_PREVIEW
NautilusFile *file;
FMIconView *icon_view;
- FILE *sound_process;
- char *file_uri;
- char *suffix;
- char *mime_type;
- const char *command_str;
- gboolean is_mp3;
- gboolean is_ogg;
- pid_t mp3_pid;
-
- GnomeVFSResult result;
- GnomeVFSHandle *handle;
- char *buffer;
- const char *audio_device = NULL;
- GnomeVFSFileSize bytes_read;
+ GPid child_pid;
+ char **argv;
+ GError *error;
+ char *uri;
- audio_device = g_getenv ("AUDIODEV");
icon_view = FM_ICON_VIEW (callback_data);
- file = icon_view->details->audio_preview_file;
- file_uri = nautilus_file_get_uri (file);
- mime_type = nautilus_file_get_mime_type (file);
- is_mp3 = eel_strcasecmp (mime_type, "audio/mpeg") == 0;
- is_ogg = eel_strcasecmp (mime_type, "application/ogg") == 0 ||
- eel_strcasecmp (mime_type, "application/x-ogg") == 0;
-
- mp3_pid = fork ();
- if (mp3_pid == (pid_t) 0) {
- /* Set the group (session) id to this process for future killing. */
- setsid();
- if (is_mp3) {
- command_str = "mpg123 -y -q -";
- } else if (is_ogg) {
- command_str = "ogg123 -q -";
- } else {
- suffix = strrchr(file_uri, '.');
- if (suffix == NULL) {
- suffix = "wav";
- } else {
- suffix += 1; /* skip the period */
- }
- if (audio_device) {
- command_str = g_strdup_printf("play -d %s -t %s -", audio_device, suffix);
- } else {
- command_str = g_strdup_printf("play -t %s -", suffix);
- }
- }
-
- /* read the file with gnome-vfs, feeding it to the sound player's standard input */
- /* First, open the file. */
- result = gnome_vfs_open (&handle, file_uri, GNOME_VFS_OPEN_READ);
- if (result != GNOME_VFS_OK) {
- _exit (0);
- }
-
- /* since the uri could be local or remote, we launch the sound player with popen and feed it
- * the data by fetching it with gnome_vfs
- */
- sound_process = popen(command_str, "w");
- if (sound_process == 0) {
- /* Close the file. */
- result = gnome_vfs_close (handle);
- _exit (0);
- }
-
- /* allocate a buffer. */
- buffer = g_malloc(READ_CHUNK_SIZE);
-
- /* read and write a chunk at a time, until we're done */
- do {
- result = gnome_vfs_read (handle,
- buffer,
- READ_CHUNK_SIZE,
- &bytes_read);
- if (result != GNOME_VFS_OK && result != GNOME_VFS_ERROR_EOF) {
- break;
- }
-
- /* pass the data the buffer to the sound process by writing to it */
- fwrite(buffer, 1, bytes_read, sound_process);
-
- } while (result == GNOME_VFS_OK);
-
- /* Close the file. */
- result = gnome_vfs_close (handle);
- g_free(buffer);
- pclose(sound_process);
- _exit (0);
- } else if (mp3_pid > (pid_t) 0) {
- if (audio_preview_pid > 0) {
- kill (-audio_preview_pid, SIGTERM);
- waitpid (audio_preview_pid, NULL, 0);
- }
- audio_preview_pid = mp3_pid;
- }
-
- g_free (file_uri);
- g_free (mime_type);
-
+ /* Stop timeout */
icon_view->details->audio_preview_timeout = 0;
-#else
- char *file_path, *file_uri, *mime_type;
- gboolean is_mp3;
- FMIconView *icon_view;
-
- icon_view = FM_ICON_VIEW (callback_data);
-
- file_uri = nautilus_file_get_uri (icon_view->details->audio_preview_file);
- file_path = gnome_vfs_get_local_path_from_uri (file_uri);
- mime_type = nautilus_file_get_mime_type (icon_view->details->audio_preview_file);
- is_mp3 = eel_strcasecmp (mime_type, "audio/mpeg") == 0;
+ file = icon_view->details->audio_preview_file;
+ uri = nautilus_file_get_uri (file);
+ argv = get_preview_argv (uri);
+ g_free (uri);
+ if (argv == NULL) {
+ return FALSE;
+ }
- if (file_path != NULL && !is_mp3) {
- icon_view->details->audio_player_data = nautilus_audio_player_play (file_path);
+ error = NULL;
+ if (!g_spawn_async_with_pipes (NULL,
+ argv,
+ NULL,
+ G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
+ NULL,
+ NULL /* user_data */,
+ &child_pid,
+ NULL, NULL, NULL,
+ &error)) {
+ g_strfreev (argv);
+ g_warning ("Error spawning sound preview: %s\n", error->message);
+ g_error_free (error);
+ return FALSE;
}
-
- g_free (file_uri);
- g_free (file_path);
- g_free (mime_type);
+ g_strfreev (argv);
- icon_view->details->audio_preview_timeout = 0;
- icon_view->details->audio_preview_file = NULL;
-#endif
+ icon_view->details->audio_preview_child_watch =
+ g_child_watch_add (child_pid,
+ audio_child_died, NULL);
+ icon_view->details->audio_preview_child_pid = child_pid;
+
return FALSE;
}
@@ -1893,19 +1844,13 @@ static void
preview_audio (FMIconView *icon_view, NautilusFile *file, gboolean start_flag)
{
/* Stop current audio playback */
-#if USE_OLD_AUDIO_PREVIEW
- if (audio_preview_pid > 0) {
- kill (-audio_preview_pid, SIGTERM);
- waitpid (audio_preview_pid, NULL, 0);
- audio_preview_pid = 0;
- }
-#else
- if (icon_view->details->audio_player_data != NULL) {
- nautilus_audio_player_stop (icon_view->details->audio_player_data);
- g_free (icon_view->details->audio_player_data);
- icon_view->details->audio_player_data = NULL;
- }
-#endif
+ if (icon_view->details->audio_preview_child_pid != 0) {
+ kill (icon_view->details->audio_preview_child_pid, SIGTERM);
+ g_source_remove (icon_view->details->audio_preview_child_watch);
+ waitpid (icon_view->details->audio_preview_child_pid, NULL, 0);
+ icon_view->details->audio_preview_child_pid = 0;
+ }
+
if (icon_view->details->audio_preview_timeout != 0) {
g_source_remove (icon_view->details->audio_preview_timeout);
icon_view->details->audio_preview_timeout = 0;
@@ -1913,31 +1858,43 @@ preview_audio (FMIconView *icon_view, NautilusFile *file, gboolean start_flag)
if (start_flag) {
icon_view->details->audio_preview_file = file;
-#if USE_OLD_AUDIO_PREVIEW
- icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
-#else
- /* FIXME: Need to kill the existing timeout if there is one? */
icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
-#endif
}
}
static gboolean
-should_preview_sound (NautilusFile *file)
+sound_preview_type_supported (NautilusFile *file)
{
- char *uri;
-
- /* Check gnome config sound preference */
- if (!gnome_esd_enabled_auto_value) {
- return FALSE;
+ char *mime_type;
+ guint i;
+
+ mime_type = nautilus_file_get_mime_type (file);
+ if (mime_type == NULL) {
+ return FALSE;
+ }
+ for (i = 0; i < G_N_ELEMENTS (audio_mime_types); i++) {
+ if (g_content_type_is_a (mime_type, audio_mime_types[i])) {
+ g_free (mime_type);
+ return TRUE;
+ }
}
+
+ g_free (mime_type);
+ return FALSE;
+}
- uri = nautilus_file_get_uri (file);
- if (uri && eel_istr_has_prefix (uri, "burn:")) {
- g_free (uri);
+
+static gboolean
+should_preview_sound (NautilusFile *file)
+{
+ GFile *location;
+
+ location = nautilus_file_get_location (file);
+ if (g_file_has_uri_scheme (location, "burn")) {
+ g_object_unref (location);
return FALSE;
}
- g_free (uri);
+ g_object_unref (location);
/* Check user performance preference */
if (preview_sound_auto_value == NAUTILUS_SPEED_TRADEOFF_NEVER) {
@@ -1951,29 +1908,6 @@ should_preview_sound (NautilusFile *file)
return nautilus_file_is_local (file);
}
-static inline gboolean
-can_play_sound (void)
-{
- int open_result;
-
-#if USE_OLD_AUDIO_PREVIEW
- /* first see if there's already one in progress; if so, return true */
- if (audio_preview_pid > 0) {
- return TRUE;
- }
-#endif
-
- /* Now check and see if system has audio out capabilites */
- open_result = esd_open_sound (NULL);
- if (open_result == -1) {
- return FALSE;
- }
-
- esd_close (open_result);
-
- return TRUE;
-}
-
static int
icon_container_preview_callback (NautilusIconContainer *container,
NautilusFile *file,
@@ -1981,27 +1915,19 @@ icon_container_preview_callback (NautilusIconContainer *container,
FMIconView *icon_view)
{
int result;
- char *mime_type, *file_name, *message;
+ char *file_name, *message;
result = 0;
/* preview files based on the mime_type. */
/* at first, we just handle sounds */
if (should_preview_sound (file)) {
- mime_type = nautilus_file_get_mime_type (file);
-
- if ((eel_istr_has_prefix (mime_type, "audio/")
- || eel_istr_has_prefix (mime_type, "application/ogg")
- || eel_istr_has_prefix (mime_type, "application/x-ogg"))
- && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0
- && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0
- && can_play_sound ()) {
+ if (sound_preview_type_supported (file)) {
result = 1;
preview_audio (icon_view, file, start_flag);
- }
- g_free (mime_type);
+ }
}
-
+
/* Display file name in status area at low zoom levels, since
* the name is not displayed or hard to read in the icon view.
*/
@@ -2600,7 +2526,7 @@ icon_view_scroll_to_file (NautilusView *view,
if (uri != NULL) {
/* Only if existing, since we don't want to add the file to
the directory if it has been removed since then */
- file = nautilus_file_get_existing (uri);
+ file = nautilus_file_get_existing_by_uri (uri);
if (file != NULL) {
nautilus_icon_container_scroll_to_icon (get_icon_container (icon_view),
NAUTILUS_ICON_CONTAINER_ICON_DATA (file));
@@ -2716,10 +2642,6 @@ fm_icon_view_init (FMIconView *icon_view)
if (!setup_sound_preview) {
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_PREVIEW_SOUND,
&preview_sound_auto_value);
-
- eel_preferences_monitor_directory ("/desktop/gnome/sound");
- eel_preferences_add_auto_boolean ("/desktop/gnome/sound/enable_esd",
- &gnome_esd_enabled_auto_value);
setup_sound_preview = TRUE;
}
@@ -2764,10 +2686,10 @@ fm_icon_view_create (NautilusWindowInfo *window)
static gboolean
fm_icon_view_supports_uri (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type)
{
- if (file_type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (file_type == G_FILE_TYPE_DIRECTORY) {
return TRUE;
}
if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){
diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c
index 3d27d3730..5d47b9bb7 100644
--- a/src/file-manager/fm-list-model.c
+++ b/src/file-manager/fm-list-model.c
@@ -31,10 +31,10 @@
#include <string.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
+#include <eel/eel-gdk-pixbuf-extensions.h>
#include <gtk/gtktreednd.h>
#include <gtk/gtktreesortable.h>
#include <glib/gi18n.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-dnd.h>
#if GLIB_CHECK_VERSION (2, 13, 0)
@@ -250,11 +250,12 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
int icon_size;
guint emblem_size;
NautilusZoomLevel zoom_level;
- char *modifier;
- GList *emblem_icons;
+ GList *emblem_pixbufs;
NautilusFile *parent_file;
- EelStringList *emblems_to_ignore;
-
+ char *emblems_to_ignore[3];
+ int i;
+ NautilusFileIconFlags flags;
+
model = (FMListModel *)tree_model;
g_return_if_fail (model->details->stamp == iter->stamp);
@@ -287,7 +288,7 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
zoom_level = fm_list_model_get_zoom_level_from_column_id (column);
icon_size = nautilus_get_icon_size_for_zoom_level (zoom_level);
- modifier = NULL;
+ flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS;
if (model->details->drag_view != NULL) {
GtkTreePath *path_a, *path_b;
@@ -298,19 +299,15 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
path_b = gtk_tree_model_get_path (tree_model, iter);
if (gtk_tree_path_compare (path_a, path_b) == 0) {
- modifier = "accept";
+ flags |= NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT;
}
gtk_tree_path_free (path_a);
gtk_tree_path_free (path_b);
}
}
-
- if (nautilus_file_has_open_window (file)) {
- modifier = "visiting";
- }
-
- icon = nautilus_icon_factory_get_pixbuf_for_file (file, modifier, icon_size, TRUE);
+
+ icon = nautilus_file_get_icon_pixbuf (file, icon_size, TRUE, flags);
g_value_set_object (value, icon);
g_object_unref (icon);
@@ -327,38 +324,34 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
if (file != NULL) {
parent_file = nautilus_file_get_parent (file);
- emblems_to_ignore = eel_string_list_new_from_string (NAUTILUS_FILE_EMBLEM_NAME_TRASH, TRUE);
+ i = 0;
+ emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_TRASH;
if (parent_file) {
if (!nautilus_file_can_write (parent_file)) {
- eel_string_list_prepend (emblems_to_ignore, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE);
+ emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE;
}
nautilus_file_unref (parent_file);
}
+ emblems_to_ignore[i++] = NULL;
+
zoom_level = fm_list_model_get_zoom_level_from_emblem_column_id (column);
icon_size = nautilus_get_icon_size_for_zoom_level (zoom_level);
- emblem_size = nautilus_icon_factory_get_emblem_size_for_icon_size (icon_size);
+ emblem_size = nautilus_icon_get_emblem_size_for_icon_size (icon_size);
/* Special case default icon size here. This works semi-ok, since we
only show one emblem for the list view anyway */
if (emblem_size == 0 && icon_size >= 24) {
emblem_size = 16;
}
- emblem_icons = NULL;
if (emblem_size != 0) {
- emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file (file, emblems_to_ignore);
- }
- eel_string_list_free (emblems_to_ignore);
-
- if (emblem_icons != NULL) {
- icon = nautilus_icon_factory_get_pixbuf_for_icon (
- emblem_icons->data, NULL, emblem_size,
- NULL, NULL, TRUE, FALSE, NULL);
- eel_g_list_free_deep (emblem_icons);
-
- g_value_set_object (value, icon);
-
- if (icon != NULL) {
- g_object_unref (icon);
+ emblem_pixbufs = nautilus_file_get_emblem_pixbufs (file,
+ emblem_size,
+ TRUE,
+ emblems_to_ignore);
+ if (emblem_pixbufs != NULL) {
+ icon = emblem_pixbufs->data;
+ g_value_set_object (value, icon);
}
+ eel_gdk_pixbuf_list_free (emblem_pixbufs);
}
}
break;
diff --git a/src/file-manager/fm-list-model.h b/src/file-manager/fm-list-model.h
index 809f24a8a..ec5f0fad1 100644
--- a/src/file-manager/fm-list-model.h
+++ b/src/file-manager/fm-list-model.h
@@ -27,7 +27,6 @@
#include <gdk/gdkdnd.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-directory.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-extension/nautilus-column.h>
#ifndef FM_LIST_MODEL_H
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index a7597d70c..673e1892c 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -50,7 +50,6 @@
#include <libegg/eggtreemultidnd.h>
#include <glib/gi18n.h>
#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-extension/nautilus-column-provider.h>
#include <libnautilus-private/nautilus-column-chooser.h>
#include <libnautilus-private/nautilus-column-utilities.h>
@@ -62,7 +61,6 @@
#include <libnautilus-private/nautilus-ui-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
@@ -138,8 +136,8 @@ static int click_policy_auto_value;
static char * default_sort_order_auto_value;
static gboolean default_sort_reversed_auto_value;
static NautilusZoomLevel default_zoom_level_auto_value;
-static GList * default_visible_columns_auto_value;
-static GList * default_column_order_auto_value;
+static char ** default_visible_columns_auto_value;
+static char ** default_column_order_auto_value;
static GdkCursor * hand_cursor = NULL;
static GtkTargetList * source_target_list = NULL;
@@ -155,7 +153,8 @@ static void fm_list_view_scroll_to_file (FMListView *v
NautilusFile *file);
static void fm_list_view_iface_init (NautilusViewIface *iface);
static void fm_list_view_rename_callback (NautilusFile *file,
- GnomeVFSResult result,
+ GFile *result_location,
+ GError *error,
gpointer callback_data);
@@ -1157,33 +1156,58 @@ move_copy_items_callback (NautilusTreeViewDragDest *dest,
}
static void
-apply_columns_settings (FMListView *list_view, GList *column_order, GList *visible_columns)
+apply_columns_settings (FMListView *list_view,
+ char **column_order,
+ char **visible_columns)
{
GList *all_columns;
GList *old_view_columns, *view_columns;
+ GHashTable *visible_columns_hash;
GtkTreeViewColumn *prev_view_column;
GList *l;
+ int i;
/* prepare ordered list of view columns using column_order and visible_columns */
view_columns = NULL;
all_columns = nautilus_get_all_columns ();
all_columns = nautilus_sort_columns (all_columns, column_order);
+
+ /* hash table to lookup if a given column should be visible */
+ visible_columns_hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+ for (i = 0; visible_columns[i] != NULL; ++i) {
+ g_hash_table_insert (visible_columns_hash,
+ g_ascii_strdown (visible_columns[i], -1),
+ g_ascii_strdown (visible_columns[i], -1));
+ }
+
for (l = all_columns; l != NULL; l = l->next) {
char *name;
+ char *lowercase;
g_object_get (G_OBJECT (l->data), "name", &name, NULL);
- if (g_list_find_custom (visible_columns, name, (GCompareFunc) g_ascii_strcasecmp) != NULL) {
+ lowercase = g_ascii_strdown (name, -1);
+
+ if (g_hash_table_lookup (visible_columns_hash, lowercase) != NULL) {
GtkTreeViewColumn *view_column;
view_column = g_hash_table_lookup (list_view->details->columns, name);
if (view_column != NULL) {
- view_columns = g_list_append (view_columns, view_column);
+ view_columns = g_list_prepend (view_columns, view_column);
}
}
+
g_free (name);
+ g_free (lowercase);
}
+
+ g_hash_table_destroy (visible_columns_hash);
nautilus_column_list_free (all_columns);
+ view_columns = g_list_reverse (view_columns);
+
/* remove columns that are not present in the configuration */
old_view_columns = gtk_tree_view_get_columns (list_view->details->tree_view);
for (l = old_view_columns; l != NULL; l = l->next) {
@@ -1208,6 +1232,7 @@ apply_columns_settings (FMListView *list_view, GList *column_order, GList *visib
gtk_tree_view_move_column_after (list_view->details->tree_view, l->data, prev_view_column);
prev_view_column = l->data;
}
+ g_list_free (view_columns);
}
static void
@@ -1418,7 +1443,9 @@ create_and_set_up_tree_view (FMListView *view)
/* Apply the default column order and visible columns, to get it
* right most of the time. The metadata will be checked when a
* folder is loaded */
- apply_columns_settings (view, default_column_order_auto_value, default_visible_columns_auto_value);
+ apply_columns_settings (view,
+ default_column_order_auto_value,
+ default_visible_columns_auto_value);
gtk_widget_show (GTK_WIDGET (view->details->tree_view));
gtk_container_add (GTK_CONTAINER (view), GTK_WIDGET (view->details->tree_view));
@@ -1437,12 +1464,15 @@ fm_list_view_add_file (FMDirectoryView *view, NautilusFile *file, NautilusDirect
fm_list_model_add_file (model, file, directory);
}
-static GList *
+static char **
get_visible_columns (FMListView *list_view)
{
NautilusFile *file;
GList *visible_columns;
-
+ char **ret;
+
+ ret = NULL;
+
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (list_view));
visible_columns = nautilus_file_get_metadata_list
@@ -1450,19 +1480,31 @@ get_visible_columns (FMListView *list_view)
NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS,
NAUTILUS_METADATA_SUBKEY_COLUMNS);
- if (!visible_columns) {
- visible_columns = eel_g_str_list_copy (default_visible_columns_auto_value);
+ if (visible_columns) {
+ GPtrArray *res;
+ GList *l;
+
+ res = g_ptr_array_new ();
+ for (l = visible_columns; l != NULL; l = l->next) {
+ g_ptr_array_add (res, l->data);
+ }
+ g_ptr_array_add (res, NULL);
+
+ ret = (char **) g_ptr_array_free (res, FALSE);
}
- return visible_columns;
+ return ret ? ret : g_strdupv (default_visible_columns_auto_value);
}
-static GList *
+static char **
get_column_order (FMListView *list_view)
{
NautilusFile *file;
GList *column_order;
-
+ char **ret;
+
+ ret = NULL;
+
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (list_view));
column_order = nautilus_file_get_metadata_list
@@ -1470,26 +1512,35 @@ get_column_order (FMListView *list_view)
NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER,
NAUTILUS_METADATA_SUBKEY_COLUMNS);
- if (!column_order) {
- column_order = eel_g_str_list_copy (default_column_order_auto_value);
+ if (column_order) {
+ GPtrArray *res;
+ GList *l;
+
+ res = g_ptr_array_new ();
+ for (l = column_order; l != NULL; l = l->next) {
+ g_ptr_array_add (res, l->data);
+ }
+ g_ptr_array_add (res, NULL);
+
+ ret = (char **) g_ptr_array_free (res, FALSE);
}
- return column_order;
+ return ret ? ret : g_strdupv (default_visible_columns_auto_value);
}
static void
set_columns_settings_from_metadata_and_preferences (FMListView *list_view)
{
- GList *column_order;
- GList *visible_columns;
+ char **column_order;
+ char **visible_columns;
column_order = get_column_order (list_view);
visible_columns = get_visible_columns (list_view);
apply_columns_settings (list_view, column_order, visible_columns);
- eel_g_list_free_deep (column_order);
- eel_g_list_free_deep (visible_columns);
+ g_strfreev (column_order);
+ g_strfreev (visible_columns);
}
static void
@@ -1605,7 +1656,10 @@ fm_list_view_clear (FMDirectoryView *view)
}
static void
-fm_list_view_rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_data)
+fm_list_view_rename_callback (NautilusFile *file,
+ GFile *result_location,
+ GError *error,
+ gpointer callback_data)
{
FMListView *view;
@@ -1614,7 +1668,7 @@ fm_list_view_rename_callback (NautilusFile *file, GnomeVFSResult result, gpointe
if (view->details->renaming_file) {
view->details->rename_done = TRUE;
- if (result != GNOME_VFS_OK) {
+ if (error != NULL) {
/* If the rename failed (or was cancelled), kill renaming_file.
* We won't get a change event for the rename, so otherwise
* it would stay around forever.
@@ -1883,20 +1937,41 @@ column_chooser_changed_callback (NautilusColumnChooser *chooser,
FMListView *view)
{
NautilusFile *file;
- GList *visible_columns;
- GList *column_order;
-
+ char **visible_columns;
+ char **column_order;
+ GList *list;
+ int i;
+
file = fm_directory_view_get_directory_as_file (FM_DIRECTORY_VIEW (view));
nautilus_column_chooser_get_settings (chooser,
&visible_columns,
&column_order);
- nautilus_file_set_metadata_list (file, NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS, NAUTILUS_METADATA_SUBKEY_COLUMNS, visible_columns);
- nautilus_file_set_metadata_list (file, NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER, NAUTILUS_METADATA_SUBKEY_COLUMNS, column_order);
+ list = NULL;
+ for (i = 0; visible_columns[i] != NULL; ++i) {
+ list = g_list_prepend (list, visible_columns[i]);
+ }
+ list = g_list_reverse (list);
+ nautilus_file_set_metadata_list (file,
+ NAUTILUS_METADATA_KEY_LIST_VIEW_VISIBLE_COLUMNS,
+ NAUTILUS_METADATA_SUBKEY_COLUMNS,
+ list);
+ g_list_free (list);
+
+ list = NULL;
+ for (i = 0; column_order[i] != NULL; ++i) {
+ list = g_list_prepend (list, column_order[i]);
+ }
+ list = g_list_reverse (list);
+ nautilus_file_set_metadata_list (file,
+ NAUTILUS_METADATA_KEY_LIST_VIEW_COLUMN_ORDER,
+ NAUTILUS_METADATA_SUBKEY_COLUMNS,
+ list);
+ g_list_free (list);
- eel_g_list_free_deep (visible_columns);
- eel_g_list_free_deep (column_order);
+ g_strfreev (visible_columns);
+ g_strfreev (column_order);
set_columns_settings_from_metadata_and_preferences (view);
}
@@ -1905,8 +1980,8 @@ static void
column_chooser_set_from_settings (NautilusColumnChooser *chooser,
FMListView *view)
{
- GList *visible_columns;
- GList *column_order;
+ char **visible_columns;
+ char **column_order;
g_signal_handlers_block_by_func
(chooser, G_CALLBACK (column_chooser_changed_callback), view);
@@ -1918,9 +1993,9 @@ column_chooser_set_from_settings (NautilusColumnChooser *chooser,
visible_columns,
column_order);
- eel_g_list_free_deep (visible_columns);
- eel_g_list_free_deep (column_order);
-
+ g_strfreev (visible_columns);
+ g_strfreev (column_order);
+
g_signal_handlers_unblock_by_func
(chooser, G_CALLBACK (column_chooser_changed_callback), view);
}
@@ -2354,19 +2429,6 @@ fm_list_view_click_policy_changed (FMDirectoryView *directory_view)
}
static void
-icons_changed_callback (GObject *icon_factory,
- gpointer callback_data)
-{
- FMListView *view;
-
- view = FM_LIST_VIEW (callback_data);
-
- gtk_tree_model_foreach (GTK_TREE_MODEL (view->details->model),
- list_view_changed_foreach, NULL);
-}
-
-
-static void
default_sort_order_changed_callback (gpointer callback_data)
{
FMListView *list_view;
@@ -2575,7 +2637,7 @@ list_view_scroll_to_file (NautilusView *view,
if (uri != NULL) {
/* Only if existing, since we don't want to add the file to
the directory if it has been removed since then */
- file = nautilus_file_get_existing (uri);
+ file = nautilus_file_get_existing_by_uri (uri);
if (file != NULL) {
fm_list_view_scroll_to_file (FM_LIST_VIEW (view), file);
nautilus_file_unref (file);
@@ -2638,10 +2700,10 @@ fm_list_view_class_init (FMListViewClass *class)
&default_sort_reversed_auto_value);
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_ZOOM_LEVEL,
(int *) &default_zoom_level_auto_value);
- eel_preferences_add_auto_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
- (const GList **) &default_visible_columns_auto_value);
- eel_preferences_add_auto_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
- (const GList **) &default_column_order_auto_value);
+ eel_preferences_add_auto_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS,
+ &default_visible_columns_auto_value);
+ eel_preferences_add_auto_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER,
+ &default_column_order_auto_value);
}
static const char *
@@ -2691,12 +2753,6 @@ fm_list_view_init (FMListView *list_view)
fm_list_view_sort_directories_first_changed (FM_DIRECTORY_VIEW (list_view));
- g_signal_connect_object
- (nautilus_icon_factory_get (),
- "icons_changed",
- G_CALLBACK (icons_changed_callback),
- list_view, 0);
-
/* ensure that the zoom level is always set in begin_loading */
list_view->details->zoom_level = NAUTILUS_ZOOM_LEVEL_SMALLEST - 1;
@@ -2716,10 +2772,10 @@ fm_list_view_create (NautilusWindowInfo *window)
static gboolean
fm_list_view_supports_uri (const char *uri,
- GnomeVFSFileType file_type,
+ GFileType file_type,
const char *mime_type)
{
- if (file_type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
+ if (file_type == G_FILE_TYPE_DIRECTORY) {
return TRUE;
}
if (strcmp (mime_type, NAUTILUS_SAVED_SEARCH_MIMETYPE) == 0){
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index aa4340cd1..c19d98bfa 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -26,13 +26,13 @@
#include "fm-properties-window.h"
#include "fm-error-reporting.h"
+#include "libnautilus-private/nautilus-mime-application-chooser.h"
#include <eel/eel-accessibility.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-labeled-image.h>
-#include <eel/eel-mime-application-chooser.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <eel/eel-vfs-extensions.h>
@@ -64,7 +64,6 @@
#include <libgnomeui/gnome-help.h>
#include <libgnomeui/gnome-thumbnail.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-extension/nautilus-property-page-provider.h>
#include <libnautilus-private/nautilus-customization-data.h>
#include <libnautilus-private/nautilus-entry.h>
@@ -72,7 +71,6 @@
#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-desktop-icon-file.h>
#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-emblem-utils.h>
#include <libnautilus-private/nautilus-link.h>
#include <libnautilus-private/nautilus-metadata.h>
@@ -163,7 +161,7 @@ struct FMPropertiesWindowDetails {
gboolean deep_count_finished;
guint total_count;
- GnomeVFSFileSize total_size;
+ goffset total_size;
guint long_operation_underway;
@@ -325,44 +323,32 @@ static NautilusFile *
get_target_file_for_original_file (NautilusFile *file)
{
NautilusFile *target_file;
+ GFile *location;
char *uri_to_display;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
NautilusDesktopLink *link;
target_file = NULL;
- if (nautilus_file_has_volume (file)) {
- volume = nautilus_file_get_volume (file);
- if (volume != NULL) {
- uri_to_display = gnome_vfs_volume_get_activation_uri (volume);
- target_file = nautilus_file_get (uri_to_display);
- g_free (uri_to_display);
- }
- } else if (nautilus_file_has_drive (file)) {
- drive = nautilus_file_get_drive (file);
- if (drive != NULL) {
- uri_to_display = gnome_vfs_drive_get_activation_uri (drive);
- if (uri_to_display != NULL) {
- target_file = nautilus_file_get (uri_to_display);
- g_free (uri_to_display);
- }
- }
- } else if (NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
+ if (NAUTILUS_IS_DESKTOP_ICON_FILE (file)) {
link = nautilus_desktop_icon_file_get_link (NAUTILUS_DESKTOP_ICON_FILE (file));
if (link != NULL) {
/* map to linked URI for these types of links */
- uri_to_display = nautilus_desktop_link_get_activation_uri (link);
- if (uri_to_display) {
- target_file = nautilus_file_get (uri_to_display);
- g_free (uri_to_display);
+ location = nautilus_desktop_link_get_activation_location (link);
+ if (location) {
+ target_file = nautilus_file_get (location);
+ g_object_unref (location);
}
g_object_unref (link);
}
- }
-
-
+ } else {
+ uri_to_display = nautilus_file_get_activation_uri (file);
+ if (uri_to_display != NULL) {
+ target_file = nautilus_file_get_by_uri (uri_to_display);
+ g_free (uri_to_display);
+ }
+ }
+
if (target_file != NULL) {
return target_file;
}
@@ -410,7 +396,7 @@ static GdkPixbuf *
get_pixbuf_for_properties_window (FMPropertiesWindow *window)
{
GdkPixbuf *pixbuf;
- char *icon;
+ NautilusIconInfo *icon, *new_icon;
GList *l;
icon = NULL;
@@ -420,30 +406,25 @@ get_pixbuf_for_properties_window (FMPropertiesWindow *window)
file = NAUTILUS_FILE (l->data);
if (!icon) {
- icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
+ icon = nautilus_file_get_icon (file, NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS | NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
} else {
- char *new_icon;
- new_icon = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- if (!new_icon || strcmp (new_icon, icon)) {
- g_free (icon);
- g_free (new_icon);
+ new_icon = nautilus_file_get_icon (file, NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS | NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
+ if (!new_icon || new_icon != icon) {
+ g_object_unref (icon);
+ g_object_unref (new_icon);
icon = NULL;
break;
}
- g_free (new_icon);
+ g_object_unref (new_icon);
}
}
if (!icon) {
- icon = g_strdup ("gnome-fs-regular");
+ icon = nautilus_icon_info_lookup_from_name ("text-x-generic", NAUTILUS_ICON_SIZE_STANDARD);
}
- pixbuf = nautilus_icon_factory_get_pixbuf_for_icon (icon, NULL,
- NAUTILUS_ICON_SIZE_STANDARD,
- NULL, NULL,
- FALSE, TRUE, NULL);
-
- g_free (icon);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon, NAUTILUS_ICON_SIZE_STANDARD);
+ g_object_unref (icon);
return pixbuf;
}
@@ -473,7 +454,7 @@ uri_is_local_image (const char *uri)
GdkPixbuf *pixbuf;
char *image_path;
- image_path = gnome_vfs_get_local_path_from_uri (uri);
+ image_path = g_filename_from_uri (uri, NULL, NULL);
if (image_path == NULL) {
return FALSE;
}
@@ -541,8 +522,11 @@ fm_properties_window_drag_data_received (GtkWidget *widget, GdkDragContext *cont
} else {
if (uri_is_local_image (uris[0])) {
set_icon (uris[0], FM_PROPERTIES_WINDOW (window));
- } else {
- if (eel_is_remote_uri (uris[0])) {
+ } else {
+ GFile *f;
+
+ f = g_file_new_for_uri (uris[0]);
+ if (!g_file_is_native (f)) {
eel_show_error_dialog
(_("The file that you dropped is not local."),
_("You can only use local images as custom icons."),
@@ -554,6 +538,7 @@ fm_properties_window_drag_data_received (GtkWidget *widget, GdkDragContext *cont
_("You can only use local images as custom icons."),
window);
}
+ g_object_unref (f);
}
}
g_strfreev (uris);
@@ -596,12 +581,6 @@ create_image_widget (FMPropertiesWindow *window,
g_object_set_data (G_OBJECT (image), "properties_window", window);
- /* React to icon theme changes. */
- g_signal_connect_object (nautilus_icon_factory_get (),
- "icons_changed",
- G_CALLBACK (update_properties_window_icon),
- image, G_CONNECT_SWAPPED);
-
window->details->icon_image = image;
window->details->icon_button = button;
@@ -776,7 +755,7 @@ name_field_restore_original_name (NautilusEntry *name_field)
}
static void
-rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_data)
+rename_callback (NautilusFile *file, GFile *res_loc, GError *error, gpointer callback_data)
{
FMPropertiesWindow *window;
char *new_name;
@@ -784,11 +763,11 @@ rename_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_da
window = FM_PROPERTIES_WINDOW (callback_data);
/* Complain to user if rename failed. */
- if (result != GNOME_VFS_OK) {
+ if (error != NULL) {
new_name = window->details->pending_name;
fm_report_error_renaming_file (file,
window->details->pending_name,
- result,
+ error,
GTK_WINDOW (window));
if (window->details->name_field != NULL) {
name_field_restore_original_name (NAUTILUS_ENTRY (window->details->name_field));
@@ -1347,18 +1326,6 @@ file_list_get_string_attribute (GList *file_list,
}
-static gboolean
-file_list_all_local (GList *file_list)
-{
- GList *l;
- for (l = file_list; l != NULL; l = l->next) {
- if (!nautilus_file_is_local (NAUTILUS_FILE (l->data))) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
static gboolean
file_list_all_directories (GList *file_list)
{
@@ -1534,7 +1501,8 @@ attach_ellipsizing_value_field (FMPropertiesWindow *window,
static void
group_change_callback (NautilusFile *file,
- GnomeVFSResult result,
+ GFile *res_loc,
+ GError *error,
FMPropertiesWindow *window)
{
char *group;
@@ -1547,7 +1515,7 @@ group_change_callback (NautilusFile *file,
/* Report the error if it's an error. */
eel_timed_wait_stop ((EelCancelCallback) cancel_group_change_callback, window);
- fm_report_error_setting_group (file, result, GTK_WINDOW (window));
+ fm_report_error_setting_group (file, error, GTK_WINDOW (window));
nautilus_file_unref (file);
g_free (group);
@@ -1951,7 +1919,7 @@ attach_group_combo_box (GtkTable *table,
static void
owner_change_callback (NautilusFile *file,
- GnomeVFSResult result,
+ GError *error,
FMPropertiesWindow *window)
{
char *owner;
@@ -1964,7 +1932,7 @@ owner_change_callback (NautilusFile *file,
/* Report the error if it's an error. */
eel_timed_wait_stop ((EelCancelCallback) cancel_owner_change_callback, window);
- fm_report_error_setting_owner (file, result, GTK_WINDOW (window));
+ fm_report_error_setting_owner (file, error, GTK_WINDOW (window));
nautilus_file_unref (file);
g_free (owner);
@@ -2252,12 +2220,12 @@ directory_contents_value_field_update (FMPropertiesWindow *window)
guint file_count;
guint total_count;
guint unreadable_directory_count;
- GnomeVFSFileSize total_size;
+ goffset total_size;
gboolean used_two_lines;
NautilusFile *file;
GList *l;
guint file_unreadable;
- GnomeVFSFileSize file_size;
+ goffset file_size;
g_assert (FM_IS_PROPERTIES_WINDOW (window));
@@ -2319,7 +2287,7 @@ directory_contents_value_field_update (FMPropertiesWindow *window)
}
} else {
char *size_str;
- size_str = gnome_vfs_format_file_size_for_display (total_size);
+ size_str = g_format_file_size_for_display (total_size);
text = g_strdup_printf (ngettext("%d item, with size %s",
"%d items, totalling %s",
total_count),
@@ -2572,7 +2540,7 @@ is_merged_trash_directory (NautilusFile *file)
gboolean result;
file_uri = nautilus_file_get_uri (file);
- result = gnome_vfs_uris_match (file_uri, EEL_TRASH_URI);
+ result = strcmp (file_uri, "trash:///") == 0;
g_free (file_uri);
return result;
@@ -2581,13 +2549,7 @@ is_merged_trash_directory (NautilusFile *file)
static gboolean
should_show_custom_icon_buttons (FMPropertiesWindow *window)
{
- /* FIXME bugzilla.gnome.org 45642:
- * Custom icons aren't displayed on the the desktop Trash icon, so
- * we shouldn't pretend that they work by showing them here.
- * When bug 5642 is fixed we can remove this case.
- */
- if (!is_multi_file_window (window)
- && is_merged_trash_directory (get_target_file (window))) {
+ if (!is_multi_file_window (window)) {
return FALSE;
}
@@ -2645,8 +2607,7 @@ should_show_link_target (FMPropertiesWindow *window)
static gboolean
should_show_free_space (FMPropertiesWindow *window)
{
- if (file_list_all_local (window->details->target_files)
- && file_list_all_directories (window->details->target_files)) {
+ if (file_list_all_directories (window->details->target_files)) {
return TRUE;
}
@@ -2657,12 +2618,6 @@ static gboolean
should_show_volume_usage (FMPropertiesWindow *window)
{
NautilusFile *file;
- GnomeVFSVolume *volume;
- GnomeVFSVolumeMonitor *monitor;
- GList *mounted_volumes;
- gchar *volume_uri;
- gchar *file_uri;
- gboolean match, is_root;
gboolean success = FALSE;
if (is_multi_file_window (window)) {
@@ -2675,43 +2630,13 @@ should_show_volume_usage (FMPropertiesWindow *window)
return FALSE;
}
- if (nautilus_file_has_volume (file)) {
- volume = nautilus_file_get_volume (file);
- if (volume != NULL &&
- gnome_vfs_volume_get_volume_type (volume) == GNOME_VFS_VOLUME_TYPE_MOUNTPOINT) {
- return TRUE;
- }
- return FALSE;
- }
-
- file_uri = nautilus_file_get_activation_uri (file);
-
- monitor = gnome_vfs_get_volume_monitor ();
-
- mounted_volumes = gnome_vfs_volume_monitor_get_mounted_volumes (monitor);
-
- while (mounted_volumes != NULL) {
- volume = mounted_volumes->data;
-
- volume_uri = gnome_vfs_volume_get_activation_uri (volume);
- match = strcmp (volume_uri, file_uri) == 0;
- is_root = strcmp (volume_uri, "file:///") == 0;
- g_free (volume_uri);
-
- if (match &&
- (gnome_vfs_volume_is_user_visible (volume) || is_root) &&
- gnome_vfs_volume_get_volume_type (volume) == GNOME_VFS_VOLUME_TYPE_MOUNTPOINT) {
- success = TRUE;
- break;
- }
-
- mounted_volumes = mounted_volumes->next;
+ if (nautilus_file_can_unmount (file)) {
+ return TRUE;
}
-
- g_free (file_uri);
- eel_g_object_list_free (mounted_volumes);
-
+#ifdef TODO_GIO
+ /* Look at is_mountpoint for activation uri */
+#endif
return success;
}
@@ -2843,52 +2768,9 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data)
cairo_destroy (cr);
}
-static gboolean
-get_mount_stats (gchar *path, guint64 *capacity, guint64 *free)
-{
- int statfs_result;
-#if HAVE_STATVFS
- struct statvfs statfs_buffer;
-#else
- struct statfs statfs_buffer;
-#endif
- GnomeVFSFileSize block_size;
-
- if (path == NULL) {
- return FALSE;
- }
-
- statfs_result = -1;
-
-#if HAVE_STATVFS
- statfs_result = statvfs (path, &statfs_buffer);
- block_size = statfs_buffer.f_frsize;
-#else
-#if STATFS_ARGS == 2
- statfs_result = statfs (path, &statfs_buffer);
-#elif STATFS_ARGS == 4
- statfs_result = statfs (path, &statfs_buffer,
- sizeof (statfs_buffer), 0);
-#endif
- block_size = statfs_buffer.f_bsize;
-#endif
-
- if (statfs_result != 0) {
- return FALSE;
- }
-
- *capacity = statfs_buffer.f_blocks * block_size;
-
- *free = statfs_buffer.f_bavail * block_size;
-
- return TRUE;
-}
-
static GtkWidget*
create_pie_widget (FMPropertiesWindow *window)
{
- GnomeVFSVolumeMonitor *monitor;
- GnomeVFSVolume *volume;
NautilusFile *file;
GtkTable *table;
GtkWidget *pie_canvas;
@@ -2901,13 +2783,14 @@ create_pie_widget (FMPropertiesWindow *window)
gchar *capacity;
gchar *used;
gchar *free;
- gchar *fs_type;
+ const char *fs_type;
gchar *uri;
- gchar *path;
+ GFile *location;
+ GFileInfo *info;
- capacity = gnome_vfs_format_file_size_for_display (window->details->volume_capacity);
- free = gnome_vfs_format_file_size_for_display (window->details->volume_free);
- used = gnome_vfs_format_file_size_for_display (window->details->volume_capacity - window->details->volume_free);
+ capacity = g_format_file_size_for_display (window->details->volume_capacity);
+ free = g_format_file_size_for_display (window->details->volume_free);
+ used = g_format_file_size_for_display (window->details->volume_capacity - window->details->volume_free);
file = get_original_file (window);
@@ -2927,21 +2810,20 @@ create_pie_widget (FMPropertiesWindow *window)
capacity_label = gtk_label_new (g_strconcat (_("Total capacity: "), capacity, NULL));
fstype_label = gtk_label_new (NULL);
-
- monitor = gnome_vfs_get_volume_monitor ();
-
- path = g_filename_from_uri (uri, NULL, NULL);
-
- volume = gnome_vfs_volume_monitor_get_volume_for_path (monitor, path);
-
- if (volume !=NULL) {
- fs_type = gnome_vfs_volume_get_filesystem_type (volume);
+
+ location = g_file_new_for_uri (uri);
+ info = g_file_query_filesystem_info (location, G_FILE_ATTRIBUTE_FS_TYPE,
+ NULL, NULL);
+ if (info) {
+ fs_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FS_TYPE);
if (fs_type != NULL) {
gtk_label_set_text (GTK_LABEL (fstype_label), g_strconcat (_("Filesytem type: "), fs_type, NULL));
}
+
+ g_object_unref (info);
}
+ g_object_unref (location);
- g_free (path);
g_free (uri);
g_free (capacity);
g_free (used);
@@ -2969,22 +2851,30 @@ static GtkWidget*
create_volume_usage_widget (FMPropertiesWindow *window)
{
GtkWidget *piewidget;
- GnomeVFSURI *vfs_uri;
- gchar *path;
gchar *uri;
NautilusFile *file;
+ GFile *location;
+ GFileInfo *info;
file = get_original_file (window);
- uri = nautilus_file_get_activation_uri (file);
- vfs_uri = gnome_vfs_uri_new (uri);
- path = g_filename_from_uri (uri,NULL,NULL);
+ uri = nautilus_file_get_activation_uri (file);
+
+ location = g_file_new_for_uri (uri);
+ info = g_file_query_filesystem_info (location, "fs:*", NULL, NULL);
+
+ if (info) {
+ window->details->volume_capacity = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FS_SIZE);
+ window->details->volume_free = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FS_FREE);
+
+ g_object_unref (info);
+ } else {
+ window->details->volume_capacity = 0;
+ window->details->volume_free = 0;
+ }
- get_mount_stats (path, &window->details->volume_capacity, &window->details->volume_free);
+ g_object_unref (location);
- g_free (uri);
- g_free(path);
-
piewidget = create_pie_widget (window);
gtk_widget_show_all (piewidget);
@@ -3075,12 +2965,12 @@ create_basic_page (FMPropertiesWindow *window)
_("--"),
TRUE);
+ append_title_and_ellipsizing_value (window, table,
+ _("Volume:"),
+ "volume",
+ _("--"),
+ FALSE);
if (should_show_free_space (window)) {
- append_title_and_ellipsizing_value (window, table,
- _("Volume:"),
- "volume",
- _("--"),
- FALSE);
append_title_value_pair (window, table, _("Free space:"),
"free_space",
_("--"),
@@ -3210,6 +3100,7 @@ create_emblems_page (FMPropertiesWindow *window)
GdkPixbuf *pixbuf;
char *label;
GList *icons, *l;
+ NautilusIconInfo *info;
/* The emblems wrapped table */
scroller = eel_scrolled_wrap_table_new (TRUE, &emblems_table);
@@ -3221,7 +3112,7 @@ create_emblems_page (FMPropertiesWindow *window)
gtk_notebook_append_page (window->details->notebook,
scroller, gtk_label_new (_("Emblems")));
- icons = nautilus_emblem_list_availible ();
+ icons = nautilus_emblem_list_available ();
window->details->initial_emblems = get_initial_emblems (window->details->original_files);
@@ -3233,15 +3124,17 @@ create_emblems_page (FMPropertiesWindow *window)
if (!nautilus_emblem_should_show_in_list (emblem_name)) {
continue;
}
-
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name (emblem_name, NULL,
- NAUTILUS_ICON_SIZE_SMALL, TRUE,
- &label);
+
+ info = nautilus_icon_info_lookup_from_name (emblem_name, NAUTILUS_ICON_SIZE_SMALL);
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, NAUTILUS_ICON_SIZE_SMALL);
if (pixbuf == NULL) {
continue;
}
-
+
+ label = g_strdup (nautilus_icon_info_get_display_name (info));
+ g_object_unref (info);
+
if (label == NULL) {
label = nautilus_emblem_get_keyword_from_icon_name (emblem_name);
}
@@ -3298,7 +3191,10 @@ end_long_operation (FMPropertiesWindow *window)
}
static void
-permission_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer callback_data)
+permission_change_callback (NautilusFile *file,
+ GFile *res_loc,
+ GError *error,
+ gpointer callback_data)
{
FMPropertiesWindow *window;
g_assert (callback_data != NULL);
@@ -3307,15 +3203,15 @@ permission_change_callback (NautilusFile *file, GnomeVFSResult result, gpointer
end_long_operation (window);
/* Report the error if it's an error. */
- fm_report_error_setting_permissions (file, result, NULL);
+ fm_report_error_setting_permissions (file, error, NULL);
g_object_unref (window);
}
static void
update_permissions (FMPropertiesWindow *window,
- GnomeVFSFilePermissions vfs_new_perm,
- GnomeVFSFilePermissions vfs_mask,
+ guint32 vfs_new_perm,
+ guint32 vfs_mask,
gboolean is_folder,
gboolean apply_to_both_folder_and_dir,
gboolean use_original)
@@ -3324,7 +3220,7 @@ update_permissions (FMPropertiesWindow *window,
for (l = window->details->target_files; l != NULL; l = l->next) {
NautilusFile *file;
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
file = NAUTILUS_FILE (l->data);
@@ -3360,19 +3256,19 @@ update_permissions (FMPropertiesWindow *window,
static gboolean
initial_permission_state_consistent (FMPropertiesWindow *window,
- GnomeVFSFilePermissions mask,
+ guint32 mask,
gboolean is_folder,
gboolean both_folder_and_dir)
{
GList *l;
gboolean first;
- GnomeVFSFilePermissions first_permissions;
+ guint32 first_permissions;
first = TRUE;
first_permissions = 0;
for (l = window->details->target_files; l != NULL; l = l->next) {
NautilusFile *file;
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
file = l->data;
@@ -3408,7 +3304,7 @@ permission_button_toggled (GtkToggleButton *button,
FMPropertiesWindow *window)
{
gboolean is_folder, is_special;
- GnomeVFSFilePermissions permission_mask;
+ guint32 permission_mask;
gboolean inconsistent;
gboolean on;
@@ -3470,7 +3366,7 @@ permission_button_update (FMPropertiesWindow *window,
gboolean is_folder, is_special;
gboolean no_match;
gboolean sensitive;
- GnomeVFSFilePermissions button_permission;
+ guint32 button_permission;
if (gtk_toggle_button_get_inconsistent (button) &&
window->details->has_recursive_apply) {
@@ -3494,7 +3390,7 @@ permission_button_update (FMPropertiesWindow *window,
no_match = TRUE;
for (l = window->details->target_files; l != NULL; l = l->next) {
NautilusFile *file;
- GnomeVFSFilePermissions file_permissions;
+ guint32 file_permissions;
file = NAUTILUS_FILE (l->data);
@@ -3553,7 +3449,7 @@ permission_button_update (FMPropertiesWindow *window,
static void
set_up_permissions_checkbox (FMPropertiesWindow *window,
GtkWidget *check_button,
- GnomeVFSFilePermissions permission,
+ guint32 permission,
gboolean is_folder)
{
/* Load up the check_button with data we'll need when updating its state. */
@@ -3579,7 +3475,7 @@ add_permissions_checkbox_with_label (FMPropertiesWindow *window,
GtkTable *table,
int row, int column,
const char *label,
- GnomeVFSFilePermissions permission_to_check,
+ guint32 permission_to_check,
GtkLabel *label_for,
gboolean is_folder)
{
@@ -3610,7 +3506,7 @@ static void
add_permissions_checkbox (FMPropertiesWindow *window,
GtkTable *table,
int row, int column,
- GnomeVFSFilePermissions permission_to_check,
+ guint32 permission_to_check,
GtkLabel *label_for,
gboolean is_folder)
{
@@ -3632,6 +3528,24 @@ add_permissions_checkbox (FMPropertiesWindow *window,
is_folder);
}
+enum {
+ UNIX_PERM_SUID = S_ISUID,
+ UNIX_PERM_SGID = S_ISGID,
+ UNIX_PERM_STICKY = 01000, /* S_ISVTX not defined on all systems */
+ UNIX_PERM_USER_READ = S_IRUSR,
+ UNIX_PERM_USER_WRITE = S_IWUSR,
+ UNIX_PERM_USER_EXEC = S_IXUSR,
+ UNIX_PERM_USER_ALL = S_IRUSR | S_IWUSR | S_IXUSR,
+ UNIX_PERM_GROUP_READ = S_IRGRP,
+ UNIX_PERM_GROUP_WRITE = S_IWGRP,
+ UNIX_PERM_GROUP_EXEC = S_IXGRP,
+ UNIX_PERM_GROUP_ALL = S_IRGRP | S_IWGRP | S_IXGRP,
+ UNIX_PERM_OTHER_READ = S_IROTH,
+ UNIX_PERM_OTHER_WRITE = S_IWOTH,
+ UNIX_PERM_OTHER_EXEC = S_IXOTH,
+ UNIX_PERM_OTHER_ALL = S_IROTH | S_IWOTH | S_IXOTH
+};
+
typedef enum {
PERMISSION_READ = (1<<0),
PERMISSION_WRITE = (1<<1),
@@ -3644,16 +3558,16 @@ typedef enum {
PERMISSION_OTHER
} PermissionType;
-static GnomeVFSFilePermissions vfs_perms[3][3] = {
- {GNOME_VFS_PERM_USER_READ, GNOME_VFS_PERM_USER_WRITE, GNOME_VFS_PERM_USER_EXEC},
- {GNOME_VFS_PERM_GROUP_READ, GNOME_VFS_PERM_GROUP_WRITE, GNOME_VFS_PERM_GROUP_EXEC},
- {GNOME_VFS_PERM_OTHER_READ, GNOME_VFS_PERM_OTHER_WRITE, GNOME_VFS_PERM_OTHER_EXEC},
+static guint32 vfs_perms[3][3] = {
+ {UNIX_PERM_USER_READ, UNIX_PERM_USER_WRITE, UNIX_PERM_USER_EXEC},
+ {UNIX_PERM_GROUP_READ, UNIX_PERM_GROUP_WRITE, UNIX_PERM_GROUP_EXEC},
+ {UNIX_PERM_OTHER_READ, UNIX_PERM_OTHER_WRITE, UNIX_PERM_OTHER_EXEC},
};
-static GnomeVFSFilePermissions
+static guint32
permission_to_vfs (PermissionType type, PermissionValue perm)
{
- GnomeVFSFilePermissions vfs_perm;
+ guint32 vfs_perm;
g_assert (type >= 0 && type < 3);
vfs_perm = 0;
@@ -3672,7 +3586,7 @@ permission_to_vfs (PermissionType type, PermissionValue perm)
static PermissionValue
-permission_from_vfs (PermissionType type, GnomeVFSFilePermissions vfs_perm)
+permission_from_vfs (PermissionType type, guint32 vfs_perm)
{
PermissionValue perm;
g_assert (type >= 0 && type < 3);
@@ -3699,7 +3613,7 @@ permission_combo_changed (GtkWidget *combo, FMPropertiesWindow *window)
gboolean is_folder, use_original;
PermissionType type;
int new_perm, mask;
- GnomeVFSFilePermissions vfs_new_perm, vfs_mask;
+ guint32 vfs_new_perm, vfs_mask;
is_folder = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (combo), "is-folder"));
type = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (combo), "permission-type"));
@@ -3796,7 +3710,7 @@ permission_combo_update (FMPropertiesWindow *window,
for (l = window->details->target_files; l != NULL; l = l->next) {
NautilusFile *file;
- GnomeVFSFilePermissions file_permissions;
+ guint32 file_permissions;
file = NAUTILUS_FILE (l->data);
@@ -4012,7 +3926,7 @@ static GtkWidget *
append_special_execution_checkbox (FMPropertiesWindow *window,
GtkTable *table,
const char *label_text,
- GnomeVFSFilePermissions permission_to_check)
+ guint32 permission_to_check)
{
GtkWidget *check_button;
guint last_row;
@@ -4042,12 +3956,12 @@ static void
append_special_execution_flags (FMPropertiesWindow *window, GtkTable *table)
{
append_special_execution_checkbox
- (window, table, _("Set _user ID"), GNOME_VFS_PERM_SUID);
+ (window, table, _("Set _user ID"), UNIX_PERM_SUID);
attach_title_field (table, table->nrows - 1, _("Special flags:"));
- append_special_execution_checkbox (window, table, _("Set gro_up ID"), GNOME_VFS_PERM_SGID);
- append_special_execution_checkbox (window, table, _("_Sticky"), GNOME_VFS_PERM_STICKY);
+ append_special_execution_checkbox (window, table, _("Set gro_up ID"), UNIX_PERM_SGID);
+ append_special_execution_checkbox (window, table, _("_Sticky"), UNIX_PERM_STICKY);
gtk_table_set_row_spacing (table, table->nrows - 1, 18);
}
@@ -4096,7 +4010,7 @@ get_initial_permissions (GList *file_list)
g_direct_equal);
for (l = file_list; l != NULL; l = l->next) {
- GnomeVFSFilePermissions permissions;
+ guint32 permissions;
NautilusFile *file;
file = NAUTILUS_FILE (l->data);
@@ -4212,7 +4126,7 @@ create_simple_permissions (FMPropertiesWindow *window, GtkTable *page_table)
add_permissions_checkbox_with_label (window, page_table,
last_row, 1,
_("Allow _executing file as program"),
- GNOME_VFS_PERM_USER_EXEC|GNOME_VFS_PERM_GROUP_EXEC|GNOME_VFS_PERM_OTHER_EXEC,
+ UNIX_PERM_USER_EXEC|UNIX_PERM_GROUP_EXEC|UNIX_PERM_OTHER_EXEC,
execute_label, FALSE);
}
@@ -4248,7 +4162,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OWNER_ROW,
PERMISSIONS_CHECKBOXES_READ_COLUMN,
- GNOME_VFS_PERM_USER_READ,
+ UNIX_PERM_USER_READ,
owner_perm_label,
is_folder);
@@ -4256,7 +4170,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OWNER_ROW,
PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- GNOME_VFS_PERM_USER_WRITE,
+ UNIX_PERM_USER_WRITE,
owner_perm_label,
is_folder);
@@ -4264,7 +4178,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OWNER_ROW,
PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- GNOME_VFS_PERM_USER_EXEC,
+ UNIX_PERM_USER_EXEC,
owner_perm_label,
is_folder);
@@ -4272,7 +4186,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_GROUP_ROW,
PERMISSIONS_CHECKBOXES_READ_COLUMN,
- GNOME_VFS_PERM_GROUP_READ,
+ UNIX_PERM_GROUP_READ,
group_perm_label,
is_folder);
@@ -4280,7 +4194,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_GROUP_ROW,
PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- GNOME_VFS_PERM_GROUP_WRITE,
+ UNIX_PERM_GROUP_WRITE,
group_perm_label,
is_folder);
@@ -4288,7 +4202,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_GROUP_ROW,
PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- GNOME_VFS_PERM_GROUP_EXEC,
+ UNIX_PERM_GROUP_EXEC,
group_perm_label,
is_folder);
@@ -4296,7 +4210,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OTHERS_ROW,
PERMISSIONS_CHECKBOXES_READ_COLUMN,
- GNOME_VFS_PERM_OTHER_READ,
+ UNIX_PERM_OTHER_READ,
other_perm_label,
is_folder);
@@ -4304,7 +4218,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OTHERS_ROW,
PERMISSIONS_CHECKBOXES_WRITE_COLUMN,
- GNOME_VFS_PERM_OTHER_WRITE,
+ UNIX_PERM_OTHER_WRITE,
other_perm_label,
is_folder);
@@ -4312,7 +4226,7 @@ create_permission_checkboxes (FMPropertiesWindow *window,
check_button_table,
PERMISSIONS_CHECKBOXES_OTHERS_ROW,
PERMISSIONS_CHECKBOXES_EXECUTE_COLUMN,
- GNOME_VFS_PERM_OTHER_EXEC,
+ UNIX_PERM_OTHER_EXEC,
other_perm_label,
is_folder);
}
@@ -4421,9 +4335,9 @@ static void
apply_recursive_clicked (GtkWidget *recursive_button,
FMPropertiesWindow *window)
{
- GnomeVFSFilePermissions file_permission, file_permission_mask;
- GnomeVFSFilePermissions dir_permission, dir_permission_mask;
- GnomeVFSFilePermissions vfs_mask, vfs_new_perm, p;
+ guint32 file_permission, file_permission_mask;
+ guint32 dir_permission, dir_permission_mask;
+ guint32 vfs_mask, vfs_new_perm, p;
GtkWidget *button, *combo;
gboolean active, is_folder, is_special, use_original;
GList *l;
@@ -4814,7 +4728,7 @@ create_open_with_page (FMPropertiesWindow *window)
mime_type = nautilus_file_get_mime_type (get_target_file (window));
- vbox = eel_mime_application_chooser_new (uri, mime_type);
+ vbox = nautilus_mime_application_chooser_new (uri, mime_type);
gtk_widget_show (vbox);
g_free (uri);
@@ -4860,9 +4774,10 @@ create_properties_window (StartupData *startup_data)
file = NAUTILUS_FILE (l->data);
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME
- | NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE;
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO;
nautilus_file_monitor_add (NAUTILUS_FILE (l->data),
&window->details->original_files,
@@ -5169,7 +5084,7 @@ fm_properties_window_present (GList *original_files,
next = l->next;
nautilus_file_call_when_ready
(NAUTILUS_FILE (l->data),
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY,
+ NAUTILUS_FILE_ATTRIBUTE_INFO,
is_directory_ready_callback,
startup_data);
}
@@ -5297,7 +5212,7 @@ set_icon (const char* icon_uri, FMPropertiesWindow *properties_window)
g_assert (icon_uri != NULL);
g_assert (FM_IS_PROPERTIES_WINDOW (properties_window));
- icon_path = gnome_vfs_get_local_path_from_uri (icon_uri);
+ icon_path = g_filename_from_uri (icon_uri, NULL, NULL);
/* we don't allow remote URIs */
if (icon_path != NULL) {
GList *l;
@@ -5319,7 +5234,8 @@ set_icon (const char* icon_uri, FMPropertiesWindow *properties_window)
gnome_desktop_item_save (ditem, NULL, TRUE, NULL);
gnome_desktop_item_unref (ditem);
nautilus_file_invalidate_attributes (file,
- NAUTILUS_FILE_ATTRIBUTE_CUSTOM_ICON);
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO);
}
} else {
real_icon_uri = make_relative_uri_from_full (icon_uri, file_uri);
@@ -5436,7 +5352,7 @@ select_image_button_callback (GtkWidget *widget,
if (nautilus_file_is_directory (file)) {
uri = nautilus_file_get_uri (file);
- image_path = gnome_vfs_get_local_path_from_uri (uri);
+ image_path = g_filename_from_uri (uri, NULL, NULL);
if (image_path != NULL) {
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), image_path);
g_free (image_path);
diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c
index 6ed639ad8..5d1748064 100644
--- a/src/file-manager/fm-tree-model.c
+++ b/src/file-manager/fm-tree-model.c
@@ -30,11 +30,11 @@
#include "fm-tree-model.h"
#include <eel/eel-glib-extensions.h>
+#include <eel/eel-gdk-pixbuf-extensions.h>
#include <glib/gi18n.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-file.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <gtk/gtkenums.h>
#include <string.h>
@@ -61,8 +61,8 @@ struct TreeNode {
NautilusFile *file;
char *display_name;
- char *icon_name;
- GnomeVFSVolume *volume;
+ GIcon *icon;
+ GVolume *volume;
GdkPixbuf *closed_pixbuf;
GdkPixbuf *open_pixbuf;
GdkPixbuf *emblem_pixbuf;
@@ -203,7 +203,7 @@ tree_node_destroy (FMTreeModel *model, TreeNode *node)
g_object_unref (node->file);
g_free (node->display_name);
- g_free (node->icon_name);
+ object_unref_if_not_NULL (node->icon);
object_unref_if_not_NULL (node->closed_pixbuf);
object_unref_if_not_NULL (node->open_pixbuf);
object_unref_if_not_NULL (node->emblem_pixbuf);
@@ -241,29 +241,59 @@ tree_node_parent (TreeNode *node, TreeNode *parent)
}
static GdkPixbuf *
-tree_node_get_pixbuf_from_factory (TreeNode *node,
- const char *modifier)
+get_menu_icon (GIcon *icon)
+{
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int size;
+
+ size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ info = nautilus_icon_info_lookup (icon, size);
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
+ g_object_unref (info);
+
+ return pixbuf;
+}
+
+static GdkPixbuf *
+get_menu_icon_for_file (NautilusFile *file,
+ NautilusFileIconFlags flags)
+{
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
+ int size;
+
+ size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+
+ info = nautilus_file_get_icon (file, size, flags);
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault_at_size (info, size);
+ g_object_unref (info);
+
+ return pixbuf;
+}
+
+static GdkPixbuf *
+tree_node_get_pixbuf (TreeNode *node,
+ NautilusFileIconFlags flags)
{
if (node->parent == NULL) {
- return nautilus_icon_factory_get_pixbuf_from_name_with_stock_size
- (node->icon_name, NULL,
- GTK_ICON_SIZE_MENU, NULL);
+ return get_menu_icon (node->icon);
}
- return nautilus_icon_factory_get_pixbuf_for_file_with_stock_size
- (node->file, modifier, GTK_ICON_SIZE_MENU);
+ return get_menu_icon_for_file (node->file, flags);
}
static gboolean
tree_node_update_pixbuf (TreeNode *node,
GdkPixbuf **pixbuf_storage,
- const char *modifier)
+ NautilusFileIconFlags flags)
{
GdkPixbuf *pixbuf;
if (*pixbuf_storage == NULL) {
return FALSE;
}
- pixbuf = tree_node_get_pixbuf_from_factory (node, modifier);
+ pixbuf = tree_node_get_pixbuf (node, flags);
if (pixbuf == *pixbuf_storage) {
g_object_unref (pixbuf);
return FALSE;
@@ -276,42 +306,47 @@ tree_node_update_pixbuf (TreeNode *node,
static gboolean
tree_node_update_closed_pixbuf (TreeNode *node)
{
- return tree_node_update_pixbuf (node, &node->closed_pixbuf, NULL);
+ return tree_node_update_pixbuf (node, &node->closed_pixbuf, 0);
}
static gboolean
tree_node_update_open_pixbuf (TreeNode *node)
{
- return tree_node_update_pixbuf (node, &node->open_pixbuf, "accept");
+ return tree_node_update_pixbuf (node, &node->open_pixbuf, NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER);
}
static GdkPixbuf *
-tree_node_get_emblem_pixbuf_from_factory (TreeNode *node)
+tree_node_get_emblem_pixbuf_internal (TreeNode *node)
{
GdkPixbuf *pixbuf;
- GList *emblem_icons;
- EelStringList *emblems_to_ignore;
-
- emblems_to_ignore = eel_string_list_new_from_string (NAUTILUS_FILE_EMBLEM_NAME_TRASH, TRUE);
+ GList *emblem_pixbufs;
+ char *emblems_to_ignore[3];
+ int i;
+
+ i = 0;
+ emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_TRASH;
+
if (node->parent && node->parent->file) {
if (!nautilus_file_can_write (node->parent->file)) {
- eel_string_list_prepend (emblems_to_ignore, NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE);
+ emblems_to_ignore[i++] = NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE;
}
}
- emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file
- (node->file, emblems_to_ignore);
- eel_string_list_free (emblems_to_ignore);
+
+ emblems_to_ignore[i++] = NULL;
+
+ emblem_pixbufs = nautilus_file_get_emblem_pixbufs (node->file,
+ nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
+ TRUE,
+ emblems_to_ignore);
+
- if (emblem_icons != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_for_icon_with_stock_size
- (emblem_icons->data, NULL,
- GTK_ICON_SIZE_MENU,
- NULL, NULL, FALSE, NULL);
+ if (emblem_pixbufs != NULL) {
+ pixbuf = g_object_ref (emblem_pixbufs->data);
} else {
pixbuf = NULL;
}
- eel_g_list_free_deep (emblem_icons);
+ eel_gdk_pixbuf_list_free (emblem_pixbufs);
return pixbuf;
}
@@ -324,7 +359,7 @@ tree_node_update_emblem_pixbuf (TreeNode *node)
if (node->emblem_pixbuf == NULL) {
return FALSE;
}
- pixbuf = tree_node_get_emblem_pixbuf_from_factory (node);
+ pixbuf = tree_node_get_emblem_pixbuf_internal (node);
if (pixbuf == node->emblem_pixbuf) {
g_object_unref (pixbuf);
return FALSE;
@@ -360,7 +395,7 @@ static GdkPixbuf *
tree_node_get_closed_pixbuf (TreeNode *node)
{
if (node->closed_pixbuf == NULL) {
- node->closed_pixbuf = tree_node_get_pixbuf_from_factory (node, NULL);
+ node->closed_pixbuf = tree_node_get_pixbuf (node, 0);
}
return node->closed_pixbuf;
}
@@ -369,7 +404,7 @@ static GdkPixbuf *
tree_node_get_open_pixbuf (TreeNode *node)
{
if (node->open_pixbuf == NULL) {
- node->open_pixbuf = tree_node_get_pixbuf_from_factory (node, "accept");
+ node->open_pixbuf = tree_node_get_pixbuf (node, NAUTILUS_FILE_ICON_FLAGS_FOR_OPEN_FOLDER);
}
return node->open_pixbuf;
}
@@ -378,7 +413,7 @@ static GdkPixbuf *
tree_node_get_emblem_pixbuf (TreeNode *node)
{
if (node->emblem_pixbuf == NULL) {
- node->emblem_pixbuf = tree_node_get_emblem_pixbuf_from_factory (node);
+ node->emblem_pixbuf = tree_node_get_emblem_pixbuf_internal (node);
}
return node->emblem_pixbuf;
}
@@ -1035,9 +1070,10 @@ get_tree_monitor_attributes (void)
{
NautilusFileAttributes attributes;
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME;
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO;
return attributes;
}
@@ -1547,21 +1583,20 @@ fm_tree_model_unref_node (GtkTreeModel *model, GtkTreeIter *iter)
}
void
-fm_tree_model_add_root_uri (FMTreeModel *model, const char *root_uri, const char *display_name, const char *icon_name, GnomeVFSVolume *volume)
+fm_tree_model_add_root_uri (FMTreeModel *model, const char *root_uri, const char *display_name, GIcon *icon, GVolume *volume)
{
NautilusFile *file;
TreeNode *node, *cnode;
FMTreeModelRoot *newroot;
- file = nautilus_file_get (root_uri);
+ file = nautilus_file_get_by_uri (root_uri);
newroot = tree_model_root_new (model);
node = create_node_for_file (newroot, file);
node->display_name = g_strdup (display_name);
- node->icon_name = g_strdup (icon_name);
+ node->icon = g_object_ref (icon);
if (volume) {
- gnome_vfs_volume_ref (volume);
- node->volume = volume;
+ node->volume = g_object_ref (volume);
}
newroot->root_node = node;
node->parent = NULL;
@@ -1580,7 +1615,7 @@ fm_tree_model_add_root_uri (FMTreeModel *model, const char *root_uri, const char
report_node_inserted (model, node);
}
-GnomeVFSVolume *
+GVolume *
fm_tree_model_get_volume_for_root_node_file (FMTreeModel *model, NautilusFile *file)
{
TreeNode *node;
@@ -1606,7 +1641,7 @@ fm_tree_model_remove_root_uri (FMTreeModel *model, const char *uri)
FMTreeModelRoot *root;
NautilusFile *file;
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
for (node = model->details->root_node; node != NULL; node = node->next) {
if (file == node->file) {
break;
@@ -1618,7 +1653,7 @@ fm_tree_model_remove_root_uri (FMTreeModel *model, const char *uri)
/* remove the node */
if (node->volume) {
- gnome_vfs_volume_unref (node->volume);
+ g_object_unref (node->volume);
node->volume = NULL;
}
@@ -1657,36 +1692,6 @@ fm_tree_model_new (void)
return model;
}
-static void
-set_theme (TreeNode *node, FMTreeModel *model)
-{
- TreeNode *child;
-
- tree_node_update_closed_pixbuf (node);
- tree_node_update_open_pixbuf (node);
-
- report_node_contents_changed (model, node);
-
- for (child = node->first_child; child != NULL; child = child->next) {
- set_theme (child, model);
- }
-}
-
-void
-fm_tree_model_set_theme (FMTreeModel *model)
-{
- TreeNode *node;
-
- g_return_if_fail (FM_IS_TREE_MODEL (model));
-
- node = model->details->root_node;
- while (node != NULL) {
- set_theme (node, model);
- node = node->next;
- }
-}
-
-
void
fm_tree_model_set_show_hidden_files (FMTreeModel *model,
gboolean show_hidden_files)
diff --git a/src/file-manager/fm-tree-model.h b/src/file-manager/fm-tree-model.h
index 70f270b67..5d71afc2b 100644
--- a/src/file-manager/fm-tree-model.h
+++ b/src/file-manager/fm-tree-model.h
@@ -29,6 +29,7 @@
#include <glib-object.h>
#include <gtk/gtktreemodel.h>
+#include <gio/gvolume.h>
#include <libnautilus-private/nautilus-file.h>
#define FM_TYPE_TREE_MODEL (fm_tree_model_get_type ())
@@ -64,29 +65,28 @@ typedef struct {
GType fm_tree_model_get_type (void);
FMTreeModel *fm_tree_model_new (void);
void fm_tree_model_set_show_hidden_files (FMTreeModel *model,
- gboolean show_hidden_files);
+ gboolean show_hidden_files);
void fm_tree_model_set_show_backup_files (FMTreeModel *model,
- gboolean show_backup_files);
+ gboolean show_backup_files);
void fm_tree_model_set_show_only_directories (FMTreeModel *model,
- gboolean show_only_directories);
+ gboolean show_only_directories);
NautilusFile * fm_tree_model_iter_get_file (FMTreeModel *model,
- GtkTreeIter *iter);
+ GtkTreeIter *iter);
void fm_tree_model_add_root_uri (FMTreeModel *model,
- const char *root_uri,
- const char *display_name,
- const char *icon_name,
- GnomeVFSVolume *volume);
+ const char *root_uri,
+ const char *display_name,
+ GIcon *icon,
+ GVolume *volume);
void fm_tree_model_remove_root_uri (FMTreeModel *model,
- const char *root_uri);
+ const char *root_uri);
gboolean fm_tree_model_iter_is_root (FMTreeModel *model,
- GtkTreeIter *iter);
+ GtkTreeIter *iter);
gboolean fm_tree_model_file_get_iter (FMTreeModel *model,
- GtkTreeIter *iter,
- NautilusFile *file,
- GtkTreeIter *currentIter);
+ GtkTreeIter *iter,
+ NautilusFile *file,
+ GtkTreeIter *currentIter);
-void fm_tree_model_set_theme (FMTreeModel *model);
-GnomeVFSVolume * fm_tree_model_get_volume_for_root_node_file
+GVolume * fm_tree_model_get_volume_for_root_node_file
(FMTreeModel *model,
NautilusFile *file);
diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c
index 688302fc7..ec045aaa6 100644
--- a/src/file-manager/fm-tree-view.c
+++ b/src/file-manager/fm-tree-view.c
@@ -40,7 +40,6 @@
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-preferences.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkcellrendererpixbuf.h>
#include <gtk/gtkcellrenderertext.h>
@@ -57,10 +56,10 @@
#include <gtk/gtkmenushell.h>
#include <gtk/gtkclipboard.h>
#include <glib/gi18n.h>
+#include <gio/gvolumemonitor.h>
+#include <gio/gthemedicon.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomeui/gnome-popup-menu.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libnautilus-private/nautilus-clipboard-monitor.h>
#include <libnautilus-private/nautilus-desktop-icon-file.h>
#include <libnautilus-private/nautilus-debug-log.h>
@@ -70,7 +69,6 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-program-choosing.h>
#include <libnautilus-private/nautilus-tree-view-drag-dest.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-cell-renderer-pixbuf-emblem.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-module.h>
@@ -90,6 +88,8 @@ struct FMTreeViewDetails {
GtkTreeModelSort *sort_model;
FMTreeModel *child_model;
+ GVolumeMonitor *volume_monitor;
+
NautilusFile *activation_file;
gboolean activation_in_new_window;
@@ -214,7 +214,7 @@ show_selection_idle_callback (gpointer callback_data)
view->details->show_selection_idle_id = 0;
- file = nautilus_file_get (view->details->selection_location);
+ file = nautilus_file_get_by_uri (view->details->selection_location);
if (file == NULL) {
return FALSE;
}
@@ -291,7 +291,7 @@ row_loaded_callback (GtkTreeModel *tree_model,
}
/* if iter is ancestor of wanted selection_location then update selection */
- selection_file = nautilus_file_get (view->details->selection_location);
+ selection_file = nautilus_file_get_by_uri (view->details->selection_location);
while (selection_file != NULL) {
if (file == selection_file) {
nautilus_file_unref (file);
@@ -334,6 +334,7 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
FMTreeView *view;
GdkScreen *screen;
NautilusWindowOpenMode mode;
+ GFile *location;
view = FM_TREE_VIEW (callback_data);
@@ -370,19 +371,21 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
&& nautilus_file_can_execute (file)
&& !nautilus_file_is_directory (file)) {
- file_uri = gnome_vfs_get_local_path_from_uri (uri);
+ file_uri = g_filename_from_uri (uri, NULL, NULL);
/* Non-local executables don't get launched. They act like non-executables. */
if (file_uri == NULL) {
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"tree view window_info_open_location window=%p: %s",
view->details->window, uri);
+ location = g_file_new_for_uri (uri);
nautilus_window_info_open_location
(view->details->window,
- uri,
+ location,
mode,
0,
NULL);
+ g_object_unref (location);
} else {
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"tree view launch_application_from_command window=%p: %s",
@@ -401,12 +404,14 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"tree view window_info_open_location window=%p: %s",
view->details->window, uri);
+ location = g_file_new_for_uri (uri);
nautilus_window_info_open_location
(view->details->window,
- uri,
+ location,
mode,
0,
NULL);
+ g_object_unref (location);
}
}
@@ -467,7 +472,7 @@ selection_changed_timer_callback(FMTreeView *view)
}
view->details->activation_in_new_window = FALSE;
- attributes = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI;
+ attributes = NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO;
nautilus_file_call_when_ready (view->details->activation_file, attributes,
got_activation_uri_callback, view);
return FALSE; /* remove timeout */
@@ -590,57 +595,49 @@ move_copy_items_callback (NautilusTreeViewDragDest *dest,
}
static void
-theme_changed_callback (GObject *icon_factory, gpointer callback_data)
-{
- FMTreeView *view;
-
- view = FM_TREE_VIEW (callback_data);
- if (view->details->child_model != NULL) {
- fm_tree_model_set_theme (FM_TREE_MODEL (view->details->child_model));
- }
-}
-
-static void
add_root_for_volume (FMTreeView *view,
- GnomeVFSVolume *volume)
+ GVolume *volume)
{
- char *icon, *mount_uri, *name;
+ char *mount_uri, *name;
+ GFile *root;
+ GIcon *icon;
- if (!gnome_vfs_volume_is_user_visible (volume)) {
- return;
- }
-
- icon = gnome_vfs_volume_get_icon (volume);
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- name = gnome_vfs_volume_get_display_name (volume);
+ icon = g_volume_get_icon (volume);
+ root = g_volume_get_root (volume);
+ mount_uri = g_file_get_uri (root);
+ g_object_unref (root);
+ name = g_volume_get_name (volume);
fm_tree_model_add_root_uri(view->details->child_model,
mount_uri, name, icon, volume);
- g_free (icon);
+ g_object_unref (icon);
g_free (name);
g_free (mount_uri);
}
static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_mounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
FMTreeView *view)
{
add_root_for_volume (view, volume);
}
static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_unmounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
FMTreeView *view)
{
+ GFile *root;
char *mount_uri;
-
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
+
+ root = g_volume_get_root (volume);
+ mount_uri = g_file_get_uri (root);
+ g_object_unref (root);
fm_tree_model_remove_root_uri (view->details->child_model,
- mount_uri);
+ mount_uri);
g_free (mount_uri);
}
@@ -667,59 +664,6 @@ get_clipboard (GtkWidget *widget)
}
static gboolean
-can_move_uri_to_trash (const char *file_uri_string)
-{
- /* Return TRUE if we can get a trash directory on the same volume as this file. */
- GnomeVFSURI *file_uri;
- GnomeVFSURI *directory_uri;
- GnomeVFSURI *trash_dir_uri;
- gboolean result;
-
- g_return_val_if_fail (file_uri_string != NULL, FALSE);
-
- file_uri = gnome_vfs_uri_new (file_uri_string);
-
- if (file_uri == NULL) {
- return FALSE;
- }
-
- /* FIXME: Why can't we just pass file_uri to gnome_vfs_find_directory? */
- directory_uri = gnome_vfs_uri_get_parent (file_uri);
- gnome_vfs_uri_unref (file_uri);
-
- if (directory_uri == NULL) {
- return FALSE;
- }
-
- /*
- * Create a new trash if needed but don't go looking for an old Trash.
- * Passing 0 permissions as gnome-vfs would override the permissions
- * passed with 700 while creating .Trash directory
- */
- result = gnome_vfs_find_directory (directory_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
- &trash_dir_uri, TRUE, FALSE, 0) == GNOME_VFS_OK;
- if (result) {
- gnome_vfs_uri_unref (trash_dir_uri);
- }
- gnome_vfs_uri_unref (directory_uri);
-
- return result;
-}
-
-static gboolean
-eject_for_type (GnomeVFSDeviceType type)
-{
- switch (type) {
- case GNOME_VFS_DEVICE_TYPE_CDROM:
- case GNOME_VFS_DEVICE_TYPE_ZIP:
- case GNOME_VFS_DEVICE_TYPE_JAZ:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-static gboolean
is_parent_writable (NautilusFile *file)
{
NautilusFile *parent;
@@ -743,7 +687,6 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
FMTreeView *view)
{
GtkTreePath *path, *cursor_path;
- char *uri;
gboolean parent_file_is_writable;
gboolean file_is_home_or_desktop;
gboolean file_is_special_link;
@@ -753,7 +696,7 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
if (event->button == 3) {
gboolean unmount_is_eject = FALSE;
gboolean show_unmount = FALSE;
- GnomeVFSVolume *volume = NULL;
+ GVolume *volume = NULL;
if (!gtk_tree_view_get_path_at_pos (treeview, event->x, event->y,
&path, NULL, NULL, NULL)) {
@@ -768,7 +711,6 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
gtk_tree_view_get_cursor (view->details->tree_widget, &cursor_path, NULL);
gtk_tree_view_set_cursor (view->details->tree_widget, path, NULL, FALSE);
gtk_tree_path_free (path);
- uri = nautilus_file_get_uri (view->details->popup_file);
gtk_widget_set_sensitive (view->details->popup_open_in_new_window,
nautilus_file_is_directory (view->details->popup_file));
@@ -782,9 +724,8 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
copied_files_atom,
clipboard_contents_received_callback, view);
}
- can_move_file_to_trash = can_move_uri_to_trash (uri);
+ can_move_file_to_trash = nautilus_file_can_trash (view->details->popup_file);
gtk_widget_set_sensitive (view->details->popup_trash, can_move_file_to_trash);
- g_free (uri);
if (show_delete_command_auto_value) {
parent_file_is_writable = is_parent_writable (view->details->popup_file);
@@ -805,7 +746,7 @@ button_pressed_callback (GtkTreeView *treeview, GdkEventButton *event,
volume = fm_tree_model_get_volume_for_root_node_file (view->details->child_model, view->details->popup_file);
if (volume) {
show_unmount = TRUE;
- unmount_is_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
+ unmount_is_eject = g_volume_can_eject (volume);
}
gtk_label_set_text (GTK_LABEL (GTK_BIN (GTK_MENU_ITEM (view->details->popup_unmount))->child),
@@ -852,7 +793,7 @@ fm_tree_view_activate_file (FMTreeView *view,
view->details->activation_file = nautilus_file_ref (file);
view->details->activation_in_new_window = open_in_new_window;
- attributes = NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI;
+ attributes = NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_LINK_INFO;
nautilus_file_call_when_ready (view->details->activation_file, attributes,
got_activation_uri_callback, view);
}
@@ -879,7 +820,7 @@ new_folder_done (const char *new_folder_uri, gpointer data)
/* show the properties window for the newly created
* folder so the user can change its name
*/
- list = g_list_prepend (NULL, nautilus_file_get (new_folder_uri));
+ list = g_list_prepend (NULL, nautilus_file_get_by_uri (new_folder_uri));
fm_properties_window_present (list, GTK_WIDGET (data));
@@ -1077,27 +1018,6 @@ fm_tree_view_paste_cb (GtkWidget *menu_item,
paste_into_clipboard_received_callback, view);
}
-static void
-fm_tree_view_trash_cb (GtkWidget *menu_item,
- FMTreeView *view)
-{
- GList *list;
- char *directory_uri;
-
- directory_uri = nautilus_file_get_uri (view->details->popup_file);
-
- if (can_move_uri_to_trash (directory_uri))
- {
- list = g_list_prepend (NULL, g_strdup (directory_uri));
-
- nautilus_file_operations_copy_move (list, NULL,
- EEL_TRASH_URI, GDK_ACTION_MOVE, GTK_WIDGET (view->details->tree_widget),
- NULL, NULL);
- }
-
- g_free (directory_uri);
-}
-
static GtkWindow *
fm_tree_view_get_containing_window (FMTreeView *view)
{
@@ -1113,75 +1033,40 @@ fm_tree_view_get_containing_window (FMTreeView *view)
return GTK_WINDOW (window);
}
-static char *
-file_name_from_uri (const char *uri)
-{
- NautilusFile *file;
- char *file_name;
-
- file = nautilus_file_get (uri);
- file_name = nautilus_file_get_display_name (file);
- nautilus_file_unref (file);
-
- return file_name;
-}
-
-static gboolean
-confirm_delete_directly (FMTreeView *view,
- const char *directory_uri)
+static void
+fm_tree_view_trash_cb (GtkWidget *menu_item,
+ FMTreeView *view)
{
- GtkDialog *dialog;
- char *file_name;
- char *prompt;
- int response;
+ GList *list;
- file_name = file_name_from_uri (directory_uri);
-
- prompt = g_strdup_printf (_("Are you sure you want to permanently delete \"%s\"?"),
- file_name);
- g_free (file_name);
-
- dialog = GTK_DIALOG (eel_alert_dialog_new (fm_tree_view_get_containing_window (view),
- 0,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- prompt,
- _("If you delete an item, it is permanently lost.")));
-
- gtk_dialog_add_button (dialog, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button (dialog, GTK_STOCK_DELETE, GTK_RESPONSE_YES);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
-
- g_free (prompt);
-
- response = gtk_dialog_run (dialog);
+ if (!nautilus_file_can_trash (view->details->popup_file)) {
+ return;
+ }
- gtk_object_destroy (GTK_OBJECT(dialog));
+ list = g_list_prepend (NULL,
+ nautilus_file_get_location (view->details->popup_file));
- return (response == GTK_RESPONSE_YES);
+ nautilus_file_operations_trash_or_delete (list,
+ fm_tree_view_get_containing_window (view),
+ NULL, NULL);
+ eel_g_object_list_free (list);
}
static void
fm_tree_view_delete_cb (GtkWidget *menu_item,
FMTreeView *view)
{
- GList *uri_list;
- char *directory_uri;
+ GList *location_list;
if (!show_delete_command_auto_value) {
return;
}
- directory_uri = nautilus_file_get_uri (view->details->popup_file);
+ location_list = g_list_prepend (NULL,
+ nautilus_file_get_location (view->details->popup_file));
- if (confirm_delete_directly (view, directory_uri)) {
- uri_list = NULL;
- uri_list = g_list_prepend (uri_list, g_strdup (directory_uri));
-
- nautilus_file_operations_delete (uri_list, GTK_WIDGET (view), NULL, NULL);
- eel_g_list_free_deep (uri_list);
- }
- g_free (directory_uri);
+ nautilus_file_operations_delete (location_list, fm_tree_view_get_containing_window (view), NULL, NULL);
+ eel_g_object_list_free (location_list);
}
static void
@@ -1198,30 +1083,11 @@ fm_tree_view_properties_cb (GtkWidget *menu_item,
}
static void
-volume_or_drive_unmounted_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer data)
-{
- gboolean eject;
-
- eject = GPOINTER_TO_INT (data);
- if (!succeeded) {
- if (eject) {
- eel_show_error_dialog_with_details (error, NULL, detailed_error, NULL);
- } else {
- eel_show_error_dialog_with_details (error, NULL, detailed_error, NULL);
- }
- }
-}
-
-
-static void
fm_tree_view_unmount_cb (GtkWidget *menu_item,
FMTreeView *view)
{
NautilusFile *file = view->details->popup_file;
- GnomeVFSVolume *volume;
+ GVolume *volume;
if (file == NULL) {
return;
@@ -1230,11 +1096,12 @@ fm_tree_view_unmount_cb (GtkWidget *menu_item,
volume = fm_tree_model_get_volume_for_root_node_file (view->details->child_model, file);
if (volume != NULL) {
- if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
- gnome_vfs_volume_eject (volume, volume_or_drive_unmounted_callback, GINT_TO_POINTER (TRUE));
+ if (g_volume_can_eject (volume)) {
+ /* TODO-gio: Handle callbacks */
+ g_volume_eject (volume, NULL, NULL, NULL);
} else {
- nautilus_file_operations_unmount_volume (GTK_WIDGET (view), volume,
- volume_or_drive_unmounted_callback, GINT_TO_POINTER (FALSE));
+ /* TODO-gio: Handle callbacks */
+ g_volume_unmount (volume, NULL, NULL, NULL);
}
}
}
@@ -1371,10 +1238,11 @@ create_tree (FMTreeView *view)
{
GtkCellRenderer *cell;
GtkTreeViewColumn *column;
- GnomeVFSVolumeMonitor *volume_monitor;
+ GVolumeMonitor *volume_monitor;
char *home_uri;
GList *volumes, *l;
char *location;
+ GIcon *icon;
view->details->child_model = fm_tree_model_new ();
view->details->sort_model = GTK_TREE_MODEL_SORT
@@ -1391,19 +1259,25 @@ create_tree (FMTreeView *view)
G_CALLBACK (row_loaded_callback),
view, G_CONNECT_AFTER);
home_uri = nautilus_get_home_directory_uri ();
- fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), "gnome-fs-home", NULL);
+ icon = g_themed_icon_new ("user-home");
+ fm_tree_model_add_root_uri (view->details->child_model, home_uri, _("Home Folder"), icon, NULL);
+ g_object_unref (icon);
g_free (home_uri);
- fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("File System"), "gnome-fs-directory", NULL);
+ icon = g_themed_icon_new ("folder");
+ fm_tree_model_add_root_uri (view->details->child_model, "file:///", _("File System"), icon, NULL);
+ g_object_unref (icon);
#ifdef NOT_YET_USABLE
+ icon = g_themed_icon_new ("gnome-fs-network");
fm_tree_model_add_root_uri (view->details->child_model, "network:///", _("Network Neighbourhood"), "gnome-fs-network", NULL);
+ g_object_unref (icon);
#endif
- volume_monitor = gnome_vfs_get_volume_monitor ();
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- volumes = g_list_sort (volumes, (GCompareFunc) gnome_vfs_volume_compare);
+ volume_monitor = g_volume_monitor_get ();
+ view->details->volume_monitor = volume_monitor;
+ volumes = g_volume_monitor_get_mounted_volumes (volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
add_root_for_volume (view, l->data);
- gnome_vfs_volume_unref (l->data);
+ g_object_unref (l->data);
}
g_list_free (volumes);
@@ -1558,9 +1432,6 @@ fm_tree_view_init (FMTreeView *view)
eel_preferences_add_callback (NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES,
filtering_changed_callback, view);
- g_signal_connect_object (nautilus_icon_factory_get(), "icons_changed",
- G_CALLBACK (theme_changed_callback), view, 0);
-
view->details->popup_file = NULL;
create_popup_menu (view);
}
@@ -1611,6 +1482,8 @@ fm_tree_view_finalize (GObject *object)
g_free (view->details->selection_location);
}
+ g_object_unref (view->details->volume_monitor);
+
g_free (view->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
diff --git a/src/file-manager/nautilus-audio-mime-types.h b/src/file-manager/nautilus-audio-mime-types.h
new file mode 100644
index 000000000..d8edcadbe
--- /dev/null
+++ b/src/file-manager/nautilus-audio-mime-types.h
@@ -0,0 +1,41 @@
+/* generated with mime-types-include.sh in the totem module, don't edit or
+ commit in the nautilus module without filing a bug against totem */
+static char *audio_mime_types[] = {
+"audio/3gpp",
+"audio/ac3",
+"audio/AMR",
+"audio/AMR-WB",
+"audio/basic",
+"audio/mp4",
+"audio/mpeg",
+"audio/mpegurl",
+"audio/ogg",
+"audio/vnd.rn-realaudio",
+"audio/x-ape",
+"audio/x-flac",
+"audio/x-it",
+"audio/x-m4a",
+"audio/x-matroska",
+"audio/x-mod",
+"audio/x-mp3",
+"audio/x-mpeg",
+"audio/x-mpegurl",
+"audio/x-ms-asf",
+"audio/x-ms-asx",
+"audio/x-ms-wax",
+"audio/x-ms-wma",
+"audio/x-musepack",
+"audio/x-pn-aiff",
+"audio/x-pn-au",
+"audio/x-pn-wav",
+"audio/x-pn-windows-acm",
+"audio/x-realaudio",
+"audio/x-real-audio",
+"audio/x-sbc",
+"audio/x-scpls",
+"audio/x-tta",
+"audio/x-wav",
+"audio/x-wav",
+"audio/x-wavpack",
+"audio/x-vorbis",
+};
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 23387ef40..18d7d3ce4 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -46,6 +46,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <string.h>
#include "nautilus-desktop-window.h"
#include "nautilus-first-time-druid.h"
#include "nautilus-main.h"
@@ -59,31 +60,21 @@
#include <libxml/xmlsave.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
+#include <gio/gfile.h>
#include <bonobo/bonobo-main.h>
#include <bonobo/bonobo-object.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string-list.h>
-#include <eel/eel-string.h>
#include <gdk/gdkx.h>
-#include <gtk/gtkinvisible.h>
-#include <gtk/gtksignal.h>
#include <gtk/gtkwindow.h>
+#include <gio/gfile.h>
#include <libgnome/gnome-config.h>
-#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-authentication-manager.h>
#include <libgnomeui/gnome-client.h>
-#include <libgnomeui/gnome-messagebox.h>
-#include <libgnomeui/gnome-stock-icons.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
#include <libnautilus-private/nautilus-debug-log.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metafile-factory.h>
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-undo-manager.h>
@@ -92,6 +83,9 @@
#include <libnautilus-private/nautilus-signaller.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <bonobo-activation/bonobo-activation.h>
+#include <gio/gthemedicon.h>
+#include <gio/gfileicon.h>
+
#ifdef HAVE_STARTUP_NOTIFICATION
#define SN_API_NOT_YET_FROZEN Yes_i_know_DO_IT
#include <libsn/sn-launchee.h>
@@ -117,11 +111,11 @@ static GList *nautilus_application_spatial_window_list;
static void desktop_changed_callback (gpointer user_data);
static void desktop_location_changed_callback (gpointer user_data);
-static void volume_unmounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+static void volume_unmounted_callback (GVolumeMonitor *monitor,
+ GVolume *volume,
NautilusApplication *application);
-static void volume_mounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+static void volume_mounted_callback (GVolumeMonitor *monitor,
+ GVolume *volume,
NautilusApplication *application);
static void update_session (gpointer callback_data);
static void init_session (void);
@@ -184,11 +178,13 @@ nautilus_application_instance_init (NautilusApplication *application)
* used anymore */
/* Watch for volume unmounts so we can close open windows */
- g_signal_connect_object (gnome_vfs_get_volume_monitor (), "volume_unmounted",
+ /* TODO-gio: This should be using the UNMOUNTED feature of GDirectoryMonitor instead */
+ application->volume_monitor = g_volume_monitor_get ();
+ g_signal_connect_object (application->volume_monitor, "volume_unmounted",
G_CALLBACK (volume_unmounted_callback), application, 0);
- g_signal_connect_object (gnome_vfs_get_volume_monitor (), "volume_pre_unmount",
+ g_signal_connect_object (application->volume_monitor, "volume_pre_unmount",
G_CALLBACK (volume_unmounted_callback), application, 0);
- g_signal_connect_object (gnome_vfs_get_volume_monitor (), "volume_mounted",
+ g_signal_connect_object (application->volume_monitor, "volume_mounted",
G_CALLBACK (volume_mounted_callback), application, 0);
/* register views */
@@ -236,6 +232,11 @@ nautilus_application_destroy (BonoboObject *object)
g_object_unref (application->undo_manager);
+ if (application->volume_monitor) {
+ g_object_unref (application->volume_monitor);
+ application->volume_monitor = NULL;
+ }
+
if (application->shell_registered) {
bonobo_activation_unregister_active_server (SHELL_IID, BONOBO_OBJREF (application->shell));
}
@@ -249,58 +250,68 @@ check_required_directories (NautilusApplication *application)
{
char *user_directory;
char *desktop_directory;
- EelStringList *directories;
- char *directories_as_string;
- char *error_string;
- char *detail_string;
- GtkDialog *dialog;
- int failed_count;
-
+ GSList *directories;
+ gboolean ret;
+
g_assert (NAUTILUS_IS_APPLICATION (application));
+ ret = TRUE;
+
user_directory = nautilus_get_user_directory ();
desktop_directory = nautilus_get_desktop_directory ();
- directories = eel_string_list_new (TRUE);
-
+ directories = NULL;
+
if (!g_file_test (user_directory, G_FILE_TEST_IS_DIR)) {
- eel_string_list_insert (directories, user_directory);
+ directories = g_slist_prepend (directories, user_directory);
}
- g_free (user_directory);
-
+
if (!g_file_test (desktop_directory, G_FILE_TEST_IS_DIR)) {
- eel_string_list_insert (directories, desktop_directory);
+ directories = g_slist_prepend (directories, desktop_directory);
}
- g_free (desktop_directory);
- failed_count = eel_string_list_get_length (directories);
+ if (directories != NULL) {
+ int failed_count;
+ GString *directories_as_string;
+ GSList *l;
+ char *error_string;
+ const char *detail_string;
+ GtkDialog *dialog;
+
+ ret = FALSE;
- if (failed_count != 0) {
- directories_as_string = eel_string_list_as_string (directories, ", ", EEL_STRING_LIST_ALL_STRINGS);
+ failed_count = g_slist_length (directories);
+
+ directories_as_string = g_string_new ((const char *)directories->data);
+ for (l = directories->next; l != NULL; l = l->next) {
+ g_string_append_printf (directories_as_string, ", %s", (const char *)l->data);
+ }
if (failed_count == 1) {
error_string = g_strdup_printf (_("Nautilus could not create the required folder \"%s\"."),
- directories_as_string);
+ directories_as_string->str);
detail_string = _("Before running Nautilus, please create the following folder, or "
"set permissions such that Nautilus can create it.");
} else {
error_string = g_strdup_printf (_("Nautilus could not create the following required folders: "
- "%s."), directories_as_string);
- detail_string = _("Before running Nautilus, please create these folders, or "
+ "%s."), directories_as_string->str);
+ detail_string = _("Before running Nautilus, please create these folders, or "
"set permissions such that Nautilus can create them.");
}
-
+
dialog = eel_show_error_dialog (error_string, detail_string, NULL);
/* We need the main event loop so the user has a chance to see the dialog. */
nautilus_main_event_loop_register (GTK_OBJECT (dialog));
- g_free (directories_as_string);
+ g_string_free (directories_as_string, TRUE);
g_free (error_string);
}
- eel_string_list_free (directories);
+ g_slist_free (directories);
+ g_free (user_directory);
+ g_free (desktop_directory);
- return failed_count == 0;
+ return ret;
}
static Nautilus_URIList *
@@ -308,6 +319,7 @@ nautilus_make_uri_list_from_shell_strv (const char * const *strv)
{
int length, i;
Nautilus_URIList *uri_list;
+ GFile *file;
char *translated_uri;
length = g_strv_length ((char **) strv);
@@ -317,7 +329,9 @@ nautilus_make_uri_list_from_shell_strv (const char * const *strv)
uri_list->_length = length;
uri_list->_buffer = CORBA_sequence_Nautilus_URI_allocbuf (length);
for (i = 0; i < length; i++) {
- translated_uri = gnome_vfs_make_uri_from_shell_arg (strv[i]);
+ file = g_file_new_for_commandline_arg (strv[i]);
+ translated_uri = g_file_get_uri (file);
+ g_object_unref (file);
uri_list->_buffer[i] = CORBA_string_dup (translated_uri);
g_free (translated_uri);
translated_uri = NULL;
@@ -433,7 +447,7 @@ initialize_kde_trash_hack (void)
trash_dir = NULL;
desktop_uri = nautilus_get_desktop_directory_uri_no_create ();
- desktop_dir = gnome_vfs_get_local_path_from_uri (desktop_uri);
+ desktop_dir = g_filename_from_uri (desktop_uri, NULL, NULL);
g_free (desktop_uri);
if (g_file_test (desktop_dir, G_FILE_TEST_EXISTS)) {
@@ -851,21 +865,22 @@ nautilus_application_close_all_navigation_windows (void)
}
static NautilusSpatialWindow *
-nautilus_application_get_existing_spatial_window (const char *location)
+nautilus_application_get_existing_spatial_window (GFile *location)
{
GList *l;
-
+
for (l = nautilus_application_get_spatial_window_list ();
l != NULL; l = l->next) {
- char *window_location;
-
+ GFile *window_location;
+
window_location = nautilus_window_get_location (NAUTILUS_WINDOW (l->data));
- if (window_location != NULL &&
- strcmp (location, window_location) == 0) {
- g_free (window_location);
- return NAUTILUS_SPATIAL_WINDOW (l->data);
+ if (window_location != NULL) {
+ if (g_file_equal (location, window_location)) {
+ g_object_unref (window_location);
+ return NAUTILUS_SPATIAL_WINDOW (l->data);
+ }
+ g_object_unref (window_location);
}
- g_free (window_location);
}
return NULL;
}
@@ -875,8 +890,7 @@ find_parent_spatial_window (NautilusSpatialWindow *window)
{
NautilusFile *file;
NautilusFile *parent_file;
- char *location;
- char *desktop_directory;
+ GFile *location;
location = nautilus_window_get_location (NAUTILUS_WINDOW (window));
if (location == NULL) {
@@ -888,28 +902,23 @@ find_parent_spatial_window (NautilusSpatialWindow *window)
if (!file) {
return NULL;
}
-
- desktop_directory = nautilus_get_desktop_directory_uri ();
-
+
parent_file = nautilus_file_get_parent (file);
nautilus_file_unref (file);
while (parent_file) {
NautilusSpatialWindow *parent_window;
-
- location = nautilus_file_get_uri (parent_file);
/* Stop at the desktop directory, as this is the
* conceptual root of the spatial windows */
- if (!strcmp (location, desktop_directory)) {
- g_free (location);
- g_free (desktop_directory);
+ if (nautilus_file_is_desktop_directory (parent_file)) {
nautilus_file_unref (parent_file);
return NULL;
}
+ location = nautilus_file_get_location (parent_file);
parent_window = nautilus_application_get_existing_spatial_window (location);
- g_free (location);
-
+ g_object_unref (location);
+
if (parent_window) {
nautilus_file_unref (parent_file);
return parent_window;
@@ -918,7 +927,6 @@ find_parent_spatial_window (NautilusSpatialWindow *window)
parent_file = nautilus_file_get_parent (file);
nautilus_file_unref (file);
}
- g_free (desktop_directory);
return NULL;
}
@@ -1025,7 +1033,7 @@ NautilusWindow *
nautilus_application_present_spatial_window (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
- const char *location,
+ GFile *location,
GdkScreen *screen)
{
return nautilus_application_present_spatial_window_with_selection (application,
@@ -1117,19 +1125,20 @@ NautilusWindow *
nautilus_application_present_spatial_window_with_selection (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
- const char *location,
+ GFile *location,
GList *new_selection,
GdkScreen *screen)
{
NautilusWindow *window;
GList *l;
+ char *uri;
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
-
+
for (l = nautilus_application_get_spatial_window_list ();
l != NULL; l = l->next) {
NautilusWindow *existing_window;
- char *existing_location;
+ GFile *existing_location;
existing_window = NAUTILUS_WINDOW (l->data);
existing_location = existing_window->details->pending_location;
@@ -1137,8 +1146,8 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
if (existing_location == NULL) {
existing_location = existing_window->details->location;
}
-
- if (gnome_vfs_uris_match (existing_location, location)) {
+
+ if (g_file_equal (existing_location, location)) {
#ifdef HAVE_STARTUP_NOTIFICATION
end_startup_notification (GTK_WIDGET (existing_window),
startup_id);
@@ -1150,9 +1159,11 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
nautilus_view_set_selection (existing_window->content_view, new_selection);
}
+ uri = g_file_get_uri (location);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"present EXISTING spatial window=%p: %s",
- existing_window, location);
+ existing_window, uri);
+ g_free (uri);
return existing_window;
}
}
@@ -1191,9 +1202,11 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
nautilus_window_go_to_with_selection (window, location, new_selection);
+ uri = g_file_get_uri (location);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"present NEW spatial window=%p: %s",
- window, location);
+ window, uri);
+ g_free (uri);
return window;
}
@@ -1298,16 +1311,16 @@ window_can_be_closed (NautilusWindow *window)
}
static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+volume_mounted_callback (GVolumeMonitor *monitor,
+ GVolume *volume,
NautilusApplication *application)
{
- char *activation_uri;
NautilusDirectory *directory;
+ GFile *root;
- activation_uri = gnome_vfs_volume_get_activation_uri (volume);
- directory = nautilus_directory_get_existing (activation_uri);
- g_free (activation_uri);
+ root = g_volume_get_root (volume);
+ directory = nautilus_directory_get_existing (root);
+ g_object_unref (root);
if (directory != NULL) {
nautilus_directory_force_reload (directory);
nautilus_directory_unref (directory);
@@ -1321,49 +1334,35 @@ volume_mounted_callback (GnomeVFSVolumeMonitor *monitor,
* This is also called on pre_unmount.
*/
static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *monitor,
- GnomeVFSVolume *volume,
+volume_unmounted_callback (GVolumeMonitor *monitor,
+ GVolume *volume,
NautilusApplication *application)
{
GList *window_list, *node, *close_list;
NautilusWindow *window;
- char *uri, *activation_uri, *path;
- GnomeVFSVolumeMonitor *volume_monitor;
- GnomeVFSVolume *window_volume;
-
+ GFile *root;
+
close_list = NULL;
/* Check and see if any of the open windows are displaying contents from the unmounted volume */
window_list = nautilus_application_get_window_list ();
- volume_monitor = gnome_vfs_get_volume_monitor ();
-
- activation_uri = gnome_vfs_volume_get_activation_uri (volume);
+ root = g_volume_get_root (volume);
/* 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 && window_can_be_closed (window)) {
- uri = nautilus_window_get_location (window);
- if (eel_str_has_prefix (uri, activation_uri)) {
+ GFile *location;
+
+ location = nautilus_window_get_location (window);
+
+ if (g_file_contains_file (root, location)) {
close_list = g_list_prepend (close_list, window);
- } else {
- path = gnome_vfs_get_local_path_from_uri (uri);
- if (path != NULL) {
- window_volume = gnome_vfs_volume_monitor_get_volume_for_path (volume_monitor,
- path);
- if (window_volume != NULL && window_volume == volume) {
- close_list = g_list_prepend (close_list, window);
- }
- gnome_vfs_volume_unref (window_volume);
- g_free (path);
- }
-
- }
- g_free (uri);
+ }
+ g_object_unref (location);
}
}
- g_free (activation_uri);
-
+
/* Handle the windows in the close list. */
for (node = close_list; node != NULL; node = node->next) {
window = NAUTILUS_WINDOW (node->data);
@@ -1373,11 +1372,10 @@ volume_unmounted_callback (GnomeVFSVolumeMonitor *monitor,
nautilus_window_go_home (window);
}
}
-
+
g_list_free (close_list);
}
-
static void
removed_from_session (GnomeClient *client, gpointer data)
{
@@ -1385,6 +1383,45 @@ removed_from_session (GnomeClient *client, gpointer data)
}
static char *
+icon_to_string (GIcon *icon)
+{
+ const char * const *names;
+ GFile *file;
+
+ if (icon == NULL) {
+ return NULL;
+ } else if (G_IS_THEMED_ICON (icon)) {
+ names = g_themed_icon_get_names (G_THEMED_ICON (icon));
+ return g_strjoinv (":", (char **)names);
+ } else if (G_IS_FILE_ICON (icon)) {
+ file = g_file_icon_get_file (G_FILE_ICON (icon));
+ return g_file_get_path (file);
+ }
+ return NULL;
+}
+
+static GIcon *
+icon_from_string (const char *string)
+{
+ GFile *file;
+ GIcon *icon;
+ gchar **names;
+
+ if (g_path_is_absolute (string)) {
+ file = g_file_new_for_path (string);
+ icon = g_file_icon_new (file);
+ g_object_unref (file);
+ return icon;
+ } else {
+ names = g_strsplit (string, ":", 0);
+ icon = g_themed_icon_new_from_names (names, -1);
+ g_strfreev (names);
+ return icon;
+ }
+ return NULL;
+}
+
+static char *
save_session_to_file (void)
{
xmlDocPtr doc;
@@ -1406,6 +1443,7 @@ save_session_to_file (void)
for (l = nautilus_get_history_list (); l != NULL; l = l->next) {
NautilusBookmark *bookmark;
xmlNodePtr bookmark_node;
+ GIcon *icon;
char *tmp;
bookmark = l->data;
@@ -1416,9 +1454,13 @@ save_session_to_file (void)
xmlNewProp (bookmark_node, "name", tmp);
g_free (tmp);
- tmp = nautilus_bookmark_get_icon (bookmark);
- xmlNewProp (bookmark_node, "icon", tmp);
- g_free (tmp);
+ icon = nautilus_bookmark_get_icon (bookmark);
+ tmp = icon_to_string (icon);
+ g_object_unref (icon);
+ if (tmp) {
+ xmlNewProp (bookmark_node, "icon", tmp);
+ g_free (tmp);
+ }
tmp = nautilus_bookmark_get_uri (bookmark);
xmlNewProp (bookmark_node, "uri", tmp);
@@ -1465,7 +1507,7 @@ save_session_to_file (void)
}
}
- tmp = nautilus_window_get_location (window);
+ tmp = nautilus_window_get_location_uri (window);
xmlNewProp (win_node, "location", tmp);
g_free (tmp);
}
@@ -1534,19 +1576,31 @@ nautilus_application_load_session (NautilusApplication *application,
if (!strcmp (bookmark_node->name, "text")) {
continue;
} else if (!strcmp (bookmark_node->name, "bookmark")) {
- xmlChar *name, *icon, *uri;
+ xmlChar *name, *icon_str, *uri;
gboolean has_custom_name;
+ GIcon *icon;
+ GFile *location;
uri = xmlGetProp (bookmark_node, "uri");
name = xmlGetProp (bookmark_node, "name");
has_custom_name = xmlHasProp (bookmark_node, "has_custom_name") ? TRUE : FALSE;
- icon = xmlGetProp (bookmark_node, "icon");
+ icon_str = xmlGetProp (bookmark_node, "icon");
+ icon = NULL;
+ if (icon_str) {
+ icon = icon_from_string (icon_str);
+ }
+ location = g_file_new_for_uri (uri);
- emit_change |= nautilus_add_to_history_list_no_notify (uri, name, has_custom_name, icon);
+ emit_change |= nautilus_add_to_history_list_no_notify (location, name, has_custom_name, icon);
+ g_object_unref (location);
+
+ if (icon) {
+ g_object_unref (icon);
+ }
xmlFree (name);
xmlFree (uri);
- xmlFree (icon);
+ xmlFree (icon_str);
} else {
g_message ("unexpected bookmark node %s while parsing %s", bookmark_node->name, filename);
bail = TRUE;
@@ -1559,7 +1613,8 @@ nautilus_application_load_session (NautilusApplication *application,
}
} else if (!strcmp (node->name, "window")) {
NautilusWindow *window;
- xmlChar *type, *location;
+ xmlChar *type, *location_uri;
+ GFile *location;
type = xmlGetProp (node, "type");
if (type == NULL) {
@@ -1568,8 +1623,8 @@ nautilus_application_load_session (NautilusApplication *application,
continue;
}
- location = xmlGetProp (node, "location");
- if (location == NULL) {
+ location_uri = xmlGetProp (node, "location");
+ if (location_uri == NULL) {
g_message ("empty location node while parsing %s", filename);
bail = TRUE;
xmlFree (type);
@@ -1610,16 +1665,20 @@ nautilus_application_load_session (NautilusApplication *application,
gtk_window_set_keep_above (GTK_WINDOW (window), FALSE);
}
+ location = g_file_new_for_uri (location_uri);
nautilus_window_open_location (window, location, FALSE);
+ g_object_unref (location);
} else if (!strcmp (type, "spatial")) {
+ location = g_file_new_for_uri (location_uri);
window = nautilus_application_present_spatial_window (application, NULL, NULL, location, gdk_screen_get_default ());
+ g_object_unref (location);
} else {
g_message ("unknown window type \"%s\" while parsing %s", type, filename);
bail = TRUE;
}
xmlFree (type);
- xmlFree (location);
+ xmlFree (location_uri);
} else {
g_message ("unexpected node %s while parsing %s", node->name, filename);
bail = TRUE;
@@ -1636,25 +1695,16 @@ nautilus_application_load_session (NautilusApplication *application,
if (bail) {
g_message ("failed to load session from %s", filename);
} else {
- char *uri;
- GnomeVFSFileInfo *info;
+ struct stat buf;
+
/* only remove file if it is regular, user-owned and the user has write access. */
- uri = gnome_vfs_get_uri_from_local_path (filename);
- info = gnome_vfs_file_info_new ();
- if (uri != NULL &&
- gnome_vfs_get_file_info (uri, info, GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK &&
- (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_TYPE) &&
- (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_PERMISSIONS) &&
- (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_IDS) &&
- info->type == GNOME_VFS_FILE_TYPE_REGULAR &&
- (info->permissions & (GNOME_VFS_PERM_USER_WRITE |
- GNOME_VFS_PERM_USER_WRITE)) &&
- info->uid == geteuid ()) {
+ if (g_stat (filename, &buf) == 0 &&
+ S_ISREG (buf.st_mode) &&
+ (buf.st_mode & S_IWUSR) &&
+ buf.st_uid == geteuid()) {
g_remove (filename);
}
- gnome_vfs_file_info_unref (info);
- g_free (uri);
}
}
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index cb1bbe4d6..870bbddd0 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -28,6 +28,7 @@
#define NAUTILUS_APPLICATION_H
#include <gdk/gdk.h>
+#include <gio/gvolumemonitor.h>
#include <bonobo/bonobo-generic-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
@@ -56,6 +57,7 @@ typedef struct {
NautilusUndoManager *undo_manager;
NautilusShell *shell;
gboolean shell_registered;
+ GVolumeMonitor *volume_monitor;
} NautilusApplication;
typedef struct {
@@ -82,12 +84,12 @@ unsigned int nautilus_application_get_n_windows (void);
NautilusWindow * nautilus_application_present_spatial_window (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
- const char *location,
+ GFile *location,
GdkScreen *screen);
NautilusWindow * nautilus_application_present_spatial_window_with_selection (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
- const char *location,
+ GFile *location,
GList *new_selection,
GdkScreen *screen);
diff --git a/src/nautilus-bookmark-list.c b/src/nautilus-bookmark-list.c
index d0e566289..d2ced9485 100644
--- a/src/nautilus-bookmark-list.c
+++ b/src/nautilus-bookmark-list.c
@@ -28,23 +28,13 @@
#include <config.h>
#include "nautilus-bookmark-list.h"
+#include <libnautilus-private/nautilus-file-utilities.h>
+#include <libnautilus-private/nautilus-file.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
-#include <eel/eel-xml-extensions.h>
-#include <gtk/gtksignal.h>
-#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnome/gnome-util.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <stdlib.h>
+#include <gio/gfile.h>
+#include <gio/gfilemonitor.h>
+#include <gio/gthemedicon.h>
#define MAX_BOOKMARK_LENGTH 80
@@ -59,65 +49,74 @@ static char *window_geometry;
/* forward declarations */
static void destroy (GtkObject *object);
-static char * nautilus_bookmark_list_get_file_path ();
-static void nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class);
static void nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks);
static void nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks);
-static void set_window_geometry_internal (const char *string);
-static void stop_monitoring_bookmark (NautilusBookmarkList *bookmarks,
- NautilusBookmark *bookmark);
-static void bookmark_monitor_notify_cb (GnomeVFSMonitorHandle *handle,
- const gchar *monitor_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer user_data);
+
+G_DEFINE_TYPE(NautilusBookmarkList, nautilus_bookmark_list, GTK_TYPE_OBJECT)
static NautilusBookmark *
new_bookmark_from_uri (const char *uri, const char *label)
{
NautilusBookmark *new_bookmark;
NautilusFile *file;
- char *name, *icon_name;
+ char *name;
+ GIcon *icon;
gboolean has_label;
+ GFile *location;
+ location = NULL;
+ if (uri) {
+ location = g_file_new_for_uri (uri);
+ }
+
has_label = FALSE;
if (!label) {
- name = nautilus_compute_title_for_uri (uri);
+ name = nautilus_compute_title_for_location (location);
} else {
name = g_strdup (label);
has_label = TRUE;
}
+
+ new_bookmark = NULL;
if (uri) {
- file = nautilus_file_get (uri);
- icon_name = NULL;
- if (nautilus_icon_factory_is_icon_ready_for_file (file)) {
- icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
+ file = nautilus_file_get (location);
+
+ icon = NULL;
+ if (nautilus_file_check_if_ready (file,
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
+ icon = nautilus_file_get_gicon (file, 0);
}
- if (!icon_name) {
- icon_name = g_strdup ("gnome-fs-directory");
- }
-
- new_bookmark = nautilus_bookmark_new_with_icon (uri, name, has_label, icon_name);
nautilus_file_unref (file);
- g_free (icon_name);
- g_free (name);
+
+ if (icon == NULL) {
+ icon = g_themed_icon_new ("gnome-fs-directory");
+ }
+
+ new_bookmark = nautilus_bookmark_new_with_icon (location, name, has_label, icon);
+
+ g_object_unref (icon);
- return new_bookmark;
}
-
g_free (name);
- return NULL;
+ g_object_unref (location);
+ return new_bookmark;
}
-static char *
-nautilus_bookmark_list_get_file_path (void)
+static GFile *
+nautilus_bookmark_list_get_file (void)
{
- char *file_path;
- file_path = g_build_filename (g_get_home_dir (),
- ".gtk-bookmarks",
- NULL);
- return file_path;
+ char *filename;
+ GFile *file;
+
+ filename = g_build_filename (g_get_home_dir (),
+ ".gtk-bookmarks",
+ NULL);
+ file = g_file_new_for_path (filename);
+
+ g_free (filename);
+
+ return file;
}
/* Initialization. */
@@ -143,25 +142,54 @@ nautilus_bookmark_list_class_init (NautilusBookmarkListClass *class)
}
static void
+bookmark_monitor_changed_cb (GFileMonitor *monitor,
+ GFile *child,
+ GFile *other_file,
+ GFileMonitorEvent eflags,
+ gpointer user_data)
+{
+ if (eflags == G_FILE_MONITOR_EVENT_CHANGED ||
+ eflags == G_FILE_MONITOR_EVENT_CREATED) {
+ g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (NAUTILUS_BOOKMARK_LIST (user_data)));
+ nautilus_bookmark_list_load_file (NAUTILUS_BOOKMARK_LIST (user_data));
+ g_signal_emit (user_data, signals[CONTENTS_CHANGED], 0);
+ }
+}
+
+static void
nautilus_bookmark_list_init (NautilusBookmarkList *bookmarks)
-{
-
- char *file, *uri;
- GnomeVFSResult res;
+{
+ GFile *file;
nautilus_bookmark_list_load_file (bookmarks);
- file = nautilus_bookmark_list_get_file_path ();
- uri = gnome_vfs_get_uri_from_local_path (file);
- res = gnome_vfs_monitor_add ( &bookmarks->handle,
- uri,
- GNOME_VFS_MONITOR_FILE,
- bookmark_monitor_notify_cb,
- bookmarks);
- g_free (uri);
- g_free (file);
+
+ file = nautilus_bookmark_list_get_file ();
+ bookmarks->monitor = g_file_monitor_file (file, 0, NULL);
+ g_signal_connect (bookmarks->monitor, "changed",
+ G_CALLBACK (bookmark_monitor_changed_cb), bookmarks);
+
+ g_object_unref (file);
}
-EEL_CLASS_BOILERPLATE (NautilusBookmarkList, nautilus_bookmark_list, GTK_TYPE_OBJECT)
+static void
+bookmark_in_list_changed_callback (NautilusBookmark *bookmark,
+ NautilusBookmarkList *bookmarks)
+{
+ g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
+ g_assert (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
+
+ /* Save changes so we'll have the good icon next time. */
+ nautilus_bookmark_list_contents_changed (bookmarks);
+}
+
+static void
+stop_monitoring_bookmark (NautilusBookmarkList *bookmarks,
+ NautilusBookmark *bookmark)
+{
+ g_signal_handlers_disconnect_by_func (bookmark,
+ bookmark_in_list_changed_callback,
+ bookmarks);
+}
static void
stop_monitoring_one (gpointer data, gpointer user_data)
@@ -171,7 +199,7 @@ stop_monitoring_one (gpointer data, gpointer user_data)
stop_monitoring_bookmark (NAUTILUS_BOOKMARK_LIST (user_data),
NAUTILUS_BOOKMARK (data));
-}
+}
static void
clear (NautilusBookmarkList *bookmarks)
@@ -184,39 +212,18 @@ clear (NautilusBookmarkList *bookmarks)
static void
destroy (GtkObject *object)
{
- if (NAUTILUS_BOOKMARK_LIST (object)->handle != NULL) {
- gnome_vfs_monitor_cancel (NAUTILUS_BOOKMARK_LIST (object)->handle);
- NAUTILUS_BOOKMARK_LIST (object)->handle = NULL;
+ if (NAUTILUS_BOOKMARK_LIST (object)->monitor != NULL) {
+ g_file_monitor_cancel (NAUTILUS_BOOKMARK_LIST (object)->monitor);
+ NAUTILUS_BOOKMARK_LIST (object)->monitor = NULL;
}
- clear (NAUTILUS_BOOKMARK_LIST (object));
-}
-
-
-
-static void
-bookmark_in_list_changed_callback (NautilusBookmark *bookmark,
- NautilusBookmarkList *bookmarks)
-{
- g_assert (NAUTILUS_IS_BOOKMARK (bookmark));
- g_assert (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
- /* Save changes so we'll have the good icon next time. */
- nautilus_bookmark_list_contents_changed (bookmarks);
-}
-
-static void
-stop_monitoring_bookmark (NautilusBookmarkList *bookmarks,
- NautilusBookmark *bookmark)
-{
- g_signal_handlers_disconnect_by_func (bookmark,
- bookmark_in_list_changed_callback,
- bookmarks);
+ clear (NAUTILUS_BOOKMARK_LIST (object));
}
static void
insert_bookmark_internal (NautilusBookmarkList *bookmarks,
- NautilusBookmark *bookmark,
- int index)
+ NautilusBookmark *bookmark,
+ int index)
{
bookmarks->list = g_list_insert (bookmarks->list, bookmark, index);
@@ -235,7 +242,7 @@ insert_bookmark_internal (NautilusBookmarkList *bookmarks,
**/
void
nautilus_bookmark_list_append (NautilusBookmarkList *bookmarks,
- NautilusBookmark *bookmark)
+ NautilusBookmark *bookmark)
{
g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark));
@@ -258,12 +265,12 @@ nautilus_bookmark_list_append (NautilusBookmarkList *bookmarks,
**/
gboolean
nautilus_bookmark_list_contains (NautilusBookmarkList *bookmarks,
- NautilusBookmark *bookmark)
+ NautilusBookmark *bookmark)
{
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks), FALSE);
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), FALSE);
- return g_list_find_custom (bookmarks->list,
+ return g_list_find_custom (bookmarks->list,
(gpointer)bookmark,
nautilus_bookmark_compare_with)
!= NULL;
@@ -281,11 +288,9 @@ nautilus_bookmark_list_contents_changed (NautilusBookmarkList *bookmarks)
g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
nautilus_bookmark_list_save_file (bookmarks);
- g_signal_emit (bookmarks,
- signals[CONTENTS_CHANGED], 0);
+ g_signal_emit (bookmarks, signals[CONTENTS_CHANGED], 0);
}
-
/**
* nautilus_bookmark_list_delete_item_at:
*
@@ -293,9 +298,9 @@ nautilus_bookmark_list_contents_changed (NautilusBookmarkList *bookmarks)
* @bookmarks: the list of bookmarks.
* @index: index, must be less than length of list.
**/
-void
+void
nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks,
- guint index)
+ guint index)
{
GList *doomed;
@@ -308,9 +313,9 @@ nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks,
g_assert (NAUTILUS_IS_BOOKMARK (doomed->data));
stop_monitoring_bookmark (bookmarks, NAUTILUS_BOOKMARK (doomed->data));
g_object_unref (doomed->data);
-
+
g_list_free_1 (doomed);
-
+
nautilus_bookmark_list_contents_changed (bookmarks);
}
@@ -321,9 +326,9 @@ nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks,
* @bookmarks: the list of bookmarks.
* @uri: The uri to match.
**/
-void
+void
nautilus_bookmark_list_delete_items_with_uri (NautilusBookmarkList *bookmarks,
- const char *uri)
+ const char *uri)
{
GList *node, *next;
gboolean list_changed;
@@ -352,8 +357,6 @@ nautilus_bookmark_list_delete_items_with_uri (NautilusBookmarkList *bookmarks,
}
}
-
-
/**
* nautilus_bookmark_list_get_window_geometry:
*
@@ -378,15 +381,15 @@ nautilus_bookmark_list_get_window_geometry (NautilusBookmarkList *bookmarks)
* @index: the position to insert the bookmark at.
* @new_bookmark: the bookmark to insert a copy of.
**/
-void
+void
nautilus_bookmark_list_insert_item (NautilusBookmarkList *bookmarks,
- NautilusBookmark* new_bookmark,
- guint index)
+ NautilusBookmark *new_bookmark,
+ guint index)
{
g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
g_return_if_fail (index <= g_list_length (bookmarks->list));
- insert_bookmark_internal (bookmarks,
+ insert_bookmark_internal (bookmarks,
nautilus_bookmark_copy (new_bookmark),
index);
@@ -436,24 +439,19 @@ nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks)
static void
nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks)
{
- char *filename, *contents;
- GError **error = NULL;
+ GFile *file;
+ char *contents;
+ GError *error = NULL;
- filename = nautilus_bookmark_list_get_file_path ();
+ file = nautilus_bookmark_list_get_file ();
/* Wipe out old list. */
clear (bookmarks);
- if (!g_file_test (filename,
- G_FILE_TEST_EXISTS)) {
- g_free (filename);
- return;
- }
-
- /* Read new list from file */
- if (g_file_get_contents (filename, &contents, NULL, error)) {
+ if (g_file_load_contents (file, NULL, &contents, NULL, NULL, &error)) {
char **lines;
int i;
+
lines = g_strsplit (contents, "\n", -1);
for (i = 0; lines[i]; i++) {
if (lines[i][0]) {
@@ -466,20 +464,23 @@ nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks)
if (space) {
*space = '\0';
label = g_strdup (space + 1);
- }
+ }
insert_bookmark_internal (bookmarks,
new_bookmark_from_uri (lines[i], label),
-1);
- if (label) {
- g_free (label);
- }
+ g_free (label);
}
}
g_free (contents);
g_strfreev (lines);
}
- g_free (filename);
+ else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
+ g_warning ("Could not load bookmark file: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (file);
}
/**
@@ -495,10 +496,8 @@ nautilus_bookmark_list_new (void)
NautilusBookmarkList *list;
list = NAUTILUS_BOOKMARK_LIST (g_object_new (NAUTILUS_TYPE_BOOKMARK_LIST, NULL));
- g_object_ref (list);
- gtk_object_sink (GTK_OBJECT (list));
- return list;
+ return g_object_ref_sink (list);
}
/**
@@ -510,100 +509,78 @@ nautilus_bookmark_list_new (void)
static void
nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks)
{
- char *tmp_filename, *filename;
- NautilusBookmark *bookmark;
- FILE *file;
- int fd;
- int saved_errno;
-
- filename = nautilus_bookmark_list_get_file_path ();
- tmp_filename = g_strconcat(filename, "XXXXXX", NULL);
-
- /* First, write a temporary file */
- fd = g_mkstemp (tmp_filename);
- if (fd == -1) {
- g_warning ("make %s failed", tmp_filename);
- saved_errno = errno;
- goto io_error;
- }
-
- if ((file = fdopen (fd, "w")) != NULL) {
- GList *l;
-
- for (l = bookmarks->list; l; l = l->next) {
- char *bookmark_string;
- bookmark = NAUTILUS_BOOKMARK (l->data);
-
- /* make sure we save label if it has one for compatibility with GTK 2.7 and 2.8 */
- if (nautilus_bookmark_get_has_custom_name (bookmark)) {
- char *label, *uri;
- label = nautilus_bookmark_get_name (bookmark);
- uri = nautilus_bookmark_get_uri (bookmark);
- bookmark_string = g_strconcat (uri, " ", label, NULL);
- g_free (uri);
- g_free (label);
- } else {
- bookmark_string = nautilus_bookmark_get_uri (bookmark);
- }
- if (fputs (bookmark_string, file) == EOF || fputs ("\n", file) == EOF) {
- saved_errno = errno;
- g_warning ("writing %s to file failed", bookmark_string);
- g_free (bookmark_string);
- goto io_error;
- }
- g_free (bookmark_string);
- }
+ GFile *file;
+ GOutputStream *out;
+ GError *error = NULL;
+ GList *l;
+
+ /* temporarily disable bookmark file monitoring when writing file */
+ if (bookmarks->monitor != NULL) {
+ g_file_monitor_cancel (bookmarks->monitor);
+ bookmarks->monitor = NULL;
+ }
- if (fclose (file) == EOF) {
- saved_errno = errno;
- g_warning ("fclose file failed");
- goto io_error;
- }
+ file = nautilus_bookmark_list_get_file ();
+ out = (GOutputStream *)g_file_replace (file, NULL, FALSE, 0, NULL, &error);
+ if (out == NULL) {
+ g_warning ("Error opening bookmark file: %s\n", error->message);
+ goto error;
+ }
- /* temporarily disable bookmark file monitoring when writing file */
- if (bookmarks->handle != NULL) {
- gnome_vfs_monitor_cancel (bookmarks->handle);
- bookmarks->handle = NULL;
+ for (l = bookmarks->list; l; l = l->next) {
+ NautilusBookmark *bookmark;
+ char *bookmark_string;
+
+ bookmark = NAUTILUS_BOOKMARK (l->data);
+
+ /* make sure we save label if it has one for compatibility with GTK 2.7 and 2.8 */
+ if (nautilus_bookmark_get_has_custom_name (bookmark)) {
+ char *label, *uri;
+ label = nautilus_bookmark_get_name (bookmark);
+ uri = nautilus_bookmark_get_uri (bookmark);
+ bookmark_string = g_strconcat (uri, " ", label, "\n", NULL);
+ g_free (uri);
+ g_free (label);
+ } else {
+ char *uri;
+ uri = nautilus_bookmark_get_uri (bookmark);
+ bookmark_string = g_strconcat (uri, "\n", NULL);
+ g_free (uri);
}
- if (rename (tmp_filename, filename) == -1) {
- g_warning ("rename failed");
- saved_errno = errno;
- goto io_error;
+ if (!g_output_stream_write_all (out,
+ bookmark_string,
+ strlen (bookmark_string),
+ NULL, NULL,
+ &error)) {
+ g_warning ("writing %s to bookmark file failed: %s\n",
+ bookmark_string, error->message);
+ g_free (bookmark_string);
+ goto error;
}
- goto out;
- } else {
- saved_errno = errno;
-
- /* fdopen() failed, so we can't do much error checking here anyway */
- close (fd);
- }
-
-io_error:
- g_warning ("Bookmark saving failed (%d)", saved_errno );
+ g_free (bookmark_string);
+ }
+ if (!g_output_stream_close (out, NULL, &error)) {
+ g_warning ("Error closing bookmark file: %s\n", error->message);
+ }
- if (fd != -1) {
- unlink (tmp_filename); /* again, not much error checking we can do here */
- }
+error:
+ if (error)
+ g_error_free (error);
-out:
-
/* re-enable bookmark file monitoring */
- gnome_vfs_monitor_add (&bookmarks->handle,
- filename,
- GNOME_VFS_MONITOR_FILE,
- bookmark_monitor_notify_cb,
- bookmarks);
-
- g_free (filename);
- g_free (tmp_filename);
+ bookmarks->monitor = g_file_monitor_file (file, 0, NULL);
+ g_signal_connect (bookmarks->monitor, "changed",
+ G_CALLBACK (bookmark_monitor_changed_cb), bookmarks);
+ if (out)
+ g_object_unref (out);
+ g_object_unref (file);
}
-
/**
* nautilus_bookmark_list_set_window_geometry:
*
@@ -615,36 +592,14 @@ out:
**/
void
nautilus_bookmark_list_set_window_geometry (NautilusBookmarkList *bookmarks,
- const char *geometry)
+ const char *geometry)
{
g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks));
g_return_if_fail (geometry != NULL);
- set_window_geometry_internal (geometry);
-
- nautilus_bookmark_list_save_file(bookmarks);
-}
-
-static void
-set_window_geometry_internal (const char *string)
-{
g_free (window_geometry);
- window_geometry = g_strdup (string);
-}
+ window_geometry = g_strdup (geometry);
-static void
-bookmark_monitor_notify_cb (GnomeVFSMonitorHandle *handle,
- const gchar *monitor_uri,
- const gchar *info_uri,
- GnomeVFSMonitorEventType event_type,
- gpointer user_data)
-{
- if (event_type == GNOME_VFS_MONITOR_EVENT_CHANGED ||
- event_type == GNOME_VFS_MONITOR_EVENT_CREATED) {
- g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (NAUTILUS_BOOKMARK_LIST(user_data)));
- nautilus_bookmark_list_load_file (NAUTILUS_BOOKMARK_LIST(user_data));
- g_signal_emit (user_data,
- signals[CONTENTS_CHANGED], 0);
- }
+ nautilus_bookmark_list_save_file (bookmarks);
}
diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h
index eb4854d91..1ad01aad9 100644
--- a/src/nautilus-bookmark-list.h
+++ b/src/nautilus-bookmark-list.h
@@ -29,7 +29,7 @@
#define NAUTILUS_BOOKMARK_LIST_H
#include <libnautilus-private/nautilus-bookmark.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
+#include <gio/gfilemonitor.h>
typedef struct NautilusBookmarkList NautilusBookmarkList;
typedef struct NautilusBookmarkListClass NautilusBookmarkListClass;
@@ -48,7 +48,7 @@ typedef struct NautilusBookmarkListClass NautilusBookmarkListClass;
struct NautilusBookmarkList {
GtkObject object;
GList *list;
- GnomeVFSMonitorHandle *handle;
+ GFileMonitor *monitor;
};
struct NautilusBookmarkListClass {
diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c
index 71d925b09..0989f1762 100644
--- a/src/nautilus-bookmarks-window.c
+++ b/src/nautilus-bookmarks-window.c
@@ -34,7 +34,6 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gnome-extensions.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-signal-handlers.h>
#include <gtk/gtkenums.h>
#include <gtk/gtkhbbox.h>
@@ -42,7 +41,6 @@
#include <libgnomeui/gnome-help.h>
#include <glade/glade.h>
-
/* Static variables to keep track of window state. If there were
* more than one bookmark-editing window, these would be struct or
* class fields.
@@ -385,11 +383,6 @@ create_bookmarks_window (NautilusBookmarkList *list, GObject *undo_manager_sourc
g_signal_connect (jump_button, "clicked",
G_CALLBACK (on_jump_button_clicked), undo_manager_source);
- /* Register to find out about icon theme changes */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (repopulate), window,
- G_CONNECT_SWAPPED);
-
gtk_tree_selection_set_mode (bookmark_selection, GTK_SELECTION_BROWSE);
/* Fill in list widget with bookmarks, must be after signals are wired up. */
@@ -550,7 +543,7 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen)
{
NautilusBookmark *selected;
NautilusWindow *window;
- char *uri = NULL;
+ GFile *location;
selected = get_selected_bookmark ();
@@ -558,36 +551,35 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen)
return;
}
- uri = nautilus_bookmark_get_uri (selected);
-
- if (!uri) {
+ location = nautilus_bookmark_get_location (selected);
+ if (location == NULL) {
return;
}
if (NAUTILUS_IS_NAVIGATION_WINDOW (user_data)) {
- nautilus_window_go_to (NAUTILUS_WINDOW (user_data), uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (user_data), location);
} else if (NAUTILUS_IS_SPATIAL_WINDOW (user_data)) {
window = nautilus_application_present_spatial_window (application,
NULL,
NULL,
- uri,
+ location,
screen);
} else { /* window that opened bookmarks window has been closed */
if (parent_is_browser_window || eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (application,
NULL,
screen);
- nautilus_window_go_to (window, uri);
+ nautilus_window_go_to (window, location);
} else {
window = nautilus_application_present_spatial_window (application,
NULL,
NULL,
- uri,
+ location,
screen);
}
}
- g_free (uri);
+ g_object_unref (location);
}
static void
@@ -783,15 +775,17 @@ update_bookmark_from_text (void)
GdkPixbuf *pixbuf;
guint selected_row;
GtkTreeIter iter;
+ GFile *location;
g_assert (GTK_IS_ENTRY (name_field));
g_assert (GTK_IS_ENTRY (uri_field));
- bookmark = nautilus_bookmark_new
- (gtk_entry_get_text (GTK_ENTRY (uri_field)),
- gtk_entry_get_text (GTK_ENTRY (name_field)));
-
- nautilus_bookmark_set_has_custom_name (bookmark, name_text_changed);
+ location = g_file_new_for_uri (gtk_entry_get_text (GTK_ENTRY (uri_field)));
+
+ bookmark = nautilus_bookmark_new_with_icon (location, gtk_entry_get_text (GTK_ENTRY (name_field)),
+ name_text_changed, NULL);
+
+ g_object_unref (location);
selected_row = get_selected_row ();
diff --git a/src/nautilus-connect-server-dialog-nonmain.c b/src/nautilus-connect-server-dialog-nonmain.c
index 408eb8838..3831a73a4 100644
--- a/src/nautilus-connect-server-dialog-nonmain.c
+++ b/src/nautilus-connect-server-dialog-nonmain.c
@@ -36,17 +36,20 @@ nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
GtkWidget *widget)
{
NautilusWindow *window;
+ GFile *location;
+ location = g_file_new_for_uri (uri);
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (application,
NULL,
gtk_widget_get_screen (widget));
- nautilus_window_go_to (window, uri);
+ nautilus_window_go_to (window, location);
} else {
nautilus_application_present_spatial_window (application,
NULL,
NULL,
- uri,
+ location,
gtk_widget_get_screen (widget));
}
+ g_object_unref (location);
}
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 879650485..aa939b90b 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -33,8 +33,8 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-vfs-extensions.h>
#include <libgnome/gnome-macros.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
+#include <gio/gthemedicon.h>
struct NautilusDesktopWindowDetails {
int dummy;
@@ -82,10 +82,14 @@ nautilus_desktop_window_delete_event (NautilusDesktopWindow *window)
void
nautilus_desktop_window_update_directory (NautilusDesktopWindow *window)
{
+ GFile *location;
+
g_assert (NAUTILUS_IS_DESKTOP_WINDOW (window));
NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE;
- nautilus_window_go_to (NAUTILUS_WINDOW (window), EEL_DESKTOP_URI);
+ location = g_file_new_for_uri (EEL_DESKTOP_URI);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), location);
+ g_object_unref (location);
}
static void
@@ -246,10 +250,10 @@ real_get_title (NautilusWindow *window)
return g_strdup (_("Desktop"));
}
-static char *
-real_get_icon_name (NautilusWindow *window)
+static NautilusIconInfo *
+real_get_icon (NautilusWindow *window)
{
- return g_strdup ("gnome-fs-desktop");
+ return nautilus_icon_info_lookup_from_name ("user-desktop", 48);
}
static void
@@ -268,7 +272,7 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class)
= real_add_current_location_to_history_list;
NAUTILUS_WINDOW_CLASS (class)->get_title
= real_get_title;
- NAUTILUS_WINDOW_CLASS (class)->get_icon_name
- = real_get_icon_name;
+ NAUTILUS_WINDOW_CLASS (class)->get_icon
+ = real_get_icon;
}
diff --git a/src/nautilus-emblem-sidebar.c b/src/nautilus-emblem-sidebar.c
index 9cfdc180e..5d7c970ff 100644
--- a/src/nautilus-emblem-sidebar.c
+++ b/src/nautilus-emblem-sidebar.c
@@ -39,7 +39,6 @@
#include <eel/eel-labeled-image.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-gdk-pixbuf-extensions.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtkdnd.h>
@@ -59,9 +58,7 @@
#include <glib/gi18n.h>
#include <libgnomeui/gnome-uidefs.h>
#include <libgnomeui/gnome-popup-menu.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <gconf/gconf-client.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
#include <libnautilus-private/nautilus-emblem-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
@@ -456,23 +453,26 @@ create_emblem_widget (NautilusEmblemSidebar *emblem_sidebar,
const char *name)
{
GtkWidget *ret;
- char *display_name, *keyword;
+ const char *display_name;
+ char *keyword;
GdkPixbuf *pixbuf;
-
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name (name, NULL,
- NAUTILUS_ICON_SIZE_STANDARD, TRUE,
- &display_name);
+ NautilusIconInfo *info;
+
+ info = nautilus_icon_info_lookup_from_name (name, NAUTILUS_ICON_SIZE_STANDARD);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_ICON_SIZE_STANDARD);
+
+ display_name = nautilus_icon_info_get_display_name (info);
+
keyword = nautilus_emblem_get_keyword_from_icon_name (name);
if (display_name == NULL) {
- display_name = g_strdup (keyword);
+ display_name = keyword;
}
ret = create_emblem_widget_with_pixbuf (emblem_sidebar, keyword,
display_name, pixbuf);
g_free (keyword);
- g_free (display_name);
-
+ g_object_unref (info);
return ret;
}
@@ -727,12 +727,14 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
Emblem *emblem;
GdkPixbuf *pixbuf;
char *uri, *error, *uri_utf8;
- GList *uris, *l;
+ char **uris;
+ GFile *f;
+ int i;
gboolean had_failure;
had_failure = FALSE;
emblems = NULL;
-
+
switch (info) {
case TARGET_URI_LIST:
if (data->format != 8 ||
@@ -742,36 +744,36 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
return;
}
- uris = nautilus_icon_dnd_uri_list_extract_uris (data->data);
- l = uris;
- while (l != NULL) {
- uri = eel_make_uri_canonical (l->data);
- l = l->next;
-
- if (uri == NULL) {
- had_failure = TRUE;
- continue;
- }
+ uris = g_uri_list_extract_uris (data->data);
+ if (uris == NULL) {
+ break;
+ }
- pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri);
+ for (i = 0; uris[i] != NULL; ++i) {
+ f = g_file_new_for_uri (uris[i]);
+ pixbuf = nautilus_emblem_load_pixbuf_for_emblem (f);
if (pixbuf == NULL) {
/* this one apparently isn't an image, or
* at least not one that we know how to read
*/
had_failure = TRUE;
+ g_object_unref (f);
continue;
}
emblem = g_new (Emblem, 1);
- emblem->uri = uri;
+ emblem->uri = g_file_get_uri (f);
emblem->name = NULL; /* created later on by the user */
emblem->keyword = NULL;
emblem->pixbuf = pixbuf;
+
+ g_object_unref (f);
emblems = g_slist_prepend (emblems, emblem);
}
- nautilus_icon_dnd_uri_list_free_strings (uris);
+
+ g_strfreev (uris);
if (had_failure && emblems != NULL) {
eel_show_error_dialog (_("Some of the files could not be added as emblems."), _("The emblems do not appear to be valid images."), NULL);
@@ -796,12 +798,8 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
uri = g_strndup (data->data, data->length);
- if (!eel_is_valid_uri (uri)) {
- eel_show_error_dialog (_("The emblem cannot be added."), _("The dragged text was not a valid file location."), NULL);
- break;
- }
-
- pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri);
+ f = g_file_new_for_uri (uri);
+ pixbuf = nautilus_emblem_load_pixbuf_for_emblem (f);
if (pixbuf != NULL) {
emblem = g_new (Emblem, 1);
@@ -814,7 +812,7 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
show_add_emblems_dialog (emblem_sidebar, emblems);
} else {
- uri_utf8 = eel_format_uri_for_display (uri);
+ uri_utf8 = g_file_get_parse_name (f);
if (uri_utf8) {
error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri_utf8);
@@ -827,6 +825,7 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
g_free (uri_utf8);
}
+ g_object_unref (f);
g_free (uri);
break;
@@ -842,20 +841,21 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
/* apparently, this is a URI/title pair? or just a pair
* of identical URIs? Regardless, this seems to work...
*/
- uris = nautilus_icon_dnd_uri_list_extract_uris (data->data);
+ uris = g_uri_list_extract_uris (data->data);
if (uris == NULL) {
break;
}
-
- uri = uris->data;
+ uri = uris[0];
if (uri == NULL) {
- nautilus_icon_dnd_uri_list_free_strings (uris);
+ g_strfreev (uris);
break;
}
- pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri);
+ f = g_file_new_for_uri (uri);
+ pixbuf = nautilus_emblem_load_pixbuf_for_emblem (f);
+ g_object_unref (f);
if (pixbuf != NULL) {
emblem = g_new (Emblem, 1);
@@ -874,6 +874,9 @@ nautilus_emblem_sidebar_drag_received_cb (GtkWidget *widget,
eel_show_error_dialog (_("The emblem cannot be added."), error, NULL);
g_free (error);
}
+
+ g_strfreev (uris);
+
break;
}
}
@@ -945,7 +948,7 @@ nautilus_emblem_sidebar_populate (NautilusEmblemSidebar *emblem_sidebar)
}
- icons = nautilus_emblem_list_availible ();
+ icons = nautilus_emblem_list_available ();
l = icons;
widgets = NULL;
diff --git a/src/nautilus-file-management-properties.c b/src/nautilus-file-management-properties.c
index 1d308f67f..4099ddfb1 100644
--- a/src/nautilus-file-management-properties.c
+++ b/src/nautilus-file-management-properties.c
@@ -44,7 +44,6 @@
#include <eel/eel-gconf-extensions.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-preferences-glade.h>
-#include <eel/eel-string-list.h>
#include <libnautilus-private/nautilus-column-chooser.h>
#include <libnautilus-private/nautilus-column-utilities.h>
@@ -162,17 +161,6 @@ static const char * const icon_captions_components[] = {
NULL
};
-static GladeXML *
-nautilus_file_management_properties_dialog_create (void)
-{
- GladeXML *xml_dialog;
-
- xml_dialog = glade_xml_new (GLADEDIR "/nautilus-file-management-properties.glade",
- NULL, NULL);
-
- return xml_dialog;
-}
-
static void
nautilus_file_management_properties_size_group_create (GladeXML *xml_dialog,
char *prefix,
@@ -267,18 +255,25 @@ static void
columns_changed_callback (NautilusColumnChooser *chooser,
gpointer callback_data)
{
- GList *visible_columns;
- GList *column_order;
-
+ char **visible_columns;
+ char **column_order;
+
nautilus_column_chooser_get_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
&visible_columns,
&column_order);
- eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS, visible_columns);
- eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER, column_order);
+ eel_preferences_set_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS, visible_columns);
+ eel_preferences_set_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER, column_order);
- eel_g_list_free_deep (visible_columns);
- eel_g_list_free_deep (column_order);
+ g_strfreev (visible_columns);
+ g_strfreev (column_order);
+}
+
+static void
+free_column_names_array (GPtrArray *column_names)
+{
+ g_ptr_array_foreach (column_names, (GFunc) g_free, NULL);
+ g_ptr_array_free (column_names, TRUE);
}
static void
@@ -286,12 +281,12 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box,
GList *columns)
{
GList *l;
- EelStringList *column_names;
+ GPtrArray *column_names;
+
+ column_names = g_ptr_array_new ();
- column_names = eel_string_list_new (FALSE);
-
gtk_combo_box_append_text (combo_box, _("None"));
- eel_string_list_insert (column_names, "none");
+ g_ptr_array_add (column_names, g_strdup ("none"));
for (l = columns; l != NULL; l = l->next) {
NautilusColumn *column;
@@ -299,7 +294,7 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box,
char *label;
column = NAUTILUS_COLUMN (l->data);
-
+
g_object_get (G_OBJECT (column),
"name", &name, "label", &label,
NULL);
@@ -310,48 +305,50 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box,
g_free (label);
continue;
}
-
+
gtk_combo_box_append_text (combo_box, label);
- eel_string_list_insert (column_names, name);
+ g_ptr_array_add (column_names, name);
- g_free (name);
g_free (label);
}
g_object_set_data_full (G_OBJECT (combo_box), "column_names",
column_names,
- (GDestroyNotify) eel_string_list_free);
+ (GDestroyNotify) free_column_names_array);
}
static void
icon_captions_changed_callback (GtkComboBox *combo_box,
gpointer user_data)
{
- GList *captions;
+ GPtrArray *captions;
GladeXML *xml;
int i;
xml = GLADE_XML (user_data);
- captions = NULL;
+ captions = g_ptr_array_new ();
for (i = 0; icon_captions_components[i] != NULL; i++) {
GtkWidget *combo_box;
int active;
- EelStringList *column_names;
+ GPtrArray *column_names;
char *name;
-
+
combo_box = glade_xml_get_widget
(GLADE_XML (xml), icon_captions_components[i]);
active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo_box));
- column_names = g_object_get_data (G_OBJECT (combo_box), "column_names");
-
- name = eel_string_list_nth (column_names, active);
- captions = g_list_prepend (captions, name);
+ column_names = g_object_get_data (G_OBJECT (combo_box),
+ "column_names");
+
+ name = g_ptr_array_index (column_names, active);
+ g_ptr_array_add (captions, name);
}
- captions = g_list_reverse (captions);
- eel_preferences_set_string_glist (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS, captions);
- eel_g_list_free_deep (captions);
+ g_ptr_array_add (captions, NULL);
+
+ eel_preferences_set_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
+ (char **)captions->pdata);
+ g_ptr_array_free (captions, TRUE);
}
static void
@@ -361,8 +358,8 @@ update_caption_combo_box (GladeXML *xml,
{
GtkWidget *combo_box;
int i;
- EelStringList *column_names;
-
+ GPtrArray *column_names;
+
combo_box = glade_xml_get_widget (xml, combo_box_name);
g_signal_handlers_block_by_func
@@ -373,8 +370,8 @@ update_caption_combo_box (GladeXML *xml,
column_names = g_object_get_data (G_OBJECT (combo_box),
"column_names");
- for (i = 0; i < eel_string_list_get_length (column_names); i++) {
- if (!strcmp (name, eel_string_list_peek_nth (column_names, i))) {
+ for (i = 0; i < column_names->len; ++i) {
+ if (!strcmp (name, g_ptr_array_index (column_names, i))) {
gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), i);
break;
}
@@ -389,28 +386,29 @@ update_caption_combo_box (GladeXML *xml,
static void
update_icon_captions_from_gconf (GladeXML *xml)
{
- GList *captions;
- int i;
- GList *l;
- char *data;
+ char **captions;
+ int i, j;
- captions = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
+ captions = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS);
- for (l = captions, i = 0;
+ for (i = 0, j = 0;
icon_captions_components[i] != NULL;
i++) {
- if (l != NULL) {
- data = l->data;
- l = l->next;
+ char *data;
+
+ if (captions[j]) {
+ data = captions[j];
+ ++j;
} else {
data = "none";
}
-
+
update_caption_combo_box (xml,
icon_captions_components[i],
data);
}
- eel_g_list_free_deep (captions);
+
+ g_strfreev (captions);
}
static void
@@ -472,19 +470,18 @@ create_date_format_menu (GladeXML *xml_dialog)
static void
set_columns_from_gconf (NautilusColumnChooser *chooser)
{
- GList *visible_columns;
- GList *column_order;
+ char **visible_columns;
+ char **column_order;
- visible_columns = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
- column_order = eel_preferences_get_string_glist (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
+ visible_columns = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_VISIBLE_COLUMNS);
+ column_order = eel_preferences_get_string_array (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_COLUMN_ORDER);
nautilus_column_chooser_set_settings (NAUTILUS_COLUMN_CHOOSER (chooser),
visible_columns,
column_order);
-
- eel_g_list_free_deep (visible_columns);
- eel_g_list_free_deep (column_order);
+ g_strfreev (visible_columns);
+ g_strfreev (column_order);
}
static void
@@ -665,7 +662,8 @@ nautilus_file_management_properties_dialog_show (GCallback close_callback, GtkWi
{
GladeXML *xml_dialog;
- xml_dialog = nautilus_file_management_properties_dialog_create ();
+ xml_dialog = glade_xml_new (GLADEDIR "/nautilus-file-management-properties.glade",
+ NULL, NULL);
g_signal_connect (G_OBJECT (glade_xml_get_widget (xml_dialog, "file_management_dialog")),
"response", close_callback, NULL);
@@ -673,4 +671,6 @@ nautilus_file_management_properties_dialog_show (GCallback close_callback, GtkWi
"delete_event", G_CALLBACK (delete_event_callback), close_callback);
nautilus_file_management_properties_dialog_setup (xml_dialog, window);
+
+ g_object_unref (xml_dialog);
}
diff --git a/src/nautilus-history-sidebar.c b/src/nautilus-history-sidebar.c
index 5335cff0e..61a30b3e5 100644
--- a/src/nautilus-history-sidebar.c
+++ b/src/nautilus-history-sidebar.c
@@ -145,7 +145,7 @@ row_activated_callback (GtkTreeView *tree_view,
GtkTreeModel *model;
GtkTreeIter iter;
NautilusBookmark *bookmark;
- char *uri;
+ GFile *location;
sidebar = NAUTILUS_HISTORY_SIDEBAR (user_data);
model = gtk_tree_view_get_model (tree_view);
@@ -158,11 +158,11 @@ row_activated_callback (GtkTreeView *tree_view,
(model, &iter, HISTORY_SIDEBAR_COLUMN_BOOKMARK, &bookmark, -1);
/* Navigate to the clicked location. */
- uri = nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (bookmark));
+ location = nautilus_bookmark_get_location (NAUTILUS_BOOKMARK (bookmark));
nautilus_window_info_open_location
(sidebar->window,
- uri, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0, NULL);
- g_free (uri);
+ location, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0, NULL);
+ g_object_unref (location);
}
static void
diff --git a/src/nautilus-image-properties-page.c b/src/nautilus-image-properties-page.c
index 87441035b..7988a03f8 100644
--- a/src/nautilus-image-properties-page.c
+++ b/src/nautilus-image-properties-page.c
@@ -30,8 +30,8 @@
#include <gtk/gtklabel.h>
#include <libgnome/gnome-macros.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <eel/eel-gnome-extensions.h>
+#include <gio/gfile.h>
+#include <eel/eel-vfs-extensions.h>
#include <libnautilus-extension/nautilus-property-page-provider.h>
#include <libnautilus-private/nautilus-module.h>
#include <string.h>
@@ -40,32 +40,17 @@
#include <libexif/exif-data.h>
#include <libexif/exif-ifd.h>
#include <libexif/exif-loader.h>
- #define ENABLE_METADATA 1
#endif
#ifdef HAVE_EXEMPI
#include <exempi/xmp.h>
#include <exempi/xmpconsts.h>
- #include <libgnomevfs/gnome-vfs-utils.h>
- #if !defined(ENABLE_METADATA)
- #define ENABLE_METADATA 1
- #endif
-#endif
-
-#ifdef ENABLE_METADATA
- #include <gtk/gtkliststore.h>
- #include <gtk/gtktreestore.h>
- #include <gtk/gtktreeview.h>
- #include <gtk/gtkscrolledwindow.h>
- #include <gtk/gtkcellrenderertext.h>
- #include <eel/eel-vfs-extensions.h>
#endif
#define LOAD_BUFFER_SIZE 8192
struct NautilusImagePropertiesPageDetails {
- char *location;
+ GCancellable *cancellable;
GtkWidget *resolution;
- GnomeVFSAsyncHandle *vfs_handle;
GdkPixbufLoader *loader;
gboolean got_size;
gboolean pixbuf_still_loading;
@@ -101,8 +86,6 @@ typedef struct {
} NautilusImagePropertiesPageProviderClass;
-static GObjectClass *parent_class = NULL;
-
static GType nautilus_image_properties_page_provider_get_type (void);
static void property_page_provider_iface_init (NautilusPropertyPageProviderIface *iface);
@@ -120,23 +103,30 @@ nautilus_image_properties_page_finalize (GObject *object)
page = NAUTILUS_IMAGE_PROPERTIES_PAGE (object);
- if (page->details->vfs_handle != NULL) {
- gnome_vfs_async_cancel (page->details->vfs_handle);
+ if (page->details->cancellable) {
+ g_cancellable_cancel (page->details->cancellable);
+ g_object_unref (page->details->cancellable);
+ page->details->cancellable = NULL;
}
-
- page->details->vfs_handle = NULL;
- g_free (page->details->location);
- g_free (page->details);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_image_properties_page_parent_class)->finalize (object);
}
static void
-file_closed_callback (GnomeVFSAsyncHandle *handle,
- GnomeVFSResult result,
- gpointer callback_data)
+file_close_callback (GObject *object,
+ GAsyncResult *res,
+ gpointer data)
{
+ NautilusImagePropertiesPage *page;
+ GInputStream *stream;
+
+ page = NAUTILUS_IMAGE_PROPERTIES_PAGE (data);
+ stream = G_INPUT_STREAM (object);
+
+ g_input_stream_close_finish (stream, res, NULL);
+
+ g_object_unref (page->details->cancellable);
+ page->details->cancellable = NULL;
}
#ifdef HAVE_EXIF
@@ -209,11 +199,14 @@ exifdata_get_tag_value_utf8 (ExifData *data, ExifTag tag)
}
static gboolean
-append_tag_value_pair (GString *string, ExifData *data, ExifTag tag, gchar *description)
+append_tag_value_pair (GString *string,
+ ExifData *data,
+ ExifTag tag,
+ char *description)
{
char *utf_attribute;
char *utf_value;
-
+
utf_attribute = exifdata_get_tag_name_utf8 (tag);
utf_value = exifdata_get_tag_value_utf8 (data, tag);
@@ -223,7 +216,9 @@ append_tag_value_pair (GString *string, ExifData *data, ExifTag tag, gchar *desc
return FALSE;
}
- g_string_append_printf (string, "<b>%s:</b> %s\n", (description != NULL) ? description : utf_attribute, utf_value);
+ g_string_append_printf (string, "<b>%s:</b> %s\n",
+ description ? description : utf_attribute,
+ utf_value);
g_free (utf_attribute);
g_free (utf_value);
@@ -254,36 +249,51 @@ append_exifdata_string (ExifData *exifdata, GString *string)
append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_PROGRAM, _("Exposure Program"));
append_tag_value_pair (string, exifdata, EXIF_TAG_FOCAL_LENGTH,_("Focal Length"));
append_tag_value_pair (string, exifdata, EXIF_TAG_SOFTWARE, _("Software"));
-
}
}
#endif /*HAVE_EXIF*/
-
#ifdef HAVE_EXEMPI
static void
-append_xmp_value_pair(GString *string, XmpPtr xmp, const char * ns, const char * propname, gchar* descr)
+append_xmp_value_pair (GString *string,
+ XmpPtr xmp,
+ const char *ns,
+ const char *propname,
+ char *descr)
{
uint32_t options;
- XmpStringPtr value = xmp_string_new();
- if(xmp_get_property_and_bits(xmp, ns, propname, value, &options)) {
- if(XMP_IS_PROP_SIMPLE(options)) {
- g_string_append_printf(string, "<b>%s:</b> %s\n", descr, xmp_string_cstr(value));
+ XmpStringPtr value;
+
+ value = xmp_string_new();
+#ifdef HAVE_EXEMPI_NEW_API
+ if (xmp_get_property (xmp, ns, propname, value, &options)) {
+#else
+ if (xmp_get_property_and_bits (xmp, ns, propname, value, &options)) {
+#endif
+ if (XMP_IS_PROP_SIMPLE (options)) {
+ g_string_append_printf (string,
+ "<b>%s:</b> %s\n",
+ descr,
+ xmp_string_cstr (value));
}
- else if(XMP_IS_PROP_ARRAY(options)) {
- XmpIteratorPtr iter = xmp_iterator_new(xmp, ns, propname, XMP_ITER_JUSTLEAFNODES);
- if(iter) {
- bool first = true;
- g_string_append_printf(string, "<b>%s:</b> ", descr);
- while (xmp_iterator_next(iter, NULL, NULL, value, &options)
+ else if (XMP_IS_PROP_ARRAY (options)) {
+ XmpIteratorPtr iter;
+
+ iter = xmp_iterator_new (xmp, ns, propname, XMP_ITER_JUSTLEAFNODES);
+ if (iter) {
+ gboolean first = TRUE;
+ g_string_append_printf (string, "<b>%s:</b> ", descr);
+ while (xmp_iterator_next (iter, NULL, NULL, value, &options)
&& !XMP_IS_PROP_QUALIFIER(options)) {
- if(!first) {
- g_string_append_printf(string, ", ");
+ if (!first) {
+ g_string_append_printf (string, ", ");
}
else {
- first = false;
+ first = FALSE;
}
- g_string_append_printf(string, "%s", xmp_string_cstr(value));
+ g_string_append_printf (string,
+ "%s",
+ xmp_string_cstr(value));
}
xmp_iterator_free(iter);
g_string_append_printf(string, "\n");
@@ -293,7 +303,6 @@ append_xmp_value_pair(GString *string, XmpPtr xmp, const char * ns, const char *
xmp_string_free(value);
}
-
static void
append_xmpdata_string(XmpPtr xmp, GString *string)
{
@@ -309,7 +318,6 @@ append_xmpdata_string(XmpPtr xmp, GString *string)
}
#endif
-
static void
load_finished (NautilusImagePropertiesPage *page)
{
@@ -367,56 +375,75 @@ load_finished (NautilusImagePropertiesPage *page)
page->details->xmp = NULL;
}
#endif
-
- if (page->details->vfs_handle != NULL) {
- gnome_vfs_async_close (page->details->vfs_handle, file_closed_callback, NULL);
- page->details->vfs_handle = NULL;
- }
}
static void
-file_read_callback (GnomeVFSAsyncHandle *vfs_handle,
- GnomeVFSResult result,
- gpointer buffer,
- GnomeVFSFileSize bytes_requested,
- GnomeVFSFileSize bytes_read,
- gpointer callback_data)
+file_read_callback (GObject *object,
+ GAsyncResult *res,
+ gpointer data)
{
NautilusImagePropertiesPage *page;
-#ifdef HAVE_EXIF
+ GInputStream *stream;
+ gssize count_read;
+ GError *error;
int exif_still_loading;
-#endif
+ gboolean done_reading;
- page = NAUTILUS_IMAGE_PROPERTIES_PAGE (callback_data);
+ page = NAUTILUS_IMAGE_PROPERTIES_PAGE (data);
+ stream = G_INPUT_STREAM (object);
+
+ error = NULL;
+ done_reading = FALSE;
+ count_read = g_input_stream_read_finish (stream, res, &error);
+
+ if (count_read > 0) {
+
+ g_assert (count_read <= sizeof(page->details->buffer));
- if (result == GNOME_VFS_OK && bytes_read != 0) {
#ifdef HAVE_EXIF
exif_still_loading = exif_loader_write (page->details->exifldr,
- buffer,
- bytes_read);
+ page->details->buffer,
+ count_read);
+#else
+ exif_still_loading = 0;
#endif
+
if (page->details->pixbuf_still_loading) {
if (!gdk_pixbuf_loader_write (page->details->loader,
- buffer,
- bytes_read,
+ page->details->buffer,
+ count_read,
NULL)) {
page->details->pixbuf_still_loading = FALSE;
}
}
- if (page->details->pixbuf_still_loading
-#ifdef HAVE_EXIF
- || (exif_still_loading == 1)
-#endif
- ) {
- gnome_vfs_async_read (page->details->vfs_handle,
- page->details->buffer,
- sizeof (page->details->buffer),
- file_read_callback,
- page);
- return;
+
+ if (page->details->pixbuf_still_loading ||
+ (exif_still_loading == 1)) {
+ g_input_stream_read_async (G_INPUT_STREAM (stream),
+ page->details->buffer,
+ sizeof (page->details->buffer),
+ 0,
+ page->details->cancellable,
+ file_read_callback,
+ page);
+ }
+ else {
+ done_reading = TRUE;
}
}
- load_finished (page);
+ else {
+ /* either EOF, cancelled or an error occurred */
+ done_reading = TRUE;
+ }
+
+ if (done_reading) {
+ load_finished (page);
+ g_input_stream_close_async (stream,
+ 0,
+ page->details->cancellable,
+ file_close_callback,
+ page);
+ }
}
static void
@@ -428,7 +455,7 @@ size_prepared_callback (GdkPixbufLoader *loader,
NautilusImagePropertiesPage *page;
page = NAUTILUS_IMAGE_PROPERTIES_PAGE (callback_data);
-
+
page->details->height = height;
page->details->width = width;
page->details->got_size = TRUE;
@@ -436,60 +463,71 @@ size_prepared_callback (GdkPixbufLoader *loader,
}
static void
-file_opened_callback (GnomeVFSAsyncHandle *vfs_handle,
- GnomeVFSResult result,
- gpointer callback_data)
+file_open_callback (GObject *object,
+ GAsyncResult *res,
+ gpointer data)
{
NautilusImagePropertiesPage *page;
-
- page = NAUTILUS_IMAGE_PROPERTIES_PAGE (callback_data);
-
- if (result != GNOME_VFS_OK) {
- page->details->vfs_handle = NULL;
- return;
- }
-
- page->details->loader = gdk_pixbuf_loader_new ();
- page->details->pixbuf_still_loading = TRUE;
- page->details->width = 0;
- page->details->height = 0;
+ GFile *file;
+ GFileInputStream *stream;
+ GError *error;
+
+ page = NAUTILUS_IMAGE_PROPERTIES_PAGE (data);
+ file = G_FILE (object);
+
+ error = NULL;
+ stream = g_file_read_finish (file, res, &error);
+ if (stream) {
+ page->details->loader = gdk_pixbuf_loader_new ();
+ page->details->pixbuf_still_loading = TRUE;
+ page->details->width = 0;
+ page->details->height = 0;
#ifdef HAVE_EXIF
- page->details->exifldr = exif_loader_new ();
+ page->details->exifldr = exif_loader_new ();
#endif /*HAVE_EXIF*/
- g_signal_connect (page->details->loader, "size_prepared",
- G_CALLBACK (size_prepared_callback), page);
-
- gnome_vfs_async_read (vfs_handle,
- page->details->buffer,
- sizeof (page->details->buffer),
- file_read_callback,
- page);
-}
+ g_signal_connect (page->details->loader,
+ "size_prepared",
+ G_CALLBACK (size_prepared_callback),
+ page);
+ g_input_stream_read_async (G_INPUT_STREAM (stream),
+ page->details->buffer,
+ sizeof (page->details->buffer),
+ 0,
+ page->details->cancellable,
+ file_read_callback,
+ page);
+
+ g_object_unref (stream);
+ }
+}
static void
load_location (NautilusImagePropertiesPage *page,
- const char *location)
+ const char *location)
{
+ GFile *file;
+
g_assert (NAUTILUS_IS_IMAGE_PROPERTIES_PAGE (page));
g_assert (location != NULL);
- if (page->details->vfs_handle != NULL)
- gnome_vfs_async_cancel (page->details->vfs_handle);
+ page->details->cancellable = g_cancellable_new ();
+ file = g_file_new_for_uri (location);
#ifdef HAVE_EXEMPI
{
/* Current Exempi does not support setting custom IO to be able to use Gnome-vfs */
/* So it will only work with local files. Future version might remove this limitation */
XmpFilePtr xf;
- gchar* localname;
- localname = gnome_vfs_get_local_path_from_uri (location);
- if(localname) {
- xf = xmp_files_open_new(localname, 0);
- page->details->xmp = xmp_files_get_new_xmp(xf); /* only load when loading */
- xmp_files_close(xf, 0);
- g_free(localname);
+ char *localname;
+
+ localname = g_filename_from_uri (location, NULL, NULL);
+ if (localname) {
+ xf = xmp_files_open_new (localname, 0);
+ page->details->xmp = xmp_files_get_new_xmp (xf); /* only load when loading */
+ xmp_files_close (xf, 0);
+ g_free (localname);
}
else {
page->details->xmp = NULL;
@@ -497,26 +535,33 @@ load_location (NautilusImagePropertiesPage *page,
}
#endif /*HAVE_EXEMPI*/
- gnome_vfs_async_open (&page->details->vfs_handle,
- location,
- GNOME_VFS_OPEN_READ,
- -2,
- file_opened_callback,
- page);
+ g_file_read_async (file,
+ 0,
+ page->details->cancellable,
+ file_open_callback,
+ page);
+
+ g_object_unref (file);
}
static void
nautilus_image_properties_page_class_init (NautilusImagePropertiesPageClass *class)
{
- parent_class = g_type_class_peek_parent (class);
-
- G_OBJECT_CLASS (class)->finalize = nautilus_image_properties_page_finalize;
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (class);
+
+ object_class->finalize = nautilus_image_properties_page_finalize;
+
+ g_type_class_add_private (object_class, sizeof(NautilusImagePropertiesPageDetails));
}
static void
nautilus_image_properties_page_init (NautilusImagePropertiesPage *page)
{
- page->details = g_new0 (NautilusImagePropertiesPageDetails, 1);
+ page->details = G_TYPE_INSTANCE_GET_PRIVATE (page,
+ NAUTILUS_TYPE_IMAGE_PROPERTIES_PAGE,
+ NautilusImagePropertiesPageDetails);
gtk_box_set_homogeneous (GTK_BOX (page), FALSE);
gtk_box_set_spacing (GTK_BOX (page), 2);
@@ -581,10 +626,11 @@ get_property_pages (NautilusPropertyPageProvider *provider,
pages = NULL;
uri = nautilus_file_info_get_uri (file);
-
+
page = g_object_new (nautilus_image_properties_page_get_type (), NULL);
- page->details->location = uri;
- load_location (page, page->details->location);
+ load_location (page, uri);
+
+ g_free (uri);
real_page = nautilus_property_page_new
("NautilusImagePropertiesPage::property_page",
diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c
index be174f142..a473f0360 100644
--- a/src/nautilus-information-panel.c
+++ b/src/nautilus-information-panel.c
@@ -40,10 +40,6 @@
#include <gtk/gtkhbox.h>
#include <glib/gi18n.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-dnd.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-file-dnd.h>
@@ -63,7 +59,6 @@ struct NautilusInformationPanelDetails {
GtkHBox *button_box_centerer;
GtkVBox *button_box;
gboolean has_buttons;
- char *uri;
NautilusFile *file;
guint file_changed_connection;
gboolean background_connected;
@@ -298,7 +293,6 @@ nautilus_information_panel_finalize (GObject *object)
nautilus_file_unref (information_panel->details->file);
}
- g_free (information_panel->details->uri);
g_free (information_panel->details->default_background_color);
g_free (information_panel->details->default_background_image);
g_free (information_panel->details->current_background_color);
@@ -441,7 +435,7 @@ uri_is_local_image (const char *uri)
GdkPixbuf *pixbuf;
char *image_path;
- image_path = gnome_vfs_get_local_path_from_uri (uri);
+ image_path = g_filename_from_uri (uri, NULL, NULL);
if (image_path == NULL) {
return FALSE;
}
@@ -516,7 +510,10 @@ receive_dropped_uri_list (NautilusInformationPanel *information_panel,
NULL);
}
} else {
- if (eel_is_remote_uri (uris[0])) {
+ GFile *f;
+
+ f = g_file_new_for_uri (uris[0]);
+ if (!g_file_is_native (f)) {
eel_show_error_dialog (
_("The file that you dropped is not local."),
_("You can only use local images as custom icons."),
@@ -528,6 +525,7 @@ receive_dropped_uri_list (NautilusInformationPanel *information_panel,
_("You can only use images as custom icons."),
window);
}
+ g_object_unref (f);
}
break;
}
@@ -795,25 +793,18 @@ nautilus_information_panel_get_window (NautilusInformationPanel *information_pan
}
static void
-command_button_callback (GtkWidget *button, char *id_str)
+command_button_callback (GtkWidget *button, GAppInfo *application)
{
NautilusInformationPanel *information_panel;
- GnomeVFSMimeApplication *application;
GList files;
information_panel = NAUTILUS_INFORMATION_PANEL (g_object_get_data (G_OBJECT (button), "user_data"));
- application = gnome_vfs_mime_application_new_from_desktop_id (id_str);
-
- if (application != NULL) {
- files.next = NULL;
- files.prev = NULL;
- files.data = information_panel->details->file;
- nautilus_launch_application (application, &files,
- nautilus_information_panel_get_window (information_panel));
-
- gnome_vfs_mime_application_free (application);
- }
+ files.next = NULL;
+ files.prev = NULL;
+ files.data = information_panel->details->file;
+ nautilus_launch_application (application, &files,
+ nautilus_information_panel_get_window (information_panel));
}
/* interpret commands for buttons specified by metadata. Handle some built-in ones explicitly, or fork
@@ -832,10 +823,10 @@ metadata_button_callback (GtkWidget *button, const char *command_str)
static void
add_command_buttons (NautilusInformationPanel *information_panel, GList *application_list)
{
- char *id_string, *temp_str;
+ char *temp_str;
GList *p;
GtkWidget *temp_button, *label;
- GnomeVFSMimeApplication *application;
+ GAppInfo *application;
/* There's always at least the "Open with..." button */
information_panel->details->has_buttons = TRUE;
@@ -843,7 +834,7 @@ add_command_buttons (NautilusInformationPanel *information_panel, GList *applica
for (p = application_list; p != NULL; p = p->next) {
application = p->data;
- temp_str = g_strdup_printf (_("Open with %s"), application->name);
+ temp_str = g_strdup_printf (_("Open with %s"), g_app_info_get_name (application));
temp_button = gtk_button_new_with_label (temp_str);
label = GTK_BIN (temp_button)->child;
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_START);
@@ -853,13 +844,11 @@ add_command_buttons (NautilusInformationPanel *information_panel, GList *applica
FALSE, FALSE,
0);
- id_string = g_strdup (gnome_vfs_mime_application_get_desktop_id (application));
-
g_signal_connect_data (temp_button,
"clicked",
G_CALLBACK (command_button_callback),
- id_string,
- (GClosureNotify)g_free,
+ g_object_ref (application),
+ (GClosureNotify)g_object_unref,
0);
g_object_set_data (G_OBJECT (temp_button), "user_data", information_panel);
@@ -953,7 +942,7 @@ nautilus_information_panel_update_buttons (NautilusInformationPanel *information
short_application_list =
nautilus_mime_get_applications_for_file (information_panel->details->file);
add_command_buttons (information_panel, short_application_list);
- gnome_vfs_mime_application_list_free (short_application_list);
+ eel_g_object_list_free (short_application_list);
}
gtk_widget_show (GTK_WIDGET (information_panel->details->button_box_centerer));
@@ -1026,7 +1015,7 @@ background_metadata_changed_callback (NautilusInformationPanel *information_pane
NautilusFileAttributes attributes;
gboolean ready;
- attributes = nautilus_mime_actions_get_minimum_file_attributes ();
+ attributes = nautilus_mime_actions_get_required_file_attributes ();
ready = nautilus_file_check_if_ready (information_panel->details->file, attributes);
if (ready) {
@@ -1052,24 +1041,20 @@ nautilus_information_panel_set_uri (NautilusInformationPanel *information_panel,
g_return_if_fail (initial_title != NULL);
/* there's nothing to do if the uri is the same as the current one */
- if (eel_strcmp (information_panel->details->uri, new_uri) == 0) {
+ if (information_panel->details->file != NULL &&
+ nautilus_file_matches_uri (information_panel->details->file, new_uri)) {
return;
}
-
- g_free (information_panel->details->uri);
- information_panel->details->uri = g_strdup (new_uri);
-
+
if (information_panel->details->file != NULL) {
g_signal_handler_disconnect (information_panel->details->file,
information_panel->details->file_changed_connection);
nautilus_file_monitor_remove (information_panel->details->file, information_panel);
}
-
- file = nautilus_file_get (information_panel->details->uri);
+ file = nautilus_file_get_by_uri (new_uri);
nautilus_file_unref (information_panel->details->file);
-
information_panel->details->file = file;
information_panel->details->file_changed_connection =
@@ -1077,7 +1062,7 @@ nautilus_information_panel_set_uri (NautilusInformationPanel *information_panel,
G_CALLBACK (background_metadata_changed_callback),
information_panel, G_CONNECT_SWAPPED);
- attributes = nautilus_mime_actions_get_minimum_file_attributes ();
+ attributes = nautilus_mime_actions_get_required_file_attributes ();
nautilus_file_monitor_add (information_panel->details->file, information_panel, attributes);
background_metadata_changed_callback (information_panel);
diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c
index 8efd711a7..cee33bd81 100644
--- a/src/nautilus-location-bar.c
+++ b/src/nautilus-location-bar.c
@@ -47,7 +47,6 @@
#include <glib/gi18n.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
#include <libnautilus-private/nautilus-clipboard.h>
#include <stdio.h>
@@ -67,9 +66,6 @@ struct NautilusLocationBarDetails {
char *last_location;
- char *current_directory;
- GList *file_info_list;
-
guint idle_id;
};
@@ -117,7 +113,7 @@ drag_data_received_callback (GtkWidget *widget,
guint32 time,
gpointer callback_data)
{
- GList *names, *node;
+ char **names;
NautilusApplication *application;
int name_count;
NautilusWindow *new_window;
@@ -126,14 +122,15 @@ drag_data_received_callback (GtkWidget *widget,
gboolean new_windows_for_extras;
char *prompt;
char *detail;
+ GFile *location;
g_assert (NAUTILUS_IS_LOCATION_BAR (widget));
g_assert (data != NULL);
g_assert (callback_data == NULL);
- names = nautilus_icon_dnd_uri_list_extract_uris (data->data);
+ names = g_uri_list_extract_uris (data->data);
- if (names == NULL) {
+ if (names == NULL || *names == NULL) {
g_warning ("No D&D URI's");
gtk_drag_finish (context, FALSE, FALSE, time);
return;
@@ -145,7 +142,7 @@ drag_data_received_callback (GtkWidget *widget,
* for multiple dropped URIs. This is likely to have been
* a mistake.
*/
- name_count = g_list_length (names);
+ name_count = g_strv_length (names);
if (name_count > 1) {
prompt = g_strdup_printf (ngettext("Do you want to view %d location?",
"Do you want to view %d locations?",
@@ -176,20 +173,24 @@ drag_data_received_callback (GtkWidget *widget,
}
nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (widget),
- names->data);
+ names[0]);
nautilus_navigation_bar_location_changed (NAUTILUS_NAVIGATION_BAR (widget));
if (new_windows_for_extras) {
+ int i;
+
application = NAUTILUS_WINDOW (window)->application;
screen = gtk_window_get_screen (GTK_WINDOW (window));
- for (node = names->next; node != NULL; node = node->next) {
+ for (i = 1; names[i] != NULL; ++i) {
new_window = nautilus_application_create_navigation_window (application, NULL, screen);
- nautilus_window_go_to (new_window, node->data);
+ location = g_file_new_for_uri (names[i]);
+ nautilus_window_go_to (new_window, location);
+ g_object_unref (location);
}
}
- nautilus_icon_dnd_uri_list_free_strings (names);
+ g_strfreev (names);
gtk_drag_finish (context, TRUE, FALSE, time);
}
@@ -280,7 +281,6 @@ label_button_pressed_callback (GtkWidget *widget,
return FALSE;
}
-
static int
get_editable_number_of_chars (GtkEditable *editable)
{
@@ -359,14 +359,6 @@ destroy (GtkObject *object)
bar->details->idle_id = 0;
}
- if (bar->details->file_info_list) {
- gnome_vfs_file_info_list_free (bar->details->file_info_list);
- bar->details->file_info_list = NULL;
- }
-
- g_free (bar->details->current_directory);
- bar->details->current_directory = NULL;
-
g_free (bar->details->last_location);
bar->details->last_location = NULL;
@@ -486,6 +478,7 @@ nautilus_location_bar_set_location (NautilusNavigationBar *navigation_bar,
{
NautilusLocationBar *bar;
char *formatted_location;
+ GFile *file;
g_assert (location != NULL);
@@ -498,20 +491,15 @@ nautilus_location_bar_set_location (NautilusNavigationBar *navigation_bar,
nautilus_location_entry_set_special_text (NAUTILUS_LOCATION_ENTRY (bar->details->entry),
"");
} else {
- formatted_location = eel_format_uri_for_display (location);
+ file = g_file_new_for_uri (location);
+ formatted_location = g_file_get_parse_name (file);
+ g_object_unref (file);
nautilus_entry_set_text (NAUTILUS_ENTRY (bar->details->entry),
formatted_location);
set_position_and_selection_to_end (GTK_EDITABLE (bar->details->entry));
g_free (formatted_location);
}
- /* free up the cached file info from the previous location */
- g_free (bar->details->current_directory);
- bar->details->current_directory = NULL;
-
- gnome_vfs_file_info_list_free (bar->details->file_info_list);
- bar->details->file_info_list = NULL;
-
/* remember the original location for later comparison */
if (bar->details->last_location != location) {
@@ -530,7 +518,7 @@ nautilus_location_bar_set_location (NautilusNavigationBar *navigation_bar,
* @bar: A NautilusLocationBar.
*
* returns a newly allocated "string" containing the mangled
- * (by gnome_vfs_make_uri_from_input) text that the user typed in...maybe a URI
+ * (by g_file_parse_name) text that the user typed in...maybe a URI
* but not guaranteed.
*
**/
@@ -538,14 +526,17 @@ static char *
nautilus_location_bar_get_location (NautilusNavigationBar *navigation_bar)
{
NautilusLocationBar *bar;
- char *user_location, *best_uri;
+ char *user_location, *uri;
+ GFile *location;
bar = NAUTILUS_LOCATION_BAR (navigation_bar);
user_location = gtk_editable_get_chars (GTK_EDITABLE (bar->details->entry), 0, -1);
- best_uri = gnome_vfs_make_uri_from_input (user_location);
+ location = g_file_parse_name (user_location);
g_free (user_location);
- return best_uri;
+ uri = g_file_get_uri (location);
+ g_object_unref (location);
+ return uri;
}
/**
@@ -558,16 +549,19 @@ static void
nautilus_location_bar_update_label (NautilusLocationBar *bar)
{
const char *current_text;
- char *current_location;
+ GFile *location;
+ GFile *last_location;
current_text = gtk_entry_get_text (GTK_ENTRY (bar->details->entry));
- current_location = gnome_vfs_make_uri_from_input (current_text);
+ location = g_file_parse_name (current_text);
+ last_location = g_file_parse_name (bar->details->last_location);
- if (gnome_vfs_uris_match (bar->details->last_location, current_location)) {
+ if (g_file_equal (last_location, location)) {
gtk_label_set_text (GTK_LABEL (bar->details->label), LOCATION_LABEL);
} else {
gtk_label_set_text (GTK_LABEL (bar->details->label), GO_TO_LABEL);
}
- g_free (current_location);
+ g_object_unref (location);
+ g_object_unref (last_location);
}
diff --git a/src/nautilus-location-dialog.c b/src/nautilus-location-dialog.c
index ba3e4952f..464057b0f 100644
--- a/src/nautilus-location-dialog.c
+++ b/src/nautilus-location-dialog.c
@@ -25,13 +25,11 @@
#include "nautilus-location-dialog.h"
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkstock.h>
#include <libgnomeui/gnome-help.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include "nautilus-location-entry.h"
#include "nautilus-desktop-window.h"
@@ -76,16 +74,14 @@ nautilus_location_dialog_destroy (GtkObject *object)
static void
open_current_location (NautilusLocationDialog *dialog)
{
- char *uri;
+ GFile *location;
char *user_location;
user_location = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->entry), 0, -1);
- uri = gnome_vfs_make_uri_from_input (user_location);
+ location = g_file_parse_name (user_location);
+ nautilus_window_go_to (dialog->details->window, location);
+ g_object_unref (location);
g_free (user_location);
-
- nautilus_window_go_to (dialog->details->window, uri);
-
- g_free (uri);
}
static void
@@ -206,7 +202,7 @@ GtkWidget *
nautilus_location_dialog_new (NautilusWindow *window)
{
GtkWidget *dialog;
- char *location;
+ GFile *location;
char *formatted_location;
dialog = gtk_widget_new (NAUTILUS_TYPE_LOCATION_DIALOG, NULL);
@@ -224,13 +220,13 @@ nautilus_location_dialog_new (NautilusWindow *window)
if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
formatted_location = g_strdup_printf ("%s/", g_get_home_dir ());
} else {
- formatted_location = eel_format_uri_for_display (location);
+ formatted_location = g_file_get_parse_name (location);
}
nautilus_entry_set_text (NAUTILUS_ENTRY (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), formatted_location);
gtk_editable_select_region (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), 0, -1);
gtk_editable_set_position (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), -1);
g_free (formatted_location);
- g_free (location);
+ g_object_unref (location);
}
gtk_widget_grab_focus (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry);
diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c
index c5e5053a1..491d64e7d 100644
--- a/src/nautilus-location-entry.c
+++ b/src/nautilus-location-entry.c
@@ -39,17 +39,17 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtksignal.h>
#include <glib/gi18n.h>
+#include <gio/gfilenamecompleter.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-entry.h>
#include <libnautilus-private/nautilus-icon-dnd.h>
#include <libnautilus-private/nautilus-clipboard.h>
+#include <gio/gfilenamecompleter.h>
#include <stdio.h>
#include <string.h>
@@ -57,7 +57,7 @@ struct NautilusLocationEntryDetails {
GtkLabel *label;
char *current_directory;
- GList *file_info_list;
+ GFilenameCompleter *completer;
guint idle_id;
@@ -73,87 +73,7 @@ EEL_CLASS_BOILERPLATE (NautilusLocationEntry,
nautilus_location_entry,
NAUTILUS_TYPE_ENTRY)
-/* utility routine to determine the string to expand to. If we don't have anything yet, accept
- the whole string, otherwise accept the largest part common to both */
-
-static char *
-accumulate_name_utf8 (char *full_name, char *candidate_name)
-{
- char *result_name, *str1, *str2;
-
- if (!g_utf8_validate (candidate_name, -1, NULL)) {
- return full_name;
- }
-
- if (full_name == NULL) {
- result_name = g_strdup (candidate_name);
- } else {
- result_name = full_name;
- if (!eel_str_has_prefix (full_name, candidate_name)) {
- str1 = full_name;
- str2 = candidate_name;
-
- while ((g_utf8_get_char (str1) == g_utf8_get_char (str2))) {
- str1 = g_utf8_next_char (str1);
- str2 = g_utf8_next_char (str2);
- }
- *str1 = '\0';
- }
- }
-
- return result_name;
-}
-
-static char *
-accumulate_name_locale (char *full_name, char *candidate_name)
-{
- char *result_name, *str1, *str2;
-
- if (full_name == NULL)
- result_name = g_strdup (candidate_name);
- else {
- result_name = full_name;
- if (!eel_str_has_prefix (full_name, candidate_name)) {
- str1 = full_name;
- str2 = candidate_name;
-
- while (*str1 == *str2) {
- str1++;
- str2++;
- }
- *str1 = '\0';
- }
- }
-
- return result_name;
-}
-
-/* utility routine to load the file info list for the current directory, if necessary */
-static void
-get_file_info_list (NautilusLocationEntry *entry, const char* dir_name)
-{
- GnomeVFSResult result;
-
- if (eel_strcmp (entry->details->current_directory, dir_name) != 0) {
- g_free (entry->details->current_directory);
- if (entry->details->file_info_list) {
- gnome_vfs_file_info_list_free (entry->details->file_info_list);
- entry->details->file_info_list = NULL;
- }
-
- entry->details->current_directory = g_strdup (dir_name);
- result = gnome_vfs_directory_list_load (&entry->details->file_info_list, dir_name,
- GNOME_VFS_FILE_INFO_DEFAULT);
- if (result != GNOME_VFS_OK) {
- if (entry->details->file_info_list) {
- gnome_vfs_file_info_list_free (entry->details->file_info_list);
- entry->details->file_info_list = NULL;
- }
- }
- }
-}
-
-/* routine that performs the tab expansion using gnome-vfs. Extract the directory name and
+/* routine that performs the tab expansion. Extract the directory name and
incomplete basename, then iterate through the directory trying to complete it. If we
find something, add it to the entry */
@@ -161,148 +81,29 @@ static gboolean
try_to_expand_path (gpointer callback_data)
{
NautilusLocationEntry *entry;
-
- GnomeVFSFileInfo *current_file_info;
- GList *element;
- GnomeVFSURI *uri;
GtkEditable *editable;
- gboolean utf8_filenames;
- const char *filename_charset;
-
- char *base_name_uri_escaped;
- char *base_name;
- char *base_name_utf8;
- char *user_location;
- char *current_path;
- char *dir_name;
- char *expand_text;
- char *expand_text_utf8;
- char *expand_name;
- char *insert_text;
-
- int base_name_length;
- int user_location_length;
- int expand_text_length;
- int pos;
+ char *suffix, *user_location;
+ int user_location_length, pos;
entry = NAUTILUS_LOCATION_ENTRY (callback_data);
editable = GTK_EDITABLE (entry);
user_location = gtk_editable_get_chars (editable, 0, -1);
- entry->details->idle_id = 0;
-
- /* if it's just '~' don't expand because slash shouldn't be appended */
- if (eel_strcmp (user_location, "~") == 0) {
- g_free (user_location);
- return FALSE;
- }
-
- /* Trailing whitespace is OK here since the cursor is known to
- be at the end of the text and therefor after the whitespace. */
- current_path = gnome_vfs_make_uri_from_input_with_trailing_ws (user_location);
- if (!eel_istr_has_prefix (current_path, "file://")) {
- g_free (user_location);
- g_free (current_path);
- return FALSE;
- }
-
- /* We already completed if we have a trailing '/' */
- if (current_path[strlen (current_path) - 1] == GNOME_VFS_URI_PATH_CHR) {
- g_free (user_location);
- g_free (current_path);
- return FALSE;
- }
-
user_location_length = g_utf8_strlen (user_location, -1);
-
- g_free (user_location);
-
- uri = gnome_vfs_uri_new (current_path);
-
- base_name_uri_escaped = gnome_vfs_uri_extract_short_name (uri);
- if (base_name_uri_escaped == NULL) {
- base_name = NULL;
- } else {
- base_name = gnome_vfs_unescape_string (base_name_uri_escaped, NULL);
- }
- g_free (base_name_uri_escaped);
-
- if (base_name == NULL) {
- gnome_vfs_uri_unref (uri);
- g_free (current_path);
- return FALSE;
- }
-
- dir_name = gnome_vfs_uri_extract_dirname (uri);
-
- gnome_vfs_uri_unref (uri);
- uri = NULL;
-
- /* get file info for the directory, if it hasn't changed since last time */
- get_file_info_list (entry, dir_name);
- if (entry->details->file_info_list == NULL) {
- g_free (dir_name);
- g_free (base_name);
- g_free (current_path);
- return FALSE;
- }
-
- utf8_filenames = eel_get_filename_charset (&filename_charset);
-
- /* iterate through the directory, keeping the intersection of all the names that
- have the current basename as a prefix. */
- expand_text = NULL;
- for (element = entry->details->file_info_list; element != NULL; element = element->next) {
- current_file_info = element->data;
- if (eel_str_has_prefix (current_file_info->name, base_name)) {
- if (current_file_info->type == GNOME_VFS_FILE_TYPE_DIRECTORY) {
- expand_name = g_strconcat (current_file_info->name, "/", NULL);
- } else {
- expand_name = g_strdup (current_file_info->name);
- }
- if (utf8_filenames) {
- expand_text = accumulate_name_utf8 (expand_text, expand_name);
- } else {
- expand_text = accumulate_name_locale (expand_text, expand_name);
- }
- g_free (expand_name);
- }
- }
-
- if (!utf8_filenames) {
- if (expand_text) {
- expand_text_utf8 = g_convert (expand_text, -1, "UTF-8", filename_charset, NULL, NULL, NULL);
- g_free (expand_text);
- expand_text = expand_text_utf8;
- }
-
- base_name_utf8 = g_convert (base_name, -1, "UTF-8", filename_charset, NULL, NULL, NULL);
- g_free (base_name);
- base_name = base_name_utf8;
- }
-
+ entry->details->idle_id = 0;
+
+ suffix = g_filename_completer_get_completion_suffix (entry->details->completer,
+ user_location);
+
/* if we've got something, add it to the entry */
- if (expand_text != NULL && base_name != NULL) {
- expand_text_length = g_utf8_strlen (expand_text, -1);
- base_name_length = g_utf8_strlen (base_name, -1);
+ if (suffix != NULL) {
+ pos = user_location_length;
+ gtk_editable_insert_text (editable,
+ suffix, -1, &pos);
+ pos = user_location_length;
+ gtk_editable_select_region (editable, pos, -1);
- if (!eel_str_has_suffix (base_name, expand_text)
- && base_name_length < expand_text_length) {
- insert_text = g_utf8_offset_to_pointer (expand_text, base_name_length);
- pos = user_location_length;
- gtk_editable_insert_text (editable,
- insert_text,
- strlen (insert_text),
- &pos);
-
- pos = user_location_length;
- gtk_editable_select_region (editable, pos, -1);
- }
+ g_free (suffix);
}
- g_free (expand_text);
-
- g_free (dir_name);
- g_free (base_name);
- g_free (current_path);
return FALSE;
}
@@ -381,6 +182,17 @@ position_and_selection_are_at_end (GtkEditable *editable)
}
static void
+got_completion_data_callback (GFilenameCompleter *completer,
+ NautilusLocationEntry *entry)
+{
+ if (entry->details->idle_id) {
+ g_source_remove (entry->details->idle_id);
+ entry->details->idle_id = 0;
+ }
+ try_to_expand_path (entry);
+}
+
+static void
editable_event_after_callback (GtkEntry *entry,
GdkEvent *event,
NautilusLocationEntry *location_entry)
@@ -435,6 +247,7 @@ finalize (GObject *object)
entry = NAUTILUS_LOCATION_ENTRY (object);
+ g_object_unref (entry->details->completer);
g_free (entry->details->special_text);
g_free (entry->details);
@@ -454,11 +267,6 @@ destroy (GtkObject *object)
entry->details->idle_id = 0;
}
- if (entry->details->file_info_list) {
- gnome_vfs_file_info_list_free (entry->details->file_info_list);
- entry->details->file_info_list = NULL;
- }
-
g_free (entry->details->current_directory);
entry->details->current_directory = NULL;
@@ -514,6 +322,9 @@ nautilus_location_entry_init (NautilusLocationEntry *entry)
{
entry->details = g_new0 (NautilusLocationEntryDetails, 1);
+ entry->details->completer = g_filename_completer_new ();
+ g_filename_completer_set_dirs_only (entry->details->completer, TRUE);
+
nautilus_entry_set_special_tab_handling (NAUTILUS_ENTRY (entry), TRUE);
g_signal_connect (entry, "event_after",
@@ -522,6 +333,8 @@ nautilus_location_entry_init (NautilusLocationEntry *entry)
g_signal_connect (entry, "notify::text",
G_CALLBACK (nautilus_location_entry_text_changed), NULL);
+ g_signal_connect (entry->details->completer, "got_completion_data",
+ G_CALLBACK (got_completion_data_callback), entry);
}
GtkWidget *
diff --git a/src/nautilus-main.c b/src/nautilus-main.c
index 947c208d9..7d51cea81 100644
--- a/src/nautilus-main.c
+++ b/src/nautilus-main.c
@@ -50,7 +50,6 @@
#include <libgnome/gnome-init.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomeui/gnome-client.h>
-#include <libgnomevfs/gnome-vfs-init.h>
#include <libnautilus-private/nautilus-debug-log.h>
#include <libnautilus-private/nautilus-directory-metafile.h>
#include <libnautilus-private/nautilus-global-preferences.h>
@@ -85,7 +84,7 @@ quit_if_in_main_loop (gpointer callback_data)
level = gtk_main_level ();
- /* We can be called even outside the main loop by gnome_vfs_shutdown,
+ /* We can be called even outside the main loop,
* so check that we are in a loop before calling quit.
*/
if (level != 0) {
@@ -399,6 +398,8 @@ main (int argc, char *argv[])
{ NULL }
};
+ g_thread_init (NULL);
+
setlocale (LC_ALL, "");
if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
@@ -556,17 +557,8 @@ main (int argc, char *argv[])
gtk_main ();
}
- /* This has to be done before gnome_vfs_shutdown, because
- * it might call nautilus_file_get_uri() which might call
- * gnome_vfs_uri_append_string()
- */
eel_debug_shut_down ();
- gnome_vfs_shutdown ();
-
- /* This has to be done after gnome_vfs_shutdown, because shutdown
- * can call pending completion callbacks which reference application.
- */
if (application != NULL) {
bonobo_object_unref (application);
}
diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c
index 2f165f923..d062d7d04 100644
--- a/src/nautilus-navigation-window-menus.c
+++ b/src/nautilus-navigation-window-menus.c
@@ -43,7 +43,6 @@
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-xml-extensions.h>
#include <libxml/parser.h>
#include <gtk/gtkmain.h>
@@ -52,13 +51,9 @@
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-about.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-search-engine.h>
#include <libnautilus-private/nautilus-signaller.h>
@@ -291,14 +286,14 @@ nautilus_navigation_window_remove_go_menu_items (NautilusNavigationWindow *windo
static void
show_bogus_history_window (NautilusWindow *window,
- NautilusBookmark *bookmark)
+ NautilusBookmark *bookmark)
{
- char *uri;
+ GFile *file;
char *uri_for_display;
char *detail;
- uri = nautilus_bookmark_get_uri (bookmark);
- uri_for_display = eel_format_uri_for_display (uri);
+ file = nautilus_bookmark_get_location (bookmark);
+ uri_for_display = g_file_get_parse_name (file);
detail = g_strdup_printf (_("The location \"%s\" does not exist."), uri_for_display);
@@ -306,7 +301,7 @@ show_bogus_history_window (NautilusWindow *window,
detail,
GTK_WINDOW (window));
- g_free (uri);
+ g_object_unref (file);
g_free (uri_for_display);
g_free (detail);
}
@@ -411,12 +406,9 @@ static void
nautilus_navigation_window_initialize_go_menu (NautilusNavigationWindow *window)
{
/* Recreate bookmarks part of menu if history list changes
- * or if icon theme changes.
*/
g_signal_connect_object (nautilus_signaller_get_current (), "history_list_changed",
G_CALLBACK (schedule_refresh_go_menu), window, G_CONNECT_SWAPPED);
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (schedule_refresh_go_menu), window, G_CONNECT_SWAPPED);
}
static void
@@ -439,7 +431,7 @@ action_folder_window_callback (GtkAction *action,
gpointer user_data)
{
NautilusWindow *current_window;
- char *current_location;
+ GFile *current_location;
current_window = NAUTILUS_WINDOW (user_data);
current_location = nautilus_window_get_location (current_window);
@@ -449,7 +441,9 @@ action_folder_window_callback (GtkAction *action,
NULL,
current_location,
gtk_window_get_screen (GTK_WINDOW (current_window)));
- g_free (current_location);
+ if (current_location != NULL) {
+ g_object_unref (current_location);
+ }
}
static void
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index 0e06509a9..0d21e665e 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -41,13 +41,8 @@
#include "nautilus-search-bar.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
-#include <eel/eel-accessibility.h>
-#include <eel/eel-debug.h>
-#include <eel/eel-gdk-extensions.h>
-#include <eel/eel-gdk-pixbuf-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
-#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkx.h>
@@ -69,7 +64,7 @@
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-horizontal-splitter.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <libnautilus-private/nautilus-icon-info.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-program-choosing.h>
@@ -83,6 +78,7 @@
#include <libnautilus-private/nautilus-signaller.h>
#include <math.h>
#include <sys/time.h>
+#include <gio/gthemedicon.h>
/* FIXME bugzilla.gnome.org 41243:
@@ -119,7 +115,7 @@ static void navigation_bar_location_changed_callback (GtkWidget *
static void navigation_bar_cancel_callback (GtkWidget *widget,
NautilusNavigationWindow *window);
static void path_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
+ GFile *path,
NautilusNavigationWindow *window);
static void always_use_location_entry_changed (gpointer callback_data);
static void always_use_browser_changed (gpointer callback_data);
@@ -402,24 +398,24 @@ always_use_browser_changed (gpointer callback_data)
static int
bookmark_list_get_uri_index (GList *list,
- const char *uri)
+ GFile *location)
{
NautilusBookmark *bookmark;
GList *l;
- char *tmp;
+ GFile *tmp;
int i;
- g_return_val_if_fail (uri != NULL, -1);
+ g_return_val_if_fail (location != NULL, -1);
for (i = 0, l = list; l != NULL; i++, l = l->next) {
bookmark = NAUTILUS_BOOKMARK (l->data);
- tmp = nautilus_bookmark_get_uri (bookmark);
- if (strcmp (tmp, uri) == 0) {
- g_free (tmp);
+ tmp = nautilus_bookmark_get_location (bookmark);
+ if (g_file_equal (location, tmp)) {
+ g_object_unref (tmp);
return i;
}
- g_free (tmp);
+ g_object_unref (tmp);
}
return -1;
@@ -427,7 +423,7 @@ bookmark_list_get_uri_index (GList *list,
static void
path_bar_location_changed_callback (GtkWidget *widget,
- const char *uri,
+ GFile *location,
NautilusNavigationWindow *window)
{
int i;
@@ -435,11 +431,11 @@ path_bar_location_changed_callback (GtkWidget *widget,
g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
/* check whether we already visited the target location */
- i = bookmark_list_get_uri_index (window->back_list, uri);
+ i = bookmark_list_get_uri_index (window->back_list, location);
if (i >= 0) {
nautilus_navigation_window_back_or_forward (window, TRUE, i);
} else {
- nautilus_window_go_to (NAUTILUS_WINDOW (window), uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), location);
}
}
@@ -479,8 +475,12 @@ navigation_bar_location_changed_callback (GtkWidget *widget,
const char *uri,
NautilusNavigationWindow *window)
{
+ GFile *location;
+
hide_temporary_bars (window);
- nautilus_window_go_to (NAUTILUS_WINDOW (window), uri);
+ location = g_file_new_for_uri (uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), location);
+ g_object_unref (location);
}
static void
@@ -700,6 +700,7 @@ nautilus_navigation_window_destroy (GtkObject *object)
window->sidebar = NULL;
g_list_foreach (window->sidebar_panels, (GFunc)g_object_unref, NULL);
+ g_list_free (window->sidebar_panels);
window->sidebar_panels = NULL;
window->view_as_combo_box = NULL;
@@ -765,10 +766,8 @@ nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window,
g_signal_connect (sidebar_panel, "tab_icon_changed",
(GCallback)side_panel_image_changed_callback, window);
-
- g_object_ref (sidebar_panel);
- window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel);
-
+ window->sidebar_panels = g_list_prepend (window->sidebar_panels,
+ g_object_ref (sidebar_panel));
/* Show if default */
sidebar_id = nautilus_sidebar_get_sidebar_id (sidebar_panel);
@@ -948,10 +947,10 @@ real_set_title (NautilusWindow *window, const char *title)
return changed;
}
-static char *
-real_get_icon_name (NautilusWindow *window)
+static NautilusIconInfo *
+real_get_icon (NautilusWindow *window)
{
- return g_strdup ("file-manager");
+ return nautilus_icon_info_lookup_from_name ("file-manager", 48);
}
static void
@@ -1077,9 +1076,13 @@ search_bar_activate_callback (NautilusSearchBar *bar,
NautilusDirectory *directory;
NautilusSearchDirectory *search_directory;
NautilusQuery *query;
+ GFile *location;
uri = nautilus_search_directory_generate_new_uri ();
- directory = nautilus_directory_get (uri);
+ location = g_file_new_for_uri (uri);
+ g_free (uri);
+
+ directory = nautilus_directory_get (location);
g_assert (NAUTILUS_IS_SEARCH_DIRECTORY (directory));
@@ -1088,7 +1091,7 @@ search_bar_activate_callback (NautilusSearchBar *bar,
query = nautilus_search_bar_get_query (NAUTILUS_SEARCH_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->search_bar));
if (query != NULL) {
if (!nautilus_search_directory_is_indexed (search_directory)) {
- current_uri = nautilus_window_get_location (window);
+ current_uri = nautilus_window_get_location_uri (window);
nautilus_query_set_location (query, current_uri);
g_free (current_uri);
}
@@ -1096,10 +1099,10 @@ search_bar_activate_callback (NautilusSearchBar *bar,
g_object_unref (query);
}
- nautilus_window_go_to (window, uri);
+ nautilus_window_go_to (window, location);
nautilus_directory_unref (directory);
- g_free (uri);
+ g_object_unref (location);
}
static void
@@ -1594,7 +1597,7 @@ nautilus_navigation_window_class_init (NautilusNavigationWindowClass *class)
NAUTILUS_WINDOW_CLASS (class)->prompt_for_location = real_prompt_for_location;
NAUTILUS_WINDOW_CLASS (class)->set_search_mode = real_set_search_mode;
NAUTILUS_WINDOW_CLASS (class)->set_title = real_set_title;
- NAUTILUS_WINDOW_CLASS (class)->get_icon_name = real_get_icon_name;
+ NAUTILUS_WINDOW_CLASS (class)->get_icon = real_get_icon;
NAUTILUS_WINDOW_CLASS (class)->get_default_size = real_get_default_size;
NAUTILUS_WINDOW_CLASS (class)->close = real_window_close;
diff --git a/src/nautilus-notes-viewer.c b/src/nautilus-notes-viewer.c
index b4bb2f4b0..1ab4c843a 100644
--- a/src/nautilus-notes-viewer.c
+++ b/src/nautilus-notes-viewer.c
@@ -247,7 +247,7 @@ notes_load_metainfo (NautilusNotesViewer *notes)
NautilusFileAttributes attributes;
done_with_file (notes);
- notes->details->file = nautilus_file_get (notes->details->uri);
+ notes->details->file = nautilus_file_get_by_uri (notes->details->uri);
/* Block the handler, so we don't respond to our own change.
*/
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index ffc9b0a06..ac36cfb8a 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -33,9 +33,9 @@
#include <gtk/gtkhbox.h>
#include <gtk/gtkmain.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <gio/gthemedicon.h>
+#include <gio/gvolumemonitor.h>
+#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include "nautilus-pathbar.h"
@@ -64,9 +64,9 @@ static gboolean desktop_is_home;
#define NAUTILUS_PATH_BAR_ICON_SIZE 16
-#define DEFAULT_ICON "gnome-fs-directory"
-#define DEFAULT_DESKTOP_ICON "gnome-fs-desktop"
-#define DEFAULT_HOME_ICON "gnome-fs-home"
+#define DEFAULT_ICON "folder"
+#define DEFAULT_DESKTOP_ICON "user-desktop"
+#define DEFAULT_HOME_ICON "user-home"
#define DEFAULT_FILESYSTEM_ICON "gnome-dev-harddisk"
typedef struct _ButtonData ButtonData;
@@ -76,10 +76,10 @@ struct _ButtonData
GtkWidget *button;
ButtonType type;
char *dir_name;
- char *path;
+ GFile *path;
/* custom icon */
- char *custom_icon_name;
+ GdkPixbuf *custom_icon;
/* flag to indicate its the base folder in the URI */
gboolean is_base_dir;
@@ -139,7 +139,7 @@ static void nautilus_path_bar_update_button_appearance (NautilusPathBar *pat
ButtonData *button_data,
gboolean current_dir);
static gboolean nautilus_path_bar_update_path (NautilusPathBar *path_bar,
- const char *file_path);
+ GFile *file_path);
static GtkWidget *
get_slider_button (NautilusPathBar *path_bar,
@@ -164,7 +164,7 @@ static void
update_button_types (NautilusPathBar *path_bar)
{
GList *list;
- char *path = NULL;
+ GFile *path = NULL;
for (list = path_bar->button_list; list; list = list->next) {
ButtonData *button_data;
@@ -187,11 +187,11 @@ desktop_location_changed_callback (gpointer user_data)
path_bar = NAUTILUS_PATH_BAR (user_data);
- g_free (path_bar->desktop_path);
- g_free (path_bar->home_path);
- path_bar->desktop_path = nautilus_get_desktop_directory_uri ();
- path_bar->home_path = nautilus_get_home_directory_uri ();
- desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0);
+ g_object_unref (path_bar->desktop_path);
+ g_object_unref (path_bar->home_path);
+ path_bar->desktop_path = nautilus_get_desktop_location ();
+ path_bar->home_path = g_file_new_for_path (g_get_home_dir ());
+ desktop_is_home = g_file_equal (path_bar->home_path, path_bar->desktop_path);
if (path_bar->home_icon) {
g_object_unref (path_bar->home_icon);
@@ -204,6 +204,8 @@ desktop_location_changed_callback (gpointer user_data)
static void
nautilus_path_bar_init (NautilusPathBar *path_bar)
{
+ char *p;
+
GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
@@ -212,10 +214,12 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
path_bar->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
path_bar->icon_size = NAUTILUS_PATH_BAR_ICON_SIZE;
- path_bar->desktop_path = nautilus_get_desktop_directory_uri ();
- path_bar->home_path = nautilus_get_home_directory_uri ();
- path_bar->root_path = g_strdup ("file:///");
- desktop_is_home = (strcmp (path_bar->home_path, path_bar->desktop_path) == 0);
+ p = nautilus_get_desktop_directory ();
+ path_bar->desktop_path = g_file_new_for_path (p);
+ g_free (p);
+ path_bar->home_path = g_file_new_for_path (g_get_home_dir ());
+ path_bar->root_path = g_file_new_for_path ("/");
+ desktop_is_home = g_file_equal (path_bar->home_path, path_bar->desktop_path);
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
desktop_location_changed_callback,
@@ -267,7 +271,7 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
- G_TYPE_STRING);
+ G_TYPE_FILE);
}
@@ -282,15 +286,15 @@ nautilus_path_bar_finalize (GObject *object)
g_list_free (path_bar->button_list);
if (path_bar->root_path) {
- g_free (path_bar->root_path);
+ g_object_unref (path_bar->root_path);
path_bar->root_path = NULL;
}
if (path_bar->home_path) {
- g_free (path_bar->home_path);
+ g_object_unref (path_bar->home_path);
path_bar->home_path = NULL;
}
if (path_bar->desktop_path) {
- g_free (path_bar->desktop_path);
+ g_object_unref (path_bar->desktop_path);
path_bar->desktop_path = NULL;
}
@@ -1012,33 +1016,37 @@ button_clicked_cb (GtkWidget *button,
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, button_data->path);
}
-static char *
-get_icon_name_for_file_path (const char *file_path)
+static GdkPixbuf *
+get_icon_for_file_path (GFile *location, const char *default_icon_name)
{
NautilusFile *file;
- char *icon_name;
+ NautilusIconInfo *info;
+ GdkPixbuf *pixbuf;
- file = nautilus_file_get (file_path);
- if (!file) {
- return g_strdup (DEFAULT_ICON);
- }
- icon_name = NULL;
- if (nautilus_icon_factory_is_icon_ready_for_file (file)) {
- icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- }
- if (!icon_name) {
- icon_name = g_strdup (DEFAULT_ICON);
+ file = nautilus_file_get (location);
+
+ if (file != NULL &&
+ nautilus_file_check_if_ready (file,
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
+ info = nautilus_file_get_icon (file, NAUTILUS_PATH_BAR_ICON_SIZE, 0);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_PATH_BAR_ICON_SIZE);
+ g_object_unref (info);
+ return pixbuf;
}
+
nautilus_file_unref (file);
- return icon_name;
+
+ info = nautilus_icon_info_lookup_from_name (default_icon_name, NAUTILUS_PATH_BAR_ICON_SIZE);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_PATH_BAR_ICON_SIZE);
+ g_object_unref (info);
+
+ return pixbuf;
}
static GdkPixbuf *
get_button_image (NautilusPathBar *path_bar,
ButtonType button_type)
{
- char *icon_name;
-
switch (button_type)
{
case ROOT_BUTTON:
@@ -1046,18 +1054,7 @@ get_button_image (NautilusPathBar *path_bar,
return path_bar->root_icon;
}
- icon_name = get_icon_name_for_file_path (path_bar->root_path);
- if (strcmp (icon_name, DEFAULT_ICON) == 0) {
- path_bar->root_icon = nautilus_icon_factory_get_pixbuf_from_name (DEFAULT_FILESYSTEM_ICON,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- } else {
- path_bar->root_icon = nautilus_icon_factory_get_pixbuf_from_name (icon_name,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- }
-
- g_free (icon_name);
+ path_bar->root_icon = get_icon_for_file_path (path_bar->root_path, DEFAULT_FILESYSTEM_ICON);
return path_bar->root_icon;
case HOME_BUTTON:
@@ -1065,36 +1062,14 @@ get_button_image (NautilusPathBar *path_bar,
return path_bar->home_icon;
}
- icon_name = get_icon_name_for_file_path (path_bar->home_path);
- if (strcmp (icon_name, DEFAULT_ICON) == 0) {
- path_bar->home_icon = nautilus_icon_factory_get_pixbuf_from_name (DEFAULT_HOME_ICON,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- } else {
- path_bar->home_icon = nautilus_icon_factory_get_pixbuf_from_name (icon_name,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- }
-
- g_free (icon_name);
+ path_bar->home_icon = get_icon_for_file_path (path_bar->root_path, DEFAULT_HOME_ICON);
return path_bar->home_icon;
case DESKTOP_BUTTON:
if (path_bar->desktop_icon != NULL) {
return path_bar->desktop_icon;
}
- icon_name = get_icon_name_for_file_path (path_bar->desktop_path);
- if (strcmp (icon_name, DEFAULT_ICON) == 0) {
- path_bar->desktop_icon = nautilus_icon_factory_get_pixbuf_from_name (DEFAULT_DESKTOP_ICON,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- } else {
- path_bar->desktop_icon = nautilus_icon_factory_get_pixbuf_from_name (icon_name,
- NULL, NAUTILUS_PATH_BAR_ICON_SIZE,
- TRUE, NULL);
- }
-
- g_free (icon_name);
+ path_bar->desktop_icon = get_icon_for_file_path (path_bar->root_path, DEFAULT_DESKTOP_ICON);
return path_bar->desktop_icon;
default:
@@ -1107,10 +1082,10 @@ get_button_image (NautilusPathBar *path_bar,
static void
button_data_free (ButtonData *button_data)
{
- g_free (button_data->path);
+ g_object_unref (button_data->path);
g_free (button_data->dir_name);
- if (button_data->custom_icon_name) {
- g_free (button_data->custom_icon_name);
+ if (button_data->custom_icon) {
+ g_object_unref (button_data->custom_icon);
}
g_free (button_data);
}
@@ -1176,8 +1151,8 @@ nautilus_path_bar_update_button_appearance (NautilusPathBar *path_bar,
if (button_data->type == VOLUME_BUTTON || (button_data->type == NORMAL_BUTTON && button_data->is_base_dir) ) {
/* set custom icon for roots */
- if (button_data->custom_icon_name) {
- gtk_image_set_from_icon_name (GTK_IMAGE (button_data->image), button_data->custom_icon_name, GTK_ICON_SIZE_MENU);
+ if (button_data->custom_icon) {
+ gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), button_data->custom_icon);
}
} else {
GdkPixbuf *pixbuf;
@@ -1194,65 +1169,47 @@ nautilus_path_bar_update_button_appearance (NautilusPathBar *path_bar,
}
static gboolean
-is_file_path_equal (const char *file_path_1, const char *file_path_2)
+is_file_path_mounted_volume (GFile *location, ButtonData *button_data)
{
- GnomeVFSURI *vfs_uri_1, *vfs_uri_2;
- gboolean result;
-
- vfs_uri_1 = gnome_vfs_uri_new (file_path_1);
- if (vfs_uri_1 == NULL) {
- return FALSE;
- }
-
- vfs_uri_2 = gnome_vfs_uri_new (file_path_2);
- if (vfs_uri_2 == NULL) {
- gnome_vfs_uri_unref (vfs_uri_1);
- return FALSE;
- }
-
- result = gnome_vfs_uri_equal (vfs_uri_1, vfs_uri_2);
-
- gnome_vfs_uri_unref (vfs_uri_1);
- gnome_vfs_uri_unref (vfs_uri_2);
- return result;
-}
-
-static gboolean
-is_file_path_mounted_volume (const char *file_path, ButtonData *button_data)
-{
- GnomeVFSVolumeMonitor *volume_monitor;
+ GVolumeMonitor *volume_monitor;
GList *volumes, *l;
- GnomeVFSVolume *volume;
+ GVolume *volume;
gboolean result;
- char *mount_uri;
+ GIcon *icon;
+ NautilusIconInfo *info;
+ GFile *root;
result = FALSE;
- volume_monitor = gnome_vfs_get_volume_monitor ();
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
+ volume_monitor = g_volume_monitor_get ();
+ volumes = g_volume_monitor_get_mounted_volumes (volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
volume = l->data;
- if (result || !gnome_vfs_volume_is_user_visible (volume)) {
- gnome_vfs_volume_unref (volume);
+ if (result) {
+ g_object_unref (volume);
continue;
}
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- if (is_file_path_equal (file_path, mount_uri)) {
+ root = g_volume_get_root (volume);
+ if (g_file_equal (location, root)) {
result = TRUE;
/* set volume specific details in button_data */
if (button_data) {
- button_data->custom_icon_name = gnome_vfs_volume_get_icon (volume);
- if (!button_data->custom_icon_name) {
- button_data->custom_icon_name = g_strdup (DEFAULT_ICON);
+ icon = g_volume_get_icon (volume);
+ if (icon == NULL) {
+ icon = g_themed_icon_new (DEFAULT_ICON);
}
- button_data->path = g_strdup (mount_uri);
- button_data->dir_name = gnome_vfs_volume_get_display_name (volume);
+ info = nautilus_icon_info_lookup (icon, NAUTILUS_PATH_BAR_ICON_SIZE);
+ g_object_unref (icon);
+ button_data->custom_icon = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_PATH_BAR_ICON_SIZE);
+ g_object_unref (info);
+ button_data->path = g_object_ref (location);
+ button_data->dir_name = g_volume_get_name (volume);
}
- gnome_vfs_volume_unref (volume);
- g_free (mount_uri);
+ g_object_unref (volume);
+ g_object_unref (root);
continue;
}
- gnome_vfs_volume_unref (volume);
- g_free (mount_uri);
+ g_object_unref (volume);
+ g_object_unref (root);
}
g_list_free (volumes);
return result;
@@ -1260,25 +1217,25 @@ is_file_path_mounted_volume (const char *file_path, ButtonData *button_data)
static ButtonType
find_button_type (NautilusPathBar *path_bar,
- const char *path,
+ GFile *location,
ButtonData *button_data)
{
- if (path_bar->root_path != NULL && is_file_path_equal (path, path_bar->root_path)) {
+ if (path_bar->root_path != NULL && g_file_equal (location, path_bar->root_path)) {
return ROOT_BUTTON;
}
- if (path_bar->home_path != NULL && is_file_path_equal (path, path_bar->home_path)) {
+ if (path_bar->home_path != NULL && g_file_equal (location, path_bar->home_path)) {
return HOME_BUTTON;
}
- if (path_bar->desktop_path != NULL && is_file_path_equal (path, path_bar->desktop_path)) {
+ if (path_bar->desktop_path != NULL && g_file_equal (location, path_bar->desktop_path)) {
if (!desktop_is_home) {
return DESKTOP_BUTTON;
} else {
return NORMAL_BUTTON;
}
}
- if (is_file_path_mounted_volume (path, button_data)) {
+ if (is_file_path_mounted_volume (location, button_data)) {
return VOLUME_BUTTON;
}
@@ -1295,9 +1252,12 @@ button_drag_data_get_cb (GtkWidget *widget,
{
ButtonData *button_data;
char *uri_list;
+ char *uri;
button_data = data;
- uri_list = g_strconcat (button_data->path, "\r\n", NULL);
+ uri = g_file_get_uri (button_data->path);
+ uri_list = g_strconcat (uri, "\r\n", NULL);
+ g_free (uri);
gtk_selection_data_set (selection_data,
selection_data->target,
8,
@@ -1309,7 +1269,7 @@ button_drag_data_get_cb (GtkWidget *widget,
static ButtonData *
make_directory_button (NautilusPathBar *path_bar,
const char *dir_name,
- const char *path,
+ GFile *path,
gboolean current_dir,
gboolean base_dir,
gboolean file_is_hidden)
@@ -1361,7 +1321,7 @@ make_directory_button (NautilusPathBar *path_bar,
gtk_box_pack_start (GTK_BOX (child), button_data->image, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (child), label_alignment, FALSE, FALSE, 0);
button_data->is_base_dir = TRUE;
- button_data->custom_icon_name = get_icon_name_for_file_path (path);
+ button_data->custom_icon = get_icon_for_file_path (path, DEFAULT_ICON);
} else {
button_data->is_base_dir = FALSE;
button_data->label = gtk_label_new (NULL);
@@ -1385,7 +1345,7 @@ make_directory_button (NautilusPathBar *path_bar,
/* do not set these for volumes */
if (button_data->type != VOLUME_BUTTON) {
button_data->dir_name = g_strdup (dir_name);
- button_data->path = g_strdup (path);
+ button_data->path = g_object_ref (path);
}
button_data->file_is_hidden = file_is_hidden;
@@ -1410,7 +1370,7 @@ make_directory_button (NautilusPathBar *path_bar,
static gboolean
nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
- const char *file_path)
+ GFile *location)
{
GList *list;
GList *current_path;
@@ -1423,7 +1383,7 @@ nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
ButtonData *button_data;
button_data = list->data;
- if (is_file_path_equal (file_path, button_data->path)) {
+ if (g_file_equal (location, button_data->path)) {
current_path = list;
break;
}
@@ -1464,55 +1424,36 @@ nautilus_path_bar_check_parent_path (NautilusPathBar *path_bar,
}
static char *
-get_parent_directory (const char *file_path)
+get_display_name_for_folder (GFile *location)
{
- GnomeVFSURI *vfs_uri, *parent_vfs_uri;
- char *parent_directory;
-
-
- vfs_uri = gnome_vfs_uri_new (file_path);
- if (vfs_uri == NULL) {
- return NULL;
- }
+ GFileInfo *info;
+ char *name;
- parent_vfs_uri = gnome_vfs_uri_get_parent (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
- if (parent_vfs_uri == NULL) {
- return NULL;
+ /* This does sync i/o, which isn't ideal.
+ * It should probably use the NautilusFile machinery
+ */
+
+ name = NULL;
+ info = g_file_query_info (location,
+ G_FILE_ATTRIBUTE_STD_DISPLAY_NAME,
+ 0, NULL, NULL);
+ if (info) {
+ name = g_strdup (g_file_info_get_display_name (info));
+ g_object_unref (info);
}
- parent_directory = gnome_vfs_uri_to_string (parent_vfs_uri,
- GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_vfs_uri);
- return parent_directory;
-
-}
-
-
-static char *
-get_display_name_for_folder (const char *file_path)
-{
- GnomeVFSURI *vfs_uri;
- NautilusFile *file;
- char *name;
-
- vfs_uri = gnome_vfs_uri_new (file_path);
- if (vfs_uri == NULL) {
- file = nautilus_file_get (file_path);
- name = nautilus_file_get_display_name (file);
- nautilus_file_unref (file);
- return name;
+ if (name == NULL) {
+ name = g_file_get_basename (location);
}
- name = nautilus_get_uri_shortname_for_display (vfs_uri);
- gnome_vfs_uri_unref (vfs_uri);
return name;
}
static gboolean
-nautilus_path_bar_update_path (NautilusPathBar *path_bar, const char *file_path)
+nautilus_path_bar_update_path (NautilusPathBar *path_bar, GFile *file_path)
{
- char *path, *parent_path, *name;
+ GFile *path, *parent_path;
+ char *name;
gboolean first_directory, last_directory;
gboolean result;
GList *new_buttons, *l, *fake_root;
@@ -1529,17 +1470,17 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar, const char *file_path)
last_directory = FALSE;
new_buttons = NULL;
- path = g_strdup (file_path);
+ path = g_object_ref (file_path);
gtk_widget_push_composite_child ();
while (path != NULL) {
- parent_path = get_parent_directory (path);
+ parent_path = g_file_get_parent (path);
name = get_display_name_for_folder (path);
last_directory = !parent_path;
button_data = make_directory_button (path_bar, name, path, first_directory, last_directory, FALSE);
- g_free (path);
+ g_object_unref (path);
g_free (name);
new_buttons = g_list_prepend (new_buttons, button_data);
@@ -1568,7 +1509,7 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar, const char *file_path)
}
gboolean
-nautilus_path_bar_set_path (NautilusPathBar *path_bar, const char *file_path)
+nautilus_path_bar_set_path (NautilusPathBar *path_bar, GFile *file_path)
{
g_return_val_if_fail (NAUTILUS_IS_PATH_BAR (path_bar), FALSE);
g_return_val_if_fail (file_path != NULL, FALSE);
diff --git a/src/nautilus-pathbar.h b/src/nautilus-pathbar.h
index 744c208b2..7a6f0d8bf 100644
--- a/src/nautilus-pathbar.h
+++ b/src/nautilus-pathbar.h
@@ -22,6 +22,7 @@
#define NAUTILUS_PATHBAR_H
#include <gtk/gtkcontainer.h>
+#include <gio/gfile.h>
typedef struct _NautilusPathBar NautilusPathBar;
typedef struct _NautilusPathBarClass NautilusPathBarClass;
@@ -38,9 +39,9 @@ struct _NautilusPathBar
{
GtkContainer parent;
- char *root_path;
- char *home_path;
- char *desktop_path;
+ GFile *root_path;
+ GFile *home_path;
+ GFile *desktop_path;
GdkPixbuf *root_icon;
GdkPixbuf *home_icon;
@@ -67,12 +68,12 @@ struct _NautilusPathBarClass
GtkContainerClass parent_class;
void (* path_clicked) (NautilusPathBar *path_bar,
- const char *file_path);
+ GFile *location);
};
GType nautilus_path_bar_get_type (void) G_GNUC_CONST;
-gboolean nautilus_path_bar_set_path (NautilusPathBar *path_bar, const char *file_path);
+gboolean nautilus_path_bar_set_path (NautilusPathBar *path_bar, GFile *file);
void nautilus_path_bar_clear_buttons (NautilusPathBar *path_bar);
void nautilus_path_bar_up (NautilusPathBar *path_bar);
diff --git a/src/nautilus-places-sidebar.c b/src/nautilus-places-sidebar.c
index 2a1b913bb..6d88d3f1e 100644
--- a/src/nautilus-places-sidebar.c
+++ b/src/nautilus-places-sidebar.c
@@ -51,11 +51,12 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-module.h>
+#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file-operations.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-volume-monitor.h>
+#include <gio/gvolumemonitor.h>
+#include <gio/gthemedicon.h>
#include "nautilus-bookmark-list.h"
#include "nautilus-places-sidebar.h"
@@ -73,6 +74,7 @@ typedef struct {
GtkTreeModel *filter_model;
NautilusWindowInfo *window;
NautilusBookmarkList *bookmarks;
+ GVolumeMonitor *volume_monitor;
/* DnD */
GList *drag_list;
@@ -188,16 +190,22 @@ static GtkTreeIter
add_place (NautilusPlacesSidebar *sidebar,
PlaceType place_type,
const char *name,
- const char *icon,
+ GIcon *icon,
const char *uri,
- GnomeVFSDrive *drive,
- GnomeVFSVolume *volume,
+ GDrive *drive,
+ GVolume *volume,
const int index)
{
GdkPixbuf *pixbuf;
GtkTreeIter iter, child_iter;
+ NautilusIconInfo *icon_info;
+ int icon_size;
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (icon, NULL, GTK_ICON_SIZE_MENU, NULL);
+ icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ icon_info = nautilus_icon_info_lookup (icon, icon_size);
+
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size);
+ g_object_unref (icon_info);
gtk_list_store_append (sidebar->store, &iter);
gtk_list_store_set (sidebar->store, &iter,
PLACES_SIDEBAR_COLUMN_ICON, pixbuf,
@@ -221,16 +229,19 @@ add_place (NautilusPlacesSidebar *sidebar,
static void
update_places (NautilusPlacesSidebar *sidebar)
{
- NautilusBookmark *bookmark;
- GtkTreeSelection *selection;
- GtkTreeIter iter, last_iter;
- GnomeVFSVolumeMonitor *volume_monitor;
- GList *volumes, *l, *ll;
- GnomeVFSVolume *volume;
- GList *drives;
- GnomeVFSDrive *drive;
- int bookmark_count, index;
- char *location, *icon, *mount_uri, *name, *desktop_path;
+ NautilusBookmark *bookmark;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter, last_iter;
+ GVolumeMonitor *volume_monitor;
+ GList *volumes, *l, *ll;
+ GVolume *volume;
+ GList *drives;
+ GDrive *drive;
+ int bookmark_count, index;
+ char *location, *mount_uri, *name, *desktop_path;
+ GIcon *icon;
+ GFile *root;
+
selection = gtk_tree_view_get_selection (sidebar->tree_view);
gtk_list_store_clear (sidebar->store);
@@ -244,9 +255,11 @@ update_places (NautilusPlacesSidebar *sidebar)
mount_uri = nautilus_get_home_directory_uri ();
display_name = g_filename_display_basename (g_get_home_dir ());
+ icon = g_themed_icon_new ("gnome-fs-home");
last_iter = add_place (sidebar, PLACES_BUILT_IN,
- display_name, "gnome-fs-home",
+ display_name, icon,
mount_uri, NULL, NULL, 0);
+ g_object_unref (icon);
g_free (display_name);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
@@ -254,10 +267,12 @@ update_places (NautilusPlacesSidebar *sidebar)
g_free (mount_uri);
}
- mount_uri = gnome_vfs_get_uri_from_local_path (desktop_path);
+ mount_uri = g_filename_to_uri (desktop_path, NULL, NULL);
+ icon = g_themed_icon_new ("gnome-fs-desktop");
last_iter = add_place (sidebar, PLACES_BUILT_IN,
- _("Desktop"), "gnome-fs-desktop",
+ _("Desktop"), icon,
mount_uri, NULL, NULL, 0);
+ g_object_unref (icon);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
}
@@ -265,45 +280,40 @@ update_places (NautilusPlacesSidebar *sidebar)
g_free (desktop_path);
mount_uri = "file:///"; /* No need to strdup */
+ icon = g_themed_icon_new ("gnome-dev-harddisk");
last_iter = add_place (sidebar, PLACES_BUILT_IN,
- _("File System"), "gnome-dev-harddisk",
+ _("File System"), icon,
mount_uri, NULL, NULL, 0);
+ g_object_unref (icon);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
}
/* for all drives add all its volumes */
- volume_monitor = gnome_vfs_get_volume_monitor ();
- drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor);
- drives = g_list_sort (drives, (GCompareFunc)gnome_vfs_drive_compare);
+ volume_monitor = sidebar->volume_monitor;
+ drives = g_volume_monitor_get_connected_drives (volume_monitor);
for (l = drives; l != NULL; l = l->next) {
drive = l->data;
- if (!gnome_vfs_drive_is_user_visible (drive)) {
- gnome_vfs_drive_unref (drive);
- continue;
- }
- if (gnome_vfs_drive_is_mounted (drive)) {
+ if (g_drive_has_volumes (drive)) {
/* The drive is mounted, add all its volumes */
- volumes = gnome_vfs_drive_get_mounted_volumes (drive);
- volumes = g_list_sort (volumes, (GCompareFunc)gnome_vfs_volume_compare);
+ volumes = g_drive_get_volumes (drive);
for (ll = volumes; ll != NULL; ll = ll->next) {
volume = ll->data;
- if (!gnome_vfs_volume_is_user_visible (volume)) {
- gnome_vfs_volume_unref (volume);
- continue;
- }
- icon = gnome_vfs_volume_get_icon (volume);
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- name = gnome_vfs_volume_get_display_name (volume);
+ icon = g_volume_get_icon (volume);
+
+ root = g_volume_get_root (volume);
+ mount_uri = g_file_get_uri (root);
+ g_object_unref (root);
+ name = g_volume_get_name (volume);
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
name, icon, mount_uri,
drive, volume, 0);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
}
- gnome_vfs_volume_unref (volume);
- g_free (icon);
+ g_object_unref (volume);
+ g_object_unref (icon);
g_free (name);
g_free (mount_uri);
}
@@ -312,54 +322,56 @@ update_places (NautilusPlacesSidebar *sidebar)
/* The drive is unmounted but visible, add it.
* This is for drives like floppy that can't be
* auto-mounted */
- icon = gnome_vfs_drive_get_icon (drive);
- name = gnome_vfs_drive_get_display_name (drive);
+ icon = g_drive_get_icon (drive);
+ name = g_drive_get_name (drive);
last_iter = add_place (sidebar, PLACES_BUILT_IN,
name, icon, NULL,
drive, NULL, 0);
- g_free (icon);
+ g_object_unref (icon);
g_free (name);
}
- gnome_vfs_drive_unref (drive);
+ g_object_unref (drive);
}
g_list_free (drives);
/* add mounted volumes that has no drive (ftp, sftp,...) */
- volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
- volumes = g_list_sort (volumes, (GCompareFunc)gnome_vfs_volume_compare);
+ volumes = g_volume_monitor_get_mounted_volumes (volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
volume = l->data;
- drive = gnome_vfs_volume_get_drive (volume);
- if (!gnome_vfs_volume_is_user_visible (volume) || drive != NULL) {
- gnome_vfs_drive_unref (drive);
- gnome_vfs_volume_unref (volume);
+ drive = g_volume_get_drive (volume);
+ if (drive != NULL) {
+ g_object_unref (drive);
+ g_object_unref (volume);
continue;
}
- icon = gnome_vfs_volume_get_icon (volume);
- mount_uri = gnome_vfs_volume_get_activation_uri (volume);
- name = gnome_vfs_volume_get_display_name (volume);
+ icon = g_volume_get_icon (volume);
+ root = g_volume_get_root (volume);
+ mount_uri = g_file_get_uri (root);
+ g_object_unref (root);
+ name = g_volume_get_name (volume);
last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME,
name, icon, mount_uri,
NULL, volume, 0);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
}
- gnome_vfs_volume_unref (volume);
- g_free (icon);
+ g_object_unref (volume);
+ g_object_unref (icon);
g_free (name);
g_free (mount_uri);
}
g_list_free (volumes);
mount_uri = "trash:///"; /* No need to strdup */
- icon = nautilus_trash_monitor_is_empty () ? "user-trash" : "user-trash-full";
+ icon = nautilus_trash_monitor_get_icon ();
last_iter = add_place (sidebar, PLACES_BUILT_IN,
_("Trash"), icon, mount_uri,
NULL, NULL, 0);
if (strcmp (location, mount_uri) == 0) {
gtk_tree_selection_select_iter (selection, &last_iter);
}
+ g_object_unref (icon);
/* add separator */
@@ -388,7 +400,7 @@ update_places (NautilusPlacesSidebar *sidebar)
gtk_tree_selection_select_iter (selection, &last_iter);
}
g_free (name);
- g_free (icon);
+ g_object_unref (icon);
g_free (mount_uri);
}
g_free (location);
@@ -419,16 +431,16 @@ nautilus_shortcuts_row_separator_func (GtkTreeModel *model,
static void
-volume_mounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_mounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
NautilusPlacesSidebar *sidebar)
{
update_places (sidebar);
}
static void
-volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume,
+volume_unmounted_callback (GVolumeMonitor *volume_monitor,
+ GVolume *volume,
NautilusPlacesSidebar *sidebar)
{
/* At this point the volume still appears to be mounted.
@@ -439,39 +451,22 @@ volume_unmounted_callback (GnomeVFSVolumeMonitor *volume_monitor,
}
static void
-drive_disconnected_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSDrive *drive,
+drive_disconnected_callback (GVolumeMonitor *volume_monitor,
+ GDrive *drive,
NautilusPlacesSidebar *sidebar)
{
update_places (sidebar);
}
static void
-drive_connected_callback (GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSDrive *drive,
+drive_connected_callback (GVolumeMonitor *volume_monitor,
+ GDrive *drive,
NautilusPlacesSidebar *sidebar)
{
update_places (sidebar);
}
static void
-volume_op_callback (gboolean succeeded,
- char *error,
- char *detailed_error,
- gpointer user_data)
-{
- if (!succeeded) {
- if (*error == 0 &&
- detailed_error != NULL && *detailed_error == 0) {
- /* This means the command displays its own errors */
- return;
- }
- eel_show_error_dialog_with_details (error, NULL,
- detailed_error, NULL);
- }
-}
-
-static void
row_activated_callback (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
@@ -674,7 +669,7 @@ can_accept_items_as_bookmarks (const GList *items)
*/
for (max = 100; items != NULL && max >= 0; items = items->next, max--) {
uri = ((NautilusDragSelectionItem *)items->data)->uri;
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
if (!can_accept_file_as_bookmark (file)) {
nautilus_file_unref (file);
return FALSE;
@@ -774,6 +769,8 @@ bookmarks_drop_uris (NautilusPlacesSidebar *sidebar,
char *uri, *name;
char **uris;
int i;
+ GFile *location;
+ GIcon *icon;
uris = gtk_selection_data_get_uris (selection_data);
if (!uris)
@@ -781,7 +778,7 @@ bookmarks_drop_uris (NautilusPlacesSidebar *sidebar,
for (i = 0; uris[i]; i++) {
uri = uris[i];
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
if (!can_accept_file_as_bookmark (file)) {
nautilus_file_unref (file);
@@ -789,17 +786,21 @@ bookmarks_drop_uris (NautilusPlacesSidebar *sidebar,
}
uri = nautilus_file_get_drop_target_uri (file);
+ location = g_file_new_for_uri (uri);
nautilus_file_unref (file);
- name = nautilus_compute_title_for_uri (uri);
+ name = nautilus_compute_title_for_location (location);
- bookmark = nautilus_bookmark_new_with_icon (uri, name,
- FALSE, "gnome-fs-directory");
+ icon = g_themed_icon_new ("gnome-fs-directory");
+ bookmark = nautilus_bookmark_new_with_icon (location, name,
+ FALSE, icon);
+ g_object_unref (icon);
if (!nautilus_bookmark_list_contains (sidebar->bookmarks, bookmark)) {
nautilus_bookmark_list_insert_item (sidebar->bookmarks, bookmark, position++);
}
+ g_object_unref (location);
g_object_unref (bookmark);
g_free (name);
g_free (uri);
@@ -1056,22 +1057,9 @@ bookmarks_popup_menu_detach_cb (GtkWidget *attach_widget,
sidebar->popup_menu_empty_trash_item = NULL;
}
-static gboolean
-eject_for_type (GnomeVFSDeviceType type)
-{
- switch (type) {
- case GNOME_VFS_DEVICE_TYPE_CDROM:
- case GNOME_VFS_DEVICE_TYPE_ZIP:
- case GNOME_VFS_DEVICE_TYPE_JAZ:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
static void
-check_visibility (GnomeVFSVolume *volume,
- GnomeVFSDrive *drive,
+check_visibility (GVolume *volume,
+ GDrive *drive,
gboolean *show_mount,
gboolean *show_unmount,
gboolean *show_eject,
@@ -1083,21 +1071,23 @@ check_visibility (GnomeVFSVolume *volume,
*show_format = FALSE;
if (volume != NULL) {
- *show_unmount = TRUE;
- *show_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
+ *show_unmount = g_volume_can_unmount (volume);
+ *show_eject = g_volume_can_eject (volume);
} else if (drive != NULL) {
- *show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
- if (gnome_vfs_drive_is_mounted (drive)) {
+ *show_eject = g_drive_can_eject (drive);
+ if (g_drive_has_volumes (drive)) {
*show_unmount = TRUE;
} else {
*show_mount = TRUE;
}
- if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
- !gnome_vfs_drive_is_mounted (drive) &&
+#ifdef TODO_GIO
+ if (something &&
g_find_program_in_path ("gfloppy")) {
*show_format = TRUE;
}
+#endif
+
}
}
@@ -1106,8 +1096,8 @@ bookmarks_check_popup_sensitivity (NautilusPlacesSidebar *sidebar)
{
GtkTreeIter iter;
PlaceType type;
- GnomeVFSDrive *drive = NULL;
- GnomeVFSVolume *volume = NULL;
+ GDrive *drive = NULL;
+ GVolume *volume = NULL;
gboolean show_mount;
gboolean show_unmount;
gboolean show_eject;
@@ -1172,6 +1162,7 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
gboolean open_in_new_window)
{
GtkTreeIter iter;
+ GFile *location;
char *uri;
if (!path) {
@@ -1188,35 +1179,31 @@ open_selected_bookmark (NautilusPlacesSidebar *sidebar,
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"activate from places sidebar window=%p: %s",
sidebar->window, uri);
+ location = g_file_new_for_uri (uri);
/* Navigate to the clicked location */
if (!open_in_new_window) {
- nautilus_window_info_open_location (sidebar->window, uri,
+ nautilus_window_info_open_location (sidebar->window, location,
NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE,
0, NULL);
} else {
NautilusWindow *cur, *new;
+
cur = NAUTILUS_WINDOW (sidebar->window);
new = nautilus_application_create_navigation_window (cur->application,
NULL,
gtk_window_get_screen (GTK_WINDOW (cur)));
- nautilus_window_go_to (new, uri);
+ nautilus_window_go_to (new, location);
}
+ g_object_unref (location);
g_free (uri);
} else {
- GnomeVFSDrive *drive;
+ GDrive *drive;
gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, -1);
if (drive != NULL) {
- char *path;
-
- path = gnome_vfs_drive_get_device_path (drive);
- nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "activate drive from places sidebar window=%p: %s",
- sidebar->window, path);
- g_free (path);
-
- gnome_vfs_drive_mount (drive, volume_op_callback, sidebar);
- gnome_vfs_drive_unref (drive);
+ /* TODO-gio: Handle callbacks etc */
+ g_drive_mount (drive, NULL, NULL, NULL, sidebar);
+ g_object_unref (drive);
}
}
}
@@ -1319,7 +1306,7 @@ mount_shortcut_cb (GtkMenuItem *item,
NautilusPlacesSidebar *sidebar)
{
GtkTreeIter iter;
- GnomeVFSDrive *drive;
+ GDrive *drive;
if (!get_selected_iter (sidebar, &iter)) {
return;
@@ -1330,8 +1317,9 @@ mount_shortcut_cb (GtkMenuItem *item,
-1);
if (drive != NULL) {
- gnome_vfs_drive_mount (drive, volume_op_callback, sidebar);
- gnome_vfs_drive_unref (drive);
+ /* TODO-gio: Handle callbacks etc */
+ g_drive_mount (drive, NULL, NULL, NULL, sidebar);
+ g_object_unref (drive);
}
}
@@ -1340,8 +1328,8 @@ unmount_shortcut_cb (GtkMenuItem *item,
NautilusPlacesSidebar *sidebar)
{
GtkTreeIter iter;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
+ GVolume *volume;
+ GDrive *drive;
if (!get_selected_iter (sidebar, &iter)) {
return;
@@ -1353,14 +1341,20 @@ unmount_shortcut_cb (GtkMenuItem *item,
-1);
if (volume != NULL) {
- nautilus_file_operations_unmount_volume (GTK_WIDGET (sidebar->tree_view),
- volume, volume_op_callback, sidebar);
- } else if (drive != NULL) {
- nautilus_file_operations_unmount_drive (GTK_WIDGET (sidebar->tree_view),
- drive, volume_op_callback, sidebar);
+ GtkWidget *toplevel;
+
+ /* TODO-gio: Handle callbacks etc */
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (sidebar->tree_view));
+
+ nautilus_file_operations_unmount_volume (GTK_WINDOW (toplevel),
+ volume, NULL, sidebar);
+ }
+ if (volume != NULL) {
+ g_object_unref (volume);
+ }
+ if (drive != NULL) {
+ g_object_unref (drive);
}
- gnome_vfs_volume_unref (volume);
- gnome_vfs_drive_unref (drive);
}
static void
@@ -1368,8 +1362,8 @@ eject_shortcut_cb (GtkMenuItem *item,
NautilusPlacesSidebar *sidebar)
{
GtkTreeIter iter;
- GnomeVFSVolume *volume;
- GnomeVFSDrive *drive;
+ GVolume *volume;
+ GDrive *drive;
if (!get_selected_iter (sidebar, &iter)) {
return;
@@ -1381,12 +1375,14 @@ eject_shortcut_cb (GtkMenuItem *item,
-1);
if (volume != NULL) {
- gnome_vfs_volume_eject (volume, volume_op_callback, sidebar);
+ /* TODO-gio: Handle callbacks etc */
+ g_volume_eject (volume, NULL, NULL, sidebar);
} else if (drive != NULL) {
- gnome_vfs_drive_eject (drive, volume_op_callback, sidebar);
+ /* TODO-gio: Handle callbacks etc */
+ g_drive_eject (drive, NULL, NULL, sidebar);
}
- gnome_vfs_volume_unref (volume);
- gnome_vfs_drive_unref (drive);
+ g_object_unref (volume);
+ g_object_unref (drive);
}
static void
@@ -1618,6 +1614,8 @@ nautilus_places_sidebar_init (NautilusPlacesSidebar *sidebar)
GtkCellRenderer *cell;
GtkTreeSelection *selection;
+ sidebar->volume_monitor = g_volume_monitor_get ();
+
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
@@ -1658,8 +1656,8 @@ nautilus_places_sidebar_init (NautilusPlacesSidebar *sidebar)
sidebar->store = gtk_list_store_new (PLACES_SIDEBAR_COLUMN_COUNT,
G_TYPE_INT,
G_TYPE_STRING,
- GNOME_VFS_TYPE_DRIVE,
- GNOME_VFS_TYPE_VOLUME,
+ G_TYPE_DRIVE,
+ G_TYPE_VOLUME,
G_TYPE_STRING,
GDK_TYPE_PIXBUF,
G_TYPE_INT
@@ -1746,6 +1744,8 @@ nautilus_places_sidebar_finalize (GObject *object)
sidebar->store = NULL;
}
+ g_object_unref (sidebar->volume_monitor);
+
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
click_policy_changed_callback,
sidebar);
@@ -1806,8 +1806,6 @@ static void
nautilus_places_sidebar_set_parent_window (NautilusPlacesSidebar *sidebar,
NautilusWindowInfo *window)
{
- GnomeVFSVolumeMonitor *volume_monitor;
-
sidebar->window = window;
sidebar->bookmarks = nautilus_window_info_get_bookmark_list (window);
@@ -1821,15 +1819,13 @@ nautilus_places_sidebar_set_parent_window (NautilusPlacesSidebar *sidebar,
G_CALLBACK (loading_uri_callback),
sidebar, 0);
- volume_monitor = gnome_vfs_get_volume_monitor ();
-
- g_signal_connect_object (volume_monitor, "volume_mounted",
+ g_signal_connect_object (sidebar->volume_monitor, "volume_mounted",
G_CALLBACK (volume_mounted_callback), sidebar, 0);
- g_signal_connect_object (volume_monitor, "volume_unmounted",
+ g_signal_connect_object (sidebar->volume_monitor, "volume_unmounted",
G_CALLBACK (volume_unmounted_callback), sidebar, 0);
- g_signal_connect_object (volume_monitor, "drive_disconnected",
+ g_signal_connect_object (sidebar->volume_monitor, "drive_disconnected",
G_CALLBACK (drive_disconnected_callback), sidebar, 0);
- g_signal_connect_object (volume_monitor, "drive_connected",
+ g_signal_connect_object (sidebar->volume_monitor, "drive_connected",
G_CALLBACK (drive_connected_callback), sidebar, 0);
update_places (sidebar);
diff --git a/src/nautilus-property-browser.c b/src/nautilus-property-browser.c
index ad6a2df78..03a3ea0c5 100644
--- a/src/nautilus-property-browser.c
+++ b/src/nautilus-property-browser.c
@@ -42,7 +42,6 @@
#include <eel/eel-labeled-image.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
#include <eel/eel-xml-extensions.h>
#include <librsvg/rsvg.h>
#include <libxml/parser.h>
@@ -67,6 +66,9 @@
#include <gtk/gtkvbox.h>
#include <gtk/gtkviewport.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
+#include <gio/gfile.h>
+#include <gio/gcontenttype.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-help.h>
#include <libgnomeui/gnome-color-picker.h>
@@ -74,12 +76,10 @@
#include <libgnomeui/gnome-help.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-customization-data.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-emblem-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-metadata.h>
@@ -690,7 +690,7 @@ nautilus_property_browser_drag_data_get (GtkWidget *widget,
g_free (user_directory);
}
- image_file_uri = gnome_vfs_get_uri_from_local_path (image_file_name);
+ image_file_uri = g_filename_to_uri (image_file_name, NULL, NULL);
gtk_selection_data_set (selection_data, selection_data->target, 8, image_file_uri, strlen (image_file_uri));
g_free (image_file_name);
g_free (image_file_uri);
@@ -714,22 +714,26 @@ nautilus_property_browser_drag_end (GtkWidget *widget, GdkDragContext *context)
/* utility routine to check if the passed-in uri is an image file */
static gboolean
-ensure_uri_is_image (const char *uri)
-{
- gboolean is_image;
- GnomeVFSResult result;
- GnomeVFSFileInfo *file_info;
-
- file_info = gnome_vfs_file_info_new ();
- result = gnome_vfs_get_file_info
- (uri, file_info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE
- | GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
- is_image = eel_istr_has_prefix (file_info->mime_type, "image/")
- && eel_strcasecmp (file_info->mime_type, "image/svg") != 0
- && eel_strcasecmp (file_info->mime_type, "image/svg+xml") != 0;
- gnome_vfs_file_info_unref (file_info);
- return is_image;
+ensure_file_is_image (GFile *file)
+{
+ GFileInfo *info;
+ const char *mime_type;
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_STD_CONTENT_TYPE, 0, NULL, NULL);
+ if (info == NULL) {
+ return FALSE;
+ }
+
+ mime_type = g_file_info_get_content_type (info);
+ if (mime_type == NULL) {
+ return FALSE;
+ }
+
+ g_object_unref (info);
+
+ return g_content_type_is_a (mime_type, "image/*") &&
+ !g_content_type_equals (mime_type, "image/svg") &&
+ !g_content_type_equals (mime_type, "image/svg+xml");
}
/* create the appropriate pixbuf for the passed in file */
@@ -741,6 +745,7 @@ make_drag_image (NautilusPropertyBrowser *property_browser, const char* file_nam
char *image_file_name;
char *icon_name;
gboolean is_reset;
+ NautilusIconInfo *info;
if (property_browser->details->category_type == NAUTILUS_PROPERTY_EMBLEM) {
if (strcmp (file_name, "erase") == 0) {
@@ -753,9 +758,9 @@ make_drag_image (NautilusPropertyBrowser *property_browser, const char* file_nam
g_free (image_file_name);
} else {
icon_name = nautilus_emblem_get_icon_name_from_keyword (file_name);
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name (icon_name, NULL,
- NAUTILUS_ICON_SIZE_STANDARD, TRUE,
- NULL);
+ info = nautilus_icon_info_lookup_from_name (file_name, NAUTILUS_ICON_SIZE_STANDARD);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_ICON_SIZE_STANDARD);
+ g_object_unref (info);
g_free (icon_name);
}
return pixbuf;
@@ -955,29 +960,27 @@ remove_color (NautilusPropertyBrowser *property_browser, const char* color_name)
static void
remove_pattern(NautilusPropertyBrowser *property_browser, const char* pattern_name)
{
- char *pattern_path, *pattern_uri;
+ char *pattern_path;
char *user_directory;
user_directory = nautilus_get_user_directory ();
/* build the pathname of the pattern */
- pattern_path = g_strdup_printf ("%s/patterns/%s",
- user_directory,
- pattern_name);
- pattern_uri = gnome_vfs_get_uri_from_local_path (pattern_path);
- g_free (pattern_path);
-
+ pattern_path = g_build_filename (user_directory,
+ "patterns",
+ pattern_name,
+ NULL);
g_free (user_directory);
/* delete the pattern from the pattern directory */
- if (gnome_vfs_unlink (pattern_uri) != GNOME_VFS_OK) {
+ if (g_unlink (pattern_path) != 0) {
char *message = g_strdup_printf (_("Sorry, but pattern %s couldn't be deleted."), pattern_name);
char *detail = _("Check that you have permission to delete the pattern.");
eel_show_error_dialog (message, detail, GTK_WINDOW (property_browser));
g_free (message);
}
- g_free (pattern_uri);
+ g_free (pattern_path);
}
/* remove the emblem matching the passed in name */
@@ -986,30 +989,28 @@ static void
remove_emblem (NautilusPropertyBrowser *property_browser, const char* emblem_name)
{
/* build the pathname of the emblem */
- char *emblem_path, *emblem_uri;
+ char *emblem_path;
char *user_directory;
user_directory = nautilus_get_user_directory ();
- emblem_path = g_strdup_printf ("%s/emblems/%s",
- user_directory,
- emblem_name);
- emblem_uri = gnome_vfs_get_uri_from_local_path (emblem_path);
- g_free (emblem_path);
+ emblem_path = g_build_filename (user_directory,
+ "emblems",
+ emblem_name,
+ NULL);
g_free (user_directory);
/* delete the emblem from the emblem directory */
- if (gnome_vfs_unlink (emblem_uri) != GNOME_VFS_OK) {
+ if (g_unlink (emblem_path) != 0) {
char *message = g_strdup_printf (_("Sorry, but emblem %s couldn't be deleted."), emblem_name);
char *detail = _("Check that you have permission to delete the emblem.");
eel_show_error_dialog (message, detail, GTK_WINDOW (property_browser));
g_free (message);
- }
- else {
+ } else {
emit_emblems_changed_signal ();
}
- g_free (emblem_uri);
+ g_free (emblem_path);
}
/* handle removing the passed in element */
@@ -1175,8 +1176,7 @@ add_pattern_to_browser (const char *path_name, gpointer *data)
char *directory_path, *source_file_name, *destination_name;
char *path_uri, *basename;
char *user_directory;
- char *directory_uri;
- GnomeVFSResult result;
+ GFile *src, *dest;
NautilusPropertyBrowser *property_browser = NAUTILUS_PROPERTY_BROWSER (data);
@@ -1197,10 +1197,10 @@ add_pattern_to_browser (const char *path_name, gpointer *data)
}
/* fetch the mime type and make sure that the file is an image */
- path_uri = gnome_vfs_get_uri_from_local_path (path_name);
+ path_uri = g_filename_to_uri (path_name, NULL, NULL);
/* don't allow the user to change the reset image */
- basename = eel_uri_get_basename (path_uri);
+ basename = g_path_get_basename (path_name);
if (basename && eel_strcmp (basename, RESET_IMAGE_NAME) == 0) {
eel_show_error_dialog (_("Sorry, but you can't replace the reset image."),
_("Reset is a special image that cannot be deleted."),
@@ -1222,24 +1222,24 @@ add_pattern_to_browser (const char *path_name, gpointer *data)
destination_name = g_build_filename (directory_path, source_file_name + 1, NULL);
/* make the directory if it doesn't exist */
- if (!g_file_test(directory_path, G_FILE_TEST_EXISTS)) {
- directory_uri = gnome_vfs_get_uri_from_local_path (directory_path);
- gnome_vfs_make_directory (directory_uri,
- GNOME_VFS_PERM_USER_ALL
- | GNOME_VFS_PERM_GROUP_ALL
- | GNOME_VFS_PERM_OTHER_READ);
- g_free (directory_uri);
+ if (!g_file_test (directory_path, G_FILE_TEST_EXISTS)) {
+ g_mkdir_with_parents (directory_path, 0775);
}
g_free (directory_path);
-
- result = eel_copy_uri_simple (path_name, destination_name);
- if (result != GNOME_VFS_OK) {
+
+ src = g_file_new_for_path (path_name);
+ dest = g_file_new_for_path (destination_name);
+ if (!g_file_copy (src, dest,
+ 0,
+ NULL, NULL, NULL, NULL)) {
char *message = g_strdup_printf (_("Sorry, but the pattern %s couldn't be installed."), path_name);
eel_show_error_dialog (message, NULL, GTK_WINDOW (property_browser));
g_free (message);
}
-
+ g_object_unref (src);
+ g_object_unref (dest);
+
g_free (destination_name);
/* update the property browser's contents to show the new one */
@@ -1414,17 +1414,18 @@ emblem_dialog_clicked (GtkWidget *dialog, int which_button, NautilusPropertyBrow
{
const char *new_keyword;
char *stripped_keyword;
- char *emblem_path, *emblem_uri;
+ char *emblem_path;
+ GFile *emblem_file;
GdkPixbuf *pixbuf;
-
+
if (which_button == GTK_RESPONSE_OK) {
/* update the image path from the file entry */
if (property_browser->details->file_entry) {
emblem_path = gnome_icon_entry_get_filename (GNOME_ICON_ENTRY (property_browser->details->file_entry));
if (emblem_path) {
- emblem_uri = gnome_vfs_get_uri_from_local_path (emblem_path);
- if (ensure_uri_is_image (emblem_uri)) {
+ emblem_file = g_file_new_for_path (emblem_path);
+ if (ensure_file_is_image (emblem_file)) {
g_free (property_browser->details->image_path);
property_browser->details->image_path = emblem_path;
} else {
@@ -1433,15 +1434,16 @@ emblem_dialog_clicked (GtkWidget *dialog, int which_button, NautilusPropertyBrow
eel_show_error_dialog (_("The file is not an image."), message, GTK_WINDOW (property_browser));
g_free (message);
g_free (emblem_path);
+ g_object_unref (emblem_file);
return;
}
- g_free (emblem_uri);
+ g_object_unref (emblem_file);
}
}
-
- emblem_uri = gnome_vfs_get_uri_from_local_path (property_browser->details->image_path);
- pixbuf = nautilus_emblem_load_pixbuf_for_emblem (emblem_uri);
- g_free (emblem_uri);
+
+ emblem_file = g_file_new_for_path (property_browser->details->image_path);
+ pixbuf = nautilus_emblem_load_pixbuf_for_emblem (emblem_file);
+ g_object_unref (emblem_file);
if (pixbuf == NULL) {
char *message = g_strdup_printf
@@ -1449,7 +1451,7 @@ emblem_dialog_clicked (GtkWidget *dialog, int which_button, NautilusPropertyBrow
eel_show_error_dialog (_("The file is not an image."), message, GTK_WINDOW (property_browser));
g_free (message);
}
-
+
new_keyword = gtk_entry_get_text(GTK_ENTRY(property_browser->details->keyword));
if (new_keyword == NULL) {
stripped_keyword = NULL;
@@ -1707,6 +1709,7 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser)
GtkWidget *blank;
guint num_images;
char *path;
+ NautilusIconInfo *info;
g_return_if_fail (NAUTILUS_IS_PROPERTY_BROWSER (property_browser));
g_return_if_fail (EEL_IS_IMAGE_TABLE (property_browser->details->content_table));
@@ -1717,7 +1720,7 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser)
eel_g_list_free_deep (property_browser->details->keywords);
property_browser->details->keywords = NULL;
- icons = nautilus_emblem_list_availible ();
+ icons = nautilus_emblem_list_available ();
l = icons;
while (l != NULL) {
@@ -1728,9 +1731,11 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser)
continue;
}
object_name = nautilus_emblem_get_keyword_from_icon_name (icon_name);
- object_pixbuf = nautilus_icon_factory_get_pixbuf_from_name (icon_name, NULL,
- NAUTILUS_ICON_SIZE_SMALL, TRUE,
- &object_label);
+ info = nautilus_icon_info_lookup_from_name (object_name, NAUTILUS_ICON_SIZE_STANDARD);
+ object_pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_ICON_SIZE_STANDARD);
+ object_label = g_strdup (nautilus_icon_info_get_display_name (info));
+ g_object_unref (info);
+
if (object_label == NULL) {
object_label = g_strdup (object_name);
}
@@ -1770,7 +1775,7 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser)
while (nautilus_customization_data_get_next_element_for_display (customization_data,
&object_name,
&object_pixbuf,
- &object_label) == GNOME_VFS_OK) {
+ &object_label)) {
property_image = labeled_image_new (object_label, object_pixbuf, object_name, PANGO_SCALE_LARGE);
@@ -1779,7 +1784,7 @@ make_properties_from_directories (NautilusPropertyBrowser *property_browser)
/* Keep track of ERASE objects to place them prominently later */
if (property_browser->details->category_type == NAUTILUS_PROPERTY_PATTERN
- && eel_str_is_equal (object_name, RESET_IMAGE_NAME)) {
+ && !eel_strcmp (object_name, RESET_IMAGE_NAME)) {
g_assert (reset_object == NULL);
reset_object = property_image;
}
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index b32379318..116a1122f 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -27,9 +27,9 @@
#include <string.h>
#include <libnautilus-private/nautilus-marshal.h>
#include <glib/gi18n.h>
+#include <gio/gcontenttype.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
-#include <eel/eel-mime-extensions.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtkbindings.h>
#include <gtk/gtkbutton.h>
@@ -46,8 +46,6 @@
#include <gtk/gtkfilechooserbutton.h>
#include "gtk/gtkcelllayout.h"
#include "gtk/gtkcellrenderertext.h"
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-mime-info.h>
typedef enum {
NAUTILUS_QUERY_EDITOR_ROW_LOCATION,
@@ -269,7 +267,7 @@ static GtkWidget *
location_row_create_widgets (NautilusQueryEditorRow *row)
{
GtkWidget *chooser;
-
+
chooser = gtk_file_chooser_button_new (_("Select folder to search in"),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (chooser), TRUE);
@@ -293,9 +291,15 @@ location_row_add_to_query (NautilusQueryEditorRow *row,
char *folder, *uri;
folder = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (row->type_widget));
- uri = gnome_vfs_get_uri_from_local_path (folder);
+ if (folder == NULL) {
+ /* I don't know why, but i got NULL here on initial search in browser mode
+ even with the location set to the homedir in create_widgets... */
+ folder = g_strdup (g_get_home_dir ());
+ }
+
+ uri = g_filename_to_uri (folder, NULL, NULL);
g_free (folder);
-
+
nautilus_query_set_location (query, uri);
g_free (uri);
}
@@ -317,7 +321,7 @@ location_add_rows_from_query (NautilusQueryEditor *editor,
if (uri == NULL) {
return;
}
- folder = gnome_vfs_get_local_path_from_uri (uri);
+ folder = g_filename_from_uri (uri, NULL, NULL);
g_free (uri);
if (folder == NULL) {
return;
@@ -521,20 +525,27 @@ type_combo_changed (GtkComboBox *combo_box, NautilusQueryEditorRow *row)
GtkWidget *toplevel;
GtkTreeSelection *selection;
- mime_infos = eel_mime_get_available_mime_types ();
+ mime_infos = g_content_types_get_registered ();
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
for (l = mime_infos; l != NULL; l = l->next) {
GtkTreeIter iter;
- EelMimeTypeInfo *info = l->data;
+ char *mime_type = l->data;
+ char *description;
+ description = g_content_type_get_description (mime_type);
+ if (description == NULL) {
+ description = g_strdup (mime_type);
+ }
+
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- 0, info->description,
- 1, info->mime_type,
+ 0, description,
+ 1, mime_type,
-1);
- eel_mime_type_info_free (info);
+ g_free (mime_type);
+ g_free (description);
}
g_list_free (mime_infos);
@@ -786,7 +797,7 @@ type_add_rows_from_query (NautilusQueryEditor *editor,
for (l = mime_types; l != NULL; l = l->next) {
mime_type = l->data;
- desc = gnome_vfs_mime_get_value (mime_type, "description");
+ desc = g_content_type_get_description (mime_type);
if (desc == NULL) {
desc = mime_type;
}
diff --git a/src/nautilus-shell-ui.xml b/src/nautilus-shell-ui.xml
index 343f7b59d..835784ab4 100644
--- a/src/nautilus-shell-ui.xml
+++ b/src/nautilus-shell-ui.xml
@@ -9,7 +9,7 @@
<placeholder name="Open Placeholder"/>
<separator/>
<placeholder name="Location Placeholder"/>
- <menuitem name="Connect to Server" action="Connect to Server"/>
+<!-- <menuitem name="Connect to Server" action="Connect to Server"/> -->
<separator/>
<placeholder name="File Items Placeholder"/>
<separator/>
diff --git a/src/nautilus-shell.c b/src/nautilus-shell.c
index 6938cd254..18cfa5f5a 100644
--- a/src/nautilus-shell.c
+++ b/src/nautilus-shell.c
@@ -36,7 +36,6 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtklabel.h>
@@ -45,7 +44,6 @@
#include <glib/gi18n.h>
#include <libgnomeui/gnome-stock-icons.h>
#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <stdlib.h>
@@ -134,7 +132,7 @@ static void
open_window (NautilusShell *shell, const char *uri, const char *startup_id,
const char *geometry, gboolean browser_window)
{
- char *home_uri;
+ GFile *location;
NautilusWindow *window;
if (browser_window ||
@@ -145,22 +143,23 @@ open_window (NautilusShell *shell, const char *uri, const char *startup_id,
if (uri == NULL) {
nautilus_window_go_home (window);
} else {
- nautilus_window_go_to (window, uri);
+ location = g_file_new_for_uri (uri);
+ nautilus_window_go_to (window, location);
+ g_object_unref (location);
}
} else {
- home_uri = NULL;
-
if (uri == NULL) {
- home_uri = nautilus_get_home_directory_uri ();
- uri = home_uri;
+ location = g_file_new_for_path (g_get_home_dir ());
+ } else {
+ location = g_file_new_for_uri (uri);
}
window = nautilus_application_present_spatial_window (shell->details->application,
NULL,
startup_id,
- uri,
+ location,
gdk_screen_get_default ());
- g_free (home_uri);
+ g_object_unref (location);
}
if (geometry != NULL && !GTK_WIDGET_VISIBLE (window)) {
@@ -380,10 +379,10 @@ save_window_states (void)
char *window_attributes;
int x, y, width, height;
char *location;
- EelStringList *states;
+ GPtrArray *states;
int screen_num = -1;
- states = NULL;
+ states = g_ptr_array_new ();
windows = nautilus_application_get_window_list ();
for (node = windows; node; node = g_list_next (node)) {
g_assert (node->data != NULL);
@@ -396,7 +395,7 @@ save_window_states (void)
gdk_window = GTK_WIDGET (window)->window;
gdk_window_get_root_origin (gdk_window, &x, &y);
- location = nautilus_window_get_location (window);
+ location = nautilus_window_get_location_uri (window);
screen_num = gdk_screen_get_number (
gtk_window_get_screen (GTK_WINDOW (window)));
@@ -407,27 +406,24 @@ save_window_states (void)
location,
screen_num);
g_free (location);
-
- if (states == NULL) {
- states = eel_string_list_new (TRUE);
- }
- eel_string_list_insert (states, window_attributes);
- g_free (window_attributes);
+
+ g_ptr_array_add (states, window_attributes);
}
+ g_ptr_array_add (states, NULL);
if (eel_preferences_key_is_writable (START_STATE_CONFIG)) {
- eel_preferences_set_string_list (START_STATE_CONFIG, states);
+ eel_preferences_set_string_array (START_STATE_CONFIG,
+ (char **) states->pdata);
}
- eel_string_list_free (states);
+ g_ptr_array_free (states, TRUE);
}
static void
-restore_one_window_callback (const char *attributes,
- gpointer callback_data)
+restore_one_window (const char *attributes, NautilusShell *shell)
{
- NautilusShell *shell;
- EelStringList *attribute_list;
+ char **attrs;
+ int attrs_len;
int x;
int y;
int width;
@@ -435,30 +431,40 @@ restore_one_window_callback (const char *attributes,
char *location;
NautilusWindow *window;
GdkScreen *screen = NULL;
- int screen_num;
- int list_length;
-
- g_return_if_fail (eel_strlen (attributes) > 0);
- g_return_if_fail (NAUTILUS_IS_SHELL (callback_data));
- shell = NAUTILUS_SHELL (callback_data);
+ g_return_if_fail (!eel_str_is_empty (attributes));
+ g_return_if_fail (NAUTILUS_IS_SHELL (shell));
- attribute_list = eel_string_list_new_from_tokens (attributes, ",", TRUE);
+ attrs = g_strsplit (attributes, ",", -1);
+ attrs_len = g_strv_length (attrs);
- list_length = eel_string_list_get_length (attribute_list);
+ x = 0;
+ y = 0;
+ width = 0;
+ height= 0;
+ location = NULL;
- eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_WIDTH, &width);
- eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_HEIGHT, &height);
- eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_X, &x);
- eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_Y, &y);
- location = eel_string_list_nth (attribute_list, WINDOW_STATE_ATTRIBUTE_LOCATION);
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_WIDTH) {
+ eel_str_to_int (attrs[WINDOW_STATE_ATTRIBUTE_WIDTH], &width);
+ }
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_HEIGHT) {
+ eel_str_to_int (attrs[WINDOW_STATE_ATTRIBUTE_HEIGHT], &width);
+ }
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_X) {
+ eel_str_to_int (attrs[WINDOW_STATE_ATTRIBUTE_X], &x);
+ }
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_Y) {
+ eel_str_to_int (attrs[WINDOW_STATE_ATTRIBUTE_Y], &y);
+ }
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_LOCATION) {
+ location = g_strdup (attrs[WINDOW_STATE_ATTRIBUTE_LOCATION]);
+ }
/* Support sessions with no screen number for backwards compat.
*/
- if (list_length >= WINDOW_STATE_ATTRIBUTE_SCREEN + 1) {
- eel_string_list_nth_as_integer (
- attribute_list, WINDOW_STATE_ATTRIBUTE_SCREEN, &screen_num);
-
+ if (attrs_len > WINDOW_STATE_ATTRIBUTE_SCREEN) {
+ int screen_num;
+ eel_str_to_int (attrs[WINDOW_STATE_ATTRIBUTE_SCREEN], &screen_num);
screen = gdk_display_get_screen (gdk_display_get_default (), screen_num);
} else {
screen = gdk_screen_get_default ();
@@ -468,11 +474,15 @@ restore_one_window_callback (const char *attributes,
/* don't always create object windows here */
#endif
if (eel_strlen (location) > 0) {
+ GFile *f;
+
+ f = g_file_new_for_uri (location);
window = nautilus_application_present_spatial_window (shell->details->application,
NULL,
NULL,
- location,
+ f,
screen);
+ g_object_unref (f);
} else {
window = nautilus_application_create_navigation_window (shell->details->application,
NULL,
@@ -484,23 +494,35 @@ restore_one_window_callback (const char *attributes,
gtk_widget_set_size_request (GTK_WIDGET (window), width, height);
g_free (location);
- eel_string_list_free (attribute_list);
+ g_strfreev (attrs);
}
/* returns TRUE if there was state info which has been used to create new windows */
static gboolean
restore_window_states (NautilusShell *shell)
{
- EelStringList *states;
+ char **states;
gboolean result;
+ int i;
+
+ result = FALSE;
+
+ states = eel_preferences_get_string_array (START_STATE_CONFIG);
+ if (!states) {
+ return result;
+ }
+
+ for (i = 0; states[i] != NULL; ++i) {
+ result = TRUE;
+ restore_one_window (states[i], shell);
+ }
- states = eel_preferences_get_string_list (START_STATE_CONFIG);
- result = eel_string_list_get_length (states) > 0;
- eel_string_list_for_each (states, restore_one_window_callback, shell);
- eel_string_list_free (states);
if (eel_preferences_key_is_writable (START_STATE_CONFIG)) {
- eel_preferences_set_string_list (START_STATE_CONFIG, NULL);
+ eel_preferences_set_string_array (START_STATE_CONFIG, NULL);
}
+
+ g_strfreev (states);
+
return result;
}
diff --git a/src/nautilus-sidebar-title.c b/src/nautilus-sidebar-title.c
index 924f6e176..7d01aded3 100644
--- a/src/nautilus-sidebar-title.c
+++ b/src/nautilus-sidebar-title.c
@@ -44,11 +44,8 @@
#include <gtk/gtksignal.h>
#include <gtk/gtkwidget.h>
#include <glib/gi18n.h>
-#include <libgnomevfs/gnome-vfs-types.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-sidebar.h>
#include <string.h>
@@ -144,10 +141,6 @@ nautilus_sidebar_title_init (NautilusSidebarTitle *sidebar_title)
{
sidebar_title->details = g_new0 (NautilusSidebarTitleDetails, 1);
- /* Register to find out about icon theme changes */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (update_icon), sidebar_title, G_CONNECT_SWAPPED);
-
/* Create the icon */
sidebar_title->details->icon = gtk_image_new ();
gtk_box_pack_start (GTK_BOX (sidebar_title), sidebar_title->details->icon, 0, 0, 0);
@@ -291,9 +284,9 @@ get_best_icon_size (NautilusSidebarTitle *sidebar_title)
if (width < 0) {
/* use smallest available icon size */
- return nautilus_icon_factory_get_smaller_icon_size (0);
+ return nautilus_icon_get_smaller_icon_size (0);
} else {
- return nautilus_icon_factory_get_smaller_icon_size ((guint) width);
+ return nautilus_icon_get_smaller_icon_size ((guint) width);
}
}
@@ -302,6 +295,7 @@ static void
update_icon (NautilusSidebarTitle *sidebar_title)
{
GdkPixbuf *pixbuf;
+ NautilusIconInfo *info;
char *icon_name;
gboolean leave_pixbuf_unchanged;
@@ -312,12 +306,16 @@ update_icon (NautilusSidebarTitle *sidebar_title)
pixbuf = NULL;
if (icon_name != NULL && icon_name[0] != '\0') {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name (icon_name, NULL, NAUTILUS_ICON_SIZE_LARGE, TRUE, NULL);
- } else if (nautilus_icon_factory_is_icon_ready_for_file (sidebar_title->details->file)) {
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file (sidebar_title->details->file,
- "accept",
- sidebar_title->details->best_icon_size,
- FALSE);
+ info = nautilus_icon_info_lookup_from_name (icon_name, NAUTILUS_ICON_SIZE_LARGE);
+ pixbuf = nautilus_icon_info_get_pixbuf_at_size (info, NAUTILUS_ICON_SIZE_LARGE);
+ g_object_unref (info);
+ } else if (sidebar_title->details->file != NULL &&
+ nautilus_file_check_if_ready (sidebar_title->details->file,
+ NAUTILUS_FILE_ATTRIBUTES_FOR_ICON)) {
+ pixbuf = nautilus_file_get_icon_pixbuf (sidebar_title->details->file,
+ sidebar_title->details->best_icon_size,
+ FALSE,
+ NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT);
} else if (sidebar_title->details->determined_icon) {
/* We used to know the icon for this file, but now the file says it isn't
* ready. This means that some file info has been invalidated, which
@@ -489,7 +487,7 @@ add_emblem (NautilusSidebarTitle *sidebar_title, GdkPixbuf *pixbuf)
static void
update_emblems (NautilusSidebarTitle *sidebar_title)
{
- GList *icons, *p;
+ GList *pixbufs, *p;
GdkPixbuf *pixbuf;
/* exit if we don't have the file yet */
@@ -503,22 +501,18 @@ update_emblems (NautilusSidebarTitle *sidebar_title)
NULL);
/* fetch the emblem icons from metadata */
- icons = nautilus_icon_factory_get_emblem_icons_for_file (sidebar_title->details->file, NULL);
+ pixbufs = nautilus_file_get_emblem_pixbufs (sidebar_title->details->file,
+ nautilus_icon_get_emblem_size_for_icon_size (NAUTILUS_ICON_SIZE_STANDARD),
+ FALSE,
+ NULL);
/* loop through the list of emblems, installing them in the box */
- for (p = icons; p != NULL; p = p->next) {
- pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
- (p->data, NULL,
- nautilus_icon_factory_get_emblem_size_for_icon_size (NAUTILUS_ICON_SIZE_STANDARD),
- NULL, NULL,
- FALSE, FALSE, NULL);
- if (pixbuf != NULL) {
- add_emblem (sidebar_title, pixbuf);
- g_object_unref (pixbuf);
- }
+ for (p = pixbufs; p != NULL; p = p->next) {
+ pixbuf = p->data;
+ add_emblem (sidebar_title, pixbuf);
+ g_object_unref (pixbuf);
}
-
- eel_g_list_free_deep (icons);
+ g_list_free (pixbufs);
}
/* return the filename text */
@@ -570,9 +564,7 @@ monitor_add (NautilusSidebarTitle *sidebar_title)
sidebar_title->details->monitoring_count = item_count_ready (sidebar_title);
- attributes = nautilus_icon_factory_get_required_file_attributes ();
- attributes |= NAUTILUS_FILE_ATTRIBUTE_METADATA;
-
+ attributes = NAUTILUS_FILE_ATTRIBUTES_FOR_ICON | NAUTILUS_FILE_ATTRIBUTE_METADATA;
if (sidebar_title->details->monitoring_count) {
attributes |= NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT;
}
diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c
index 0d8d509da..38c2c8d74 100644
--- a/src/nautilus-spatial-window.c
+++ b/src/nautilus-spatial-window.c
@@ -42,10 +42,11 @@
#include "nautilus-search-bar.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-zoom-control.h"
+#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-gtk-macros.h>
#include <eel/eel-string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkmain.h>
@@ -54,17 +55,12 @@
#include <gtk/gtkvbox.h>
#include <gtk/gtkuimanager.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-macros.h>
-#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/nautilus-dnd.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-horizontal-splitter.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-program-choosing.h>
@@ -93,8 +89,6 @@ struct _NautilusSpatialWindowDetails {
GtkWidget *location_icon;
GtkWidget *query_editor;
-
- GnomeVFSURI *location;
};
static const GtkTargetEntry location_button_drag_types[] = {
@@ -102,8 +96,7 @@ static const GtkTargetEntry location_button_drag_types[] = {
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
};
-GNOME_CLASS_BOILERPLATE (NautilusSpatialWindow, nautilus_spatial_window,
- NautilusWindow, NAUTILUS_TYPE_WINDOW)
+G_DEFINE_TYPE(NautilusSpatialWindow, nautilus_spatial_window, NAUTILUS_TYPE_WINDOW)
static gboolean
save_window_geometry_timeout (gpointer callback_data)
@@ -128,7 +121,7 @@ nautilus_spatial_window_configure_event (GtkWidget *widget,
window = NAUTILUS_SPATIAL_WINDOW (widget);
- GTK_WIDGET_CLASS (parent_class)->configure_event (widget, event);
+ GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->configure_event (widget, event);
/* Only save the geometry if the user hasn't resized the window
* for a second. Otherwise delay the callback another second.
@@ -172,7 +165,7 @@ nautilus_spatial_window_unrealize (GtkWidget *widget)
window = NAUTILUS_SPATIAL_WINDOW (widget);
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+ GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->unrealize (widget);
if (window->details->save_geometry_timeout_id != 0) {
g_source_remove (window->details->save_geometry_timeout_id);
@@ -209,8 +202,8 @@ nautilus_spatial_window_state_event (GtkWidget *widget,
event->new_window_state & GDK_WINDOW_STATE_ABOVE);
}
- if (GTK_WIDGET_CLASS (parent_class)->window_state_event != NULL) {
- return GTK_WIDGET_CLASS (parent_class)->window_state_event (widget, event);
+ if (GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->window_state_event != NULL) {
+ return GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->window_state_event (widget, event);
}
return FALSE;
@@ -225,7 +218,7 @@ nautilus_spatial_window_destroy (GtkObject *object)
window->details->content_box = NULL;
- GTK_OBJECT_CLASS (parent_class)->destroy (object);
+ GTK_OBJECT_CLASS (nautilus_spatial_window_parent_class)->destroy (object);
}
static void
@@ -235,18 +228,11 @@ nautilus_spatial_window_finalize (GObject *object)
window = NAUTILUS_SPATIAL_WINDOW (object);
- if (window->details->location != NULL) {
- gnome_vfs_uri_unref (window->details->location);
- }
-
if (window->details->last_geometry != NULL) {
g_free (window->details->last_geometry);
}
- g_free (window->details);
- window->details = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_spatial_window_parent_class)->finalize (object);
}
void
@@ -321,7 +307,7 @@ nautilus_spatial_window_show (GtkWidget *widget)
window = NAUTILUS_SPATIAL_WINDOW (widget);
- GTK_WIDGET_CLASS (parent_class)->show (widget);
+ GTK_WIDGET_CLASS (nautilus_spatial_window_parent_class)->show (widget);
if (NAUTILUS_WINDOW (window)->details->search_mode &&
window->details->query_editor != NULL) {
@@ -412,10 +398,11 @@ real_set_search_mode (NautilusWindow *window, gboolean search_mode,
}
}
-static char *
-real_get_icon_name (NautilusWindow *window)
+static NautilusIconInfo *
+real_get_icon (NautilusWindow *window)
{
- return nautilus_icon_factory_get_icon_for_file (window->details->viewed_file, FALSE);
+ return nautilus_file_get_icon (window->details->viewed_file, 48,
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
}
static gboolean
@@ -423,8 +410,7 @@ real_set_title (NautilusWindow *window, const char *title)
{
gboolean changed;
- changed = EEL_CALL_PARENT_WITH_RETURN_VALUE
- (NAUTILUS_WINDOW_CLASS, set_title, (window, title));
+ changed = NAUTILUS_WINDOW_CLASS (nautilus_spatial_window_parent_class)->set_title (window, title);
if (changed && title[0] == '\0') {
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
@@ -444,12 +430,11 @@ real_set_content_view_widget (NautilusWindow *window,
NautilusView *new_view)
{
GtkWidget *widget;
-
- EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, set_content_view_widget,
- (window, new_view));
+
+ NAUTILUS_WINDOW_CLASS (nautilus_spatial_window_parent_class)->set_content_view_widget (window, new_view);
widget = nautilus_view_get_widget (new_view);
-
+
gtk_container_add (GTK_CONTAINER (NAUTILUS_SPATIAL_WINDOW (window)->details->content_box),
widget);
}
@@ -474,7 +459,6 @@ real_get_default_size (NautilusWindow *window,
}
}
-
static void
real_set_throbber_active (NautilusWindow *window, gboolean active)
{
@@ -492,70 +476,82 @@ real_set_allow_up (NautilusWindow *window, gboolean allow)
SPATIAL_ACTION_CLOSE_PARENT_FOLDERS);
gtk_action_set_sensitive (action, allow);
- NAUTILUS_WINDOW_CLASS (parent_class)->set_allow_up (window, allow);
+ NAUTILUS_WINDOW_CLASS (nautilus_spatial_window_parent_class)->set_allow_up (window, allow);
}
static void
location_menu_item_activated_callback (GtkWidget *menu_item,
NautilusSpatialWindow *window)
{
- GnomeVFSURI *uri;
char *location;
+ GFile *current;
+ GFile *dest;
GdkEvent *event;
- uri = g_object_get_data (G_OBJECT (menu_item), "uri");
- location = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+ location = nautilus_window_get_location_uri (NAUTILUS_WINDOW (window));
+ current = g_file_new_for_uri (location);
+ g_free (location);
+
+ dest = g_object_get_data (G_OBJECT (menu_item), "uri");
+
event = gtk_get_current_event();
- if (!gnome_vfs_uri_equal (uri, window->details->location))
+ if (!g_file_equal (current, dest))
{
+ GFile *child;
gboolean close_behind;
GList *selection;
- GnomeVFSURI *child_uri;
close_behind = FALSE;
selection = NULL;
- child_uri = g_object_get_data (G_OBJECT(menu_item), "child_uri");
- if (child_uri != NULL) {
- char *child_location;
- child_location = gnome_vfs_uri_to_string (child_uri, GNOME_VFS_URI_HIDE_NONE);
- selection = g_list_prepend (NULL, child_location);
+
+ child = g_object_get_data (G_OBJECT(menu_item), "child_uri");
+ if (child != NULL) {
+ selection = g_list_prepend (NULL, g_object_ref (child));
}
+
if (event != NULL && ((GdkEventAny *) event)->type == GDK_BUTTON_RELEASE &&
(((GdkEventButton *) event)->button == 2 ||
(((GdkEventButton *) event)->state & GDK_SHIFT_MASK) != 0))
{
close_behind = TRUE;
}
- nautilus_window_open_location_with_selection (NAUTILUS_WINDOW (window), location, selection, close_behind);
+
+ nautilus_window_open_location_with_selection (NAUTILUS_WINDOW (window),
+ dest, selection, close_behind);
+
+ eel_g_object_list_free (selection);
}
if (event != NULL) {
gdk_event_free (event);
}
- g_free (location);
-
+ g_object_unref (current);
}
static void
got_file_info_for_location_menu_callback (NautilusFile *file,
gpointer callback_data)
{
- GtkWidget *icon;
GtkWidget *menu_item = callback_data;
+ GtkWidget *label;
+ GtkWidget *icon;
GdkPixbuf *pixbuf;
- char *icon_name;
+ char *name;
g_return_if_fail (NAUTILUS_IS_FILE (file));
pixbuf = NULL;
- icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- if (icon_name != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (icon_name, NULL, GTK_ICON_SIZE_MENU, NULL);
- g_free (icon_name);
- }
+ name = nautilus_file_get_display_name (file);
+ label = gtk_bin_get_child (GTK_BIN (menu_item));
+ gtk_label_set_label (GTK_LABEL (label), name);
+
+ pixbuf = nautilus_file_get_icon_pixbuf (file,
+ nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
+ TRUE,
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
if (pixbuf != NULL) {
icon = gtk_image_new_from_pixbuf (pixbuf);
@@ -622,53 +618,78 @@ location_button_pressed_callback (GtkWidget *widget,
}
static void
-location_button_clicked_callback (GtkWidget *widget, NautilusSpatialWindow *window)
+location_button_clicked_callback (GtkWidget *widget,
+ NautilusSpatialWindow *window)
{
GtkWidget *popup, *menu_item, *first_item = NULL;
- GnomeVFSURI *uri;
- GnomeVFSURI *child_uri;
- char *name;
+ char *location;
+ GFile *uri;
+ GFile *child_uri;
GMainLoop *loop;
-
- g_return_if_fail (window->details->location != NULL);
-
popup = gtk_menu_new ();
first_item = NULL;
- uri = gnome_vfs_uri_ref (window->details->location);
+
+ location = nautilus_window_get_location_uri (NAUTILUS_WINDOW (window));
+ g_return_if_fail (location != NULL);
+
+ uri = g_file_new_for_uri (location);
+ g_free (location);
+
child_uri = NULL;
while (uri != NULL) {
NautilusFile *file;
- char *uri_string;
+ char *name;
- name = nautilus_get_uri_shortname_for_display (uri);
+ file = nautilus_file_get (uri);
+
+ name = nautilus_file_get_display_name (file);
menu_item = gtk_image_menu_item_new_with_label (name);
g_free (name);
+
if (first_item == NULL) {
first_item = menu_item;
}
-
- uri_string = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
- file = nautilus_file_get (uri_string);
+
g_object_ref (menu_item);
nautilus_file_call_when_ready (file,
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY,
+ NAUTILUS_FILE_ATTRIBUTE_INFO,
got_file_info_for_location_menu_callback,
menu_item);
- g_free (uri_string);
gtk_widget_show (menu_item);
g_signal_connect (menu_item, "activate",
G_CALLBACK (location_menu_item_activated_callback),
window);
- g_object_set_data_full (G_OBJECT (menu_item), "uri", uri, (GDestroyNotify)gnome_vfs_uri_unref);
- g_object_set_data_full (G_OBJECT (menu_item), "child_uri", child_uri, (GDestroyNotify)gnome_vfs_uri_unref);
+
+ g_object_set_data_full (G_OBJECT (menu_item),
+ "uri",
+ g_object_ref (uri),
+ (GDestroyNotify)g_object_unref);
+
+ if (child_uri) {
+ g_object_set_data_full (G_OBJECT (menu_item),
+ "child_uri",
+ g_object_ref (child_uri),
+ (GDestroyNotify)g_object_unref);
+ }
gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), menu_item);
- child_uri = gnome_vfs_uri_ref (uri);
- uri = gnome_vfs_uri_get_parent (uri);
+ if (child_uri){
+ g_object_unref (child_uri);
+ }
+ child_uri = uri;
+ uri = g_file_get_parent (uri);
+ }
+
+ if (child_uri){
+ g_object_unref (child_uri);
}
+ if (uri){
+ g_object_unref (uri);
+ }
+
gtk_menu_set_screen (GTK_MENU (popup), gtk_widget_get_screen (widget));
loop = g_main_loop_new (NULL, FALSE);
@@ -710,8 +731,10 @@ location_button_drag_begin_callback (GtkWidget *widget,
{
GdkPixbuf *pixbuf;
- pixbuf = nautilus_icon_factory_get_pixbuf_for_file (NAUTILUS_WINDOW (window)->details->viewed_file,
- "open", get_dnd_icon_size (window), FALSE);
+ pixbuf = nautilus_file_get_icon_pixbuf (NAUTILUS_WINDOW (window)->details->viewed_file,
+ get_dnd_icon_size (window),
+ FALSE,
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING | NAUTILUS_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT);
gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0);
@@ -727,25 +750,23 @@ get_data_binder (NautilusDragEachSelectedItemDataGet iteratee,
gpointer data)
{
NautilusSpatialWindow *window;
+ char *location;
int icon_size;
- char *uri;
g_assert (NAUTILUS_IS_SPATIAL_WINDOW (iterator_context));
window = NAUTILUS_SPATIAL_WINDOW (iterator_context);
- uri = gnome_vfs_uri_to_string (window->details->location,
- GNOME_VFS_URI_HIDE_NONE);
-
+ location = nautilus_window_get_location_uri (NAUTILUS_WINDOW (window));
icon_size = get_dnd_icon_size (window);
- iteratee (uri,
+ iteratee (location,
0,
0,
icon_size,
icon_size,
data);
- g_free (uri);
+ g_free (location);
}
static void
@@ -762,38 +783,30 @@ location_button_drag_data_get_callback (GtkWidget *widget,
void
nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window,
- const char *location)
+ GFile *location)
{
- GnomeVFSURI *uri;
- char *name;
-
- uri = NULL;
if (location != NULL) {
- uri = gnome_vfs_uri_new (location);
- }
- if (uri != NULL) {
NautilusFile *file;
- GnomeVFSResult vfs_result_code;
-
- name = nautilus_get_uri_shortname_for_display (uri);
+ char *name;
+ GError *error;
+
+ file = nautilus_file_get (location);
+
+ /* FIXME: monitor for name change... */
+ name = nautilus_file_get_display_name (file);
gtk_label_set_label (GTK_LABEL (window->details->location_label),
name);
g_free (name);
gtk_widget_set_sensitive (window->details->location_button, TRUE);
- file = nautilus_file_get (location);
- vfs_result_code = nautilus_file_get_file_info_result (file);
- if (vfs_result_code == GNOME_VFS_OK) {
- char *icon_name;
+ error = nautilus_file_get_file_info_error (file);
+ if (error == NULL) {
GdkPixbuf *pixbuf;
- pixbuf = NULL;
-
- icon_name = nautilus_icon_factory_get_icon_for_file (file, FALSE);
- if (icon_name != NULL) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name_with_stock_size (icon_name, NULL, GTK_ICON_SIZE_MENU, NULL);
- g_free (icon_name);
- }
+ pixbuf = nautilus_file_get_icon_pixbuf (file,
+ nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
+ TRUE,
+ NAUTILUS_FILE_ICON_FLAGS_IGNORE_VISITING);
if (pixbuf != NULL) {
gtk_image_set_from_pixbuf (GTK_IMAGE (window->details->location_icon), pixbuf);
@@ -810,11 +823,6 @@ nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window,
"");
gtk_widget_set_sensitive (window->details->location_button, FALSE);
}
-
- if (window->details->location != NULL) {
- gnome_vfs_uri_unref (window->details->location);
- }
- window->details->location = uri;
}
static void
@@ -854,11 +862,14 @@ action_search_callback (GtkAction *action,
{
NautilusWindow *window;
char *uri;
+ GFile *f;
window = NAUTILUS_WINDOW (user_data);
uri = nautilus_search_directory_generate_new_uri ();
- nautilus_window_go_to (window, uri);
+ f = g_file_new_for_uri (uri);
+ nautilus_window_go_to (window, f);
+ g_object_unref (f);
g_free (uri);
}
@@ -885,7 +896,7 @@ static const GtkActionEntry spatial_entries[] = {
};
static void
-nautilus_spatial_window_instance_init (NautilusSpatialWindow *window)
+nautilus_spatial_window_init (NautilusSpatialWindow *window)
{
GtkRcStyle *rc_style;
GtkWidget *arrow;
@@ -894,8 +905,11 @@ nautilus_spatial_window_instance_init (NautilusSpatialWindow *window)
GtkUIManager *ui_manager;
GtkTargetList *targets;
const char *ui;
-
- window->details = g_new0 (NautilusSpatialWindowDetails, 1);
+
+ window->details = G_TYPE_INSTANCE_GET_PRIVATE (window,
+ NAUTILUS_TYPE_SPATIAL_WINDOW,
+ NautilusSpatialWindowDetails);
+
window->affect_spatial_window_on_next_location_change = TRUE;
vbox = gtk_vbox_new (FALSE, 0);
@@ -1016,8 +1030,8 @@ nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class)
real_prompt_for_location;
NAUTILUS_WINDOW_CLASS (class)->set_search_mode =
real_set_search_mode;
- NAUTILUS_WINDOW_CLASS (class)->get_icon_name =
- real_get_icon_name;
+ NAUTILUS_WINDOW_CLASS (class)->get_icon =
+ real_get_icon;
NAUTILUS_WINDOW_CLASS (class)->set_title =
real_set_title;
NAUTILUS_WINDOW_CLASS (class)->set_content_view_widget =
@@ -1038,5 +1052,6 @@ nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class)
gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK | GDK_MOD1_MASK,
"go_up", 1,
G_TYPE_BOOLEAN, TRUE);
-
+
+ g_type_class_add_private (G_OBJECT_CLASS (class), sizeof(NautilusSpatialWindowDetails));
}
diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h
index f8557b6ff..d2552a45e 100644
--- a/src/nautilus-spatial-window.h
+++ b/src/nautilus-spatial-window.h
@@ -57,12 +57,10 @@ struct _NautilusSpatialWindowClass {
GType nautilus_spatial_window_get_type (void);
-GtkWidget *nautilus_spatial_window_get (const char *uri);
void nautilus_spatial_window_save_geometry (NautilusSpatialWindow *window);
void nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window);
void nautilus_spatial_window_save_show_hidden_files_mode (NautilusSpatialWindow *window);
void nautilus_spatial_window_set_location_button (NautilusSpatialWindow *window,
- const char *location);
-
+ GFile *location);
#endif
diff --git a/src/nautilus-window-bookmarks.c b/src/nautilus-window-bookmarks.c
index 50d01f44d..2b0d54d4e 100644
--- a/src/nautilus-window-bookmarks.c
+++ b/src/nautilus-window-bookmarks.c
@@ -85,13 +85,13 @@ show_bogus_bookmark_window (NautilusWindow *window,
NautilusBookmark *bookmark)
{
GtkDialog *dialog;
- char *uri;
+ GFile *location;
char *uri_for_display;
char *prompt;
char *detail;
- uri = nautilus_bookmark_get_uri (bookmark);
- uri_for_display = eel_format_uri_for_display (uri);
+ location = nautilus_bookmark_get_location (bookmark);
+ uri_for_display = g_file_get_parse_name (location);
prompt = _("Do you want to remove any bookmarks with the "
"non-existing location from your list?");
@@ -105,13 +105,13 @@ show_bogus_bookmark_window (NautilusWindow *window,
g_signal_connect_data (dialog,
"response",
G_CALLBACK (remove_bookmarks_for_uri_if_yes),
- g_strdup (uri),
+ g_file_get_uri (location),
(GClosureNotify)g_free,
0);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_NO);
- g_free (uri);
+ g_object_unref (location);
g_free (uri_for_display);
g_free (detail);
}
@@ -325,9 +325,4 @@ nautilus_window_initialize_bookmarks_menu (NautilusWindow *window)
g_signal_connect_object (nautilus_get_bookmark_list (), "contents_changed",
G_CALLBACK (schedule_refresh_bookmarks_menu),
window, G_CONNECT_SWAPPED);
-
- /* Recreate static & dynamic parts of menu if icon theme changes */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (schedule_refresh_bookmarks_menu),
- window, G_CONNECT_SWAPPED);
}
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 13a71aad7..b25612011 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -44,16 +44,12 @@
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
+#include <eel/eel-mount-operation.h>
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
-#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-icon-theme.h>
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-uri.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-extension/nautilus-location-widget-provider.h>
#include <libnautilus-private/nautilus-debug-log.h>
#include <libnautilus-private/nautilus-file-attributes.h>
@@ -65,7 +61,6 @@
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-monitor.h>
#include <libnautilus-private/nautilus-search-directory.h>
-#include <libnautilus-private/nautilus-trash-directory.h>
#include <libnautilus-private/nautilus-view-factory.h>
#include <libnautilus-private/nautilus-window-info.h>
@@ -87,7 +82,7 @@ static void connect_view (NautilusWindow
static void disconnect_view (NautilusWindow *window,
NautilusView *view);
static void begin_location_change (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *new_selection,
NautilusLocationChangeType type,
guint distance,
@@ -101,9 +96,10 @@ static void create_content_view (NautilusWindow
const char *view_id);
static void display_view_selection_failure (NautilusWindow *window,
NautilusFile *file,
- const char *location);
+ GFile *location,
+ GError *error);
static void load_new_location (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *selection,
gboolean tell_current_content_view,
gboolean tell_new_content_view);
@@ -123,17 +119,18 @@ nautilus_window_report_selection_changed (NautilusWindowInfo *window)
/* set_displayed_location:
*/
static void
-set_displayed_location (NautilusWindow *window, const char *location)
+set_displayed_location (NautilusWindow *window, GFile *location)
{
- char *bookmark_uri;
+ GFile *bookmark_location;
gboolean recreate;
+ char *name;
if (window->current_location_bookmark == NULL || location == NULL) {
recreate = TRUE;
} else {
- bookmark_uri = nautilus_bookmark_get_uri (window->current_location_bookmark);
- recreate = !gnome_vfs_uris_match (bookmark_uri, location);
- g_free (bookmark_uri);
+ bookmark_location = nautilus_bookmark_get_location (window->current_location_bookmark);
+ recreate = !g_file_equal (bookmark_location, location);
+ g_object_unref (bookmark_location);
}
if (recreate) {
@@ -142,23 +139,30 @@ set_displayed_location (NautilusWindow *window, const char *location)
g_object_unref (window->last_location_bookmark);
}
window->last_location_bookmark = window->current_location_bookmark;
+ name = g_file_get_uri (location);
window->current_location_bookmark = (location == NULL) ? NULL
- : nautilus_bookmark_new (location, location);
+ : nautilus_bookmark_new (location, name);
+ g_free (name);
}
nautilus_window_update_title (window);
nautilus_window_update_icon (window);
}
static void
-check_bookmark_location_matches (NautilusBookmark *bookmark, const char *uri)
+check_bookmark_location_matches (NautilusBookmark *bookmark, GFile *location)
{
- char *bookmark_uri;
+ GFile *bookmark_location;
+ char *bookmark_uri, *uri;
- bookmark_uri = nautilus_bookmark_get_uri (bookmark);
- if (!gnome_vfs_uris_match (uri, bookmark_uri)) {
+ bookmark_location = nautilus_bookmark_get_location (bookmark);
+ if (!g_file_equal (location, bookmark_location)) {
+ bookmark_uri = g_file_get_uri (bookmark_location);
+ uri = g_file_get_uri (location);
g_warning ("bookmark uri is %s, but expected %s", bookmark_uri, uri);
+ g_free (uri);
+ g_free (bookmark_uri);
}
- g_free (bookmark_uri);
+ g_object_unref (bookmark_location);
}
/* Debugging function used to verify that the last_location_bookmark
@@ -173,7 +177,7 @@ check_last_bookmark_location_matches_window (NautilusWindow *window)
}
static void
-handle_go_back (NautilusNavigationWindow *window, const char *location)
+handle_go_back (NautilusNavigationWindow *window, GFile *location)
{
guint i;
GList *link;
@@ -212,7 +216,7 @@ handle_go_back (NautilusNavigationWindow *window, const char *location)
}
static void
-handle_go_forward (NautilusNavigationWindow *window, const char *location)
+handle_go_forward (NautilusNavigationWindow *window, GFile *location)
{
guint i;
GList *link;
@@ -251,10 +255,10 @@ handle_go_forward (NautilusNavigationWindow *window, const char *location)
}
static void
-handle_go_elsewhere (NautilusWindow *window, const char *location)
+handle_go_elsewhere (NautilusWindow *window, GFile *location)
{
#if !NEW_UI_COMPLETE
- if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
+ if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
/* Clobber the entire forward list, and move displayed location to back list */
nautilus_navigation_window_clear_forward_list (NAUTILUS_NAVIGATION_WINDOW (window));
@@ -263,7 +267,7 @@ handle_go_elsewhere (NautilusWindow *window, const char *location)
* This also avoids a problem where set_displayed_location
* didn't update last_location_bookmark since the uri didn't change.
*/
- if (!gnome_vfs_uris_match (window->details->location, location)) {
+ if (!g_file_equal (window->details->location, location)) {
/* Store bookmark for current location in back list, unless there is no current location */
check_last_bookmark_location_matches_window (window);
/* Use the first bookmark in the history list rather than creating a new one. */
@@ -271,7 +275,7 @@ handle_go_elsewhere (NautilusWindow *window, const char *location)
window->last_location_bookmark);
g_object_ref (NAUTILUS_NAVIGATION_WINDOW (window)->back_list->data);
}
- }
+ }
}
#endif
}
@@ -280,15 +284,15 @@ static void
update_up_button (NautilusWindow *window)
{
gboolean allowed;
- GnomeVFSURI *new_uri;
+ GFile *parent;
allowed = FALSE;
if (window->details->location != NULL) {
- new_uri = gnome_vfs_uri_new (window->details->location);
- if (new_uri != NULL) {
- allowed = gnome_vfs_uri_has_parent (new_uri);
- gnome_vfs_uri_unref (new_uri);
- }
+ parent = g_file_get_parent (window->details->location);
+ allowed = parent != NULL;
+ if (parent != NULL) {
+ g_object_unref (parent);
+ }
}
nautilus_window_allow_up (window, allowed);
@@ -298,8 +302,9 @@ static void
viewed_file_changed_callback (NautilusFile *file,
NautilusWindow *window)
{
- char *new_location;
+ GFile *new_location;
gboolean is_in_trash, was_in_trash;
+ char *uri;
g_assert (NAUTILUS_IS_FILE (file));
g_assert (NAUTILUS_IS_WINDOW (window));
@@ -335,70 +340,65 @@ viewed_file_changed_callback (NautilusFile *file,
end_location_change (window);
if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
- /* auto-show existing parent URI. */
- char *uri, *go_to_uri;
- NautilusFile *parent_file;
-
- parent_file = nautilus_file_get_parent (file);
- uri = nautilus_file_get_uri (parent_file);
-
- go_to_uri = nautilus_find_existing_uri_in_hierarchy (uri);
- if (go_to_uri != NULL) {
+ /* auto-show existing parent. */
+ GFile *go_to_file, *parent, *location;
+
+ go_to_file = NULL;
+ location = nautilus_file_get_location (file);
+ parent = g_file_get_parent (location);
+ g_object_unref (location);
+ if (parent) {
+ go_to_file = nautilus_find_existing_uri_in_hierarchy (parent);
+ g_object_unref (parent);
+ }
+
+ if (go_to_file != NULL) {
/* the path bar URI will be set to go_to_uri immediately
* in begin_location_change, but we don't want the
* inexistant children to show up anymore */
nautilus_path_bar_clear_buttons (NAUTILUS_PATH_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->path_bar));
- nautilus_window_go_to (NAUTILUS_WINDOW (window), go_to_uri);
- g_free (go_to_uri);
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), go_to_file);
+ g_object_unref (go_to_file);
} else {
nautilus_window_go_home (NAUTILUS_WINDOW (window));
}
-
- g_free (uri);
- nautilus_file_unref (parent_file);
} else {
nautilus_window_close (window);
}
}
} else {
- new_location = nautilus_file_get_uri (file);
+ new_location = nautilus_file_get_location (file);
- /* FIXME: We need to graft the fragment part of the
- * old location onto the new renamed location or we'll
- * lose the fragment part of the location altogether.
- * If we did that, then we woudn't need to ignore
- * fragments in this comparison.
- */
/* If the file was renamed, update location and/or
- * title. Ignore fragments in this comparison, because
- * NautilusFile omits the fragment part.
- */
- if (!eel_uris_match_ignore_fragments (new_location,
- window->details->location)) {
- g_free (window->details->location);
+ * title. */
+ if (!g_file_equal (new_location,
+ window->details->location)) {
+ g_object_unref (window->details->location);
window->details->location = new_location;
/* Check if we can go up. */
update_up_button (window);
#if !NEW_UI_COMPLETE
+ uri = g_file_get_uri (window->details->location);
if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) {
/* Change the location bar and path bar to match the current location. */
nautilus_navigation_bar_set_location
(NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar),
- window->details->location);
+ uri);
nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->path_bar),
- window->details->location);
- }
+ window->details->location);
+ }
if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
/* Change the location button to match the current location. */
nautilus_spatial_window_set_location_button
(NAUTILUS_SPATIAL_WINDOW (window),
window->details->location);
}
+ g_free (uri);
#endif
} else {
- g_free (new_location);
+ g_object_unref (new_location);
}
nautilus_window_update_title (window);
@@ -409,7 +409,7 @@ viewed_file_changed_callback (NautilusFile *file,
static void
update_history (NautilusWindow *window,
NautilusLocationChangeType type,
- const char *new_location)
+ GFile *new_location)
{
switch (type) {
case NAUTILUS_LOCATION_CHANGE_STANDARD:
@@ -469,24 +469,33 @@ new_window_show_callback (GtkWidget *widget,
void
nautilus_window_open_location_full (NautilusWindow *window,
- const char *location,
+ GFile *location,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags,
GList *new_selection)
{
NautilusWindow *target_window;
gboolean do_load_location = TRUE;
- char *old_location;
+ GFile *old_location;
+ char *old_uri, *new_uri;
target_window = NULL;
- old_location = nautilus_window_get_location (window);
+ old_uri = nautilus_window_get_location_uri (window);
+ if (old_uri == NULL) {
+ old_uri = g_strdup ("(none)");
+ }
+ new_uri = g_file_get_uri (location);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"window %p open location: old=\"%s\", new=\"%s\"",
window,
- old_location ? old_location : "(none)",
- location);
+ old_uri,
+ new_uri);
+ g_free (old_uri);
+ g_free (new_uri);
+
+ old_location = nautilus_window_get_location (window);
switch (mode) {
case NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE :
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
@@ -545,7 +554,7 @@ nautilus_window_open_location_full (NautilusWindow *window,
break;
default :
g_warning ("Unknown open location mode");
- g_free (old_location);
+ g_object_unref (old_location);
return;
}
@@ -566,15 +575,15 @@ nautilus_window_open_location_full (NautilusWindow *window,
}
if ((!do_load_location) ||
- (target_window == window && !eel_strcmp (old_location, location))) {
- g_free (old_location);
+ (target_window == window &&
+ old_location && g_file_equal (old_location, location))) {
+ g_object_unref (old_location);
return;
}
- g_free (old_location);
-
- if (!eel_is_valid_uri (location))
- g_warning ("Possibly invalid new URI '%s'\n"
- "This can cause subtle evils like #48423", location);
+
+ if (old_location) {
+ g_object_unref (old_location);
+ }
begin_location_change (target_window, location, new_selection,
NAUTILUS_LOCATION_CHANGE_STANDARD, 0, NULL);
@@ -582,7 +591,7 @@ nautilus_window_open_location_full (NautilusWindow *window,
void
nautilus_window_open_location (NautilusWindow *window,
- const char *location,
+ GFile *location,
gboolean close_behind)
{
NautilusWindowOpenFlags flags;
@@ -599,7 +608,7 @@ nautilus_window_open_location (NautilusWindow *window,
void
nautilus_window_open_location_with_selection (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *selection,
gboolean close_behind)
{
@@ -709,7 +718,7 @@ nautilus_window_content_view_matches_iid (NautilusWindow *window,
*/
static void
begin_location_change (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *new_selection,
NautilusLocationChangeType type,
guint distance,
@@ -736,10 +745,11 @@ begin_location_change (NautilusWindow *window,
g_assert (window->details->pending_location == NULL);
g_assert (window->details->pending_selection == NULL);
- window->details->pending_location = g_strdup (location);
+ window->details->pending_location = g_object_ref (location);
window->details->location_change_type = type;
window->details->location_change_distance = distance;
- window->details->pending_selection = eel_g_str_list_copy (new_selection);
+ window->details->tried_mount = FALSE;
+ window->details->pending_selection = eel_g_object_list_copy (new_selection);
window->details->pending_scroll_to = g_strdup (scroll_pos);
@@ -786,8 +796,7 @@ begin_location_change (NautilusWindow *window,
cancel_viewed_file_changed_callback (window);
nautilus_file_call_when_ready (window->details->determine_view_file,
- NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY |
- NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE |
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_METADATA,
got_file_info_for_view_selection_callback,
window);
@@ -864,7 +873,7 @@ setup_new_window (NautilusWindow *window, NautilusFile *file)
} else {
/* If there is a pending selection, we want to scroll to an item in
* the pending selection list. */
- scroll_string = g_strdup (window->details->pending_selection->data);
+ scroll_string = g_file_get_uri (window->details->pending_selection->data);
}
/* scroll_string might be NULL if there was no saved scroll position. */
@@ -874,31 +883,102 @@ setup_new_window (NautilusWindow *window, NautilusFile *file)
}
}
+typedef struct {
+ GCancellable *cancellable;
+ NautilusWindow *window;
+} MountNotMountedData;
+
+static void
+mount_not_mounted_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ MountNotMountedData *data;
+ NautilusWindow *window;
+ GError *error;
+ GCancellable *cancellable;
+
+ data = user_data;
+ window = data->window;
+ cancellable = data->cancellable;
+ g_free (data);
+
+ if (g_cancellable_is_cancelled (cancellable)) {
+ /* Cancelled, don't call back */
+ g_object_unref (cancellable);
+ return;
+ }
+
+ window->details->mount_cancellable = NULL;
+
+ window->details->determine_view_file = nautilus_file_get (window->details->pending_location);
+
+ error = NULL;
+ if (!g_mount_for_location_finish (G_FILE (source_object), res, &error)) {
+ window->details->mount_error = error;
+ got_file_info_for_view_selection_callback (window->details->determine_view_file, window);
+ window->details->mount_error = NULL;
+ g_error_free (error);
+ } else {
+ nautilus_file_invalidate_all_attributes (window->details->determine_view_file);
+ nautilus_file_call_when_ready (window->details->determine_view_file,
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_METADATA,
+ got_file_info_for_view_selection_callback,
+ window);
+ }
+
+ g_object_unref (cancellable);
+}
+
static void
got_file_info_for_view_selection_callback (NautilusFile *file,
gpointer callback_data)
{
- GnomeVFSResult vfs_result_code;
+ GError *error;
char *view_id;
char *mimetype;
NautilusWindow *window;
NautilusFile *viewed_file;
- char *location;
- char *home_uri;
-
+ GFile *location;
+ GMountOperation *mount_op;
+ MountNotMountedData *data;
+
window = callback_data;
g_assert (window->details->determine_view_file == file);
window->details->determine_view_file = NULL;
+ if (window->details->mount_error) {
+ error = window->details->mount_error;
+ } else {
+ error = nautilus_file_get_file_info_error (file);
+ }
+
+ if (error && error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_MOUNTED &&
+ !window->details->tried_mount) {
+ window->details->tried_mount = TRUE;
+
+ mount_op = eel_mount_operation_new (GTK_WINDOW (window));
+ location = nautilus_file_get_location (file);
+ data = g_new0 (MountNotMountedData, 1);
+ data->cancellable = g_cancellable_new ();
+ data->window = window;
+ window->details->mount_cancellable = data->cancellable;
+ g_mount_for_location (location, mount_op, window->details->mount_cancellable,
+ mount_not_mounted_callback, data);
+ g_object_unref (location);
+ g_object_unref (mount_op);
+
+ return;
+ }
+
location = window->details->pending_location;
view_id = NULL;
- vfs_result_code = nautilus_file_get_file_info_result (file);
- if (vfs_result_code == GNOME_VFS_OK
- || vfs_result_code == GNOME_VFS_ERROR_NOT_SUPPORTED
- || vfs_result_code == GNOME_VFS_ERROR_INVALID_URI) {
+ if (error == NULL ||
+ (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_SUPPORTED)) {
/* We got the information we need, now pick what view to use: */
mimetype = nautilus_file_get_mime_type (file);
@@ -944,7 +1024,7 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
g_free (view_id);
} else {
display_view_selection_failure (window, file,
- location);
+ location, error);
if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) {
/* Destroy never-had-a-chance-to-be-seen window. This case
@@ -961,16 +1041,18 @@ got_file_info_for_view_selection_callback (NautilusFile *file,
/* the user could have typed in a home directory that doesn't exist,
in which case going home would cause an infinite loop, so we
better test for that */
-
- if (!gnome_vfs_uris_match (location, "file:///")) {
- home_uri = nautilus_get_home_directory_uri ();
- if (!gnome_vfs_uris_match (home_uri, location)) {
+
+ if (!nautilus_is_root_directory (location)) {
+ if (!nautilus_is_home_directory (location)) {
nautilus_window_go_home (NAUTILUS_WINDOW (window));
} else {
+ GFile *root;
+
+ root = g_file_new_for_path ("/");
/* the last fallback is to go to a known place that can't be deleted! */
- nautilus_window_go_to (NAUTILUS_WINDOW (window), "file:///");
+ nautilus_window_go_to (NAUTILUS_WINDOW (window), root);
+ g_object_unref (root);
}
- g_free (home_uri);
} else {
gtk_object_destroy (GTK_OBJECT (window));
}
@@ -1067,7 +1149,7 @@ create_content_view (NautilusWindow *window,
FALSE,
TRUE);
- eel_g_list_free_deep (window->details->pending_selection);
+ eel_g_object_list_free (window->details->pending_selection);
window->details->pending_selection = NULL;
} else if (window->details->location != NULL) {
selection = nautilus_view_get_selection (window->content_view);
@@ -1076,7 +1158,7 @@ create_content_view (NautilusWindow *window,
selection,
FALSE,
TRUE);
- eel_g_list_free_deep (selection);
+ eel_g_object_list_free (selection);
} else {
/* Something is busted, there was no location to load.
Just load the homedir. */
@@ -1087,32 +1169,37 @@ create_content_view (NautilusWindow *window,
static void
load_new_location (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *selection,
gboolean tell_current_content_view,
gboolean tell_new_content_view)
{
GList *selection_copy;
NautilusView *view;
+ char *uri;
g_assert (NAUTILUS_IS_WINDOW (window));
g_assert (location != NULL);
- selection_copy = eel_g_str_list_copy (selection);
+ selection_copy = eel_g_object_list_copy (selection);
view = NULL;
/* Note, these may recurse into report_load_underway */
if (window->content_view != NULL && tell_current_content_view) {
view = window->content_view;
- nautilus_view_load_location (window->content_view, location);
+ uri = g_file_get_uri (location);
+ nautilus_view_load_location (window->content_view, uri);
+ g_free (uri);
}
if (window->new_content_view != NULL && tell_new_content_view &&
(!tell_current_content_view ||
window->new_content_view != window->content_view) ) {
view = window->new_content_view;
- nautilus_view_load_location (window->new_content_view, location);
+ uri = g_file_get_uri (location);
+ nautilus_view_load_location (window->new_content_view, uri);
+ g_free (uri);
}
if (view != NULL) {
/* window->new_content_view might have changed here if
@@ -1120,7 +1207,7 @@ load_new_location (NautilusWindow *window,
nautilus_view_set_selection (view, selection_copy);
}
- eel_g_list_free_deep (selection_copy);
+ eel_g_object_list_free (selection_copy);
}
/* A view started to load the location its viewing, either due to
@@ -1147,7 +1234,10 @@ static void
location_has_really_changed (NautilusWindow *window)
{
GtkWidget *widget;
- char *location_copy;
+ GFile *location_copy;
+ char *uri;
+
+ location_copy = NULL;
if (window->new_content_view != NULL) {
widget = nautilus_view_get_widget (window->new_content_view);
@@ -1160,8 +1250,8 @@ location_has_really_changed (NautilusWindow *window)
window->new_content_view = NULL;
}
- location_copy = g_strdup (window->details->pending_location);
if (window->details->pending_location != NULL) {
+ location_copy = g_object_ref (window->details->pending_location);
/* Tell the window we are finished. */
update_for_new_location (window);
}
@@ -1169,20 +1259,23 @@ location_has_really_changed (NautilusWindow *window)
free_location_change (window);
if (location_copy != NULL) {
- g_signal_emit_by_name (window, "loading_uri",
- location_copy);
- g_free (location_copy);
+ uri = g_file_get_uri (location_copy);
+ g_signal_emit_by_name (window, "loading_uri", uri);
+ g_free (uri);
+ g_object_unref (location_copy);
}
}
static void
-add_extension_extra_widgets (NautilusWindow *window, const char *uri)
+add_extension_extra_widgets (NautilusWindow *window, GFile *location)
{
GList *providers, *l;
GtkWidget *widget;
+ char *uri;
providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_LOCATION_WIDGET_PROVIDER);
+ uri = g_file_get_uri (location);
for (l = providers; l != NULL; l = l->next) {
NautilusLocationWidgetProvider *provider;
@@ -1192,6 +1285,7 @@ add_extension_extra_widgets (NautilusWindow *window, const char *uri)
nautilus_window_add_extra_location_widget (window, widget);
}
}
+ g_free (uri);
nautilus_module_extension_list_free (providers);
}
@@ -1213,10 +1307,11 @@ nautilus_window_show_trash_bar (NautilusWindow *window)
static void
update_for_new_location (NautilusWindow *window)
{
- char *new_location;
+ GFile *new_location;
NautilusFile *file;
NautilusDirectory *directory;
gboolean location_really_changed;
+ char *uri;
new_location = window->details->pending_location;
window->details->pending_location = NULL;
@@ -1225,10 +1320,14 @@ update_for_new_location (NautilusWindow *window)
update_history (window, window->details->location_change_type, new_location);
- location_really_changed = eel_strcmp (window->details->location, new_location) != 0;
+ location_really_changed =
+ window->details->location == NULL ||
+ !g_file_equal (window->details->location, new_location);
/* Set the new location. */
- g_free (window->details->location);
+ if (window->details->location) {
+ g_object_unref (window->details->location);
+ }
window->details->location = new_location;
/* Create a NautilusFile for this location, so we can catch it
@@ -1267,7 +1366,7 @@ update_for_new_location (NautilusWindow *window)
nautilus_window_set_search_mode (window, FALSE, NULL);
}
- if (NAUTILUS_IS_TRASH_DIRECTORY (directory)) {
+ if (nautilus_directory_is_in_trash (directory)) {
nautilus_window_show_trash_bar (window);
}
@@ -1285,18 +1384,19 @@ update_for_new_location (NautilusWindow *window)
nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->forward_list != NULL);
/* Change the location bar and path bar to match the current location. */
+ uri = g_file_get_uri (window->details->location);
nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar),
- window->details->location);
+ uri);
+ g_free (uri);
nautilus_path_bar_set_path (NAUTILUS_PATH_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->path_bar),
window->details->location);
nautilus_navigation_window_load_extension_toolbar_items (NAUTILUS_NAVIGATION_WINDOW (window));
}
-
+
if (NAUTILUS_IS_SPATIAL_WINDOW (window)) {
/* Change the location button to match the current location. */
- nautilus_spatial_window_set_location_button
- (NAUTILUS_SPATIAL_WINDOW (window),
- window->details->location);
+ nautilus_spatial_window_set_location_button (NAUTILUS_SPATIAL_WINDOW (window),
+ window->details->location);
}
#endif
}
@@ -1323,13 +1423,13 @@ nautilus_window_report_load_complete (NautilusWindow *window,
static void
end_location_change (NautilusWindow *window)
{
- char *location;
+ char *uri;
- location = nautilus_window_get_location (window);
- if (location) {
+ uri = nautilus_window_get_location_uri (window);
+ if (uri) {
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
- "finished loading window %p: %s", window, location);
- g_free (location);
+ "finished loading window %p: %s", window, uri);
+ g_free (uri);
}
nautilus_window_allow_stop (window, FALSE);
@@ -1346,16 +1446,23 @@ end_location_change (NautilusWindow *window)
static void
free_location_change (NautilusWindow *window)
{
- g_free (window->details->pending_location);
+ if (window->details->pending_location) {
+ g_object_unref (window->details->pending_location);
+ }
window->details->pending_location = NULL;
- eel_g_list_free_deep (window->details->pending_selection);
+ eel_g_object_list_free (window->details->pending_selection);
window->details->pending_selection = NULL;
/* Don't free pending_scroll_to, since thats needed until
* the load_complete callback.
*/
+ if (window->details->mount_cancellable != NULL) {
+ g_cancellable_cancel (window->details->mount_cancellable);
+ window->details->mount_cancellable = NULL;
+ }
+
if (window->details->determine_view_file != NULL) {
nautilus_file_cancel_call_when_ready
(window->details->determine_view_file,
@@ -1384,14 +1491,13 @@ cancel_location_change (NautilusWindow *window)
* be told, or it is the very pending change we wish
* to cancel.
*/
- selection = nautilus_view_get_selection (window->new_content_view);
+ selection = nautilus_view_get_selection (window->content_view);
load_new_location (window,
window->details->location,
selection,
TRUE,
FALSE);
- eel_g_list_free_deep (selection);
-
+ eel_g_object_list_free (selection);
}
end_location_change (window);
@@ -1402,7 +1508,7 @@ nautilus_window_report_view_failed (NautilusWindow *window,
NautilusView *view)
{
gboolean do_close_window;
- char *fallback_load_location;
+ GFile *fallback_load_location;
g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged.");
@@ -1419,7 +1525,7 @@ nautilus_window_report_view_failed (NautilusWindow *window,
if (window->details->location_change_type != NAUTILUS_LOCATION_CHANGE_FALLBACK) {
report_nascent_content_view_failure_to_user (window, view);
- fallback_load_location = g_strdup (window->details->pending_location);
+ fallback_load_location = g_object_ref (window->details->pending_location);
} else {
if (!GTK_WIDGET_VISIBLE (window)) {
do_close_window = TRUE;
@@ -1433,7 +1539,7 @@ nautilus_window_report_view_failed (NautilusWindow *window,
/* We loose the pending selection change here, but who cares... */
begin_location_change (window, fallback_load_location, NULL,
NAUTILUS_LOCATION_CHANGE_FALLBACK, 0, NULL);
- g_free (fallback_load_location);
+ g_object_unref (fallback_load_location);
}
if (do_close_window) {
@@ -1443,22 +1549,17 @@ nautilus_window_report_view_failed (NautilusWindow *window,
static void
display_view_selection_failure (NautilusWindow *window, NautilusFile *file,
- const char *location)
+ GFile *location, GError *error)
{
- GnomeVFSResult result_code;
char *full_uri_for_display;
char *uri_for_display;
char *error_message;
char *detail_message;
char *scheme_string;
- const char *host_name;
GtkDialog *dialog;
- GnomeVFSURI *vfs_uri;
- result_code = nautilus_file_get_file_info_result (file);
-
/* Some sort of failure occurred. How 'bout we tell the user? */
- full_uri_for_display = eel_format_uri_for_display (location);
+ full_uri_for_display = g_file_get_parse_name (location);
/* Truncate the URI so it doesn't get insanely wide. Note that even
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
@@ -1466,9 +1567,10 @@ display_view_selection_failure (NautilusWindow *window, NautilusFile *file,
uri_for_display = eel_str_middle_truncate
(full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_uri_for_display);
-
- switch (result_code) {
- case GNOME_VFS_OK:
+
+ error_message = NULL;
+ detail_message = NULL;
+ if (error == NULL) {
if (nautilus_file_is_directory (file)) {
error_message = g_strdup_printf
(_("Couldn't display \"%s\"."),
@@ -1482,91 +1584,63 @@ display_view_selection_failure (NautilusWindow *window, NautilusFile *file,
detail_message = g_strdup
(_("The location is not a folder."));
}
- break;
- case GNOME_VFS_ERROR_NOT_FOUND:
- error_message = g_strdup_printf
- (_("Couldn't find \"%s\"."),
- uri_for_display);
- detail_message = g_strdup
- (_("Please check the spelling and try again."));
- break;
-
- case GNOME_VFS_ERROR_INVALID_URI:
- error_message = g_strdup_printf
- (_("\"%s\" is not a valid location."),
- uri_for_display);
- detail_message = g_strdup
- (_("Please check the spelling and try again."));
- break;
-
- case GNOME_VFS_ERROR_NOT_SUPPORTED:
- /* Can't create a vfs_uri and get the method from that, because
- * gnome_vfs_uri_new might return NULL.
- */
- scheme_string = eel_str_get_prefix (location, ":");
- g_assert (scheme_string != NULL); /* Shouldn't have gotten this error unless there's a : separator. */
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup_printf (_("Nautilus cannot handle %s: locations."),
- scheme_string);
- g_free (scheme_string);
- break;
-
- case GNOME_VFS_ERROR_LOGIN_FAILED:
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("The attempt to log in failed."));
- break;
-
- case GNOME_VFS_ERROR_ACCESS_DENIED:
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("Access was denied."));
- break;
-
- case GNOME_VFS_ERROR_HOST_NOT_FOUND:
- /* This case can be hit for user-typed strings like "foo" due to
- * the code that guesses web addresses when there's no initial "/".
- * But this case is also hit for legitimate web addresses when
- * the proxy is set up wrong.
- */
- vfs_uri = gnome_vfs_uri_new (location);
- host_name = gnome_vfs_uri_get_host_name (vfs_uri);
- error_message = g_strdup_printf (_("Couldn't display \"%s\", because no host \"%s\" could be found."),
- uri_for_display,
- host_name ? host_name : "");
- detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct."));
- gnome_vfs_uri_unref (vfs_uri);
- break;
-
- case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS:
- error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("Check that your proxy settings are correct."));
- break;
-
- case GNOME_VFS_ERROR_NO_MASTER_BROWSER:
- error_message = g_strdup_printf
- (_("Couldn't display \"%s\", because Nautilus cannot contact the SMB master browser."),
- uri_for_display);
- detail_message = g_strdup
- (_("Check that an SMB server is running in the local network."));
- break;
-
- case GNOME_VFS_ERROR_CANCELLED:
- g_free (uri_for_display);
- return;
-
- case GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE:
+ } else if (error->domain == G_IO_ERROR) {
+ switch (error->code) {
+ case G_IO_ERROR_NOT_FOUND:
+ error_message = g_strdup_printf
+ (_("Couldn't find \"%s\"."),
+ uri_for_display);
+ detail_message = g_strdup
+ (_("Please check the spelling and try again."));
+ break;
+ case G_IO_ERROR_NOT_SUPPORTED:
+ scheme_string = g_file_get_uri_scheme (location);
+
+ error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
+ uri_for_display);
+ if (scheme_string != NULL) {
+ detail_message = g_strdup_printf (_("Nautilus cannot handle %s: locations."),
+ scheme_string);
+ } else {
+ detail_message = g_strdup (_("Nautilus cannot handle this kind of locations."));
+ }
+ g_free (scheme_string);
+ break;
+ case G_IO_ERROR_NOT_MOUNTED:
+ error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
+ uri_for_display);
+ detail_message = g_strdup (_("Unable to mount the location."));
+ break;
+
+ case G_IO_ERROR_PERMISSION_DENIED:
+ error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
+ uri_for_display);
+ detail_message = g_strdup (_("Access was denied."));
+ break;
+
+ case G_IO_ERROR_HOST_NOT_FOUND:
+ /* This case can be hit for user-typed strings like "foo" due to
+ * the code that guesses web addresses when there's no initial "/".
+ * But this case is also hit for legitimate web addresses when
+ * the proxy is set up wrong.
+ */
+ error_message = g_strdup_printf (_("Couldn't display \"%s\", because the host could be found."),
+ uri_for_display);
+ detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct."));
+ break;
+ case G_IO_ERROR_CANCELLED:
+ g_free (uri_for_display);
+ return;
+
+ default:
+ break;
+ }
+ }
+
+ if (error_message == NULL) {
error_message = g_strdup_printf (_("Couldn't display \"%s\"."),
uri_for_display);
- detail_message = g_strdup (_("Check if the service is available."));
- break;
-
- default:
- error_message = g_strdup_printf (_("Nautilus cannot display \"%s\"."),
- uri_for_display);
- detail_message = g_strdup (_("Please select another viewer and try again."));
+ detail_message = g_strdup_printf (_("Error: %s\nPlease select another viewer and try again."), error->message);
}
dialog = eel_show_error_dialog (error_message, detail_message, NULL);
@@ -1600,7 +1674,7 @@ nautilus_window_set_content_view (NautilusWindow *window,
g_return_if_fail (window->details->location != NULL);
g_return_if_fail (id != NULL);
- location = nautilus_window_get_location (window);
+ location = nautilus_window_get_location_uri (window);
nautilus_debug_log (FALSE, NAUTILUS_DEBUG_LOG_DOMAIN_USER,
"change view of window %p: \"%s\" to \"%s\"",
window, location, id);
@@ -1761,7 +1835,7 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
gboolean back, guint distance)
{
GList *list;
- char *uri;
+ GFile *location;
char *scroll_pos;
guint len;
NautilusBookmark *bookmark;
@@ -1780,16 +1854,16 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
distance = len - 1;
bookmark = g_list_nth_data (list, distance);
- uri = nautilus_bookmark_get_uri (bookmark);
+ location = nautilus_bookmark_get_location (bookmark);
scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark);
begin_location_change
(NAUTILUS_WINDOW (window),
- uri, NULL,
+ location, NULL,
back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD,
distance,
scroll_pos);
- g_free (uri);
+ g_object_unref (location);
g_free (scroll_pos);
}
@@ -1797,8 +1871,9 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window,
void
nautilus_window_reload (NautilusWindow *window)
{
- char *location;
+ GFile *location;
char *current_pos;
+ GList *selection_uris, *l;
GList *selection;
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
@@ -1810,19 +1885,25 @@ nautilus_window_reload (NautilusWindow *window)
/* window->details->location can be free'd during the processing
* of begin_location_change, so make a copy
*/
- location = g_strdup (window->details->location);
+ location = g_object_ref (window->details->location);
current_pos = NULL;
selection = NULL;
if (window->content_view != NULL) {
current_pos = nautilus_view_get_first_visible_file (window->content_view);
- selection = nautilus_view_get_selection (window->content_view);
+ selection_uris = nautilus_view_get_selection (window->content_view);
+ selection = NULL;
+ for (l = selection_uris; l != NULL; l = l->next) {
+ selection = g_list_prepend (selection, g_file_new_for_uri (l->data));
+ }
+ eel_g_list_free_deep (selection_uris);
+ selection = g_list_reverse (selection);
}
begin_location_change
(window, location, selection,
NAUTILUS_LOCATION_CHANGE_RELOAD, 0, current_pos);
g_free (current_pos);
- g_free (location);
- eel_g_list_free_deep (selection);
+ g_object_unref (location);
+ eel_g_object_list_free (selection);
}
static void
diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h
index ea91a8ea8..21d7ffca8 100644
--- a/src/nautilus-window-manage-views.h
+++ b/src/nautilus-window-manage-views.h
@@ -33,14 +33,14 @@
void nautilus_window_manage_views_destroy (NautilusWindow *window);
void nautilus_window_manage_views_finalize (NautilusWindow *window);
void nautilus_window_open_location (NautilusWindow *window,
- const char *location,
+ GFile *location,
gboolean close_behind);
void nautilus_window_open_location_with_selection (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *selection,
gboolean close_behind);
void nautilus_window_open_location_full (NautilusWindow *window,
- const char *location,
+ GFile *location,
NautilusWindowOpenMode mode,
NautilusWindowOpenFlags flags,
GList *new_selection);
diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c
index 39bcc5fe8..63b04c72e 100644
--- a/src/nautilus-window-menus.c
+++ b/src/nautilus-window-menus.c
@@ -31,7 +31,9 @@
#include "nautilus-actions.h"
#include "nautilus-application.h"
+#ifdef GIO_CONVERSION_DONE
#include "nautilus-connect-server-dialog.h"
+#endif
#include "nautilus-file-management-properties.h"
#include "nautilus-property-browser.h"
#include "nautilus-window-manage-views.h"
@@ -39,36 +41,22 @@
#include "nautilus-window-private.h"
#include "nautilus-desktop-window.h"
#include "nautilus-search-bar.h"
-#include <eel/eel-debug.h>
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-gtk-extensions.h>
-#include <eel/eel-stock-dialogs.h>
-#include <eel/eel-string.h>
-#include <eel/eel-vfs-extensions.h>
-#include <eel/eel-xml-extensions.h>
-#include <libxml/parser.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkaboutdialog.h>
#include <gtk/gtkenums.h>
#include <gtk/gtkversion.h>
-#include <libgnome/gnome-help.h>
+#include <gio/gvfs.h>
#include <glib/gi18n.h>
-#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-help.h>
-#include <libgnomeui/gnome-uidefs.h>
-#include <libgnomevfs/gnome-vfs-file-info.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-module.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-search-directory.h>
#include <libnautilus-private/nautilus-search-engine.h>
#include <libnautilus-private/nautilus-signaller.h>
+#include <string.h>
#define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions"
#define POPUP_PATH_EXTENSION_ACTIONS "/background/Before Zoom Items/Extension Actions"
@@ -128,16 +116,16 @@ static void
activate_bookmark_in_menu_item (GtkAction *action, gpointer user_data)
{
BookmarkHolder *holder;
- char *uri;
+ GFile *location;
holder = (BookmarkHolder *)user_data;
if (nautilus_bookmark_uri_known_not_to_exist (holder->bookmark)) {
holder->failed_callback (holder->window, holder->bookmark);
} else {
- uri = nautilus_bookmark_get_uri (holder->bookmark);
- nautilus_window_go_to (holder->window, uri);
- g_free (uri);
+ location = nautilus_bookmark_get_location (holder->bookmark);
+ nautilus_window_go_to (holder->window, location);
+ g_object_unref (location);
}
}
@@ -207,6 +195,8 @@ action_close_window_callback (GtkAction *action,
nautilus_window_close (NAUTILUS_WINDOW (user_data));
}
+#ifdef GIO_CONVERSION_DONE
+
static void
action_connect_to_server_callback (GtkAction *action,
gpointer user_data)
@@ -214,25 +204,34 @@ action_connect_to_server_callback (GtkAction *action,
NautilusWindow *window = NAUTILUS_WINDOW (user_data);
GtkWidget *dialog;
char *location;
- location = nautilus_window_get_location (window);
+ location = nautilus_window_get_location_uri (window);
dialog = nautilus_connect_server_dialog_new (window, location);
g_free (location);
gtk_widget_show (dialog);
}
+#endif
+
static gboolean
have_burn_uri (void)
{
static gboolean initialized = FALSE;
static gboolean res;
- GnomeVFSURI *uri;
+ GVfs *vfs;
+ int i;
+ const gchar * const * supported_uri_schemes;
if (!initialized) {
- uri = gnome_vfs_uri_new ("burn:///");
- res = uri != NULL;
- if (uri != NULL) {
- gnome_vfs_uri_unref (uri);
+ vfs = g_vfs_get_default ();
+ supported_uri_schemes = g_vfs_get_supported_uri_schemes (vfs);
+
+ res = FALSE;
+ for (i = 0; supported_uri_schemes != NULL && supported_uri_schemes[i] != NULL; i++) {
+ if (strcmp ("burn", supported_uri_schemes[i]) == 0) {
+ res = TRUE;
+ break;
+ }
}
initialized = TRUE;
}
@@ -265,45 +264,60 @@ static void
action_go_to_computer_callback (GtkAction *action,
gpointer user_data)
{
+ GFile *computer;
+ computer = g_file_new_for_uri (COMPUTER_URI);
nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- COMPUTER_URI);
+ computer);
+ g_object_unref (computer);
}
static void
action_go_to_network_callback (GtkAction *action,
gpointer user_data)
{
+ GFile *network;
+ network = g_file_new_for_uri (NETWORK_URI);
nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- NETWORK_URI);
+ network);
+ g_object_unref (network);
}
static void
action_go_to_templates_callback (GtkAction *action,
gpointer user_data)
{
- char *uri;
+ char *path;
+ GFile *location;
- nautilus_create_templates_directory ();
- uri = nautilus_get_templates_directory_uri ();
+ path = nautilus_get_templates_directory ();
+ location = g_file_new_for_path (path);
+ g_free (path);
nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- uri);
- g_free (uri);
+ location);
+ g_object_unref (location);
}
static void
action_go_to_trash_callback (GtkAction *action,
gpointer user_data)
{
+ GFile *trash;
+ trash = g_file_new_for_uri ("trash:///");
nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- EEL_TRASH_URI);
+ trash);
+ g_object_unref (trash);
}
static void
action_go_to_burn_cd_callback (GtkAction *action,
gpointer user_data)
{
+ GFile *burn;
+ burn = g_file_new_for_uri (BURN_CD_URI);
nautilus_window_go_to (NAUTILUS_WINDOW (user_data),
- BURN_CD_URI);
+ burn);
+ g_object_unref (burn);
+
}
static void
@@ -645,10 +659,12 @@ static const GtkActionEntry main_entries[] = {
N_("Normal Si_ze"), "<control>0", /* label, accelerator */
N_("Show the contents at the normal size"), /* tooltip */
G_CALLBACK (action_zoom_normal_callback) },
+#ifdef GIO_CONVERSION_DONE
{ "Connect to Server", NULL, /* name, stock id */
N_("Connect to _Server..."), NULL, /* label, accelerator */
N_("Connect to a remote computer or shared disk"), /* tooltip */
G_CALLBACK (action_connect_to_server_callback) },
+#endif
{ "Home", "gnome-fs-home", /* name, stock id */
N_("_Home Folder"), "<alt>Home", /* label, accelerator */
N_("Open your personal folder"), /* tooltip */
diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h
index a5f9ba7a5..9eead2364 100644
--- a/src/nautilus-window-private.h
+++ b/src/nautilus-window-private.h
@@ -68,7 +68,7 @@ struct NautilusWindowDetails
guint bookmarks_merge_id;
/* Current location. */
- char *location;
+ GFile *location;
char *title;
NautilusFile *viewed_file;
gboolean viewed_file_seen;
@@ -78,10 +78,13 @@ struct NautilusWindowDetails
/* New location. */
NautilusLocationChangeType location_change_type;
guint location_change_distance;
- char *pending_location;
+ GFile *pending_location;
char *pending_scroll_to;
GList *pending_selection;
NautilusFile *determine_view_file;
+ GCancellable *mount_cancellable;
+ GError *mount_error;
+ gboolean tried_mount;
/* View As choices */
GtkActionGroup *view_as_action_group; /* owned by ui_manager */
@@ -93,7 +96,7 @@ struct NautilusWindowDetails
char *extra_viewer;
/* Deferred location change. */
- char *location_to_change_to_at_idle;
+ GFile *location_to_change_to_at_idle;
guint location_change_at_idle_id;
NautilusWindowShowHiddenFilesMode show_hidden_files_mode;
@@ -203,11 +206,11 @@ void nautilus_window_set_viewed_file (Nautil
NautilusFile *file);
void nautilus_send_history_list_changed (void);
void nautilus_window_add_current_location_to_history_list (NautilusWindow *window);
-void nautilus_remove_from_history_list_no_notify (const char *location);
-gboolean nautilus_add_to_history_list_no_notify (const char *location,
+void nautilus_remove_from_history_list_no_notify (GFile *location);
+gboolean nautilus_add_to_history_list_no_notify (GFile *location,
const char *name,
gboolean has_custom_name,
- const char *icon);
+ GIcon *icon);
GList * nautilus_get_history_list (void);
void nautilus_window_bookmarks_preference_changed_callback (gpointer user_data);
void nautilus_window_update_icon (NautilusWindow *window);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index e2bc9bbf1..f9bf16fd4 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -32,7 +32,6 @@
#include "nautilus-actions.h"
#include "nautilus-application.h"
-#include "nautilus-bookmark-list.h"
#include "nautilus-bookmarks-window.h"
#include "nautilus-information-panel.h"
#include "nautilus-main.h"
@@ -56,12 +55,10 @@
#ifdef HAVE_X11_XF86KEYSYM_H
#include <X11/XF86keysym.h>
#endif
-#include <libgnomevfs/gnome-vfs-uri.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-file-attributes.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-horizontal-splitter.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <libnautilus-private/nautilus-program-choosing.h>
@@ -145,14 +142,6 @@ static const struct {
};
static void
-icons_changed_callback (GObject *factory, NautilusWindow *window)
-{
- g_return_if_fail (NAUTILUS_IS_WINDOW (window));
-
- nautilus_window_update_icon (window);
-}
-
-static void
nautilus_window_init (NautilusWindow *window)
{
GtkWidget *table;
@@ -195,13 +184,6 @@ nautilus_window_init (NautilusWindow *window)
GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0,
0, 0);
- /* Register IconFactory callback to update the window border icon
- * when the icon-theme is changed.
- */
- g_signal_connect_object (nautilus_icon_factory_get (), "icons_changed",
- G_CALLBACK (icons_changed_callback), window,
- 0);
-
/* Register to menu provider extension signal managing menu updates */
g_signal_connect_object (nautilus_signaller_get_current (), "popup_menu_changed",
G_CALLBACK (nautilus_window_load_extension_menus), window, G_CONNECT_SWAPPED);
@@ -248,20 +230,20 @@ nautilus_window_set_status (NautilusWindow *window, const char *text)
}
void
-nautilus_window_go_to (NautilusWindow *window, const char *uri)
+nautilus_window_go_to (NautilusWindow *window, GFile *location)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- nautilus_window_open_location (window, uri, FALSE);
+ nautilus_window_open_location (window, location, FALSE);
}
void
-nautilus_window_go_to_with_selection (NautilusWindow *window, const char *uri, GList *new_selection)
+nautilus_window_go_to_with_selection (NautilusWindow *window, GFile *location, GList *new_selection)
{
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- nautilus_window_open_location_with_selection (window, uri, new_selection, FALSE);
+ nautilus_window_open_location_with_selection (window, location, new_selection, FALSE);
}
static gboolean
@@ -274,10 +256,8 @@ nautilus_window_go_up_signal (NautilusWindow *window, gboolean close_behind)
void
nautilus_window_go_up (NautilusWindow *window, gboolean close_behind)
{
- GnomeVFSURI *current_uri;
- GnomeVFSURI *parent_uri;
+ GFile *parent;
GList *selection;
- char *parent_uri_string;
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
@@ -285,23 +265,19 @@ nautilus_window_go_up (NautilusWindow *window, gboolean close_behind)
return;
}
- current_uri = gnome_vfs_uri_new (window->details->location);
- parent_uri = gnome_vfs_uri_get_parent (current_uri);
- gnome_vfs_uri_unref (current_uri);
+ parent = g_file_get_parent (window->details->location);
- if (parent_uri == NULL) {
+ if (parent == NULL) {
return;
}
- parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE);
- gnome_vfs_uri_unref (parent_uri);
-
- selection = g_list_prepend (NULL, g_strdup (window->details->location));
+ selection = g_list_prepend (NULL, g_object_ref (window->details->location));
+
+ nautilus_window_open_location_with_selection (window, parent, selection, close_behind);
- nautilus_window_open_location_with_selection (window, parent_uri_string, selection, close_behind);
+ g_object_unref (parent);
- g_free (parent_uri_string);
- eel_g_list_free_deep (selection);
+ eel_g_object_list_free (selection);
}
static void
@@ -381,13 +357,13 @@ nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
void
nautilus_window_go_home (NautilusWindow *window)
{
- char *home_uri;
+ GFile *home;
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- home_uri = nautilus_get_home_directory_uri ();
- nautilus_window_open_location (window, home_uri, FALSE);
- g_free (home_uri);
+ home = g_file_new_for_path (g_get_home_dir ());
+ nautilus_window_open_location (window, home, FALSE);
+ g_object_unref (home);
}
void
@@ -401,11 +377,25 @@ nautilus_window_prompt_for_location (NautilusWindow *window,
}
char *
+nautilus_window_get_location_uri (NautilusWindow *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
+
+ if (window->details->location) {
+ return g_file_get_uri (window->details->location);
+ }
+ return NULL;
+}
+
+GFile *
nautilus_window_get_location (NautilusWindow *window)
{
g_return_val_if_fail (NAUTILUS_IS_WINDOW (window), NULL);
- return g_strdup (window->details->location);
+ if (window->details->location != NULL) {
+ return g_object_ref (window->details->location);
+ }
+ return NULL;
}
void
@@ -629,7 +619,9 @@ nautilus_window_finalize (GObject *object)
free_stored_viewers (window);
- g_free (window->details->location);
+ if (window->details->location) {
+ g_object_ref (window->details->location);
+ }
eel_g_list_free_deep (window->details->pending_selection);
if (window->current_location_bookmark != NULL) {
@@ -1101,7 +1093,7 @@ nautilus_window_load_view_as_menus (NautilusWindow *window)
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- attributes = nautilus_mime_actions_get_full_file_attributes ();
+ attributes = nautilus_mime_actions_get_required_file_attributes ();
cancel_view_as_callback (window);
nautilus_file_call_when_ready (window->details->viewed_file,
@@ -1136,7 +1128,7 @@ real_get_title (NautilusWindow *window)
}
if (title == NULL) {
- title = nautilus_compute_title_for_uri (window->details->location);
+ title = nautilus_compute_title_for_location (window->details->location);
}
return title;
@@ -1232,16 +1224,30 @@ nautilus_window_update_title (NautilusWindow *window)
void
nautilus_window_update_icon (NautilusWindow *window)
{
- char *icon_name;
+ NautilusIconInfo *info;
+ const char *icon_name;
+ GdkPixbuf *pixbuf;
g_return_if_fail (NAUTILUS_IS_WINDOW (window));
- icon_name = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
- get_icon_name, (window));
+ info = EEL_CALL_METHOD_WITH_RETURN_VALUE (NAUTILUS_WINDOW_CLASS, window,
+ get_icon, (window));
- if (icon_name != NULL) {
- gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
- g_free (icon_name);
+ icon_name = NULL;
+ if (info) {
+ icon_name = nautilus_icon_info_get_used_name (info);
+ if (icon_name != NULL) {
+ gtk_window_set_icon_name (GTK_WINDOW (window), icon_name);
+ } else {
+ pixbuf = nautilus_icon_info_get_pixbuf_nodefault (info);
+
+ if (pixbuf) {
+ gtk_window_set_icon (GTK_WINDOW (window), pixbuf);
+ }
+ g_object_unref (pixbuf);
+ }
+
+ g_object_unref (info);
}
}
@@ -1347,7 +1353,9 @@ nautilus_window_set_viewed_file (NautilusWindow *window,
}
if (file != NULL) {
- attributes = NAUTILUS_FILE_ATTRIBUTE_DISPLAY_NAME | NAUTILUS_FILE_ATTRIBUTE_SLOW_MIME_TYPE;
+ attributes =
+ NAUTILUS_FILE_ATTRIBUTE_INFO |
+ NAUTILUS_FILE_ATTRIBUTE_LINK_INFO;
nautilus_file_monitor_add (file, window, attributes);
}
@@ -1438,25 +1446,25 @@ add_to_history_list (NautilusBookmark *bookmark)
}
void
-nautilus_remove_from_history_list_no_notify (const char *uri)
+nautilus_remove_from_history_list_no_notify (GFile *location)
{
NautilusBookmark *bookmark;
- bookmark = nautilus_bookmark_new (uri, "");
+ bookmark = nautilus_bookmark_new (location, "");
remove_from_history_list (bookmark);
g_object_unref (bookmark);
}
gboolean
-nautilus_add_to_history_list_no_notify (const char *uri,
+nautilus_add_to_history_list_no_notify (GFile *location,
const char *name,
gboolean has_custom_name,
- const char *icon)
+ GIcon *icon)
{
NautilusBookmark *bookmark;
gboolean ret;
- bookmark = nautilus_bookmark_new_with_icon (uri, name, has_custom_name, icon);
+ bookmark = nautilus_bookmark_new_with_icon (location, name, has_custom_name, icon);
ret = add_to_history_list (bookmark);
g_object_unref (bookmark);
@@ -1600,7 +1608,7 @@ nautilus_window_info_iface_init (NautilusWindowInfoIface *iface)
iface->get_title = nautilus_window_get_cached_title;
iface->get_history = nautilus_window_get_history;
iface->get_bookmark_list = nautilus_window_get_bookmark_list;
- iface->get_current_location = nautilus_window_get_location;
+ iface->get_current_location = nautilus_window_get_location_uri;
iface->get_ui_manager = nautilus_window_get_ui_manager;
iface->get_selection_count = nautilus_window_get_selection_count;
iface->get_selection = nautilus_window_get_selection;
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index 1d2f0bd55..d4ae6d428 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -68,7 +68,7 @@ typedef struct {
char * (* get_title) (NautilusWindow *window);
gboolean (* set_title) (NautilusWindow *window, const char *title);
- char * (* get_icon_name) (NautilusWindow *window);
+ NautilusIconInfo * (* get_icon) (NautilusWindow *window);
void (* load_view_as_menu) (NautilusWindow *window);
void (* set_content_view_widget) (NautilusWindow *window,
@@ -119,11 +119,12 @@ struct NautilusWindow {
GType nautilus_window_get_type (void);
void nautilus_window_show_window (NautilusWindow *window);
void nautilus_window_close (NautilusWindow *window);
-char * nautilus_window_get_location (NautilusWindow *window);
+char * nautilus_window_get_location_uri (NautilusWindow *window);
+GFile * nautilus_window_get_location (NautilusWindow *window);
void nautilus_window_go_to (NautilusWindow *window,
- const char *location);
+ GFile *location);
void nautilus_window_go_to_with_selection (NautilusWindow *window,
- const char *location,
+ GFile *location,
GList *new_selection);
void nautilus_window_go_home (NautilusWindow *window);
void nautilus_window_go_up (NautilusWindow *window,
diff --git a/src/nautilus-zoom-control.h b/src/nautilus-zoom-control.h
index 36120187a..51b66de5f 100644
--- a/src/nautilus-zoom-control.h
+++ b/src/nautilus-zoom-control.h
@@ -29,7 +29,7 @@
#define NAUTILUS_ZOOM_CONTROL_H
#include <gtk/gtkhbox.h>
-#include <libnautilus-private/nautilus-icon-factory.h> /* For NautilusZoomLevel */
+#include <libnautilus-private/nautilus-icon-info.h> /* For NautilusZoomLevel */
#define NAUTILUS_TYPE_ZOOM_CONTROL (nautilus_zoom_control_get_type ())
#define NAUTILUS_ZOOM_CONTROL(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ZOOM_CONTROL, NautilusZoomControl))
diff --git a/test/Makefile.am b/test/Makefile.am
index b6fd4cd70..d018fea59 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -16,8 +16,11 @@ noinst_PROGRAMS =\
test-nautilus-wrap-table \
test-nautilus-search-engine \
test-nautilus-directory-async \
+ test-nautilus-copy \
$(NULL)
+test_nautilus_copy_SOURCES = test-copy.c test.c
+
test_nautilus_wrap_table_SOURCES = test-nautilus-wrap-table.c test.c
test_nautilus_search_engine_SOURCES = test-nautilus-search-engine.c
diff --git a/test/test-copy.c b/test/test-copy.c
new file mode 100644
index 000000000..c71cda907
--- /dev/null
+++ b/test/test-copy.c
@@ -0,0 +1,93 @@
+#include "test.h"
+
+#include <libnautilus-private/nautilus-file-operations.h>
+#include <libnautilus-private/nautilus-progress-info.h>
+
+static void
+copy_done (GHashTable *debuting_uris, gpointer data)
+{
+ g_print ("Copy done\n");
+}
+
+static void
+changed_cb (NautilusProgressInfo *info,
+ gpointer data)
+{
+ g_print ("Changed: %s -- %s\n",
+ nautilus_progress_info_get_status (info),
+ nautilus_progress_info_get_details (info));
+}
+
+static void
+progress_changed_cb (NautilusProgressInfo *info,
+ gpointer data)
+{
+ g_print ("Progress changed: %f\n",
+ nautilus_progress_info_get_progress (info));
+}
+
+static void
+finished_cb (NautilusProgressInfo *info,
+ gpointer data)
+{
+ g_print ("Finished\n");
+ gtk_main_quit ();
+}
+
+int
+main (int argc, char* argv[])
+{
+ GtkWidget *window;
+ GList *sources;
+ GFile *dest;
+ GFile *source;
+ int i;
+ GList *infos;
+ NautilusProgressInfo *progress_info;
+
+ g_thread_init (NULL);
+
+ test_init (&argc, &argv);
+
+ if (argc < 3) {
+ g_print ("Usage test-copy <sources...> <dest dir>\n");
+ return 1;
+ }
+
+ sources = NULL;
+ for (i = 1; i < argc - 1; i++) {
+ source = g_file_new_for_commandline_arg (argv[i]);
+ sources = g_list_prepend (sources, source);
+ }
+ sources = g_list_reverse (sources);
+
+ dest = g_file_new_for_commandline_arg (argv[i]);
+
+ window = test_window_new ("copy test", 5);
+
+ gtk_widget_show (window);
+
+ nautilus_file_operations_copy (sources,
+ NULL /* GArray *relative_item_points */,
+ dest,
+ GTK_WINDOW (window),
+ copy_done, NULL);
+
+ infos = nautilus_get_all_progress_info ();
+
+ if (infos == NULL) {
+ return 0;
+ }
+
+ progress_info = NAUTILUS_PROGRESS_INFO (infos->data);
+
+ g_signal_connect (progress_info, "changed", (GCallback)changed_cb, NULL);
+ g_signal_connect (progress_info, "progress-changed", (GCallback)progress_changed_cb, NULL);
+ g_signal_connect (progress_info, "finished", (GCallback)finished_cb, NULL);
+
+ gtk_main ();
+
+ return 0;
+}
+
+
diff --git a/test/test-nautilus-directory-async.c b/test/test-nautilus-directory-async.c
index 0bb82f85c..49098c4c5 100644
--- a/test/test-nautilus-directory-async.c
+++ b/test/test-nautilus-directory-async.c
@@ -1,5 +1,4 @@
#include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-directory.h>
#include <libnautilus-private/nautilus-search-directory.h>
#include <libnautilus-private/nautilus-file.h>
@@ -84,12 +83,11 @@ main (int argc, char **argv)
client1 = g_new0 (int, 1);
client2 = g_new0 (int, 1);
- gnome_vfs_init ();
gtk_init (&argc, &argv);
query = nautilus_query_new ();
nautilus_query_set_text (query, "richard hult");
- directory = nautilus_directory_get ("x-nautilus-search://0/");
+ directory = nautilus_directory_get_by_uri ("x-nautilus-search://0/");
nautilus_search_directory_set_query (NAUTILUS_SEARCH_DIRECTORY (directory), query);
g_object_unref (query);
diff --git a/test/test-nautilus-mime-actions-set.c b/test/test-nautilus-mime-actions-set.c
index e2f63ac0d..7bf6ec49b 100644
--- a/test/test-nautilus-mime-actions-set.c
+++ b/test/test-nautilus-mime-actions-set.c
@@ -25,8 +25,6 @@
#include <config.h>
#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <stdio.h>
@@ -121,7 +119,7 @@ main (int argc, char **argv)
field = argv[2];
value = argv[3];
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
attributes = nautilus_mime_actions_get_full_file_attributes ();
nautilus_file_call_when_ready (file, attributes, ready_callback, NULL);
diff --git a/test/test-nautilus-mime-actions.c b/test/test-nautilus-mime-actions.c
index 72cf4d680..4e92e0854 100644
--- a/test/test-nautilus-mime-actions.c
+++ b/test/test-nautilus-mime-actions.c
@@ -25,8 +25,6 @@
#include <config.h>
#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-mime-handlers.h>
-#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/nautilus-mime-actions.h>
#include <stdio.h>
@@ -62,17 +60,15 @@ format_supported_uri_schemes_for_display (GList *supported_uri_schemes)
}
static void
-print_application (GnomeVFSMimeApplication *application)
+print_application (GAppInfo *application)
{
if (application == NULL) {
puts ("(none)");
} else {
- printf ("name: %s\ncommand: %s\ncan_open_multiple_files: %s\nexpects_uris: %s\nsupported_uri_schemes: %s\nrequires_terminal: %s\n",
- application->name, application->command,
- (application->can_open_multiple_files ? "TRUE" : "FALSE"),
- (application->expects_uris ? "TRUE" : "FALSE"),
- format_supported_uri_schemes_for_display (application->supported_uri_schemes),
- (application->requires_terminal ? "TRUE" : "FALSE"));
+ printf ("name: %s\ncommand: %s\nexpects_uris: %s\n",
+ g_application_get_name (application),
+ g_application_get_executable (application),
+ (g_app_info_supports_uris (application) ? "TRUE" : "FALSE"));
}
}
@@ -102,7 +98,7 @@ int
main (int argc, char **argv)
{
const char *uri;
- GnomeVFSMimeApplication *default_application;
+ GAppInfo *default_application;
GList *all_applications;
NautilusFile *file;
NautilusFileAttributes attributes;
@@ -116,7 +112,7 @@ main (int argc, char **argv)
}
uri = argv[1];
- file = nautilus_file_get (uri);
+ file = nautilus_file_get_by_uri (uri);
attributes = nautilus_mime_actions_get_full_file_attributes ();
nautilus_file_call_when_ready (file, attributes, ready_callback, NULL);
diff --git a/test/test-nautilus-preferences-change.c b/test/test-nautilus-preferences-change.c
deleted file mode 100644
index b34317751..000000000
--- a/test/test-nautilus-preferences-change.c
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "test.h"
-
-#include <eel/eel-string-picker.h>
-#include <libnautilus-private/nautilus-global-preferences.h>
-#include <unistd.h>
-
-static void
-fruits_changed_callback (gpointer callback_data)
-{
- g_print ("Something underneath 'fruits' changed, dunno what\n");
-}
-
-static void
-int_picker_changed_callback (EelStringPicker *string_picker,
- gpointer callback_data)
-{
- char *selected_string;
- int new_value;
-
- g_return_if_fail (EEL_IS_STRING_PICKER (string_picker));
- g_return_if_fail (callback_data != NULL);
-
- selected_string = eel_string_picker_get_selected_string (string_picker);
-
- new_value = eel_string_picker_get_index_for_string (string_picker, selected_string);
-
- eel_preferences_set_integer ((const char *) callback_data, new_value);
-
- g_free (selected_string);
-}
-
-static GtkWidget *
-picker_new (const char *name,
- const EelStringList *entries)
-{
- GtkWidget *string_picker;
-
- g_return_val_if_fail (name != NULL, NULL);
- g_return_val_if_fail (entries != NULL, NULL);
-
- string_picker = eel_string_picker_new ();
- eel_caption_set_title_label (EEL_CAPTION (string_picker), name);
- g_signal_connect (string_picker, "changed",
- G_CALLBACK (int_picker_changed_callback), (gpointer) name);
-
- eel_string_picker_set_string_list (EEL_STRING_PICKER (string_picker), entries);
- eel_string_picker_set_selected_string_index (EEL_STRING_PICKER (string_picker),
- eel_preferences_get_integer (name));
-
- return string_picker;
-}
-
-int
-main (int argc, char *argv[])
-{
- GtkWidget *window;
- GtkWidget *green_picker;
- GtkWidget *yellow_picker;
- GtkWidget *red_picker;
- GtkWidget *fruits_apple_picker;
- GtkWidget *fruits_orange_picker;
- GtkWidget *fruits_pear_picker;
-
- GtkWidget *vbox;
-
- EelStringList *user_level_entries;
- EelStringList *color_entries;
- EelStringList *fruits_entries;
-
- test_init (&argc, &argv);
-
- nautilus_global_preferences_init ();
-
- user_level_entries = eel_string_list_new_from_tokens ("Beginner,Intermediate,Advanced", ",", TRUE);
- color_entries = eel_string_list_new_from_tokens ("0,1,2,3,4,5,6,7,8,9,10", ",", TRUE);
- fruits_entries = eel_string_list_new_from_tokens ("0,1,2,3", ",", TRUE);
-
- eel_preferences_set_emergency_fallback_integer ("green", 3);
-
- eel_preferences_set_emergency_fallback_integer ("yellow", 9);
-
- eel_preferences_set_emergency_fallback_integer ("red", 7);
-
- eel_preferences_set_emergency_fallback_integer ("fruits/apple", 1);
- eel_preferences_set_emergency_fallback_integer ("fruits/orange", 2);
- eel_preferences_set_emergency_fallback_integer ("fruits/pear", 3);
-
- /* sleep (10); */
-
- window = test_window_new (NULL, 4);
- test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Change");
-
- vbox = gtk_vbox_new (FALSE, 2);
- gtk_container_add (GTK_CONTAINER (window), vbox);
-
- green_picker = picker_new ("green", color_entries);
- yellow_picker = picker_new ("yellow", color_entries);
- red_picker = picker_new ("red", color_entries);
- fruits_apple_picker = picker_new ("fruits/apple", fruits_entries);
- fruits_orange_picker = picker_new ("fruits/orange", fruits_entries);
- fruits_pear_picker = picker_new ("fruits/pear", fruits_entries);
-
- gtk_box_pack_start (GTK_BOX (vbox), green_picker, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), yellow_picker, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), red_picker, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (vbox), fruits_apple_picker, FALSE, FALSE, 20);
- gtk_box_pack_start (GTK_BOX (vbox), fruits_orange_picker, FALSE, FALSE, 20);
- gtk_box_pack_start (GTK_BOX (vbox), fruits_pear_picker, FALSE, FALSE, 20);
-
- eel_string_list_free (user_level_entries);
- eel_string_list_free (color_entries);
- eel_string_list_free (fruits_entries);
-
- eel_preferences_add_callback ("fruits", fruits_changed_callback, NULL);
-
- gtk_widget_show_all (window);
-
- gtk_main ();
-
- return 0;
-}
diff --git a/test/test-nautilus-wrap-table.c b/test/test-nautilus-wrap-table.c
index bb1996915..258bde9a9 100644
--- a/test/test-nautilus-wrap-table.c
+++ b/test/test-nautilus-wrap-table.c
@@ -3,7 +3,7 @@
#include <eel/eel-wrap-table.h>
#include <eel/eel-labeled-image.h>
#include <libnautilus-private/nautilus-customization-data.h>
-#include <libnautilus-private/nautilus-icon-factory.h>
+#include <libnautilus-private/nautilus-icon-info.h>
int
main (int argc, char* argv[])
diff --git a/test/test.c b/test/test.c
index 46d9f93b0..bd9065ecd 100644
--- a/test/test.c
+++ b/test/test.c
@@ -8,7 +8,6 @@ test_init (int *argc,
{
gtk_init (argc, argv);
gdk_rgb_init ();
- gnome_vfs_init ();
eel_make_warnings_and_criticals_stop_in_debugger ();
}
@@ -16,8 +15,6 @@ test_init (int *argc,
int
test_quit (int exit_code)
{
- /* gnome_vfs_shutdown (); */
-
if (gtk_main_level () > 0) {
gtk_main_quit ();
}
@@ -152,52 +149,3 @@ test_window_set_title_with_pid (GtkWindow *window,
g_free (tmp);
}
-void
-test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
- const char *tile_name,
- int x0,
- int y0,
- int x1,
- int y1,
- int opacity)
-{
- ArtIRect area;
- GdkPixbuf *tile_pixbuf;
-
- g_return_if_fail (eel_gdk_pixbuf_is_valid (pixbuf));
- g_return_if_fail (tile_name != NULL);
- g_return_if_fail (opacity > EEL_OPACITY_FULLY_TRANSPARENT);
- g_return_if_fail (opacity <= EEL_OPACITY_FULLY_OPAQUE);
-
- tile_pixbuf = test_pixbuf_new_named (tile_name, 1.0);
-
- g_return_if_fail (tile_pixbuf != NULL);
-
- if (x0 == -1 && y0 == -1 && x1 == -1 && y1 == -1) {
- EelDimensions dimensions;
- dimensions = eel_gdk_pixbuf_get_dimensions (pixbuf);
- area = eel_art_irect_assign_dimensions (0, 0, dimensions);
- } else {
- g_return_if_fail (x0 >= 0);
- g_return_if_fail (y0 >= 0);
- g_return_if_fail (x1 > x0);
- g_return_if_fail (y1 > y0);
-
- area.x0 = x0;
- area.y0 = y0;
- area.x1 = x1;
- area.y1 = y1;
- }
-
- eel_gdk_pixbuf_draw_to_pixbuf_tiled (tile_pixbuf,
- pixbuf,
- area,
- gdk_pixbuf_get_width (tile_pixbuf),
- gdk_pixbuf_get_height (tile_pixbuf),
- 0,
- 0,
- opacity,
- GDK_INTERP_NEAREST);
-
- g_object_unref (tile_pixbuf);
-}
diff --git a/test/test.h b/test/test.h
index bb97aa076..3acddeb2b 100644
--- a/test/test.h
+++ b/test/test.h
@@ -4,7 +4,6 @@
#include <config.h>
#include <gtk/gtk.h>
#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-init.h>
#include <eel/eel-art-extensions.h>
#include <eel/eel-art-gtk-extensions.h>