After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 345023 - Single-click in treeview and iconview
Single-click in treeview and iconview
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTreeView
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtktreeview-bugs
gtktreeview-bugs
touch
Depends on:
Blocks:
 
 
Reported: 2006-06-15 15:36 UTC by Jean-François Fortin Tam
Modified: 2013-01-20 21:50 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Add an optional single click activation mode to treeview (8.36 KB, patch)
2013-01-18 09:33 UTC, William Jon McCann
needs-work Details | Review
Add a simple test for activate on single click (1.16 KB, patch)
2013-01-18 09:33 UTC, William Jon McCann
none Details | Review
Add optional single click activate for icon view (7.92 KB, patch)
2013-01-18 09:33 UTC, William Jon McCann
reviewed Details | Review
Add an optional single click activation mode to treeview (12.03 KB, patch)
2013-01-18 19:38 UTC, William Jon McCann
accepted-commit_now Details | Review
Add a simple test for activate on single click (1.16 KB, patch)
2013-01-18 19:38 UTC, William Jon McCann
accepted-commit_now Details | Review
Add optional single click activate for icon view (8.84 KB, patch)
2013-01-18 19:38 UTC, William Jon McCann
accepted-commit_now Details | Review
Add an optional single click activation mode to treeview (12.48 KB, patch)
2013-01-19 16:19 UTC, William Jon McCann
committed Details | Review
Add a simple test for activate on single click (1.16 KB, patch)
2013-01-19 16:19 UTC, William Jon McCann
committed Details | Review
Add optional single click activation mode for icon view (9.38 KB, patch)
2013-01-19 16:19 UTC, William Jon McCann
committed Details | Review

Description Jean-François Fortin Tam 2006-06-15 15:36:16 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.
Comment 1 Kristian Rietveld 2006-06-26 11:58:40 UTC
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 ...
Comment 2 Lionel Dricot 2008-03-09 22:19:45 UTC
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.
Comment 3 Cosimo Cecchi 2012-10-19 19:13:05 UTC
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.
Comment 4 William Jon McCann 2013-01-18 09:33:39 UTC
Created attachment 233737 [details] [review]
Add an optional single click activation mode to treeview
Comment 5 William Jon McCann 2013-01-18 09:33:42 UTC
Created attachment 233738 [details] [review]
Add a simple test for activate on single click
Comment 6 William Jon McCann 2013-01-18 09:33:45 UTC
Created attachment 233739 [details] [review]
Add optional single click activate for icon view
Comment 7 Cosimo Cecchi 2013-01-18 17:18:01 UTC
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?
Comment 8 Cosimo Cecchi 2013-01-18 17:18:38 UTC
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?
Comment 9 William Jon McCann 2013-01-18 17:22:21 UTC
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.
Comment 10 Cosimo Cecchi 2013-01-18 17:23:02 UTC
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.
Comment 11 William Jon McCann 2013-01-18 19:38:19 UTC
Created attachment 233787 [details] [review]
Add an optional single click activation mode to treeview
Comment 12 William Jon McCann 2013-01-18 19:38:28 UTC
Created attachment 233788 [details] [review]
Add a simple test for activate on single click
Comment 13 William Jon McCann 2013-01-18 19:38:30 UTC
Created attachment 233789 [details] [review]
Add optional single click activate for icon view
Comment 14 Cosimo Cecchi 2013-01-18 19:52:05 UTC
Patches look good to me now.
Comment 15 Benjamin Otte (Company) 2013-01-18 23:11:02 UTC
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?
Comment 16 Matthias Clasen 2013-01-19 00:33:49 UTC
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
Comment 17 Matthias Clasen 2013-01-19 00:38:52 UTC
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
Comment 18 Matthias Clasen 2013-01-19 00:39:16 UTC
Review of attachment 233788 [details] [review]:

sure
Comment 19 Matthias Clasen 2013-01-19 00:39:55 UTC
Review of attachment 233787 [details] [review]:

please commit with the doc fixes
Comment 20 Matthias Clasen 2013-01-19 00:40:13 UTC
Review of attachment 233789 [details] [review]:

please commit with the documentation changes
Comment 21 William Jon McCann 2013-01-19 15:28:16 UTC
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?
Comment 22 William Jon McCann 2013-01-19 16:19:23 UTC
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.
Comment 23 William Jon McCann 2013-01-19 16:19:34 UTC
Created attachment 233873 [details] [review]
Add a simple test for activate on single click
Comment 24 William Jon McCann 2013-01-19 16:19:52 UTC
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.
Comment 25 Matthias Clasen 2013-01-20 21:26:42 UTC
Review of attachment 233872 [details] [review]:

ok
Comment 26 Matthias Clasen 2013-01-20 21:26:59 UTC
Review of attachment 233873 [details] [review]:

ok
Comment 27 Matthias Clasen 2013-01-20 21:27:18 UTC
Review of attachment 233874 [details] [review]:

ok
Comment 28 William Jon McCann 2013-01-20 21:50:06 UTC
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