Skip to content

Commit e148897

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 e3cb374 commit e148897

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
@@ -315,13 +315,14 @@ eom_image_init (EomImage *img)
315315
}
316316

317317
EomImage *
318-
eom_image_new_file (GFile *file)
318+
eom_image_new_file (GFile *file, const gchar *caption)
319319
{
320320
EomImage *img;
321321

322322
img = EOM_IMAGE (g_object_new (EOM_TYPE_IMAGE, NULL));
323323

324324
img->priv->file = g_object_ref (file);
325+
img->priv->caption = g_strdup (caption);
325326

326327
return img;
327328
}

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
@@ -352,13 +352,14 @@ eom_list_store_append_image (EomListStore *store, EomImage *image)
352352

353353
static void
354354
eom_list_store_append_image_from_file (EomListStore *store,
355-
GFile *file)
355+
GFile *file,
356+
const gchar *caption)
356357
{
357358
EomImage *image;
358359

359360
g_return_if_fail (EOM_IS_LIST_STORE (store));
360361

361-
image = eom_image_new_file (file);
362+
image = eom_image_new_file (file, caption);
362363

363364
eom_list_store_append_image (store, image);
364365
}
@@ -378,7 +379,8 @@ file_monitor_changed_cb (GFileMonitor *monitor,
378379
switch (event) {
379380
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
380381
file_info = g_file_query_info (file,
381-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
382+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
383+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
382384
0, NULL, NULL);
383385
if (file_info == NULL) {
384386
break;
@@ -398,7 +400,10 @@ file_monitor_changed_cb (GFileMonitor *monitor,
398400
}
399401
} else {
400402
if (eom_image_is_supported_mime_type (mimetype)) {
401-
eom_list_store_append_image_from_file (store, file);
403+
const gchar *caption;
404+
405+
caption = g_file_info_get_display_name (file_info);
406+
eom_list_store_append_image_from_file (store, file, caption);
402407
}
403408
}
404409
g_object_unref (file_info);
@@ -417,15 +422,19 @@ file_monitor_changed_cb (GFileMonitor *monitor,
417422
case G_FILE_MONITOR_EVENT_CREATED:
418423
if (!is_file_in_list_store_file (store, file, NULL)) {
419424
file_info = g_file_query_info (file,
420-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
425+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
426+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
421427
0, NULL, NULL);
422428
if (file_info == NULL) {
423429
break;
424430
}
425431
mimetype = g_file_info_get_content_type (file_info);
426432

427433
if (eom_image_is_supported_mime_type (mimetype)) {
428-
eom_list_store_append_image_from_file (store, file);
434+
const gchar *caption;
435+
436+
caption = g_file_info_get_display_name (file_info);
437+
eom_list_store_append_image_from_file (store, file, caption);
429438
}
430439
g_object_unref (file_info);
431440
}
@@ -473,8 +482,11 @@ directory_visit (GFile *directory,
473482
}
474483

475484
if (load_uri) {
485+
const gchar *caption;
486+
476487
child = g_file_get_child (directory, name);
477-
eom_list_store_append_image_from_file (store, child);
488+
caption = g_file_info_get_display_name (children_info);
489+
eom_list_store_append_image_from_file (store, child, caption);
478490
}
479491
}
480492

@@ -503,6 +515,7 @@ eom_list_store_append_directory (EomListStore *store,
503515

504516
file_enumerator = g_file_enumerate_children (file,
505517
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
518+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME ","
506519
G_FILE_ATTRIBUTE_STANDARD_NAME,
507520
0, NULL, NULL);
508521
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)
549562

550563
for (it = file_list; it != NULL; it = it->next) {
551564
GFile *file = (GFile *) it->data;
565+
gchar *caption = NULL;
552566

553567
file_info = g_file_query_info (file,
554568
G_FILE_ATTRIBUTE_STANDARD_TYPE","
555-
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
569+
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE","
570+
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
556571
0, NULL, NULL);
557572
if (file_info == NULL) {
558573
continue;
559574
}
575+
576+
caption = g_strdup (g_file_info_get_display_name (file_info));
560577
file_type = g_file_info_get_file_type (file_info);
561578

562579
/* Workaround for gvfs backends that don't set the GFileType. */
@@ -597,16 +614,18 @@ eom_list_store_add_files (EomListStore *store, GList *file_list)
597614
if (!is_file_in_list_store_file (store,
598615
initial_file,
599616
&iter)) {
600-
eom_list_store_append_image_from_file (store, initial_file);
617+
eom_list_store_append_image_from_file (store, initial_file, caption);
601618
}
602619
} else {
603-
eom_list_store_append_image_from_file (store, initial_file);
620+
eom_list_store_append_image_from_file (store, initial_file, caption);
604621
}
605622
g_object_unref (file);
606623
} else if (file_type == G_FILE_TYPE_REGULAR &&
607624
g_list_length (file_list) > 1) {
608-
eom_list_store_append_image_from_file (store, file);
625+
eom_list_store_append_image_from_file (store, file, caption);
609626
}
627+
628+
g_free (caption);
610629
}
611630

612631
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),

0 commit comments

Comments
 (0)