[eog] Reduce the number of g_file_query_info calls at start-up
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog] Reduce the number of g_file_query_info calls at start-up
- Date: Mon, 11 Apr 2016 19:48:21 +0000 (UTC)
commit 65e61ccc81987643d9642a3b2bd49dd01674b591
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Apr 7 10:14:19 2016 +0200
Reduce the number of g_file_query_info calls at start-up
https://bugzilla.gnome.org/show_bug.cgi?id=764139
src/eog-image.c | 3 ++-
src/eog-image.h | 2 +-
src/eog-list-store.c | 41 ++++++++++++++++++++++++++++++-----------
3 files changed, 33 insertions(+), 13 deletions(-)
---
diff --git a/src/eog-image.c b/src/eog-image.c
index 5dc833a..cf773f9 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -332,13 +332,14 @@ eog_image_init (EogImage *img)
}
EogImage *
-eog_image_new_file (GFile *file)
+eog_image_new_file (GFile *file, const gchar *caption)
{
EogImage *img;
img = EOG_IMAGE (g_object_new (EOG_TYPE_IMAGE, NULL));
img->priv->file = g_object_ref (file);
+ img->priv->caption = g_strdup (caption);
return img;
}
diff --git a/src/eog-image.h b/src/eog-image.h
index d344462..23f2fb3 100644
--- a/src/eog-image.h
+++ b/src/eog-image.h
@@ -118,7 +118,7 @@ GType eog_image_get_type (void) G_GNUC_CONST;
GQuark eog_image_error_quark (void);
-EogImage *eog_image_new_file (GFile *file);
+EogImage *eog_image_new_file (GFile *file, const gchar *caption);
gboolean eog_image_load (EogImage *img,
EogImageData data2read,
diff --git a/src/eog-list-store.c b/src/eog-list-store.c
index 2866489..d5c5df0 100644
--- a/src/eog-list-store.c
+++ b/src/eog-list-store.c
@@ -357,13 +357,14 @@ eog_list_store_append_image (EogListStore *store, EogImage *image)
static void
eog_list_store_append_image_from_file (EogListStore *store,
- GFile *file)
+ GFile *file,
+ const gchar *caption)
{
EogImage *image;
g_return_if_fail (EOG_IS_LIST_STORE (store));
- image = eog_image_new_file (file);
+ image = eog_image_new_file (file, caption);
eog_list_store_append_image (store, image);
}
@@ -383,7 +384,8 @@ file_monitor_changed_cb (GFileMonitor *monitor,
switch (event) {
case G_FILE_MONITOR_EVENT_CHANGED:
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;
@@ -403,7 +405,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
}
} else {
if (eog_image_is_supported_mime_type (mimetype)) {
- eog_list_store_append_image_from_file (store, file);
+ const gchar *caption;
+
+ caption = g_file_info_get_display_name (file_info);
+ eog_list_store_append_image_from_file (store, file, caption);
}
}
g_object_unref (file_info);
@@ -422,7 +427,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;
@@ -430,7 +436,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
mimetype = g_file_info_get_content_type (file_info);
if (eog_image_is_supported_mime_type (mimetype)) {
- eog_list_store_append_image_from_file (store, file);
+ const gchar *caption;
+
+ caption = g_file_info_get_display_name (file_info);
+ eog_list_store_append_image_from_file (store, file, caption);
}
g_object_unref (file_info);
}
@@ -481,8 +490,11 @@ directory_visit (GFile *directory,
}
if (load_uri) {
+ const gchar *caption;
+
child = g_file_get_child (directory, name);
- eog_list_store_append_image_from_file (store, child);
+ caption = g_file_info_get_display_name (children_info);
+ eog_list_store_append_image_from_file (store, child, caption);
}
}
@@ -511,6 +523,7 @@ eog_list_store_append_directory (EogListStore *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);
@@ -557,14 +570,18 @@ eog_list_store_add_files (EogListStore *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. */
@@ -605,16 +622,18 @@ eog_list_store_add_files (EogListStore *store, GList *file_list)
if (!is_file_in_list_store_file (store,
initial_file,
&iter)) {
- eog_list_store_append_image_from_file (store, initial_file);
+ eog_list_store_append_image_from_file (store, initial_file, caption);
}
} else {
- eog_list_store_append_image_from_file (store, initial_file);
+ eog_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) {
- eog_list_store_append_image_from_file (store, file);
+ eog_list_store_append_image_from_file (store, file, caption);
}
+
+ g_free (caption);
}
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]