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



Jeffrey Rush wrote:
Hi all,

Hi Jeffrey

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




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