2006-06-01 00:01:24 +02:00
|
|
|
import dbus
|
|
|
|
import geckoembed
|
2006-06-15 17:18:33 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
2006-06-16 22:31:54 +02:00
|
|
|
import gobject
|
2006-06-01 00:01:24 +02:00
|
|
|
|
|
|
|
import sugar.env
|
|
|
|
|
|
|
|
from sugar.browser.BrowserActivity import BrowserActivity
|
2006-06-18 07:31:55 +02:00
|
|
|
from sugar.presence import Service
|
2006-06-01 00:01:24 +02:00
|
|
|
|
|
|
|
class BrowserShell(dbus.service.Object):
|
2006-06-15 17:18:33 +02:00
|
|
|
def __init__(self, bus_name, object_path = '/com/redhat/Sugar/Browser'):
|
2006-06-01 00:01:24 +02:00
|
|
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
2006-06-15 04:04:44 +02:00
|
|
|
|
|
|
|
geckoembed.set_profile_path(sugar.env.get_user_dir())
|
2006-06-01 00:01:24 +02:00
|
|
|
self.__browsers = []
|
|
|
|
|
2006-06-15 17:18:33 +02:00
|
|
|
def start(self):
|
2006-06-15 04:04:44 +02:00
|
|
|
gtk.main()
|
2006-06-01 00:01:24 +02:00
|
|
|
|
|
|
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
|
|
|
def get_links(self):
|
|
|
|
links = []
|
|
|
|
for browser in self.__browsers:
|
|
|
|
embed = browser.get_embed()
|
|
|
|
link = {}
|
|
|
|
link['title'] = embed.get_title()
|
|
|
|
link['address'] = embed.get_address()
|
|
|
|
links.append(link)
|
|
|
|
return links
|
|
|
|
|
2006-06-18 07:31:55 +02:00
|
|
|
def _start_browser_cb(self, browser, service):
|
|
|
|
browser.connect_to_shell(service)
|
2006-06-16 22:31:54 +02:00
|
|
|
|
2006-06-01 00:01:24 +02:00
|
|
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
2006-06-18 07:31:55 +02:00
|
|
|
def open_browser(self, uri, serialized_service=None):
|
|
|
|
service = None
|
2006-06-18 09:00:23 +02:00
|
|
|
# if serialized_service is not None:
|
|
|
|
# service = Service.deserialize(serialized_service)
|
2006-06-15 17:29:00 +02:00
|
|
|
browser = BrowserActivity(uri)
|
2006-06-01 00:01:24 +02:00
|
|
|
self.__browsers.append(browser)
|
2006-06-18 07:31:55 +02:00
|
|
|
gobject.idle_add(self._start_browser_cb, browser, service)
|
2006-06-16 07:43:42 +02:00
|
|
|
|
|
|
|
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
2006-06-18 07:31:55 +02:00
|
|
|
def open_browser_from_service_foobar(self, uri, serialized_service):
|
2006-06-18 09:00:23 +02:00
|
|
|
service = Service.deserialize(serialized_service)
|
2006-06-16 07:43:42 +02:00
|
|
|
browser = BrowserActivity(uri)
|
|
|
|
self.__browsers.append(browser)
|
2006-06-18 07:31:55 +02:00
|
|
|
gobject.idle_add(self._start_browser_cb, browser, service)
|