diff --git a/ChangeLog b/ChangeLog index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0b2686d650..ef1b14af98 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2001-06-06 Pablo Saratxaga + + * configure.in: Check for nl_langinfo (CODESET). Code taken from + glib 1.3 branch. + * gtk/gtkrc.c,gtk/gtkrc.*,gtk/Makefile.am: changed the algorithm + ussed to look for locale dependent rc files so it does a better job + finding them based on charset. + 2001-06-01 Alex Larsson * gdk/gdkevents.c (expose_predicate): diff --git a/configure.in b/configure.in index 688941ac0c..9c0c74752d 100644 --- a/configure.in +++ b/configure.in @@ -192,6 +192,15 @@ LIBS="$LIBS $INTLLIBS" gtklocaledir='${prefix}/${DATADIRNAME}/locale' AC_SUBST(gtklocaledir) +dnl Check for nl_langinfo and CODESET +AC_MSG_CHECKING([for nl_langinfo (CODESET)]) +AC_TRY_COMPILE([#include ], + [char *codeset = nl_langinfo (CODESET);], + AC_DEFINE(HAVE_CODESET,1,[Have nl_langinfo (CODESET)]) + have_codeset=yes, + have_codeset=no) +AC_MSG_RESULT($have_codeset) + dnl The DU4 header files don't provide library prototypes unless dnl -std1 is given to the native cc. AC_MSG_CHECKING([for extra flags to get ANSI library prototypes]) diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8c65fa52b6..238e270785 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -374,9 +374,11 @@ $(srcdir)/gtktypebuiltins_evals.c: @REBUILD@ makeenums.pl $(gtk_public_h_sources gtkconfdir = $(sysconfdir)/gtk -gtkconf_DATA = gtkrc.az gtkrc.el gtkrc.eo gtkrc.he gtkrc.hy gtkrc.ja \ - gtkrc.ko gtkrc.ru gtkrc.tr gtkrc.th gtkrc.uk gtkrc.iso-8859-2 \ - gtkrc.iso-8859-5 gtkrc.iso-8859-13 gtkrc.iso-8859-14 \ +gtkconf_DATA = gtkrc.az gtkrc.he gtkrc.hy gtkrc.ja \ + gtkrc.ko gtkrc.ru gtkrc.th gtkrc.uk \ + gtkrc.utf-8 gtkrc.iso-8859-2 \ + gtkrc.iso-8859-3 gtkrc.iso-8859-5 gtkrc.iso-8859-7 \ + gtkrc.iso-8859-9 gtkrc.iso-8859-13 gtkrc.iso-8859-14 \ gtkrc.iso-8859-15 gtkrc.zh_CN gtkrc.zh_TW.big5 \ gtkrc.ka_GE.georgianacademy gtkrc.ka_GE.georgianps \ gtkrc.vi_VN.tcvn gtkrc.vi_VN.viscii gtkrc.cp1251 gtkrc.cp1255 diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 9db6edf492..9980dd4a5c 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -33,6 +33,9 @@ #include #include #include +#ifdef HAVE_CODESET +#include +#endif #include "gtkrc.h" #include "gtkbindings.h" @@ -440,7 +443,7 @@ _gtk_normalize_codeset (const char *codeset, int name_len) void gtk_rc_init (void) { - static gchar *locale_suffixes[3]; + static gchar *locale_suffixes[8]; static gint n_locale_suffixes = 0; gint i, j; @@ -449,8 +452,6 @@ gtk_rc_init (void) if (!initted) { - gint length; - char *locale = setlocale (LC_CTYPE, NULL); char *p; @@ -470,38 +471,91 @@ gtk_rc_init (void) * We normalize the charset into a standard form, * which has all '-' and '_' characters removed, * and is lowercase. + * + * the search is done in that order: + * gtkrc.ll_cc.lowercasecodeset + * gtkrc.ll_cc.normalizedcodeset + * gtkrc.ll.lowercasecodeset + * gtkrc.ll.normalizedcodeset + * gtkrc.lowercasecodeset + * gtkrc.normalizedcodeset + * gtkrc.ll_cc + * gtkrc.ll + * */ - gchar *normalized_locale; + char *codeset = NULL; + char *normalized_codeset = NULL; + char *cc = NULL; + char *ll; + char *tmp = NULL; p = strchr (locale, '@'); - length = p ? (p -locale) : strlen (locale); + if (p) + *p = '\0'; +#ifdef HAVE_CODESET + codeset = nl_langinfo (CODESET); +#endif p = strchr (locale, '.'); + if ((codeset==NULL) && (p)) + codeset = p+1; if (p) - { - gchar *tmp1 = g_strndup (locale, p - locale + 1); - gchar *tmp2 = _gtk_normalize_codeset (p + 1, length - (p - locale + 1)); - - normalized_locale = g_strconcat (tmp1, tmp2, NULL); - g_free (tmp1); - g_free (tmp2); - - locale_suffixes[n_locale_suffixes++] = g_strdup (normalized_locale); - length = p - locale; - } - else - normalized_locale = g_strndup (locale, length); + *p = '\0'; - p = strchr (normalized_locale, '_'); - if (p) + if (codeset) { - locale_suffixes[n_locale_suffixes++] = g_strndup (normalized_locale, length); - length = p - normalized_locale; + /* if codeset is the result of nl_langinfo() it is + * read-only so we need to copy it to a rw place */ + tmp = g_strdup(codeset); + p = tmp; + + while (*p) + { + /* tolower not used, because some locales are not + * compatible with C locale in lowercasing ascii */ + if (*p >= 'A' && *p <= 'Z') + *p = (*p)-'A'+'a'; + p++; + } + codeset = tmp; + normalized_codeset = + _gtk_normalize_codeset(codeset, strlen(codeset)); + if (strcmp(normalized_codeset,codeset) == 0) + normalized_codeset = NULL; } - - locale_suffixes[n_locale_suffixes++] = g_strndup (normalized_locale, length); - g_free (normalized_locale); + p = strchr (locale, '_'); + if (p) { + cc = p+1; + *p = '\0'; + } + + ll = locale; + + if (cc && codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( g_strconcat(ll,"_",cc,".",codeset,NULL)); + if (cc && normalized_codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( g_strconcat(ll,"_",cc,".",normalized_codeset,NULL)); + if (codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( g_strconcat(ll,".",codeset,NULL)); + if (normalized_codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( g_strconcat(ll,".",normalized_codeset,NULL)); + if (codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( codeset ); + if (normalized_codeset) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( normalized_codeset ); + if (cc) + locale_suffixes[n_locale_suffixes++] = + g_strdup ( g_strconcat(ll,"_",cc,NULL)); + locale_suffixes[n_locale_suffixes++] = g_strdup ( ll ); + + if (tmp) g_free (tmp); } } diff --git a/gtk/gtkrc.eo b/gtk/gtkrc.iso-8859-3 similarity index 100% rename from gtk/gtkrc.eo rename to gtk/gtkrc.iso-8859-3 diff --git a/gtk/gtkrc.el b/gtk/gtkrc.iso-8859-7 similarity index 100% rename from gtk/gtkrc.el rename to gtk/gtkrc.iso-8859-7 diff --git a/gtk/gtkrc.tr b/gtk/gtkrc.iso-8859-9 similarity index 100% rename from gtk/gtkrc.tr rename to gtk/gtkrc.iso-8859-9 diff --git a/gtk/gtkrc.utf-8 b/gtk/gtkrc.utf-8 new file mode 100644 index 0000000000..6e4815ec87 --- /dev/null +++ b/gtk/gtkrc.utf-8 @@ -0,0 +1,9 @@ +style "default-text" { + fontset = "-b&h-lucida sans-medium-r-normal--14-*-*-*-*-*-iso10646-1,\ + -*-arial-medium-r-normal--14-*-*-*-*-*-iso10646-1,\ + -*-r-*-iso10646-1,*" + +} + +class "GtkWidget" style "default-text" +