Ok. I addressed all concerns from the previous mails and the comments in irc.<br>This patch take the supported mime types from the pixbuf library and open the image at the desired size to optimize if possible the io.<br><br>
Gonzalo<br><br><div class="gmail_quote">On Wed, Sep 15, 2010 at 7:58 AM, Simon Schampijer <span dir="ltr"><<a href="mailto:simon@schampijer.de">simon@schampijer.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Gonzalo,<br>
<br>
thanks for the new patch. Would be good to tell in a few words what you<br>
did change to the previous one, like: "I addressed all concerns." or<br>
"That one I did not address since..."<br>
<br>
Regards,<br>
Simon<br>
<div><div></div><div class="h5"><br>
On 09/14/2010 08:06 PM, <a href="mailto:godiard@sugarlabs.org">godiard@sugarlabs.org</a> wrote:<br>
> From: Gonzalo Odiard<<a href="mailto:godiard@sugarlabs.org">godiard@sugarlabs.org</a>><br>
><br>
> ---<br>
> downloadmanager.py | 32 ++++++++++++++++++++++++++++++++<br>
> 1 files changed, 32 insertions(+), 0 deletions(-)<br>
><br>
> diff --git a/downloadmanager.py b/downloadmanager.py<br>
> index 3eec649..24d3911 100644<br>
> --- a/downloadmanager.py<br>
> +++ b/downloadmanager.py<br>
> @@ -36,6 +36,7 @@ from sugar import profile<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>
> # #3903 - this constant can be removed and assumed to be 1 when dbus-python<br>
> @@ -192,12 +193,43 @@ class Download:<br>
> sniffed_mime_type = mime.get_for_file(self._target_file.path)<br>
> self.dl_jobject.metadata['mime_type'] = sniffed_mime_type<br>
><br>
> + pixbuf_mime_types = []<br>
> + for pixbuf_format in gtk.gdk.pixbuf_get_formats():<br>
> + pixbuf_mime_types.extend(pixbuf_format['mime_types'])<br>
> +<br>
> + if self._mime_type in pixbuf_mime_types:<br>
> + self.dl_jobject.metadata['preview'] = self._get_preview_image()<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>
> + preview_width, preview_height = style.zoom(300), style.zoom(225)<br>
> +<br>
> + pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(self._target_file.path, preview_width, preview_height)<br>
> + width, height = pixbuf.get_width(), pixbuf.get_height()<br>
> +<br>
> + pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, pixbuf.get_has_alpha(),<br>
> + pixbuf.get_bits_per_sample(), preview_width, preview_height)<br>
> +<br>
> + OPAQUE_WHITE = 0xffffffff<br>
> + pixbuf2.fill(OPAQUE_WHITE)<br>
> +<br>
> + margin_x, margin_y = (preview_width - width) / 2, (preview_height - height) / 2<br>
> +<br>
> + pixbuf.copy_area(0, 0, width, 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, 'png', user_data=preview_data)<br>
> + preview_data = ''.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>
<br>
</div></div>_______________________________________________<br>
Sugar-devel mailing list<br>
<a href="mailto:Sugar-devel@lists.sugarlabs.org">Sugar-devel@lists.sugarlabs.org</a><br>
<a href="http://lists.sugarlabs.org/listinfo/sugar-devel" target="_blank">http://lists.sugarlabs.org/listinfo/sugar-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Gonzalo Odiard<br>SugarLabs Argentina<br><br>