Implementing a ListView that responds to both single and double clicks

I have a ListView that should behave similarly to folder overviews in Nautilus, in that:

  • When single clicking a file/folder, I want to see details in a label (e.g. 'fooFile' selected (35 kB))
  • When double clicking a file/folder, it should open

How would you model this in Gtk? I know that ListView can use either single click and double click activations depending on the value of gtk_list_view_set_single_click_activate, but AFAIK not at the same time.

Single clicking should select the item, so you can use the SelectionModel to track that. If you’re using a GtkSingleSelection, you can connect to notify::selected or notify::selected-item.

More generically (e.g. if you’re using GtkMultiSelection), you can connect to the selection-changed signal. See also the note about items-changed in the documentation:

That works, thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.