[kupfer] Enter text-mode automatically in third pane



commit fc4b849df81c9cec114de23ea475b8023959129c
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Fri Mar 11 00:25:32 2011 +0100

    Enter text-mode automatically in third pane
    
    Enable by iself text-mode if sensible in the indirect object pane.
    This will only happen if it uses a text source as Leaf.object_source()
    at the moment.

 kupfer/core/data.py  |   13 +++++++++++++
 kupfer/ui/browser.py |    4 ++++
 2 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index 03b0a84..9ece885 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -190,6 +190,8 @@ class Pane (gobject.GObject):
 		return self.latest_key
 	def get_can_enter_text_mode(self):
 		return False
+	def get_should_enter_text_mode(self):
+		return False
 	def emit_search_result(self, match, match_iter, context):
 		self.emit("search-result", match, match_iter, context)
 
@@ -246,6 +248,9 @@ class LeafPane (Pane, pretty.OutputMixin):
 	def get_can_enter_text_mode(self):
 		return self.is_at_source_root()
 
+	def get_should_enter_text_mode(self):
+		return False
+
 	def refresh_data(self):
 		self.emit("new-source", self.source)
 
@@ -380,6 +385,10 @@ class SecondaryObjectPane (LeafPane):
 		return (atroot and
 			any(sc.good_source_for_types(s, types) for s in textsrcs))
 
+	def get_should_enter_text_mode(self):
+		return (self.is_at_source_root() and
+		        hasattr(self.get_source(), "get_text_items"))
+
 	def search(self, key=u"", context=None, text_mode=False):
 		"""
 		filter for action @item
@@ -718,6 +727,10 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		panectl = self._panectl_table[pane]
 		return panectl.get_can_enter_text_mode()
 
+	def get_should_enter_text_mode(self, pane):
+		panectl = self._panectl_table[pane]
+		return panectl.get_should_enter_text_mode()
+
 	def validate(self):
 		"""Check if all selected items are still valid
 		(for example after being spawned again, old item
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 89bca14..4b23811 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1306,7 +1306,11 @@ class Interface (gobject.GObject):
 		if (prev_pane.get_match_state() is State.Match and
 				new_focus is not self.current):
 			self.current = new_focus
+			# Use toggle_text_mode to reset
 			self.toggle_text_mode(False)
+			pane = self._pane_for_widget(new_focus)
+			if self.data_controller.get_should_enter_text_mode(pane):
+				self.toggle_text_mode_quick()
 			self._update_active()
 
 	def _browse_up(self):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]