Only allow one player window in the window stack
authorKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Sun, 3 Jan 2010 01:39:31 +0000 (02:39 +0100)
committerKristoffer Grönlund <kristoffer.gronlund@purplescout.se>
Sun, 3 Jan 2010 01:39:31 +0000 (02:39 +0100)
jamaui/playerwindow.py

index 724e73d..ab6e95e 100644 (file)
@@ -38,10 +38,14 @@ from songposition import SongPosition
 log = logging.getLogger(__name__)
 
 class PlayerWindow(hildon.StackableWindow):
+    instance = None
+
     def __init__(self):
         hildon.StackableWindow.__init__(self)
         self.set_title("jamaendo")
 
+        PlayerWindow.instance = self
+
         self.connect('destroy', self.on_destroy)
 
         self.player = the_player
@@ -153,6 +157,7 @@ class PlayerWindow(hildon.StackableWindow):
         return None
 
     def on_destroy(self, wnd):
+        PlayerWindow.instance = None
         self.stop_position_timer()
         postoffice.disconnect(['album-cover', 'next', 'prev', 'play', 'stop'], self)
 
@@ -297,6 +302,15 @@ class PlayerWindow(hildon.StackableWindow):
         self.player.stop()
 
 def open_playerwindow():
-    player = PlayerWindow()
-    player.show_all()
+    if PlayerWindow.instance:
+        player = PlayerWindow.instance
+        stack = player.get_stack()
+        sz = stack.size()
+        windows = stack.pop(sz)
+        windows.remove(player)
+        windows.append(player)
+        stack.push_list(windows)
+    else:
+        player = PlayerWindow()
+        player.show_all()
     return player