2006-06-01 00:01:24 +02:00
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk
|
|
|
|
|
2006-06-21 20:23:18 +02:00
|
|
|
from AddressItem import AddressItem
|
2006-06-01 00:01:24 +02:00
|
|
|
|
|
|
|
class NavigationToolbar(gtk.Toolbar):
|
|
|
|
def __init__(self, browser):
|
|
|
|
gtk.Toolbar.__init__(self)
|
|
|
|
self._browser = browser
|
|
|
|
self._embed = self._browser.get_embed()
|
|
|
|
|
|
|
|
self.set_style(gtk.TOOLBAR_BOTH_HORIZ)
|
|
|
|
|
2006-06-07 22:08:14 +02:00
|
|
|
self.back = gtk.ToolButton(None, 'Back')
|
|
|
|
self.back.set_icon_name('back')
|
2006-06-01 00:01:24 +02:00
|
|
|
self.back.connect("clicked", self.__go_back_cb)
|
|
|
|
self.insert(self.back, -1)
|
|
|
|
self.back.show()
|
|
|
|
|
2006-06-07 22:08:14 +02:00
|
|
|
self.forward = gtk.ToolButton(None, 'Forward')
|
|
|
|
self.forward.set_icon_name('forward')
|
2006-06-01 00:01:24 +02:00
|
|
|
self.forward.connect("clicked", self.__go_forward_cb)
|
|
|
|
self.insert(self.forward, -1)
|
|
|
|
self.forward.show()
|
|
|
|
|
2006-06-07 22:08:14 +02:00
|
|
|
self.reload = gtk.ToolButton(None, 'Reload')
|
|
|
|
self.reload.set_icon_name('reload')
|
2006-06-01 00:01:24 +02:00
|
|
|
self.reload.connect("clicked", self.__reload_cb)
|
|
|
|
self.insert(self.reload, -1)
|
|
|
|
self.reload.show()
|
|
|
|
|
|
|
|
separator = gtk.SeparatorToolItem()
|
|
|
|
self.insert(separator, -1)
|
|
|
|
separator.show()
|
|
|
|
|
|
|
|
address_item = AddressItem(self.__open_address_cb)
|
|
|
|
self.insert(address_item, -1)
|
|
|
|
address_item.show()
|
|
|
|
|
|
|
|
self._update_sensitivity()
|
|
|
|
|
|
|
|
self._embed.connect("location", self.__location_changed)
|
|
|
|
|
|
|
|
def _update_sensitivity(self):
|
|
|
|
self.back.set_sensitive(self._embed.can_go_back())
|
|
|
|
self.forward.set_sensitive(self._embed.can_go_forward())
|
|
|
|
|
|
|
|
def __go_back_cb(self, button):
|
|
|
|
self._embed.go_back()
|
|
|
|
|
|
|
|
def __go_forward_cb(self, button):
|
|
|
|
self._embed.go_forward()
|
|
|
|
|
|
|
|
def __reload_cb(self, button):
|
|
|
|
self._embed.reload()
|
|
|
|
|
|
|
|
def __location_changed(self, embed):
|
|
|
|
self._update_sensitivity()
|
|
|
|
|
|
|
|
def __open_address_cb(self, address):
|
|
|
|
self._embed.load_address(address)
|