[nautilus] Adds Trashed On and Original Location as columns in List View
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Adds Trashed On and Original Location as columns in List View
- Date: Thu, 13 May 2010 10:33:27 +0000 (UTC)
commit f62cad9bae1b742b41c088449b2278eb7b6fd093
Author: Marcus Carlson <marcus mejlamej nu>
Date: Sun Oct 11 01:02:48 2009 +0200
Adds Trashed On and Original Location as columns in List View
And also an 'Arrange by Trash Time' option in Icon View.
https://bugzilla.gnome.org/show_bug.cgi?id=89706
libnautilus-private/nautilus-column-utilities.c | 14 ++++
libnautilus-private/nautilus-file-private.h | 4 +-
libnautilus-private/nautilus-file.c | 76 ++++++++++++++++++++++-
libnautilus-private/nautilus-file.h | 6 +-
libnautilus-private/nautilus-vfs-file.c | 9 +++
src/file-manager/fm-icon-view.c | 11 +++
src/file-manager/nautilus-icon-view-ui.xml | 2 +
7 files changed, 118 insertions(+), 4 deletions(-)
---
diff --git a/libnautilus-private/nautilus-column-utilities.c b/libnautilus-private/nautilus-column-utilities.c
index bc8c80b..ddc25ec 100644
--- a/libnautilus-private/nautilus-column-utilities.c
+++ b/libnautilus-private/nautilus-column-utilities.c
@@ -128,6 +128,20 @@ get_builtin_columns (void)
/* TODO: Change after string freeze over */
"description", _("Location"),
NULL));
+ columns = g_list_append (columns,
+ g_object_new (NAUTILUS_TYPE_COLUMN,
+ "name", "trashed_on",
+ "attribute", "trashed_on",
+ "label", _("Trashed On"),
+ "description", _("Date when file was moved to the Trash"),
+ NULL));
+ columns = g_list_append (columns,
+ g_object_new (NAUTILUS_TYPE_COLUMN,
+ "name", "trash_orig_path",
+ "attribute", "trash_orig_path",
+ "label", _("Original Location"),
+ "description", _("Original location of file before moved to the Trash"),
+ NULL));
return columns;
}
diff --git a/libnautilus-private/nautilus-file-private.h b/libnautilus-private/nautilus-file-private.h
index 1d3b2bf..eee3b64 100644
--- a/libnautilus-private/nautilus-file-private.h
+++ b/libnautilus-private/nautilus-file-private.h
@@ -40,7 +40,7 @@
#define NAUTILUS_FILE_TOP_LEFT_TEXT_MAXIMUM_BYTES 1024
#define NAUTILUS_FILE_DEFAULT_ATTRIBUTES \
- "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path,metadata::*"
+ "standard::*,access::*,mountable::*,time::*,unix::*,owner::*,selinux::*,thumbnail::*,id::filesystem,trash::orig-path,trash::deletion-date,metadata::*"
/* 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.
@@ -226,6 +226,8 @@ struct NautilusFileDetails
eel_boolean_bit filesystem_readonly : 1;
eel_boolean_bit filesystem_use_preview : 2; /* GFilesystemPreviewType */
eel_boolean_bit filesystem_info_is_up_to_date : 1;
+
+ time_t trash_time; /* 0 is unknown */
};
typedef struct {
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index b69ba00..d3f5fe9 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -130,6 +130,8 @@ static GQuark attribute_name_q,
attribute_deep_directory_count_q,
attribute_deep_total_count_q,
attribute_date_changed_q,
+ attribute_trashed_on_q,
+ attribute_trash_orig_path_q,
attribute_date_permissions_q,
attribute_permissions_q,
attribute_selinux_context_q,
@@ -467,6 +469,7 @@ nautilus_file_clear_info (NautilusFile *file)
file->details->mtime = 0;
file->details->atime = 0;
file->details->ctime = 0;
+ file->details->trash_time = 0;
g_free (file->details->symlink_name);
file->details->symlink_name = NULL;
eel_ref_str_unref (file->details->mime_type);
@@ -2052,6 +2055,9 @@ update_info_internal (NautilusFile *file,
goffset size;
int sort_order;
time_t atime, mtime, ctime;
+ time_t trash_time;
+ GTimeVal g_trash_time;
+ const char * time_string;
const char *symlink_name, *mime_type, *selinux_context, *name, *thumbnail_path;
GFileType file_type;
GIcon *icon;
@@ -2415,6 +2421,17 @@ update_info_internal (NautilusFile *file,
file->details->filesystem_id = eel_ref_str_get_unique (filesystem_id);
}
+ trash_time = 0;
+ time_string = g_file_info_get_attribute_string (info, "trash::deletion-date");
+ if (time_string != NULL) {
+ g_time_val_from_iso8601 (time_string, &g_trash_time);
+ trash_time = g_trash_time.tv_sec;
+ }
+ if (file->details->trash_time != trash_time) {
+ changed = TRUE;
+ file->details->trash_time = trash_time;
+ }
+
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;
@@ -2668,6 +2685,9 @@ get_time (NautilusFile *file,
case NAUTILUS_DATE_TYPE_ACCESSED:
time = file->details->atime;
break;
+ case NAUTILUS_DATE_TYPE_TRASHED:
+ time = file->details->trash_time;
+ break;
default:
g_assert_not_reached ();
break;
@@ -3182,6 +3202,12 @@ nautilus_file_compare_for_sort (NautilusFile *file_1,
result = compare_by_full_path (file_1, file_2);
}
break;
+ case NAUTILUS_FILE_SORT_BY_TRASHED_TIME:
+ result = compare_by_time (file_1, file_2, NAUTILUS_DATE_TYPE_TRASHED);
+ if (result == 0) {
+ result = compare_by_full_path (file_1, file_2);
+ }
+ break;
case NAUTILUS_FILE_SORT_BY_EMBLEMS:
/* GnomeVFS doesn't know squat about our emblems, so
* we handle comparing them here, before falling back
@@ -3245,6 +3271,11 @@ nautilus_file_compare_for_sort_by_attribute_q (NautilusFile
NAUTILUS_FILE_SORT_BY_ATIME,
directories_first,
reversed);
+ } else if (attribute == attribute_trashed_on_q) {
+ return nautilus_file_compare_for_sort (file_1, file_2,
+ NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
+ directories_first,
+ reversed);
} else if (attribute == attribute_emblems_q) {
return nautilus_file_compare_for_sort (file_1, file_2,
NAUTILUS_FILE_SORT_BY_EMBLEMS,
@@ -4340,6 +4371,7 @@ nautilus_file_get_date (NautilusFile *file,
g_return_val_if_fail (date_type == NAUTILUS_DATE_TYPE_CHANGED
|| date_type == NAUTILUS_DATE_TYPE_ACCESSED
|| date_type == NAUTILUS_DATE_TYPE_MODIFIED
+ || date_type == NAUTILUS_DATE_TYPE_TRASHED
|| date_type == NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED, FALSE);
if (file == NULL) {
@@ -4579,6 +4611,30 @@ nautilus_file_fit_modified_date_as_string (NautilusFile *file,
width, measure_callback, truncate_callback, measure_context);
}
+static char *
+nautilus_file_get_trash_original_file_parent_as_string (NautilusFile *file)
+{
+ NautilusFile *orig_file, *parent;
+ GFile *location;
+ char *filename;
+
+ if (file->details->trash_orig_path != NULL) {
+ orig_file = nautilus_file_get_trash_original_file (file);
+ parent = nautilus_file_get_parent (orig_file);
+ location = nautilus_file_get_location (parent);
+
+ filename = g_file_get_parse_name (location);
+
+ g_object_unref (location);
+ nautilus_file_unref (parent);
+ nautilus_file_unref (orig_file);
+
+ return filename;
+ }
+
+ return NULL;
+}
+
/**
* nautilus_file_get_date_as_string:
*
@@ -6008,7 +6064,7 @@ nautilus_file_get_deep_directory_count_as_string (NautilusFile *file)
* set includes "name", "type", "mime_type", "size", "deep_size", "deep_directory_count",
* "deep_file_count", "deep_total_count", "date_modified", "date_changed", "date_accessed",
* "date_permissions", "owner", "group", "permissions", "octal_permissions", "uri", "where",
- * "link_target", "volume", "free_space", "selinux_context"
+ * "link_target", "volume", "free_space", "selinux_context", "trashed_on", "trashed_orig_path"
*
* Returns: Newly allocated string ready to display to the user, or NULL
* if the value is unknown or @attribute_name is not supported.
@@ -6046,6 +6102,9 @@ nautilus_file_get_string_attribute_q (NautilusFile *file, GQuark attribute_q)
if (attribute_q == attribute_deep_total_count_q) {
return nautilus_file_get_deep_total_count_as_string (file);
}
+ if (attribute_q == attribute_trash_orig_path_q) {
+ return nautilus_file_get_trash_original_file_parent_as_string (file);
+ }
if (attribute_q == attribute_date_modified_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_MODIFIED);
@@ -6058,6 +6117,10 @@ nautilus_file_get_string_attribute_q (NautilusFile *file, GQuark attribute_q)
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_ACCESSED);
}
+ if (attribute_q == attribute_trashed_on_q) {
+ return nautilus_file_get_date_as_string (file,
+ NAUTILUS_DATE_TYPE_TRASHED);
+ }
if (attribute_q == attribute_date_permissions_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED);
@@ -6183,6 +6246,14 @@ nautilus_file_get_string_attribute_with_default_q (NautilusFile *file, GQuark at
if (attribute_q == attribute_mime_type_q) {
return g_strdup (_("unknown MIME type"));
}
+ if (attribute_q == attribute_trashed_on_q) {
+ /* If n/a */
+ return g_strdup ("");
+ }
+ if (attribute_q == attribute_trash_orig_path_q) {
+ /* If n/a */
+ return g_strdup ("");
+ }
/* Fallback, use for both unknown attributes and attributes
* for which we have no more appropriate default.
@@ -6204,6 +6275,7 @@ nautilus_file_is_date_sort_attribute_q (GQuark attribute_q)
attribute_q == attribute_accessed_date_q ||
attribute_q == attribute_date_accessed_q ||
attribute_q == attribute_date_changed_q ||
+ attribute_q == attribute_trashed_on_q ||
attribute_q == attribute_date_permissions_q) {
return TRUE;
}
@@ -7916,6 +7988,8 @@ nautilus_file_class_init (NautilusFileClass *class)
attribute_deep_directory_count_q = g_quark_from_static_string ("deep_directory_count");
attribute_deep_total_count_q = g_quark_from_static_string ("deep_total_count");
attribute_date_changed_q = g_quark_from_static_string ("date_changed");
+ attribute_trashed_on_q = g_quark_from_static_string ("trashed_on");
+ attribute_trash_orig_path_q = g_quark_from_static_string ("trash_orig_path");
attribute_date_permissions_q = g_quark_from_static_string ("date_permissions");
attribute_permissions_q = g_quark_from_static_string ("permissions");
attribute_selinux_context_q = g_quark_from_static_string ("selinux_context");
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 6959b1f..8c86ae2 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -61,7 +61,8 @@ typedef enum {
NAUTILUS_FILE_SORT_BY_TYPE,
NAUTILUS_FILE_SORT_BY_MTIME,
NAUTILUS_FILE_SORT_BY_ATIME,
- NAUTILUS_FILE_SORT_BY_EMBLEMS
+ NAUTILUS_FILE_SORT_BY_EMBLEMS,
+ NAUTILUS_FILE_SORT_BY_TRASHED_TIME
} NautilusFileSortType;
typedef enum {
@@ -487,7 +488,8 @@ typedef enum {
NAUTILUS_DATE_TYPE_MODIFIED,
NAUTILUS_DATE_TYPE_CHANGED,
NAUTILUS_DATE_TYPE_ACCESSED,
- NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED
+ NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED,
+ NAUTILUS_DATE_TYPE_TRASHED
} NautilusDateType;
typedef struct {
diff --git a/libnautilus-private/nautilus-vfs-file.c b/libnautilus-private/nautilus-vfs-file.c
index 97faccd..ef7de84 100644
--- a/libnautilus-private/nautilus-vfs-file.c
+++ b/libnautilus-private/nautilus-vfs-file.c
@@ -312,6 +312,15 @@ vfs_file_get_date (NautilusFile *file,
*date = file->details->mtime;
}
return TRUE;
+ case NAUTILUS_DATE_TYPE_TRASHED:
+ /* Before we have info on a file, the date is unknown. */
+ if (file->details->trash_time == 0) {
+ return FALSE;
+ }
+ if (date != NULL) {
+ *date = file->details->trash_time;
+ }
+ return TRUE;
case NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED:
/* Before we have info on a file, the date is unknown. */
if (file->details->mtime == 0 || file->details->ctime == 0) {
diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c
index e8744ca..b3c8ff5 100644
--- a/src/file-manager/fm-icon-view.c
+++ b/src/file-manager/fm-icon-view.c
@@ -150,6 +150,13 @@ static const SortCriterion sort_criteria[] = {
"Sort by Emblems",
N_("by _Emblems"),
N_("Keep icons sorted by emblems in rows")
+ },
+ {
+ NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
+ "trashed",
+ "Sort by Trash Time",
+ N_("by T_rash Time"),
+ N_("Keep icons sorted by trash time in rows")
}
};
@@ -1550,6 +1557,10 @@ static const GtkRadioActionEntry arrange_radio_entries[] = {
N_("By _Emblems"), NULL,
N_("Keep icons sorted by emblems in rows"),
NAUTILUS_FILE_SORT_BY_EMBLEMS },
+ { "Sort by Trash Time", NULL,
+ N_("By T_rash Time"), NULL,
+ N_("Keep icons sorted by trash time in rows"),
+ NAUTILUS_FILE_SORT_BY_TRASHED_TIME },
};
static void
diff --git a/src/file-manager/nautilus-icon-view-ui.xml b/src/file-manager/nautilus-icon-view-ui.xml
index 9897f9e..179df40 100644
--- a/src/file-manager/nautilus-icon-view-ui.xml
+++ b/src/file-manager/nautilus-icon-view-ui.xml
@@ -16,6 +16,7 @@
<menuitem name="Sort by Type" action="Sort by Type"/>
<menuitem name="Sort by Modification Date" action="Sort by Modification Date"/>
<menuitem name="Sort by Emblems" action="Sort by Emblems"/>
+ <menuitem name="Sort by Trash Time" action="Sort by Trash Time"/>
</placeholder>
<separator name="Layout separator"/>
<menuitem name="Tighter Layout" action="Tighter Layout"/>
@@ -38,6 +39,7 @@
<menuitem name="Sort by Type" action="Sort by Type"/>
<menuitem name="Sort by Modification Date" action="Sort by Modification Date"/>
<menuitem name="Sort by Emblems" action="Sort by Emblems"/>
+ <menuitem name="Sort by Trash Time" action="Sort by Trash Time"/>
</placeholder>
<separator name="Layout separator"/>
<menuitem name="Tighter Layout" action="Tighter Layout"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]