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