From: Clifford Heath Date: 2004-03-01T20:21:10+09:00 Subject: Re: Ruby-gtk ? On the subject of ruby-gtk2, the absence of (sufficient) docs is a shame, and the raw GTK docs don't always help. But perhaps one of you folk can help me. I've modified one of the TreeView examples to add a toggle as a second column, but I can't work out what signal to connect to allow the toggle to be clicked. My code is below, can you see how to make the toggle clickable? Is there a dynamic way to list all signals that an object can generate? Clifford Heath. require 'gtk2' def build_tree(tree, model) root = model.append(nil) root.set_value(0, "Root") for i in 1..4 sub = model.append(root) sub.set_value(0, "Foo#{i}") for i in 1..2 sub2 = model.append(sub) sub2.set_value(0, "Bar#{i}") sub2.set_value(1, i == 1) # Bar 1 is enabled end end @window.show_all end # Initialize Gtk Gtk.init # Create the main window: @window = Gtk::Window.new(Gtk::Window::TOPLEVEL) @window.set_size_request(400, 400) @window.signal_connect("delete_event") { Gtk.main_quit } @window.set_border_width(5) @window.set_title("TreeStore Example"); # Put a scrollable vbox in it: vbox2 = Gtk::VBox.new(false, 0) scroller = Gtk::ScrolledWindow.new scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) @window.add(vbox2) vbox2.pack_start(scroller, true, true, 0) # Create the TreeStore with two columns model = Gtk::TreeStore.new(String, TrueClass) # Create the TreeView adding the TreeStore tree = Gtk::TreeView.new(model) # Create the Text renderer and set properties render1 = Gtk::CellRendererText.new # Create the Toggle renderer and set properties render2 = Gtk::CellRendererToggle.new render2.activatable = true # Create the columns c1 = Gtk::TreeViewColumn.new("Headings", render1, {:text => 0}) c2 = Gtk::TreeViewColumn.new("Enabled", render2, {:active => 1}) ## This doesn't work: #c2.signal_connect("clicked") { |view, path, column| # p column # p column.class.name #} # append the columns to treeview tree.append_column(c1) tree.append_column(c2) # add the treeview to the scroller scroller.add(tree) build_tree(tree, model) @window.show_all Gtk.main