On Sat, Mar 11, 2006 at 05:34:06PM +0100, Dirk Meyer wrote:
> "TheHog" wrote:
> > Hi,
> >
> > I'm writing a plugin for freevo. One of the menu items should be a toggle
> > item, i.e. it should switch between "disabled" and "enabled". i cannot 
> > figure
> > out how this can best be done. Could you please give a short description?
> 
> Well, only with a bad hack.
> 

I have done something similar.
It changes the text of a submenu entry and redraws the skin.

The plugin is here:

http://helvete.escomposlinux.org/~gorka/files/misoft/freevo/mplayer_aspectratio.py


A relevant excerpt of the code:

 def aspect(self, arg=None, menuw=None):

        self.cnt += 1
        self.ratio = self.ratios[self.cnt % len(self.ratios)]

        if self.ratio == self.ratios[0]:
            config.MPLAYER_ARGS_DEF = self.args_def
        else:
            config.MPLAYER_ARGS_DEF = (self.args_def + ' -aspect ' + 
self.ratio)        _debug_('Aspect command string for mplayer:  %s' % 
config.MPLAYER_ARGS_DEF)
        if self.ratio == self.ratios[0]:
            str = self.default_str
        else:
            str = self.ratio

        self.title = self.title_def % str

        menuw.menustack[-1].selected.name = self.title
        self.skin.force_redraw = True
        self.skin.draw('menu', menuw)


    def actions(self, item):
        self.item = item
        myactions = []

        if item.type == 'video':
            myactions.append((self.aspect, self.title))

        return myactions

-- 

Attachment: signature.asc
Description: Digital signature

Reply via email to