GNOME Bugzilla – Bug 345023
Single-click in treeview and iconview
Last modified: 2013-01-20 21:50:14 UTC
taken from http://trac.gajim.org/ticket/2072 please take a look, as it describes the situation a lot better than this small summary: There is a setting in GNOME that makes applications such as nautilus use single-clicking (it also exists in Windows as far as I know). It would be interesting to provide that as a feature of GTK instead, so that not all software writers have to implement the same feature over and over again. The problem I see however is that this setting should not be enforced. A few applications require a special behavior depending on single or double click signals. It has been suggested to me that I report this issue to gtk, so here I am. I don't think this only applies to treeview though.
Reading the original ticket it sounds like this is just covered by hover selection and connecting to button-press or button-release on the tree view ...
I agree that Gtk should support single click in tree view. My father always had problem with double-click. I set the "single click" preference for him in nautilus and I told him : "never double click again". He was very happy until he tried to play a song in Rhythmbox. And He still doesn't understand why he should double-click there.
I think it would be nice to have an API on GtkTreeView and GtkIconView to choose whether row/item activation is emitted on single or double click - it would stop applications that want to change the default behavior writing complex and hairy button-press/button-release-event handlers.
Created attachment 233737 [details] [review] Add an optional single click activation mode to treeview
Created attachment 233738 [details] [review] Add a simple test for activate on single click
Created attachment 233739 [details] [review] Add optional single click activate for icon view
Review of attachment 233737 [details] [review]: ::: gtk/gtk.symbols @@ +3522,3 @@ gtk_tree_view_expand_row gtk_tree_view_expand_to_path +gtk_tree_view_get_activate_on_single_click Should also add these to gtk3-sections.txt in docs/reference/gtk ::: gtk/gtktreeview.c @@ +3210,3 @@ + else + { + tree_view->priv->button_pressed_node = tree_view->priv->prelight_node; Shouldn't we still check for GDK_BUTTON_PRIMARY + GDK_BUTTON_PRESS here? @@ +3409,3 @@ + if (tree_view->priv->activate_on_single_click + && tree_view->priv->button_pressed_node != NULL) This button_pressed_node != NULL check is not necessary, since right above the function returns FALSE if it's the case. I think this block should be moved into the following though; we still need to check for event->button == GDK_BUTTON_PRIMARY, and set button_pressed_tree/node to NULL after activation. Also, if the expander was hit instead, I don't think you want to emit both row-activated and row-expanded/collapsed in that case. Finally, what happens if the button press and release happen on two different rows?
Review of attachment 233738 [details] [review]: ::: tests/testtreeview.c @@ +749,2 @@ tv = gtk_tree_view_new_with_model (models[0]); + g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL); Where do you set activate-on-single-click in the test?
Review of attachment 233738 [details] [review]: ::: tests/testtreeview.c @@ +749,2 @@ tv = gtk_tree_view_new_with_model (models[0]); + g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL); The test window includes toggles for all properties.
Review of attachment 233739 [details] [review]: ::: gtk/gtk.symbols @@ +1330,3 @@ gtk_icon_view_enable_model_drag_dest gtk_icon_view_enable_model_drag_source +gtk_icon_view_get_activate_on_single_click These should also go in the docs ::: gtk/gtkiconview.c @@ +2389,3 @@ + { + GtkTreePath *path; + GtkIconViewItem *item = icon_view->priv->last_single_clicked; I think we should still check that the release event is on the same item here.
Created attachment 233787 [details] [review] Add an optional single click activation mode to treeview
Created attachment 233788 [details] [review] Add a simple test for activate on single click
Created attachment 233789 [details] [review] Add optional single click activate for icon view
Patches look good to me now.
Could we have an explanation in the API docs for why you would ever want to set / not set that property? I think it's hellishly confusing if sometimes treeviews activate and sometimes they don't. Or is that just me?
Review of attachment 233787 [details] [review]: Other than that, looks ok ::: gtk/gtktreeview.c @@ +1183,3 @@ + * The activate-on-single-click property specifies whether the "row-activated" signal + * will be emitted after a single click. + * The documentation should point out that this interferes with selection handling - it does, right ? @@ +11834,3 @@ + * instead of double click. + * + **/ Needs a Since: 3.8 here @@ +11857,3 @@ + * + * Return value: %TRUE if row-activated will be emitted on single click + **/ Since: 3.8
Review of attachment 233789 [details] [review]: looks good otherwise ::: gtk/gtkiconview.c @@ +115,3 @@ + PROP_VSCROLL_POLICY, + + PROP_ACTIVATE_ON_SINGLE_CLICK Unexpected empty line here @@ +7194,3 @@ + * Cause the "item-activated" signal to be emitted on single click + * instead of double click. + * Since: 3.8, and make it 3rd person: 'Causes ...' Also, not sure if we are consistent on this, but wouldn't it be better to say 'single-click' and 'double-click' ? @@ +7217,3 @@ + * Gets the setting set by gtk_icon_view_set_activate_on_single_click(). + * + * Return value: %TRUE if item-activated will be emitted on single click Since: 3.8
Review of attachment 233788 [details] [review]: sure
Review of attachment 233787 [details] [review]: please commit with the doc fixes
Review of attachment 233789 [details] [review]: please commit with the documentation changes
Review of attachment 233789 [details] [review]: ::: gtk/gtkiconview.c @@ +115,3 @@ + PROP_VSCROLL_POLICY, + + PROP_ACTIVATE_ON_SINGLE_CLICK I was trying to separate it from the scrollable interface properties. I don't think I can add it above because that would change ABI right?
Created attachment 233872 [details] [review] Add an optional single click activation mode to treeview Instead of adding the docs to point out this interferes with selection mode it might be better to just not activate when explicitly changing the selection.
Created attachment 233873 [details] [review] Add a simple test for activate on single click
Created attachment 233874 [details] [review] Add optional single click activation mode for icon view Instead of adding the docs to point out this interferes with selection mode it might be better to just not activate when explicitly changing the selection.
Review of attachment 233872 [details] [review]: ok
Review of attachment 233873 [details] [review]: ok
Review of attachment 233874 [details] [review]: ok
Attachment 233872 [details] pushed as dcc412c - Add an optional single click activation mode to treeview Attachment 233873 [details] pushed as a84f244 - Add a simple test for activate on single click Attachment 233874 [details] pushed as c7169e1 - Add optional single click activation mode for icon view