[meld] tree: Move previous/next path finding logic to SearchableTreeStore
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] tree: Move previous/next path finding logic to SearchableTreeStore
- Date: Sat, 16 Dec 2017 02:37:06 +0000 (UTC)
commit bf9d0903f4619830f228c3b0b1bfb1763a318d0e
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Oct 23 07:43:05 2016 +1000
tree: Move previous/next path finding logic to SearchableTreeStore
meld/tree.py | 43 ++++++++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/meld/tree.py b/meld/tree.py
index 1706d5c3..bf39748d 100644
--- a/meld/tree.py
+++ b/meld/tree.py
@@ -78,6 +78,26 @@ class SearchableTreeStore(Gtk.TreeStore):
raise StopIteration()
yield it
+ def get_previous_next_paths(self, path, match_func):
+ prev_path, next_path = None, None
+ try:
+ start_iter = self.get_iter(path)
+ except ValueError:
+ # Invalid tree path
+ return None, None
+
+ for it in self.inorder_search_up(start_iter):
+ if match_func(it):
+ prev_path = self.get_path(it)
+ break
+
+ for it in self.inorder_search_down(start_iter):
+ if match_func(it):
+ next_path = self.get_path(it)
+ break
+
+ return prev_path, next_path
+
class DiffTreeStore(SearchableTreeStore):
@@ -207,26 +227,11 @@ class DiffTreeStore(SearchableTreeStore):
return None
def _find_next_prev_diff(self, start_path):
- prev_path, next_path = None, None
- try:
- start_iter = self.get_iter(start_path)
- except ValueError:
- # Invalid tree path
- return None, None
-
- for it in self.inorder_search_up(start_iter):
- state = self.get_state(it, 0)
- if state not in (STATE_NORMAL, STATE_EMPTY):
- prev_path = self.get_path(it)
- break
-
- for it in self.inorder_search_down(start_iter):
- state = self.get_state(it, 0)
- if state not in (STATE_NORMAL, STATE_EMPTY):
- next_path = self.get_path(it)
- break
+ def match_func(it):
+ # TODO: It works, but matching on the first pane only is very poor
+ return self.get_state(it, 0) not in (STATE_NORMAL, STATE_EMPTY)
- return prev_path, next_path
+ return self.get_previous_next_paths(start_path, match_func)
def state_rows(self, states):
"""Generator of rows in one of the given states
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]