Hello, World: An Example of I18N Patch
- From: Li-Da Lho <ollie ms1 hinet net>
- To: gtk-list redhat com
- Subject: Hello, World: An Example of I18N Patch
- Date: Wed, 02 Jul 1997 17:30:56 +0800
Hello
I will present in this mail an example of the i18n patch. After
recompiling and reinstall the patched GTK lib, it is really trival to
display I18N text in a GTK application. Generally speaking, it takes
only a few steps:
1. Add a calle to gtk_setlocale() to initialize locale dependent
part of Xlib.
2. Add the fontset entry in the rc file to specify the fontset
used to display I18N text.
Here is a "hello world" example:
------------------------------ hello.c ---------------------------------
#include "gtk/gtk.h"
void
destroy (void)
{
gtk_exit (0);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *button;
/* set locale to current locale */
gtk_setlocale();
/* initialize the GTK widget */
gtk_init (&argc, &argv);
/* read the resource database file */
gtk_rc_parse ("hello.rc");
/* create toplevel window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (destroy), NULL);
gtk_window_set_title (GTK_WINDOW (window), "&L7')p");
gtk_container_border_width (GTK_CONTAINER (window), 10);
/* create a label widget to display I18N text */
button = gtk_button_new_with_label ("Hello World, &L7')p");
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
gtk_container_add (GTK_CONTAINER (window), button);
/* realize widgets */
gtk_widget_show (button);
gtk_widget_show (window);
/* enter events loop */
gtk_main ();
return 0;
}
-------------------------------- End of hello.c -----------------------
and its resource file
-------------------------- hello.rc -----------------------------------
style "label"
{
fontset = "-eten-mingti-medium-r-normal--*-240-*-*-*-*-big5-0, -adobe-helvetica-medium-r-normal--*-240-*-*-*-*-*-*"
fg[PRELIGHT] = { 0, 0, 0 }
bg[PRELIGHT] = { 0.75, 0, 1.0 }
fg[NORMAL] = { 1.0, 0, 0 }
fg[ACTIVE] = { 0, 1.00, 0 }
}
widget_class "*GtkLabel*" style "label"
--------------------------------- End of hello.rc ----------------------
and the result is :
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]