Changeset 9823

Show
Ignore:
Timestamp:
06/19/08 14:56:45 (6 months ago)
Author:
vardo
Message:

Added GajimPluginConfigDialog? class - dialog that plugins should use to present configuration to user.
Now, 'Configure' button is invoked only for plug-ins that have config_dialog.

Location:
branches/plugin-system
Files:
6 modified

Legend:

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

    r9792 r9823  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    22<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> 
    3 <!--Generated with glade3 3.4.5 on Mon Jun  9 15:22:01 2008 --> 
     3<!--Generated with glade3 3.4.5 on Thu Jun 19 13:11:54 2008 --> 
    44<glade-interface> 
    55  <widget class="GtkWindow" id="plugins_window"> 
     
    243243                            <property name="receives_default">True</property> 
    244244                            <property name="response_id">0</property> 
     245                            <signal name="clicked" handler="on_uninstall_plugin_button_clicked"/> 
    245246                            <child> 
    246247                              <widget class="GtkHBox" id="hbox11"> 
     
    271272                            <property name="receives_default">True</property> 
    272273                            <property name="response_id">0</property> 
     274                            <signal name="clicked" handler="on_configure_plugin_button_clicked"/> 
    273275                            <child> 
    274276                              <widget class="GtkHBox" id="hbox12"> 
  • branches/plugin-system/plugins/acronyms_expander.py

    r9821 r9823  
    4545                 
    4646        def init(self): 
     47                self.config_dialog = None 
     48                 
    4749                self.gui_extension_points = { 
    4850                        'chat_control_base' : (self.connect_with_chat_control_base, 
  • branches/plugin-system/plugins/length_notifier.py

    r9821 r9823  
    4646        @log_calls('LengthNotifierPlugin') 
    4747        def init(self): 
     48                #self.config_dialog = None 
     49                 
    4850                self.gui_extension_points = { 
    4951                        'chat_control' : (self.connect_with_chat_control, 
  • branches/plugin-system/plugins/roster_buttons/plugin.py

    r9821 r9823  
    5353                self.roster_vbox = gajim.interface.roster.xml.get_widget('roster_vbox2') 
    5454                self.show_offline_contacts_menuitem = gajim.interface.roster.xml.get_widget('show_offline_contacts_menuitem') 
     55                 
     56                self.config_dialog = None 
    5557         
    5658        @log_calls('RosterButtonsPlugin') 
  • branches/plugin-system/src/plugins/gui.py

    r9821 r9823  
    118118                self.plugin_description_textview.set_property('sensitive', True) 
    119119                self.uninstall_plugin_button.set_property('sensitive', True) 
    120                 self.configure_plugin_button.set_property('sensitive', True) 
     120                if plugin.config_dialog is None: 
     121                        self.configure_plugin_button.set_property('sensitive', False) 
     122                else: 
     123                        self.configure_plugin_button.set_property('sensitive', True) 
    121124                 
    122125        def _clear_installed_plugin_info(self): 
     
    165168        def on_close_button_clicked(self, widget): 
    166169                self.window.destroy() 
     170         
     171        @log_calls('PluginsWindow') 
     172        def on_configure_plugin_button_clicked(self, widget): 
     173                log.debug('widget: %s'%(widget)) 
     174                selection = self.installed_plugins_treeview.get_selection() 
     175                model, iter = selection.get_selected() 
     176                if iter: 
     177                        plugin = model.get_value(iter, 0) 
     178                        plugin_name = model.get_value(iter, 1) 
     179                        is_active = model.get_value(iter, 2) 
     180                         
     181 
     182                        result = plugin.config_dialog.run(self.window) 
     183 
     184                else: 
     185                        # No plugin selected. this should never be reached. As configure 
     186                        # plugin button should only my clickable when plugin is selected. 
     187                        # XXX: maybe throw exception here? 
     188                        pass 
     189         
     190        @log_calls('PluginsWindow') 
     191        def on_uninstall_plugin_button_clicked(self, widget): 
     192                pass 
     193 
     194         
     195class GajimPluginConfigDialog(gtk.Dialog): 
     196         
     197        @log_calls('GajimPluginConfigDialog') 
     198        def __init__(self, plugin, **kwargs): 
     199                # TRANSLATORS: The window title for the generic configuration dialog of plugins 
     200                gtk.Dialog.__init__(self, '%s : %s'%(_('Configuration'), plugin.name), **kwargs) 
     201                self.plugin = plugin 
     202                self.add_button('gtk-close', gtk.RESPONSE_CLOSE) 
     203         
     204                self.main = self.child 
     205                self.main.set_spacing(3) 
     206         
     207                # TRANSLATORS: Short text stating which plugin a configuration dialog is for 
     208                label = gtk.Label(_('<b>%s Configuration</b>') % (plugin.name)) 
     209                label.set_markup(label.get_label()) 
     210                self.main.pack_start(label, False, False) 
     211                 
     212        @log_calls('GajimPluginConfigDialog') 
     213        def run(self, parent=None): 
     214                self.reparent(parent) 
     215                self.show_all() 
     216                result =  super(GajimPluginConfigDialog, self).run() 
     217                self.hide() 
     218                return result 
     219         
  • branches/plugin-system/src/plugins/plugin.py

    r9821 r9823  
    2828 
    2929from plugins.helpers import log_calls 
     30from plugins.gui import GajimPluginConfigDialog 
    3031 
    3132class GajimPlugin(object): 
     
    9798        @log_calls('GajimPlugin') 
    9899        def __init__(self): 
    99                 self.config = Config() 
     100                self.config = GajimPluginConfig() 
    100101                ''' 
    101102                Plug-in configuration dictionary. 
     
    103104                Automatically saved and loaded and plug-in (un)load. 
    104105                 
    105                 :type: `plugins.plugin.Config` 
     106                :type: `plugins.plugin.GajimPluginConfig` 
    106107                ''' 
    107108                self.load_config() 
     109                self.config_dialog = GajimPluginConfigDialog(self) 
    108110                self.init() 
    109111         
    110112        @log_calls('GajimPlugin') 
    111113        def save_config(self): 
    112                 pass 
     114                self.config.save() 
    113115         
    114116        @log_calls('GajimPlugin')        
    115117        def load_config(self): 
    116                 pass 
     118                self.config.load() 
    117119         
    118120        @log_calls('GajimPlugin') 
    119121        def __del__(self): 
    120                 self._save_config() 
     122                self.save_config() 
    121123                 
    122124        @log_calls('GajimPlugin') 
     
    136138                pass 
    137139 
    138 class Config(dict): 
    139         pass 
     140class GajimPluginConfig(dict): 
     141        @log_calls('GajimPluginConfig') 
     142        def save(self): 
     143                pass 
     144         
     145        @log_calls('GajimPluginConfig') 
     146        def load(self): 
     147                pass