Ruby Forum Ruby-Gnome 2 > Class to Widget

Posted by Alan Lake (alake)
on 04.10.2007 22:39
Attachment: listbox.rb (1,4 KB)
I'd like to learn how to convert a class to a widget.  Is there someone
who can help me with this?  The Ruby tutorial on this subject hasn't
been written yet.  I'd like to write that section using listbox.rb as an
example.
Posted by Mathieu Blondel (Guest)
on 04.10.2007 23:07
Attachment: listbox.rb (1,3 KB)
(Received via mailing list)
Your class should be a child of Gtk::TreeView, not Gtk::Widget. Updated
example attached.

Mathieu
Posted by Alan Lake (alake)
on 05.10.2007 01:08
Mathieu Blondel wrote:
> Your class should be a child of Gtk::TreeView, not Gtk::Widget. Updated
> example attached.
> 
> Mathieu
Thanks, Mathieu!  That takes care of the reason it wouldn't run.  But, 
does the fact that TreeView is a widget automatically make ListBox a 
widget?
Posted by Mathieu Blondel (Guest)
on 05.10.2007 17:50
(Received via mailing list)
Alan Lake wrote:
> Mathieu Blondel wrote:
>   
> Thanks, Mathieu!  That takes care of the reason it wouldn't run.  But, 
> does the fact that TreeView is a widget automatically make ListBox a 
> widget?
>   
Yes it is because Gtk::TreeView is itself a Gtk::Widget (and otherwise
you wouldn't be able to add your ListBox object to the window). Have a
look at the object hierarchy of a Gtk::TreeView:

http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ATreeView

mathieu@mathieulaptop:~$ irb
irb(main):001:0> require "gtk2"
=> true
irb(main):002:0> Gtk::TreeView.ancestors
=> [Gtk::TreeView, Gtk::Container, Gtk::Widget, Atk::Implementor,
GLib::Interface, GLib::MetaInterface, Gtk::Object,
GLib::InitiallyUnowned, GLib::Object, GLib::Instantiatable, Object, 
Kernel]
irb(main):003:0> tv = Gtk::TreeView.new
=> #<Gtk::TreeView:0xb67d37d0 ptr=0x8328120>
irb(main):004:0> tv.is_a? Gtk::Widget
=> true

HTH,
Mathieu