From 2aa58482475c16113e45f7671a4321c3360c73fc Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 21 Sep 2012 19:23:50 +0000 Subject: [PATCH] GTK3: store integer in user_data of iter: https://bugzilla.gnome.org/show_bug.cgi?id=683599 svn: r20429 --- src/gui/views/treemodels/flatbasemodel.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gui/views/treemodels/flatbasemodel.py b/src/gui/views/treemodels/flatbasemodel.py index c81a7c959..977430555 100644 --- a/src/gui/views/treemodels/flatbasemodel.py +++ b/src/gui/views/treemodels/flatbasemodel.py @@ -233,8 +233,10 @@ class FlatNodeMap(object): :param type: an object handle :Returns: the path, or None if handle does not link to a path """ - handle = iter.user_data - return self.get_path_from_handle(handle) + index = iter.user_data + if index is None: + return None + return Gtk.TreePath((self.real_path(index),)) def get_path_from_handle(self, handle): """ @@ -269,7 +271,8 @@ class FlatNodeMap(object): """ iter = Gtk.TreeIter() iter.stamp = self.stamp - iter.user_data = handle + ##GTK3: user data may only be an integer, we store the index + iter.user_data = self._hndl2index[handle] return iter def get_iter(self, path): @@ -313,12 +316,11 @@ class FlatNodeMap(object): in the treeview is needed :param type: an object handle """ - handle = iter.user_data - if handle is None: + index = iter.user_data + if index is None: #Nothing on this level return False - - index = self._hndl2index.get(handle) + if self._reverse : index -= 1 if index < 0: @@ -748,8 +750,8 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): See Gtk.TreeModel. col is the model column that is needed, not the visible column! """ - #print 'do_get_val', iter, iter.user_data, col, - handle = iter.user_data + #print 'do_get_val', iter, iter.user_data, col + handle = self.node_map._index2hndl[iter.user_data][1] if handle != self.prev_handle: data = self.map(str(handle)) if data is None: @@ -781,7 +783,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): #print 'do_iter_next', iter, iter.user_data handle = self.node_map.find_next_handle(iter) if handle: - iter.user_data = handle[1] + iter.user_data = self.node_map._hndl2index[handle[1]] return True else: return False