Re: [gtk-list] Combo signal problem
- From: Allan Black <allan genia scotnet co uk>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Combo signal problem
- Date: Fri, 22 Oct 1999 13:59:03 +0100 (BST)
> I'm using a combo-list where I call a function every time the selection
> is changed. I use the "selection-changed" signal to do this, and this
> works mostly fine, except that when I select an entry the signal-handler
> is called 4 times.
Every time you drag over one of the popdown strings, the entry gets updated
and you get sent a signal.
> Since my signal handler connects to a MySQL database to fetch information
> this is wasting resources.
I had this problem too. In my case, there was visual feedback, so the screen
kept changing while the mouse was being dragged up & down the menu.
> Is there a practical way to avoid the 3 extra calls, or do I have to put
> in a check to see whether the signal was just done with the same data?
[I actually found this solution by looking at the AbiWord source.]
Connect to the "hide" signal on the combo's popup menu. When the menu is
hidden, go and see what value the user finally settled for.
gtk_signal_connect(GTK_OBJECT(GTK_COMBO(w)->popwin), "hide",
GTK_SIGNAL_FUNC(mycallback), w);
static void mycallback(GtkWidget *w, GtkCombo combo)
{
gchar *value;
value = gtk_entry_get_text(GTK_ENTRY(combo->entry));
[...]
}
Allan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]