diff options
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | configure.in.in | 2 | ||||
-rw-r--r-- | thunar/thunar-details-view.c | 32 | ||||
-rw-r--r-- | thunar/thunar-file.c | 117 | ||||
-rw-r--r-- | thunar/thunar-file.h | 85 | ||||
-rw-r--r-- | thunar/thunar-list-model.c | 208 | ||||
-rw-r--r-- | thunar/thunar-list-model.h | 5 | ||||
-rw-r--r-- | thunar/thunar-local-file.c | 34 | ||||
-rw-r--r-- | thunar/thunar-trash-file.c | 15 |
9 files changed, 438 insertions, 73 deletions
@@ -1,3 +1,16 @@ +2005-06-24 Benedikt Meurer <benny@xfce.org> + + * configure.in.in: Add check for localtime_r. + * thunar/thunar-file.{c,h}: Add support to query accessed, changed and + modified dates of ThunarFiles. + * thunar/thunar-local-file.c, thunar/thunar-trash-file.c: Implement + the virtual get_date() method. + * thunar/thunar-list-model.{c,h}: Add new columns accessed date, + modified date and mime type. Fix the sorting for the mime comment + column. + * thunar/thunar-details-view.c: Display type and date modified columns + as well. + 2005-06-23 Benedikt Meurer <benny@xfce.org> * docs/papers/HackingOnThunar.odt, docs/papers/Makefile.am, diff --git a/configure.in.in b/configure.in.in index 611e0d1d..9502fe58 100644 --- a/configure.in.in +++ b/configure.in.in @@ -46,7 +46,7 @@ AC_CHECK_HEADERS([errno.h fcntl.h fstab.h memory.h stdlib.h string.h \ sys/mount.h sys/stat.h sys/time.h sys/param.h time.h]) dnl Check for standard functions -AC_CHECK_FUNCS([kqueue]) +AC_CHECK_FUNCS([kqueue localtime_r]) dnl Check for required packages XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.1]) diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index d892b065..b4360af0 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -145,6 +145,38 @@ thunar_details_view_init (ThunarDetailsView *details_view) gtk_tree_view_column_set_sort_column_id (column, THUNAR_LIST_MODEL_COLUMN_PERMISSIONS); gtk_tree_view_append_column (GTK_TREE_VIEW (details_view), column); + /* fourth column (type) */ + column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, + "reorderable", TRUE, + "resizable", TRUE, + "title", _("Type"), + NULL); + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, + "xalign", 0.0, + NULL); + gtk_tree_view_column_pack_start (column, renderer, TRUE); + gtk_tree_view_column_set_attributes (column, renderer, + "text", THUNAR_LIST_MODEL_COLUMN_TYPE, + NULL); + gtk_tree_view_column_set_sort_column_id (column, THUNAR_LIST_MODEL_COLUMN_TYPE); + gtk_tree_view_append_column (GTK_TREE_VIEW (details_view), column); + + /* fifth column (modification date) */ + column = g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, + "reorderable", TRUE, + "resizable", TRUE, + "title", _("Date modified"), + NULL); + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, + "xalign", 0.0, + NULL); + gtk_tree_view_column_pack_start (column, renderer, TRUE); + gtk_tree_view_column_set_attributes (column, renderer, + "text", THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED, + NULL); + gtk_tree_view_column_set_sort_column_id (column, THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED); + gtk_tree_view_append_column (GTK_TREE_VIEW (details_view), column); + /* configure the tree selection */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (details_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c index 559ca4d4..dc2cabf9 100644 --- a/thunar/thunar-file.c +++ b/thunar/thunar-file.c @@ -24,6 +24,9 @@ #ifdef HAVE_ERRNO_H #include <errno.h> #endif +#ifdef HAVE_TIME_H +#include <time.h> +#endif #include <thunar/thunar-file.h> #include <thunar/thunar-icon-factory.h> @@ -39,14 +42,17 @@ enum -static void thunar_file_class_init (ThunarFileClass *klass); -static void thunar_file_finalize (GObject *object); -static ThunarFolder*thunar_file_real_open_as_folder (ThunarFile *file, - GError **error); -static const gchar *thunar_file_real_get_special_name (ThunarFile *file); -static void thunar_file_real_changed (ThunarFile *file); -static void thunar_file_destroyed (gpointer data, - GObject *object); +static void thunar_file_class_init (ThunarFileClass *klass); +static void thunar_file_finalize (GObject *object); +static ThunarFolder*thunar_file_real_open_as_folder (ThunarFile *file, + GError **error); +static const gchar *thunar_file_real_get_special_name (ThunarFile *file); +static gboolean thunar_file_real_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return); +static void thunar_file_real_changed (ThunarFile *file); +static void thunar_file_destroyed (gpointer data, + GObject *object); @@ -98,6 +104,7 @@ thunar_file_class_init (ThunarFileClass *klass) klass->open_as_folder = thunar_file_real_open_as_folder; klass->get_special_name = thunar_file_real_get_special_name; + klass->get_date = thunar_file_real_get_date; klass->changed = thunar_file_real_changed; /** @@ -150,6 +157,16 @@ thunar_file_real_get_special_name (ThunarFile *file) +static gboolean +thunar_file_real_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return) +{ + return FALSE; +} + + + static void thunar_file_real_changed (ThunarFile *file) { @@ -436,6 +453,39 @@ thunar_file_get_kind (ThunarFile *file) /** + * thunar_file_get_date: + * @file : a #ThunarFile instance. + * @date_type : the kind of date you are interested in. + * @date_return : the return location for the date. + * + * Queries the given @date_type from @file and stores the result in @date_return. + * Not all #ThunarFile implementations may support all kinds of @date_type<!---->s, + * some may not even support dates at all. If the @date_type could not be determined + * on @file, %FALSE will be returned and @date_type will not be set to the proper + * value. Else if the operation was successful, %TRUE will be returned. + * + * Modules using this method must be prepared to handle the case when %FALSE is + * returned! + * + * Return value: %TRUE if the operation was successful, else %FALSE. + **/ +gboolean +thunar_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return) +{ + g_return_val_if_fail (THUNAR_IS_FILE (file), FALSE); + g_return_val_if_fail (date_type == THUNAR_FILE_DATE_ACCESSED + || date_type == THUNAR_FILE_DATE_CHANGED + || date_type == THUNAR_FILE_DATE_MODIFIED, FALSE); + g_return_val_if_fail (date_return != NULL, FALSE); + + return THUNAR_FILE_GET_CLASS (file)->get_date (file, date_type, date_return); +} + + + +/** * thunar_file_get_mode: * @file : a #ThunarFile instance. * @@ -470,6 +520,57 @@ thunar_file_get_size (ThunarFile *file) /** + * thunar_file_get_date_string: + * @file : a #ThunarFile instance. + * @date_type : the kind of date you are interested to know about @file. + * + * Tries to determine the @date_type of @file, and if @file supports the + * given @date_type, it'll be formatted as string and returned. The + * caller is responsible for freeing the string using the #g_free() + * function. + * + * Else if @date_type is not supported for @file, %NULL will be returned + * and the caller must be able to handle that case. + * + * Return value: the @date_type of @file formatted as string or %NULL. + **/ +gchar* +thunar_file_get_date_string (ThunarFile *file, + ThunarFileDateType date_type) +{ + ThunarVfsFileTime time; +#ifdef HAVE_LOCALTIME_R + struct tm tmbuf; +#endif + struct tm *tm; + gchar *result; + + g_return_val_if_fail (THUNAR_IS_FILE (file), NULL); + g_return_val_if_fail (date_type == THUNAR_FILE_DATE_ACCESSED + || date_type == THUNAR_FILE_DATE_CHANGED + || date_type == THUNAR_FILE_DATE_MODIFIED, NULL); + + /* query the date on the given file */ + if (!thunar_file_get_date (file, date_type, &time)) + return NULL; + + /* convert to local time */ +#ifdef HAVE_LOCALTIME_R + tm = localtime_r (&time, &tmbuf); +#else + tm = localtime (&time); +#endif + + /* convert to string */ + result = g_new (gchar, 20); + strftime (result, 20, "%Y-%m-%d %H:%M:%S", tm); + + return result; +} + + + +/** * thunar_file_get_mode_string: * @file : a #ThunarFile instance. * diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h index c0ed39c8..26a97eca 100644 --- a/thunar/thunar-file.h +++ b/thunar/thunar-file.h @@ -39,27 +39,47 @@ typedef struct _ThunarFile ThunarFile; #define THUNAR_IS_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_FILE)) #define THUNAR_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_FILE, ThunarFileClass)) +/** + * ThunarFileDateType: + * @THUNAR_FILE_DATE_ACCESSED: date of last access to the file. + * @THUNAR_FILE_DATE_CHANGED: date of last change to the file meta data or the content. + * @THUNAR_FILE_DATE_MODIFIED: date of last modification of the file's content. + * + * The various dates that can be queried about a #ThunarFile. Note, that not all + * #ThunarFile implementations support all types listed above. See the documentation + * of the #thunar_file_get_date() method for details. + **/ +typedef enum +{ + THUNAR_FILE_DATE_ACCESSED, + THUNAR_FILE_DATE_CHANGED, + THUNAR_FILE_DATE_MODIFIED, +} ThunarFileDateType; + struct _ThunarFileClass { GtkObjectClass __parent__; /* virtual methods */ - ThunarFolder *(*open_as_folder) (ThunarFile *file, - GError **error); + ThunarFolder *(*open_as_folder) (ThunarFile *file, + GError **error); - ThunarVfsURI *(*get_uri) (ThunarFile *file); + ThunarVfsURI *(*get_uri) (ThunarFile *file); - ExoMimeInfo *(*get_mime_info) (ThunarFile *file); + ExoMimeInfo *(*get_mime_info) (ThunarFile *file); - const gchar *(*get_display_name) (ThunarFile *file); - const gchar *(*get_special_name) (ThunarFile *file); + const gchar *(*get_display_name) (ThunarFile *file); + const gchar *(*get_special_name) (ThunarFile *file); - ThunarVfsFileType (*get_kind) (ThunarFile *file); - ThunarVfsFileMode (*get_mode) (ThunarFile *file); - ThunarVfsFileSize (*get_size) (ThunarFile *file); + gboolean (*get_date) (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return); + ThunarVfsFileType (*get_kind) (ThunarFile *file); + ThunarVfsFileMode (*get_mode) (ThunarFile *file); + ThunarVfsFileSize (*get_size) (ThunarFile *file); - const gchar *(*get_icon_name) (ThunarFile *file, - GtkIconTheme *icon_theme); + const gchar *(*get_icon_name) (ThunarFile *file, + GtkIconTheme *icon_theme); /* signals */ @@ -77,34 +97,39 @@ struct _ThunarFile GType thunar_file_get_type (void) G_GNUC_CONST; -ThunarFile *thunar_file_get_for_uri (ThunarVfsURI *uri, - GError **error); -ThunarFile *thunar_file_get_parent (ThunarFile *file, - GError **error); +ThunarFile *thunar_file_get_for_uri (ThunarVfsURI *uri, + GError **error); +ThunarFile *thunar_file_get_parent (ThunarFile *file, + GError **error); -ThunarFolder *thunar_file_open_as_folder (ThunarFile *file, - GError **error); +ThunarFolder *thunar_file_open_as_folder (ThunarFile *file, + GError **error); -ThunarVfsURI *thunar_file_get_uri (ThunarFile *file); +ThunarVfsURI *thunar_file_get_uri (ThunarFile *file); -ExoMimeInfo *thunar_file_get_mime_info (ThunarFile *file); +ExoMimeInfo *thunar_file_get_mime_info (ThunarFile *file); -const gchar *thunar_file_get_display_name (ThunarFile *file); -const gchar *thunar_file_get_special_name (ThunarFile *file); +const gchar *thunar_file_get_display_name (ThunarFile *file); +const gchar *thunar_file_get_special_name (ThunarFile *file); -ThunarVfsFileType thunar_file_get_kind (ThunarFile *file); -ThunarVfsFileMode thunar_file_get_mode (ThunarFile *file); -ThunarVfsFileSize thunar_file_get_size (ThunarFile *file); +gboolean thunar_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return); +ThunarVfsFileType thunar_file_get_kind (ThunarFile *file); +ThunarVfsFileMode thunar_file_get_mode (ThunarFile *file); +ThunarVfsFileSize thunar_file_get_size (ThunarFile *file); -gchar *thunar_file_get_mode_string (ThunarFile *file); -gchar *thunar_file_get_size_string (ThunarFile *file); +gchar *thunar_file_get_date_string (ThunarFile *file, + ThunarFileDateType date_type); +gchar *thunar_file_get_mode_string (ThunarFile *file); +gchar *thunar_file_get_size_string (ThunarFile *file); -GdkPixbuf *thunar_file_load_icon (ThunarFile *file, - gint size); +GdkPixbuf *thunar_file_load_icon (ThunarFile *file, + gint size); -void thunar_file_changed (ThunarFile *file); +void thunar_file_changed (ThunarFile *file); -gboolean thunar_file_is_hidden (ThunarFile *file); +gboolean thunar_file_is_hidden (ThunarFile *file); #define thunar_file_get_name(file) (thunar_vfs_uri_get_name (THUNAR_FILE_GET_CLASS ((file))->get_uri ((file)))) diff --git a/thunar/thunar-list-model.c b/thunar/thunar-list-model.c index fd8c77ce..335a9d46 100644 --- a/thunar/thunar-list-model.c +++ b/thunar/thunar-list-model.c @@ -142,6 +142,12 @@ static void thunar_list_model_folder_destroy (ThunarFolder static void thunar_list_model_files_added (ThunarFolder *folder, GSList *files, ThunarListModel *store); +static gint sort_by_date_accessed (ThunarFile *a, + ThunarFile *b); +static gint sort_by_date_modified (ThunarFile *a, + ThunarFile *b); +static gint sort_by_mime_type (ThunarFile *a, + ThunarFile *b); static gint sort_by_name (ThunarFile *a, ThunarFile *b); static gint sort_by_permissions (ThunarFile *a, @@ -479,7 +485,10 @@ thunar_list_model_get_column_type (GtkTreeModel *model, { switch (index) { - case THUNAR_LIST_MODEL_COLUMN_NAME: + case THUNAR_LIST_MODEL_COLUMN_DATE_ACCESSED: + return G_TYPE_STRING; + + case THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED: return G_TYPE_STRING; case THUNAR_LIST_MODEL_COLUMN_ICON_SMALL: @@ -491,6 +500,12 @@ thunar_list_model_get_column_type (GtkTreeModel *model, case THUNAR_LIST_MODEL_COLUMN_ICON_LARGE: return GDK_TYPE_PIXBUF; + case THUNAR_LIST_MODEL_COLUMN_MIME_TYPE: + return G_TYPE_STRING; + + case THUNAR_LIST_MODEL_COLUMN_NAME: + return G_TYPE_STRING; + case THUNAR_LIST_MODEL_COLUMN_PERMISSIONS: return G_TYPE_STRING; @@ -569,63 +584,81 @@ thunar_list_model_get_value (GtkTreeModel *model, { ExoMimeInfo *mime_info; GdkPixbuf *icon; + gchar *str; Row *row; g_return_if_fail (THUNAR_IS_LIST_MODEL (model)); g_return_if_fail (iter->stamp == (THUNAR_LIST_MODEL (model))->stamp); row = (Row *) iter->user_data; + g_assert (row != NULL); switch (column) { - case THUNAR_LIST_MODEL_COLUMN_NAME: + case THUNAR_LIST_MODEL_COLUMN_DATE_ACCESSED: g_value_init (value, G_TYPE_STRING); - g_value_set_static_string (value, thunar_file_get_display_name (row->file)); + str = thunar_file_get_date_string (row->file, THUNAR_FILE_DATE_ACCESSED); + if (G_LIKELY (str != NULL)) + g_value_take_string (value, str); + else + g_value_set_static_string (value, _("unknown")); + break; + + case THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED: + g_value_init (value, G_TYPE_STRING); + str = thunar_file_get_date_string (row->file, THUNAR_FILE_DATE_MODIFIED); + if (G_LIKELY (str != NULL)) + g_value_take_string (value, str); + else + g_value_set_static_string (value, _("unknown")); break; case THUNAR_LIST_MODEL_COLUMN_ICON_SMALL: g_value_init (value, GDK_TYPE_PIXBUF); - if (G_LIKELY (row != NULL)) - { - // FIXME: don't use pixel sizes here - icon = thunar_file_load_icon (row->file, 16); - g_value_set_object (value, icon); - g_object_unref (G_OBJECT (icon)); - } + // FIXME: don't use pixel sizes here + icon = thunar_file_load_icon (row->file, 16); + g_value_set_object (value, icon); + g_object_unref (G_OBJECT (icon)); break; case THUNAR_LIST_MODEL_COLUMN_ICON_NORMAL: g_value_init (value, GDK_TYPE_PIXBUF); - if (G_LIKELY (row != NULL)) - { - // FIXME: don't use pixel sizes here - icon = thunar_file_load_icon (row->file, 48); - g_value_set_object (value, icon); - g_object_unref (G_OBJECT (icon)); - } + // FIXME: don't use pixel sizes here + icon = thunar_file_load_icon (row->file, 48); + g_value_set_object (value, icon); + g_object_unref (G_OBJECT (icon)); break; case THUNAR_LIST_MODEL_COLUMN_ICON_LARGE: g_value_init (value, GDK_TYPE_PIXBUF); - if (G_LIKELY (row != NULL)) - { - // FIXME: don't use pixel sizes here - icon = thunar_file_load_icon (row->file, 64); - g_value_set_object (value, icon); - g_object_unref (G_OBJECT (icon)); - } + // FIXME: don't use pixel sizes here + icon = thunar_file_load_icon (row->file, 64); + g_value_set_object (value, icon); + g_object_unref (G_OBJECT (icon)); + break; + + case THUNAR_LIST_MODEL_COLUMN_MIME_TYPE: + g_value_init (value, G_TYPE_STRING); + mime_info = thunar_file_get_mime_info (row->file); + if (G_LIKELY (mime_info != NULL)) + g_value_set_static_string (value, exo_mime_info_get_name (mime_info)); + else + g_value_set_static_string (value, _("unknown")); + break; + + case THUNAR_LIST_MODEL_COLUMN_NAME: + g_value_init (value, G_TYPE_STRING); + g_value_set_static_string (value, thunar_file_get_display_name (row->file)); break; case THUNAR_LIST_MODEL_COLUMN_PERMISSIONS: g_value_init (value, G_TYPE_STRING); - if (G_LIKELY (row != NULL)) - g_value_take_string (value, thunar_file_get_mode_string (row->file)); + g_value_take_string (value, thunar_file_get_mode_string (row->file)); break; case THUNAR_LIST_MODEL_COLUMN_SIZE: g_value_init (value, G_TYPE_STRING); - if (G_LIKELY (row != NULL)) - g_value_take_string (value, thunar_file_get_size_string (row->file)); + g_value_take_string (value, thunar_file_get_size_string (row->file)); break; case THUNAR_LIST_MODEL_COLUMN_TYPE: @@ -634,7 +667,7 @@ thunar_list_model_get_value (GtkTreeModel *model, if (G_LIKELY (mime_info != NULL)) g_value_set_static_string (value, exo_mime_info_get_comment (mime_info)); else - g_value_set_static_string (value, "unknown"); + g_value_set_static_string (value, _("unknown")); break; default: @@ -814,12 +847,18 @@ thunar_list_model_get_sort_column_id (GtkTreeSortable *sortable, g_return_val_if_fail (THUNAR_IS_LIST_MODEL (store), FALSE); - if (store->sort_func == sort_by_name) + if (store->sort_func == sort_by_mime_type) + *sort_column_id = THUNAR_LIST_MODEL_COLUMN_MIME_TYPE; + else if (store->sort_func == sort_by_name) *sort_column_id = THUNAR_LIST_MODEL_COLUMN_NAME; else if (store->sort_func == sort_by_permissions) *sort_column_id = THUNAR_LIST_MODEL_COLUMN_PERMISSIONS; else if (store->sort_func == sort_by_size) *sort_column_id = THUNAR_LIST_MODEL_COLUMN_SIZE; + else if (store->sort_func == sort_by_date_accessed) + *sort_column_id = THUNAR_LIST_MODEL_COLUMN_DATE_ACCESSED; + else if (store->sort_func == sort_by_date_modified) + *sort_column_id = THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED; else if (store->sort_func == sort_by_type) *sort_column_id = THUNAR_LIST_MODEL_COLUMN_TYPE; else @@ -846,6 +885,18 @@ thunar_list_model_set_sort_column_id (GtkTreeSortable *sortable, switch (sort_column_id) { + case THUNAR_LIST_MODEL_COLUMN_DATE_ACCESSED: + store->sort_func = sort_by_date_accessed; + break; + + case THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED: + store->sort_func = sort_by_date_modified; + break; + + case THUNAR_LIST_MODEL_COLUMN_MIME_TYPE: + store->sort_func = sort_by_mime_type; + break; + case THUNAR_LIST_MODEL_COLUMN_NAME: store->sort_func = sort_by_name; break; @@ -1213,6 +1264,85 @@ thunar_list_model_files_added (ThunarFolder *folder, static gint +sort_by_date_accessed (ThunarFile *a, + ThunarFile *b) +{ + ThunarVfsFileTime date_a; + ThunarVfsFileTime date_b; + gboolean can_a; + gboolean can_b; + + can_a = thunar_file_get_date (a, THUNAR_FILE_DATE_ACCESSED, &date_a); + can_b = thunar_file_get_date (b, THUNAR_FILE_DATE_ACCESSED, &date_b); + + if (G_UNLIKELY (!can_a && !can_b)) + return 0; + else if (G_UNLIKELY (!can_a)) + return -1; + else if (G_UNLIKELY (!can_b)) + return 1; + + if (date_a < date_b) + return -1; + else if (date_a > date_b) + return 1; + return 0; +} + + + +static gint +sort_by_date_modified (ThunarFile *a, + ThunarFile *b) +{ + ThunarVfsFileTime date_a; + ThunarVfsFileTime date_b; + gboolean can_a; + gboolean can_b; + + can_a = thunar_file_get_date (a, THUNAR_FILE_DATE_MODIFIED, &date_a); + can_b = thunar_file_get_date (b, THUNAR_FILE_DATE_MODIFIED, &date_b); + + if (G_UNLIKELY (!can_a && !can_b)) + return 0; + else if (G_UNLIKELY (!can_a)) + return -1; + else if (G_UNLIKELY (!can_b)) + return 1; + + if (date_a < date_b) + return -1; + else if (date_a > date_b) + return 1; + return 0; +} + + + +static gint +sort_by_mime_type (ThunarFile *a, + ThunarFile *b) +{ + ExoMimeInfo *info_a; + ExoMimeInfo *info_b; + + info_a = thunar_file_get_mime_info (a); + info_b = thunar_file_get_mime_info (b); + + if (G_UNLIKELY (info_a == NULL && info_b == NULL)) + return 0; + else if (G_UNLIKELY (info_a == NULL)) + return -1; + else if (G_UNLIKELY (info_b == NULL)) + return 1; + + return strcasecmp (exo_mime_info_get_name (info_a), + exo_mime_info_get_name (info_b)); +} + + + +static gint sort_by_name (ThunarFile *a, ThunarFile *b) { @@ -1264,9 +1394,21 @@ static gint sort_by_type (ThunarFile *a, ThunarFile *b) { - // TODO: Implement this. - g_assert_not_reached (); - return 0; + ExoMimeInfo *info_a; + ExoMimeInfo *info_b; + + info_a = thunar_file_get_mime_info (a); + info_b = thunar_file_get_mime_info (b); + + if (G_UNLIKELY (info_a == NULL && info_b == NULL)) + return 0; + else if (G_UNLIKELY (info_a == NULL)) + return -1; + else if (G_UNLIKELY (info_b == NULL)) + return 1; + + return strcasecmp (exo_mime_info_get_comment (info_a), + exo_mime_info_get_comment (info_b)); } diff --git a/thunar/thunar-list-model.h b/thunar/thunar-list-model.h index a9a80a48..ace1fbe6 100644 --- a/thunar/thunar-list-model.h +++ b/thunar/thunar-list-model.h @@ -42,10 +42,13 @@ typedef struct _ThunarListModel ThunarListModel; **/ typedef enum { - THUNAR_LIST_MODEL_COLUMN_NAME, + THUNAR_LIST_MODEL_COLUMN_DATE_ACCESSED, + THUNAR_LIST_MODEL_COLUMN_DATE_MODIFIED, THUNAR_LIST_MODEL_COLUMN_ICON_SMALL, THUNAR_LIST_MODEL_COLUMN_ICON_NORMAL, THUNAR_LIST_MODEL_COLUMN_ICON_LARGE, + THUNAR_LIST_MODEL_COLUMN_MIME_TYPE, + THUNAR_LIST_MODEL_COLUMN_NAME, THUNAR_LIST_MODEL_COLUMN_PERMISSIONS, THUNAR_LIST_MODEL_COLUMN_SIZE, THUNAR_LIST_MODEL_COLUMN_TYPE, diff --git a/thunar/thunar-local-file.c b/thunar/thunar-local-file.c index 17ef646a..1faeea0e 100644 --- a/thunar/thunar-local-file.c +++ b/thunar/thunar-local-file.c @@ -35,6 +35,9 @@ static ThunarVfsURI *thunar_local_file_get_uri (ThunarFile static ExoMimeInfo *thunar_local_file_get_mime_info (ThunarFile *file); static const gchar *thunar_local_file_get_display_name (ThunarFile *file); static const gchar *thunar_local_file_get_special_name (ThunarFile *file); +static gboolean thunar_local_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return); static ThunarVfsFileType thunar_local_file_get_kind (ThunarFile *file); static ThunarVfsFileMode thunar_local_file_get_mode (ThunarFile *file); static ThunarVfsFileSize thunar_local_file_get_size (ThunarFile *file); @@ -79,6 +82,7 @@ thunar_local_file_class_init (ThunarLocalFileClass *klass) thunarfile_class->get_mime_info = thunar_local_file_get_mime_info; thunarfile_class->get_display_name = thunar_local_file_get_display_name; thunarfile_class->get_special_name = thunar_local_file_get_special_name; + thunarfile_class->get_date = thunar_local_file_get_date; thunarfile_class->get_kind = thunar_local_file_get_kind; thunarfile_class->get_mode = thunar_local_file_get_mode; thunarfile_class->get_size = thunar_local_file_get_size; @@ -177,6 +181,36 @@ thunar_local_file_get_special_name (ThunarFile *file) +static gboolean +thunar_local_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return) +{ + ThunarLocalFile *local_file = THUNAR_LOCAL_FILE (file); + + switch (date_type) + { + case THUNAR_FILE_DATE_ACCESSED: + *date_return = local_file->info.atime; + break; + + case THUNAR_FILE_DATE_CHANGED: + *date_return = local_file->info.ctime; + break; + + case THUNAR_FILE_DATE_MODIFIED: + *date_return = local_file->info.mtime; + break; + + default: + return THUNAR_FILE_GET_CLASS (file)->get_date (file, date_type, date_return); + } + + return TRUE; +} + + + static ThunarVfsFileMode thunar_local_file_get_mode (ThunarFile *file) { diff --git a/thunar/thunar-trash-file.c b/thunar/thunar-trash-file.c index 3a262a2e..69db7534 100644 --- a/thunar/thunar-trash-file.c +++ b/thunar/thunar-trash-file.c @@ -40,6 +40,9 @@ static ThunarFolder *thunar_trash_file_open_as_folder (ThunarFile static ThunarVfsURI *thunar_trash_file_get_uri (ThunarFile *file); static ExoMimeInfo *thunar_trash_file_get_mime_info (ThunarFile *file); static const gchar *thunar_trash_file_get_display_name (ThunarFile *file); +static gboolean thunar_trash_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return); static ThunarVfsFileType thunar_trash_file_get_kind (ThunarFile *file); static ThunarVfsFileMode thunar_trash_file_get_mode (ThunarFile *file); static ThunarVfsFileSize thunar_trash_file_get_size (ThunarFile *file); @@ -84,6 +87,7 @@ thunar_trash_file_class_init (ThunarTrashFileClass *klass) thunarfile_class->get_uri = thunar_trash_file_get_uri; thunarfile_class->get_mime_info = thunar_trash_file_get_mime_info; thunarfile_class->get_display_name = thunar_trash_file_get_display_name; + thunarfile_class->get_date = thunar_trash_file_get_date; thunarfile_class->get_kind = thunar_trash_file_get_kind; thunarfile_class->get_mode = thunar_trash_file_get_mode; thunarfile_class->get_size = thunar_trash_file_get_size; @@ -156,6 +160,17 @@ thunar_trash_file_get_display_name (ThunarFile *file) +static gboolean +thunar_trash_file_get_date (ThunarFile *file, + ThunarFileDateType date_type, + ThunarVfsFileTime *date_return) +{ + ThunarTrashFile *trash_file = THUNAR_TRASH_FILE (file); + return THUNAR_FILE_GET_CLASS (trash_file->real_file)->get_date (trash_file->real_file, date_type, date_return); +} + + + static ThunarVfsFileType thunar_trash_file_get_kind (ThunarFile *file) { |