From 3742ba44a1cc6d8180517576f53e4050598dbe30 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Tue, 29 May 2018 10:51:50 +0200 Subject: pluma-notebook: avoid new file with double click in forward arrow button Fixes https://github.com/mate-desktop/pluma/issues/331 --- pluma/pluma-notebook.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/pluma/pluma-notebook.c b/pluma/pluma-notebook.c index 1b84bdb7..bc5f30e9 100644 --- a/pluma/pluma-notebook.c +++ b/pluma/pluma-notebook.c @@ -84,6 +84,7 @@ static void move_current_tab_to_another_notebook (PlumaNotebook *src, static GdkCursor *cursor = NULL; static gboolean leftdown = FALSE; static gboolean drag_ready = FALSE; +static gboolean newfile_ready = TRUE; /* Signals */ enum @@ -690,7 +691,11 @@ button_press_cb (PlumaNotebook *notebook, if (event->type == GDK_BUTTON_PRESS) { tab1click = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); - newfile = (tab_clicked == -1); + + if (newfile_ready) + newfile = (tab_clicked == -1); + else + newfile = FALSE; } else if (event->type == GDK_2BUTTON_PRESS) { @@ -714,6 +719,24 @@ grab_focus_cb (PlumaNotebook *notebook, return FALSE; } +static gboolean +focus_in_cb (PlumaNotebook *notebook, + GdkEventButton *event, + gpointer data) +{ + newfile_ready = FALSE; + return FALSE; +} + +static gboolean +focus_out_cb (PlumaNotebook *notebook, + GdkEventButton *event, + gpointer data) +{ + newfile_ready = TRUE; + return FALSE; +} + /** * pluma_notebook_new: * @@ -815,6 +838,16 @@ pluma_notebook_init (PlumaNotebook *notebook) (GCallback)grab_focus_cb, NULL); + g_signal_connect (notebook, + "focus-in-event", + (GCallback)focus_in_cb, + NULL); + + g_signal_connect (notebook, + "focus-out-event", + (GCallback)focus_out_cb, + NULL); + gtk_widget_add_events (GTK_WIDGET (notebook), GDK_BUTTON1_MOTION_MASK); -- cgit v1.2.1