cmds: add SetDefaultRepo command
[git-cola.git] / cola / actions.py
blob2259c663c6bfe04358b11e6886761da4fd4f31a9
1 from PyQt4.QtCore import SIGNAL
3 from cola import cmds
4 from cola import hotkeys
5 from cola import icons
6 from cola import qtutils
7 from cola.i18n import N_
10 def cmd_action(widget, cmd, icon, *shortcuts):
11 action = qtutils.add_action(widget, cmd.name(), cmds.run(cmd), *shortcuts)
12 action.setIcon(icon)
13 return action
16 def launch_editor(widget, *shortcuts):
17 icon = icons.configure()
18 return cmd_action(widget, cmds.LaunchEditor, icon, hotkeys.EDIT, *shortcuts)
21 def launch_difftool(widget):
22 icon = icons.diff()
23 return cmd_action(widget, cmds.LaunchDifftool, icon, hotkeys.DIFF)
26 def stage_or_unstage(widget):
27 icon = icons.add()
28 return cmd_action(widget, cmds.StageOrUnstage, icon,
29 hotkeys.STAGE_SELECTION)
32 def move_down(widget):
33 return qtutils.add_action(widget,
34 N_('Next File'), lambda: widget.emit(SIGNAL('move_down()')),
35 hotkeys.MOVE_DOWN_SECONDARY)
38 def move_up(widget):
39 return qtutils.add_action(widget,
40 N_('Previous File'), lambda: widget.emit(SIGNAL('move_up()')),
41 hotkeys.MOVE_UP_SECONDARY)