creating seperate dbus-tubes in a single instance of a shared actvity

2009-08-20 Thread sumit singh
Hi all,


As far as I can understand from the reading is that when we share an
activity, a new channel is created for that activity and in this
channel a new dbus-tube is created, through which the data transfer
can take place between the xos/laptops.

Now, what I want to ask is that is there any way to create more than
one tube in that channel so that something like parallel data transfer
can take place between the activities?
Also, in case there is a way to do so , then how can we distinguish
between these tubes?

Kindly give your suggestions. Also, kindly let me know if I am wrong
somewhere in my understanding of the concepts.

Kind regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: [Sugar-devel] activity not getting installed with sugar-install-bundle

2009-08-08 Thread sumit singh
Hi Tomeu,

Thanx a lot for your reply and for all the support you have given
throughout the development.



 Hi, you need to run that command from the terminal activity.

Yes, I was using Terminal activity only to do it. Anyways, the problem
has been solved now, the activity can now be installed using the
sugar-install-bundle command.

Regards,
VIJIT

 Regards,

 Tomeu

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


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


activity not getting installed with sugar-install-bundle

2009-08-07 Thread sumit singh
Hello all,

The xo bundle of my activity is not gettting installed on the xo using
the sugar-install-bundle command, however, when i unzip the xo bundle
in the /home/olpc/Activities folder , it is gettng installed
correctly. The error I am getting while using the sugar-install-bundle
command is ---

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did
not receive a reply. Possible causes include : the remote application
did not send a reply, the message bus security policy blockec the
reply, the reply timeout expired, or the network connection was
broken.

What can be the probable solution? Kindly give your suggestions.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: Getting a gtk.image from the get_preview function

2009-08-06 Thread sumit singh
Hi Tomeu,

Thanx for your reply. I tried this as well, but doesn't seems to work.
Here is my code--   http://pastebin.be/20215  , where get_preview2()
is similar to get_preview fn and it returns in a similar manner. This
is the get preview2 fn--- http://pastebin.be/20216
. The log error can be found at --- http://pastebin.be/20214 . Kindly
give your suggestions.

Regards,
VIJIT

On Thu, Aug 6, 2009 at 1:15 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 13:05, sumit singhsumit.co...@gmail.com wrote:
 Hi Tomeu,

 Thanx for your reply. I tried using the it , but it doesn't seem to
 work, it gives an error that the image should be a gdkpixbuf or None.
 Here is my code-  http://pastebin.be/20184  , isn't it so that while
 creating the pixmap on line no15, we are just using the height and
 width of the surface and not the surface anywhere. I mean how are we
 transferring the data of the image to the pixmap.
 Thinking this I also tried this approach but didn't worked
 http://pastebin.be/20185 .

 Kindly have a look as in where am I doing the mistake.

 Have written some code based on my earlier pointers, but haven't tested it:

 # wrap the png data in a virtual file
 import StringIO.StringIO
 png_file = StringIO.StringIO(preview_data)

 # create a cairo surface with the png data
 surface = cairo.ImageSurface.create_from_png(png_file)

 # create a pixmap with the same dimensions
 w, h = surface.get_width(), surface.get_height()
 pixmap = gtk.gdk.Pixmap (None, w, h, 24)

 # create a cairo graphics context dor drawing into the pixmap
 cr = pixmap.cairo_create ()

 # paint the surface to the graphics context
 cr.set_source_surface (surface, 0, 0)
 cr.paint ()

 # create an image widget and assign the pixmap to it
 im = gtk.Image()
 im.set_from_pixmap(pixmap, None)

 You may want to read a bit about pixmaps, pixbufs, etc. Both in the
 PyGtk and X11 documentation:

 http://www.pygtk.org/pygtktutorial/sec-pixmaps.html
 http://www.pygtk.org/docs/pygtk/class-gdkpixmap.html
 http://tronche.com/gui/x/xlib/pixmap-and-cursor/pixmap.html

 HTH,

 Tomeu

 Regards,
 sumit

 On Wed, Aug 5, 2009 at 12:33 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 03:06, sumit singhsumit.co...@gmail.com wrote:
 Hi all,

 I would like to ask what is the best way to get a gtk.Image from the
 data returned by get_preview function of activity.Activity fn of
 sugar. I want to make an image buttton using this data. Currently, I
 am doing it by saving the data in a temp file using the tempfile
 module of sugar and then by loading the image from this file, however,
 as I will be req to load around 15-20 such images, I can't say how
 fast the process will end into. Is there a faster method?

 For your reference , here is the code of how the journal activity uses
 this data http://pastebin.be/20177 , but as I don't want to use
 hippo canvas, so this method won't work. Kindly give your suggestions.

 Sorry, didn't remembered that the journal used hippo to display the
 previews when I recommended you to look at that.

 If you get a cairo surface like the journal does, you can draw it to a
 pixmap and then tell a gtk.Image to display it. More details in this
 post (disregard the pixbuf stuff):

 http://lethalman.blogspot.com/2009/04/create-pixbuf-from-cairo-surface.html

 HTH,

 Tomeu

 Regards,
 sumit




