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