ruby-****@sourc*****
ruby-****@sourc*****
2012年 9月 28日 (金) 03:25:58 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-rr ------------------------- @@ -23,6 +23,52 @@ At this point in addition to Gtk::TreeStore, we also need to address the Gtk::ListStore. 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 operate with paths, but if you do, you most likely will use methods like Gtk::TreePath#up!, Gtk::TreePath#down!, Gtk::TreePath#next!, Gtk::TreePath#prev!, Gtk::TreePath#ancestor?, Gtk::TreePath#decendent?. Note that this way you can operate on tree paths which refer to rows that do not exist in model. A far more coomon way to refer to a row in a list or tree model is Gtk::TreeIter. + + + + +((*------------- FIXME, FIXME, FIXME, FIXME, FIXME, FIXME ---------- (start) ------*)) + +:PATH NAVIGATION METHODS (up!, down!, prev! next!) DO NOT WORK AS EXPECTED: + + As of September 2012, path navigation methods do not work when you reach the last level, i.e. when the path depth reaches 0 (ZERO). But you can bypass the problem if you handle path as if it were a string. Following are two code snippets demonstrating what was just said. (1) the first showing the code that does not work, utilizing Gtk::TreePath navigation methods. And (2) the second showing how you can accomplish the desired effect by processing path as a string. + + For instance the following code does not work: + + # GTk::TreePath#up! DOES NOT WORK + + def fix_parent_row_prices(treeview, sel_path, added_price) + model = treeview.model + path = sel_path + while path + puts "DEBUG: path.class=#{path.class} to_str=#{path.to_str} path=#{path}" + iter = model.get_iter(path) + iter[PRICE_COLUMN] += added_price + path = nil if !(path.up!) + end + end + + The following code processing path as a string works: + + def fix_parent_row_prices(treeview, sel_path, added_price) + model = treeview.model + path = sel_path + while path + iter = model.get_iter(path) + iter[PRICE_COLUMN] += added_price + path = /(.+)(:\d+)/ =~ path ? $1 : $2 + end + end + +((*------------- FIXME, FIXME, FIXME, FIXME, FIXME, FIXME ---------- (end) ------*)) + + + + + + + + {{br}}