6665: New errors when using pygobject 3.8: Cannot get n_columns on flatbasemodel

svn: r22245
This commit is contained in:
Benny Malengier 2013-05-10 16:03:37 +00:00
parent 98bfecc918
commit 7f264b91f5
12 changed files with 38 additions and 20 deletions

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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)

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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):

View File

@ -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