[gnome-control-center] background: Avoid re-querying the GFileInfo
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] background: Avoid re-querying the GFileInfo
- Date: Mon, 13 Dec 2010 16:21:29 +0000 (UTC)
commit 9580be8d17d6902632ce1785c25dfb69f60d48ea
Author: Bastien Nocera <hadess hadess net>
Date: Mon Dec 13 15:30:22 2010 +0000
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.
panels/background/bg-pictures-source.c | 8 ++++----
panels/background/gnome-wp-info.c | 29 +++++++++++++++++++----------
panels/background/gnome-wp-info.h | 1 +
panels/background/gnome-wp-item.c | 3 ++-
panels/background/gnome-wp-item.h | 1 +
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 c26605c..49e2ba5 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 4cdb258..53a4d30 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 b65ec79..c30dfb8 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 40265c1..8829661 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 12281c8..33232f6 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 ec6537c..b5e3c4a 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]