Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / examples / hello-c++-gnome / hello.cc
blob6056083dc63c1adf69da920576941fe38f16cbb1
1 /* Example for use of GNU gettext.
2 This file is in the public domain.
4 Source code of the C++ program. */
7 /* Get GNOME declarations. */
8 #include <gnome.h>
9 #include <gtk--.h>
11 /* Get getpid() declaration. */
12 #if HAVE_UNISTD_H
13 # include <unistd.h>
14 #endif
16 static Gtk::Main *application;
18 static gint
19 quit_callback (GdkEventAny*)
21 application->quit ();
24 int
25 main (int argc, char *argv[])
27 Gtk::Window *window;
28 Gtk::VBox *panel;
29 Gtk::Label *label1;
30 Gtk::Alignment *label1aligned;
31 Gtk::Label *label2;
32 Gtk::Alignment *label2aligned;
33 Gtk::Button *button;
34 Gtk::HButtonBox *buttonbar;
36 /* Initializations. */
38 setlocale (LC_ALL, "");
39 application = new Gtk::Main (argc, argv);
40 textdomain ("hello-c++-gnome");
41 bindtextdomain ("hello-c++-gnome", LOCALEDIR);
43 /* Create the GUI elements. */
45 window = new Gtk::Window (GTK_WINDOW_TOPLEVEL);
46 window->set_title ("Hello example");
47 window->realize ();
48 window->delete_event.connect (SigC::slot (quit_callback));
50 label1 = new Gtk::Label (_("Hello, world!"));
52 label1aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
53 label1aligned->add (*label1);
55 label2 = new Gtk::Label (g_strdup_printf (_("This program is running as process number %d."), getpid ()));
57 label2aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
58 label2aligned->add (*label2);
60 button = new Gtk::Button ("OK");
61 button->clicked.connect (Gtk::Main::quit.slot()); //slot (quit_callback));
63 buttonbar = new Gtk::HButtonBox (GTK_BUTTONBOX_END);
64 buttonbar->pack_start (*button);
66 panel = new Gtk::VBox (false, GNOME_PAD_SMALL);
67 panel->pack_start (*label1aligned);
68 panel->pack_start (*label2aligned);
69 panel->pack_start (*buttonbar);
71 window->add (*panel);
73 /* Make the GUI elements visible. */
75 label1->show ();
76 label1aligned->show ();
77 label2->show ();
78 label2aligned->show ();
79 button->show ();
80 buttonbar->show ();
81 panel->show ();
82 window->show ();
84 /* Start the event loop. */
86 application->run ();