This patch resolves the problem in browser.<br>I don&#39;t know if may be a good idea do the preview in the datastore instead.<br><br>Gonzalo<br><br>[gonzalo@aronax Browse.activity]$ diff -u downloadmanager.py.ori downloadmanager.py<br>
--- downloadmanager.py.ori    2010-07-05 20:27:06.000000000 -0300<br>+++ downloadmanager.py    2010-08-06 02:17:23.095272320 -0300<br>@@ -36,8 +36,10 @@<br> from sugar import mime<br> from sugar.graphics.alert import Alert, TimeoutAlert<br>
 from sugar.graphics.icon import Icon<br>+from sugar.graphics import style<br> from sugar.activity import activity<br> <br>+<br> # #3903 - this constant can be removed and assumed to be 1 when dbus-python<br> # 0.82.3 is the only version used<br>
 import dbus<br>@@ -192,12 +194,47 @@<br>                 sniffed_mime_type = mime.get_for_file(self._target_file.path)<br>                 self.dl_jobject.metadata[&#39;mime_type&#39;] = sniffed_mime_type<br> <br>+            if self._mime_type in (&#39;image/bmp&#39;,&#39;image/gif&#39;,&#39;image/jpeg&#39;,&#39;image/png&#39;,&#39;image/tiff&#39;):<br>
+<br>+                self.dl_jobject.metadata[&#39;preview&#39;] = self.__get_preview_image()<br>+            else:<br>+                self.dl_jobject.metadata[&#39;preview&#39;] = &#39;&#39;<br>+<br>             datastore.write(self.dl_jobject,<br>
                             transfer_ownership=True,<br>                             reply_handler=self._internal_save_cb,<br>                             error_handler=self._internal_save_error_cb,<br>                             timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)<br>
 <br>+    def __get_preview_image(self):<br>+        pixbuf = gtk.gdk.pixbuf_new_from_file(self._target_file.path)<br>+        width, height = pixbuf.get_width(), pixbuf.get_height()<br>+<br>+        preview_width = style.zoom(300)<br>
+        preview_height =  style.zoom(225)<br>+<br>+        if (width &gt; preview_width) or (height &gt; preview_height):<br>+            scale_x = float(width) / preview_width<br>+            scale_y = float(height) / preview_height<br>
+            scale = max(scale_x,scale_y)<br>+        <br>+            pixbuf = pixbuf.scale_simple(float(width) / scale, height / scale,<br>+                                     gtk.gdk.INTERP_BILINEAR)<br>+        pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,pixbuf.get_has_alpha(),8,preview_width,preview_height)<br>
+        pixbuf2.fill(0xffffffff)<br>+        margin_x = (preview_width - pixbuf.get_width()) / 2 <br>+        margin_y = (preview_height - pixbuf.get_height()) / 2<br>+<br>+        pixbuf.copy_area(0,0,pixbuf.get_width(),pixbuf.get_height(),pixbuf2,margin_x,margin_y)<br>
+<br>+        preview_data = []<br>+        def save_func(buf, data):<br>+            data.append(buf)<br>+<br>+        pixbuf2.save_to_callback(save_func, &#39;png&#39;, user_data=preview_data)<br>+        preview_data = &#39;&#39;.join(preview_data)<br>
+        return dbus.ByteArray(preview_data)<br>+<br>     def __start_response_cb(self, alert, response_id):<br>         global _active_downloads<br>         if response_id is gtk.RESPONSE_CANCEL:<br>@@ -273,10 +310,10 @@<br>
         self.dl_jobject.metadata[&#39;progress&#39;] = &#39;0&#39;<br>         self.dl_jobject.metadata[&#39;keep&#39;] = &#39;0&#39;<br>         self.dl_jobject.metadata[&#39;buddies&#39;] = &#39;&#39;<br>-        self.dl_jobject.metadata[&#39;preview&#39;] = &#39;&#39;<br>
         self.dl_jobject.metadata[&#39;icon-color&#39;] = \<br>                 profile.get_color().to_string()<br>         self.dl_jobject.metadata[&#39;mime_type&#39;] = self._mime_type<br>+        self.dl_jobject.metadata[&#39;preview&#39;] = &#39;&#39;<br>
         self.dl_jobject.file_path = &#39;&#39;<br>         datastore.write(self.dl_jobject)<br> <br><br>