Changeset 9762

Show
Ignore:
Timestamp:
06/07/08 19:28:34 (4 months ago)
Author:
vardo
Message:

Added first version of 'Plugins' window. It's accessible through 'Edit/Plugins' item in roster menu. It seems that you can successfully (de)activate plug-ins through GUI now.

Added 'homepage' attribute to Plugin class.

Added (commented out) calls of pycallgraph in src/gajim.py for later use.

[xbright] Changed 'python' to 'python2.5' because code uses modules not available in previous versions of Python.

Location:
branches/plugin-system
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • branches/plugin-system/data/glade/roster_window.glade

    r9521 r9762  
    194194                      </widget> 
    195195                    </child> 
     196                    <child> 
     197                      <widget class="GtkImageMenuItem" id="plugins_menuitem"> 
     198                        <property name="visible">True</property> 
     199                        <property name="label" translatable="yes">P_lugins</property> 
     200                        <property name="use_underline">True</property> 
     201                        <signal name="activate" handler="on_plugins_menuitem_activate"/> 
     202                        <child internal-child="image"> 
     203                          <widget class="GtkImage" id="menu-item-image16"> 
     204                            <property name="visible">True</property> 
     205                            <property name="stock">gtk-disconnect</property> 
     206                            <property name="icon_size">1</property> 
     207                          </widget> 
     208                        </child> 
     209                      </widget> 
     210                    </child> 
    196211                  </widget> 
    197212                </child> 
  • branches/plugin-system/launch.sh

    r9680 r9762  
    1616 
    1717cd ${BASE}/src 
    18 exec -a gajim python -t gajim.py $@ 
     18exec -a gajim python2.5 -t gajim.py $@ 
  • branches/plugin-system/plugins/length_notifier.py

    r9754 r9762  
    3333 
    3434class LengthNotifierPlugin(GajimPlugin): 
    35         name = 'Message Length Notifier' 
    36         short_name = 'length_notifier' 
    37         version = '0.1' 
    38         description = '''Highlights message entry field in chat window when given  
    39 length of message is exceeded.''' 
    40         authors = ['Mateusz Biliński <mateusz@bilinski.it>'] 
     35        name = u'Message Length Notifier' 
     36        short_name = u'length_notifier' 
     37        version = u'0.1' 
     38        description = u'''Highlights message entry field in chat window when given length of message is exceeded.''' 
     39        authors = [u'Mateusz Biliński <mateusz@bilinski.it>'] 
     40        homepage = u'http://blog.bilinski.it' 
    4141 
    4242        @log_calls('LengthNotifierPlugin') 
  • branches/plugin-system/src/gajim.py

    r9752 r9762  
    2727 
    2828import os 
     29import pycallgraph 
     30 
    2931 
    3032if os.name == 'nt': 
     
    603605                import osx 
    604606                osx.shutdown() 
     607         
     608        #pycallgraph.make_dot_graph('common.xmpp-only.dot', format='dot') 
    605609 
    606610import atexit 
     
    32323236 
    32333237        def __init__(self): 
     3238                #filter_func = pycallgraph.GlobbingFilter(include=['common.xmpp.*']) 
     3239                #pycallgraph.start_trace(filter_func=filter_func) 
     3240                 
    32343241                gajim.interface = self 
    32353242                # This is the manager and factory of message windows set by the module 
  • branches/plugin-system/src/plugins/pluginmanager.py

    r9754 r9762  
    9595 
    9696                for path in gajim.PLUGINS_DIRS: 
    97                         self.plugins.extend(PluginManager.scan_dir_for_plugins(path)) 
     97                        self._add_plugins(PluginManager.scan_dir_for_plugins(path)) 
    9898 
    9999                log.debug('plugins: %s'%(self.plugins)) 
     
    103103                log.debug('active: %s'%(self.active_plugins)) 
    104104 
     105                 
     106        @log_calls('PluginManager') 
     107        def _add_plugin(self, plugin_class): 
     108                ''' 
     109                :todo: what about adding plug-ins that are already added? Module reload 
     110                and adding class from reloaded module or ignoring adding plug-in? 
     111                ''' 
     112                plugin_class._active = False 
     113                plugin_class._instance = None 
     114                self.plugins.append(plugin_class) 
     115         
     116        @log_calls('PluginManager') 
     117        def _add_plugins(self, plugin_classes): 
     118                for plugin_class in plugin_classes: 
     119                        self._add_plugin(plugin_class) 
     120                 
    105121        @log_calls('PluginManager') 
    106122        def gui_extension_point(self, gui_extpoint_name, *args): 
     
    125141                        Looking closer - we only rewrite tuples here. Real check should be 
    126142                        made in method that invokes gui_extpoints handlers. 
    127  
    128143                ''' 
    129144 
     
    142157 
    143158        @log_calls('PluginManager') 
    144         def activate_plugin(self, plugin): 
     159        def activate_plugin(self, plugin_class): 
    145160                ''' 
    146161                :param plugin: plugin to be activated 
     
    148163                ''' 
    149164                 
    150                 plugin_object = plugin() 
     165                plugin_object = plugin_class() 
    151166 
    152167                success = True 
     
    157172                if success: 
    158173                        self.active_plugins.append(plugin_object) 
     174                        plugin_class._instance = plugin_object 
     175                        plugin_class._active = True 
    159176 
    160177                return success 
     
    166183                for gui_extpoint_name, gui_extpoint_handlers in \ 
    167184                                plugin_object.gui_extension_points.iteritems(): 
    168                         for gui_extension_point_args in self.gui_extension_points[gui_extpoint_name]: 
    169                                 gui_extpoint_handlers[1](*gui_extension_point_args) 
     185                        if gui_extpoint_name in self.gui_extension_points: 
     186                                for gui_extension_point_args in self.gui_extension_points[gui_extpoint_name]: 
     187                                        gui_extpoint_handlers[1](*gui_extension_point_args) 
    170188                                 
    171189                # remove GUI extension points handlers (provided by plug-in) from 
     
    177195                # removing plug-in from active plug-ins list 
    178196                self.active_plugins.remove(plugin_object) 
     197                plugin_object.__class__._active = False 
     198                del plugin_object 
    179199                 
    180200        def deactivate_all_plugins(self): 
  • branches/plugin-system/src/plugins/plugin.py

    r9745 r9762  
    3131        Base class for implementing Gajim plugins. 
    3232        ''' 
    33         name = '' 
     33        name = u'' 
    3434        ''' 
    3535        Name of plugin. 
     
    3939        :type: unicode 
    4040        ''' 
    41         short_name = '' 
     41        short_name = u'' 
    4242        ''' 
    4343        Short name of plugin. 
     
    5050                module name) can act as such short name          
    5151        ''' 
    52         version = '' 
     52        version = u'' 
    5353        ''' 
    5454        Version of plugin. 
     
    6262                one to be active - is such policy good? 
    6363        ''' 
    64         description = '' 
     64        description = u'' 
    6565        ''' 
    6666        Plugin description. 
     
    7979                Especially: should we force format of giving author's e-mail? 
    8080        ''' 
     81        homepage = u'' 
     82        ''' 
     83        URL to plug-in's homepage. 
     84         
     85        :type: unicode 
     86         
     87        :todo: should we check whether provided string is valid URI? (Maybe 
     88        using 'property') 
     89        ''' 
    8190        gui_extension_points = {} 
    8291        ''' 
  • branches/plugin-system/src/roster_window.py

    r9745 r9762  
    4545import notify 
    4646import features_window 
     47import plugins 
     48import plugins.gui 
    4749 
    4850from common import gajim 
     
    31303132                else: 
    31313133                        gajim.interface.instances['preferences'] = config.PreferencesWindow() 
     3134                         
     3135        def on_plugins_menuitem_activate(self, widget): 
     3136                if gajim.interface.instances.has_key('plugins'): 
     3137                        gajim.interface.instances['plugins'].window.present() 
     3138                else: 
     3139                        gajim.interface.instances['plugins'] = plugins.gui.PluginsWindow() 
    31323140 
    31333141        def on_publish_tune_checkbutton_toggled(self, widget, account):