No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / examples / hello-c-gnome / hello.c
blob2937b0284932b55ed3331a0fc8b2958eb568b086
1 /* Example for use of GNU gettext.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3 This file is in the public domain.
5 Source code of the C program. */
8 /* Get GNOME declarations. */
9 #include <gnome.h>
11 /* Get getpid() declaration. */
12 #if HAVE_UNISTD_H
13 # include <unistd.h>
14 #endif
16 static void
17 quit_callback (GtkWidget *widget, void *data)
19 gtk_main_quit ();
22 int
23 main (int argc, char *argv[])
25 GtkWidget *window;
26 GtkWidget *panel;
27 GtkWidget *label1;
28 GtkWidget *label1aligned;
29 GtkWidget *label2;
30 GtkWidget *label2aligned;
31 GtkWidget *button;
32 GtkWidget *buttonbar;
34 /* Initializations. */
36 gnome_init (PACKAGE, VERSION, argc, argv);
37 textdomain ("hello-c-gnome");
38 bindtextdomain ("hello-c-gnome", LOCALEDIR);
40 /* Create the GUI elements. */
42 window = gnome_app_new ("hello-c-gnome", "Hello example");
43 gtk_widget_realize (window);
44 gtk_signal_connect (GTK_OBJECT (window), "delete_event",
45 GTK_SIGNAL_FUNC (quit_callback), NULL);
47 label1 = gtk_label_new (_("Hello, world!"));
49 label1aligned = gtk_alignment_new (0.0, 0.5, 0, 0);
50 gtk_container_add (GTK_CONTAINER (label1aligned), label1);
52 label2 = gtk_label_new (g_strdup_printf (_("This program is running as process number %d."), getpid ()));
54 label2aligned = gtk_alignment_new (0.0, 0.5, 0, 0);
55 gtk_container_add (GTK_CONTAINER (label2aligned), label2);
57 button = gtk_button_new_with_label ("OK");
58 gtk_signal_connect (GTK_OBJECT (button), "clicked",
59 GTK_SIGNAL_FUNC (quit_callback), NULL);
61 buttonbar = gtk_hbutton_box_new ();
62 gtk_button_box_set_layout (GTK_BUTTON_BOX (buttonbar), GTK_BUTTONBOX_END);
63 gtk_box_pack_start_defaults (GTK_BOX (buttonbar), button);
65 panel = gtk_vbox_new (FALSE, GNOME_PAD_SMALL);
66 gtk_box_pack_start_defaults (GTK_BOX (panel), label1aligned);
67 gtk_box_pack_start_defaults (GTK_BOX (panel), label2aligned);
68 gtk_box_pack_start_defaults (GTK_BOX (panel), buttonbar);
70 gnome_app_set_contents (GNOME_APP (window), panel);
72 /* Make the GUI elements visible. */
74 gtk_widget_show (label1);
75 gtk_widget_show (label1aligned);
76 gtk_widget_show (label2);
77 gtk_widget_show (label2aligned);
78 gtk_widget_show (button);
79 gtk_widget_show (buttonbar);
80 gtk_widget_show (panel);
81 gtk_widget_show (window);
83 /* Start the event loop. */
85 gtk_main ();
87 return 0;