Author: dmeyer
Date: Sun Feb  4 20:46:17 2007
New Revision: 9163

Modified:
   trunk/ui/src/gui/__init__.py
   trunk/ui/src/gui/displays/__init__.py
   trunk/ui/src/image/viewer.py
   trunk/ui/src/input/plugins/sdl.py
   trunk/ui/src/input/plugins/x11.py
   trunk/ui/src/plugins/idlebar/__init__.py
   trunk/ui/src/plugins/osd.py
   trunk/ui/src/plugins/shutdown.py

Log:
hide some gui internals

Modified: trunk/ui/src/gui/__init__.py
==============================================================================
--- trunk/ui/src/gui/__init__.py        (original)
+++ trunk/ui/src/gui/__init__.py        Sun Feb  4 20:46:17 2007
@@ -82,9 +82,10 @@
 #
 # -----------------------------------------------------------------------------
 
-width   = 0
-height  = 0
-display = None
+_display = None
+
+def get_display():
+    return _display
 
 # ugly compat code until the new gui is ready
 from compat import *

Modified: trunk/ui/src/gui/displays/__init__.py
==============================================================================
--- trunk/ui/src/gui/displays/__init__.py       (original)
+++ trunk/ui/src/gui/displays/__init__.py       Sun Feb  4 20:46:17 2007
@@ -62,10 +62,7 @@
     display = Display(size, True)
     display_stack.append(display)
     animation.create(display)
-    # set global gui width / height
-    gui.width   = display.width
-    gui.height  = display.height
-    gui.display = display
+    gui._display = display
     return display
 
 # create a display (== get first one)
@@ -98,10 +95,7 @@
     display.update()
 
     animation.create(display)
-    # set global gui width / height
-    gui.width   = display.width
-    gui.height  = display.height
-    gui.display = display
+    gui._display = display
     return display
 
 
@@ -130,10 +124,7 @@
     display = display_stack[-1]
     display.show()
     animation.create(display)
-    # set global gui width / height
-    gui.width   = display.width
-    gui.height  = display.height
-    gui.display = display
+    gui._display = display
     return display
 
 

Modified: trunk/ui/src/image/viewer.py
==============================================================================
--- trunk/ui/src/image/viewer.py        (original)
+++ trunk/ui/src/image/viewer.py        Sun Feb  4 20:46:17 2007
@@ -179,6 +179,8 @@
             return
 
         width, height = image.width, image.height
+        gui_width = gui.get_display().width
+        gui_height = gui.get_display().height
 
         # Bounding box default values
         bbx = bby = bbw = bbh = 0
@@ -198,16 +200,16 @@
 
             # calculate the scaling that the image is 3 times that big
             # as the screen (3 times because we have a 3x3 grid)
-            scale_x = float(gui.width*3) / width
-            scale_y = float(gui.height*3) / height
+            scale_x = float(gui_width*3) / width
+            scale_y = float(gui_height*3) / height
             scale   = min(scale_x, scale_y)
 
             # create bbx and bby were to start showing the zoomed image
             bbx, bby = int(scale*bbx), int(scale*bby)
-            if int(width*scale) - bbx < gui.width:
-                bbx = int(width*scale) - gui.width
-            if int(height*scale) - bby < gui.height:
-                bby = int(height*scale) - gui.height
+            if int(width*scale) - bbx < gui_width:
+                bbx = int(width*scale) - gui_width
+            if int(height*scale) - bby < gui_height:
+                bby = int(height*scale) - gui_height
             # calculate new width and height after scaling
             width  = int(scale * 3 * width)
             height = int(scale * 3 * height)
@@ -215,8 +217,8 @@
 
         else:
             # No zoom, scale image that it fits the screen
-            scale_x = float(gui.width) / width
-            scale_y = float(gui.height) / height
+            scale_x = float(gui_width) / width
+            scale_y = float(gui_height) / height
             scale   = min(scale_x, scale_y)
             # calculate new width and height after scaling
             width  = int(scale * width)
