]> git.saurik.com Git - wxWidgets.git/commitdiff
preserve checkbox status in SetString()
authorPaul Cornett <paulcor@bullseye.com>
Tue, 2 Jul 2013 16:29:49 +0000 (16:29 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Tue, 2 Jul 2013 16:29:49 +0000 (16:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/listbox.cpp

index 27d7440ae2e107c91ef333569053d694218fd2af..5f1a0ed7a1ceed48337994289b484732f1f25a1e 100644 (file)
@@ -598,22 +598,20 @@ void wxListBox::DoSetItemClientData(unsigned int n, void* clientData)
 
 void wxListBox::SetString(unsigned int n, const wxString& label)
 {
-    wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetString") );
     wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );
 
-    GtkTreeEntry* entry = GTKGetEntry(n);
-    wxCHECK_RET( entry, wxT("wrong listbox index") );
+    GtkTreeIter iter;
+    wxCHECK_RET(GTKGetIteratorFor(n, &iter), "invalid index");
+    wxGtkObject<GtkTreeEntry> entry(GetEntry(m_liststore, &iter, this));
 
     // update the item itself
     gtk_tree_entry_set_label(entry, wxGTK_CONV(label));
 
-    // and update the model which will refresh the tree too
-    GtkTreeIter iter;
-    wxCHECK_RET( GTKGetIteratorFor(n, &iter), wxT("failed to get iterator") );
-
-    // FIXME: this resets the checked status of a wxCheckListBox item
-
-    GTKSetItem(iter, entry);
+    // signal row changed
+    GtkTreeModel* tree_model = GTK_TREE_MODEL(m_liststore);
+    GtkTreePath* path = gtk_tree_model_get_path(tree_model, &iter);
+    gtk_tree_model_row_changed(tree_model, path, &iter);
+    gtk_tree_path_free(path);
 }
 
 wxString wxListBox::GetString(unsigned int n) const