ruby-****@sourc*****
ruby-****@sourc*****
2009年 2月 18日 (水) 01:51:08 JST
------------------------- REMOTE_ADDR = 74.15.84.244 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-crs ------------------------- @@ -29,7 +29,6 @@ As with the editable text renderers, you have to manually apply the changes performed by the user. Otherwise, the button will not toggle visually on the screen. Because of this, Gtk::CellRendererToggle provides the ((*toggle*)) signal, which is emitted when the user presses the check button. - {{image_right("treev-crs-01.png")}} We are using the same program as in the introductory session to the tree store (1.3 ((<Using Gtk::ListStore|tut-gtk2-treev-parts#Using Gtk::ListStore>))), there called "treestore.rb". The only changes are in the ((*setup_tree_view(treeview)*)) method, where we had to change the type of our cell renderer. An important, often overlooked change is also in the column line, where we change the name of the attribute that used to be "text" to "active". Since we wish to provide our users with the ability to interactively change the status of "Buy" column, wee need to make our toggle button clickable, which means that we also need to provide the callback proc (block) which will set the toggle to the new value. @@ -38,15 +37,15 @@ {{br}} ((*treestore-toggle.rb*)) + #!/usr/bin/env ruby require 'gtk2' - # Add three columns to the GtkTreeView. All three of the - # columns will be displayed as text, although one is a boolean + # Add three columns to the Gtk::TreeView. All three of the + # columns will be displayed as text, although one is a Boolean # value and another is an integer. def setup_tree_view(treeview) - # Create a new GtkCellRendererText, add it to the tree + # Create a new Gtk::CellRendererText, add it to the tree # view column and append the column to the tree view. renderer = Gtk::CellRendererToggle.new @@ -101,12 +101,12 @@ # integer and string. store = Gtk::TreeStore.new(TrueClass, Integer, String) - # Avoid creation of iterators on every iterration, since they + # Avoid creation of iterators on every iteration, since they # need to provide state information for all iterations. Hence: # establish closure variables for iterators parent and child. parent = child = nil - # Add all of the products to the GtkListStore. + # Add all of the products to the Gtk::ListStore. list.each_with_index do |e, i| # If the product type is a category, count the quantity