# .require. mono
# .compile-only.
# .args. -c -pkg:gtk-sharp-2.0
"""
A small example of using the GTK GUI library.

How to compile:
cobra -c -pkg:gtk-sharp-2.0 390-GTK.cobra 

URLs of interest:
	http://www.mono-project.com/GtkSharp
	http://www.mono-project.com/GtkSharp:_Hello_World
	http://www.mono-project.com/GtkSharpBeginnersGuide
	http://go-mono.org/docs/index.aspx?tlink=5@N%3aGtk  (Mono Gtk Namespace Docs)
	http://en.wikipedia.org/wiki/Gtk_Sharp

Credit:
	Adapted from http://www.mono-project.com/GtkSharp:_Hello_World

Misc:
	Other GUI libraries include System.Windows.Forms and Cocoa#.
"""

use Gtk

class ToggleButtons

	def main is shared
		ToggleButtons().run

	def onDeleteEvent(obj, args as DeleteEventArgs)
		Application.quit

	def onExitButtonEvent(obj, args as EventArgs)
		Application.quit

	def run
		Application.init

		window = Window('Toggle Buttons')
		listen window.deleteEvent, ref .onDeleteEvent
		window.borderWidth = 0

		box1 = VBox(false, 10)
		window.add(box1)
		box1.show

		box2 = VBox(false, 10)
		box2.borderWidth = 10
		box1.packStart(box2, true, true, 0)
		box2.show

		toggleButt = ToggleButton('Button 1')
		box2.packStart(toggleButt, true, true, 0)
		toggleButt.show

		toggleButt = ToggleButton('Button 2')
		toggleButt.active = true
		box2.packStart(toggleButt, true, true, 0)
		toggleButt.show

		separator = HSeparator()
		box1.packStart(separator, false, true, 0)
		separator.show

		box3 = VBox(false, 10)
		box3.borderWidth = 10
		box1.packStart(box3, false, true, 0)

		button = Button('Close')
		listen button.clicked, ref .onExitButtonEvent

		box3.packStart(button, true, true, 0)
		button.canDefault = true
		button.grabDefault
		button.show

		window.showAll 

		Application.run
