1/* Example for use of GNU gettext. 2 This file is in the public domain. 3 4 Source code of the Objective C program. */ 5 6 7/* Get GNOME declarations. */ 8#include <obgnome/obgnome.h> 9 10/* Get getpid() declaration. */ 11#if HAVE_UNISTD_H 12# include <unistd.h> 13#endif 14 15static void 16quit_callback (GtkWidget *widget, void *data) 17{ 18 gtk_main_quit (); 19} 20 21int 22main (int argc, char *argv[]) 23{ 24 Gnome_App *application; 25 Gtk_Window *window; 26 Gtk_VBox *panel; 27 Gtk_Label *label1; 28 Gtk_Alignment *label1aligned; 29 Gtk_Label *label2; 30 Gtk_Alignment *label2aligned; 31 Gtk_Button *button; 32 Gtk_ButtonBox *buttonbar; 33 34 /* Initializations. */ 35 36 application = [[Gnome_App alloc] initApp: PACKAGE : VERSION : argc : argv]; 37 textdomain ("hello-objc-gnome"); 38 bindtextdomain ("hello-objc-gnome", LOCALEDIR); 39 40 /* Create the GUI elements. */ 41 42 window = [[Gtk_Window alloc] initWithWindowInfo: GTK_WINDOW_TOPLEVEL]; 43 [window set_title: "Hello example"]; 44 [window realize]; 45 [window signal_connect: "delete_event" signalFunc: quit_callback funcData: NULL]; 46 47 label1 = [[Gtk_Label alloc] initWithLabelInfo: _("Hello, world!")]; 48 49 label1aligned = [[Gtk_Alignment alloc] initWithAlignmentInfo: 0.0 : 0.5 : 0 : 0]; 50 [label1aligned add: label1]; 51 52 label2 = [[Gtk_Label alloc] initWithLabelInfo: g_strdup_printf (_("This program is running as process number %d."), getpid ())]; 53 54 label2aligned = [[Gtk_Alignment alloc] initWithAlignmentInfo: 0.0 : 0.5 : 0 : 0]; 55 [label2aligned add: label2]; 56 57 button = [Gtk_Button alloc]; 58 [button initWithLabel: "OK"]; 59 [button signal_connect: "clicked" signalFunc: quit_callback funcData: NULL]; 60 61 buttonbar = [Gtk_HButtonBox new]; 62 [buttonbar set_layout: GTK_BUTTONBOX_END]; 63 [buttonbar pack_start_defaults: button]; 64 65 panel = [[Gtk_VBox alloc] initWithVBoxInfo: FALSE : GNOME_PAD_SMALL]; 66 [panel pack_start_defaults: label1aligned]; 67 [panel pack_start_defaults: label2aligned]; 68 [panel pack_start_defaults: buttonbar]; 69 70 [window add: panel]; 71 72 /* Make the GUI elements visible. */ 73 74 [label1 show]; 75 [label1aligned show]; 76 [label2 show]; 77 [label2aligned show]; 78 [button show]; 79 [buttonbar show]; 80 [panel show]; 81 [window show]; 82 83 /* Start the event loop. */ 84 85 gtk_main (); 86 87 return 0; 88} 89