From b4ac18ae9c7c937e7359a8bf9d44c6de5f07bd71 Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 27 Mar 2007 18:16:36 +0000 Subject: [PATCH] Patch from John Sullivan: process double-clicks in the session list box on button-up rather than button-down. The effect of this is that if a saved session is already selected in the list box and then you double-click it, it will open rather than beeping annoyingly. git-svn-id: svn://svn.tartarus.org/sgt/putty@7414 cda61777-01e9-0310-a592-d414129be87e --- unix/gtkdlg.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index 0a870ca3..10138e27 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -57,6 +57,7 @@ struct uctrl { GtkWidget *label; /* for dlg_label_change */ GtkAdjustment *adj; /* for the scrollbar in a list box */ guint textsig; + int nclicks; }; struct dlgparam { @@ -95,8 +96,10 @@ static int listitem_single_key(GtkWidget *item, GdkEventKey *event, gpointer data); static int listitem_multi_key(GtkWidget *item, GdkEventKey *event, gpointer data); -static int listitem_button(GtkWidget *item, GdkEventButton *event, - gpointer data); +static int listitem_button_press(GtkWidget *item, GdkEventButton *event, + gpointer data); +static int listitem_button_release(GtkWidget *item, GdkEventButton *event, + gpointer data); static void menuitem_activate(GtkMenuItem *item, gpointer data); static void coloursel_ok(GtkButton *button, gpointer data); static void coloursel_cancel(GtkButton *button, gpointer data); @@ -439,7 +442,9 @@ void dlg_listbox_addwithid(union control *ctrl, void *dlg, gtk_signal_connect(GTK_OBJECT(listitem), "focus_in_event", GTK_SIGNAL_FUNC(widget_focus), dp); gtk_signal_connect(GTK_OBJECT(listitem), "button_press_event", - GTK_SIGNAL_FUNC(listitem_button), dp); + GTK_SIGNAL_FUNC(listitem_button_press), dp); + gtk_signal_connect(GTK_OBJECT(listitem), "button_release_event", + GTK_SIGNAL_FUNC(listitem_button_release), dp); gtk_object_set_data(GTK_OBJECT(listitem), "user-data", GINT_TO_POINTER(id)); } else { @@ -1083,13 +1088,26 @@ static int listitem_multi_key(GtkWidget *item, GdkEventKey *event, return listitem_key(item, event, data, TRUE); } -static int listitem_button(GtkWidget *item, GdkEventButton *event, - gpointer data) +static int listitem_button_press(GtkWidget *item, GdkEventButton *event, + gpointer data) +{ + struct dlgparam *dp = (struct dlgparam *)data; + struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item)); + switch (event->type) { + default: + case GDK_BUTTON_PRESS: uc->nclicks = 1; break; + case GDK_2BUTTON_PRESS: uc->nclicks = 2; break; + case GDK_3BUTTON_PRESS: uc->nclicks = 3; break; + } + return FALSE; +} + +static int listitem_button_release(GtkWidget *item, GdkEventButton *event, + gpointer data) { struct dlgparam *dp = (struct dlgparam *)data; - if (event->type == GDK_2BUTTON_PRESS || - event->type == GDK_3BUTTON_PRESS) { - struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item)); + struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item)); + if (uc->nclicks>1) { uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_ACTION); return TRUE; } @@ -1367,6 +1385,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs, uc->entry = uc->list = uc->menu = NULL; uc->button = uc->optmenu = uc->text = NULL; uc->label = NULL; + uc->nclicks = 0; switch (ctrl->generic.type) { case CTRL_BUTTON: -- 2.11.0