diff options
author | Christoph Reiter <reiter.christoph@gmail.com> | 2018-11-30 01:19:33 +0100 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2018-11-30 01:19:33 +0100 |
commit | 288c099147586b86750ecd2aa1090b0b15c9b13a (patch) | |
tree | 2a3cb2134711a76465fc704b33debe09b0c867c7 /gi | |
parent | 99820cc09fb4d86b6c7682aa6251f27d06a631e7 (diff) | |
download | pygobject-288c099147586b86750ecd2aa1090b0b15c9b13a.tar.gz |
gtk: Fix rows getting inserted on the wrong level if parent=None. Fixes #281
TreeStore.insert_before allows passing parent as None in which case the parent
is derived from the sibling. The new code using insert_with_values() didn't take
this into account and simply passed the None along resulting in the row always getting
added at the toplevel.
Fix this by always passing a parent iter to insert_with_values() except when sibling is also
None and we want to add to the toplevel anyway.
Diffstat (limited to 'gi')
-rw-r--r-- | gi/overrides/Gtk.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index d9c1a05f..ba0a71dc 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -1263,6 +1263,8 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable): if sibling is None: position = -1 else: + if parent is None: + parent = self.iter_parent(sibling) position = self.get_path(sibling).get_indices()[-1] return self._do_insert(parent, position, row) @@ -1273,6 +1275,8 @@ class TreeStore(Gtk.TreeStore, TreeModel, TreeSortable): if sibling is None: position = 0 else: + if parent is None: + parent = self.iter_parent(sibling) position = self.get_path(sibling).get_indices()[-1] + 1 return self._do_insert(parent, position, row) |