I knew I could depend on you guys!!!! ;) Armin Burgmeier wrote: > Robert Caryl wrote: > > Furthermore, I am going to assume that you have written a function in > > your class that will serve as the callback slot parameter for > > Gtk::TreeSelection::selected_foreach_iter. In this callback slot you > > should make a call to Gtk::TreeModel::erase using the iterator passed as > > its formal parameter, and voila! Your selected rows will be deleted. > > The GTK+ documentation states the following for > gtk_tree_selection_selected_foreach: "Note that you cannot modify the > tree or selection from within this function." > > This is the way I did it. It is plain C, but you probably get the idea. > It is perhaps even possible to avoid the conversion to iterators if you > delete the rows in the reverse order (from bottom to top). > > static void > cg_element_editor_remove_button_clicked_cb (G_GNUC_UNUSED GtkButton > *button, > gpointer user_data) > { > CgElementEditor *editor; > CgElementEditorPrivate *priv; > GtkTreeSelection *selection; > GtkTreeIter *iter; > GtkTreePath *path; > GList *selected_rows; > GList *selected_iters; > GList *cur_item; > > editor = CG_ELEMENT_EDITOR (user_data); > priv = CG_ELEMENT_EDITOR_PRIVATE (editor); > selection = gtk_tree_view_get_selection (priv->view); > selected_rows = gtk_tree_selection_get_selected_rows (selection, > NULL); > selected_iters = NULL; > > /* Convert paths to iters because changing the model borks offsets > * in paths, but since GtkListStore has GTK_TREE_MODEL_PERSIST set, > * iters continue to live after changing the model. */ > for (cur_item = selected_rows; cur_item != NULL; cur_item = > cur_item->next) > { > path = cur_item->data; > iter = g_new (GtkTreeIter, 1); > > gtk_tree_model_get_iter (priv->list, iter, path); > selected_iters = g_list_prepend (selected_iters, iter); > > gtk_tree_path_free (path); > } > > for (cur_item = selected_iters; > cur_item != NULL; > cur_item = cur_item->next) > { > iter = cur_item->data; > gtk_list_store_remove (GTK_LIST_STORE (priv->list), iter); > g_free (iter); > } > > g_list_free (selected_rows); > g_list_free (selected_iters); > } > > Greetings, > Armin
-- <!-- @page { size: 8.5in 11in; margin: 0.79in } P { margin-bottom: 0.08in } --> *Robert L. Caryl Jr.* Fiscal Systems, Inc. 102 Commerce Circle Madison, AL 35758-2706 USA 256-772-8922 ext. 108 /This e-mail message may contain privileged or confidential information. If you are not the intended recipient, you may not disclose, use, disseminate, distribute, copy or relay this message or attachment in any way. If you received this e-mail message in error, please return by forwarding the message and it's attachment to the sender and then delete the message and it's attachment from your computer./ /Neither Fiscal Systems, Inc., nor its affiliates, accept any liability for any errors, omissions, corruption or viruses in the contents of this message or any attachments that arise as a result of e-mail transmission./ _______________________________________________ gtkmm-list mailing list gtkmm-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtkmm-list