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="label.c" xml:lang="gl">
3  <info>
4    <title type="text">Label (C)</title>
5    <link type="guide" xref="c#display-widgets"/>
6    <link type="seealso" xref="switch.c"/>
7    <revision version="0.2" date="2012-06-22" status="draft"/>
8
9    <credit type="author copyright">
10      <name>Monica Kochofar</name>
11      <email its:translate="no">monicakochofar@gmail.com</email>
12      <years>2012</years>
13    </credit>
14
15    <desc>A widget which displays text</desc>
16
17    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
18      <mal:name>Fran Dieguez</mal:name>
19      <mal:email>frandieguez@gnome.org</mal:email>
20      <mal:years>2012-2013.</mal:years>
21    </mal:credit>
22  </info>
23
24  <title>Etiqueta</title>
25<table>
26  <tr>
27    <td>
28      <media type="image" mime="image/png" src="media/label.png"/>
29      <p>A simple label</p>
30    </td>
31  </tr>
32</table>
33
34<code mime="text/x-csrc" style="numbered">#include &lt;gtk/gtk.h&gt;
35
36
37
38static void
39activate (GtkApplication *app,
40          gpointer        user_data)
41{
42  GtkWidget *window;
43  GtkWidget *label;
44
45  /*Create a window with a title and a default size*/
46  window = gtk_application_window_new (app);
47  gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
48  gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");
49  gtk_window_set_default_size (GTK_WINDOW (window), 200,100);
50
51  /*Create a label and set its alignment. Setting the line wrap to TRUE makes
52  the label break lines if the text exceeds the widget's size. When set to
53  FALSE the text gets cut off by the edge of the widget*/
54  label = gtk_label_new ("Hello GNOME!");
55  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
56  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
57
58  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (label));
59
60  gtk_widget_show_all (GTK_WIDGET (window));
61}
62
63
64
65int
66main (int argc, char **argv)
67{
68  GtkApplication *app;
69  int status;
70
71  app = gtk_application_new ("org.gtk.example",G_APPLICATION_FLAGS_NONE);
72  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
73  status = g_application_run (G_APPLICATION (app), argc, argv);
74  g_object_unref (app);
75  return status;
76}
77</code>
78<p>Neste exemplo empregaremos o seguinte:</p>
79<list>
80  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html">GtkApplication</link></p></item>
81  <item><p><link href="http://developer.gnome.org/gtk3/stable/GtkWindow.html">GtkWindow</link></p></item>
82 <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLabel.html">GtkLabel</link></p></item>
83</list>
84</page>
85