Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Tomeu Vizoso
On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( because
 not only it happened with my activity, but also with other activities ), but
 I'd like to be sure I'm not doing anything wrong!

Haven't seen it happening myself. Can you tell us specific versions of
Sugar and any tips for reproducing it?

Thanks,

Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the access
 permissions to it, and, although we could simply manually change the folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, until
 we discovered that another sugar activity, Scratch, implemented saving and
 loading on a similar fashion we previously wanted. It has a folder inside
 it's Activity directory with subdirectories related to each kind of Scratch
 project. Also, Scratch's Activity directory has the same access permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without using the
 journal? Keep in mind that we do know that there are other directories we
 could use to save our files, but we would like to use our Activity directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] 0.90 Exception: Activities list view and Journal view crashes in Arabic

2010-09-24 Thread Tomeu Vizoso
On Wed, Sep 22, 2010 at 18:06, Simon Schampijer si...@schampijer.de wrote:
 Hi,

 I am asking for an exception for [1] 0.90. Originally discovered on 0.84
 this is also present on 0.90. The patch [2] has been reviewed by Sascha
 and Tomeu already and it is low risk. Otherwise Arabic will be unusable
 as this effects the Journal and the Activities list view.

I think there should be a big FIXME comment with a reference to a
ticket in trac because it's a hack and because we really need to find
an appropriate fix in the near future.

Also, we don't have plurals in any other place?

Regards,

Tomeu

 Regards,
    Simon

 [1] http://bugs.sugarlabs.org/ticket/2354
 [2] Patch: http://bugs.sugarlabs.org/ticket/2354#comment:3
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Unicode and input method menu in gtk inputs

2010-09-24 Thread Tomeu Vizoso
On Wed, Sep 22, 2010 at 13:58, Gonzalo Odiard godi...@sugarlabs.org wrote:
 In all the gtk inputs we display in Sugar there are a menu when we the
 options Cut, Copy,Paste,Select all and the Input method and unicode menu
 menus.
 The last two menus are optional and by default not showed  in Gnome.
 You can use gconf to change the visibility of the menus
 Gconf settings
 /desktop/gnome/interface/show_unicode_menu
 /desktop/gnome/interface/show_input_method_menu

 I tried to change the values in gconf or in .gtkrc-2.0 or in
 /etc/gtk-2.0/gtkrc but Sugar ignores the settings.
 I have a simple pygtk test program with a entry. If I run it from the gnome
 terminal doesn't show the menus, if I run it from Sugar Terminal show the
 menus.

 Anybody knows if this is a bug in the theme engine or where I set the menus
 visibility?

Which gconf database and gtkrc file will be used is defined by the
environment on which Sugar is running.

To make sure you are modifying the Sugar GConf, run gconftool-2 or
gconf-editor from inside the terminal activity.

Sugar installs its own gtkrc files, called sugar-72.gtkrc or sugar-100.gtkrc.

Regards,

Tomeu

 --
 Gonzalo Odiard
 SugarLabs Argentina


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Unicode and input method menu in gtk inputs

2010-09-24 Thread Gonzalo Odiard
Thanks.
The setting must be in sugar-72.gtkrc or sugar-100.gtkrc.
Ticket http://dev.laptop.org/ticket/8269

Gonzalo

On Fri, Sep 24, 2010 at 5:12 AM, Tomeu Vizoso to...@sugarlabs.org wrote:

 On Wed, Sep 22, 2010 at 13:58, Gonzalo Odiard godi...@sugarlabs.org
 wrote:
  In all the gtk inputs we display in Sugar there are a menu when we the
  options Cut, Copy,Paste,Select all and the Input method and unicode
 menu
  menus.
  The last two menus are optional and by default not showed  in Gnome.
  You can use gconf to change the visibility of the menus
  Gconf settings
  /desktop/gnome/interface/show_unicode_menu
  /desktop/gnome/interface/show_input_method_menu
 
  I tried to change the values in gconf or in .gtkrc-2.0 or in
  /etc/gtk-2.0/gtkrc but Sugar ignores the settings.
  I have a simple pygtk test program with a entry. If I run it from the
 gnome
  terminal doesn't show the menus, if I run it from Sugar Terminal show the
  menus.
 
  Anybody knows if this is a bug in the theme engine or where I set the
 menus
  visibility?

 Which gconf database and gtkrc file will be used is defined by the
 environment on which Sugar is running.

 To make sure you are modifying the Sugar GConf, run gconftool-2 or
 gconf-editor from inside the terminal activity.

 Sugar installs its own gtkrc files, called sugar-72.gtkrc or
 sugar-100.gtkrc.

 Regards,

 Tomeu

  --
  Gonzalo Odiard
  SugarLabs Argentina
 
 
  ___
  Sugar-devel mailing list
  Sugar-devel@lists.sugarlabs.org
  http://lists.sugarlabs.org/listinfo/sugar-devel
 
 




-- 
Gonzalo Odiard
SugarLabs Argentina
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Walter Bender
On Fri, Sep 24, 2010 at 4:02 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
 alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( because
 not only it happened with my activity, but also with other activities ), but
 I'd like to be sure I'm not doing anything wrong!