___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: Getting a gtk.image from the get_preview function

2009-08-06 Thread sumit singh
Tomeu,

Moreover, is it possible to use a hippocanvas surface as a button
image or something like a button or a normal image even, I mean can I
pack a hippocanvas in a vbox or hbox? Sorry, for asking such a basic
question but I don't have any idea about hippocanvas.

Regards,
sumit

On Thu, Aug 6, 2009 at 8:28 PM, sumit singhsumit.co...@gmail.com wrote:
 Hi Tomeu,

 Thanx for your reply. I tried this as well, but doesn't seems to work.
 Here is my code--   http://pastebin.be/20215  , where get_preview2()
 is similar to get_preview fn and it returns in a similar manner. This
 is the get preview2 fn--- http://pastebin.be/20216
 . The log error can be found at --- http://pastebin.be/20214 . Kindly
 give your suggestions.

 Regards,


 On Thu, Aug 6, 2009 at 1:15 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 13:05, sumit singhsumit.co...@gmail.com wrote:
 Hi Tomeu,

 Thanx for your reply. I tried using the it , but it doesn't seem to
 work, it gives an error that the image should be a gdkpixbuf or None.
 Here is my code-  http://pastebin.be/20184  , isn't it so that while
 creating the pixmap on line no15, we are just using the height and
 width of the surface and not the surface anywhere. I mean how are we
 transferring the data of the image to the pixmap.
 Thinking this I also tried this approach but didn't worked
 http://pastebin.be/20185 .

 Kindly have a look as in where am I doing the mistake.

 Have written some code based on my earlier pointers, but haven't tested it:

 # wrap the png data in a virtual file
 import StringIO.StringIO
 png_file = StringIO.StringIO(preview_data)

 # create a cairo surface with the png data
 surface = cairo.ImageSurface.create_from_png(png_file)

 # create a pixmap with the same dimensions
 w, h = surface.get_width(), surface.get_height()
 pixmap = gtk.gdk.Pixmap (None, w, h, 24)

 # create a cairo graphics context dor drawing into the pixmap
 cr = pixmap.cairo_create ()

 # paint the surface to the graphics context
 cr.set_source_surface (surface, 0, 0)
 cr.paint ()

 # create an image widget and assign the pixmap to it
 im = gtk.Image()
 im.set_from_pixmap(pixmap, None)

 You may want to read a bit about pixmaps, pixbufs, etc. Both in the
 PyGtk and X11 documentation:

 http://www.pygtk.org/pygtktutorial/sec-pixmaps.html
 http://www.pygtk.org/docs/pygtk/class-gdkpixmap.html
 http://tronche.com/gui/x/xlib/pixmap-and-cursor/pixmap.html

 HTH,

 Tomeu

 Regards,
 sumit

 On Wed, Aug 5, 2009 at 12:33 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 03:06, sumit singhsumit.co...@gmail.com wrote:
 Hi all,

 I would like to ask what is the best way to get a gtk.Image from the
 data returned by get_preview function of activity.Activity fn of
 sugar. I want to make an image buttton using this data. Currently, I
 am doing it by saving the data in a temp file using the tempfile
 module of sugar and then by loading the image from this file, however,
 as I will be req to load around 15-20 such images, I can't say how
 fast the process will end into. Is there a faster method?

 For your reference , here is the code of how the journal activity uses
 this data http://pastebin.be/20177 , but as I don't want to use
 hippo canvas, so this method won't work. Kindly give your suggestions.

 Sorry, didn't remembered that the journal used hippo to display the
 previews when I recommended you to look at that.

 If you get a cairo surface like the journal does, you can draw it to a
 pixmap and then tell a gtk.Image to display it. More details in this
 post (disregard the pixbuf stuff):

 http://lethalman.blogspot.com/2009/04/create-pixbuf-from-cairo-surface.html

 HTH,

 Tomeu

 Regards,
 sumit





