[kupfer] quickview: Fix escape key behavior



commit fe92a698757deb0893cb3f947e8dd884d5821f57
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Mar 22 01:45:24 2011 +0100

    quickview: Fix escape key behavior

 kupfer/plugin/quickview.py |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/kupfer/plugin/quickview.py b/kupfer/plugin/quickview.py
index 1c173d9..3e72f43 100644
--- a/kupfer/plugin/quickview.py
+++ b/kupfer/plugin/quickview.py
@@ -14,6 +14,7 @@ from kupfer.objects import Action, FileLeaf
 from kupfer.objects import OperationError
 from kupfer import utils
 
+
 def is_content_type(fileleaf, ctype):
 	predicate = gio.content_type_is_a
 	ctype_guess, uncertain = gio.content_type_guess(fileleaf.object, None, True)
@@ -48,15 +49,6 @@ def load_image_max_size(filename, w, h):
 		pl.close()
 	return pl.get_pixbuf()
 
-def window_key_press(window, event, filepath):
-	if gtk.gdk.keyval_name(event.keyval) == "Escape":
-		window.destroy()
-		return True
-	if gtk.gdk.keyval_name(event.keyval) == "Return":
-		utils.show_path(filepath)
-		window.destroy()
-		return True
-
 class View (Action):
 
 	def __init__(self):
@@ -86,7 +78,7 @@ class View (Action):
 		window.set_position(gtk.WIN_POS_CENTER)
 		window.add(image_widget)
 		window.present()
-		window.connect("key-press-event", window_key_press, obj.object)
+		window.connect("key-press-event", self.window_key_press, obj.object)
 		window.connect("delete-event", self.window_deleted, obj.object)
 		self.open_windows[obj.object] = window
 
@@ -94,6 +86,17 @@ class View (Action):
 		self.open_windows.pop(filename, None)
 		return False
 
+	def window_key_press(self, window, event, filepath):
+		if gtk.gdk.keyval_name(event.keyval) == "Escape":
+			self.window_deleted(window, event, filepath)
+			window.destroy()
+			return True
+		if gtk.gdk.keyval_name(event.keyval) == "Return":
+			self.window_deleted(window, event, filepath)
+			utils.show_path(filepath)
+			window.destroy()
+			return True
+
 	def get_description(self):
 		return None
 



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