[Sugar-devel] help about the get_preview function of activity.Activity class to take screenshots
tomeu at sugarlabs.org
Wed Jul 22 04:35:32 EDT 2009
On Tue, Jul 21, 2009 at 15:51, sumit singh<sumit.coder at gmail.com> wrote:
> Hi Tomeu,
> Thanx a lot for the function. I would be using it as of now while creating
> the infrastructure for the activity, would try to provide support to both
> the new as well as the previous builds. I would be testing the function on
> my 0.82 build soon.
> Moreover, I am also planning to move to 0.84 Soas build , but as I am not
> having access to a wifi-system and it needs atleast a day to get the
> developer key, so it would take some time to setup the environment on my xo,
> till then would be using this function. Moving on to the sugar 0.84 would
> keep us in a better sync with the latest release of write-63 and further
> development of the activity.
Testing on both 0.82 and 0.84 makes sense, hopefully the differences
aren't too big.
Note that you can run SoaS on any computer, don't really need to block
on getting a developer key for the XO.
>> You are asking good questions ;)
>> In Sugar < 0.84, the only way to get a screenshot of activities was
>> asking the X server for the current contents of the screen. This was
>> pretty slow and also required that the activity was covering the whole
>> screen during that operation (so the user couldn't invoke the frame,
>> nor switch activities, etc.).
>> In Sugar 0.84, we upgraded to a newer version of gtk+ that adds API
>> for redrawing a window in a pixbuf. This is faster and can be done at
>> any moment. But the abiword shipped with 0.84 did things a bit
>> differently so that gtk+ API didn't worked properly, then Martin
>> Sevior kindly implemented an additional function that did the job in
>> the meantime.
>> This is the slow method for retrieving previews as was implemented in
>> the s.g.w.Window class:
>> def get_canvas_screenshot(self):
>> if not self.canvas:
>> return None
>> window = self.canvas.window
>> width, height = window.get_size()
>> screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,
>> has_alpha=False, bits_per_sample=8, width=width, height=height)
>> screenshot.get_from_drawable(window, window.get_colormap(), 0, 0,
>> 0, 0, width, height)
>> return screenshot
More information about the Devel