From d7a1ac5cec8aa955fcdf47c97109b36a00b142c8 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Mon, 23 Sep 2024 11:08:22 -0400 Subject: [PATCH] display: Close image tabs with middle mouse button This adds a "button-press-event" to the ImageWindow's image tabs. If the user has clicked with the middle mouse button, it calls the same close code as if they had clicked on the "X" button. --- app/display/gimpimagewindow.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c index c0a08344a5..4140e3c493 100644 --- a/app/display/gimpimagewindow.c +++ b/app/display/gimpimagewindow.c @@ -265,6 +265,9 @@ static GtkWidget * gimp_image_window_create_tab_label (GimpImageWindow *window, GimpDisplayShell *shell); static void gimp_image_window_update_tab_labels (GimpImageWindow *window); +gboolean gimp_image_window_tab_button_press (GtkWidget *widget, + GdkEventButton *event, + GimpDisplayShell *shell); static void gimp_image_window_configure_pad (GimpImageWindow *window, GimpDeviceInfo *info); @@ -1320,6 +1323,9 @@ gimp_image_window_add_shell (GimpImageWindow *window, private->shells = g_list_append (private->shells, shell); tab_label = gimp_image_window_create_tab_label (window, shell); + g_signal_connect_object (tab_label, "button-press-event", + G_CALLBACK (gimp_image_window_tab_button_press), + shell, 0); gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook), GTK_WIDGET (shell), tab_label); @@ -2506,6 +2512,20 @@ gimp_image_window_update_tab_labels (GimpImageWindow *window) g_list_free (children); } +gboolean +gimp_image_window_tab_button_press (GtkWidget *widget, + GdkEventButton *event, + GimpDisplayShell *shell) +{ + if (event->type == GDK_BUTTON_PRESS && event->button == 2) + { + if (shell) + gimp_display_shell_close (shell, FALSE); + } + + return TRUE; +} + static void gimp_image_window_configure_pad (GimpImageWindow *window, GimpDeviceInfo *info)