|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
xmlns:its="http://www.w3.org/2005/11/its"
|
|
Packit |
1470ea |
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
Packit |
1470ea |
type="guide" style="task"
|
|
Packit |
1470ea |
id="hello-world">
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title type="link">Hello World (C)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="c#examples"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2013-06-17" status="review"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Susanna Huhtanen</name>
|
|
Packit |
1470ea |
<email its:translate="no">ihmis.suski@gmail.com</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
<credit type="editor">
|
|
Packit |
1470ea |
<name>Tiffany Antopolski</name>
|
|
Packit |
1470ea |
<email its:translate="no">tiffany.antopolski@gmail.com</email>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
<credit type="editor">
|
|
Packit |
1470ea |
<name>Bastian Ilsø</name>
|
|
Packit |
1470ea |
<email its:translate="no">bastianilso@gnome.org</email>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>Creating a small "Hello, World" application using GTK+.</desc>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Hello world</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<note>
|
|
Packit |
1470ea |
For a detailed walk-through of creating a GTK+ dialog in C, see
|
|
Packit |
1470ea |
<link href="https://developer.gnome.org/gtk3/stable/gtk-getting-started.html">Getting Started with GTK+</link>
|
|
Packit |
1470ea |
</note>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Writing a hello world GTK+ dialog in C can be done as seen in the code sample below:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<xi:include href="samples/hello-in-C/hello-world.c" parse="text"><xi:fallback/></xi:include>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
GtkApplication initializes GTK+. It also connects the <gui>x</gui> button
|
|
Packit |
1470ea |
that's automatically generated along with the window to the "destroy" signal.
|
|
Packit |
1470ea |
We can start building our first window.
|
|
Packit |
1470ea |
We do this by creating a variable called window and assigning it
|
|
Packit |
1470ea |
a gtk_application_window_new. The window title can be any string you want it
|
|
Packit |
1470ea |
to be. To be on the safe side, it's best to stick to UTF-8 encoding.
|
|
Packit |
1470ea |
The code above will create a dialog window similar to what can be seen below:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/hello-world.png"/>
|
|
Packit |
1470ea |
</page>
|