<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" type="guide" style="task" id="button.vala" xml:lang="gl">
  <info>
    <link type="guide" xref="beginner.vala#buttons"/>
    <revision version="0.1" date="2012-02-21" status="stub"/>

    <credit type="author copyright">
      <name>Tiffany Antopolski</name>
      <email>tiffany.antopolski@gmail.com</email>
      <years>2012</years>
    </credit>

    <desc>A button widget which can be connected to other widgets.</desc>
  </info>

  <title>Button widget</title>

  <media type="image" mime="image/png" src="media/button.png"/>
  <p>A button widget connected to stdout.printf (), and a modal window.</p>
  
      <code mime="text/x-vala" style="numbered"><![CDATA[
/*callback for the "clicked" signal.*/
void button_clicked_cb () {
	stdout.printf ("You clicked the button!\n");
	//TODO: add a modal window
}

int main (string[] args) {

	Gtk.init (ref args);

	var window = new Gtk.Window ();
	window.title = "GNOME Button";
	window.set_default_size (250,50);

	var button = new Gtk.Button.with_label ("Click Me");
	window.add (button);

	window.window_position = Gtk.WindowPosition.CENTER;

	/* The "clicked" signal is emitted when the
	   button is clicked.  The signal is connected to
	   the button_clicked_cb method defined above.*/
	button.clicked.connect (button_clicked_cb);

	/*The "destroy" signal is emitted when the x
	  in the top right of the window is clicked.
	  The destroy signal is connected to the
	  main_quit method, which destroys the window
	  and exits the program.*/
	window.destroy.connect (Gtk.main_quit);

	window.show_all ();

	Gtk.main ();
	return 0;
}
]]></code>
<p>
  In this sample we used the following:
  <link xref="window.vala">Gtk.Window</link>,
  <link href="http://www.valadoc.org/#!api=gtk+-2.0/Gtk.Button">Gtk.Button</link>
</p>
</page>
