diff options
author | Tor Lillqvist <tml@iki.fi> | 2003-09-20 23:52:16 +0000 |
---|---|---|
committer | Tor Lillqvist <tml@src.gnome.org> | 2003-09-20 23:52:16 +0000 |
commit | 71e847d11c4a94291b8068eeae924a3978cc91c5 (patch) | |
tree | 86bfedba20cc2c25fb4c34f0f83e9f9be6ce91b4 /gtk/gtkmain.c | |
parent | e95ad99afe722788319dd0fcb9f4e7ed9ab6e2e6 (diff) | |
download | gtk+-71e847d11c4a94291b8068eeae924a3978cc91c5.tar.gz |
Don't use zip -r on the etc directory, to avoid including editor backup
2003-09-20 Tor Lillqvist <tml@iki.fi>
* gtk-zip.sh.in: Don't use zip -r on the etc directory, to avoid
including editor backup files. List files we want explicitly.
* gtk/gtkmain.c (_gtk_get_lc_ctype): New function. On Unix, just
calls setlocale (LC_CTYPE, NULL). On Windows, looks for the
LC_ALL, LC_CTYPE and LANG environment variables, than calls
g_win32_getlocale().
(gtk_get_default_language): Code snippet moved to above function,
call it.
* gtk/gtkimmulticontext.c (gtk_im_multicontext_get_slave)
* gtk/gtkrc.c (gtk_rc_context_parse_file): Call
_gtk_get_lc_ctype() instead of setlocale().
Diffstat (limited to 'gtk/gtkmain.c')
-rw-r--r-- | gtk/gtkmain.c | 104 |
1 files changed, 70 insertions, 34 deletions
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 02e2361405..78dc4d1c02 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -989,8 +989,13 @@ gtk_exit (gint errorcode) * <literal>setlocale (LC_ALL, "")</literal> but also takes care of the * locale specific setup of the windowing system used by GDK. * - * Return value: a string corresponding to the locale set, as with the - * C library function <function>setlocale()</function>. + * Return: a string corresponding to the locale set, typically in the + * form lang_COUNTRY, where lang is an ISO-639 language code, and + * COUNTRY is an ISO-3166 country code. On Unix, this form matches the + * result of the <function>setlocale()</function>; it is also used on + * other machines, such as Windows, where the C library returns a + * different result. The string is owned by GTK+ and should not be + * modified or freed. **/ gchar * gtk_set_locale (void) @@ -999,55 +1004,86 @@ gtk_set_locale (void) } /** - * gtk_get_default_language: + * _gtk_get_lc_ctype: * - * Returns the #PangoLanguage for the default language currently in - * effect. (Note that this can change over the life of an - * application.) The default language is derived from the current - * locale. It determines, for example, whether GTK+ uses the - * right-to-left or left-to-right text direction. + * Return the Unix-style locale string for the language currently in + * effect. On Unix systems, this is the return value from + * <literal>setlocale(LC_CTYPE, NULL)</literal>, and the user can + * affect this through the environment variables LC_ALL, LC_CTYPE or + * LANG (checked in that order). The locale strings typically is in + * the form lang_COUNTRY, where lang is an ISO-639 language code, and + * COUNTRY is an ISO-3166 country code. For instance, sv_FI for + * Swedish as written in Finland or pt_BR for Portuguese as written in + * Brazil. * - * Return value: the default language as a #PangoLanguage, must not be - * freed - **/ -PangoLanguage * -gtk_get_default_language (void) + * On Windows, the C library doesn't use any such environment + * variables, and setting them won't affect the behaviour of functions + * like <function>ctime()</function>. The user sets the locale through + * the Regional Options in the Control Panel. The C library (in the + * <function>setlocale()</function> function) does not use country and + * language codes, but country and language names spelled out in + * English. However, this function does check the above environment + * variables, and does return a Unix-style locale string based on + * either said environment variables or the thread's current locale. + * + * Return value: a dynamically allocated string, free with g_free(). + */ + +gchar * +_gtk_get_lc_ctype (void) { - gchar *lang; - PangoLanguage *result; gchar *p; - + #ifdef G_OS_WIN32 /* Somebody might try to set the locale for this process using the * LANG or LC_ environment variables. The Microsoft C library * doesn't know anything about them. You set the locale in the * Control Panel. Setting these env vars won't have any affect on - * locale-dependent C library functions like ctime. But just for - * kicks, do obey LC_ALL, LANG and LC_CTYPE in GTK. (This also makes + * locale-dependent C library functions like ctime(). But just for + * kicks, do obey LC_ALL, LC_CTYPE and LANG in GTK. (This also makes * it easier to test GTK and Pango in various default languages, you * don't have to clickety-click in the Control Panel, you can simply * start the program with LC_ALL=something on the command line.) */ p = getenv ("LC_ALL"); if (p != NULL) - lang = g_strdup (p); - else - { - p = getenv ("LANG"); - if (p != NULL) - lang = g_strdup (p); - else - { - p = getenv ("LC_CTYPE"); - if (p != NULL) - lang = g_strdup (p); - else - lang = g_win32_getlocale (); - } - } + return g_strdup (p); + + p = getenv ("LC_CTYPE"); + if (p != NULL) + return g_strdup (p); + + p = getenv ("LANG"); + if (p != NULL) + return g_strdup (p); + + return g_win32_getlocale (); #else - lang = g_strdup (setlocale (LC_CTYPE, NULL)); + return g_strdup (setlocale (LC_CTYPE, NULL)); #endif +} + +/** + * gtk_get_default_language: + * + * Returns the #PangoLanguage for the default language currently in + * effect. (Note that this can change over the life of an + * application.) The default language is derived from the current + * locale. It determines, for example, whether GTK+ uses the + * right-to-left or left-to-right text direction. See + * _gtk_get_lc_ctype for notes on behaviour on Windows. + * + * Return value: the default language as a #PangoLanguage, must not be + * freed + **/ +PangoLanguage * +gtk_get_default_language (void) +{ + gchar *lang; + PangoLanguage *result; + gchar *p; + + lang = _gtk_get_lc_ctype (); p = strchr (lang, '.'); if (p) *p = '\0'; |