home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / gedit-2 / plugins / snippets / __init__.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.9 KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import os
  6. import shutil
  7. import gtk
  8. from gtk import gdk
  9. import gedit
  10. import platform
  11. from WindowHelper import WindowHelper
  12. from Library import Library
  13. from Manager import Manager
  14. from Snippet import Snippet
  15.  
  16. class SnippetsPlugin(gedit.Plugin):
  17.     
  18.     def __init__(self):
  19.         gedit.Plugin.__init__(self)
  20.         self.dlg = None
  21.         library = Library()
  22.         library.set_accelerator_callback(self.accelerator_activated)
  23.         if platform.platform() == 'Windows':
  24.             userdir = os.path.expanduser('~/gedit/snippets')
  25.         else:
  26.             userdir = os.path.expanduser('~/.gnome2/gedit/snippets')
  27.         library.set_dirs(userdir, self.system_dirs())
  28.  
  29.     
  30.     def system_dirs(self):
  31.         if platform.platform() != 'Windows':
  32.             if 'XDG_DATA_DIRS' in os.environ:
  33.                 datadirs = os.environ['XDG_DATA_DIRS']
  34.             else:
  35.                 datadirs = '/usr/local/share:/usr/share'
  36.             dirs = []
  37.             for d in datadirs.split(':'):
  38.                 d = os.path.join(d, 'gedit-2', 'plugins', 'snippets')
  39.                 if os.path.isdir(d):
  40.                     dirs.append(d)
  41.                     continue
  42.             
  43.         
  44.         dirs.append(self.get_data_dir())
  45.         return dirs
  46.  
  47.     
  48.     def activate(self, window):
  49.         data = WindowHelper(self)
  50.         window._snippets_plugin_data = data
  51.         data.run(window)
  52.  
  53.     
  54.     def deactivate(self, window):
  55.         window._snippets_plugin_data.stop()
  56.         window._snippets_plugin_data = None
  57.  
  58.     
  59.     def update_ui(self, window):
  60.         window._snippets_plugin_data.update()
  61.  
  62.     
  63.     def create_configure_dialog(self):
  64.         if not self.dlg:
  65.             self.dlg = Manager(self.get_data_dir())
  66.         else:
  67.             self.dlg.run()
  68.         window = gedit.app_get_default().get_active_window()
  69.         if window:
  70.             self.dlg.dlg.set_transient_for(window)
  71.         
  72.         return self.dlg.dlg
  73.  
  74.     
  75.     def accelerator_activated(self, group, obj, keyval, mod):
  76.         if hasattr(obj, '_snippets_plugin_data'):
  77.             obj._snippets_plugin_data.accelerator_activated(keyval, mod)
  78.         
  79.  
  80.  
  81.