From 901a8a2a57d8baa11a6a5e399d50364a20fb5795 Mon Sep 17 00:00:00 2001 From: David Aguilar Date: Tue, 27 Jul 2010 04:24:32 -0700 Subject: [PATCH] usability: Allow un/staging all by right-clicking on top-level items We can now stage or unstage all files by right-clicking on the 'Staged' or 'Unstaged' icons. Closes #57 Suggested-by: Shish Moom via github Signed-off-by: David Aguilar --- cola/models/main.py | 6 ++++++ cola/views/status.py | 10 +++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cola/models/main.py b/cola/models/main.py index 1cce21b7..4fd8ea9f 100644 --- a/cola/models/main.py +++ b/cola/models/main.py @@ -591,6 +591,9 @@ class MainModel(ObservableModel): def stage_paths(self, paths): """Stages add/removals to git.""" + if not paths: + self.stage_all() + return add = [] remove = [] sset = set(self.staged) @@ -636,6 +639,9 @@ class MainModel(ObservableModel): self.notify_message_observers(self.message_updated) def unstage_paths(self, paths): + if not paths: + self.unstage_all() + return self.notify_message_observers(self.message_about_to_update) staged_set = set(self.staged) diff --git a/cola/views/status.py b/cola/views/status.py index c9eac4ed..c94f3529 100644 --- a/cola/views/status.py +++ b/cola/views/status.py @@ -254,15 +254,16 @@ class StatusWidget(QtGui.QWidget): staged, modified, unmerged, untracked = self.selection() menu = QtGui.QMenu(self) - if staged and staged[0] in cola.model().submodules: + enable_staging = self.model.enable_staging() + if not enable_staging: menu.addAction(self.tr('Unstage Selected'), SLOT(signals.unstage, self.staged())) + + if staged and staged[0] in cola.model().submodules: menu.addAction(self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(staged[0]))) return menu elif staged: - menu.addAction(self.tr('Unstage Selected'), - SLOT(signals.unstage, self.staged())) menu.addSeparator() menu.addAction(self.tr('Launch Editor'), SLOT(signals.edit, self.staged())) @@ -286,7 +287,6 @@ class StatusWidget(QtGui.QWidget): modified_submodule = (modified and modified[0] in cola.model().submodules) - enable_staging = self.model.enable_staging() if enable_staging: menu.addAction(self.tr('Stage Selected'), SLOT(signals.stage, self.unstaged())) @@ -296,7 +296,7 @@ class StatusWidget(QtGui.QWidget): menu.addAction(self.tr('Launch git-cola'), SLOT(signals.open_repo, os.path.abspath(modified[0]))) - else: + elif self.unstaged(): menu.addAction(self.tr('Launch Editor'), SLOT(signals.edit, self.unstaged())) -- 2.11.4.GIT