Setting Gtk.ListView() single-click-activate property

I’m trying to set the single-click-activate property to False (which from what I understand is the default value…?) but I can’t get it to work:

lv = Gtk.ListView.new(self.selection, self.factory)
lv.set_property("show-separators", True) # <= This works
lv.set_property("single-click-activate", False) # <= This doesn't, why?

First of all, please: use idiomatic Python

listView = Gtk.ListView(model=self.selection, factory=self.factory)
listview.props.show_separators = True
listview.props.single_click_activate = False

The single-click-activate property is already false by default, so setting it to False won’t do anything.

But, more importantly: what does “I can’t get it to work” mean? Care to describe:

  • what you expect?
  • what you are observing?

First of all, please: use idiomatic Python

Ok, thanks & sorry about that.

what you expect?

I need the item to be activated on double-click / Return only

what you are observing?

The item is activated as soon as it is selected.

By the lack of warnings or errors, I already suspected that I did not understand what this property does, and that’s apparently the case. Is there another property I overlooked that would allow me to achieve what I need?

The single-click-activate property is already false by default, so setting it to False won’t do anything.

Oh, I get it : This property toggles the behaviour between “activate on hover” and “activate on click” so OK, this is covered, but how can I set the behaviour to “activate on double click”? I’m only asking because I didn’t find the answer anywhere, starting from the documentation. I looked at the Selection() properties too, but no luck.

Suddenly I’m thinking that what I want to do may simply be impossible, due to the tactile orientation of Gtk4 (or maybe just Adwaita) is that it? Because that would be a perfectly acceptable answer…?

I don’t think that that’s correct. If single-click-activate is False, then I believe GtkListView should already display the behaviour you want: double-click activate (or Enter), single-click select.

Maybe this is a problem with the GtkListItem instead. The GtkListView properties control how activation/selection work, but GtkListItem:activatable and GtkListItem:selectable control when those are enabled for a row.

1 Like

Ok, I found out ; I was using the selection-changed signal, and was wondering why my callback fired on selection change, because I’m an idiot. Thanks a lot for your patience.

I don’t think that that’s correct. If single-click-activate is False, then I believe GtkListView should already display the behaviour you want: double-click activate (or Enter), single-click select.

That is right indeed.

1 Like