Use of gtk spin buttons [WAS Re: Margins Plugin Bug]
Olivier Fourdan
fourdan at xfce.org
Sun Mar 30 16:40:10 CEST 2003
Oh..., and I almost forgot. You need to #include <math.h> since you use
ceil() and floor()
Cheers,
Olivier.
On Sun, 2003-03-30 at 16:37, Olivier Fourdan 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_BUTTON(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
More information about the Xfce4-dev
mailing list