Skip to content

Commit 98a063e

Browse files
debarshirayraveit65
authored andcommitted
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
1 parent 0d1a90a commit 98a063e

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

src/eom-image.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,13 +321,14 @@ eom_image_init (EomImage *img)
321321
}
322322

323323
EomImage *
324-
eom_image_new_file (GFile *file)
324+
eom_image_new_file (GFile *file, const gchar *caption)
325325
{
326326
EomImage *img;
327327

328328
img = EOM_IMAGE (g_object_new (EOM_TYPE_IMAGE, NULL));
329329

330330
img->priv->file = g_object_ref (file);
331+
img->priv->caption = g_strdup (caption);
331332

332333
return img;
333334
}

src/eom-image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ GType eom_image_get_type (void) G_GNUC_CONST;
121121

122122
GQuark eom_image_error_quark (void);
123123

124-
EomImage *eom_image_new_file (GFile *file);
124+
EomImage *eom_image_new_file (GFile *file, const gchar *caption);
125125

126126
gboolean eom_image_load (EomImage *img,
127127
EomImageData data2read,

src/eom-list-store.c

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,14 @@ eom_list_store_append_image (EomListStore *store, EomImage *image)
368368

369369
static void
370370
eom_list_store_append_image_from_file (EomListStore *store,
371-
GFile *file)
371+
GFile *file,
372+
const gchar *caption)
372373
{
373374
EomImage *image;
374375

375376
g_return_if_fail (EOM_IS_LIST_STORE (store));
376377

377-
image = eom_image_new_file (file);
378+
image = eom_image_new_file (file, caption);
378379

379380
eom_list_store_append_image (store, image);
380381
}
@@ -394,7 +395,8 @@ file_monitor_changed_cb (GFileMonitor *monitor,
394395
switch (event) {
395396
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
396397
file_info = g_file_query_info (file,
397-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
398+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
399+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
398400
0, NULL, NULL);
399401
if (file_info == NULL) {
400402
break;
@@ -414,7 +416,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
414416
}
415417
} else {
416418
if (eom_image_is_supported_mime_type (mimetype)) {
417-
eom_list_store_append_image_from_file (store, file);
419+
const gchar *caption;
420+
421+
caption = g_file_info_get_display_name (file_info);
422+
eom_list_store_append_image_from_file (store, file, caption);
418423
}
419424
}
420425
g_object_unref (file_info);
@@ -433,15 +438,19 @@ file_monitor_changed_cb (GFileMonitor *monitor,
433438
case G_FILE_MONITOR_EVENT_CREATED:
434439
if (!is_file_in_list_store_file (store, file, NULL)) {
435440
file_info = g_file_query_info (file,
436-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
441+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
442+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
437443
0, NULL, NULL);
438444
if (file_info == NULL) {
439445
break;
440446
}
441447
mimetype = g_file_info_get_content_type (file_info);
442448

443449
if (eom_image_is_supported_mime_type (mimetype)) {
444-
eom_list_store_append_image_from_file (store, file);
450+
const gchar *caption;
451+
452+
caption = g_file_info_get_display_name (file_info);
453+
eom_list_store_append_image_from_file (store, file, caption);
445454
}
446455
g_object_unref (file_info);
447456
}
@@ -489,8 +498,11 @@ directory_visit (GFile *directory,
489498
}
490499

491500
if (load_uri) {
501+
const gchar *caption;
502+
492503
child = g_file_get_child (directory, name);
493-
eom_list_store_append_image_from_file (store, child);
504+
caption = g_file_info_get_display_name (children_info);
505+
eom_list_store_append_image_from_file (store, child, caption);
494506
}
495507
}
496508

@@ -519,6 +531,7 @@ eom_list_store_append_directory (EomListStore *store,
519531

520532
file_enumerator = g_file_enumerate_children (file,
521533
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
534+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
522535
G_FILE_ATTRIBUTE_STANDARD_NAME,
523536
0, NULL, NULL);
524537
file_info = g_file_enumerator_next_file (file_enumerator, NULL, NULL);
@@ -565,14 +578,18 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
565578

566579
for (it = file_list; it != NULL; it = it->next) {
567580
GFile *file = (GFile *) it->data;
581+
gchar *caption = NULL;
568582

569583
file_info = g_file_query_info (file,
570584
G_FILE_ATTRIBUTE_STANDARD_TYPE","
571-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
585+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
586+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
572587
0, NULL, NULL);
573588
if (file_info == NULL) {
574589
continue;
575590
}
591+
592+
caption = g_strdup (g_file_info_get_display_name (file_info));
576593
file_type = g_file_info_get_file_type (file_info);
577594

578595
/* Workaround for gvfs backends that don't set the GFileType. */
@@ -613,16 +630,18 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
613630
if (!is_file_in_list_store_file (store,
614631
initial_file,
615632
&iter)) {
616-
eom_list_store_append_image_from_file (store, initial_file);
633+
eom_list_store_append_image_from_file (store, initial_file, caption);
617634
}
618635
} else {
619-
eom_list_store_append_image_from_file (store, initial_file);
636+
eom_list_store_append_image_from_file (store, initial_file, caption);
620637
}
621638
g_object_unref (file);
622639
} else if (file_type == G_FILE_TYPE_REGULAR &&
623640
g_list_length (file_list) > 1) {
624-
eom_list_store_append_image_from_file (store, file);
641+
eom_list_store_append_image_from_file (store, file, caption);
625642
}
643+
644+
g_free (caption);
626645
}
627646

628647
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),

0 commit comments

Comments
 (0)