Clean up hint command.

This commit is contained in:
Florian Bruhin 2014-07-29 02:24:04 +02:00
parent 425a7fd7c4
commit e1f9403876

View File

@ -250,12 +250,12 @@ class CommandDispatcher:
self._tabs.currentWidget().go_forward() self._tabs.currentWidget().go_forward()
@cmdutils.register(instance='mainwindow.tabs.cmd') @cmdutils.register(instance='mainwindow.tabs.cmd')
def hint(self, groupstr='all', targetstr='normal', *args): def hint(self, group='all', target='normal', *args):
"""Start hinting. """Start hinting.
Args: Args:
groupstr: The hinting mode to use. group: The hinting mode to use.
targetstr: Where to open the links. target: Where to open the links.
*args: Arguments for spawn/userscript. *args: Arguments for spawn/userscript.
""" """
widget = self._tabs.currentWidget() widget = self._tabs.currentWidget()
@ -263,15 +263,15 @@ class CommandDispatcher:
if frame is None: if frame is None:
raise CommandError("No frame focused!") raise CommandError("No frame focused!")
try: try:
group = getattr(webelem.Group, groupstr.replace('-', '_')) group_enum = webelem.Group[group.replace('-', '_')]
except AttributeError: except AttributeError:
raise CommandError("Unknown hinting group {}!".format(groupstr)) raise CommandError("Unknown hinting group {}!".format(group))
try: try:
target = getattr(hints.Target, targetstr.replace('-', '_')) target_enum = hints.Target[target.replace('-', '_')]
except AttributeError: except AttributeError:
raise CommandError("Unknown hinting target {}!".format(targetstr)) raise CommandError("Unknown hinting target {}!".format(target))
widget.hintmanager.start(frame, self._tabs.current_url(), group, widget.hintmanager.start(frame, self._tabs.current_url(), group_enum,
target, *args) target_enum, *args)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True) @cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def follow_hint(self): def follow_hint(self):