File: hello.m

package info (click to toggle)
gettext 0.17-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 64,956 kB
  • ctags: 38,653
  • sloc: ansic: 299,024; sh: 49,429; makefile: 8,097; perl: 4,181; lisp: 3,261; yacc: 665; java: 618; cs: 578; sed: 369; objc: 337; cpp: 325; awk: 80; tcl: 63; pascal: 12; php: 8
file content (88 lines) | stat: -rw-r--r-- 2,241 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Example for use of GNU gettext.
   This file is in the public domain.

   Source code of the Objective C program.  */


/* Get GNOME declarations.  */
#include <obgnome/obgnome.h>

/* Get getpid() declaration.  */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif

static void
quit_callback (GtkWidget *widget, void *data)
{
  gtk_main_quit ();
}

int
main (int argc, char *argv[])
{
  Gnome_App *application;
  Gtk_Window *window;
  Gtk_VBox *panel;
  Gtk_Label *label1;
  Gtk_Alignment *label1aligned;
  Gtk_Label *label2;
  Gtk_Alignment *label2aligned;
  Gtk_Button *button;
  Gtk_ButtonBox *buttonbar;

  /* Initializations.  */

  application = [[Gnome_App alloc] initApp: PACKAGE : VERSION : argc : argv];
  textdomain ("hello-objc-gnome");
  bindtextdomain ("hello-objc-gnome", LOCALEDIR);

  /* Create the GUI elements.  */

  window = [[Gtk_Window alloc] initWithWindowInfo: GTK_WINDOW_TOPLEVEL];
  [window set_title: "Hello example"];
  [window realize];
  [window signal_connect: "delete_event" signalFunc: quit_callback funcData: NULL];

  label1 = [[Gtk_Label alloc] initWithLabelInfo: _("Hello, world!")];

  label1aligned = [[Gtk_Alignment alloc] initWithAlignmentInfo: 0.0 : 0.5 : 0 : 0];
  [label1aligned add: label1];

  label2 = [[Gtk_Label alloc] initWithLabelInfo: g_strdup_printf (_("This program is running as process number %d."), getpid ())];

  label2aligned =  [[Gtk_Alignment alloc] initWithAlignmentInfo: 0.0 : 0.5 : 0 : 0];
  [label2aligned add: label2];

  button = [Gtk_Button alloc];
  [button initWithLabel: "OK"];
  [button signal_connect: "clicked" signalFunc: quit_callback funcData: NULL];

  buttonbar = [Gtk_HButtonBox new];
  [buttonbar set_layout: GTK_BUTTONBOX_END];
  [buttonbar pack_start_defaults: button];

  panel = [[Gtk_VBox alloc] initWithVBoxInfo: FALSE : GNOME_PAD_SMALL];
  [panel pack_start_defaults: label1aligned];
  [panel pack_start_defaults: label2aligned];
  [panel pack_start_defaults: buttonbar];

  [window add: panel];

  /* Make the GUI elements visible.  */

  [label1 show];
  [label1aligned show];
  [label2 show];
  [label2aligned show];
  [button show];
  [buttonbar show];
  [panel show];
  [window show];

  /* Start the event loop.  */

  gtk_main ();

  return 0;
}