From 7c693f91d3e5f451e51ec0dad74769e0b84fad3f Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Mon, 18 Jan 2010 23:32:47 -0800 Subject: [PATCH] views.main: Use different context menus for submodules We can now stage submodules and launch git-cola on a submodule from within the submodule diff text context menu. Signed-off-by: David Aguilar --- cola/views/main.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cola/views/main.py b/cola/views/main.py index f58d2b4d..80dbc897 100644 --- a/cola/views/main.py +++ b/cola/views/main.py @@ -467,7 +467,13 @@ class MainView(MainWindow): staged, modified, unmerged, untracked = cola.selection() if self.mode == self.model.mode_worktree: - if modified: + if modified and modified[0] in cola.model().submodules: + menu.addAction(self.tr('Stage'), + SLOT(signals.stage, modified)) + menu.addAction(self.tr('Launch git-cola'), + SLOT(signals.open_repo, + os.path.abspath(modified[0]))) + elif modified: menu.addAction(self.tr('Stage &Hunk For Commit'), self.stage_hunk) menu.addAction(self.tr('Stage &Selected Lines'), @@ -479,8 +485,17 @@ class MainView(MainWindow): self.undo_selection) elif self.mode == self.model.mode_index: - menu.addAction(self.tr('Unstage &Hunk From Commit'), self.unstage_hunk) - menu.addAction(self.tr('Unstage &Selected Lines'), self.unstage_hunk_selection) + if staged and staged[0] in cola.model().submodules: + menu.addAction(self.tr('Unstage'), + SLOT(signals.unstage, staged)) + menu.addAction(self.tr('Launch git-cola'), + SLOT(signals.open_repo, + os.path.abspath(staged[0]))) + else: + menu.addAction(self.tr('Unstage &Hunk From Commit'), + self.unstage_hunk) + menu.addAction(self.tr('Unstage &Selected Lines'), + self.unstage_hunk_selection) elif self.mode == self.model.mode_branch: menu.addAction(self.tr('Apply Diff to Work Tree'), self.stage_hunk) -- 2.11.4.GIT