___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: Getting a gtk.image from the get_preview function

2009-08-06 Thread sumit singh
I tried it using the self.canvas.window and the self.window both of
them , but they still give the same error.

On a separate note, would it be a good idea to use the hippoImage
itself as the image of the button, I mean wrapping it into a hippobox
and then using that box as the image of the button?

Actually we had planned to start the deployment/testing of the project
from tomorrow, everything else is almost in sync with tomorrow's
deadline except this problem, so may be I should use this concept to
solve the immediate purpose, and would try and find a better soln
after meeting tomorrow's deadline as we will proceed further with the
project. Kindly give your suggestions.

Regards,
sumit

On Thu, Aug 6, 2009 at 9:17 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Thu, Aug 6, 2009 at 16:58, sumit singhsumit.co...@gmail.com wrote:
 Hi Tomeu,

 Thanx for your reply. I tried this as well, but doesn't seems to work.
 Here is my code--   http://pastebin.be/20215  , where get_preview2()
 is similar to get_preview fn and it returns in a similar manner. This
 is the get preview2 fn--- http://pastebin.be/20216
 . The log error can be found at --- http://pastebin.be/20214 . Kindly
 give your suggestions.

 The problem seems to be the None value passed to gtk.gdk.Pixmap(), try
 passing a gdk.Window to it, probably the one of the current widget:
 self.window.

 Regards,

 Tomeu

 Regards,
 VIJIT

 On Thu, Aug 6, 2009 at 1:15 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 13:05, sumit singhsumit.co...@gmail.com wrote:
 Hi Tomeu,

 Thanx for your reply. I tried using the it , but it doesn't seem to
 work, it gives an error that the image should be a gdkpixbuf or None.
 Here is my code-  http://pastebin.be/20184  , isn't it so that while
 creating the pixmap on line no15, we are just using the height and
 width of the surface and not the surface anywhere. I mean how are we
 transferring the data of the image to the pixmap.
 Thinking this I also tried this approach but didn't worked
 http://pastebin.be/20185 .

 Kindly have a look as in where am I doing the mistake.

 Have written some code based on my earlier pointers, but haven't tested it:

 # wrap the png data in a virtual file
 import StringIO.StringIO
 png_file = StringIO.StringIO(preview_data)

 # create a cairo surface with the png data
 surface = cairo.ImageSurface.create_from_png(png_file)

 # create a pixmap with the same dimensions
 w, h = surface.get_width(), surface.get_height()
 pixmap = gtk.gdk.Pixmap (None, w, h, 24)

 # create a cairo graphics context dor drawing into the pixmap
 cr = pixmap.cairo_create ()

 # paint the surface to the graphics context
 cr.set_source_surface (surface, 0, 0)
 cr.paint ()

 # create an image widget and assign the pixmap to it
 im = gtk.Image()
 im.set_from_pixmap(pixmap, None)

 You may want to read a bit about pixmaps, pixbufs, etc. Both in the
 PyGtk and X11 documentation:

 http://www.pygtk.org/pygtktutorial/sec-pixmaps.html
 http://www.pygtk.org/docs/pygtk/class-gdkpixmap.html
 http://tronche.com/gui/x/xlib/pixmap-and-cursor/pixmap.html

 HTH,

 Tomeu

 Regards,
 sumit

 On Wed, Aug 5, 2009 at 12:33 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 03:06, sumit singhsumit.co...@gmail.com wrote:
 Hi all,

 I would like to ask what is the best way to get a gtk.Image from the
 data returned by get_preview function of activity.Activity fn of
 sugar. I want to make an image buttton using this data. Currently, I
 am doing it by saving the data in a temp file using the tempfile
 module of sugar and then by loading the image from this file, however,
 as I will be req to load around 15-20 such images, I can't say how
 fast the process will end into. Is there a faster method?

 For your reference , here is the code of how the journal activity uses
 this data http://pastebin.be/20177 , but as I don't want to use
 hippo canvas, so this method won't work. Kindly give your suggestions.

 Sorry, didn't remembered that the journal used hippo to display the
 previews when I recommended you to look at that.

 If you get a cairo surface like the journal does, you can draw it to a
 pixmap and then tell a gtk.Image to display it. More details in this
 post (disregard the pixbuf stuff):

 http://lethalman.blogspot.com/2009/04/create-pixbuf-from-cairo-surface.html

 HTH,

 Tomeu

 Regards,
 sumit






