Author: dmeyer
Date: Sat Jan 20 20:22:55 2007
New Revision: 9020

Modified:
   trunk/ui/src/gui/windows/__init__.py
   trunk/ui/src/gui/windows/confirmbox.py
   trunk/ui/src/gui/windows/messagebox.py
   trunk/ui/src/gui/windows/waitbox.py
   trunk/ui/src/gui/windows/window.py

Log:
application controls windows now

Modified: trunk/ui/src/gui/windows/__init__.py
==============================================================================
--- trunk/ui/src/gui/windows/__init__.py        (original)
+++ trunk/ui/src/gui/windows/__init__.py        Sat Jan 20 20:22:55 2007
@@ -33,5 +33,6 @@
 from waitbox     import *
 from messagebox  import *
 from confirmbox  import *
-from progressbox import *
-from inputbox    import *
+
+# from progressbox import *
+# from inputbox    import *

Modified: trunk/ui/src/gui/windows/confirmbox.py
==============================================================================
--- trunk/ui/src/gui/windows/confirmbox.py      (original)
+++ trunk/ui/src/gui/windows/confirmbox.py      Sat Jan 20 20:22:55 2007
@@ -57,16 +57,20 @@
     function should be called if Yes is selected. INPUT_EXIT will be close
     the box like pressing No.
     """
-    def __init__(self, text, buttons=(_('Yes'), _('No')), default_choice=0):
-        WaitBox.__init__(self, text)
+    def __init__(self, obj):
+        WaitBox.__init__(self, obj)
 
         spacing = self.content_spacing
-        w = int((self.get_content_size()[0] - spacing) / len(buttons))
+        w = int((self.get_content_size()[0] - spacing) / len(obj.buttons))
         x, y = self.get_content_pos()
 
         self.buttons = []
-        for btext in buttons:
-            self.buttons.append(Button(btext, (x,y), w, self.button_normal))
+        for b in obj.buttons:
+            button = Button(b.name, (x,y), w, self.button_normal)
+            button.info = b
+            if b.selected:
+                button.set_style(self.button_selected)
+            self.buttons.append(button)
             x += w + spacing
             
         y = self.add_row(self.buttons[0].get_size()[1])
@@ -74,44 +78,11 @@
             b.set_pos((b.get_pos()[0], y))
             self.add_child(b)
 
-        self.selected = self.buttons[default_choice]
-        self.selected.set_style(self.button_selected)
-        
 
-    def connect(self, button, function, *args, **kwargs):
-        """
-        Connect a callback to a button by it's number. If nothing is sepcified
-        in the constructor, 0 is yes and 1 is no.
-        """
-        self.buttons[button].connect(function, *args, **kwargs)
-        
-
-    def eventhandler(self, event):
-        """
-        Eventhandler to toggle the selection or press the button
-        """
-        if event in (INPUT_LEFT, INPUT_RIGHT):
-            # Toggle selection
-            self.selected.set_style(self.button_normal)
-            index = self.buttons.index(self.selected)
-            if event == INPUT_LEFT:
-                index = (index + 1) % len(self.buttons)
-            elif index == 0:
-                index = len(self.buttons) - 1
+    def update(self):
+        for b in self.buttons:
+            if b.info.selected:
+                b.set_style(self.button_selected)
             else:
-                index = index - 1
-            self.selected = self.buttons[index]
-            self.selected.set_style(self.button_selected)
-            self.update()
-            return True
-
-        elif event == INPUT_EXIT:
-            self.destroy()
-            return True
-
-        elif event == INPUT_ENTER:
-            self.selected.select()
-            self.destroy()
-            return True
-        
-        return False
+                b.set_style(self.button_normal)
+        WaitBox.update(self)

Modified: trunk/ui/src/gui/windows/messagebox.py
==============================================================================
--- trunk/ui/src/gui/windows/messagebox.py      (original)
+++ trunk/ui/src/gui/windows/messagebox.py      Sat Jan 20 20:22:55 2007
@@ -54,31 +54,11 @@
     """
     A box with a label and an OK button to close it.
     """
-    def __init__(self, text, button_text=_('OK')):
-        WaitBox.__init__(self, text)
-        self.button = Button(button_text, self.get_content_pos(),
+    def __init__(self, obj):
+        WaitBox.__init__(self, obj)
+        self.button = Button(obj.button.name, self.get_content_pos(),
                              self.get_content_size()[0],
                              self.button_selected)
         y = self.add_row(self.button.get_size()[1])
         self.button.set_pos((self.button.get_pos()[0], y))
         self.add_child(self.button)
-
-
-    def eventhandler(self, event):
-        """
-        Eventhandler to close the box on INPUT_ENTER or INPUT_EXIT
-        """
-        if event in (INPUT_ENTER, INPUT_EXIT):
-            self.destroy()
-            if event == INPUT_ENTER:
-                self.button.select()
-            return True
-        return False
-
-
-    def connect(self, function, *args, **kwargs):
-        """
-        Connect to the selection of the button.
-        """
-        self.button.connect(function, *args, **kwargs)
-

Modified: trunk/ui/src/gui/windows/waitbox.py
==============================================================================
--- trunk/ui/src/gui/windows/waitbox.py (original)
+++ trunk/ui/src/gui/windows/waitbox.py Sat Jan 20 20:22:55 2007
@@ -58,11 +58,12 @@
     should be used when Freevo is doing some background action and the user
     has to wait.
     """
-    def __init__(self, text):
+    def __init__(self, obj):
         Window.__init__(self)
 
         width, height = self.get_content_size()
-
+        text = obj.text
+        
         # We need at least text_height * text_width space for the text, in
         # most cases more (because of line breaks. To make the text look
         # nice, we try 4:3 aspect of the box at first and than use the max
@@ -120,11 +121,3 @@
         self.label.set_pos((x, y))
         # the y position of the text is now label pos + label height + spacing
         return y + label_height + spacing
-
-    
-    def eventhandler(self, event):
-        """
-        Eventhandler for the box. A WaitBox can handle no events, something
-        from the outside must close the box.
-        """
-        return False

Modified: trunk/ui/src/gui/windows/window.py
==============================================================================
--- trunk/ui/src/gui/windows/window.py  (original)
+++ trunk/ui/src/gui/windows/window.py  Sat Jan 20 20:22:55 2007
@@ -38,9 +38,6 @@
 # python imports
 import copy
 
-# freevo imports
-import application
-
 # gui imports
 from gui import displays
 from gui import theme
@@ -131,7 +128,6 @@
         """
         if self.__display:
             return
-        application.add_window(self)
         self.__display = displays.get()
         self.__create_background(self.__display)
         self.__display.add_child(self)
@@ -142,23 +138,8 @@
         """
         Destroy (close) the window
         """
-        application.remove_window(self)
         if not self.__display:
             return
         self.__display.remove_child(self)
         self.__display.update()
         self.__display = None
-
-
-    def eventhandler(self, event):
-        """
-        Eventhandler for the window, this raw window has nothing to do
-        """
-        return False
-
-
-    def get_eventmap(self):
-        """
-        Return the eventmap for the window
-        """
-        return 'input'

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to