Re: Opening Browse programatically
Thanks. It works now. In case anyone else wants to do this, here's what I ended up with: def open_url(self, url): Ask the journal to open an URL for us. from sugar import profile from shutil import rmtree from sugar.datastore import datastore from sugar.activity.activity import show_object_in_journal from tempfile import mkdtemp tmpfolder = mkdtemp('.tmp', 'url', os.path.join(self.get_activity_root(), 'instance')) tmpfilepath = os.path.join(tmpfolder, 'url') try: tmpfile = open(tmpfilepath, 'w') tmpfile.write(url) tmpfile.close() os.chmod(tmpfolder, 0755) os.chmod(tmpfilepath, 0755) jobject = datastore.create() metadata = { 'title': url, 'title_set_by_user': '1', 'buddies': '', 'preview': '', 'icon-color': profile.get_color().to_string(), 'mime_type': 'text/uri-list', } for k, v in metadata.items(): jobject.metadata[k] = v # the dict.update method is missing =( jobject.file_path = tmpfilepath datastore.write(jobject) show_object_in_journal(jobject.object_id) jobject.destroy() finally: rmtree(tmpfilepath, ignore_errors=True) # clean up! -josh On Mar 9, 2008, at 3:27 PM, C. Scott Ananian wrote: On Sun, Mar 9, 2008 at 1:18 PM, Joshua Minor [EMAIL PROTECTED] wrote: I made an activity wrapper for the interactive fiction interpreter Frotz. I want to have a button in the toolbar called Get More Games that opens a web page where you can download z-machine files. It looks like Chat lets you copy links to the clipboard and you can open them from there. I'll try that for now. You can also ask the journal to open a link for you. Look at how Pippy/Browse handle the 'show source' key. For security reasons, we don't let activities directly invoke other activities. Mediating the interaction with the journal ensures that the child's interaction is involved. --scott -- ( http://cscott.net/ ) ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Opening Browse programatically
I want to make a button in my activity that opens a particular URL with Browse. I found some code like this: activityfactory.create_with_uri('org.laptop.WebActivity', url) but that doesn't seem to work properly. It tries to open Browse, but throws an exception when trying to create a log file. Oddly, this does work if I run my activity via sugar-launch, but not from the frame. Is there another way to do this? -josh ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Opening Browse programatically
Launching activities from another activity is currently not supported. There are security concerns which will have to be addressed. I hope to find time to look into this for Update.2. Marco On Sun, Mar 9, 2008 at 10:41 AM, Joshua Minor [EMAIL PROTECTED] wrote: I want to make a button in my activity that opens a particular URL with Browse. I found some code like this: activityfactory.create_with_uri('org.laptop.WebActivity', url) but that doesn't seem to work properly. It tries to open Browse, but throws an exception when trying to create a log file. Oddly, this does work if I run my activity via sugar-launch, but not from the frame. Is there another way to do this? -josh ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Opening Browse programatically
On Sun, Mar 9, 2008 at 10:41 AM, Joshua Minor [EMAIL PROTECTED] wrote: I want to make a button in my activity that opens a particular URL with Browse. I found some code like this: activityfactory.create_with_uri('org.laptop.WebActivity', url) but that doesn't seem to work properly. It tries to open Browse, but throws an exception when trying to create a log file. Oddly, this does work if I run my activity via sugar-launch, but not from the frame. Is there another way to do this? As Marco said, we cannot do this currently. But perhaps you could explain what you are trying to do and perhaps someone could think of some alternative? Thanks, Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Opening Browse programatically
I want to make a button in my activity that opens a particular URL with Browse. As Marco said, we cannot do this currently. An observation (this is NOT any kind of request for action): Traditionally, computers have had a console stack (usually LIFO). Software could push a text string to it, then request that it be popped by the command interpreter, as a means to start a program. In my XO I can in Terminal type in 'opera URL' (without the quotes, and specifying the URL), and the Opera activity will launch. Seems to me whatever mechanism works for launching from Terminal, ought to be adaptable to launching from Joshua's activity. mikus ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Opening Browse programatically
I made an activity wrapper for the interactive fiction interpreter Frotz. I want to have a button in the toolbar called Get More Games that opens a web page where you can download z-machine files. It looks like Chat lets you copy links to the clipboard and you can open them from there. I'll try that for now. -josh On Mar 9, 2008, at 8:06 AM, Tomeu Vizoso wrote: On Sun, Mar 9, 2008 at 10:41 AM, Joshua Minor [EMAIL PROTECTED] wrote: I want to make a button in my activity that opens a particular URL with Browse. I found some code like this: activityfactory.create_with_uri('org.laptop.WebActivity', url) but that doesn't seem to work properly. It tries to open Browse, but throws an exception when trying to create a log file. Oddly, this does work if I run my activity via sugar-launch, but not from the frame. Is there another way to do this? As Marco said, we cannot do this currently. But perhaps you could explain what you are trying to do and perhaps someone could think of some alternative? Thanks, Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Opening Browse programatically
On Sun, Mar 9, 2008 at 1:18 PM, Joshua Minor [EMAIL PROTECTED] wrote: I made an activity wrapper for the interactive fiction interpreter Frotz. I want to have a button in the toolbar called Get More Games that opens a web page where you can download z-machine files. It looks like Chat lets you copy links to the clipboard and you can open them from there. I'll try that for now. You can also ask the journal to open a link for you. Look at how Pippy/Browse handle the 'show source' key. For security reasons, we don't let activities directly invoke other activities. Mediating the interaction with the journal ensures that the child's interaction is involved. --scott -- ( http://cscott.net/ ) ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel