Re: [gtk-list] Re: Getting check button children
- From: Eric Harlow <linuxgeek yahoo com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Getting check button children
- Date: Sat, 11 Jul 1998 18:11:40 -0700 (PDT)
The problem is that you have an event handler on the "clicked" event
which ends up firing the "clicked" event. There are many ways of
handling this. A static variable in the function might be the easiest
way. Something like
setStateFalse ()
{
static int bInLoop = 0
if (bInLoop == 0) {
bInLoop = 1;
// --- put your code here that changes
// the state
bInLoop = 0;
}
}
This will have the effect of not going into the loop if the function
is already in the middle of a call. Of course, you can always use
*real* semaphores instead of a static variable.
-Eric
---"Buch, William H." <bbuch@hqm.com> wrote:
>
> how should i call a mouse event against a check button? currently i
am
> doing the following:
>
> gtk_signal_connect(button, "clicked", function, pointer data)
>
> i guess that isn't correct?
>
> -bill
>
> -----Original Message-----
> From: Eric Harlow [mailto:linuxgeek@yahoo.com]
> Sent: Saturday, July 11, 1998 8:15 PM
> To: BBUCH@JERRY.hqm.com
> Subject: [gtk-list] Re: Getting check button children
>
>
>
> Without seeing how you're installing the event handler / signal
> handler, it's hard to say. Check to see which events the buttons are
> handling. The gtk_toggle_button_set_state button does call the
> gtk_button_clicked function which, I believe, ends up signaling a
> "button_clicked" and if you're listening to it and calling
> setStateFalse from there, that might cause an infinite loop to occur.
>
> -Eric
>
>
>
> ---"Buch, William H." <bbuch@hqm.com> wrote:
> >
> > I used erics children get procedure and it works. but when i try to
> > change the state of the check button, i get into an endless loop and
> > then it segment faults on me. here is the code below:
> >
> > GtkWidget parent = gtk_widget_get_ancestor(widget,
> gtk_hbox_get_type());
> >
> > i have three check boxes packed into a hbox, which i got above.
then:
> >
> > gtk_container_foreach(GTK_CONTAINER(parent),
> > (GtkCallback) setStateFalse,
> > NULL);
> >
> > void setStateFalse(GtkWidget *widget, gpointer data)
> > {
> > if(GTK_IS_TOGGLE_BUTTON(GTK_OBJECT(widget)))
> > printf("toggle");
> > }
> >
> > the above works. it prints out three toggle messages which it
should
> > because there are three toggle buttons.
> > but this one doesn't work.
> >
> > void setStateFalse(GtkWidget *widget, gpointer data)
> > {
> > if(GTK_IS_TOGGLE_BUTTON(GTK_OBJECT(widget))) {
> > gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget),
> > FALSE);
> > }
> > }
> >
> > if i would stick a printf("toggle") into that, i get a lot of toggle
> > messages printed to the screen. is there something wrong that i am
> > doing? i need to HELP! :)
> >
> > thanks in advance
> >
> > Bill
> >
> > --
> > To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
> /dev/null
> >
> >
>
> _________________________________________________________
> DO YOU YAHOO!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
> /dev/null
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
>
>
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]