background: Avoid re-querying the GFileInfo
If we already have it from enumerating the Pictures directory. Saves us from doing sync queries in certain cases.
This commit is contained in:
parent
a1fa500dc5
commit
9580be8d17
6 changed files with 29 additions and 18 deletions
|
@ -172,6 +172,7 @@ file_info_async_ready (GObject *source,
|
|||
|
||||
/* create a new GnomeWpItem */
|
||||
item = gnome_wp_item_new (filename, NULL,
|
||||
info,
|
||||
priv->thumb_factory);
|
||||
|
||||
if (!item)
|
||||
|
@ -181,11 +182,10 @@ file_info_async_ready (GObject *source,
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* insert the item into the liststore */
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_scale (filename, THUMBNAIL_WIDTH,
|
||||
THUMBNAIL_HEIGHT, TRUE,
|
||||
pixbuf = gdk_pixbuf_new_from_file_at_scale (filename,
|
||||
THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT,
|
||||
TRUE,
|
||||
NULL);
|
||||
gtk_list_store_insert_with_values (store, &iter, 0,
|
||||
0, pixbuf,
|
||||
|
|
|
@ -25,21 +25,30 @@
|
|||
#include "gnome-wp-info.h"
|
||||
|
||||
GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
|
||||
GFileInfo * file_info,
|
||||
GnomeDesktopThumbnailFactory * thumbs) {
|
||||
GnomeWPInfo *wp;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
|
||||
file = g_file_new_for_commandline_arg (uri);
|
||||
if (file_info == NULL)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL, NULL);
|
||||
g_object_unref (file);
|
||||
file = g_file_new_for_commandline_arg (uri);
|
||||
|
||||
info = g_file_query_info (file,
|
||||
G_FILE_ATTRIBUTE_STANDARD_NAME ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_SIZE ","
|
||||
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
|
||||
G_FILE_ATTRIBUTE_TIME_MODIFIED,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
NULL, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
{
|
||||
info = g_object_ref (file_info);
|
||||
}
|
||||
|
||||
if (info == NULL || g_file_info_get_content_type (info) == NULL) {
|
||||
if (!strcmp (uri, "(none)")) {
|
||||
|
|
|
@ -38,6 +38,7 @@ struct _GnomeWPInfo {
|
|||
};
|
||||
|
||||
GnomeWPInfo * gnome_wp_info_new (const gchar * uri,
|
||||
GFileInfo * file_info,
|
||||
GnomeDesktopThumbnailFactory * thumbs);
|
||||
void gnome_wp_info_free (GnomeWPInfo * info);
|
||||
|
||||
|
|
|
@ -155,11 +155,12 @@ void gnome_wp_item_update (GnomeWPItem *item) {
|
|||
|
||||
GnomeWPItem * gnome_wp_item_new (const gchar * filename,
|
||||
GHashTable * wallpapers,
|
||||
GFileInfo * file_info,
|
||||
GnomeDesktopThumbnailFactory * thumbnails) {
|
||||
GnomeWPItem *item = g_new0 (GnomeWPItem, 1);
|
||||
|
||||
item->filename = g_strdup (filename);
|
||||
item->fileinfo = gnome_wp_info_new (filename, thumbnails);
|
||||
item->fileinfo = gnome_wp_info_new (filename, file_info, thumbnails);
|
||||
|
||||
if (item->fileinfo != NULL && item->fileinfo->mime_type != NULL &&
|
||||
(g_str_has_prefix (item->fileinfo->mime_type, "image/") ||
|
||||
|
|
|
@ -69,6 +69,7 @@ struct _GnomeWPItem {
|
|||
|
||||
GnomeWPItem * gnome_wp_item_new (const gchar *filename,
|
||||
GHashTable *wallpapers,
|
||||
GFileInfo *file_info,
|
||||
GnomeDesktopThumbnailFactory *thumbnails);
|
||||
|
||||
void gnome_wp_item_free (GnomeWPItem *item);
|
||||
|
|
|
@ -83,7 +83,7 @@ static void gnome_wp_load_legacy (GnomeWpXml *data) {
|
|||
continue;
|
||||
}
|
||||
|
||||
item = gnome_wp_item_new (foo, data->wp_hash, data->thumb_factory);
|
||||
item = gnome_wp_item_new (foo, data->wp_hash, NULL, data->thumb_factory);
|
||||
if (item != NULL && item->fileinfo == NULL) {
|
||||
gnome_wp_item_free (item);
|
||||
}
|
||||
|
@ -118,7 +118,6 @@ static void gnome_wp_xml_load_xml (GnomeWpXml *data,
|
|||
if (!strcmp ((gchar *)list->name, "wallpaper")) {
|
||||
GnomeWPItem * wp;
|
||||
gchar *pcolor = NULL, *scolor = NULL;
|
||||
gchar *s;
|
||||
gboolean have_scale = FALSE, have_shade = FALSE;
|
||||
|
||||
wp = g_new0 (GnomeWPItem, 1);
|
||||
|
@ -224,7 +223,7 @@ static void gnome_wp_xml_load_xml (GnomeWpXml *data,
|
|||
if ((wp->filename != NULL &&
|
||||
g_file_test (wp->filename, G_FILE_TEST_EXISTS)) ||
|
||||
!strcmp (wp->filename, "(none)")) {
|
||||
wp->fileinfo = gnome_wp_info_new (wp->filename, data->thumb_factory);
|
||||
wp->fileinfo = gnome_wp_info_new (wp->filename, NULL, data->thumb_factory);
|
||||
|
||||
if (wp->name == NULL || !strcmp (wp->filename, "(none)")) {
|
||||
g_free (wp->name);
|
||||
|
|
Loading…
Add table
Reference in a new issue