Changeset 9737

Show
Ignore:
Timestamp:
06/02/08 01:33:51 (3 months ago)
Author:
vardo
Message:

Initial commit related to plug-in system:
- basic PluginManager? class that loads plugins from *.py files

in given directories

- Singleton metaclass was created to use with PluginManager?;

notice: init of class is called only once (not like in code

that is included in Python Cookbook)

- variable to keep paths of plugin directories has been created

(common.gajim.PLUGINS_DIRS); also added initilization of these
paths to common.ConfigPaths?

- added global variable with PluginManager? object:

common.gajim.plugin_manager

- created customized logger for plugin system ('gajim.plugin_system')
- created function decorator plugins.helpers.log_calls which logs

each call of function/method; it also logs when function is left

- base class Plugin for plug-in implementation added; not much

here - only empty class attributes: name, short_name, authors,

version, description

- based on Plugin class, first plugin was created named

LengthNotifierPlugin?; it is used to notify users when they
exceed given length of message during writing it (text entry
field highlights)

- first GUI extension points works when ChatControl? object

is created (it is used in mentioned plugin)

- added 'epydoc.conf' file customized a little bit (file

is also in trunk now)

- fixed indentation in common.sleepy module (also in trunk

now)

Location:
branches/plugin-system
Files:
10 added
5 modified

Legend:

Unmodified
Added
Removed
  • branches/plugin-system/src/chat_control.py

    r9695 r9737  
    11401140                # restore previous conversation 
    11411141                self.restore_conversation() 
     1142                 
     1143                gajim.plugin_manager.gui_extension_point('chat_control', self) 
    11421144 
    11431145        def on_avatar_eventbox_enter_notify_event(self, widget, event): 
  • branches/plugin-system/src/common/configpaths.py

    r9095 r9737  
    9393                self.add('HOME', fse(os.path.expanduser('~'))) 
    9494                self.add('TMP', fse(tempfile.gettempdir())) 
     95                 
     96                # dirs for plugins 
     97                self.add('PLUGINS_BASE', os.path.join(u'..', windowsify(u'plugins'))) 
     98                self.add_from_root('PLUGINS_USER', u'plugins') 
    9599 
    96100                try: 
  • branches/plugin-system/src/common/gajim.py

    r9699 r9737  
    6262verbose = False 
    6363ipython_window = None 
     64plugin_manager = None 
    6465 
    6566h = logging.StreamHandler() 
     
    8687DATA_DIR = gajimpaths['DATA'] 
    8788HOME_DIR = gajimpaths['HOME'] 
     89PLUGINS_DIRS = [gajimpaths['PLUGINS_BASE'], 
     90                                gajimpaths['PLUGINS_USER']] 
    8891 
    8992try: 
  • branches/plugin-system/src/common/sleepy.py

    r8972 r9737  
    3636SUPPORTED = True 
    3737try: 
    38                 if os.name == 'nt': 
    39                         import ctypes 
     38        if os.name == 'nt': 
     39                import ctypes 
    4040 
    41                         GetTickCount = ctypes.windll.kernel32.GetTickCount 
    42                         GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo 
     41                GetTickCount = ctypes.windll.kernel32.GetTickCount 
     42                GetLastInputInfo = ctypes.windll.user32.GetLastInputInfo 
    4343 
    44                         class LASTINPUTINFO(ctypes.Structure): 
    45                                 _fields_ = [('cbSize', ctypes.c_uint), ('dwTime', ctypes.c_uint)] 
     44                class LASTINPUTINFO(ctypes.Structure): 
     45                        _fields_ = [('cbSize', ctypes.c_uint), ('dwTime', ctypes.c_uint)] 
    4646 
    47                         lastInputInfo = LASTINPUTINFO() 
    48                         lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) 
     47                lastInputInfo = LASTINPUTINFO() 
     48                lastInputInfo.cbSize = ctypes.sizeof(lastInputInfo) 
    4949 
    50                 elif sys.platform == 'darwin': 
    51                         import osx.idle as idle 
    52                 else: # unix 
    53                         import idle 
     50        elif sys.platform == 'darwin': 
     51                import osx.idle as idle 
     52        else: # unix 
     53                import idle 
    5454except: 
    5555        gajim.log.debug('Unable to load idle module') 
  • branches/plugin-system/src/gajim.py

    r9699 r9737  
    34623462                gobject.timeout_add_seconds(gajim.config.get( 
    34633463                        'check_idle_every_foo_seconds'), self.read_sleepy) 
     3464                 
     3465                # Creating plugin manager 
     3466                import plugins 
     3467                gajim.plugin_manager = plugins.PluginManager() 
    34643468 
    34653469if __name__ == '__main__':