home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / deskbar-applet / handlers / iswitch-window.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2007-04-29  |  3.6 KB  |  93 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from gettext import gettext as _
  5. from gettext import ngettext
  6. from deskbar.defs import VERSION
  7. import wnck
  8. import gtk
  9. import deskbar.Handler as deskbar
  10. import deskbar.Match as deskbar
  11. import deskbar
  12. import re
  13. import cgi
  14. HANDLERS = {
  15.     'ISwitchWindowHandler': {
  16.         'name': _('Window Switcher'),
  17.         'description': _('Switch to an existing window by name.'),
  18.         'categories': {
  19.             'windows': {
  20.                 'name': _('Windows') } },
  21.         'version': VERSION } }
  22.  
  23. class ISwitchWindowMatch(deskbar.Match.Match):
  24.     
  25.     def __init__(self, handler, window = None, pixbuf = None, **args):
  26.         deskbar.Match.Match.__init__(self, handler, **args)
  27.         self.name = cgi.escape(self.name)
  28.         self._icon = pixbuf
  29.         self._window = window
  30.  
  31.     
  32.     def get_verb(self):
  33.         return _('Switch to <b>%(name)s</b>')
  34.  
  35.     
  36.     def action(self, text = None):
  37.         if self._window.is_active():
  38.             return None
  39.         
  40.         
  41.         try:
  42.             time = gtk.get_current_event().time
  43.         except:
  44.             print 'WARNING, iSwitchWindow : Using bogus timestamp.'
  45.             time = gtk.get_current_event_time()
  46.  
  47.         if hasattr(self._window.get_workspace(), 'activate') and self._window.get_workspace() != self._window.get_screen().get_active_workspace():
  48.             self._window.get_workspace().activate(time)
  49.         
  50.         self._window.activate(time)
  51.  
  52.     
  53.     def get_category(self):
  54.         return 'windows'
  55.  
  56.     
  57.     def get_hash(self, text = None):
  58.         return self.name
  59.  
  60.     
  61.     def serialize(self):
  62.         pass
  63.  
  64.     
  65.     def skip_history(self):
  66.         return True
  67.  
  68.  
  69.  
  70. class ISwitchWindowHandler(deskbar.Handler.Handler):
  71.     
  72.     def __init__(self):
  73.         deskbar.Handler.Handler.__init__(self, 'panel-window-menu.png')
  74.  
  75.     
  76.     def query(self, query):
  77.         results = []
  78.         query = query.lower()
  79.         for w in wnck.screen_get_default().get_windows_stacked():
  80.             if w.is_skip_tasklist():
  81.                 continue
  82.             
  83.             for name in (w.get_name().lower(), w.get_application().get_name().lower()):
  84.                 if name.find(query) != -1:
  85.                     results.append(ISwitchWindowMatch(self, name = name, window = w, pixbuf = w.get_mini_icon()))
  86.                     break
  87.                     continue
  88.             
  89.         
  90.         return results
  91.  
  92.  
  93.