gtkrc.$localevalue patch
- From: Changwoo Ryu <cwryu adam kaist ac kr>
- To: gnome-list gnome org
- Subject: gtkrc.$localevalue patch
- Date: 04 Jan 1999 10:57:31 +0900
Hello, gnome hackers.
The patch below is the implementation of Owen Taylor's proposal, for
gnome library.
For example, my usual $LANG value is `ko_KR.euc'. With this patch
applied, all gnome programs in my system will try to read gtkrc files
in this order:
$gnomedatadir/gtkrc.ko_KR.euc
$gnomedatadir/gtkrc.ko_KR
$gnomedatadir/gtkrc.ko
$gnomedatadir/gtkrc
$gnomedatadir/$apprc.ko_KR.euc
$gnomedatadir/$apprc.ko_KR
$gnomedatadir/$apprc.ko
$gnomedatadir/$apprc
~/.gnome/gtkrc.ko_KR.euc
<...>
There has been much discussion about this... The advantage is, that
we can distribute gtkrc files needed by some locales.
Please comment.. Is this patch OK?
--- gnome-init.c 1998/12/30 18:53:45 1.64
+++ gnome-init.c 1999/01/04 01:34:55
@@ -40,6 +40,7 @@
extern void gnome_type_init (void);
+static void gtk_rc_parse_by_locale (const gchar *filename);
static void gnome_rc_parse(gchar *command);
#ifdef USE_SEGV_HANDLE
static void gnome_segv_handle(int signum);
@@ -442,30 +443,30 @@
/* <gnomedatadir>/gtkrc */
- file = gnome_datadir_file("gtkrc");
+ file = gnome_unconditional_datadir_file("gtkrc");
if (file){
- gtk_rc_parse (file);
+ gtk_rc_parse_by_locale (file);
g_free (file);
}
/* <gnomedatadir>/<progname> */
- file = gnome_datadir_file(apprc);
+ file = gnome_unconditional_datadir_file(apprc);
if (file){
- gtk_rc_parse (file);
+ gtk_rc_parse_by_locale (file);
g_free (file);
}
/* ~/.gnome/gtkrc */
- file = gnome_util_home_file("gtkrc");
+ file = gnome_unconditional_util_home_file("gtkrc");
if (file){
- gtk_rc_parse (file);
+ gtk_rc_parse_by_locale (file);
g_free (file);
}
/* ~/.gnome/<progname> */
- file = gnome_util_home_file(apprc);
+ file = gnome_unconditional_util_home_file(apprc);
if (file){
- gtk_rc_parse (file);
+ gtk_rc_parse_by_locale (file);
g_free (file);
}
@@ -575,3 +576,88 @@
#endif
return TRUE;
}
+
+
+static void
+gtk_rc_parse_by_locale (const gchar *filename)
+{
+ GList *language_list;
+
+ language_list = gnome_i18n_get_language_list ("LC_CTYPE");
+ while (language_list)
+ {
+ const char *lang= language_list->data;
+
+
+ if (strcmp (lang, "C") == 0)
+ {
+ if (g_file_exists (filename))
+ {
+ gtk_rc_parse (filename);
+ return;
+ }
+ }
+ else
+ {
+ gchar *locale_filename;
+
+ locale_filename = g_strconcat (filename, ".", lang, NULL);
+ if (g_file_exists (locale_filename))
+ {
+ gtk_rc_parse (locale_filename);
+ g_free (locale_filename);
+ return;
+ }
+ else
+ {
+ /* Sometimes locale variable looks like ko_KR.EUC@verbose. In
+ this case we follow this order.
+
+ 1. ko_KR.euc@verbose
+ 2. ko_KR.euc
+ 3. ko_KR
+ 4. ko
+ */
+ char *ptr;
+
+ if (g_file_exists (locale_filename))
+ {
+ gtk_rc_parse (locale_filename);
+ g_free (locale_filename);
+ return;
+ }
+
+ ptr = locale_filename + strlen (locale_filename) - 1;
+ for (;;)
+ {
+ while (ptr > (locale_filename + strlen (filename)))
+ {
+ if (*ptr == '.' || *ptr == '_' || *ptr == '@')
+ {
+ *ptr = '\0';
+ ptr --;
+ break;
+ }
+ ptr --;
+ }
+ if (ptr <= (locale_filename + strlen (filename)))
+ break;
+
+ if (g_file_exists (locale_filename))
+ {
+ gtk_rc_parse (locale_filename);
+ g_free (locale_filename);
+ return;
+ }
+ }
+ }
+ g_free (locale_filename);
+ }
+ language_list = language_list->next;
+ }
+
+ /* fallback to the default */
+ gtk_rc_parse (filename);
+}
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]