From: Klaus Ethgen Date: Fri, 4 Mar 2016 10:21:09 +0000 (+0100) Subject: Implementing sorting by file creation X-Git-Tag: v1.3~64^2 X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=commitdiff_plain;h=0c87c52dbbb1dc1f89300b004526d94b24bd6d56 Implementing sorting by file creation --- diff --git a/src/filedata.c b/src/filedata.c index c4e0525a..cf24f7ad 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -165,6 +165,7 @@ static gboolean file_data_check_changed_single_file(FileData *fd, struct stat *s { fd->size = st->st_size; fd->date = st->st_mtime; + fd->cdate = st->st_ctime; fd->mode = st->st_mode; if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf); fd->thumb_pixbuf = NULL; @@ -394,6 +395,7 @@ static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean fd->size = st->st_size; fd->date = st->st_mtime; + fd->cdate = st->st_ctime; fd->mode = st->st_mode; fd->ref = 1; fd->magick = FD_MAGICK; @@ -997,6 +999,11 @@ gint filelist_sort_compare_filedata(FileData *fa, FileData *fb) if (fa->date > fb->date) return 1; /* fall back to name */ break; + case SORT_CTIME: + if (fa->cdate < fb->cdate) return -1; + if (fa->cdate > fb->cdate) return 1; + /* fall back to name */ + break; case SORT_EXIFTIME: if (fa->exifdate < fb->exifdate) return -1; if (fa->exifdate > fb->exifdate) return 1; diff --git a/src/menu.c b/src/menu.c index 7d493a8a..bea2dc2b 100644 --- a/src/menu.c +++ b/src/menu.c @@ -135,6 +135,9 @@ gchar *sort_type_get_text(SortType method) case SORT_TIME: return _("Sort by date"); break; + case SORT_CTIME: + return _("Sort by file creation date"); + break; case SORT_EXIFTIME: return _("Sort by Exif-date"); break; @@ -191,6 +194,7 @@ GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data, submenu_add_sort_item(submenu, func, SORT_NUMBER, show_current, type); #endif submenu_add_sort_item(submenu, func, SORT_TIME, show_current, type); + submenu_add_sort_item(submenu, func, SORT_CTIME, show_current, type); submenu_add_sort_item(submenu, func, SORT_EXIFTIME, show_current, type); submenu_add_sort_item(submenu, func, SORT_SIZE, show_current, type); if (include_path) submenu_add_sort_item(submenu, func, SORT_PATH, show_current, type); diff --git a/src/typedefs.h b/src/typedefs.h index d5a65c8f..b9034602 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -49,6 +49,7 @@ typedef enum { SORT_NAME, SORT_SIZE, SORT_TIME, + SORT_CTIME, SORT_PATH, SORT_NUMBER, SORT_EXIFTIME @@ -511,6 +512,7 @@ struct _FileData { gchar *collate_key_name_nocase; gint64 size; time_t date; + time_t cdate; mode_t mode; /* this is needed at least for notification in view_dir because it is preserved after the file/directory is deleted */ gint sidecar_priority;