home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 June / CHIP 2006-06.2.iso / program / freeware / Democracy-0.8.2.exe / xulrunner / python / frontend_implementation / MainFrame.py < prev    next >
Encoding:
Python Source  |  2006-04-10  |  2.7 KB  |  76 lines

  1. import frontend
  2. from xpcom import components
  3. import threading
  4. from util import quoteJS
  5.  
  6. ###############################################################################
  7. #### Main window                                                           ####
  8. ###############################################################################
  9.  
  10. class MainFrame:
  11.     def __init__(self, appl):
  12.         # Symbols by other parts of the program as as arguments
  13.         # to selectDisplay
  14.         self.mainDisplay = "mainDisplay"
  15.         self.channelsDisplay = "channelsDisplay"
  16.         self.videoInfoDisplay = "videoInfoDisplay"
  17.  
  18.         # Displays selected in each area, for generating deselection
  19.         # messages.
  20.         self.selectedDisplays = {}
  21.  
  22.     def selectDisplay(self, newDisplay, area):
  23.         """Install the provided 'newDisplay' in the requested area"""
  24.  
  25.     # Generate a deselection message for the previously selected
  26.     # display in this area, if any
  27.         if area in self.selectedDisplays:
  28.             oldDisplay = self.selectedDisplays[area]
  29.             if oldDisplay:
  30.                 oldDisplay.onDeselected_private(self)
  31.                 oldDisplay.onDeselected(self)
  32.  
  33.     # Generate a selection message for the new display, if any
  34.         self.selectedDisplays[area] = newDisplay
  35.     if newDisplay:
  36.         newDisplay.onSelected_private(self)
  37.         newDisplay.onSelected(self)
  38.  
  39.         # NEEDS: case out instances for HTMLDisplay and VideoDisplay
  40.         self.selectHTML(newDisplay, area)
  41.  
  42.     def selectHTML(self, display, area):
  43.         newURL = display.getURL()
  44.         # make the display load newURL. that's it!
  45.  
  46.         frontend.execChromeJS("navigateDisplay('%s', '%s');" % \
  47.                               (quoteJS(area), quoteJS(newURL)))
  48.  
  49.     def selectURL(self, url, area):
  50.     # Generate a deselection message for the previously selected
  51.     # display in this area, if any
  52.         if area in self.selectedDisplays:
  53.             oldDisplay = self.selectedDisplays[area]
  54.             if oldDisplay:
  55.                 oldDisplay.onDeselected_private(self)
  56.                 oldDisplay.onDeselected(self)
  57.             self.selectedDisplays[area] = None
  58.  
  59.         # Now just make Mozilla load the new URL over there
  60.         frontend.execChromeJS("navigateDisplay('%s', '%s');" % \
  61.                               (quoteJS(area), quoteJS(url)))
  62.  
  63.     # Internal use: return an estimate of the size of a given display area
  64.     # as a (width, height) pair, or None if no information's available.
  65.     def getDisplaySizeHint(self, area):
  66.     return None
  67.  
  68.     def unlink(self):
  69.         pass
  70.  
  71.     def __del__(self):
  72.         self.unlink()
  73.  
  74. ###############################################################################
  75. ###############################################################################
  76.