Re: [gtk-list] Re: toggle button




On Sun, 31 Jan 1999, Alexander Kotelnikov wrote:
> ...
> void quit(GtkObject *widget)
> {
> gtk_main_quit();
> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),FALSE);
> }
> 
> explanations
>  I use 'button' many times, 'loop_button' only once. I need my program
> exiting just after pressing "Quit" button, it works only if "Loop" button
> is not toggled (I think that's because "loop" function have many things to 
> do:), so I want my Quit buton to untoggle loop_button ("loop" function
> works while(GTK_TOGGLE_BUTTON (widget)->active)) and then I want to
> gtk_main_quit BUT I had to swap this actions, 'cos another way I get many
> Gtk/Gdk 'messages' after exiting.
> 

This is just a mess. Try keeping a separate bool which reflects the toggle
button's state; that will cause you less problems. Better: connect to
"toggled" on the toggle button, start or stop your loop when it's toggled.
That way you aren't chewing CPU checking the bool over and over.

Havoc





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