ruby-****@sourc*****
ruby-****@sourc*****
2009年 2月 12日 (木) 03:06:01 JST
------------------------- REMOTE_ADDR = 74.15.84.244 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-parts ------------------------- @@ -215,7 +215,20 @@ The tree view columns are now set up with the desired cell renderers, so it is time to create the tree model that will interface between the renderers and the tree view. In our example program, we used the Gtk::ListStore so that the items would be shown as a list of elements. -First we create the list and at the same time define the data types for each column within a row, and then loop through our array of values to append them to the list. Indeed the important feature of this process is the iterator, i.e. the Gtk::TreeIter object, which is manipulated as an index into our list, however, the Gtk::ListStore#append does all the work for us. It creates a new empty list entry (record or row) and points the iterator (index) to it. We then proceed to assign values to individual columns with Gtk::ListStore# +First we create the list and at the same time define the data types for each column within a row, and then loop through our array of values to append them to the list. Indeed the important feature of this process is the iterator, i.e. the Gtk::TreeIter object, which is manipulated as an index into our list, however, the Gtk::ListStore#append does all the work for us. It creates a new empty list entry (record or row) and points the iterator (index) to it. We then proceed to assign values to individual columns with Gtk::ListStore#: + + # Create a new tree model with three columns, as Boolean, + # integer and string. + store = Gtk::ListStore.new(TrueClass, Integer, String) + + # Add all of the products to the GtkListStore. + list.each_with_index do |e, i| + iter = store.append + store.set_value(iter, $buy_it, list[i].buy) + store.set_value(iter, $quantity, list[i].quantity) + store.set_value(iter, $product, list[i].product) + end + Following are the pertinent methods we use with regards to the Gtk::ListStore object: