summaryrefslogtreecommitdiff
path: root/src/eom-list-store.c
diff options
context:
space:
mode:
authorDebarshi Ray <[email protected]>2016-04-07 10:14:19 +0200
committerraveit65 <[email protected]>2018-08-24 08:36:14 +0200
commite1488971ed44e26257d7014760aa251393351473 (patch)
tree8a74a75972be5014576de8c31856b3272c33b068 /src/eom-list-store.c
parente3cb374d82809e26582d5b60374baef4474d5773 (diff)
downloadeom-e1488971ed44e26257d7014760aa251393351473.tar.bz2
eom-e1488971ed44e26257d7014760aa251393351473.tar.xz
Reduce the number of g_file_query_info calls at start-up
https://bugzilla.gnome.org/show_bug.cgi?id=764139 origin commit: https://gitlab.gnome.org/GNOME/eog/commit/65e61ccc
Diffstat (limited to 'src/eom-list-store.c')
-rw-r--r--src/eom-list-store.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/src/eom-list-store.c b/src/eom-list-store.c
index 12c8cf4..4be7e02 100644
--- a/src/eom-list-store.c
+++ b/src/eom-list-store.c
@@ -352,13 +352,14 @@ eom_list_store_append_image (EomListStore *store, EomImage *image)
static void
eom_list_store_append_image_from_file (EomListStore *store,
- GFile *file)
+ GFile *file,
+ const gchar *caption)
{
EomImage *image;
g_return_if_fail (EOM_IS_LIST_STORE (store));
- image = eom_image_new_file (file);
+ image = eom_image_new_file (file, caption);
eom_list_store_append_image (store, image);
}
@@ -378,7 +379,8 @@ file_monitor_changed_cb (GFileMonitor *monitor,
switch (event) {
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_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
break;
@@ -398,7 +400,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
}
} else {
if (eom_image_is_supported_mime_type (mimetype)) {
- eom_list_store_append_image_from_file (store, file);
+ const gchar *caption;
+
+ caption = g_file_info_get_display_name (file_info);
+ eom_list_store_append_image_from_file (store, file, caption);
}
}
g_object_unref (file_info);
@@ -417,7 +422,8 @@ file_monitor_changed_cb (GFileMonitor *monitor,
case G_FILE_MONITOR_EVENT_CREATED:
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_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
break;
@@ -425,7 +431,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
mimetype = g_file_info_get_content_type (file_info);
if (eom_image_is_supported_mime_type (mimetype)) {
- eom_list_store_append_image_from_file (store, file);
+ const gchar *caption;
+
+ caption = g_file_info_get_display_name (file_info);
+ eom_list_store_append_image_from_file (store, file, caption);
}
g_object_unref (file_info);
}
@@ -473,8 +482,11 @@ directory_visit (GFile *directory,
}
if (load_uri) {
+ const gchar *caption;
+
child = g_file_get_child (directory, name);
- eom_list_store_append_image_from_file (store, child);
+ caption = g_file_info_get_display_name (children_info);
+ eom_list_store_append_image_from_file (store, child, caption);
}
}
@@ -503,6 +515,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_DISPLAY_NAME ","
G_FILE_ATTRIBUTE_STANDARD_NAME,
0, NULL, NULL);
file_info = g_file_enumerator_next_file (file_enumerator, NULL, NULL);
@@ -549,14 +562,18 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
for (it = file_list; it != NULL; it = it->next) {
GFile *file = (GFile *) it->data;
+ gchar *caption = NULL;
file_info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_TYPE","
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
+ G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
0, NULL, NULL);
if (file_info == NULL) {
continue;
}
+
+ caption = g_strdup (g_file_info_get_display_name (file_info));
file_type = g_file_info_get_file_type (file_info);
/* Workaround for gvfs backends that don't set the GFileType. */
@@ -597,16 +614,18 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
if (!is_file_in_list_store_file (store,
initial_file,
&iter)) {
- eom_list_store_append_image_from_file (store, initial_file);
+ eom_list_store_append_image_from_file (store, initial_file, caption);
}
} else {
- eom_list_store_append_image_from_file (store, initial_file);
+ eom_list_store_append_image_from_file (store, initial_file, caption);
}
g_object_unref (file);
} else if (file_type == G_FILE_TYPE_REGULAR &&
g_list_length (file_list) > 1) {
- eom_list_store_append_image_from_file (store, file);
+ eom_list_store_append_image_from_file (store, file, caption);
}
+
+ g_free (caption);
}
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),