From 15d1fd3f6f5083ccad4a338084f6ee7802f6a0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 27 Aug 2011 13:24:25 +0000 Subject: [PATCH] Notify GtkTreeView if a node stops being a parent. GtkTreeView requires the row-has-child-toggled signal to be emitted in this situation, so do it from ItemDeleted handler. Curiously, it handles adding the first child automatically. That's good, because detecting this situation when adding the first child wouldn't be trivial and so not having to do it is a plus. (Emitting it on every node addition doesn't sound like a terribly bright idea.) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68915 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/dataview.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gtk/dataview.cpp b/src/gtk/dataview.cpp index 4246a441b5..51713e1c48 100644 --- a/src/gtk/dataview.cpp +++ b/src/gtk/dataview.cpp @@ -1588,12 +1588,14 @@ bool wxGtkDataViewModelNotifier::ItemDeleted( const wxDataViewItem &parent, cons GTK_TREE_MODEL(wxgtk_model), &iter )); #else // so get the path from the parent - GtkTreeIter iter; - iter.stamp = wxgtk_model->stamp; - iter.user_data = (gpointer) parent.GetID(); - wxGtkTreePath path(wxgtk_tree_model_get_path( - GTK_TREE_MODEL(wxgtk_model), &iter )); + GtkTreeIter parentIter; + parentIter.stamp = wxgtk_model->stamp; + parentIter.user_data = (gpointer) parent.GetID(); + wxGtkTreePath parentPath(wxgtk_tree_model_get_path( + GTK_TREE_MODEL(wxgtk_model), &parentIter )); + // and add the final index ourselves + wxGtkTreePath path(gtk_tree_path_copy(parentPath)); int index = m_internal->GetIndexOf( parent, item ); gtk_tree_path_append_index( path, index ); #endif @@ -1603,6 +1605,17 @@ bool wxGtkDataViewModelNotifier::ItemDeleted( const wxDataViewItem &parent, cons m_internal->ItemDeleted( parent, item ); + // Did we remove the last child, causing 'parent' to become a leaf? + if ( !m_wx_model->IsContainer(parent) ) + { + gtk_tree_model_row_has_child_toggled + ( + GTK_TREE_MODEL(wxgtk_model), + parentPath, + &parentIter + ); + } + return true; }