[kupfer: 12/31] objects: Make sure you can pickle OpenWith



commit 748cdfe3fe3a5d42ecd49a0b49513deb35852e65
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Dec 30 16:46:58 2009 +0100

    objects: Make sure you can pickle OpenWith

 kupfer/objects.py |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/objects.py b/kupfer/objects.py
index 6e9c53e..8a7f84b 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -542,6 +542,16 @@ 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
 



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