handle Back button

This commit is contained in:
Josh Holtrop 2016-06-27 16:02:49 -04:00
parent 62814e7502
commit baeac4dae9

View File

@ -19,6 +19,7 @@ class MainWindow(Gtk.Window):
self.cache_file = CacheFile() self.cache_file = CacheFile()
self.directory_buttons = [] self.directory_buttons = []
self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD) self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
self.url_history = []
if (self.cache_file["width"] is not None and if (self.cache_file["width"] is not None and
self.cache_file["height"] is not None): self.cache_file["height"] is not None):
@ -63,6 +64,7 @@ class MainWindow(Gtk.Window):
self.add(vbox) self.add(vbox)
self.connect("delete-event", self.__close) self.connect("delete-event", self.__close)
self.connect("key-press-event", self.__on_key_press_event)
icon_theme = Gtk.IconTheme.get_default() icon_theme = Gtk.IconTheme.get_default()
icon = icon_theme.load_icon("folder", 128, 0) icon = icon_theme.load_icon("folder", 128, 0)
@ -102,6 +104,8 @@ class MainWindow(Gtk.Window):
self.__refresh_repo_root(url) self.__refresh_repo_root(url)
if self.repo_root is not None: if self.repo_root is not None:
self.current_url = url self.current_url = url
if len(self.url_history) < 1 or self.url_history[-1] != url:
self.url_history.append(url)
self.__refresh_directory_buttons(url) self.__refresh_directory_buttons(url)
self.__refresh_directory_contents(url) self.__refresh_directory_contents(url)
else: else:
@ -207,3 +211,11 @@ class MainWindow(Gtk.Window):
self.popup_menu.append(mi) self.popup_menu.append(mi)
self.popup_menu.show_all() self.popup_menu.show_all()
self.popup_menu.popup(None, None, None, None, event.button, event.time) self.popup_menu.popup(None, None, None, None, event.button, event.time)
def __on_key_press_event(self, widget, event):
if event.keyval == Gdk.keyval_from_name("Back"):
if len(self.url_history) >= 2:
self.url_history.pop()
self.__go(self.url_history.pop())
return True
return False