ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 7日 (日) 01:26:10 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-trees ------------------------- @@ -882,8 +882,7 @@ store = Gtk::ListStore.new(TrueClass, Integer, String, Gdk::Pixbuf) -After the model structure was augmented we also need to provide and load the data into the newly created column. Accordingly the new column constant ((*ICON*)) is added and the column of image file names is added to the ((*list*)) array. These changes are also reflected in the data loading loop, where our model in ((*store*)) variable is initialized -with a Gtk::Pixbuf object created from the image file. For this to work we need a helper method called ((*get_pixbuf_if_file_exists*)), which has to make sure in event image files do not exist errors are handled gracefully. +After the model structure was augmented we also need to provide and load the data into the newly created column. Accordingly the new column constant ((*ICON*)) is added and the column of image file names is added to the ((*list*)) array. These changes are also reflected in the data loading loop, where our model in ((*store*)) variable is initialized with a Gdk::Pixbuf object created from the image file. For this to work we need a helper method called ((*get_pixbuf_if_file_exists*)), which has to make sure in event image files do not exist errors are handled gracefully. But the most important changes for this "Multi-item Column" version program are tucked away in the ((*setup_tree_view*)) method, where we needed to replace the original column instantiation method which handled a single "Product" item with a number of different methods that now manage both text and image items in the same column. This also requires reordering of statements dictated first by the API, and second by the way we would like to arrange the order of items (ie text and images) in the Product column. For the API related reordering of code please check the listing and search for the comment (# PECULIARITY: ...). The ordering of image and text in the column deserves some more attention. If you didn't care weather image appeared before the string (text), you wouldn't have to replace the original Product column instantiation statement: