[nautilus] Add support for a column that combines atime and mtime
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Add support for a column that combines atime and mtime
- Date: Wed, 25 Jul 2012 09:05:35 +0000 (UTC)
commit 85a1b463bfb89c79064059cd3fbaeeeb8775ba89
Author: Florian MÃllner <fmuellner gnome org>
Date: Tue Jul 24 18:58:58 2012 +0200
Add support for a column that combines atime and mtime
For many users, the difference between access and modification time
is rather unobvious, so add support for a "Used" column, which combines
the two times, and make it default.
https://bugzilla.gnome.org/show_bug.cgi?id=680550
libnautilus-private/nautilus-column-utilities.c | 10 ++++++
libnautilus-private/nautilus-file.c | 35 ++++++++++++++++++-
libnautilus-private/nautilus-file.h | 2 +
libnautilus-private/nautilus-vfs-file.c | 10 ++++++
.../org.gnome.nautilus.gschema.xml.in | 4 +-
5 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/libnautilus-private/nautilus-column-utilities.c b/libnautilus-private/nautilus-column-utilities.c
index 757f777..2f24fbe 100644
--- a/libnautilus-private/nautilus-column-utilities.c
+++ b/libnautilus-private/nautilus-column-utilities.c
@@ -35,6 +35,7 @@ static const char *default_column_order[] = {
"name",
"size",
"type",
+ "date_used",
"date_modified",
"date_accessed",
"owner",
@@ -76,6 +77,15 @@ get_builtin_columns (void)
NULL));
columns = g_list_append (columns,
g_object_new (NAUTILUS_TYPE_COLUMN,
+ "name", "date_used",
+ "attribute", "date_used",
+ "label", _("Used"),
+ "description", _("The date the file was last used."),
+ "default-sort-order", GTK_SORT_DESCENDING,
+ NULL));
+
+ columns = g_list_append (columns,
+ g_object_new (NAUTILUS_TYPE_COLUMN,
"name", "date_modified",
"attribute", "date_modified",
"label", _("Modified"),
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index 1721c68..71b1fef 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -124,6 +124,9 @@ static GQuark attribute_name_q,
attribute_accessed_date_q,
attribute_date_accessed_q,
attribute_date_accessed_full_q,
+ attribute_used_date_q,
+ attribute_date_used_q,
+ attribute_date_used_full_q,
attribute_mime_type_q,
attribute_size_detail_q,
attribute_deep_size_q,
@@ -2720,6 +2723,9 @@ get_time (NautilusFile *file,
case NAUTILUS_DATE_TYPE_ACCESSED:
time = file->details->atime;
break;
+ case NAUTILUS_DATE_TYPE_USED:
+ time = MAX (file->details->atime, file->details->mtime);
+ break;
case NAUTILUS_DATE_TYPE_TRASHED:
time = file->details->trash_time;
break;
@@ -3147,6 +3153,12 @@ nautilus_file_compare_for_sort (NautilusFile *file_1,
result = compare_by_full_path (file_1, file_2);
}
break;
+ case NAUTILUS_FILE_SORT_BY_USED_TIME:
+ result = compare_by_time (file_1, file_2, NAUTILUS_DATE_TYPE_USED);
+ if (result == 0) {
+ 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) {
@@ -3206,6 +3218,11 @@ nautilus_file_compare_for_sort_by_attribute_q (NautilusFile
NAUTILUS_FILE_SORT_BY_ATIME,
directories_first,
reversed);
+ } else if (attribute == attribute_used_date_q || attribute == attribute_date_used_q || attribute == attribute_date_used_full_q) {
+ return nautilus_file_compare_for_sort (file_1, file_2,
+ NAUTILUS_FILE_SORT_BY_ATIME,
+ directories_first,
+ reversed);
} else if (attribute == attribute_trashed_on_q || attribute == attribute_trashed_on_full_q) {
return nautilus_file_compare_for_sort (file_1, file_2,
NAUTILUS_FILE_SORT_BY_TRASHED_TIME,
@@ -4298,6 +4315,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_USED
|| date_type == NAUTILUS_DATE_TYPE_TRASHED
|| date_type == NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED, FALSE);
@@ -5852,8 +5870,8 @@ nautilus_file_get_deep_directory_count_as_string (NautilusFile *file)
* @file: NautilusFile representing the file in question.
* @attribute_name: The name of the desired attribute. The currently supported
* 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", "date_modified_full", "date_changed_full", "date_accessed_full",
+ * "deep_file_count", "deep_total_count", "date_modified", "date_changed", "date_accessed", "date_used",
+ * "date_permissions", "date_modified_full", "date_changed_full", "date_accessed_full", "date_used_full",
* "date_permissions_full", "owner", "group", "permissions", "octal_permissions", "uri", "where",
* "link_target", "volume", "free_space", "selinux_context", "trashed_on", "trashed_on_full", "trashed_orig_path"
*
@@ -5926,6 +5944,16 @@ nautilus_file_get_string_attribute_q (NautilusFile *file, GQuark attribute_q)
NAUTILUS_DATE_TYPE_ACCESSED,
FALSE);
}
+ if (attribute_q == attribute_date_used_q) {
+ return nautilus_file_get_date_as_string (file,
+ NAUTILUS_DATE_TYPE_USED,
+ TRUE);
+ }
+ if (attribute_q == attribute_date_used_full_q) {
+ return nautilus_file_get_date_as_string (file,
+ NAUTILUS_DATE_TYPE_USED,
+ FALSE);
+ }
if (attribute_q == attribute_trashed_on_q) {
return nautilus_file_get_date_as_string (file,
NAUTILUS_DATE_TYPE_TRASHED,
@@ -7896,6 +7924,9 @@ nautilus_file_class_init (NautilusFileClass *class)
attribute_accessed_date_q = g_quark_from_static_string ("accessed_date");
attribute_date_accessed_q = g_quark_from_static_string ("date_accessed");
attribute_date_accessed_full_q = g_quark_from_static_string ("date_accessed_full");
+ attribute_used_date_q = g_quark_from_static_string ("used_date");
+ attribute_date_used_q = g_quark_from_static_string ("date_used");
+ attribute_date_used_full_q = g_quark_from_static_string ("date_used_full");
attribute_mime_type_q = g_quark_from_static_string ("mime_type");
attribute_size_detail_q = g_quark_from_static_string ("size_detail");
attribute_deep_size_q = g_quark_from_static_string ("deep_size");
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index f482377..87118f8 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -60,6 +60,7 @@ typedef enum {
NAUTILUS_FILE_SORT_BY_TYPE,
NAUTILUS_FILE_SORT_BY_MTIME,
NAUTILUS_FILE_SORT_BY_ATIME,
+ NAUTILUS_FILE_SORT_BY_USED_TIME,
NAUTILUS_FILE_SORT_BY_TRASHED_TIME
} NautilusFileSortType;
@@ -474,6 +475,7 @@ typedef enum {
NAUTILUS_DATE_TYPE_MODIFIED,
NAUTILUS_DATE_TYPE_CHANGED,
NAUTILUS_DATE_TYPE_ACCESSED,
+ NAUTILUS_DATE_TYPE_USED,
NAUTILUS_DATE_TYPE_PERMISSIONS_CHANGED,
NAUTILUS_DATE_TYPE_TRASHED
} NautilusDateType;
diff --git a/libnautilus-private/nautilus-vfs-file.c b/libnautilus-private/nautilus-vfs-file.c
index fdb3ad0..44c1fc4 100644
--- a/libnautilus-private/nautilus-vfs-file.c
+++ b/libnautilus-private/nautilus-vfs-file.c
@@ -304,6 +304,16 @@ vfs_file_get_date (NautilusFile *file,
*date = file->details->mtime;
}
return TRUE;
+ case NAUTILUS_DATE_TYPE_USED:
+ /* Before we have info on a file, the date is unknown. */
+ if (file->details->mtime == 0 && file->details->atime == 0) {
+ return FALSE;
+ }
+ if (date != NULL) {
+ *date = MAX (file->details->atime,
+ 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) {
diff --git a/libnautilus-private/org.gnome.nautilus.gschema.xml.in b/libnautilus-private/org.gnome.nautilus.gschema.xml.in
index 56435d1..262ced3 100644
--- a/libnautilus-private/org.gnome.nautilus.gschema.xml.in
+++ b/libnautilus-private/org.gnome.nautilus.gschema.xml.in
@@ -234,12 +234,12 @@
<_description>Default zoom level used by the list view.</_description>
</key>
<key name="default-visible-columns" type="as">
- <default>[ 'name', 'size', 'type', 'date_modified' ]</default>
+ <default>[ 'name', 'size', 'type', 'date_used' ]</default>
<_summary>Default list of columns visible in the list view</_summary>
<_description>Default list of columns visible in the list view.</_description>
</key>
<key name="default-column-order" type="as">
- <default>[ 'name', 'size', 'type', 'date_modified' ]</default>
+ <default>[ 'name', 'size', 'type', 'date_used' ]</default>
<_summary>Default column order in the list view</_summary>
<_description>Default column order in the list view.</_description>
</key>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]