ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 12日 (日) 02:35:58 JST
------------------------- REMOTE_ADDR = 184.145.90.35 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-model-reference ------------------------- @@ -7,7 +7,7 @@ {{image_right "treepath.png"}} -The picture shows the tree path in string form next to the label. Basically, it just counts the children from the imaginary root of the tree view. An empty tree path string would specify that imaginary invisible root. Now 'Songs' is the first child (from the root) and thus its tree path is just "0". 'Videos' is the second child from the root, and its tree path is "1". 'oggs' is the second child of the first item from the root, so its tree path is "0:1". So you just count your way down from the root to the row in question, and you get your tree path. You can get a new Gtk::TreePath from a path in string form using Gtk::TreePath.new, and you can convert a given Gtk::TreePath into its string notation with Gtk::TreePath#to_str. Usually you will rarely have to handle the string notation, it is described here merely to demonstrate the concept of tree paths. +The picture shows the tree path in string form next to the label. Basically, it just counts the children from the imaginary root of the tree view. An empty tree path string would specify that imaginary invisible root. Now 'Songs' is the first child (from the root) and thus its tree path is just "0". 'Videos' is the second child from the root, and its tree path is "1". 'oggs' is the second child of the first item from the root, so its tree path is "0:1". So you just count your way down from the root to the row in question, and you get your tree path. You can get a new Gtk::TreePath from a path in string form using Gtk::TreePath.new(path_in_string_notation), and you can convert a given Gtk::TreePath into its string notation with Gtk::TreePath#to_str. Usually you will rarely have to handle the string notation, it is described here merely to demonstrate the concept of tree paths. Instead of the string notation, Gtk::TreePath uses an integer array internally. You can get the depth (ie. the nesting level) of a tree path with Gtk::TreePath#depth. A depth of 0 is the imaginary invisible root node of the tree view and model. A depth of 1 means that the tree path describes a top-level row. As lists are just trees without child nodes, all rows in a list always have tree paths of depth 1. Gtk::TreePath#indices returns the internal integer array of a tree path. You will rarely need to operate with those either.