Skip to content

Commit 3742ba4

Browse files
committed
pluma-notebook: avoid new file with double click in forward arrow button
Fixes #331
1 parent f6f9fdc commit 3742ba4

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

pluma/pluma-notebook.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static void move_current_tab_to_another_notebook (PlumaNotebook *src,
8484
static GdkCursor *cursor = NULL;
8585
static gboolean leftdown = FALSE;
8686
static gboolean drag_ready = FALSE;
87+
static gboolean newfile_ready = TRUE;
8788

8889
/* Signals */
8990
enum
@@ -690,7 +691,11 @@ button_press_cb (PlumaNotebook *notebook,
690691
if (event->type == GDK_BUTTON_PRESS)
691692
{
692693
tab1click = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
693-
newfile = (tab_clicked == -1);
694+
695+
if (newfile_ready)
696+
newfile = (tab_clicked == -1);
697+
else
698+
newfile = FALSE;
694699
}
695700
else if (event->type == GDK_2BUTTON_PRESS)
696701
{
@@ -714,6 +719,24 @@ grab_focus_cb (PlumaNotebook *notebook,
714719
return FALSE;
715720
}
716721

722+
static gboolean
723+
focus_in_cb (PlumaNotebook *notebook,
724+
GdkEventButton *event,
725+
gpointer data)
726+
{
727+
newfile_ready = FALSE;
728+
return FALSE;
729+
}
730+
731+
static gboolean
732+
focus_out_cb (PlumaNotebook *notebook,
733+
GdkEventButton *event,
734+
gpointer data)
735+
{
736+
newfile_ready = TRUE;
737+
return FALSE;
738+
}
739+
717740
/**
718741
* pluma_notebook_new:
719742
*
@@ -815,6 +838,16 @@ pluma_notebook_init (PlumaNotebook *notebook)
815838
(GCallback)grab_focus_cb,
816839
NULL);
817840

841+
g_signal_connect (notebook,
842+
"focus-in-event",
843+
(GCallback)focus_in_cb,
844+
NULL);
845+
846+
g_signal_connect (notebook,
847+
"focus-out-event",
848+
(GCallback)focus_out_cb,
849+
NULL);
850+
818851
gtk_widget_add_events (GTK_WIDGET (notebook),
819852
GDK_BUTTON1_MOTION_MASK);
820853

0 commit comments

Comments
 (0)