diff options
author | Bastien Nocera <hadess@hadess.net> | 2010-12-13 15:30:22 +0000 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2010-12-13 15:30:22 +0000 |
commit | 9580be8d17d6902632ce1785c25dfb69f60d48ea (patch) | |
tree | 25163fbd95a5aeddcf88bf1a2a02e4ac64adba30 | |
parent | a1fa500dc5ca8e7ec65a315c8e08f64464e850ba (diff) |
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.
-rw-r--r-- | panels/background/bg-pictures-source.c | 8 | ||||
-rw-r--r-- | panels/background/gnome-wp-info.c | 29 | ||||
-rw-r--r-- | panels/background/gnome-wp-info.h | 1 | ||||
-rw-r--r-- | panels/background/gnome-wp-item.c | 3 | ||||
-rw-r--r-- | panels/background/gnome-wp-item.h | 1 | ||||
-rw-r--r-- | panels/background/gnome-wp-xml.c | 5 |
6 files changed, 29 insertions, 18 deletions
diff --git a/panels/background/bg-pictures-source.c b/panels/background/bg-pictures-source.c index c26605cd0..49e2ba5ed 100644 --- a/panels/background/bg-pictures-source.c +++ b/panels/background/bg-pictures-source.c @@ -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, diff --git a/panels/background/gnome-wp-info.c b/panels/background/gnome-wp-info.c index 4cdb25811..53a4d30b8 100644 --- a/panels/background/gnome-wp-info.c +++ b/panels/background/gnome-wp-info.c @@ -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)")) { diff --git a/panels/background/gnome-wp-info.h b/panels/background/gnome-wp-info.h index b65ec79e1..c30dfb83a 100644 --- a/panels/background/gnome-wp-info.h +++ b/panels/background/gnome-wp-info.h @@ -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); diff --git a/panels/background/gnome-wp-item.c b/panels/background/gnome-wp-item.c index 40265c1e0..882966191 100644 --- a/panels/background/gnome-wp-item.c +++ b/panels/background/gnome-wp-item.c @@ -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/") || diff --git a/panels/background/gnome-wp-item.h b/panels/background/gnome-wp-item.h index 12281c823..33232f63c 100644 --- a/panels/background/gnome-wp-item.h +++ b/panels/background/gnome-wp-item.h @@ -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); diff --git a/panels/background/gnome-wp-xml.c b/panels/background/gnome-wp-xml.c index ec6537cf9..b5e3c4a73 100644 --- a/panels/background/gnome-wp-xml.c +++ b/panels/background/gnome-wp-xml.c @@ -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); |