___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: Getting a gtk.image from the get_preview function

2009-08-05 Thread sumit singh
Hi Tomeu,

Thanx for your reply. I tried using the it , but it doesn't seem to
work, it gives an error that the image should be a gdkpixbuf or None.
Here is my code-  http://pastebin.be/20184  , isn't it so that while
creating the pixmap on line no15, we are just using the height and
width of the surface and not the surface anywhere. I mean how are we
transferring the data of the image to the pixmap.
Thinking this I also tried this approach but didn't worked
http://pastebin.be/20185 .

Kindly have a look as in where am I doing the mistake.

Regards,
sumit

On Wed, Aug 5, 2009 at 12:33 PM, Tomeu Vizosoto...@sugarlabs.org wrote:
 On Wed, Aug 5, 2009 at 03:06, sumit singhsumit.co...@gmail.com wrote:
 Hi all,

 I would like to ask what is the best way to get a gtk.Image from the
 data returned by get_preview function of activity.Activity fn of
 sugar. I want to make an image buttton using this data. Currently, I
 am doing it by saving the data in a temp file using the tempfile
 module of sugar and then by loading the image from this file, however,
 as I will be req to load around 15-20 such images, I can't say how
 fast the process will end into. Is there a faster method?

 For your reference , here is the code of how the journal activity uses
 this data http://pastebin.be/20177 , but as I don't want to use
 hippo canvas, so this method won't work. Kindly give your suggestions.

 Sorry, didn't remembered that the journal used hippo to display the
 previews when I recommended you to look at that.

 If you get a cairo surface like the journal does, you can draw it to a
 pixmap and then tell a gtk.Image to display it. More details in this
 post (disregard the pixbuf stuff):

 http://lethalman.blogspot.com/2009/04/create-pixbuf-from-cairo-surface.html

 HTH,

 Tomeu

 Regards,
 sumit


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Can I use the keep or title_set_by_user key of metadata to store info about my activity

2009-08-04 Thread sumit singh
Hi Tomeu,

This is in continuation with our chat yesterday. The write/report
activity would be having 3 states , I mean whether the user is working
on a blank document , designing a new template or using a previously
designed template. So, what I wanted was to save this state as well
while saving the activity using the write_file method, so that when I
resume my activity from the journal , i should switch over directly to
that state where the user closed the activity.

The only idea I was getting to achieve that was to save the state as a
number in the metadata file and then retrieving it from read_file fn ,
 however as I cannot add new keys in 0.82 version as they are lost
over restarts of xo, so I was planning to use the keep or the
title_set_by_user key of the metadata as I didn't find them getting
used anywhere. However, I am not sure whether these are used for some
important work internally by sugar. What do you think would it be safe
to use any of these 2 key values. Is there any other way to achieve
this other than this on 0.82.

I think I can use the hasattr fn to distinguish b/w 0.82 and 0.84 and
do so only if it is a 0.82 version while adding a new key instead in
0.84 version. Kindly give your suggestions.



Regards,
sumit.
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Getting a gtk.image from the get_preview function

2009-08-04 Thread sumit singh
Hi all,

I would like to ask what is the best way to get a gtk.Image from the
data returned by get_preview function of activity.Activity fn of
sugar. I want to make an image buttton using this data. Currently, I
am doing it by saving the data in a temp file using the tempfile
module of sugar and then by loading the image from this file, however,
as I will be req to load around 15-20 such images, I can't say how
fast the process will end into. Is there a faster method?

For your reference , here is the code of how the journal activity uses
this data http://pastebin.be/20177 , but as I don't want to use
hippo canvas, so this method won't work. Kindly give your suggestions.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Is using the datastore.find() function reliable and safe?

2009-08-02 Thread sumit singh
Hello all,

I want to save files from my activity so that I can retrieve them from
 the future instances of my activity and also want them to be visible
in the journal. So, I am planning to save them in the datastore. And
is planning to retrieve them using the datastore.find() function in
the future instances of my activity. However, the following link
mentions -- 
http://wiki.sugarlabs.org/go/Development_Team/Almanac/sugar.datastore.datastore
that using the function is not very reliable except with the
activity_id key.

