[kupfer] objects: Fix repr_key for OpenWith and SourceLeaf



commit d64ab2a537d046ba2749b874dc96b93a4264d959
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Jan 5 13:14:41 2010 +0100

    objects: Fix repr_key for OpenWith and SourceLeaf
    
    And OpenWith does not need to be pickleable anymore.
    
    If the OpenWith (default) action is now resolved by reference, it will
    always find the *current default* open with action. Which can be
    expected in a way. If the user wants to save an absolutely specific
    trigger, you should use the Open With.. (any) action.

 kupfer/objects.py |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index 921faa7..12f6fb4 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -329,6 +329,9 @@ class SourceLeaf (Leaf):
 	def has_content(self):
 		return True
 
+	def repr_key(self):
+		return repr(self.object)
+
 	def content_source(self, alternate=False):
 		return self.object
 
@@ -541,18 +544,8 @@ class OpenWith (Action):
 		if package_name:
 			self.name_aliases.add(_("Open with %s") % package_name)
 
-	def __getstate__(self):
-		state = dict(vars(self))
-		state["desktop_item_id"] = self.desktop_item.get_id()
-		state["desktop_item"] = None
-		return state
-
-	def __setstate__(self, state):
-		vars(self).update(state)
-		self.desktop_item = gio.unix.DesktopAppInfo(self.desktop_item_id)
-
 	def repr_key(self):
-		return self
+		return "" if self.is_default else self.desktop_item.get_id()
 
 	def activate(self, leaf):
 		if not self.desktop_item.supports_files() and not self.desktop_item.supports_uris():



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