Re: Handling multiple selections in a Gtk::TreeView



On Thu, 2004-11-25 at 22:17 +0100, Matthias wrote:
> Hi,
> 
> I'm working on a widget which uses a TreeView with the ListStore model.
> Now, multiple selections should be possible. However, the documentation in 
> this case is rather lacking, I can't get it to work.
> 
> First of all, some basic questions.

This is mentioned in the book, by the way:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch08s04.html

> 1) What exactly do I need that callback function for that I pass to 
> TreeSelection::selected_foreach and when is it called?

It's called once for each row that is selected. It is synchronous,
meaning that it only returns when it has finished calling your callback.

This is documented:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeSelection.html#a16

> 2) What is a ListHandle_Path and how do I use it?

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch03s05.html

> 3) What is a slot, and what is a path?

It is a libsigc++ callback object:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/ch03s03.html

http://libsigc.sourceforge.net/libsigc1_2/manual/html/
(though that's for libsigc++ 1.2, which is used by gtkmm 2.2)

> and what is a path?

From
http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1TreeModel.html

"A Gtk::TreeModel::Path is essentially a potential node. It is a
location on a model that may or may not actually correspond to a node on
a specific model."

> What I have is this:
> 
> (in the ctor of my widget)
> 
> m_selection->set_mode( Gtk::SELECTION_MULTIPLE );
> m_selection->selected_foreach_iter( sigc::mem_fun( *this,    
> &FileBrowser::selection_callback ) );

There is no point in examining the selected rows before the user has had
a chance to select them.

> m_selection->signal_changed().connect( sigc::mem_fun( *this, 
> &FileBrowser::on_selection_changed ) );
> 
> ... where m_selection is a TreeSelection RefPtr.
> 
> Furthermore:
> 
> void FileBrowser::selection_callback( const Gtk::TreeModel::iterator & iter )
> {
>     Gtk::TreeModel::Row row = *iter;
>     cout << "selection_callback" << endl;
> }
> 
> void FileBrowser::on_selection_changed()
> {
>     cout << "on_selection_changed" << endl;
> }
> 
> However, selecting multiple rows only seems to issue the selection handler. 
> The callback function is never called.

Hopefully it makes sense now.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com





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