|
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="grid.vala" xml:lang="ca">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">Grid (Vala)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.vala#layout"/>
|
|
Packit |
1470ea |
<link type="seealso" xref="button.vala"/>
|
|
Packit |
1470ea |
<link type="seealso" xref="progressbar.vala"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-05-04" 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>Pack widgets in rows and columns</desc>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Grid widget</title>
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/grid.png"/>
|
|
Packit |
1470ea |
A button widget connected to a progress bar.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public class MyWindow : Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Gtk.Widget progress_bar;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "Grid Example");
|
|
Packit |
1470ea |
var grid = new Gtk.Grid();
|
|
Packit |
1470ea |
progress_bar = new Gtk.ProgressBar ();
|
|
Packit |
1470ea |
progress_bar.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var button = new Gtk.Button.with_label ("Button");
|
|
Packit |
1470ea |
button.clicked.connect (on_button_click);
|
|
Packit |
1470ea |
button.show ();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
this.add(grid);
|
|
Packit |
1470ea |
grid.attach(button, 0, 1, 1, 1);
|
|
Packit |
1470ea |
grid.attach_next_to (progress_bar, button, Gtk.PositionType.BOTTOM, 1, 1);
|
|
Packit |
1470ea |
grid.show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
void on_button_click (Gtk.Button button) {
|
|
Packit |
1470ea |
(progress_bar as Gtk.ProgressBar).pulse ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
new MyWindow (this).show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
internal MyApplication () {
|
|
Packit |
1470ea |
Object (application_id: "org.example.MyApplication");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
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.Grid.html">Gtk.Grid</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</page>
|