> > -----Original Message-----
> > From: Luca Cappa [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, February 24, 2005 10:56 AM
> > To: Prewitt, Nathan C ERDC-ITL-MS Contractor
> > Subject: Re: Blocking signals
> > 
> > 
> > Hello Nathan,
> > 
> > if in your case a set_value call trigs another set_value 
> > call, as could 
> > be using the gtkscale widget, you could avoid the need to block the 
> > emitting of the signal on the set_value method. Instead just 
> > put this in 
> > your code:
> > 
> > void setTheNewScaleValue (int i)
> > {
> >     if (i != actual_value)
> >     {
> >        actual_value = i;
> >        scale.set_value (actuall_value);
> >     }//if
> > }
> > 
> > Luca
> > 
> 
>     It's more a case of dependent widgets.  I have six sets of widgets
> with a
> GtkEntry and a GtkHScale in each set.  The value in the Entry is the
> same as
> the value of the HScale.  When the signal handler for the HScale is
> called, I
> have to set the value of the Entry.  I have to block the signal
> handler for
> the Entry to keep its signal handler from being called.  Likewise,
> when the
> signal handler for the Entry is called, I have to set the value of the
> HScale
> and block the signal handler for the HScale while I set it.  I ended
> up with
> 12 different callback functions, when I could have 2.  It is
> complicated
> further by the fact that I have a SpinButton that allows me to change
> data
> sets and this in turn changes the values and ranges in the Entry and
> HScale
> widgets. 
> 
> Thanks,
> 
> Nathan

Hi there.

I will recommend you to use a GtkSpinButton instead of the GtkEntry in
that way both the GtkSpinButton and the GtkHScale can share the same
GtkAdjustment and both will show the same value all the time without any
extra effort from you. As far as I know you can even hide the arrows in
the GtkSpinButton but I am not completely sure about it.

This code may give you and idea:

/* define the range for the slider widgets, spin button */
adjust  = g_object_new(GTK_TYPE_ADJUSTMENT,
                                           "lower", -100.0,
                                           "upper", 100.0,
                                           "step-increment", 1.0,
                                           "page-increment", 10.0,
                                           "page-size", 0.0,
                                           "value", 1.0,
                                           NULL);

/* create horizontal slider */
h_slider        = g_object_new(GTK_TYPE_HSCALE, "adjustment", adjust, 
                                NULL);
        
/* spin button */
spin_button     = g_object_new(GTK_TYPE_SPIN_BUTTON,
                           "adjustment", adjust,
                           "digits", 1,
                           "value", 42.0,
                           NULL);

Hope this can help you to achieve your goals.

Best regards.

Hazael
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to