Use of gtk spin buttons [WAS Re: Margins Plugin Bug]

Jasper Huijsmans jasper at moongroup.com
Sun Mar 30 18:35:52 CEST 2003


Ok, I partly take that back. It works for the panel at the moment.
Unlike the margins plugin I use the "value-changed" signal on the spin
button. The "changed" signal is for the gtk entry ;-)

	Jasper


On Sun, 30 Mar 2003 17:02:56 +0200
Jasper Huijsmans <jasper at moongroup.com> wrote:

> He-he, that's what you get for being arrogant ;-) I was so sure ...
> 
> Anyway, I gladly stand corrected and will now humbly get to work to
> fix all my spinbuttons ;-)
> 
> 	Jasper
> 
> On 30 Mar 2003 16:37:33 +0200
> Olivier Fourdan <fourdan at xfce.org> wrote:
> 
> > On Wed, 2003-03-26 at 09:43, Jasper Huijsmans wrote:
> > > Yeah, this is a gtk bug. Spinbuttons don't update their value
> > > properly when using the keyboard. Nothing we can do about it, I'm
> > > afraid. I didn't check if the gtk people know about it, though
> > > (yeah, I'm lazy).
> > 
> > No it's not. It's a bug in your code :P
> > 
> > The correct way to get value changes is to connect a "value_changed"
> > event to the spin adjustment, something like :
> >    
> > g_signal_connect(G_OBJECT(gtk_spin_button_get_adjustment(GTK_SPIN_B
> > UT TON(spin))), "value_changed", G_CALLBACK(a_callback), a_pointer);
> > 
> > This, obviously , changes the callback function since the widget is
> > now a GtkAdjustment (and not a GtkSpin anymore).
> > 
> > The (int) value can then be retrieved with :
> > 
> >     val = gtk_adjustment_get_value(GTK_ADJUSTMENT(widget));
> >     if (val - floor (val) < ceil (val) - val)
> >     {
> >         n = floor (val);
> >     }
> >     else
> >     {
> >         n = ceil (val);
> >     }
> > 
> > Humm, and yes, that probably needs to be fixed elsewhere (in
> > xfce4-panel, maybe :). I just fixed the margin plug-in for now.
> > 
> > Cheers,
> > -- 
> > Olivier Fourdan <fourdan at xfce.org>
> > http://www.xfce.org
> > 
> > _______________________________________________
> > Xfce4-dev mailing list
> > Xfce4-dev at xfce.org
> > http://moongroup.com/mailman/listinfo/xfce4-dev
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://moongroup.com/mailman/listinfo/xfce4-dev



More information about the Xfce4-dev mailing list