As, I want to access all such files with a special property which I
saved from the previous versions of the activity, I can't just rely on
the activity_id thing. So, what can be a good solution for it. Would
using the find function be fine. Kindly give your suggestions. Just
repeating my requirements-

1. The files should be visible in the journal.
2. They should be accessible from within the future instances of the activity.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Need Help: usb drive not visible in the journal

2009-08-01 Thread sumit singh
Hi all,

I am facing a sort of weird problem at this point. On my xo, my usb
drives are not visible in the journal. I mean the icons at the bottom
of the journal are not visible. However, to my surprise my usb
drives(pendrives) are mounted and I can access them from the terminal.
I have tested it with 3 pen drives so I don't think its due to my pen
drive. Moreover, these pen drives are not even visible in the
objectChooser widget when I invoke it through any of the xo activities
like write or paint.

Can anybody please suggest me a solution. Moreover, is there any way
to access the data in the journal through the terminal, I mean there
are many activities which saves data into the journal and I am in
severe need to access that data. Is there any way to do so. I got this
link-  
http://wiki.laptop.org/go/Copy_to_and_from_the_Journal#Copy_from_Journal_script
, but I think the names of files are hashed and I won't be able to
recognize my file in this case.

Kindly give your suggestions.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: [Sugar-devel] Need Help: usb drive not visible in the journal

2009-08-01 Thread sumit singh
Hello sir,

Thank You for your reply.

On Sat, Aug 1, 2009 at 5:44 PM, Walter Benderwalter.ben...@gmail.com wrote:
 What version of Sugar are you running?

I am on sugar 0.82 ( 767 build). It was working fine since the last
4-5 months but the problem started suddenly yesterday.

 re copy-from-journal, if you use the -q flag, it will search on the
 title and description fields.

 copy-from-journal -q 'title of some journal object' filename

 with copy-to-journal, it is it important to use a -m flag

 copy to journal foo.png -m image/png

Yes, this should be of gr8 help. Would soon be trying it on the xo.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


problem connecting to irc

2009-07-31 Thread sumit singh
Hi all,

I am trying to connect to the sugar irc but getting this error- Your
reported hostname is banned: You have a host listed in the DroneBL.
For more information, visit dronebl.org/lookup_branded.do?

Any ideas about how can this be dealt with?

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: [Sugar-devel] problem connecting to irc

2009-07-31 Thread sumit singh
Hi James,

Thanx a lot James for your reply. I don't know why the problem
occurred, but finally after a few hours I can now access the sugar
irc. Maybe its due to the blessings of all the sugar mailing list
users, lolz ... :)

Regards,
sumit.

On Fri, Jul 31, 2009 at 5:20 PM, James Cameronqu...@laptop.org wrote:
 On Fri, Jul 31, 2009 at 04:46:38PM +0530, sumit singh wrote:
 I am trying to connect to the sugar irc but getting this error- Your
 reported hostname is banned: You have a host listed in the DroneBL.
 For more information, visit dronebl.org/lookup_branded.do?

 Any ideas about how can this be dealt with?

 It has nothing to do with Sugar.  The channel is hosted on a free
 service, FreeNode, which has some conditions of use, and these restrict
 where connections can be made from.

 You will need to resolve the issue causing you to be listed in dronebl
 before you can connect to freenode.

 You should determine why your IP address is listed.

 If you are purchasing IP service from a company, you could ask them for
 advice, but the situation is usually caused by someone else who used
 your IP before you doing something particularly evil.

 --
 James Cameron
 http://quozl.linux.org.au/

___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: [Sugar-devel] help about the get_preview function of activity.Activity class to take screenshots

2009-07-21 Thread sumit singh
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.

Regards,
sumit.







 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

 Regards,

 Tomeu



___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


help about the get_preview function of activity.Activity class to take screenshots

2009-07-20 Thread sumit singh
Hi everyone,

Can anyone please guide me about the proper use of the get_preview function
of the activity.Activity class of sugar. I had a look at its api, it seems
to be returning a dictionary sort of thing which is called as the png image.
What I want to do is to save this image somewhere in the datastore and show
this image later to the user in my activity. So, what I want to ask is to
how to load this information in the form of an image later on
programatically. Can we load it using the gtk.image widget and what is the
right procedure to save this information.

Regards,
sumit
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: [Sugar-devel] help about the get_preview function of activity.Activity class to take screenshots

2009-07-20 Thread sumit singh
Martin and Tomeu,

