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

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 8月 27日 (月) 03:04:54 JST


-------------------------
REMOTE_ADDR = 70.49.49.99
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-parts
-------------------------
@@ -110,7 +110,39 @@
 
 Gtk::ListStore is used to create lists of data that have no hierarchical relationships among rows. Following is an example "Grocery List" application, which contains three columns, all of which are built using Gtk::CellRendererText. The first column is a Boolean value displayed as true or false, that define whether or not the product should be purchased. (Later we will learn how to use Gtk::CellRendererToggle in the place of spelling out true or false. The second column is an integer, representing the quantity to purchase and the third is a text string describing the product.
 
-As promised, in this program we implement the easiest of column/cell style and colour rendering. Pay attention to how the colour of entire column is set to be red. 
+#######
+Before we look at the next example, I wish to point out how tree view and a model are connected. The order in which we create either the view or the model is not important, though depending on your style of programming you may have your preference. For instance, I prefer to create model before view, because I like to connect the two at the time when view is created. Let us look at the different ways you can accomplish this association for a model with two columns defined as String and Integer:
+
+ # Create a view
+ view = Gtk::TreeView.new
+
+ # Create empty data store
+ treestore = Gtk::TreeStore.new(String, Integer)
+
+ # Associate model with view utilizing Gtk::TreeView#model= 
+ view.model = treestore
+
+
+I prefer the following, shorter version:
+
+ # Create empty data store
+ treestore = Gtk::TreeStore.new(String, Integer)
+
+ # Create view and associate model with it. 
+ view = Gtk::TreeView.new(treestore)
+
+
+Even more terse though arguably more intelligible style is:
+
+ view = Gtk::TreeView.new(treestore = Gtk::TreeStore.new(String, Integer))
+
+#######
+
+{{{br}}
+
+Lets look at our example program now. As promised, in this program we implement the easiest of column/cell style and colour rendering. Pay attention to how the colour of entire column is set to be red. 
+
+###
 
 {{br}}
 




ruby-gnome2-cvs メーリングリストの案内
Back to archive index