diff options
author | Christian Neumair <cneumair@gnome.org> | 2008-07-21 14:52:45 +0000 |
---|---|---|
committer | Christian Neumair <cneumair@src.gnome.org> | 2008-07-21 14:52:45 +0000 |
commit | 838b12f0f416c59c98924a3e70672235bc344298 (patch) | |
tree | 09b753f61e6d74537ff54261d21c46b8efa0e1ef /libnautilus-private | |
parent | 02cbb458f332df72ab305636699e570612e5c7cc (diff) | |
download | nautilus-838b12f0f416c59c98924a3e70672235bc344298.tar.gz |
Support restoring from trash (one item at a time).
2008-07-21 Christian Neumair <cneumair@gnome.org>
* libnautilus-private/nautilus-file-private.h:
* libnautilus-private/nautilus-file.c (update_info_internal),
(nautilus_file_get_trash_original_file):
* libnautilus-private/nautilus-file.h:
* src/file-manager/fm-actions.h:
* src/file-manager/fm-directory-view.c
(action_restore_from_trash_callback), (restore_from_trash),
(action_location_restore_from_trash_callback),
(update_restore_from_trash_action), (real_update_location_menu),
(real_update_menus):
* src/file-manager/nautilus-directory-view-ui.xml:
Support restoring from trash (one item at a time).
svn path=/trunk/; revision=14386
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-file-private.h | 4 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.c | 29 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file.h | 2 |
3 files changed, 34 insertions, 1 deletions
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h index fb4e7e3e6..8b116c1f9 100644 --- a/libnautilus-private/nautilus-file-private.h +++ b/libnautilus-private/nautilus-file-private.h @@ -46,7 +46,7 @@ GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS) #define NAUTILUS_FILE_DEFAULT_ATTRIBUTES \ - "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem" + "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path" /* 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. @@ -120,6 +120,8 @@ struct NautilusFileDetails */ eel_ref_str filesystem_id; + char *trash_orig_path; + /* The following is for file operations in progress. Since * there are normally only a few of these, we can move them to * a separate hash table or something if required to keep the diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c index d7854ce99..292f4990a 100644 --- a/libnautilus-private/nautilus-file.c +++ b/libnautilus-private/nautilus-file.c @@ -1561,6 +1561,7 @@ update_info_internal (NautilusFile *file, const char *activation_uri; const char *description; const char *filesystem_id; + const char *trash_orig_path; if (file->details->is_gone) { return FALSE; @@ -1832,6 +1833,13 @@ update_info_internal (NautilusFile *file, eel_ref_str_unref (file->details->filesystem_id); file->details->filesystem_id = eel_ref_str_get_unique (filesystem_id); } + + trash_orig_path = g_file_info_get_attribute_byte_string (info, "trash::orig-path"); + if (eel_strcmp (file->details->trash_orig_path, trash_orig_path) != 0) { + changed = TRUE; + g_free (file->details->trash_orig_path); + file->details->trash_orig_path = g_strdup (trash_orig_path); + } if (update_name) { name = g_file_info_get_name (info); @@ -6144,6 +6152,27 @@ nautilus_file_get_filesystem_id (NautilusFile *file) return g_strdup (eel_ref_str_peek (file->details->filesystem_id)); } +NautilusFile * +nautilus_file_get_trash_original_file (NautilusFile *file) +{ + GFile *location; + NautilusFile *original_file; + char *filename; + + original_file = NULL; + + if (file->details->trash_orig_path != NULL) { + /* file name is stored in URL encoding */ + filename = g_uri_unescape_string (file->details->trash_orig_path, ""); + location = g_file_new_for_path (filename); + original_file = nautilus_file_get (location); + g_object_unref (G_OBJECT (location)); + g_free (filename); + } + + return original_file; + +} void nautilus_file_mark_gone (NautilusFile *file) diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h index f52a4222b..8e86ec04e 100644 --- a/libnautilus-private/nautilus-file.h +++ b/libnautilus-private/nautilus-file.h @@ -227,6 +227,8 @@ GFilesystemPreviewType nautilus_file_get_filesystem_use_preview (Nautilu char * nautilus_file_get_filesystem_id (NautilusFile *file); +NautilusFile * nautilus_file_get_trash_original_file (NautilusFile *file); + /* Permissions. */ gboolean nautilus_file_can_get_permissions (NautilusFile *file); gboolean nautilus_file_can_set_permissions (NautilusFile *file); |