How to make a Gtk.Iconview react to single click instead of double click?

Solution 1:

One solution (but only for the single click activation) is of cause to use the selection_changed signal of the IconView (because the IconView selection is single click based).

A sample that assumes a working on_item_activated signal would be:

def on_icon_view_selection_changed(self, widget):
        self.on_item_activated(widget, widget.get_selected_items()[0])

Solution 2:

A GtkIconView is not an arrangement of button widgets into a table. It is basically a special case of GtkTreeView, with items laid out in a grid, rather than a list/tree. To do highlight of items on hover, I believe a patch to GTK+ would be required. A patch would also be required to add API to enable single-click vs. double-click to activate, however, this feature can be implemented on top of the existing widget API, by listening to the button_press_event signal on the widget, and acting accordingly.

Solution 3:

You seem to explore the limitations of Gtk lately :-)

First of all, dobeys answer seems correct.

Tree- and List-Stores are a good choice for collections. Larger amounts of data which are identical in type but different in meta-content (e.g. a music collection where every piece has an artist, album, title, but the actual artist name, album name, title name changes).

The good thing about these widgets is that they are easily sortable, many items can be selected (e.g. in 'rubber-band' mode), and you need relatively few lines of code to add thousands of similar items.

Changing the way a TreeView or ListView behaves to clicks / hover etc on a per application level is a bad idea, because it messes with the way users expect your application to behave. You found that out yourself based on the reaction you describe in your question.

Your problem however is that users did not understand that your widget is a TreeView / ListView, instead they thought that they are a number of buttons. And that seems to make sense, based on your screenshot.

Buttons are meant to start an action (e.g. stop, play, pause) or communicate with the program (e.g. Ok, Cancel) or even act as a link to a different view (see LinkButton). They don't normally have an (abstract) object or item associated with it (e.g. ' "Sammy Davis Jr" by "Movits!" from the album "Out of my head" ').

So, while the not-configurable click behaviour is a shortcoming of gtk, it should anyway only be on a per-user global level.

What you want is probably a grid with Buttons. (Buttons can also contain icons).