It could be that the Journal is reindexing. (For a large Journal, this
sometimes has the appearance of an empty or nearly empty Journal.) If
you wait for the indexing to complete, everything reappears as normal.

-walter

 Haven't seen it happening myself. Can you tell us specific versions of
 Sugar and any tips for reproducing it?

 Thanks,

 Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the access
 permissions to it, and, although we could simply manually change the folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, until
 we discovered that another sugar activity, Scratch, implemented saving and
 loading on a similar fashion we previously wanted. It has a folder inside
 it's Activity directory with subdirectories related to each kind of Scratch
 project. Also, Scratch's Activity directory has the same access permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without using the
 journal? Keep in mind that we do know that there are other directories we
 could use to save our files, but we would like to use our Activity directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel




-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Tomeu Vizoso
On Fri, Sep 24, 2010 at 14:41, Walter Bender walter.ben...@gmail.com wrote:
 On Fri, Sep 24, 2010 at 4:02 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
 alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( because
 not only it happened with my activity, but also with other activities ), but
 I'd like to be sure I'm not doing anything wrong!

 It could be that the Journal is reindexing. (For a large Journal, this
 sometimes has the appearance of an empty or nearly empty Journal.) If
 you wait for the indexing to complete, everything reappears as normal.

But why would it be reindexing? Are people getting their journals
reindexed from time to time?

Regards,

Tomeu

 -walter

 Haven't seen it happening myself. Can you tell us specific versions of
 Sugar and any tips for reproducing it?

 Thanks,

 Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the 
 access
 permissions to it, and, although we could simply manually change the folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, until
 we discovered that another sugar activity, Scratch, implemented saving and
 loading on a similar fashion we previously wanted. It has a folder inside
 it's Activity directory with subdirectories related to each kind of Scratch
 project. Also, Scratch's Activity directory has the same access permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without using 
 the
 journal? Keep in mind that we do know that there are other directories we
 could use to save our files, but we would like to use our Activity 
 directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel




 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Walter Bender
On Fri, Sep 24, 2010 at 9:10 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Fri, Sep 24, 2010 at 14:41, Walter Bender walter.ben...@gmail.com wrote:
 On Fri, Sep 24, 2010 at 4:02 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
 alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( because
 not only it happened with my activity, but also with other activities ), 
 but
 I'd like to be sure I'm not doing anything wrong!

 It could be that the Journal is reindexing. (For a large Journal, this
 sometimes has the appearance of an empty or nearly empty Journal.) If
 you wait for the indexing to complete, everything reappears as normal.

 But why would it be reindexing? Are people getting their journals
 reindexed from time to time?

Not sure why, but in sugar-jhbuild, where I do most of my work, it
seems to reindex fairly often (~1 out of every 30-40 sessions
launched). one trigger *seems to be* changing the display size, e.g.,
if I use 1200x900 sessions for a while and then switch to 800x600, it
will often reindex. (Likely nothing causal there.)

-walter

 Regards,

 Tomeu

 -walter

 Haven't seen it happening myself. Can you tell us specific versions of
 Sugar and any tips for reproducing it?

 Thanks,

 Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the 
 access
 permissions to it, and, although we could simply manually change the 
 folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, until
 we discovered that another sugar activity, Scratch, implemented saving and
 loading on a similar fashion we previously wanted. It has a folder inside
 it's Activity directory with subdirectories related to each kind of 
 Scratch
 project. Also, Scratch's Activity directory has the same access permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without using 
 the
 journal? Keep in mind that we do know that there are other directories we
 could use to save our files, but we would like to use our Activity 
 directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel




 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org





-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] bug #2170

2010-09-24 Thread Ishan Bansal
Hi

I had made the patch for the Bug #2170.

http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026963.htmlhttp://lists.sugarlabs.org/archive/sugar-devel/2010-September/026732.html

Please review the patch and provide suggestions on any change required.

regards

ishan
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Tomeu Vizoso
On Fri, Sep 24, 2010 at 15:25, Walter Bender walter.ben...@gmail.com wrote:
 On Fri, Sep 24, 2010 at 9:10 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Fri, Sep 24, 2010 at 14:41, Walter Bender walter.ben...@gmail.com wrote:
 On Fri, Sep 24, 2010 at 4:02 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
 alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but 
 when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save 
 the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( because
 not only it happened with my activity, but also with other activities ), 
 but
 I'd like to be sure I'm not doing anything wrong!

 It could be that the Journal is reindexing. (For a large Journal, this
 sometimes has the appearance of an empty or nearly empty Journal.) If
 you wait for the indexing to complete, everything reappears as normal.

 But why would it be reindexing? Are people getting their journals
 reindexed from time to time?

 Not sure why, but in sugar-jhbuild, where I do most of my work, it
 seems to reindex fairly often (~1 out of every 30-40 sessions
 launched). one trigger *seems to be* changing the display size, e.g.,
 if I use 1200x900 sessions for a while and then switch to 800x600, it
 will often reindex. (Likely nothing causal there.)

It could be very interesting to look at the logs of the session when
reindexing starts and also of the session just before that.

Regards,

