home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / deskbar / Keybinder.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  2.4 KB  |  72 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import gtk
  5. import gobject
  6. import gconf
  7. import deskbar
  8. import deskbar.keybinder as deskbar
  9.  
  10. class Keybinder(gobject.GObject):
  11.     __gsignals__ = {
  12.         'activated': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
  13.             gobject.TYPE_ULONG]),
  14.         'changed': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
  15.             gobject.TYPE_BOOLEAN]) }
  16.     
  17.     def __init__(self):
  18.         gobject.GObject.__init__(self)
  19.         self.bound = False
  20.         self.keybinding = deskbar.GCONF_CLIENT.get_string(deskbar.GCONF_KEYBINDING)
  21.         if self.keybinding == None:
  22.             self.keybinding = '<Alt>F3'
  23.         
  24.         deskbar.GCONF_CLIENT.notify_add(deskbar.GCONF_KEYBINDING, (lambda x, y, z, a: self.on_config_keybinding(z.value)))
  25.         self.bind()
  26.  
  27.     
  28.     def on_config_keybinding(self, value = None):
  29.         if value != None and value.type == gconf.VALUE_STRING:
  30.             self.keybinding = value.get_string()
  31.             self.bind()
  32.         
  33.  
  34.     
  35.     def on_keyboard_shortcut(self):
  36.         self.emit('activated', deskbar.keybinder.tomboy_keybinder_get_current_event_time())
  37.  
  38.     
  39.     def bind(self):
  40.         if self.bound:
  41.             self.unbind()
  42.         
  43.         
  44.         try:
  45.             print 'Binding Global shortcut %s to focus the deskbar' % self.keybinding
  46.             deskbar.keybinder.tomboy_keybinder_bind(self.keybinding, self.on_keyboard_shortcut)
  47.             self.bound = True
  48.         except KeyError:
  49.             self.bound = False
  50.  
  51.         self.emit('changed', self.bound)
  52.  
  53.     
  54.     def unbind(self):
  55.         
  56.         try:
  57.             deskbar.keybinder.tomboy_keybinder_unbind(self.keybinding)
  58.             self.bound = False
  59.         except KeyError:
  60.             pass
  61.  
  62.  
  63.  
  64. if gtk.pygtk_version < (2, 8, 0):
  65.     gobject.type_register(Keybinder)
  66.  
  67. keybinder = Keybinder()
  68.  
  69. def get_deskbar_keybinder():
  70.     return keybinder
  71.  
  72.