diff --git a/gramps/gui/views/treemodels/citationlistmodel.py b/gramps/gui/views/treemodels/citationlistmodel.py index 808096dbc..6642cd7a8 100644 --- a/gramps/gui/views/treemodels/citationlistmodel.py +++ b/gramps/gui/views/treemodels/citationlistmodel.py @@ -115,5 +115,5 @@ class CitationListModel(CitationBaseModel, FlatBaseModel): """ return 14 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 diff --git a/gramps/gui/views/treemodels/citationtreemodel.py b/gramps/gui/views/treemodels/citationtreemodel.py index c5a84966a..4f3cc21dd 100644 --- a/gramps/gui/views/treemodels/citationtreemodel.py +++ b/gramps/gui/views/treemodels/citationtreemodel.py @@ -191,7 +191,7 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): if self._get_node(data[5]): self.add_node(data[5], handle, sort_key, handle, secondary=True) - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_header(self, node): diff --git a/gramps/gui/views/treemodels/eventmodel.py b/gramps/gui/views/treemodels/eventmodel.py index ac92e5409..d55be496c 100644 --- a/gramps/gui/views/treemodels/eventmodel.py +++ b/gramps/gui/views/treemodels/eventmodel.py @@ -121,7 +121,7 @@ class EventModel(FlatBaseModel): """ return 9 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_description(self,data): diff --git a/gramps/gui/views/treemodels/familymodel.py b/gramps/gui/views/treemodels/familymodel.py index dcfa42d59..cd20bacc7 100644 --- a/gramps/gui/views/treemodels/familymodel.py +++ b/gramps/gui/views/treemodels/familymodel.py @@ -104,7 +104,7 @@ class FamilyModel(FlatBaseModel): """ return 8 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_father(self, data): diff --git a/gramps/gui/views/treemodels/flatbasemodel.py b/gramps/gui/views/treemodels/flatbasemodel.py index 8551426d8..b692674ba 100644 --- a/gramps/gui/views/treemodels/flatbasemodel.py +++ b/gramps/gui/views/treemodels/flatbasemodel.py @@ -277,6 +277,8 @@ class FlatNodeMap(object): iter = Gtk.TreeIter() iter.stamp = self.stamp ##GTK3: user data may only be an integer, we store the index + ##PROBLEM: pygobject 3.8 seems to store 0 as None, we need to correct + ## when using user_data for that! iter.user_data = self._hndl2index[handle] return iter @@ -327,8 +329,8 @@ class FlatNodeMap(object): """ index = iter.user_data if index is None: - #Nothing on this level - return False + #problem in pygobject 3.8, passing 0 stores None + index = 0 if self._reverse : index -= 1 @@ -452,7 +454,7 @@ class FlatNodeMap(object): # FlatBaseModel # #------------------------------------------------------------------------- -class FlatBaseModel(GObject.Object, Gtk.TreeModel): +class FlatBaseModel(GObject.GObject, Gtk.TreeModel): """ The base class for all flat treeview models. It keeps a FlatNodeMap, and obtains data from database as needed @@ -464,7 +466,7 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): search=None, skip=set(), sort_map=None): cput = time.clock() - GObject.GObject.__init__(self) + super(FlatBaseModel, self).__init__() #inheriting classes must set self.map to obtain the data self.prev_handle = None self.prev_data = None @@ -713,7 +715,11 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): """ Get the gramps handle for an iter. """ - index = self.node_map.real_index(iter.user_data) + ud = iter.user_data + if ud is None: + #problem in pygobject 3.8, passing 0 stores None + ud = 0 + index = self.node_map.real_index(ud) return self.node_map.get_handle(index) # The following implement the public interface of Gtk.TreeModel @@ -727,9 +733,13 @@ class FlatBaseModel(GObject.Object, Gtk.TreeModel): return Gtk.TreeModelFlags.LIST_ONLY #| Gtk.TreeModelFlags.ITERS_PERSIST def do_get_n_columns(self): + """Internal method. Don't inherit""" + return self.on_get_n_columns() + + def on_get_n_columns(self): """ Return the number of columns. Must be implemented in the child objects - See Gtk.TreeModel + See Gtk.TreeModel. Inherit as needed """ #print 'do_get_n_col' raise NotImplementedError @@ -785,8 +795,12 @@ 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 = self.node_map._index2hndl[iter.user_data][1] + #print ('do_get_val', iter, iter.user_data, col) + ud = iter.user_data + if ud is None: + #problem in pygobject 3.8, passing 0 stores None + ud = 0 + handle = self.node_map._index2hndl[ud][1] val = self._get_value(handle, col) #print 'val is', val, type(val) diff --git a/gramps/gui/views/treemodels/mediamodel.py b/gramps/gui/views/treemodels/mediamodel.py index dd203b300..1d4e43314 100644 --- a/gramps/gui/views/treemodels/mediamodel.py +++ b/gramps/gui/views/treemodels/mediamodel.py @@ -103,7 +103,7 @@ class MediaModel(FlatBaseModel): """ return 8 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_description(self, data): diff --git a/gramps/gui/views/treemodels/notemodel.py b/gramps/gui/views/treemodels/notemodel.py index 0188beb29..ec46b23b5 100644 --- a/gramps/gui/views/treemodels/notemodel.py +++ b/gramps/gui/views/treemodels/notemodel.py @@ -97,7 +97,7 @@ class NoteModel(FlatBaseModel): """ return 6 - def do_get_n_columns(self): + def on_get_n_columns(self): """Return the column number of the Note tab.""" return len(self.fmap) + 1 diff --git a/gramps/gui/views/treemodels/peoplemodel.py b/gramps/gui/views/treemodels/peoplemodel.py index d14bf0c5e..d0c08e478 100644 --- a/gramps/gui/views/treemodels/peoplemodel.py +++ b/gramps/gui/views/treemodels/peoplemodel.py @@ -185,7 +185,7 @@ class PeopleBaseModel(object): self.lru_bdate.clear() self.lru_ddate.clear() - def do_get_n_columns(self): + def on_get_n_columns(self): """ Return the number of columns in the model """ return len(self.fmap)+1 diff --git a/gramps/gui/views/treemodels/placemodel.py b/gramps/gui/views/treemodels/placemodel.py index 6687f31cc..1e7f68cf5 100644 --- a/gramps/gui/views/treemodels/placemodel.py +++ b/gramps/gui/views/treemodels/placemodel.py @@ -135,7 +135,7 @@ class PlaceBaseModel(object): """ return 16 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_place_name(self, data): diff --git a/gramps/gui/views/treemodels/repomodel.py b/gramps/gui/views/treemodels/repomodel.py index 27fbf8a72..4f4476bfc 100644 --- a/gramps/gui/views/treemodels/repomodel.py +++ b/gramps/gui/views/treemodels/repomodel.py @@ -115,7 +115,7 @@ class RepositoryModel(FlatBaseModel): """ return 15 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_id(self,data): diff --git a/gramps/gui/views/treemodels/sourcemodel.py b/gramps/gui/views/treemodels/sourcemodel.py index 569cfebf0..66a004364 100644 --- a/gramps/gui/views/treemodels/sourcemodel.py +++ b/gramps/gui/views/treemodels/sourcemodel.py @@ -97,7 +97,7 @@ class SourceModel(FlatBaseModel): """ return 8 - def do_get_n_columns(self): + def on_get_n_columns(self): return len(self.fmap)+1 def column_title(self,data): diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index caf946f78..39745c335 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -235,7 +235,7 @@ class NodeMap(object): # TreeBaseModel # #------------------------------------------------------------------------- -class TreeBaseModel(GObject.Object, Gtk.TreeModel): +class TreeBaseModel(GObject.GObject, Gtk.TreeModel): """ The base class for all hierarchical treeview models. The model defines the mapping between a unique node and a path. Paths are defined by a tuple. @@ -288,7 +288,7 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): group_can_have_handle = False, has_secondary=False): cput = time.clock() - GObject.GObject.__init__(self) + super(TreeBaseModel, self).__init__() #We create a stamp to recognize invalid iterators. From the docs: #Set the stamp to be equal to your model's stamp, to mark the #iterator as valid. When your model's structure changes, you should @@ -867,6 +867,10 @@ class TreeBaseModel(GObject.Object, Gtk.TreeModel): return 0 #Gtk.TreeModelFlags.ITERS_PERSIST def do_get_n_columns(self): + """Internal method. Don't inherit""" + return self.on_get_n_columns() + + def on_get_n_columns(self): """ Return the number of columns. Must be implemented in the child objects See Gtk.TreeModel