|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="spinbutton.vala" xml:lang="de">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">SpinButton (Vala)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.vala#entry"/>
|
|
Packit |
1470ea |
<link type="seealso" xref="label.vala"/>
|
|
Packit |
1470ea |
<link type="seealso" xref="grid.vala"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-05-07" status="draft"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Tiffany Antopolski</name>
|
|
Packit |
1470ea |
<email its:translate="no">tiffany.antopolski@gmail.com</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>Retrieve an integer or floating point number.</desc>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Mario Blättermann</mal:name>
|
|
Packit |
1470ea |
<mal:email>mario.blaettermann@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2011, 2013</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>SpinButton</title>
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/spinbutton.png"/>
|
|
Packit |
1470ea |
Choose a number, by entering it or by clicking on the -/+ buttons!
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* This is the application. */
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
Gtk.Label label;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Override the 'activate' signal of GLib.Application. */
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
var window = new Gtk.ApplicationWindow (this);
|
|
Packit |
1470ea |
window.title = "SpinButton Example";
|
|
Packit |
1470ea |
window.set_default_size (210, 70);
|
|
Packit |
1470ea |
window.set_border_width (5);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var spinbutton = new Gtk.SpinButton.with_range (0, 100, 1);
|
|
Packit |
1470ea |
spinbutton.set_hexpand (true);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
label = new Gtk.Label ("Choose a number");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var grid = new Gtk.Grid ();
|
|
Packit |
1470ea |
grid.attach (spinbutton, 0, 0, 1, 1);
|
|
Packit |
1470ea |
grid.attach (label, 0, 1, 1, 1);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
spinbutton.value_changed.connect (this.value_changed_cb);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
window.add (grid);
|
|
Packit |
1470ea |
window.show_all ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
void value_changed_cb (Gtk.SpinButton spin) {
|
|
Packit |
1470ea |
label.set_text ("The number you selected is %.0f.".printf (spin.get_value()));
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* main creates and runs the application. */
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
In this sample we used the following:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.SpinButton.html">Gtk.SpinButton</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</page>
|