Martin, thanx a lot for such a detailed answer. I have got what you want to
say. But the problem with me right now is that I think the get_preview
function is available only in the latest release of sugar 0.84 because I am
on 0.82, and my xo gives an error --  Activity module does not have an
attribute get_preview . Is it so that the function has been added after
0.82 ? If yes, then is there any way on 0.82 build to take screenshots
programatically.

There is one strange thing which I am encountering right now. Though the log
gives an error that get_preview function is not present but when I ran write
63.xo on the machine ( after replacing sugar.graphics.colorbutton with
gtk.colorButton  in toolbar.py ) , closed it and then again tried to restart
the activity from the journal , I was able to see the following preview
which I am attaching with this mail, that was what was there on my activity
screen before I closed it.

Though I am not very much sure, but this should have happened because of the
save function in activity.Activity class , here is the link-
http://api.sugarlabs.org/sugar.activity.activity-pysrc.html , which calls
the get_preview function of sugar, which is a bit contradictory, if we
consider the result of the logs. Am I wrong in the way I am understanding
this? Kindly give your comments.

Regards,
sumit.






On Mon, Jul 20, 2009 at 6:58 PM, Martin Sevior msev...@gmail.com wrote:

 Hi Sumit,

 I just fixed the example code in the pyabiword module of abiword to
 give an example
 of how this works.

 The important line in this example is:

  i.props.pixbuf = abi.render_page_to_image(1)

 The converts page number 1 to a GdkPixbuf. Once you have a GdkPixbuf,
 in this case in
 a Gtk.Image you can convert it to whatever format you wish.

 From the PyGtk reference manual http://www.pygtk.org/docs/pygtk/
  you convert  this to an image with:

 http://www.pygtk.org/docs/pygtk/class-gdkpixbuf.html#method-gdkpixbuf--save

 So if you wanted the GdkPixbuf directly you would do:

 PagePixbuf = abi.render_page_to_image(1)
 PagePixbuf.save(filename,png)

 Where filename is the name of the file you wish to store to.

 Cheers!

 Martin

 PS. here is test.py which shows the feature in action (thanks for the
 patch tomeu!)

 --
 #!/usr/bin/python

 import sys
 import pygtk
 pygtk.require('2.0')
 import gtk
 import abiword

 window = gtk.Window()
 window.set_default_size(640, 480)
 window.connect('delete-event', gtk.main_quit)

 box = gtk.VBox()
 window.add(box)
 box.show()

 abi = abiword.Canvas()
 box.add(abi)
 abi.show()

 window.show()

 b = gtk.Button('render page')
 box.add(b)
 b.show()

 i = gtk.Image()
 box.add(i)
 i.show()

 def _clicked_cb(widget, abi, i):
i.props.pixbuf = abi.render_page_to_image(1)

 b.connect('clicked', lambda widget: _clicked_cb(widget, abi, i))

 gtk.main()
 

 On Mon, Jul 20, 2009 at 10:43 PM, sumit singhsumit.co...@gmail.com
 wrote:
  Hi everyone,
 
  Can anyone please guide me about the proper use of the get_preview
 function
  of the activity.Activity class of sugar. I had a look at its api, it
 seems
  to be returning a dictionary sort of thing which is called as the png
 image.
  What I want to do is to save this image somewhere in the datastore and
 show
  this image later to the user in my activity. So, what I want to ask is to
  how to load this information in the form of an image later on
  programatically. Can we load it using the gtk.image widget and what is
 the
  right procedure to save this information.
 
  Regards,
  sumit
 
  ___
  Sugar-devel mailing list
  sugar-de...@lists.sugarlabs.org
  http://lists.sugarlabs.org/listinfo/sugar-devel
 
 

attachment: preview image.png___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Proper use of self.set_canvas function

2009-07-19 Thread sumit singh
Hi everyone,

I would like to discuss about the set_canvas function of the
activity.Activity class, I can understand that it is used to define the
current working area of our activity. But , I want something of the sort
that when I start my activity the current working area would be a
gtk.scrollingwindow from which the user can select from the available
options and then when he clicks on a particular option , the current working
area should become a gtk.Vbox containing other widgets where the actual game
will be played. Now, when the user again wants to select from the available
game options, the current working area should become the gtk.Scrollingwindow
and so on...

So, should everytime I be using the set_canvas method in order to switch b/w
the 2 states or is there any other option.

Regards,
sumit.
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel