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

Jasper Huijsmans jasper at moongroup.com
Sun Mar 30 17:02:56 CEST 2003


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_BUT
> 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



More information about the Xfce4-dev mailing list