Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pluma-notebook: avoid new file with double click in forward arrow button
Fixes #331
  • Loading branch information
sc0w committed May 29, 2018
1 parent f6f9fdc commit 3742ba4
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion pluma/pluma-notebook.c
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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:
*
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 3742ba4

Please sign in to comment.