Tomeu

 -walter

 Regards,

 Tomeu

 -walter

 Haven't seen it happening myself. Can you tell us specific versions of
 Sugar and any tips for reproducing it?

 Thanks,

 Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the 
 access
 permissions to it, and, although we could simply manually change the 
 folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, 
 until
 we discovered that another sugar activity, Scratch, implemented saving 
 and
 loading on a similar fashion we previously wanted. It has a folder inside
 it's Activity directory with subdirectories related to each kind of 
 Scratch
 project. Also, Scratch's Activity directory has the same access 
 permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without using 
 the
 journal? Keep in mind that we do know that there are other directories we
 could use to save our files, but we would like to use our Activity 
 directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel




 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org





 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] bug #305

2010-09-24 Thread Tomeu Vizoso
On Fri, Sep 24, 2010 at 15:26, Ishan Bansal is...@seeta.in wrote:
 Hi

 I had made the patch for the Bug #305.

 http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026732.html

 Please review the patch and provide suggestions on any change required.

Looks good to me, but we have to wait until we branch 0.90 before we
can commit. Can you ask benzea in #sugar if he has time to give it a
look?

Regards,

Tomeu

 regards

 ishan

 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] implements http://bugs.sugarlabs.org/ticket/1106 - Browse: No preview in Journal for downloaded image

2010-09-24 Thread godiard
From: Gonzalo Odiard godi...@sugarlabs.org

generates a preview image with a fixed size and proportions.
if the original image is bigger scale down and center the image, if is smaller 
center the image
the supported format files are checked with pixbuf_get_formats

this patch adressed comments from silbe about segregate the check of a image 
mime type and use of sugar.style constant colors
now opens the image in the original size because we don't want scale up small 
images
---
 downloadmanager.py |   46 ++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/downloadmanager.py b/downloadmanager.py
index 3eec649..ed68d82 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -35,6 +35,7 @@ from sugar.datastore import datastore
 from sugar import profile
 from sugar import mime
 from sugar.graphics.alert import Alert, TimeoutAlert
+from sugar.graphics import style
 from sugar.graphics.icon import Icon
 from sugar.activity import activity
 
@@ -192,12 +193,57 @@ class Download:
 sniffed_mime_type = mime.get_for_file(self._target_file.path)
 self.dl_jobject.metadata['mime_type'] = sniffed_mime_type
 
+if self._check_image_mime_type():
+self.dl_jobject.metadata['preview'] = self._get_preview_image()
+
 datastore.write(self.dl_jobject,
 transfer_ownership=True,
 reply_handler=self._internal_save_cb,
 error_handler=self._internal_save_error_cb,
 timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
 
+
+def _check_image_mime_type(self):
+pixbuf_mime_types = []
+for pixbuf_format in gtk.gdk.pixbuf_get_formats():
+pixbuf_mime_types.extend(pixbuf_format['mime_types'])
+
+return self._mime_type in pixbuf_mime_types
+
+def _get_preview_image(self):
+preview_width, preview_height = style.zoom(300), style.zoom(225)
+
+pixbuf = gtk.gdk.pixbuf_new_from_file(self._target_file.path)
+width, height = pixbuf.get_width(), pixbuf.get_height()
+
+
+if (width  preview_width) or (height  preview_height):
+scale_x = float(width) / preview_width
+scale_y = float(height) / preview_height
+scale = max(scale_x,scale_y)
+
+pixbuf = pixbuf.scale_simple(float(width) / scale, height / scale,
+ gtk.gdk.INTERP_BILINEAR)
+
+width, height = pixbuf.get_width(), pixbuf.get_height()
+
+pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 
pixbuf.get_has_alpha(),
+pixbuf.get_bits_per_sample(), preview_width, preview_height)
+
+pixbuf2.fill(style.COLOR_WHITE.get_int())
+
+margin_x, margin_y = (preview_width - width) / 2, (preview_height - 
height) / 2
+
+pixbuf.copy_area(0, 0, width, height, pixbuf2, margin_x, margin_y)
+
+preview_data = []
+def save_func(buf, data):
+data.append(buf)
+
+pixbuf2.save_to_callback(save_func, 'png', user_data=preview_data)
+preview_data = ''.join(preview_data)
+return dbus.ByteArray(preview_data)
+
 def __start_response_cb(self, alert, response_id):
 global _active_downloads
 if response_id is gtk.RESPONSE_CANCEL:
-- 
1.7.2.3

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] bug #2170

2010-09-24 Thread Tomeu Vizoso
On Fri, Sep 24, 2010 at 15:28, Ishan Bansal is...@seeta.in wrote:
 Hi

 I had made the patch for the Bug #2170.

 http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026963.html

 Please review the patch and provide suggestions on any change required.

The patch has been reviewed already IIRC, but I'm not sure if
Sayamindu has time to keep maintaining Read. If not, we need to find a
new maintainer.

Regards,

Tomeu

 regards

 ishan

 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Walter Bender
