Skip to content

Commit ea60fd3

Browse files
committed
pluma-notebook: avoid new file with double click in forward arrow button
Fixes #331
1 parent 5fb5765 commit ea60fd3

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
@@ -664,7 +665,11 @@ button_press_cb (PlumaNotebook *notebook,
664665
if (event->type == GDK_BUTTON_PRESS)
665666
{
666667
tab1click = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
667-
newfile = (tab_clicked == -1);
668+
669+
if (newfile_ready)
670+
newfile = (tab_clicked == -1);
671+
else
672+
newfile = FALSE;
668673
}
669674
else if (event->type == GDK_2BUTTON_PRESS)
670675
{
@@ -688,6 +693,24 @@ grab_focus_cb (PlumaNotebook *notebook,
688693
return FALSE;
689694
}
690695

696+
static gboolean
697+
focus_in_cb (PlumaNotebook *notebook,
698+
GdkEventButton *event,
699+
gpointer data)
700+
{
701+
newfile_ready = FALSE;
702+
return FALSE;
703+
}
704+
705+
static gboolean
706+
focus_out_cb (PlumaNotebook *notebook,
707+
GdkEventButton *event,
708+
gpointer data)
709+
{
710+
newfile_ready = TRUE;
711+
return FALSE;
712+
}
713+
691714
/**
692715
* pluma_notebook_new:
693716
*
@@ -789,6 +812,16 @@ pluma_notebook_init (PlumaNotebook *notebook)
789812
(GCallback)grab_focus_cb,
790813
NULL);
791814

815+
g_signal_connect (notebook,
816+
"focus-in-event",
817+
(GCallback)focus_in_cb,
818+
NULL);
819+
820+
g_signal_connect (notebook,
821+
"focus-out-event",
822+
(GCallback)focus_out_cb,
823+
NULL);
824+
792825
gtk_widget_add_events (GTK_WIDGET (notebook),
793826
GDK_BUTTON1_MOTION_MASK);
794827

0 commit comments

Comments
 (0)