[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-treeview-selection-handle

Back to archive index

ruby-****@sourc***** ruby-****@sourc*****
2012年 8月 10日 (金) 01:14:32 JST


-------------------------
REMOTE_ADDR = 184.145.90.35
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-selection-handle
-------------------------
@@ -5,6 +5,29 @@
 
 There are three ways to deal with tree view selections: either you get a list of the currently selected rows whenever you need it, for example within a context menu method, or you keep track of all select and unselect actions and keep a list of the currently selected rows around for whenever you need them; as a last resort, you can also traverse your list or tree and check each single row for whether it is selected or not (which you need to do if you want all rows that are not selected for example).
 
+Example traversing entire TreeView structure:
+
+ def traverse_list_to_print_all_rows(store)
+   # get first row in list store
+   return unless iter = store.iter_first
+ 
+   begin
+     puts "Product: #{iter[2]} Buy:#{iter[0]}"
+   end while iter.next!
+ end
+
+Example obtaining only NON-selected rows:
+
+ def print_only_unselected_rows(store, treeview)
+   # get first row in list store
+   return unless iter = store.iter_first
+
+   all_selections = treeview.selection   # <--- obtain all selections from TreeView
+   begin
+     puts "Product: #{iter[2]} Buy:#{iter[0]}"  if ! all_selections.iter_is_selected?(iter)
+   end while iter.next!                         #  =-==============-=======================
+ end
+
 == Selection Modes
 
 You can use Gtk::TreeSelection#mode= to influence the way that selections are handled. There are four selection modes: 




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