[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-treev-addrnhs

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2012年 10月 2日 (火) 06:33:02 JST


-------------------------
REMOTE_ADDR = 184.145.80.187
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-addrnhs
-------------------------
@@ -866,5 +866,16 @@
 Finally in this session, let us look at the((*imaginary, invisible root node.*))Try to add another product, say a 'Scanner Printer SP100' to the list. You will soon realize that it can only be added as a "sub-product" of any of the three existing products. There simply is no row visible, which would contain these products as children.
 
 
+There are two solutions to this problem. The easiest would be to add one higher level "Inventory" or "Computer Store" row to the ASCII table. This would not require any additional coding at all. But a better way would be to implement a context menu, with a new option, say: 'Generate New Product'. Now a minor addition to the existing strategy would be the requirement that when this option from the context menu is selected, we would make sure the we have a method like the following, and that it gets executed when 'Generate New Product' option from a context menu or some other button is clicked:
+
+ def generate_new_product(treeview)
+   iter = treeview.model.append(nil)
+   iter[NAME_COLUMN]   = product
+   iter[PRICE_COLUMN]  = price = 0.0
+ end
+
+In the above code the((*nil*))argument in Gtk::TreeStore#append(nil) is the most important thing. It creates a child for the elusive top level((*imaginary, invisible root node.*))
+
+
 
 #### path = /(.+)(:\d+)/ =~ path ? $1 : $2  #### BUG? Gtk::TreePath#up! <<< doesn't work




ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る