summaryrefslogtreecommitdiff
path: root/src/eom-list-store.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/eom-list-store.c')
-rw-r--r--src/eom-list-store.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/eom-list-store.c b/src/eom-list-store.c
index 0115b1d..9336614 100644
--- a/src/eom-list-store.c
+++ b/src/eom-list-store.c
@@ -26,6 +26,7 @@
#include "eom-image.h"
#include "eom-job-queue.h"
#include "eom-jobs.h"
+#include "eom-util.h"
#include <string.h>
@@ -34,7 +35,8 @@ struct _EomListStorePrivate {
gint initial_image; /* The image that should be selected firstly by the view. */
GdkPixbuf *busy_image; /* Loading image icon */
GdkPixbuf *missing_image; /* Missing image icon */
- GMutex mutex; /* Mutex for saving the jobs in the model */
+ GMutex mutex; /* Mutex for saving the jobs in the model */
+ gboolean preserve_order; /* If TRUE, preserves the original order of files */
};
G_DEFINE_TYPE_WITH_PRIVATE (EomListStore, eom_list_store, GTK_TYPE_LIST_STORE);
@@ -377,12 +379,13 @@ file_monitor_changed_cb (GFileMonitor *monitor,
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
break;
}
- mimetype = g_file_info_get_content_type (file_info);
+ mimetype = eom_util_get_content_type_with_fallback (file_info);
if (is_file_in_list_store_file (store, file, &iter)) {
if (eom_image_is_supported_mime_type (mimetype)) {
@@ -418,12 +421,13 @@ file_monitor_changed_cb (GFileMonitor *monitor,
if (!is_file_in_list_store_file (store, file, NULL)) {
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
break;
}
- mimetype = g_file_info_get_content_type (file_info);
+ mimetype = eom_util_get_content_type_with_fallback (file_info);
if (eom_image_is_supported_mime_type (mimetype)) {
const gchar *caption;
@@ -436,12 +440,13 @@ file_monitor_changed_cb (GFileMonitor *monitor,
break;
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
file_info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
0, NULL, NULL);
if (file_info == NULL) {
break;
}
- mimetype = g_file_info_get_content_type (file_info);
+ mimetype = eom_util_get_content_type_with_fallback (file_info);
if (is_file_in_list_store_file (store, file, &iter) &&
eom_image_is_supported_mime_type (mimetype)) {
eom_list_store_thumbnail_refresh (store, &iter);
@@ -467,7 +472,7 @@ directory_visit (GFile *directory,
gboolean load_uri = FALSE;
const char *mime_type, *name;
- mime_type = g_file_info_get_content_type (children_info);
+ mime_type = eom_util_get_content_type_with_fallback (children_info);
name = g_file_info_get_name (children_info);
if (!g_str_has_prefix (name, ".")) {
@@ -511,6 +516,7 @@ eom_list_store_append_directory (EomListStore *store,
file_enumerator = g_file_enumerate_children (file,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE ","
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
G_FILE_ATTRIBUTE_STANDARD_NAME,
0, NULL, NULL);
@@ -529,6 +535,7 @@ eom_list_store_append_directory (EomListStore *store,
* eom_list_store_add_files:
* @store: An #EomListStore.
* @file_list: (element-type GFile): A %NULL-terminated list of #GFile's.
+ * @preserve_order: Flag to indicate whether to honor the order of input parameters.
*
* Adds a list of #GFile's to @store. The given list
* must be %NULL-terminated.
@@ -540,7 +547,7 @@ eom_list_store_append_directory (EomListStore *store,
*
**/
void
-eom_list_store_add_files (EomListStore *store, GList *file_list)
+eom_list_store_add_files (EomListStore *store, GList *file_list, gboolean preserve_order)
{
GList *it;
GFileInfo *file_info;
@@ -563,6 +570,7 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE","
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
+ G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE","
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
@@ -576,7 +584,7 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
if (G_UNLIKELY (file_type == G_FILE_TYPE_UNKNOWN)) {
const gchar *ctype;
- ctype = g_file_info_get_content_type (file_info);
+ ctype = eom_util_get_content_type_with_fallback (file_info);
/* If the content type is supported adjust file_type */
if (eom_image_is_supported_mime_type (ctype))
@@ -624,7 +632,11 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
g_free (caption);
}
+ /* Set the sort behaviour depending on the toggle option.
+ If preserve_order is TRUE, then preserve the order in which files were provided.
+ Otherwise, use the default sort function. */
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ preserve_order ? GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID : \
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
GTK_SORT_ASCENDING);