1<?xml version="1.0" encoding="utf-8"?>
2<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="window.vala" xml:lang="ca">
3  <info>
4  <title type="text">Window (Vala)</title>
5    <link type="guide" xref="beginner.vala#windows"/>
6    <revision version="0.1" date="2012-04-07" status="draft"/>
7
8    <credit type="author copyright">
9      <name>Tiffany Antopolski</name>
10      <email its:translate="no">tiffany.antopolski@gmail.com</email>
11      <years>2012</years>
12    </credit>
13
14    <desc>A toplevel window which can contain other widgets</desc>
15  </info>
16
17  <title>Window</title>
18<table>
19  <tr>
20    <td>
21      <media type="image" mime="image/png" src="media/window.png"/>
22      <p>The simplest Gtk.Application</p>
23    </td>
24    <td>
25      <p>Use <link xref="GtkApplicationWindow.vala">Application Window</link> if you need GMenu support.</p>
26    </td>
27  </tr>
28</table>
29<code mime="text/x-csharp" style="numbered">/* This is the application. */
30public class Application : Gtk.Application {
31
32	/* Constructor */
33	public Application () {
34		Object (application_id: "org.example.window");
35	}
36
37	/* Override the 'activate' signal of GLib.Application,
38	 * which is inherited by Gtk.Application. */
39	public override void activate () {
40
41		var window = new Gtk.Window ();
42		window.title = "Welcome to GNOME";
43
44		/* The following 3 lines are included here to introduce
45		 * you to ways you can adjust the toplevel window to suit
46		 * your needs.  Uncomment them to see what they do.
47		 */
48
49		//window.border_width = 10;
50		//window.set_default_size (350, 70);
51		//window.window_position = Gtk.WindowPosition.CENTER;
52
53		/* Add the window to this application. */
54		this.add_window (window);
55
56		/* Show the window. */
57		window.show ();
58	}
59}
60
61/* The main function creates the application and runs it.*/
62int main (string[] args) {
63	var app = new Application ();
64	return app.run (args);
65}
66</code>
67<p>
68  In this sample we used the following:
69</p>
70<list>
71  <item><p><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Application.html">Gtk.Application</link></p></item>
72  <item><p>The widget <link href="http://www.valadoc.org/gtk+-3.0/Gtk.Window.html">Gtk.Window</link></p></item>
73
74  <item><p>The enum <link href="http://www.valadoc.org/gtk+-3.0/Gtk.WindowPosition.html">Gtk.WindowPosition</link></p></item>
75
76  <item><p>The method <link href="http://www.valadoc.org/gtk+-3.0/Gtk.Window.set_default_size.html">set_default_size</link></p></item>
77
78  <item><p><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Container.border_width.html">border_width</link></p></item>
79
80  <item><p><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Window.window_position.html">window_position</link></p></item>
81</list>
82</page>
83