On Fri, Sep 24, 2010 at 9:40 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Fri, Sep 24, 2010 at 15:25, Walter Bender walter.ben...@gmail.com wrote:
 On Fri, Sep 24, 2010 at 9:10 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Fri, Sep 24, 2010 at 14:41, Walter Bender walter.ben...@gmail.com 
 wrote:
 On Fri, Sep 24, 2010 at 4:02 AM, Tomeu Vizoso to...@sugarlabs.org wrote:
 On Thu, Sep 23, 2010 at 00:58, Alberto Arruda de Oliveira
 alberto.a.o...@gmail.com wrote:
 Hello,

 First of all, thanks for all the answers!

 I decided to follow your advices and implement the saving feature of my
 activity through the journal.

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but 
 when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save 
 the
 state of the activity?

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped. I suspect this is an emulator problem ( 
 because
 not only it happened with my activity, but also with other activities ), 
 but
 I'd like to be sure I'm not doing anything wrong!

 It could be that the Journal is reindexing. (For a large Journal, this
 sometimes has the appearance of an empty or nearly empty Journal.) If
 you wait for the indexing to complete, everything reappears as normal.

 But why would it be reindexing? Are people getting their journals
 reindexed from time to time?

 Not sure why, but in sugar-jhbuild, where I do most of my work, it
 seems to reindex fairly often (~1 out of every 30-40 sessions
 launched). one trigger *seems to be* changing the display size, e.g.,
 if I use 1200x900 sessions for a while and then switch to 800x600, it
 will often reindex. (Likely nothing causal there.)

 It could be very interesting to look at the logs of the session when
 reindexing starts and also of the session just before that.

I'll try to save them next time it happens.

-walter

 Regards,

 Tomeu

 -walter

 Regards,

 Tomeu

 -walter

 Haven't seen it happening myself. Can you tell us specific versions of
 Sugar and any tips for reproducing it?

 Thanks,

 Tomeu

 Thanks again,

 Alberto Arruda de Oliveira

 2010/9/20 Alberto Arruda de Oliveira alberto.a.o...@gmail.com

 Hello,

 I've been adapting an application to use as an activity, and I have some
 questions about the way to save on sugar.

 At first, I tried to just create a directory inside my Activity folder
 especially made for saving files, but it did not work, because of the 
 access
 permissions to it, and, although we could simply manually change the 
 folder
 permission for writing on that folder, we would have to do it for every
 single OLPC we installed our activity into and we didn't want that.

 Then, we started trying with the journal. Everything was going fine, 
 until
 we discovered that another sugar activity, Scratch, implemented saving 
 and
 loading on a similar fashion we previously wanted. It has a folder 
 inside
 it's Activity directory with subdirectories related to each kind of 
 Scratch
 project. Also, Scratch's Activity directory has the same access 
 permission
 as any other sugar Activity installed.

 So, my question is, does anyone knows how Scratch implements it's save /
 loading method? is there any guide explaining how to do it without 
 using the
 journal? Keep in mind that we do know that there are other directories 
 we
 could use to save our files, but we would like to use our Activity 
 directory
 if possible.

 Thanks in advance ( and sorry for any english mistakes :] ),

 Alberto Arruda de Oliveira


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel


 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel




 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org





 --
 Walter Bender
 Sugar Labs
 http://www.sugarlabs.org





-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] 0.90 Exception: Activities list view and Journal view crashes in Arabic

2010-09-24 Thread Simon Schampijer
On 09/24/2010 10:06 AM, Tomeu Vizoso wrote:
 On Wed, Sep 22, 2010 at 18:06, Simon Schampijersi...@schampijer.de  wrote:
 Hi,

 I am asking for an exception for [1] 0.90. Originally discovered on 0.84
 this is also present on 0.90. The patch [2] has been reviewed by Sascha
 and Tomeu already and it is low risk. Otherwise Arabic will be unusable
 as this effects the Journal and the Activities list view.

 I think there should be a big FIXME comment with a reference to a
 ticket in trac because it's a hack and because we really need to find
 an appropriate fix in the near future.

 Also, we don't have plurals in any other place?

 Regards,

 Tomeu

http://bugs.sugarlabs.org/attachment/ticket/2354/0001-If-the-string-does-not-contain-a-conversion-specifie.patch

The latest patch does add the comment.

I will check if there are other plurals at other places - none I am 
aware of for now.

Regards,
Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] 0.90 Exception: Activities list view and Journal view crashes in Arabic

2010-09-24 Thread Tomeu Vizoso
On Fri, Sep 24, 2010 at 16:10, Simon Schampijer si...@schampijer.de wrote:
 On 09/24/2010 10:06 AM, Tomeu Vizoso wrote:

 On Wed, Sep 22, 2010 at 18:06, Simon Schampijersi...@schampijer.de
  wrote:

 Hi,

 I am asking for an exception for [1] 0.90. Originally discovered on 0.84
 this is also present on 0.90. The patch [2] has been reviewed by Sascha
 and Tomeu already and it is low risk. Otherwise Arabic will be unusable
 as this effects the Journal and the Activities list view.

 I think there should be a big FIXME comment with a reference to a
 ticket in trac because it's a hack and because we really need to find
 an appropriate fix in the near future.

 Also, we don't have plurals in any other place?

 Regards,

 Tomeu

 http://bugs.sugarlabs.org/attachment/ticket/2354/0001-If-the-string-does-not-contain-a-conversion-specifie.patch

 The latest patch does add the comment.

