1 #include <gtk/gtk.h>
2 
3 
4 
5 static void
activate(GtkApplication * app,gpointer user_data)6 activate (GtkApplication *app,
7           gpointer        user_data)
8 {
9   GtkWidget *window;
10   GtkWidget *label;
11 
12   /*Create a window with a title and a default size*/
13   window = gtk_application_window_new (app);
14   gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
15   gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");
16   gtk_window_set_default_size (GTK_WINDOW (window), 200,100);
17 
18   /*Create a label and set its alignment. Setting the line wrap to TRUE makes
19   the label break lines if the text exceeds the widget's size. When set to
20   FALSE the text gets cut off by the edge of the widget*/
21   label = gtk_label_new ("Hello GNOME!");
22   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
23   gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
24 
25   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (label));
26 
27   gtk_widget_show_all (GTK_WIDGET (window));
28 }
29 
30 
31 
32 int
main(int argc,char ** argv)33 main (int argc, char **argv)
34 {
35   GtkApplication *app;
36   int status;
37 
38   app = gtk_application_new ("org.gtk.example",G_APPLICATION_FLAGS_NONE);
39   g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
40   status = g_application_run (G_APPLICATION (app), argc, argv);
41   g_object_unref (app);
42   return status;
43 }
44