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

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2009年 2月 14日 (土) 00:49:17 JST


-------------------------
REMOTE_ADDR = 74.15.84.244
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-rr
-------------------------
@@ -1,11 +1,60 @@
 = The Tree View Widget
-{{link "tut-gtk2-treev-trees", "tut-gtk2-treev", "tut-gtk", "tut-gtk2-treev-rr"}}
+{{link "tut-gtk2-treev-trees", "tut-gtk2-treev", "tut-gtk", "tut-gtk2-treev-addrnhs"}}
 
-= Sorry this page is still under construction
 
 == Referencing Rows
 
+Three objects are available for referring to a specific row within a tree model, each with its own unique advantages. They are  Gtk::TreePath, Gtk::TreeIter, and Gtk::TreeRowReference.
+
+=== Tree Path
+
 {{image_right("treev-rr-01.png")}}
 
+Instances of Gtk::TreePath class are a very convenient objects for referring to rows within a tree model, because it can be easily represented as a human-readable string. It can also be represented as an array of integers. For instance, if you are presented with the string 3:7:5, you would start at the fourth root element (recall that indexing begins at zero) in root level. You would next proceed to the eighth child of that root element. The row in question is that child's sixth child.
 
+
 {{br}}
+
+--- Gtk::TreePath.new(path = nil)
+
+    Creates a new Gtk::TreePath initialized to path. path is expected to be a colon separated list of numbers. For example, the string "10:4:0" would create a path of depth 3 pointing to the 11th child of the root node, the 5th child of that 11th child, and the 1st child of that 5th child. If an invalid path string is passed in, error is occured.
+    * path: The string representation of a path. 
+    * Returns: A newly created Gtk::TreePath.
+
+For example one could write:
+
+ path = Gtk::TreePath.new("1:2")
+
+You may want to convert a path to an array of indices:
+
+--- indices
+
+    Returns the current indices of path. This is an array of integers, each representing a node in a tree. This value should not be freed.
+    * Returns : The current indices, or nil.
+
+
+
+=== Tree Iterators
+
+
+GTK+ providess the Gtk::TreeIter object, which can be used to reference a specific row within a Gtk::TreeModel. These iterators are used internally by models, which means you never directly alter the contents of an iterator.
+
+
+A Gtk::TreeIter is a reference to a specific node on a specific model. These are filled in by the model in a model-specific way. One can convert a path to an iterator by calling Gtk::TreeModel#get_iter. These iterators are the primary way of accessing a model and are similar to the iterators used by Gtk::TextBuffer. They are generally statically allocated on the heap and only used for a short time. The model interface defines a set of operations using them for navigating the model.
+
+=== Tree Row References
+
+Gtk::TreeRowReference objects are used to watch a tree model for changes. Internally they connect to the ((*row-inserted,*)) ((*row-deleted,*)) and ((*row-reordered*)) signals, updating the stored path based on the changes.
+
+New tree row references are created with Gtk::TreeRowReference.new:
+
+--- Gtk::TreeRowReference.new(model, path)
+
+    Creates a row reference based on path. This reference will keep pointing to the node pointed to by path, so long as it exists. It listens to all signals emitted by model, and updates it's path appropriately. If path isn't a valid path in model, then an error is occurred.
+    * model : A Gtk::TreeModel 
+    * path : A valid Gtk::TreePath to monitor 
+    * Returns : A new Gtk::TreeRowReference
+
+If you need to retrieve a path, you can use Gtk::TreeRowReference#path instance method, which will return nil if if the row no longer exists within the model. As you can see from the API document segment above, the tree references are able to update the tree path based on changes within the tree model, but if you remove all the elements from the same level as the tree path's row, it will no longer have a row to point to.
+
+You should be aware that tree row references do add a bit of a processing overhead, when adding, removing, or sorting rows within a tree model, since the references will have to handle all signals emitted by these actions.




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