Sorry, I was referring to a ticket about correctly translating strings
with plurals. If you want to use the same ticket, at least it should
be clear that it is about a proper solution and not just about the
crash. It also helps if it starts with FIXME.

 I will check if there are other plurals at other places - none I am aware of
 for now.

I have only found the activity updater.

Regards,

Tomeu

 Regards,
   Simon

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] implements http://bugs.sugarlabs.org/ticket/1106 - Browse: No preview in Journal for downloaded image

2010-09-24 Thread Gonzalo Odiard
ignore this patch.
I am doing anything wrong with git

Gonzalo

On Fri, Sep 24, 2010 at 10:44 AM, godi...@sugarlabs.org wrote:

 From: Gonzalo Odiard godi...@sugarlabs.org

 generates a preview image with a fixed size and proportions.
 if the original image is bigger scale down and center the image, if is
 smaller center the image
 the supported format files are checked with pixbuf_get_formats

 this patch adressed comments from silbe about segregate the check of a
 image mime type and use of sugar.style constant colors
 now opens the image in the original size because we don't want scale up
 small images
 ---
  downloadmanager.py |   46 ++
  1 files changed, 46 insertions(+), 0 deletions(-)

 diff --git a/downloadmanager.py b/downloadmanager.py
 index 3eec649..ed68d82 100644
 --- a/downloadmanager.py
 +++ b/downloadmanager.py
 @@ -35,6 +35,7 @@ from sugar.datastore import datastore
  from sugar import profile
  from sugar import mime
  from sugar.graphics.alert import Alert, TimeoutAlert
 +from sugar.graphics import style
  from sugar.graphics.icon import Icon
  from sugar.activity import activity

 @@ -192,12 +193,57 @@ class Download:
 sniffed_mime_type =
 mime.get_for_file(self._target_file.path)
 self.dl_jobject.metadata['mime_type'] = sniffed_mime_type

 +if self._check_image_mime_type():
 +self.dl_jobject.metadata['preview'] =
 self._get_preview_image()
 +
 datastore.write(self.dl_jobject,
 transfer_ownership=True,
 reply_handler=self._internal_save_cb,
 error_handler=self._internal_save_error_cb,
 timeout=360 *
 DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)

 +
 +def _check_image_mime_type(self):
 +pixbuf_mime_types = []
 +for pixbuf_format in gtk.gdk.pixbuf_get_formats():
 +pixbuf_mime_types.extend(pixbuf_format['mime_types'])
 +
 +return self._mime_type in pixbuf_mime_types
 +
 +def _get_preview_image(self):
 +preview_width, preview_height = style.zoom(300), style.zoom(225)
 +
 +pixbuf = gtk.gdk.pixbuf_new_from_file(self._target_file.path)
 +width, height = pixbuf.get_width(), pixbuf.get_height()
 +
 +
 +if (width  preview_width) or (height  preview_height):
 +scale_x = float(width) / preview_width
 +scale_y = float(height) / preview_height
 +scale = max(scale_x,scale_y)
 +
 +pixbuf = pixbuf.scale_simple(float(width) / scale, height /
 scale,
 + gtk.gdk.INTERP_BILINEAR)
 +
 +width, height = pixbuf.get_width(), pixbuf.get_height()
 +
 +pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
 pixbuf.get_has_alpha(),
 +pixbuf.get_bits_per_sample(), preview_width, preview_height)
 +
 +pixbuf2.fill(style.COLOR_WHITE.get_int())
 +
 +margin_x, margin_y = (preview_width - width) / 2, (preview_height
 - height) / 2
 +
 +pixbuf.copy_area(0, 0, width, height, pixbuf2, margin_x, margin_y)
 +
 +preview_data = []
 +def save_func(buf, data):
 +data.append(buf)
 +
 +pixbuf2.save_to_callback(save_func, 'png', user_data=preview_data)
 +preview_data = ''.join(preview_data)
 +return dbus.ByteArray(preview_data)
 +
 def __start_response_cb(self, alert, response_id):
 global _active_downloads
 if response_id is gtk.RESPONSE_CANCEL:
 --
 1.7.2.3




