diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-26 11:57:04 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-26 16:42:01 +0100 |
commit | 9b17ad5b54b684e58eb488f2ab586e694c65e1ef (patch) | |
tree | 140a1e803aad7d7395ffabe0a0e854935e148359 | |
parent | 90ad0740a22bc50c478ad743eef1f30b2fc1b226 (diff) |
get the real last row, not the last toplevel row
Change-Id: I7de72c383f11187ec706cd6971ff0431d04db72f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89539
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 1e93792e7778..ad19e1d762f0 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -9051,6 +9051,33 @@ private: return true; } + void last_child(GtkTreeModel* pModel, GtkTreeIter* result, GtkTreeIter* pParent, int nChildren) + { + gtk_tree_model_iter_nth_child(pModel, result, pParent, nChildren - 1); + nChildren = gtk_tree_model_iter_n_children(pModel, result); + if (nChildren) + { + GtkTreeIter newparent(*result); + last_child(pModel, result, &newparent, nChildren); + } + } + + GtkTreePath* get_path_of_last_entry(GtkTreeModel *pModel) + { + GtkTreePath *lastpath; + // find the last entry in the model for comparison + int nChildren = gtk_tree_model_iter_n_children(pModel, nullptr); + if (!nChildren) + lastpath = gtk_tree_path_new_from_indices(0, -1); + else + { + GtkTreeIter iter; + last_child(pModel, &iter, nullptr, nChildren); + lastpath = gtk_tree_model_get_path(pModel, &iter); + } + return lastpath; + } + public: GtkInstanceTreeView(GtkTreeView* pTreeView, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pTreeView), pBuilder, bTakeOwnership) @@ -10381,12 +10408,7 @@ public: // find the last entry in the model for comparison GtkTreeModel *pModel = GTK_TREE_MODEL(m_pTreeStore); - int nChildren = gtk_tree_model_iter_n_children(pModel, nullptr); - GtkTreePath *lastpath; - if (nChildren) - lastpath = gtk_tree_path_new_from_indices(nChildren - 1, -1); - else - lastpath = gtk_tree_path_new_from_indices(0, -1); + GtkTreePath *lastpath = get_path_of_last_entry(pModel); if (!ret) { |