ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 7日 (日) 04:49:30 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-pxbr ------------------------- @@ -152,3 +152,19 @@ window.add(scrolled_win) window.show_all Gtk.main + +As mentioned in the introductory text above, we added another column for the image, but not for the pixbuf in the model, namely, the last String model column (remember: stock item is just a string description for the image, and that is what we are storing in the model here): + + # Create a new tree model this time with four columns, as Boolean, + # integer, string and additional String for the Gdk::Pixbuf. + store = Gtk::TreeStore.new(TrueClass, Integer, String, String) + + # NOTE: If we used image files we would need to convert them to + # Gdk::Pixbuf objects and it would be more appropriate, + # to use Gdk::Pixbuf instead of String, for the image item + # here (see [8.2.4] for the correct handling of pixbufs). + # IMPORTANT - the following would not work here: + # + # store = Gtk::TreeStore.new(TrueClass, Integer, String, Gdk::Pixbuf) + +Indeed, in the the 'liststore-col-w-double-renderers-pixbufs.rb' example in section [8.2.4], we use the Gdk::Pixbuf rather than the String data type to define our model (store).