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="fr"> 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>Un élément graphique qui affiche du texte</desc> 16 17 <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright"> 18 <mal:name>Luc Rebert,</mal:name> 19 <mal:email>traduc@rebert.name</mal:email> 20 <mal:years>2011</mal:years> 21 </mal:credit> 22 23 <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright"> 24 <mal:name>Alain Lojewski,</mal:name> 25 <mal:email>allomervan@gmail.com</mal:email> 26 <mal:years>2011-2012</mal:years> 27 </mal:credit> 28 29 <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright"> 30 <mal:name>Luc Pionchon</mal:name> 31 <mal:email>pionchon.luc@gmail.com</mal:email> 32 <mal:years>2011</mal:years> 33 </mal:credit> 34 35 <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright"> 36 <mal:name>Bruno Brouard</mal:name> 37 <mal:email>annoa.b@gmail.com</mal:email> 38 <mal:years>2011-12</mal:years> 39 </mal:credit> 40 41 <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright"> 42 <mal:name>Luis Menina</mal:name> 43 <mal:email>liberforce@freeside.fr</mal:email> 44 <mal:years>2014</mal:years> 45 </mal:credit> 46 </info> 47 48 <title>Étiquette</title> 49<table> 50 <tr> 51 <td> 52 <media type="image" mime="image/png" src="media/label.png"/> 53 <p>Une étiquette simple</p> 54 </td> 55 </tr> 56</table> 57 58<code mime="text/x-csrc" style="numbered">#include <gtk/gtk.h> 59 60 61 62static void 63activate (GtkApplication *app, 64 gpointer user_data) 65{ 66 GtkWidget *window; 67 GtkWidget *label; 68 69 /*Create a window with a title and a default size*/ 70 window = gtk_application_window_new (app); 71 gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app)); 72 gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME"); 73 gtk_window_set_default_size (GTK_WINDOW (window), 200,100); 74 75 /*Create a label and set its alignment. Setting the line wrap to TRUE makes 76 the label break lines if the text exceeds the widget's size. When set to 77 FALSE the text gets cut off by the edge of the widget*/ 78 label = gtk_label_new ("Hello GNOME!"); 79 gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); 80 gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); 81 82 gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (label)); 83 84 gtk_widget_show_all (GTK_WIDGET (window)); 85} 86 87 88 89int 90main (int argc, char **argv) 91{ 92 GtkApplication *app; 93 int status; 94 95 app = gtk_application_new ("org.gtk.example",G_APPLICATION_FLAGS_NONE); 96 g_signal_connect (app, "activate", G_CALLBACK (activate), NULL); 97 status = g_application_run (G_APPLICATION (app), argc, argv); 98 g_object_unref (app); 99 return status; 100} 101</code> 102<p>Dans cet exemple, les éléments suivants sont utilisés :</p> 103<list> 104 <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html">GtkApplication</link></p></item> 105 <item><p><link href="http://developer.gnome.org/gtk3/stable/GtkWindow.html">GtkWindow</link></p></item> 106 <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLabel.html">GtkLabel</link></p></item> 107</list> 108</page> 109