[kupfer: 8/10] ui: Only update active/normal/selected state in one place



commit b1e759b926b928e5ff79b19ffb8ac7c9ec56c6eb
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Apr 25 19:01:39 2011 +0200

    ui: Only update active/normal/selected state in one place

 kupfer/ui/browser.py |   35 ++++++++++++-----------------------
 1 files changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index bc75292..5391ca6 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -311,13 +311,6 @@ class MatchView (gtk.Bin):
 		selectedc = self.style.dark[gtk.STATE_SELECTED]
 		self.event_box.modify_bg(gtk.STATE_SELECTED, selectedc)
 
-	def _key_held_feedback(self, held):
-		if held:
-			selectedc = self.style.dark[gtk.STATE_ACTIVE]
-			self.event_box.modify_bg(gtk.STATE_SELECTED, selectedc)
-		else:
-			self._update_theme()
-
 	def build_widget(self):
 		"""
 		Core initalization method that builds the widget
@@ -980,7 +973,7 @@ class Interface (gobject.GObject):
 		self._key_press_interval = 0.3
 		self._key_press_repeat_threshold = 0.02
 		self._key_pressed = None
-		self._key_held = False
+		self._key_repeat_active = False
 		self._reset_to_toplevel = False
 		self._reset_when_back = False
 		self.entry.connect("realize", self._entry_realized)
@@ -1079,16 +1072,14 @@ class Interface (gobject.GObject):
 	def _entry_realized(self, widget):
 		self.update_text_mode()
 
-	def _key_held_feedback(self, held):
-		self.current.match_view._key_held_feedback(held)
-
 	def _entry_key_release(self, entry, event):
+		if self._key_repeat_active:
+			self._key_repeat_active = False
+			self.activate()
 		if self._key_pressed == event.keyval:
 			self._key_pressed = None
-		if self._key_held:
-			self._key_held = False
-			self._key_held_feedback(False)
-			self._activate(None, None)
+			self._key_repeat_active = False
+		self._update_active()
 
 	def _entry_key_press(self, entry, event):
 		"""
@@ -1160,17 +1151,15 @@ class Interface (gobject.GObject):
 				keyv not in self.keys_sensible and
 				curtime - self._key_press_time > self._key_press_repeat_threshold):
 			if curtime - self._key_press_time > self._key_press_interval:
-				if not self._key_held:
-					self._key_held_feedback(True)
-					self._key_held = True
+				self._key_repeat_active = True
+				self._update_active()
 			return True
 		else:
 			self._key_press_time = curtime
 			self._key_pressed = keyv
-			if self._key_held:
-				self._key_held_feedback(False)
-				self._key_held = False
-
+			if self._key_repeat_active:
+				self._key_repeat_active = False
+				self._update_active()
 
 		# exit here if it's not a special key
 		if keyv not in self.keys_sensible:
@@ -1553,7 +1542,7 @@ class Interface (gobject.GObject):
 			if panewidget is not self.current:
 				panewidget.set_state(gtk.STATE_NORMAL)
 			panewidget.match_view.inject_preedit(None)
-		if self._is_text_mode:
+		if self._is_text_mode or self._key_repeat_active:
 			self.current.set_state(gtk.STATE_ACTIVE)
 		else:
 			self.current.set_state(gtk.STATE_SELECTED)



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