gnome-desktop r5259 - in trunk: . libgnome-desktop



Author: alexl
Date: Tue Oct 21 13:05:44 2008
New Revision: 5259
URL: http://svn.gnome.org/viewvc/gnome-desktop?rev=5259&view=rev

Log:
2008-10-21  Alexander Larsson  <alexl redhat com>

        * gnome-desktop-thumbnail.c:
        (_gdk_pixbuf_new_from_uri_at_scale):
	Check for preview::icon for fast backend-side thumbnails (#557184)
	Patch from David Zeuthen



Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/libgnome-desktop/ChangeLog
   trunk/libgnome-desktop/gnome-desktop-thumbnail.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Tue Oct 21 13:05:44 2008
@@ -71,7 +71,7 @@
 
 GDK_PIXBUF_REQUIRED=2.4.0
 GTK_REQUIRED=2.11.3
-GLIB_REQUIRED=2.15.4
+GLIB_REQUIRED=2.19.1
 GCONF_REQUIRED=2.0.0
 STARTUP_NOTIFICATION_REQUIRED=0.5
 XRANDR_REQUIRED=1.2

Modified: trunk/libgnome-desktop/gnome-desktop-thumbnail.c
==============================================================================
--- trunk/libgnome-desktop/gnome-desktop-thumbnail.c	(original)
+++ trunk/libgnome-desktop/gnome-desktop-thumbnail.c	Tue Oct 21 13:05:44 2008
@@ -137,15 +137,42 @@
     gboolean has_frame;
     SizePrepareContext info;
     GFile *file;
-    GFileInputStream *file_input_stream;
+    GFileInfo *file_info;
+    GInputStream *input_stream;
 
     g_return_val_if_fail (uri != NULL, NULL);
 
+    input_stream = NULL;
+
     file = g_file_new_for_uri (uri);
-    file_input_stream = g_file_read (file, NULL, NULL);
-    if (file_input_stream == NULL) {
-	g_object_unref (file);
-	return NULL;
+
+    /* First see if we can get an input stream via preview::icon  */
+    file_info = g_file_query_info (file,
+                                   G_FILE_ATTRIBUTE_PREVIEW_ICON,
+                                   G_FILE_QUERY_INFO_NONE,
+                                   NULL,  /* GCancellable */
+                                   NULL); /* return location for GError */
+    if (file_info != NULL) {
+        GObject *object;
+
+        object = g_file_info_get_attribute_object (file_info,
+                                                   G_FILE_ATTRIBUTE_PREVIEW_ICON);
+        if (object != NULL && G_IS_LOADABLE_ICON (object)) {
+            input_stream = g_loadable_icon_load (G_LOADABLE_ICON (object),
+                                                 0,     /* size */
+                                                 NULL,  /* return location for type */
+                                                 NULL,  /* GCancellable */
+                                                 NULL); /* return location for GError */
+        }
+        g_object_unref (file_info);
+    }
+
+    if (input_stream == NULL) {
+        input_stream = G_INPUT_STREAM (g_file_read (file, NULL, NULL));
+        if (input_stream == NULL) {
+	    g_object_unref (file);
+            return NULL;
+        }
     }
 
     loader = gdk_pixbuf_loader_new ();
@@ -162,7 +189,7 @@
     result = FALSE;
     while (!has_frame) {
 
-	bytes_read = g_input_stream_read (G_INPUT_STREAM (file_input_stream),
+	bytes_read = g_input_stream_read (input_stream,
 					  buffer,
 					  sizeof (buffer),
 					  NULL,
@@ -194,17 +221,17 @@
     }
 
     gdk_pixbuf_loader_close (loader, NULL);
-    
-    if (result) {
+
+    if (!result) {
 	g_object_unref (G_OBJECT (loader));
-	g_input_stream_close (G_INPUT_STREAM (file_input_stream), NULL, NULL);
-	g_object_unref (file_input_stream);
+	g_input_stream_close (input_stream, NULL, NULL);
+	g_object_unref (input_stream);
 	g_object_unref (file);
 	return NULL;
     }
 
-    g_input_stream_close (G_INPUT_STREAM (file_input_stream), NULL, NULL);
-    g_object_unref (file_input_stream);
+    g_input_stream_close (input_stream, NULL, NULL);
+    g_object_unref (input_stream);
     g_object_unref (file);
 
     pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]