1*946379e7Schristos /* Example for use of GNU gettext.
2*946379e7Schristos Copyright (C) 2003 Free Software Foundation, Inc.
3*946379e7Schristos This file is in the public domain.
4*946379e7Schristos
5*946379e7Schristos Source code of the C++ program. */
6*946379e7Schristos
7*946379e7Schristos
8*946379e7Schristos /* Get GNOME declarations. */
9*946379e7Schristos #include <gnome.h>
10*946379e7Schristos #include <gtk--.h>
11*946379e7Schristos
12*946379e7Schristos /* Get getpid() declaration. */
13*946379e7Schristos #if HAVE_UNISTD_H
14*946379e7Schristos # include <unistd.h>
15*946379e7Schristos #endif
16*946379e7Schristos
17*946379e7Schristos static Gtk::Main *application;
18*946379e7Schristos
19*946379e7Schristos static gint
quit_callback(GdkEventAny *)20*946379e7Schristos quit_callback (GdkEventAny*)
21*946379e7Schristos {
22*946379e7Schristos application->quit ();
23*946379e7Schristos }
24*946379e7Schristos
25*946379e7Schristos int
main(int argc,char * argv[])26*946379e7Schristos main (int argc, char *argv[])
27*946379e7Schristos {
28*946379e7Schristos Gtk::Window *window;
29*946379e7Schristos Gtk::VBox *panel;
30*946379e7Schristos Gtk::Label *label1;
31*946379e7Schristos Gtk::Alignment *label1aligned;
32*946379e7Schristos Gtk::Label *label2;
33*946379e7Schristos Gtk::Alignment *label2aligned;
34*946379e7Schristos Gtk::Button *button;
35*946379e7Schristos Gtk::HButtonBox *buttonbar;
36*946379e7Schristos
37*946379e7Schristos /* Initializations. */
38*946379e7Schristos
39*946379e7Schristos setlocale (LC_ALL, "");
40*946379e7Schristos application = new Gtk::Main (argc, argv);
41*946379e7Schristos textdomain ("hello-c++-gnome");
42*946379e7Schristos bindtextdomain ("hello-c++-gnome", LOCALEDIR);
43*946379e7Schristos
44*946379e7Schristos /* Create the GUI elements. */
45*946379e7Schristos
46*946379e7Schristos window = new Gtk::Window (GTK_WINDOW_TOPLEVEL);
47*946379e7Schristos window->set_title ("Hello example");
48*946379e7Schristos window->realize ();
49*946379e7Schristos window->delete_event.connect (SigC::slot (quit_callback));
50*946379e7Schristos
51*946379e7Schristos label1 = new Gtk::Label (_("Hello, world!"));
52*946379e7Schristos
53*946379e7Schristos label1aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
54*946379e7Schristos label1aligned->add (*label1);
55*946379e7Schristos
56*946379e7Schristos label2 = new Gtk::Label (g_strdup_printf (_("This program is running as process number %d."), getpid ()));
57*946379e7Schristos
58*946379e7Schristos label2aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
59*946379e7Schristos label2aligned->add (*label2);
60*946379e7Schristos
61*946379e7Schristos button = new Gtk::Button ("OK");
62*946379e7Schristos button->clicked.connect (Gtk::Main::quit.slot()); //slot (quit_callback));
63*946379e7Schristos
64*946379e7Schristos buttonbar = new Gtk::HButtonBox (GTK_BUTTONBOX_END);
65*946379e7Schristos buttonbar->pack_start (*button);
66*946379e7Schristos
67*946379e7Schristos panel = new Gtk::VBox (false, GNOME_PAD_SMALL);
68*946379e7Schristos panel->pack_start (*label1aligned);
69*946379e7Schristos panel->pack_start (*label2aligned);
70*946379e7Schristos panel->pack_start (*buttonbar);
71*946379e7Schristos
72*946379e7Schristos window->add (*panel);
73*946379e7Schristos
74*946379e7Schristos /* Make the GUI elements visible. */
75*946379e7Schristos
76*946379e7Schristos label1->show ();
77*946379e7Schristos label1aligned->show ();
78*946379e7Schristos label2->show ();
79*946379e7Schristos label2aligned->show ();
80*946379e7Schristos button->show ();
81*946379e7Schristos buttonbar->show ();
82*946379e7Schristos panel->show ();
83*946379e7Schristos window->show ();
84*946379e7Schristos
85*946379e7Schristos /* Start the event loop. */
86*946379e7Schristos
87*946379e7Schristos application->run ();
88*946379e7Schristos }
89