2006-10-13 11:17:35 +02:00
|
|
|
from gettext import gettext as _
|
2006-10-13 11:24:07 +02:00
|
|
|
import gtk
|
|
|
|
import gtkmozembed
|
2006-10-13 11:05:47 +02:00
|
|
|
|
2006-10-13 10:22:01 +02:00
|
|
|
from sugar.activity.Activity import Activity
|
2006-10-13 11:24:07 +02:00
|
|
|
from sugar import env
|
2006-10-13 18:05:48 +02:00
|
|
|
from sugar.graphics import style
|
|
|
|
import web.stylesheet
|
2006-10-13 10:22:01 +02:00
|
|
|
from webbrowser import WebBrowser
|
2006-10-13 11:05:47 +02:00
|
|
|
from toolbar import Toolbar
|
2006-10-13 15:46:11 +02:00
|
|
|
from linksmodel import LinksModel
|
|
|
|
from linksview import LinksView
|
|
|
|
from linkscontroller import LinksController
|
2006-10-13 10:22:01 +02:00
|
|
|
|
|
|
|
_HOMEPAGE = 'http://www.google.com'
|
|
|
|
|
|
|
|
class WebActivity(Activity):
|
|
|
|
def __init__(self):
|
|
|
|
Activity.__init__(self)
|
|
|
|
|
2006-10-13 11:17:35 +02:00
|
|
|
self.set_title(_('Web Activity'))
|
|
|
|
|
2006-10-13 11:05:47 +02:00
|
|
|
vbox = gtk.VBox()
|
|
|
|
|
2006-10-13 10:22:01 +02:00
|
|
|
self._browser = WebBrowser()
|
2006-10-13 11:17:35 +02:00
|
|
|
self._browser.connect('notify::title', self._title_changed_cb)
|
2006-10-13 11:05:47 +02:00
|
|
|
|
2006-10-13 18:05:48 +02:00
|
|
|
self._links_model = LinksModel()
|
2006-10-13 19:04:04 +02:00
|
|
|
links_view = LinksView(self._links_model, self._browser)
|
2006-10-13 11:05:47 +02:00
|
|
|
|
2006-10-13 15:46:11 +02:00
|
|
|
self._toolbar = Toolbar(self._browser)
|
|
|
|
vbox.pack_start(self._toolbar, False)
|
|
|
|
self._toolbar.show()
|
|
|
|
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
|
|
|
|
hbox.pack_start(links_view, False)
|
|
|
|
hbox.pack_start(self._browser)
|
2006-10-13 10:22:01 +02:00
|
|
|
self._browser.show()
|
|
|
|
|
2006-10-13 15:46:11 +02:00
|
|
|
vbox.pack_start(hbox)
|
|
|
|
hbox.show()
|
|
|
|
|
2006-10-13 11:05:47 +02:00
|
|
|
self.add(vbox)
|
|
|
|
vbox.show()
|
|
|
|
|
2006-10-13 10:22:01 +02:00
|
|
|
self._browser.load_url(_HOMEPAGE)
|
2006-10-13 11:17:35 +02:00
|
|
|
|
2006-10-13 18:05:48 +02:00
|
|
|
def _setup_links_controller(self):
|
|
|
|
links_controller = LinksController(self._service, self._links_model)
|
|
|
|
self._toolbar.set_links_controller(links_controller)
|
|
|
|
|
2006-10-13 13:57:39 +02:00
|
|
|
def join(self, activity_ps):
|
|
|
|
Activity.join(self, activity_ps)
|
|
|
|
|
2006-10-13 18:05:48 +02:00
|
|
|
self._setup_links_controller()
|
2006-10-13 15:46:11 +02:00
|
|
|
|
2006-10-13 13:57:39 +02:00
|
|
|
url = self._service.get_published_value('URL')
|
|
|
|
if url:
|
|
|
|
self._browser.load_url(url)
|
|
|
|
|
|
|
|
def share(self):
|
|
|
|
Activity.share(self)
|
|
|
|
|
2006-10-13 18:05:48 +02:00
|
|
|
self._setup_links_controller()
|
|
|
|
|
2006-10-13 13:57:39 +02:00
|
|
|
url = self._browser.get_location()
|
|
|
|
if url:
|
|
|
|
self._service.set_published_value('URL', url)
|
|
|
|
|
2006-10-13 11:17:35 +02:00
|
|
|
def _title_changed_cb(self, embed, pspec):
|
|
|
|
self.set_title(embed.props.title)
|
2006-10-13 11:24:07 +02:00
|
|
|
|
|
|
|
def start():
|
|
|
|
gtkmozembed.set_profile_path(env.get_profile_path(), 'gecko')
|
2006-10-13 18:05:48 +02:00
|
|
|
style.load_stylesheet(web.stylesheet)
|