+ def _find_next(self):
+ """
+ check if 'new find' or 'last find' or 'next-find'
+
+ new-find = run the find algorithm which also selects the first found unit
+ = self._findIndex = 0 and self._find_result = []
+
+ last-find = restart from top again
+ = self._findIndex = len(self._find_result)
+
+ next-find = continue to next found location
+ = self._findIndex = 0 and len(self._find_result)>0
+ """
+ if len(self._find_result) == 0:
+ self._find_first()
+ else:
+ if self._findIndex == len(self._find_result)-1:
+ self._findIndex = 0
+ else:
+ self._findIndex += 1
+
+ if not self._find_result:
+ self._findLabel.set_text('Text not found')
+ else:
+ self._update_find_selection()
+ resultsLeft = len(self._find_result) - self._findIndex - 1
+ self._findLabel.set_text(
+ '%s result(s) left' % (resultsLeft, )
+ )
+
+ def _find_previous(self):
+ """
+ check if 'new find' or 'last find' or 'next-find'
+
+ new-find = run the find algorithm which also selects the first found unit
+ = self._findIndex = 0 and self._find_result = []
+
+ last-find = restart from top again
+ = self._findIndex = len(self._find_result)
+
+ next-find = continue to next found location
+ = self._findIndex = 0 and len(self._find_result)>0
+ """
+ if len(self._find_result) == 0:
+ self._find_first()
+ else:
+ if self._findIndex == 0:
+ self._findIndex = len(self._find_result)-1
+ else:
+ self._findIndex -= 1
+
+ if not self._find_result:
+ self._findLabel.set_text('Text not found')
+ else:
+ self._update_find_selection()
+ resultsLeft = len(self._find_result) - self._findIndex - 1
+ self._findLabel.set_text(
+ '%s result(s) left' % (resultsLeft, )
+ )
+
+ def _toggle_find(self):
+ if self._searchLayout.get_property("visible"):
+ self._searchLayout.hide()
+ else:
+ self._searchLayout.show()
+