-- 
Gonzalo Odiard
SugarLabs Argentina
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Managing own patches on patchwork (was: Re: [PATCH] Announce file transfer capabilities #1603)

2010-09-24 Thread Tomeu Vizoso
On Tue, Sep 21, 2010 at 02:14, James Cameron qu...@laptop.org wrote:
 On Mon, Sep 20, 2010 at 10:57:49PM +0200, Sascha Silbe wrote:
 BTW, it would be nice if patch submitters would update the state of their
 own patches on patchwork [1], especially if they get superseded by newer
 patch versions or accepted into mainline.
 This is entirely optional, but helps reducing the load on maintainers.

 Neat.  Didn't know I could do that.

 Advice for others: get an account if you don't have one yet, log in,
 look in the patches list, identify those that are superceded, click on
 them, update the state and optionally click on archived, then update.

Just did it for the patches I submitted, if others could do the same
would be great.

Thanks,

Tomeu

 --
 James Cameron
 http://quozl.linux.org.au/
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Some questions concerning saving methods on sugar

2010-09-24 Thread Sascha Silbe
Excerpts from Alberto Arruda de Oliveira's message of Thu Sep 23 00:58:18 +0200 
2010:

 Although it's not working perfectly yet, I hope it will be soon. I'm just
 having a little problem with the keep button. My activity creates the
 journal entry like it should when I exit through the close button, but when
 I press the keep button, it doesn't create the entry. Is there any big
 differences in how the keep and close button access the journal to save the
 state of the activity?

It's hard to say anything definitive without looking at the code of your
activity. If you use the activity framework provided by sugar-toolkit
(especially the sugar.activity.activity.Activity class) and implement
both read_file() and write_file(), then Keep should work just fine. All
it does is to save the entry and cause a new object_id to be assigned on
next save (which will happen on Stop or switching away from the
activity).

 Also, related to the sugar-emulator, sometimes, when I close it, all the
 journal entries are wiped.

Uh, that's pretty bad. Are you sure the entries are gone, or will they
reappear when you restart Sugar (i.e. sugar-emulator)?

If the former, please file a bug [2] and create a tarball of ~/.sugar
the next time it happens:

tar -C $HOME -cjf sugar-datastore-cleared.tar.bz2 .sugar

If you used Sugar for anything else than testing your activity, you
can send me that tarball privately (it will contain a private key used
for collaboration and probably all of your Journal entries as well as
temporary / cached files from e.g. Browse).

Sascha

[1] 
http://git.sugarlabs.org/projects/sugar-toolkit/repos/mainline/blobs/master/src/sugar/activity/activity.py#line676
[2] 
https://bugs.sugarlabs.org/newticket?component=sugar-datastoreseverity=Critical
--
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Patch for SL Bug #630 : Journal Full Message has Issues

2010-09-24 Thread Mukul Gupta
Team,

This is with reference to SL Bug #630 : Journal Full Message has Issues. I
have prepared a patch for the same. Please review the patch and provide me
with your valuable suggestions.

http://lists.sugarlabs.org/archive/sugar-devel/2010-September/027168.html

Bug #630:Modal Dialog Fix and Journal Memory Full Alert added

Description:Modal Dialog should be displayed only once at startup if free
memory is less than 50MB but greater than 10MB. Instead, for every
redundant Modal Dialog Display, an Alert in the Journal signifying
Low Memory is displayed.But when free memory reaches a critical
limit(ie. 10MB) Modal Dialog is displayed repeatedly asking the
user to delete some data in the Journal along with an alert in the
Journal

Existing Situation:
Modal Dialog asking the user to delete some data from the journal is
displayed at startup if Free Memory is less than 50MB.Then, when reaching
the Journal, the dialog appears redundantly on top of the Journal itself. It
is displayed everytime after exiting an activity.

After applying the patch:
Dialog Box is displayed only once at startup if free memory is less than
50MB but greater than 10MB. Instead, for every
redundant Modal Dialog Display, an Alert in the Journal stating Low Memory
is displayed.But when free memory reaches a critical
limit(ie. 10MB) Modal Dialog Box is displayed repeatedly asking the user to
delete some data in the Journal along with an alert in the
Journal.

Regards,

Mukul Gupta
Research Engineer, SEETA
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Patch for SL Bug #630 : Journal Full Message has Issues

2010-09-24 Thread Mukul Gupta
Team,

I was reconsidering that if the critical limit of 10MB was too low and
whether it should be changed to around 35 MB. Please provide your
suggestions.

Regards,

Mukul Gupta
Research Engineer,SEETA

On Fri, Sep 24, 2010 at 10:37 PM, Mukul Gupta mu...@seeta.in wrote:

 Team,

 This is with reference to SL Bug #630 : Journal Full Message has Issues. I
 have prepared a patch for the same. Please review the patch and provide me
 with your valuable suggestions.

 http://lists.sugarlabs.org/archive/sugar-devel/2010-September/027168.html

 Bug #630:Modal Dialog Fix and Journal Memory Full Alert added

 Description:Modal Dialog should be displayed only once at startup if free
 memory is less than 50MB but greater than 10MB. Instead, for every
 redundant Modal Dialog Display, an Alert in the Journal signifying
 Low Memory is displayed.But when free memory reaches a critical
 limit(ie. 10MB) Modal Dialog is displayed repeatedly asking the
 user to delete some data in the Journal along with an alert in the
 Journal

 Existing Situation:
 Modal Dialog asking the user to delete some data from the journal is
 displayed at startup if Free Memory is less than 50MB.Then, when reaching
 the Journal, the dialog appears redundantly on top of the Journal itself. It
 is displayed everytime after exiting an activity.

 After applying the patch:
 Dialog Box is displayed only once at startup if free memory is less than
 50MB but greater than 10MB. Instead, for every
 redundant Modal Dialog Display, an Alert in the Journal stating Low Memory
 is displayed.But when free memory reaches a critical
 limit(ie. 10MB) Modal Dialog Box is displayed repeatedly asking the user to
 delete some data in the Journal along with an alert in the
 Journal.

 Regards,

 Mukul Gupta
 Research Engineer, SEETA
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Unintentional data store reindexing on sugar-emulator restart (was: Re: Some questions concerning saving methods on sugar)

2010-09-24 Thread Sascha Silbe
Excerpts from Tomeu Vizoso's message of Fri Sep 24 15:10:07 +0200 2010:

  It could be that the Journal is reindexing. (For a large Journal, this
  sometimes has the appearance of an empty or nearly empty Journal.) If
  you wait for the indexing to complete, everything reappears as normal.
 
 But why would it be reindexing? Are people getting their journals
 reindexed from time to time?

This happened to me a few times during the last few days, each time
after I restarted Sugar rather quickly. There's an exception in the log:

1285265788.580216 DEBUG root: max_versions=0
1285265788.604839 ERROR root: Failed to open index, will rebuild
Traceback (most recent call last):
  File 
/home/sascha.silbe/sugar-jhbuild/install/lib/python2.6/site-packages/carquinyol/datastore.py,
 line 275, in __init__
self._index_store.open_index()
  File 
/home/sascha.silbe/sugar-jhbuild/install/lib/python2.6/site-packages/carquinyol/indexstore.py,
 line 246, in open_index
self._database = WritableDatabase(index_path, xapian.DB_CREATE_OR_OPEN)
  File /usr/lib/python2.6/dist-packages/xapian/__init__.py, line 4059, in 
__init__
_xapian.WritableDatabase_swiginit(self,_xapian.new_WritableDatabase(*args))
DatabaseLockError: Unable to get write lock on 
/home/sascha.silbe/.sugar/default/datastore/index: already locked
1285265789.971570 DEBUG root: Going to update the index with object_ids 
[('15947ca6-a018-47d0-9c09-f58c12e6cf82'
[...]


My guess is that the old sugar-datastore instance still has the index
open. We don't have API for stopping sugar-datastore and instead rely
on dbus-daemon to stop it when it gets stopped itself. I've noticed that
when using --exit-with-session dbus-launch and dbus-daemon often continue
to run for several seconds after a session has ended and returned.

So this is just another way to trigger SL#1257 [1].

It might be even easier to trigger if you're running sugar-emulator from
a GUI menu on a slow system as the user assumes it to be finished as
soon as the Xephyr window is closed, not when sugar-emulator (the
script) stops.

Sascha

[1] https://bugs.sugarlabs.org/ticket/1257
--
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Bug 2318

2010-09-24 Thread Dipankar Patro
Hi all,

I am working on the bug : http://bugs.sugarlabs.org/ticket/2318

I tried changing the class JournalButton in jarabe/journal/volumestoolbar.py
as follows
http://paste.ubuntu.com/499852/
It seems that the volume info still does not appear.

I think it is somewhat related to right click key handler, because in other
places (frame, home view) the volume info appears as a right click popup.

Would be great if you some could provide some pointers on the views above.

Regards,
Dipankar
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] implements http://bugs.sugarlabs.org/ticket/1106 - Browse: No preview in Journal for downloaded image

2010-09-24 Thread godiard
From: Gonzalo Odiard godi...@sugarlabs.org

generates a preview image with a fixed size and proportions.
if the original image is bigger scale down and center the image, if is smaller 
center the image
the supported format files are checked with pixbuf_get_formats
---
 downloadmanager.py |   45 +
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/downloadmanager.py b/downloadmanager.py
index 3eec649..f4bb2a5 100644
--- a/downloadmanager.py
+++ b/downloadmanager.py
@@ -35,6 +35,7 @@ from sugar.datastore import datastore
 from sugar import profile
 from sugar import mime
 from sugar.graphics.alert import Alert, TimeoutAlert
+from sugar.graphics import style
 from sugar.graphics.icon import Icon
 from sugar.activity import activity
 
@@ -192,12 +193,56 @@ class Download:
 sniffed_mime_type = mime.get_for_file(self._target_file.path)
 self.dl_jobject.metadata['mime_type'] = sniffed_mime_type
 
+if self._check_image_mime_type():
+self.dl_jobject.metadata['preview'] = self._get_preview_image()
+
 datastore.write(self.dl_jobject,
 transfer_ownership=True,
 reply_handler=self._internal_save_cb,
 error_handler=self._internal_save_error_cb,
 timeout=360 * DBUS_PYTHON_TIMEOUT_UNITS_PER_SECOND)
 
+def _check_image_mime_type(self):
+for pixbuf_format in gtk.gdk.pixbuf_get_formats():
+if self._mime_type in pixbuf_format['mime_types']:
+return True
+return False
+
+def _get_preview_image(self):
+preview_width, preview_height = style.zoom(300), style.zoom(225)
+
+pixbuf = gtk.gdk.pixbuf_new_from_file(self._target_file.path)
+width, height = pixbuf.get_width(), pixbuf.get_height()
+
+scale = 1
+if (width  preview_width) or (height  preview_height):
+scale_x = preview_width / float(width)
+scale_y = preview_height / float(height)
+scale = min(scale_x, scale_y)
+
+pixbuf2 = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, \
+pixbuf.get_has_alpha(), \
+pixbuf.get_bits_per_sample(), \
+preview_width, preview_height)
+pixbuf2.fill(style.COLOR_WHITE.get_int())
+
+margin_x = int((preview_width - (width * scale)) / 2)
+margin_y = int((preview_height - (height * scale)) / 2)
+
+pixbuf.scale(pixbuf2, margin_x, margin_y, \
+preview_width - (margin_x * 2), \
+preview_height - (margin_y * 2), \
+margin_x, margin_y, scale, scale, \
+gtk.gdk.INTERP_BILINEAR)
+
+preview_data = []
+def save_func(buf, data):
+data.append(buf)
+
+pixbuf2.save_to_callback(save_func, 'png', user_data=preview_data)
+preview_data = ''.join(preview_data)
+return dbus.ByteArray(preview_data)
+
 def __start_response_cb(self, alert, response_id):
 global _active_downloads
 if response_id is gtk.RESPONSE_CANCEL:
-- 
1.7.2.3

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] (no subject)

