No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / examples / hello-c++-gnome / hello.cc
blob15ae0a98dbc8f0d5574b4e0f91c9f02142e5b379
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>
10 #include <gtk--.h>
12 /* Get getpid() declaration. */
13 #if HAVE_UNISTD_H
14 # include <unistd.h>
15 #endif
17 static Gtk::Main *application;
19 static gint
20 quit_callback (GdkEventAny*)
22 application->quit ();
25 int
26 main (int argc, char *argv[])
28 Gtk::Window *window;
29 Gtk::VBox *panel;
30 Gtk::Label *label1;
31 Gtk::Alignment *label1aligned;
32 Gtk::Label *label2;
33 Gtk::Alignment *label2aligned;
34 Gtk::Button *button;
35 Gtk::HButtonBox *buttonbar;
37 /* Initializations. */
39 setlocale (LC_ALL, "");
40 application = new Gtk::Main (argc, argv);
41 textdomain ("hello-c++-gnome");
42 bindtextdomain ("hello-c++-gnome", LOCALEDIR);
44 /* Create the GUI elements. */
46 window = new Gtk::Window (GTK_WINDOW_TOPLEVEL);
47 window->set_title ("Hello example");
48 window->realize ();
49 window->delete_event.connect (SigC::slot (quit_callback));
51 label1 = new Gtk::Label (_("Hello, world!"));
53 label1aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
54 label1aligned->add (*label1);
56 label2 = new Gtk::Label (g_strdup_printf (_("This program is running as process number %d."), getpid ()));
58 label2aligned = new Gtk::Alignment (0.0, 0.5, 0, 0);
59 label2aligned->add (*label2);
61 button = new Gtk::Button ("OK");
62 button->clicked.connect (Gtk::Main::quit.slot()); //slot (quit_callback));
64 buttonbar = new Gtk::HButtonBox (GTK_BUTTONBOX_END);
65 buttonbar->pack_start (*button);
67 panel = new Gtk::VBox (false, GNOME_PAD_SMALL);
68 panel->pack_start (*label1aligned);
69 panel->pack_start (*label2aligned);
70 panel->pack_start (*buttonbar);
72 window->add (*panel);
74 /* Make the GUI elements visible. */
76 label1->show ();
77 label1aligned->show ();
78 label2->show ();
79 label2aligned->show ();
80 button->show ();
81 buttonbar->show ();
82 panel->show ();
83 window->show ();
85 /* Start the event loop. */
87 application->run ();