def create_main_window
buttons = [
["button box", ButtonBoxSample],
["buttons", ButtonSample],
["check buttons", CheckButtonSample],
["color selection", ColorSelectionSample],
["dialog", DialogSample],
["entry", EntrySample],
["file selection", FileSelectionSample],
["font selection", FontSelectionSample],
["gamma curve", GammaCurveSample],
["labels", LabelSample],
["layout", LayoutSample],
["menus", MenuSample],
["notebook", NotebookSample],
["pixmap", PixmapSample],
["progress bar", ProgressBarSample],
["radio buttons", RadioButtonSample],
["range controls", RangeSample],
["reparent", ReparentSample],
["rulers", RulerSample],
["saved position", SavedPositionSample],
["scrolled windows", ScrolledWindowSample],
["shapes", ShapesSample],
["spinbutton", SpinButtonSample],
["statusbar", StatusbarSample],
["toggle buttons", ToggleButtonSample],
["toolbar", ToolbarSample],
["tooltips", TooltipsSample],
["WM hints", WMHintsSample],
]
nbuttons = buttons.size
window = Gtk::Window.new
window.name = "main window"
window.set_default_size(200, 400)
window.move(20, 20)
window.signal_connect("destroy"){Gtk.main_quit}
box1 = Gtk::VBox.new(false, 0)
window.add(box1)
label = Gtk::Label.new("Gtk+ v#{Gtk::MAJOR_VERSION}.#{Gtk::MINOR_VERSION}.#{Gtk::MICRO_VERSION}")
box1.pack_start(label, false, false, 0)
label = Gtk::Label.new("Ruby/GTK2 v#{Gtk::BINDING_VERSION.join(".")}")
box1.pack_start(label, false, false, 0)
scrolled_window = Gtk::ScrolledWindow.new(nil, nil)
scrolled_window.border_width = 10
scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC,
Gtk::POLICY_AUTOMATIC)
box1.pack_start(scrolled_window, true, true, 0)
box2 = Gtk::VBox.new(false, 0)
box2.border_width = 10
scrolled_window.add_with_viewport(box2);
box2.focus_vadjustment = scrolled_window.vadjustment
buttons.each do |title, sample_class|
button = Gtk::Button.new(title)
unless sample_class.nil?
button.signal_connect("clicked"){|obj|
sample_class.invoke
}
else
button.sensitive = false
end
box2.pack_start(button, true, true, 0)
end
box1.pack_start(Gtk::HSeparator.new, false, true, 0)
button = Gtk::Button.new("close")
button.signal_connect("clicked") do
window.destroy
Gtk.main_quit
end
box1.pack_start(button, false, true, 5)
window.show_all
end