public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* guile-gtk-0.17 i18n
@ 2000-02-20 19:36 Hisao Suzuki
  2000-02-21 15:03 ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Hisao Suzuki @ 2000-02-20 19:36 UTC (permalink / raw)
  To: jarios; +Cc: guile-gtk

Hi,

Last Saturday, I installed guile-1.3.4 and guile-gtk-0.17 into
my Linux box, and noticed that the latter would not recognize
"ja" (i.e., Japanese) locale.  I used gtk-1.2.6.

Indeed you can display Japanese characters if you invoke
(gdk-set-locale) and (gtk-rc-parse "gtkrc.ja") within your
Scheme script, but you can never input Japanese characters via
X11's input method.

After all you have to invoke gtk_set_locale BEFORE gtk_init.  I
modified the initialization routine as follows.

----------------------------------------------------------------------
*** guile-gtk-0.17/guile-gtk.c~	Wed Sep 29 05:39:13 1999
--- guile-gtk-0.17/guile-gtk.c	Sat Feb 19 21:13:01 2000
***************
*** 2374,2381 ****
       been initialized when Gdk has.  That is not completely correct,
       but the best I can do. */
  
!   if (gdk_display == NULL)
      gtk_init (argcp, argvp);
    sgtk_init_substrate ();
    sgtk_inited = 1;
  }
--- 2374,2383 ----
       been initialized when Gdk has.  That is not completely correct,
       but the best I can do. */
  
!   if (gdk_display == NULL) {
!     gtk_set_locale ();
      gtk_init (argcp, argvp);
+   }
    sgtk_init_substrate ();
    sgtk_inited = 1;
  }
----------------------------------------------------------------------

Now you can both display and input Japanese characters on the
GTK widgets if you are in "ja" locale; no hacking on Scheme
scripts is required.  For example, the present "galway" as it is
seems Japanese-capable now!  Of course, if you are in "C"
locale, the modified guile-gtk will behave exactly the same as
the original one.

I'd hope the next guile-gtk will pick up this modification.
Note that the pygtk of Python, a counterpart of the guile-gtk of
Guile, is implemented as follows, and thus locale-sensible (see
gnome-python-1.0.50/pygtk/gtk.py).

| # this sets up i18n input stuff
| _gtk.gtk_set_locale()
| 
| # initialise GTK (only if it can find the display -- this avoids segfaults)
| if '--display' in sys.argv or os.environ.has_key('DISPLAY'):
| 	_gtk.gtk_init()
| else:
| 	print 'No display information -- gtk_init not called'

Regards,

Hisao Suzuki		suzuki611@okisoft.co.jp, suzuki@acm.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guile-gtk-0.17 i18n
  2000-02-20 19:36 guile-gtk-0.17 i18n Hisao Suzuki
@ 2000-02-21 15:03 ` Marius Vollmer
  2000-02-22  0:45   ` Hisao Suzuki
  0 siblings, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2000-02-21 15:03 UTC (permalink / raw)
  To: Hisao Suzuki; +Cc: jarios, guile-gtk

Hisao Suzuki <suzuki611@okisoft.co.jp> writes:

> After all you have to invoke gtk_set_locale BEFORE gtk_init.

I would like to have guile-gtk fully support the i18n features of
Gtk+, but I don't understand the issue at all.  Therefore, please
excuse the following questions:

Why do you have to call gtk_set_locale before gtk_init?  Is there a
good reason for this or can it be considered a bug in Gtk+?

What are the consequences of calling gtk_set_locale?  Are there good
reasons why anyone does _not_ want to call gtk_set_locale?  Why
doesn't gtk_init call gtk_set_locale itself?

- Marius

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guile-gtk-0.17 i18n
  2000-02-21 15:03 ` Marius Vollmer
@ 2000-02-22  0:45   ` Hisao Suzuki
  2000-02-22 11:45     ` Marius Vollmer
  0 siblings, 1 reply; 4+ messages in thread
From: Hisao Suzuki @ 2000-02-22  0:45 UTC (permalink / raw)
  To: mvo; +Cc: jarios, guile-gtk

Marius Vollmer <mvo@zagadka.ping.de> wrote:

> Why do you have to call gtk_set_locale before gtk_init?  Is there a
> good reason for this or can it be considered a bug in Gtk+?

gtk_init parses locale-specific gtkrc file(s) and opens a
locale-specific input method via XOpenIM(3x) of Xlib.  The
locale is supposed to have been already set.

gtk_set_locale invokes setlocale(3), and here is its man page:

| SETLOCALE(3)        Linux Programmer's Manual        SETLOCALE(3)
| 
| NAME
|        setlocale - set the current locale.
[snip]
|        On startup of the main program, the portable "C" locale is
|        selected as default.
[snip]

Thus you have to call gtk_set_locale before gtk_init.

> What are the consequences of calling gtk_set_locale?  Are there good
> reasons why anyone does _not_ want to call gtk_set_locale?  Why
> doesn't gtk_init call gtk_set_locale itself?

Besides setting the locale, gtk_set_locale sets gdk_use_mb, a
static gboolean variable which indicates whether multibyte
characters may be used or not, according to the locale.  In any
case, if you are in "C" locale, everything is the same as
default.

I don't know why gtk_init doesn't call gtk_set_locale.  Maybe it
is just a historical reason, or maybe some applications want to
run in "C" locale against any LANG environment variable value.

--
Hisao Suzuki		suzuki611@okisoft.co.jp, suzuki@acm.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guile-gtk-0.17 i18n
  2000-02-22  0:45   ` Hisao Suzuki
@ 2000-02-22 11:45     ` Marius Vollmer
  0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2000-02-22 11:45 UTC (permalink / raw)
  To: Hisao Suzuki; +Cc: guile-gtk

Hisao Suzuki <suzuki611@okisoft.co.jp> writes:

> Marius Vollmer <mvo@zagadka.ping.de> wrote:
> 
> > Why do you have to call gtk_set_locale before gtk_init?  Is there a
> > good reason for this or can it be considered a bug in Gtk+?
> 
> gtk_init parses locale-specific gtkrc file(s) and opens a
> locale-specific input method via XOpenIM(3x) of Xlib.  The
> locale is supposed to have been already set.
>
> [...]
>
> I don't know why gtk_init doesn't call gtk_set_locale.  Maybe it
> is just a historical reason, or maybe some applications want to
> run in "C" locale against any LANG environment variable value.

Aha, I see.  Basically, gtk_set_locale is a not a completely harmless
operation because it changes the environment of the whole process (via
setlocale) and not just for the Gtk+ library.  This should maybe not
be done unconditionally.

However, I now think that gtk_set_locale is an important part of
initializing Gtk+ and I think it is reasonable to just expect all
programs to work correctly when setlocale has been called.

So, your change goes in!

[ I'm sorry, I know that this change has been requested previously,
  and I turned it down then. ]

- Marius

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-02-22 11:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-02-20 19:36 guile-gtk-0.17 i18n Hisao Suzuki
2000-02-21 15:03 ` Marius Vollmer
2000-02-22  0:45   ` Hisao Suzuki
2000-02-22 11:45     ` Marius Vollmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).