[Glade-users] Ghost signals with libglade (ctn.)



- Sorry I accidentally pressed the Send button using
the keyboard...

Hi,

I just came across a strange behavior with libglade
yesterday. It's not lethal or anything but it's still
interesting to find out what actually happened.

I designed a GUI with glade (It's Glade-2 as I was a
bit panicky to switch to Glade-3 at this point for
reasons mentioned in another mail) which had a
GtkDrawingArea widget receiving "button_press_event"
(along with some other events).  I also used autotools
to ease the building process.  Everything went fine
until I needed to parse a pointer to a structure to
the signal handler.  I didn't do that straight away
but something simpler:

1. I manually removed the entry for the
button_press_event in the .glade file

2. In main.c, I obtained the drawing area widget and
manually attached the signal

...
pdrawingarea1 = glade_xml_get_widget (xml,
"pdrawingarea1");
g_signal_connect (pdrawingarea1, "button_press_event",
G_CALLBACK (on_pdrawingarea1_button_press_event),
(gpointer) 42);
...

3. Somewhere in the signal handler, I printed the
number:

printf ("%i\n", (int) user_data);

4. I rerun autogen.sh and make.

To my surprise, the signal handler was invoked twice
when I clicked the mouse button once, first time
printing a 0 and the second time printing the right
number.  And upon removing the line with
g_signal_connect() and recompile, the program still
listened to the mouse click and printed a 0.  This
really made me wonder how this ghost signal came
about.

It'd be much appreciated if someone can enlighten me.

Cheers,
DK

Send instant messages to your online friends http://au.messenger.yahoo.com 




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