Re: Signals firing too often




On Thursday, May 20, 2004, at 08:58 PM, Daniel Kasak wrote:

I've got a Gtk2::SimpleList that triggers some code when a row is selected. The signal I'm currently using is 'button_release_event'. I've tried a fair few others.

have you tried the "changed" signal of the treeview's selection?

  $simplelist->get_selection->signal_connect (changed => \&func);

http://developer.gnome.org/doc/API/2.0/gtk/ GtkTreeSelection.html#GtkTreeSelection-changed


The update process refreshes the data in the Gtk2::SimpleList, which seems to trigger more events, and it doesn't matter which signal I use, they all seem to get triggered multiple times. Without any further modification, I get 3 events.

erm, sorry, but this is a little too vague to make sense of. are you changing which row is selected? (that includes clearing the list and refilling it.) are you changing the data of the selected row? is it the same signal that fires three times or different ones? do they fire recursively?


Is there a signal I can use to catch when someone selects a row in a SimpleList that:
a) Won't get triggered if the SimpleList data is rebuild
b) Won't trigger multiple times?

trap the selection's "changed" signal, and get the index of the selected row.
refill the simplelist.
programmatically select the row at the index you found a moment ago. you may have to set up a guard that lets you know not to run your handler again (e.g., signal_handlers_block or a boolean flag of your own).


--
Brian: If i recall correctly, this is the physics department.
Chris: That explains all that gravity.
        -- Family Guy, "The Story on Page One"




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]