Changeset 187

Show
Ignore:
Timestamp:
05/07/06 15:16:34 (3 years ago)
Author:
nicfit
Message:

Hacking on plugin configurations launched from Preference window

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Makefile.in

    r173 r187  
    6161        install -m 755 -d ${libdir}/plugins 
    6262        install -m 644 ./src/plugins/*.py ${libdir}/plugins 
    63         #install -m 644 ./src/plugins/*.glade ${libdir}/plugins 
     63        install -m 644 ./src/plugins/*.glade ${libdir}/plugins 
    6464 
    6565        install -m 755 -d ${docdir} 
  • trunk/src/main.py

    r186 r187  
    6464                        help=_('Select a specific profile other than ' 
    6565                               'the default'), 
    66                         metavar='PROFILE', default=None
     66                        metavar='PROFILE', default=''
    6767 
    6868    (opts, args) = cmd_line.parse_args() 
    6969 
    7070    # Load config 
    71     profile = Non
     71    profile = opts.profil
    7272    if opts.profile: 
    73         profile = opts.profile 
    74         config_file = '%s/config.%s' % (mesk.MESK_DIR, profile) 
     73        config_file = '%s/config.%s' % (mesk.MESK_DIR, opts.profile) 
    7574    else: 
    7675        config_file = '%s/config' % (mesk.MESK_DIR) 
    7776    try: 
    78         mesk.config.load(config_file
     77        mesk.config.load(config_file, opts.profile
    7978    except IOError: 
    8079        first_run = True 
  • trunk/src/mesk/common/config.py

    r122 r187  
    4949                self.set(section, opt, opt_val) 
    5050 
    51     def load(self, config_file): 
     51    def load(self, config_file, profile_name = ''): 
     52        self.profile = profile_name 
    5253        file_config = ConfigParser.ConfigParser() 
    5354        file_config.readfp(file(config_file, 'r')) 
  • trunk/src/mesk/plugin/__init__.py

    r186 r187  
    9090 
    9191    def shutdown(self): 
    92         pass 
     92        '''Called when the plugin is shutdown or deactivated''' 
     93 
     94    def configure(self): 
     95        '''Plugin implementations should show a config window when called''' 
    9396 
    9497class PluginMgr: 
     
    131134            mesk.log.warning(_('Plugin not found: %s') % name) 
    132135 
    133     def get_registry(self): 
     136    def get_plugin_registry(self): 
    134137        registry = [] 
    135138        for plugin in self.__plugin_registry.values(): 
     
    146149                plugins.append(p) 
    147150        return plugins 
     151 
     152    def get_plugin(self, name): 
     153        try: 
     154            return self.__plugins[name] 
     155        except: 
     156            return None 
    148157 
    149158    def activate_plugin(self, plugin_name): 
  • trunk/src/mesk_gui.glade

    r184 r187  
    13371337                                      <property name="relief">GTK_RELIEF_NORMAL</property> 
    13381338                                      <property name="focus_on_click">True</property> 
     1339                                      <signal name="clicked" handler="_on_plugin_config_button_clicked" last_modification_time="Sun, 07 May 2006 20:37:23 GMT"/> 
    13391340 
    13401341                                      <child> 
  • trunk/src/plugins/audioscrobbler.py

    r181 r187  
    2424import threading 
    2525import pickle 
     26import gtk, gtk.glade 
    2627 
    2728import mesk 
     
    4748 
    4849CONFIG_SECTION = NAME 
    49 QUEUE_FILE = '/var/tmp/mesk_audioscrobbler_queue.dat' 
    5050MAX_SUBMIT = 10 
    5151 
     
    6565        self.queue_lock = threading.Lock() 
    6666        self.queue = [] 
     67        profile = '' 
     68        if mesk.config.profile: 
     69            profile = '_%s' % mesk.config.profile 
    6770        self.queue_filename = mesk.MESK_DIR + os.sep + 'tmp' + os.sep + \ 
    68                               ('%s.queue' % NAME
     71                              ('%s%s.queue' % (NAME, profile)
    6972 
    7073        self.may_submit = threading.Event() 
     
    9295            os.makedirs(q_dir) 
    9396 
     97        self._config_window = None 
     98 
    9499    def shutdown(self): 
    95100        self.log.debug('Shutting down...') 
     
    100105        self.log.info(_('Saving %d queued items') % len(self.queue)) 
    101106        pickle.dump(self.queue, open(self.queue_filename, 'w')) 
     107 
     108    def configure(self): 
     109        if self._config_window is None: 
     110            xml = gtk.glade.XML('./plugins/plugins_gui.glade', 
     111                                'audioscrobbler_window', 'mesk') 
     112            xml.signal_autoconnect(self) 
     113            self._config_window = xml.get_widget('audioscrobbler_window') 
     114        self._config_window.show() 
    102115 
    103116    def get_md5(self, s): 
  • trunk/src/preference_window.py

    r184 r187  
    7171 
    7272        # Populate plugins list 
    73         self._plugins = mesk.plugin.get_manager().get_registry() 
     73        self._plugins = mesk.plugin.get_manager().get_plugin_registry() 
    7474        active_plugins = mesk.plugin.get_manager().get_active_plugins() 
    7575        if self._plugins: 
     
    118118        self._copyright_label.set_text(plugin['COPYRIGHT']) 
    119119        self._url_label.set_text(plugin['URL']) 
     120 
     121        # TODO: Hide config button if plugin does not support configuration 
    120122        is_active = treeview.get_model()[row][0] 
    121123        self._config_button.set_sensitive(is_active) 
     
    123125    def _on_plugin_toggled(self, cell, path, model): 
    124126        new_state = model[path][0] = not model[path][0] 
     127 
     128    def _on_plugin_config_button_clicked(self, button): 
     129        selected_row = self._plugins_view.get_cursor()[0][0] 
     130        selected_plugin = self._plugins[selected_row] 
     131        plugin = mesk.plugin.get_manager().get_plugin(selected_plugin['NAME']) 
     132        plugin.configure()