@@ -224,8 +226,8 @@
 
         # Now we have all necessary informations about zoom yes/no and
         # the kind of rotation
-        x = max((gui.width - width) / 2, 0)
-        y = max((gui.height - height) / 2, 0)
+        x = max((gui_width - width) / 2, 0)
+        y = max((gui_height - height) / 2, 0)
 
         # copy the image because we will change it (scale, rotate)
         image = image.copy()
@@ -250,15 +252,15 @@
         if (self.last_image and self.last_item != item and
             config.IMAGEVIEWER_BLEND_MODE != None):
             # blend over to the new image
-            gui.display.add_child(image)
+            gui.get_display().add_child(image)
             a = Transition([self.last_image], [image], 20,
-                           (gui.width, gui.height), 
config.IMAGEVIEWER_BLEND_MODE)
+                           (gui_width, gui_height), 
config.IMAGEVIEWER_BLEND_MODE)
             # start the animation and wait until it's done
             a.start()
             a.wait()
         else:
             # add the new image
-            gui.display.add_child(image)
+            gui.get_display().add_child(image)
 
         # remove the last image if there is one
         if self.last_image:
@@ -434,24 +436,27 @@
             # remove the first space from the string
             osdstring = osdstring[1:]
 
+        gui_width = gui.get_display().width
+        gui_height = gui.get_display().height
+
         # create the text widget
         pos = (config.GUI_OVERSCAN_X + 10, config.GUI_OVERSCAN_Y + 10)
-        size = (gui.width - 2 * config.GUI_OVERSCAN_X - 20,
-                gui.height - 2 * config.GUI_OVERSCAN_Y - 20)
+        size = (gui_width - 2 * config.GUI_OVERSCAN_X - 20,
+                gui_height - 2 * config.GUI_OVERSCAN_Y - 20)
         self.osd_text = widgets.Textbox(osdstring, pos, size,
                                         theme.font('default'),
                                         'left', 'bottom', mode='soft')
         # add the text widget to the screen, make sure the zindex
         # is 2 (== above the image and the box)
         self.osd_text.set_zindex(2)
-        gui.display.add_child(self.osd_text)
+        gui.get_display().add_child(self.osd_text)
 
         # create a box around the text
         rect = self.osd_text.get_size()
 
         if rect[1] < 100:
             # text too small, set to a minimum position
