LOL, helldon. though there's something bad going on with gthreads.
authorKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Tue, 5 Jan 2010 16:26:17 +0000 (17:26 +0100)
committerKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Wed, 6 Jan 2010 13:56:42 +0000 (14:56 +0100)
helldon/__init__.py
jamaui/listbox.py

index d3aa134..cf817d7 100644 (file)
@@ -29,27 +29,55 @@ class Program(gtk.Window):
         self.add(self._vbox)
         self.show_all()
         Program.instance = self
+        self._backbtn.connect('clicked', self.on_back)
+
+        self._stack = []
 
     def add_window(self, wnd):
         pass
 
-    def add_stackable(self, wnd):
+    def push_stackable(self, wnd):
+        while self._notebook.get_n_pages() > 0:
+            p = self._notebook.get_nth_page(0)
+            self._stack.append(p)
+            self._notebook.remove_page(0)
+            p.hide()
+
         idx = self._notebook.append_page(wnd)
         self._notebook.set_current_page(idx)
         wnd.show_all()
         wnd._nb_index = idx
 
+    def popped_stackable(self, wnd=None):
+        pass
+
+    def pop_stackable(self):
+        while self._notebook.get_n_pages() > 0:
+            p = self._notebook.get_nth_page(0)
+            self._notebook.remove_page(0)
+            p.hide()
+        if len(self._stack):
+            tail = self._stack.pop()
+            self.push_stackable(tail)
+
+    def on_back(self, *args):
+        self.pop_stackable()
+
 class StackableWindow(gtk.Frame):
     def __init__(self):
         gtk.Frame.__init__(self)
         self._nb_index = 0
-        Program.instance.add_stackable(self)
+        Program.instance.push_stackable(self)
+        self.connect('destroy', self.on_destroy)
     def set_app_menu(self, menu):
         pass
 
     def set_title(self, title):
         Program.instance._title.set_text(title)#_notebook.set_tab_label_text(self, title)
 
+    def on_destroy(self, *args):
+        Program.instance.popped_stackable(self)
+
 class AppMenu(object):
     def __init__(self):
         pass
index bc34d09..c74f1d8 100644 (file)
@@ -2,8 +2,10 @@
 import gtk
 try:
     import hildon
+    _using_helldon = False
 except:
     import helldon as hildon
+    _using_helldon = True
 
 class ListBox(gtk.TreeView):
     def __init__(self):
@@ -42,7 +44,7 @@ class ListBox(gtk.TreeView):
 
 class ListDialog(gtk.Dialog):
     def __init__(self, title, parent=None):
-        gtk.Dialog.__init__(self, title, parent)
+        gtk.Dialog.__init__(self, title, parent if not _using_helldon else None)
         self.listbox = ListBox()
         panarea = hildon.PannableArea()
         panarea.add(self.listbox)
@@ -59,7 +61,7 @@ class ListDialog(gtk.Dialog):
 
 class ButtonListDialog(gtk.Dialog):
     def __init__(self, title, parent=None):
-        gtk.Dialog.__init__(self, title, parent)
+        gtk.Dialog.__init__(self, title, parent if not _using_helldon else None)
         self.panarea = hildon.PannableArea()
         self.panarea.set_size_request(800, 400)
         self.buttons = gtk.VBox(False, 0)