From 6bb0e96d7ace34f8aab7ba3b99c9f9a077ac266a Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 20 Oct 2012 10:01:35 +0200 Subject: [PATCH] Add listbox double-click callback This function was formerly performed by WheelProc. --- xoptions.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/xoptions.c b/xoptions.c index 5fb0e49..fb203c6 100644 --- a/xoptions.c +++ b/xoptions.c @@ -980,6 +980,18 @@ void BrowseGTK(GtkWidget *widget, gpointer gdata) dialog = NULL; } +gboolean +ListCallback (GtkWidget *widget, GdkEventButton *event, gpointer gdata) +{ + int n = (intptr_t) gdata & 0xFFFF; + int dlg = (intptr_t) gdata >> 16; + Option *opt = dialogOptions[dlg] + n; + + if(event->type != GDK_2BUTTON_PRESS || event->button != 1) return FALSE; + ((ListBoxCallback*) opt->textValue)(n, SelectedListBoxItem(opt)); + return TRUE; +} + static char *oneLiner = "Return: redraw-display() \n \ Tab: TabProc() \n "; @@ -1382,6 +1394,9 @@ printf("n=%d, h=%d, w=%d\n",n,height,width); gtk_container_add(GTK_CONTAINER(sw), list); gtk_widget_set_size_request(GTK_WIDGET(sw), option[i].max ? option[i].max : -1, option[i].value ? option[i].value : -1); + if(option[i].textValue) // generic callback for double-clicking listbox item + g_signal_connect(list, "button-press-event", G_CALLBACK(ListCallback), (gpointer) (dlgNr<<16 | i) ); + /* never has label, so let listbox occupy all columns */ Pack(hbox, table, sw, left, left+r, top, GTK_EXPAND); } -- 1.7.0.4