2010-09-24 Thread Anurag Chowdhury
Shutdown (and Logout) menu items should activate the buzzy cursor (or provide 
some other visual feedback, perhaps dimming/locking the UI from use).

changelog: 
http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026741.html
http://lists.sugarlabs.org/archive/sugar-devel/2010-September/026981.html
---
 src/jarabe/view/buddymenu.py |   42 ++
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/src/jarabe/view/buddymenu.py b/src/jarabe/view/buddymenu.py
index 0ba6cc1..7135d9e 100644
--- a/src/jarabe/view/buddymenu.py
+++ b/src/jarabe/view/buddymenu.py
@@ -21,6 +21,8 @@ from gettext import gettext as _
 import gtk
 import gconf
 import dbus
+import jarabe
+import glib
 
 from sugar.graphics.palette import Palette
 from sugar.graphics.menuitem import MenuItem
@@ -98,16 +100,40 @@ class BuddyMenu(Palette):
 item.show()
 
 def __logout_activate_cb(self, menu_item):
-session_manager = get_session_manager()
-session_manager.logout()
+def update_cur(window):
+window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+return False 
+def shut(self, menu_item):
+session_manager = get_session_manager()
+session_manager.logout()
+window = jarabe.desktop.homewindow.get_instance()
+glib.timeout_add(3, update_cur, window)  
+glib.idle_add(shut,self,menu_item)
+gtk.main()
 
 def __reboot_activate_cb(self, menu_item):
-session_manager = get_session_manager()
-session_manager.reboot()
-
-def __shutdown_activate_cb(self, menu_item):
-session_manager = get_session_manager()
-session_manager.shutdown()
+def update_cur(window):
+window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+return False 
+def shut(self, menu_item):
+session_manager = get_session_manager()
+session_manager.reboot()
+window = jarabe.desktop.homewindow.get_instance()
+glib.timeout_add(3, update_cur, window)  
+glib.idle_add(shut,self,menu_item)
+gtk.main()
+
+def __shutdown_activate_cb(self, menu_item):
+def update_cur(window):
+window.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+return False 
+def shut(self, menu_item):
+session_manager = get_session_manager()
+session_manager.shutdown()
+window = jarabe.desktop.homewindow.get_instance()
+glib.timeout_add(3, update_cur, window)  
+glib.idle_add(shut,self,menu_item)
+gtk.main()
 
 def __controlpanel_activate_cb(self, menu_item):
 panel = ControlPanel()
-- 
1.7.2.2

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Priorities for testing

2010-09-24 Thread Tim McNamara
The New Zealand testing groups will be operating in a few hours. If you have
any requests for things to be explored, please respond within 5 hours.

Thank you

Tim
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] Priorities for testing

2010-09-24 Thread Walter Bender
On Fri, Sep 24, 2010 at 4:37 PM, Tim McNamara
paperl...@timmcnamara.co.nz wrote:
 The New Zealand testing groups will be operating in a few hours. If you have
 any requests for things to be explored, please respond within 5 hours.

I have a new (soon to be released) version of Turtle Art I'd love for
them to testL

http://bugs.sugarlabs.org/attachment/ticket/2353/TurtleArt-99.xo

features/enhancements include:
* reskinable turtle (#2353)
* setxy honors pen up/pen down (#2358)
* updated Tamil, Spanish (#2359), and German translations
* expandable two-argument blocks (#2330, #2336)
* updated samples to take advantage of #2330 and removed extra turtles
* removed import numpy to fix #2313 and #2314

-walter


 Thank you

 Tim
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel





-- 
Walter Bender
Sugar Labs
http://www.sugarlabs.org
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] Read Activity on Fedora 14 / SoaS v4

2010-09-24 Thread Peter Robinson
Hi All,

With this update below I've now fixed Read on Fedora 14.

https://admin.fedoraproject.org/updates/gnome-python2-desktop-2.31.1-7.fc14

I've only given it a cursory test so if others could please do so and
add Karma (remember you need to be logged into bodhi for your karma to
actually have a + effect) so we can get this into the nightly builds.

Cheers,
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel