[meld/VersionControlRework: 92/123] vcview: Refactor sensitivity setting for new valid actions API
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/VersionControlRework: 92/123] vcview: Refactor sensitivity setting for new valid actions API
- Date: Sun, 19 Apr 2015 20:13:44 +0000 (UTC)
commit c13e8b4e7e47bae9501ef134077f11eb0a970086
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Apr 11 09:30:17 2015 +1000
vcview: Refactor sensitivity setting for new valid actions API
Every VC gets this for free now, so no point doing hasattr checks.
meld/vcview.py | 45 ++++++++++++++++++---------------------------
1 files changed, 18 insertions(+), 27 deletions(-)
---
diff --git a/meld/vcview.py b/meld/vcview.py
index 9be2db6..58a932c 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -560,36 +560,27 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
self.refresh()
def on_treeview_selection_changed(self, selection=None):
-
- def set_sensitive(action, sensitive):
- self.actiongroup.get_action(action).set_sensitive(sensitive)
-
if selection is None:
selection = self.treeview.get_selection()
model, rows = selection.get_selected_rows()
-
- if hasattr(self.vc, 'get_valid_actions'):
- paths = [self.model.value_path(model.get_iter(r), 0) for r in rows]
- states = [self.model.get_state(model.get_iter(r), 0) for r in rows]
- path_states = dict(zip(paths, states))
- valid_actions = self.vc.get_valid_actions(path_states)
- action_sensitivity = {
- "VcCompare": 'compare' in valid_actions,
- "VcCommit": 'commit' in valid_actions,
- "VcUpdate": 'update' in valid_actions,
- "VcPush": 'push' in valid_actions,
- "VcAdd": 'add' in valid_actions,
- "VcResolved": 'resolve' in valid_actions,
- "VcRemove": 'remove' in valid_actions,
- "VcRevert": 'revert' in valid_actions,
- "VcDeleteLocally": bool(paths) and self.vc.root not in paths,
- }
- for action, sensitivity in action_sensitivity.items():
- set_sensitive(action, sensitivity)
- else:
- have_selection = bool(rows)
- for action in self.valid_vc_actions:
- set_sensitive(action, have_selection)
+ paths = [self.model.value_path(model.get_iter(r), 0) for r in rows]
+ states = [self.model.get_state(model.get_iter(r), 0) for r in rows]
+ path_states = dict(zip(paths, states))
+
+ valid_actions = self.vc.get_valid_actions(path_states)
+ action_sensitivity = {
+ "VcCompare": 'compare' in valid_actions,
+ "VcCommit": 'commit' in valid_actions,
+ "VcUpdate": 'update' in valid_actions,
+ "VcPush": 'push' in valid_actions,
+ "VcAdd": 'add' in valid_actions,
+ "VcResolved": 'resolve' in valid_actions,
+ "VcRemove": 'remove' in valid_actions,
+ "VcRevert": 'revert' in valid_actions,
+ "VcDeleteLocally": bool(paths) and self.vc.root not in paths,
+ }
+ for action, sensitivity in action_sensitivity.items():
+ self.actiongroup.get_action(action).set_sensitive(sensitivity)
def _get_selected_files(self):
model, rows = self.treeview.get_selection().get_selected_rows()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]