~ubuntu-branches/ubuntu/breezy/gettext/breezy

« back to all changes in this revision

Viewing changes to gettext-tools/examples/hello-c++-gnome/hello.cc

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2004-03-14 17:40:02 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040314174002-p1ad5ldve1hqzhye
Tags: 0.14.1-2
* Added libexpat1-dev to Build-Depends, for glade support.
* Added libc0.1-dev to Build-Depends, for GNU/kFreeBSD.
* Removed special-casing of knetbsd-gnu in debian/rules.

Show diffs side-by-side

added added

removed removed

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