setup: apply flake8 suggestions
[git-cola.git] / cola / actions.py
blob8a80b767baed9d2e47f5213a5d1dd123d5c01d6f
1 from __future__ import absolute_import
3 from cola import sipcompat
4 sipcompat.initialize()
6 from PyQt4.QtCore import SIGNAL
8 from cola import cmds
9 from cola import hotkeys
10 from cola import icons
11 from cola import qtutils
12 from cola.i18n import N_
15 def cmd_action(widget, cmd, icon, *shortcuts):
16 action = qtutils.add_action(widget, cmd.name(), cmds.run(cmd), *shortcuts)
17 action.setIcon(icon)
18 return action
21 def launch_editor(widget, *shortcuts):
22 icon = icons.configure()
23 return cmd_action(widget, cmds.LaunchEditor, icon, hotkeys.EDIT, *shortcuts)
26 def launch_difftool(widget):
27 icon = icons.diff()
28 return cmd_action(widget, cmds.LaunchDifftool, icon, hotkeys.DIFF)
31 def stage_or_unstage(widget):
32 icon = icons.add()
33 return cmd_action(widget, cmds.StageOrUnstage, icon,
34 hotkeys.STAGE_SELECTION)
37 def move_down(widget):
38 return qtutils.add_action(
39 widget, N_('Next File'),
40 lambda: widget.emit(SIGNAL('move_down()')),
41 hotkeys.MOVE_DOWN_SECONDARY)
44 def move_up(widget):
45 return qtutils.add_action(
46 widget, N_('Previous File'),
47 lambda: widget.emit(SIGNAL('move_up()')),
48 hotkeys.MOVE_UP_SECONDARY)