]> git.saurik.com Git - wxWidgets.git/commitdiff
Notify GtkTreeView if a node stops being a parent.
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 27 Aug 2011 13:24:25 +0000 (13:24 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 27 Aug 2011 13:24:25 +0000 (13:24 +0000)
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

index 4246a441b51df5e1be1c85564b742a24b0df356f..51713e1c48e3a41a51d7b23f46166439af65b8a0 100644 (file)
@@ -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;
 }