ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 14日 (火) 09:27:58 JST
------------------------- REMOTE_ADDR = 184.145.90.35 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-treeview-selection-contextmenu ------------------------- @@ -38,13 +38,13 @@ # view column and append the column to the tree view. renderer = Gtk::CellRendererText.new renderer.foreground = "#ff0000" - column = Gtk::TreeViewColumn.new("Buy", renderer, :text => $buy_it) + column = Gtk::TreeViewColumn.new("Buy", renderer, :text => BUY_IT) treeview.append_column(column) renderer = Gtk::CellRendererText.new - column = Gtk::TreeViewColumn.new("Count", renderer, :text => $quantity) + column = Gtk::TreeViewColumn.new("Count", renderer, :text => QUANTITY) treeview.append_column(column) renderer = Gtk::CellRendererText.new - column = Gtk::TreeViewColumn.new("Product", renderer, :text => $product) + column = Gtk::TreeViewColumn.new("Product", renderer, :text => PRODUCT) treeview.append_column(column) end @@ -59,7 +59,7 @@ attr_accessor :buy, :quantity, :product def initialize(b, q, p); @buy, @quantity, @product = b, q, p; end end - $buy_it = 0; $quantity = 1; $product = 2 + BUY_IT = 0; QUANTITY = 1; PRODUCT = 2 list = Array.new list[0] = GroceryItem.new(true, 1, "Paper Towels") @@ -80,9 +80,9 @@ list.each_with_index do |e, i| iter = store.append - iter[$buy_it] = list[i].buy # same as: >>> # store.set_value(iter, $buy_it, list[i].buy) - iter[$quantity] = list[i].quantity # same as: >>> # store.set_value(iter, $quantity, list[i].quantity) - iter[$product] = list[i].product # same as: >>> # store.set_value(iter, $product, list[i].product) + iter[BUY_IT] = list[i].buy # same as: >>> # store.set_value(iter, BUY_IT, list[i].buy) + iter[QUANTITY] = list[i].quantity # same as: >>> # store.set_value(iter, QUANTITY, list[i].quantity) + iter[PRODUCT] = list[i].product # same as: >>> # store.set_value(iter, PRODUCT, list[i].product) end # Add the tree model to the tree view