-            self.osd_text.set_pos((self.osd_text.get_pos()[0], gui.height - \
+            self.osd_text.set_pos((self.osd_text.get_pos()[0], gui_height - \
                                    config.GUI_OVERSCAN_Y - 100))
             rect = rect[0], 100
 
@@ -465,8 +470,8 @@
 
         # build a new rectangle.
         pos  = (0, self.osd_text.get_pos()[1] - 10)
-        size = (gui.width, rect[1] + 20)
-        background = imagelib.load('background', (gui.width, gui.height))
+        size = (gui_width, rect[1] + 20)
+        background = imagelib.load('background', (gui_width, gui_height))
         if background:
             background.crop(pos, size)
             self.osd_box = widgets.Image(background, pos)
@@ -477,7 +482,7 @@
         # put the rectangle on the screen and set the zindex to 1
         # (between image and text)
         self.osd_box.set_zindex(1)
-        gui.display.add_child(self.osd_box)
+        gui.get_display().add_child(self.osd_box)
 
         if newosd:
             # show the idlebar but not update the screen now

Modified: trunk/ui/src/input/plugins/sdl.py
==============================================================================
--- trunk/ui/src/input/plugins/sdl.py   (original)
+++ trunk/ui/src/input/plugins/sdl.py   Sun Feb  4 20:46:17 2007
@@ -65,10 +65,10 @@
                 log.error('unable to find key code for %s' % key)
 
         # set mouse hiding on
-        gui.display._window.hide_mouse = True
+        gui.get_display()._window.hide_mouse = True
 
         # connect to signals
-        signals = gui.display._window.signals
+        signals = gui.get_display()._window.signals
         signals['key_press_event'].connect(self.key_press_event)
 
 

Modified: trunk/ui/src/input/plugins/x11.py
==============================================================================
--- trunk/ui/src/input/plugins/x11.py   (original)
+++ trunk/ui/src/input/plugins/x11.py   Sun Feb  4 20:46:17 2007
@@ -51,7 +51,7 @@
     """
     def __init__(self):
         InputPlugin.__init__(self)
-        gui.display._window.signals["key_press_event"].connect(self.handle)
+        
gui.get_display()._window.signals["key_press_event"].connect(self.handle)
 
 
     def handle( self, keycode ):
@@ -62,7 +62,7 @@
             global SCREENSHOT
             filename = 'screenshots/screenshot-%04d.png' % SCREENSHOT
             log.info('screenshot %s' % filename)
-            gui.display._backing_store._image.save(filename)
+            gui.get_display()._backing_store._image.save(filename)
             SCREENSHOT += 1
             return True
 

Modified: trunk/ui/src/plugins/idlebar/__init__.py
==============================================================================
--- trunk/ui/src/plugins/idlebar/__init__.py    (original)
+++ trunk/ui/src/plugins/idlebar/__init__.py    Sun Feb  4 20:46:17 2007
@@ -73,7 +73,7 @@
 
         self.container = widgets.Container()
         self.container.set_zindex(10)
-        gui.display.add_child(self.container)
+        gui.get_display().add_child(self.container)
 
         self._timer = kaa.notifier.Timer(self.poll)
         self._timer.start(30)
@@ -91,7 +91,7 @@
         """
         changed = False
 
-        w = gui.display.width
+        w = gui.get_display().width
         h = config.GUI_OVERSCAN_Y + 60
 
         x1 = config.GUI_OVERSCAN_X
@@ -139,7 +139,7 @@
         self.visible = True
         self.update()
         if update:
-            gui.display.update()
+            gui.get_display().update()
 
 
     def hide(self, update=True, fade=0):
@@ -148,7 +148,7 @@
         animation.FadeAnimation([self.container], fade, 255, 0).start()
         self.visible = False
         if update:
-            gui.display.update()
+            gui.get_display().update()
 
 
     def add_background(self):
@@ -157,7 +157,7 @@
         """
         if not self.background:
             # FIXME: respect fxd settings changes!!!
-            s = gui.display
+            s = gui.get_display()
             size = (s.width, s.height)
             self.background = imagelib.load('background', size)
             if self.background:
@@ -184,7 +184,7 @@
         fade = True
         
         # get gui informations
-        w = gui.display.width
+        w = gui.get_display().width
         h = config.GUI_OVERSCAN_Y + 60
 
         f = theme.image('idlebar')
@@ -223,7 +223,7 @@
         if not self.visible:
             return
         if self.update():
-            gui.display.update()
+            gui.get_display().update()
 
 
 

Modified: trunk/ui/src/plugins/osd.py
==============================================================================
--- trunk/ui/src/plugins/osd.py (original)
+++ trunk/ui/src/plugins/osd.py Sun Feb  4 20:46:17 2007
@@ -72,7 +72,7 @@
         """
         update the display
         """
-        display = gui.display
+        display = gui.get_display()
         if self.gui_object:
             # remove the current text from the display
             self.gui_object.unparent()

Modified: trunk/ui/src/plugins/shutdown.py
==============================================================================
--- trunk/ui/src/plugins/shutdown.py    (original)
+++ trunk/ui/src/plugins/shutdown.py    Sun Feb  4 20:46:17 2007
@@ -118,12 +118,13 @@
         """
         Clear the screen and show the message.
         """
-        msg = widgets.Text(text, (0, 0), (gui.width, gui.height),
+        size = gui.get_display().width, gui.get_display().height
+        msg = widgets.Text(text, (0, 0), size,
                            theme.font('default'), align_h='center',
                            align_v='center')
-        gui.display.clear()
-        gui.display.add_child(msg)
-        gui.display.update()
+        gui.get_display().clear()
+        gui.get_display().add_child(msg)
+        gui.get_display().update()
 
         
     def shutdown_freevo(self):

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to