[kupfer] Make Action objects comparable with ==; use equivalency checking



commit 05e78bdc1ea70090a1a92e753e4a083f2fc777fa
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Jan 13 17:29:19 2010 +0100

    Make Action objects comparable with ==; use equivalency checking
    
    In the DataController we distinguish different objects by equivalence
    (==) not identify (is) now.
    
    We make the Action in general comparable. This means we avoid clearing
    the third (indirect object) pane when we are really just re-selecting
    the same action in the second pane.

 kupfer/core/data.py |    2 +-
 kupfer/obj/base.py  |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index 0bfef35..e236515 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -642,7 +642,7 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		relevant places"""
 		# If already selected, do nothing
 		panectl = self._panectl_table[pane]
-		if item is panectl.get_selection():
+		if item == panectl.get_selection():
 			return
 		self.cancel_search()
 		panectl.select(item)
diff --git a/kupfer/obj/base.py b/kupfer/obj/base.py
index 57174c7..9616172 100644
--- a/kupfer/obj/base.py
+++ b/kupfer/obj/base.py
@@ -210,6 +210,13 @@ class Action (KupferObject):
 		return True
 	'''
 
+	def __hash__(self):
+		return hash(repr(self))
+
+	def __eq__(self, other):
+		return (type(self) == type(other) and repr(self) == repr(other) and
+				unicode(self) == unicode(other))
+
 	def repr_key(self):
 		"""by default, actions of one type are all the same"""
 		return ""



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