[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-treeview-view-connect

Zurück zum Archiv-Index

ruby-****@sourc***** ruby-****@sourc*****
2012年 8月 13日 (月) 03:25:29 JST


-------------------------
REMOTE_ADDR = 184.145.90.35
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-view-connect
-------------------------
@@ -1,6 +1,29 @@
 = Connecting Tree View and Model
 {{link "tut-treeview-view", "tut-treeview-view", "tut-treeview", "tut-treeview-view-look"}}
 
-Before we proceed to the next section where we display data on the screen, we need connect our data store to the tree view, so it knows where to get the data to display from. This is achieved with Gtk::TreeView#model=, which will by itself do very little. However, it is a prerequisite for what we do in the following sections.  Alternately you can pass the model as a parameter when you call Gtk::TreeView.new. 
+Let's repeat: In order to display data in a tree view widget, we need to create one first, and we need to instruct it where to get the data to display from.
+
+A new tree view is created with:
+
+ view = Gtk::TreeView.new
+
+Before we proceed to the next section where we display data on the screen, we need connect our data store to the tree view, so it knows where to get the data to display from. This is achieved with Gtk::TreeView#model=, which will by itself do very little. However, it is a prerequisite for what we do in the following sections. Alternately you can pass the model as a parameter when you call Gtk::TreeView.new.
+
+ # Create empty data store
+ treestore = Gtk::TreeStore.new(String, Integer)
+ 
+ # Create a view
+ view = Gtk::TreeView.new
+ 
+ # Associate model with view utilizing Gtk::TreeView#model= 
+ view.model = treestore
+
+The above can be done with less typing:
+
+ # Create empty data store
+ treestore = Gtk::TreeStore.new(String, Integer)
+ 
+ # Create view and associate model with it. 
+ view = Gtk::TreeView.new(treestore)
 
 Gtk::TreeView#model will return the model that is currently attached to a given tree view, which is useful in callbacks where you only get passed the tree view widget (after all, we do not want to go down the road of global variables, which will inevitably lead to the Dark Side, do we?).




ruby-gnome2-cvs メーリングリストの案内
Zurück zum Archiv-Index