From 208a68e451635883d0c6f58e56c8308bafe8b16c Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 09 Jun 2013 22:06:54 +0000 Subject: refactoring based on lasted commits upstream --- (limited to 'src/jarabe/journal/listmodel.py') diff --git a/src/jarabe/journal/listmodel.py b/src/jarabe/journal/listmodel.py index b98d01c..dad0c76 100644 --- a/src/jarabe/journal/listmodel.py +++ b/src/jarabe/journal/listmodel.py @@ -16,7 +16,7 @@ import logging -import simplejson +import json from gi.repository import GObject from gi.repository import Gtk from gettext import gettext as _ @@ -109,7 +109,7 @@ class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): return ListModel._COLUMN_TYPES[index] def do_iter_n_children(self, iterator): - if iterator == None: + if iterator is None: return self._result_set.length else: return 0 @@ -176,8 +176,8 @@ class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): buddies = [] if metadata.get('buddies'): try: - buddies = simplejson.loads(metadata['buddies']).values() - except simplejson.decoder.JSONDecodeError, exception: + buddies = json.loads(metadata['buddies']).values() + except json.decoder.JSONDecodeError, exception: logging.warning('Cannot decode buddies for %r: %s', metadata['uid'], exception) @@ -237,14 +237,17 @@ class ListModel(GObject.GObject, Gtk.TreeModel, Gtk.TreeDragSource): def do_drag_data_get(self, path, selection): uid = self[path][ListModel.COLUMN_UID] - if selection.target == 'text/uri-list': + target_atom = selection.get_target() + target_name = target_atom.name() + if target_name == 'text/uri-list': # Get hold of a reference so the temp file doesn't get deleted self._temp_drag_file_path = model.get_file(uid) logging.debug('putting %r in selection', self._temp_drag_file_path) - selection.set(selection.target, 8, self._temp_drag_file_path) + selection.set(target_atom, 8, self._temp_drag_file_path) return True - elif selection.target == 'journal-object-id': - selection.set(selection.target, 8, uid) + elif target_name == 'journal-object-id': + # uid is unicode but Gtk.SelectionData.set() needs str + selection.set(target_atom, 8, str(uid)) return True return False -- cgit v0.9.1