from gettext import gettext as _ import gtk import deskbar from deskbar.Handler import Handler from deskbar.Match import Match import re HANDLERS = { "MySQLBugHandler" : { "name": _("MySQL Bugs"), "description": _("goes to the web page for a MySQL bug number"), } } BUGEXPR = re.compile(r"^BUG(?P\d+)") class MySQLBugMatch(Match): def __init__(self, backend, bugno, **args): deskbar.Match.Match.__init__(self, backend, **args) self.bugno= bugno def action(self, text=None): gnomevfs.url_show("http://bugs.mysql.com/" + self.bugno) def get_category(self): return "actions" def get_name (self, text=None): # SEE Match.py for return {"bugno":self.bugno} def get_verb(self): return _("Open MySQL Bug %(bugno)s") def get_hash(self, text=None): return self.bugno class MySQLBugHandler(Handler): def __init__(self): deskbar.Handler.Handler.__init__(self, "mysql_bugs") def query(self, query, max=1): # ADD max=1 match = BUGEXPR.match(query) if match != None: return [MySQLBugMatch(self, match.group('bugno'))] return []