[Deskbar] keywords
- From: Sebastian Menge <sebastian menge uni-dortmund de>
- To: deskbar-applet-list gnome org
- Subject: [Deskbar] keywords
- Date: Sun, 15 Apr 2007 21:42:15 +0200
Hi
I want to write a handler to simulate the behavior of firefox feature to
use search-engines via keywords. [1]
e.g. assign the keyword "z" to the amazon-search-engine and write in the
adress-bar of firefox: "z harry potter" and it will search amazon.
I want that behavior in deskbar. That means i want to choose the handler
to use before I enter the word by a (cryptic) prefix.
The reason is: I always know *before* entering the word what
search-engine i would like to use (translator, wikipedia, goo/beagle,
evolution contacts) -- deskbar forces me to choose afterwards.
So my first idea was to write some kind of meta-handler that strips of
the first letters ("z ") and delegates the query to a specific handler.
I did some steps in that direction, but im stuck at the moment because i
dont know how to proceed with the results of the delegated handler. I
wanted sth like "result.append(aHandler.query(myquery)". But that didnt
work, (the Matches seem to be of "NoneType").
But now, when i'm thinking about it, i'm reinventig the wheel. the trick
would be to recognize the search-engine keywords, and then let firefox
do the rest. That would mean to modify "handlers/mozilla.py" (but then,
how to deal with keywords for beagle, evo? )
OK. That was a mixture of feature request, a half-implemented
MetaHandler, or request for comments and other ideas on this ...
Let me know what you think.
Best regards, Sebastian.
[1] In fact I think Opera had it first. Together with mouse gestures it
is extremely usable: "Mouse Down, g sth" googles for sth. extremely
fast :-)
from gettext import gettext as _
import gnomevfs
import string
from deskbar.Handler import Handler
from deskbar.Match import Match
from deskbar.DeskbarApplet import DeskbarApplet
from deskbar.ModuleList import ModuleList
import gtk, gtk.gdk
HANDLERS = {
"MetaHandler" : {
"name": _("MetaHandler"),
"description": _("Choose the deskbar handler by a prefix"),
}
}
class MetaMatch(Match):
def __init__(self, backend, **args):
Match.__init__(self, backend, **args)
def action(self, text=None):
gnomevfs.url_show(self.url)
def get_verb(self):
return _("Show PyGtk API for <b>%(name)s</b>")
def get_hash(self, text=None):
return self.url
class MetaHandler(Handler):
def __init__(self):
Handler.__init__(self, "")
self.dba = DeskbarApplet.get_instance()
def query(self, query):
result = []
query = query.lower()
print(query)
if query.startswith('m'):
stripped = query.lstrip('m')
print(stripped)
for m in self.dba.module_list:
if m.handler == "MozillaSearchHandler":
print("found moz search handler. ")
#result = m.module.query(stripped)
# for match in result:
# print match
# print "done"
result.append(m.module.query(stripped))
#result.append()
#result.append(PyGtkAPIMatch(self, name=name, url=url))
return result
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]