2006-06-01 00:01:24 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
import geckoembed
|
|
|
|
|
|
|
|
from sugar.shell import activity
|
|
|
|
from sugar.browser.AddressItem import AddressItem
|
|
|
|
|
|
|
|
class AddressToolbar(gtk.Toolbar):
|
|
|
|
def __init__(self, shell):
|
|
|
|
gtk.Toolbar.__init__(self)
|
|
|
|
|
|
|
|
self._shell = shell
|
|
|
|
|
|
|
|
address_item = AddressItem(self.__open_address_cb)
|
|
|
|
self.insert(address_item, 0)
|
|
|
|
address_item.show()
|
|
|
|
|
|
|
|
def __open_address_cb(self, address):
|
|
|
|
self._shell.open_browser(address)
|
|
|
|
|
|
|
|
class WebActivity(activity.Activity):
|
|
|
|
def __init__(self, shell):
|
|
|
|
activity.Activity.__init__(self)
|
|
|
|
self._shell = shell
|
|
|
|
|
2006-06-02 20:52:20 +02:00
|
|
|
def on_connected_to_shell(self):
|
|
|
|
self.set_tab_text("Web")
|
|
|
|
self.set_tab_icon(name="web-browser")
|
|
|
|
self.set_show_tab_icon(True)
|
2006-06-01 00:01:24 +02:00
|
|
|
|
|
|
|
vbox = gtk.VBox()
|
|
|
|
|
|
|
|
self.embed = geckoembed.Embed()
|
|
|
|
self.embed.connect("open-address", self.__open_address);
|
|
|
|
vbox.pack_start(self.embed)
|
|
|
|
self.embed.show()
|
|
|
|
|
|
|
|
address_toolbar = AddressToolbar(self._shell)
|
|
|
|
vbox.pack_start(address_toolbar, False)
|
|
|
|
address_toolbar.show()
|
|
|
|
|
2006-06-02 20:52:20 +02:00
|
|
|
plug = self.gtk_plug()
|
2006-06-01 00:01:24 +02:00
|
|
|
plug.add(vbox)
|
|
|
|
plug.show()
|
|
|
|
|
|
|
|
vbox.show()
|
|
|
|
|
|
|
|
self.embed.load_address("http://www.google.com")
|
|
|
|
|
|
|
|
def __open_address(self, embed, uri, data=None):
|
|
|
|
if uri.startswith("http://www.google.com"):
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
self._shell.open_browser(uri)
|
|
|
|
return True
|
|
|
|
|
2006-06-02 20:52:20 +02:00
|
|
|
def on_disconnected_from_shell(self):
|
2006-06-01 00:01:24 +02:00
|
|
|
gtk.main_quit()
|