Forum: Ruby-Gnome 2 Class to Widget

Posted by Alan Lake (alake)
on 2007-10-04 22:39
Attachment: listbox.rb (1,37 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 2007-10-04 23:07
Attachment: listbox.rb (1,32 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 2007-10-05 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 2007-10-05 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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.