ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 8日 (月) 11:09:26 JST
------------------------- REMOTE_ADDR = 184.145.82.7 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-crs ------------------------- @@ -335,3 +335,21 @@ (total += tmp_iter[GItm::QTY_INDEX] if tmp_iter[GItm::BUY_INDEX]) while tmp_iter.next! parent[GItm::QTY_INDEX] = total end + + +The other (i.e. the first) modification found in the area where the 'Buy' column is set up is: + + column.set_cell_data_func(renderer) do |tvc, cell, model, iter| + iter[GItm::BUY_INDEX] = any_child_set_to_buy(iter) if iter.has_child? + end + +Here the helper method((*any_child_set_to_buy*))is used to modify only the product category control rows or in other words parent nodes, i.e. the rows with children rows. We need the helper method to traverse all the children for the pertinent product category and return true if any child has 'Buy' value checked and false otherwise: + + def any_child_set_to_buy(parent) + tmp_iter = parent.first_child + return true if tmp_iter[GItm::BUY_INDEX] + (return true if tmp_iter[GItm::BUY_INDEX]) while tmp_iter.next! + return false + end + +The interesting thing is that this cell data function block controls two things, namely it provides info to our check-box altering mechanism when children rows are checked or unchecked, as well as it prevents user from directly altering the check-box status on the control product category row.