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 780799 - Close tabs with middle mouse button
Close tabs with middle mouse button
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: Tabs
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
https://gitlab.gnome.org/GNOME/nautil...
Depends on:
Blocks:
 
 
Reported: 2017-04-01 09:45 UTC by Tiberiu Lepadatu
Modified: 2018-05-26 16:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
notebook: close tab with middle click (1.36 KB, patch)
2017-04-01 09:45 UTC, Tiberiu Lepadatu
needs-work Details | Review

Description Tiberiu Lepadatu 2017-04-01 09:45:02 UTC
Close tab with middle click. All tabs based applications have this
possibility. Used g_signal_emit() function to do so.
Comment 1 Tiberiu Lepadatu 2017-04-01 09:45:06 UTC
Created attachment 349106 [details] [review]
notebook: close tab with middle click
Comment 2 Razvan Chitu 2017-04-01 10:11:52 UTC
Review of attachment 349106 [details] [review]:

The commit message needs a bit more work.

"All tabs based applications have this possibility" -> how do you know that? :) How about: "In other applications such as browsers tabs can be closed using middle click."

The commit message does not need to mention the functions you used. People can see that by looking at your code. You should focus on explaining what you did and how you did it: "Implement this by emitting a tab close request when a user middle clicks a tab."

::: src/nautilus-notebook.c
@@ +162,3 @@
     }
 
+if (event->type == GDK_BUTTON_PRESS &&

This line is unindented.

@@ +166,3 @@
+        (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
+    {
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));

This line is too long.
Also, the first parameter for gtk_notebook_get_nth_page has to be of type GtkNotebook *. You should cast it because right now the patch introduces a compile warning.

@@ +168,3 @@
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));
+
+        if (tab_clicked == -1)

This check should be done before calling g_signal_emit.

@@ +171,3 @@
+        {
+            /* consume event, so that we don't pop up the context menu when
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));

This comment is not relevant.

@@ +176,3 @@
+        }
+
+        if (tab_clicked == -1)

This comment is no longer relevant. Be more careful when copy-pasting code!
Also, maybe you should mark the event as consumed here, since you are going to close the tab anyway.
Comment 3 Razvan Chitu 2017-04-01 10:11:55 UTC
Review of attachment 349106 [details] [review]:

The commit message needs a bit more work.

"All tabs based applications have this possibility" -> how do you know that? :) How about: "In other applications such as browsers tabs can be closed using middle click."

The commit message does not need to mention the functions you used. People can see that by looking at your code. You should focus on explaining what you did and how you did it: "Implement this by emitting a tab close request when a user middle clicks a tab."

::: src/nautilus-notebook.c
@@ +162,3 @@
     }
 
+if (event->type == GDK_BUTTON_PRESS &&

This line is unindented.

@@ +166,3 @@
+        (event->state & gtk_accelerator_get_default_mod_mask ()) == 0)
+    {
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));

This line is too long.
Also, the first parameter for gtk_notebook_get_nth_page has to be of type GtkNotebook *. You should cast it because right now the patch introduces a compile warning.

@@ +168,3 @@
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));
+
+        if (tab_clicked == -1)

This check should be done before calling g_signal_emit.

@@ +171,3 @@
+        {
+            /* consume event, so that we don't pop up the context menu when
+        g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, gtk_notebook_get_nth_page (notebook, tab_clicked));

This comment is not relevant.

@@ +176,3 @@
+        }
+
+        if (tab_clicked == -1)

This comment is no longer relevant. Be more careful when copy-pasting code!
Also, maybe you should mark the event as consumed here, since you are going to close the tab anyway.
Comment 4 Ernestas Kulik 2017-04-01 10:13:53 UTC
Review of attachment 349106 [details] [review]:

::: src/nautilus-notebook.c
@@ +163,3 @@
 
+if (event->type == GDK_BUTTON_PRESS &&
+        event->button == 2 &&

GDK_BUTTON_MIDDLE

@@ +173,3 @@
+             * the mouse if not over a tab label
+             */
+            return TRUE;

Try to use GDK_EVENT_STOP and GDK_EVENT_PROPAGATE.
Comment 5 Carlos Soriano 2017-04-01 10:38:25 UTC
Design wise this topic is something we avoided in the past. As opposed to what the first commit message says, no GNOME app implements this behavior. So this need to be checked with designers.
Comment 6 António Fernandes 2018-02-07 09:17:32 UTC
Discussion continues on gitlab https://gitlab.gnome.org/GNOME/nautilus/issues/47
Comment 7 António Fernandes 2018-05-26 16:24:17 UTC
*** Bug 687267 has been marked as a duplicate of this bug. ***