[Deskbar] Module with multiple actions



I'm trying to extend one of my existing modules to support multiple
actions.  I'm using a single match with multiple "add_actions".  Unless
I include one of the stock actions, CopyToClipboardAction for example,
Deskbar seems to pick the first action and ignore the rest.  I'm
probably doing something horribly wrong, can anyone help?  I've attached
a very simple test module that attempts to show what I am doing.

Thanks.

-- 
Matthew Gregg <mcg braintube com>
#
#  test.py : Test multiple actions.
#

import deskbar, deskbar.core.Indexer, deskbar.interfaces.Module, deskbar.core.Utils, deskbar.interfaces.Match, deskbar.interfaces.Action
from gettext import gettext as _ 
_debug=False
if _debug:
    import traceback

HANDLERS = ["TestHandler"]

class FooAction(deskbar.interfaces.Action):
    def __init__(self, name=None):
        deskbar.interfaces.Action.__init__(self, name)
        self._name = name

    def activate(self, text=None):
        return 

    def get_verb(self):
        return _("Foo is <b>%(name)s</b>")


class BarAction(deskbar.interfaces.Action):
    def __init__(self, name=None):
        deskbar.interfaces.Action.__init__(self, name)
        self._name = name

    def activate(self, text=None):
        return

    def get_verb(self):
        return _("Bar is <b>%(name)s</b>")


class TestMatch(deskbar.interfaces.Match):
    def __init__(self, name=None, **kwargs):
        deskbar.interfaces.Match.__init__(self, category="actions",  **kwargs)
        self.name = name
        self.add_action( FooAction(self.name))
        self.add_action( BarAction(self.name))

class TestHandler(deskbar.interfaces.Module):
    INFOS = {"icon": deskbar.core.Utils.load_icon("stock_internet"),
             "name": _("Test"),
             "description": _("Testing multiple actions."),
             "version": "0.1",
            }

    def __init__(self):
        deskbar.interfaces.Module.__init__(self)

    def query(self, query): 
        self._emit_query_ready(query, [TestMatch(query)])



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