Forum: Ruby-Gnome 2 CellRendererSpin - how to use?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Michal S. (Guest)
on 2009-01-04 14:44
(Received via mailing list)
Attachment: grsubt.glade (0 Bytes)
Hello

I tried writing a small Hello World style application with ruby-gtk2.

After I was told that 'list' and 'table' are both spelled 'treeview'
in GTK I was able to put together a small demo that actually allows
editing a list of text strings.

Howeveer, I cannot make the SpinButton cell renderer to display, and
there is no GTK warning or anything that would indicate there is
something wrong.

Is there some demo showing the less common cell renderers? I was
looking at the gtk-demo but it uses CellRendererText for numbers.

Thanks

Michal
Roy W. (Guest)
on 2009-01-23 09:28
Michal S. wrote:
> Hello
>
> I tried writing a small Hello World style application with ruby-gtk2.
>
> After I was told that 'list' and 'table' are both spelled 'treeview'
> in GTK I was able to put together a small demo that actually allows
> editing a list of text strings.
>
> Howeveer, I cannot make the SpinButton cell renderer to display, and
> there is no GTK warning or anything that would indicate there is
> something wrong.
>
> Is there some demo showing the less common cell renderers? I was
> looking at the gtk-demo but it uses CellRendererText for numbers.
>
> Thanks
>
> Michal

Take a look at:

  http://www.kksou.com/php-gtk2/articles/input-or-ed...

HTH,
Roy
Michal S. (Guest)
on 2009-01-30 16:00
(Received via mailing list)
On 23/01/2009, Roy W. <removed_email_address@domain.invalid> wrote:
>  > there is no GTK warning or anything that would indicate there is
> Take a look at:
>
> 
http://www.kksou.com/php-gtk2/articles/input-or-ed...

Thanks for the sample. It seems they set the value property from the
model rather than the adjustment property. Although the docs seem to
indicate that either should be possible maybe it is not.

I will try a few modifications of my hello world and see how it goes.

Thanks

Michal
Michal S. (Guest)
on 2009-02-26 01:21
(Received via mailing list)
Attachment: hw.glade (0 Bytes)
Attachment: hw.rb (0 Bytes)
Hello

On 23/01/2009, Roy W. <removed_email_address@domain.invalid> wrote:
>
>
> Take a look at:
>
> 
http://www.kksou.com/php-gtk2/articles/input-or-ed...
>

Thanks for this sample.

It shows clearly that the cell renderers have an undocumented property
text which also gets propagated as the value of the
GtkCellRendererSpin adjustment.

However, there is a bug somewhere that prevents me from incrementing
the spinbutton value in non-integer steps. The value gets rounded
somewhere, and I am not aware of ever doing that.

In fact I can type an exact value and my handler sets it into the
model (I wish there was a default handler doing just that) but
whenever the value is loaded into the spinbutton it is rounded.

Attaching the test program, hopefully file this time.

Thanks

Michal
Michal S. (Guest)
on 2009-02-26 01:28
(Received via mailing list)
On 26/02/2009, Michal S. <removed_email_address@domain.invalid> wrote:
>  >
>  somewhere, and I am not aware of ever doing that.
>
>  In fact I can type an exact value and my handler sets it into the
>  model (I wish there was a default handler doing just that) but
>  whenever the value is loaded into the spinbutton it is rounded.

It's because the renderer displays the value differently when inactive
and while editing. It can be seen by uncommenting the part with
set_digits()

The value is a plain label normally with many decimal places but the
spinbutton only has as many decimal digits as set with the digits
property thus the value is rounded when loaded into the spinbutton.

The odd things that happen here are two:

 - the renderer sets digits on the spinbutton but does not heed the
property for the label
 - the spinbutton rounds the value when set but allows entering exact
value manually

Thanks

Michal
This topic is locked and can not be replied to.