Get rid of the web search activity, refactor
This commit is contained in:
parent
3e3c168ab0
commit
a4b2e74d25
@ -5,35 +5,17 @@ import gobject
|
||||
|
||||
import sugar.env
|
||||
|
||||
from sugar.browser.WebActivity import WebActivity
|
||||
from sugar.browser.BrowserActivity import BrowserActivity
|
||||
|
||||
class BrowserShell(dbus.service.Object):
|
||||
instance = None
|
||||
_lock = threading.Lock()
|
||||
|
||||
def get_instance():
|
||||
BrowserShell._lock.acquire()
|
||||
if not BrowserShell.instance:
|
||||
BrowserShell.instance = BrowserShell()
|
||||
BrowserShell._lock.release()
|
||||
return BrowserShell.instance
|
||||
get_instance = staticmethod(get_instance)
|
||||
|
||||
def __init__(self):
|
||||
geckoembed.set_profile_path(sugar.env.get_user_dir())
|
||||
|
||||
session_bus = dbus.SessionBus()
|
||||
bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus)
|
||||
object_path = '/com/redhat/Sugar/Browser'
|
||||
|
||||
def __init__(self, object_path = '/com/redhat/Sugar/Browser'):
|
||||
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||
|
||||
geckoembed.set_profile_path(sugar.env.get_user_dir())
|
||||
self.__browsers = []
|
||||
|
||||
def open_web_activity(self):
|
||||
web_activity = WebActivity(self)
|
||||
web_activity.connect_to_shell()
|
||||
def start():
|
||||
gtk.main()
|
||||
|
||||
@dbus.service.method('com.redhat.Sugar.BrowserShell')
|
||||
def get_links(self):
|
||||
|
@ -1,59 +0,0 @@
|
||||
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
|
||||
|
||||
def on_connected_to_shell(self):
|
||||
self.set_tab_text("Web")
|
||||
self.set_tab_icon(name="web-browser")
|
||||
self.set_show_tab_icon(True)
|
||||
|
||||
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()
|
||||
|
||||
plug = self.gtk_plug()
|
||||
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
|
||||
|
||||
def on_disconnected_from_shell(self):
|
||||
gtk.main_quit()
|
@ -3,6 +3,7 @@
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import dbus
|
||||
|
||||
import sugar.env
|
||||
|
||||
@ -14,6 +15,7 @@ log_writer.start()
|
||||
|
||||
gtk.rc_parse(sugar.env.get_data_file('browser.rc'))
|
||||
|
||||
BrowserShell.get_instance().open_web_activity()
|
||||
|
||||
gtk.main()
|
||||
session_bus = dbus.SessionBus()
|
||||
bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus)
|
||||
shell = BrowserShell(bus_name)
|
||||
shell.start()
|
||||
|
Loading…
Reference in New Issue
Block a user