[gtkmm] going crazy with the multipe selection with Gtk::TreeSelection



Hello!
yes, it s still me with another new problem :p with Gtkmm 2.2 (not 2.4 for the moment)

this time, i ve made a Gtk::ListStore with several rows.
i ve add a button witch can add a new row, and another witch can delete the highlighted (= selectionned row). it works, so i ve tried to enable multiple selection (this is ok) and then to enable multiple supression and this last thing is my problem.

i ve read the docs of gtkmm.org about it, and i ve made my callback and the multiple selection as explained, but i don t manage to compile my prog! in the examples i found

here is the doc explanations:

------------------------------------------------------------------------------
For multiple-selection, you need to define a callback, and give it to selected_foreach(), like so:

refTreeSelection->selected_foreach( SigC::Slot(*this, &TheClass::selected_row_callback) );

...

void TheClass::selected_row_callback(const Gtk::TreeModel::iterator& iter)
{
 TreeModel::Row row = *iter;
 //Do something with the row.
}
------------------------------------------------------------------------------

I imagine that the first instruction is supposed to connect each selected row to the &TheClass::selected_row_callback to "do a thing" with each row separately.
but the callback has an iter parameter and THIS is my problem: i don t manage to put it in the first instruction...

here is a part of my source:

------------------------------------------------------------------------
//to enable multiple rows selection
	refTreeSelection = billArray.get_selection();
	refTreeSelection->set_mode(Gtk::SELECTION_MULTIPLE);

...


//called when we press the "delete_lines" button
void BillFormat::on_delline_press()
{	// ok for single selection
/*	refTreeSelection = billArray.get_selection();
	Gtk::TreeModel::iterator iter;
	iter = refTreeSelection->get_selected();
	row = *(m_refListModel->erase(iter));*/

	//for multiple selection
	refTreeSelection->selected_foreach
		(SigC::slot(*this, &BillFormat::selected_row_callback(iter) ) );
}


void BillFormat::selected_row_callback(Gtk::TreeModel::iterator iter)
{
//	Gtk::TreeModel::iterator iter;
//	iter = refTreeSelection->get_selected();	
 	Gtk::TreeModel::Row row = *iter;

	row = *(m_refListModel->erase(iter));
}
-------------------------------------------------------------------------------------

i ve tried many ways to pass the iter parameter without any success...

the closest to the candidates (suggered by the compilator for the call to "
Gtk::TreeSelection::selected_foreach" was with "...->
selected_foreach(SigC::slot(*this, &BillFormat::selected_row_callback,iter ) );" and removing the iter parameter in the declaration of "selected_row_callback".

really, i m out of intuition! :'(
one more time, thanks for your help! ;-)
cedric






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]