ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 2日 (火) 04:00:56 JST
------------------------- REMOTE_ADDR = 184.145.80.187 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-addrnhs ------------------------- @@ -641,7 +641,13 @@ Before we look at this program more closely, let me first expose its obvious flaws. The most obvious one is the awkward dialogue mechanism used to add and remove new products. A more appropriate thing to do would be to employ a context menu on which the addition and removal would be two separate choices. However, we have not yet introduced the context menu widget, and hence, instead used what you should already be familiar with. Also, we did not care to ensure the parent rows did not allow price column to be filled initially. And the most obvious flaw is that we do not provide a way to enter another top level product. All these issues can be easily fixed, however, the implementation of these fixes would greatly obscure the basic issues we are trying to present in the first place. Nevertheless, the bare bones of this program have already been introduced two chapters back and pointed to at the beginning of this segment. If you gave trouble understanding how the program works I suggest you have a peak back into the 'Using Tree Store' chapter as mentioned above (((<"Tedious Job of Loading Multidimensional Tree Store"|tut-gtk2-treev-trees#Tedious Job of Loading Multidimensional Tree Store>))). -The new addition to this program is hidden from the user, and is only exposed in the top level tooltip, i.e. when a cursor hovers above this program's main window it triggers the tooltip explaining that double-clicking a row will allow adding or removing rows. +The new addition to this program is hidden from the user, and is only exposed in the top level tooltip, i.e. when a cursor hovers above this program's main window it triggers the tooltip explaining that double-clicking a row will allow adding or removing rows. Things are not that hidden for the programmers, though, nevertheless the additions are not so huge. The bulk of new code is tucked away into two methods: the((*add_n_rm_product*))and the((*fix_parent_row_prices*)). This code is triggered by the following signal_connect method: + + treeview.signal_connect("row-activated") do |view, path, column| + add_n_rm_product(treeview, path) + end + +The important difference between this and the previous example is how the selected rows are handled in the two. Here, the selection is implicit to the 'row-activated' signal, namely, it (the selection) is passed into the code block and subsequently to the insertion and removal management method as path parameter, owned by the 'row-activated' signal. #### path = /(.+)(:\d+)/ =~ path ? $1 : $2 #### BUG? Gtk::TreePath#up! <<< doesn't work