remote: do not hide the Fetch/Push/Pull button
[git-cola.git] / cola / actions.py
blob4c5d97d8c3fdcf5279ec81f2a85fecb9addf377a
1 """QAction creator functions"""
3 from . import cmds
4 from . import difftool
5 from . import hotkeys
6 from . import icons
7 from . import qtutils
8 from .i18n import N_
11 def cmd_action(widget, cmd, context, icon, *shortcuts):
12 """Wrap a generic ContextCommand in a QAction"""
13 action = qtutils.add_action(widget, cmd.name(), cmds.run(cmd, context), *shortcuts)
14 action.setIcon(icon)
15 return action
18 def launch_editor(context, widget, *shortcuts):
19 """Create a QAction to launch an editor"""
20 icon = icons.edit()
21 return cmd_action(
22 widget, cmds.LaunchEditor, context, icon, hotkeys.EDIT, *shortcuts
26 def launch_editor_at_line(context, widget, *shortcuts):
27 """Create a QAction to launch an editor at the current line"""
28 icon = icons.edit()
29 return cmd_action(
30 widget, cmds.LaunchEditorAtLine, context, icon, hotkeys.EDIT, *shortcuts
34 def launch_difftool(context, widget):
35 """Create a QAction to launch git-difftool(1)"""
36 icon = icons.diff()
37 cmd = difftool.LaunchDifftool
38 action = qtutils.add_action(
39 widget, cmd.name(), cmds.run(cmd, context), hotkeys.DIFF
41 action.setIcon(icon)
42 return action
45 def stage_or_unstage(context, widget):
46 """Create a QAction to stage or unstage the selection"""
47 icon = icons.add()
48 return cmd_action(
49 widget, cmds.StageOrUnstage, context, icon, hotkeys.STAGE_SELECTION
53 def move_down(widget):
54 """Create a QAction to select the next item"""
55 action = qtutils.add_action(
56 widget, N_('Next File'), widget.down.emit, hotkeys.MOVE_DOWN_SECONDARY
58 action.setIcon(icons.move_down())
59 return action
62 def move_up(widget):
63 """Create a QAction to select the previous/above item"""
64 action = qtutils.add_action(
65 widget, N_('Previous File'), widget.up.emit, hotkeys.MOVE_UP_SECONDARY
67 action.setIcon(icons.move_up())
68 return action