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.

[originally from svn r7414]
This commit is contained in:
Simon Tatham 2007-03-27 18:16:36 +00:00
Родитель d1df3e226a
Коммит 7e4eb1f404
1 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -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,7 +96,9 @@ 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,
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);
@ -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,
static int listitem_button_press(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));
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;
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: