[Rhythmbox-devel] capture middle click in plugin



I've managed to get my GUI working on my other plugin and have got
actions for buttons and all that so things are going well there.

I've been looking at writing another plugin but can't find any
information on how to run on mouse clicks. (It's all from buttons, etc
online)
Basically I want to write a plugin that can perform actions on a
middle click of the mouse which i'll build on once i get it running.

I think the problem is in capture_click but haven't been able to find
anything to help..

Here's my code that i've written up so far today:

class middleclick(rb.Plugin):

    def __init__(self):
        rb.Plugin.__init__(self)

    # Rhythmbox standard Activate method
    def activate(self, shell):
        self.shell = shell
        self.capture_click(shell)

    # Rhythmbox standard Deactivate method
    def deactivate(self, shell):
        self.shell = None

    # Run test_plugin for middle click
    def capture_click(self, shell):
        self.action = gtk.Action('MiddleClick', _('Middle Click'),
_('Action on Middle Click'), gtk.gdk.BUTTON_PRESS_MASK)
        self.action.connect('activate', self.test_plugin, shell)
        self.action_group = gtk.ActionGroup('OnClickActions')
        self.action_group.add_action(self.action)
        uim = shell.get_ui_manager()
        uim.insert_action_group(self.action_group, 0)
        uim.ensure_update()

    def test_plugin(self, shell):
        if event.button == 2:
            print 'THIS IS AN EVENT'


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]