Re: [gtkmm] sensitivity seems to be 'ignored'



Ahh, I think I understand! Let me summarize this:
Each callback routine is handled like an atomic function, which
'normally' won't get interrupted. But by inserting
while(g_main_iteration(FALSE)) pending events are processed
immediately, even if this means to interrupt the current
callback. And after processing the 'interrupting' callback,
processing continues where it got before interruption.
Is that correct that way?!

Btw, that fix of yours, Manuel, worked of course! Thanks for
helping!

Many cheers,
Jeffrey Rush

ok, the attachment holds a short C++ example file (buttontest.cc).
I also did a pure GTK+ version of it (buttons.c) - same trouble.
Example usage (after compiling and starting):
click "cool button" - uncool button set insensitive, click it anyway
wait some seconds until uncool button is sensitive again
look at console output: the uncool button's event got processed
even though that button was insensitive.

No, the button was not insensitive. The click event of the uncool button is handled after the callback1 is exited, and after you exit, the button is sensitive again.

To have the behavior you want, look at this modified version of your callback1:

/* Our usual callback function */
void callback1( GtkWidget *widget,
               gpointer   data )
{
    g_print ("Hello again - %s was pressed\n", (char *) data);
    gtk_widget_set_sensitive(button2, FALSE);
    while(g_main_iteration(FALSE));
    heavycalc();
    while(g_main_iteration(FALSE)); // <----------------------------------
    gtk_widget_set_sensitive(button2, TRUE);
}

After the heavycalc, pending events are processed. Here, the uncool but _is_ insesitive, so you don't see the events.

Hope this helps.

--
Manuel Clos
llanero eresmas net

TCPA y Palladium: http://bulmalug.net/body.phtml?nIdNoticia=1398
TCPA and Palladium: http://www.cl.cam.ac.uk/~rja14/tcpa-faq.html

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx




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