summaryrefslogtreecommitdiff
path: root/gtk/gtkrc.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1998-12-14 23:26:12 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-12-14 23:26:12 +0000
commit698a11c6069a3700e9123164b05c1dc592efeff7 (patch)
treeecf1fe8cfd28598b2556d256efe9ea7ada0f5b9c /gtk/gtkrc.c
parentc46265c82c3602a55e564749f9e15b3cce1b840e (diff)
downloadgtk+-698a11c6069a3700e9123164b05c1dc592efeff7.tar.gz
Append locale-specific suffixes to default rc file names, and look these
Mon Dec 14 16:10:05 1998 Owen Taylor <otaylor@redhat.com> * gtk/gtkrc.c (gtk_rc_init): Append locale-specific suffixes to default rc file names, and look these up in addition to the base filename, to facilitate having the correct fontset per-locale. move $(sysconfdir)/gtkrc to $(sysconfdir)/gtk/gtkrc * gtk/gtkitemfactory.[ch] (gtk_item_factory_set_translate_func): New function to set a function to translate menu paths. * gtk/gtkrc.c (gtk_rc_add_initial_default_files): Free results of g_strsplit().
Diffstat (limited to 'gtk/gtkrc.c')
-rw-r--r--gtk/gtkrc.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 91e5bd06ce..1b33c235e5 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -16,6 +16,7 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+#include <X11/Xlocale.h> /* so we get the right setlocale */
#include <ctype.h>
#include <unistd.h>
#include <sys/stat.h>
@@ -24,6 +25,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+
#include "gtkrc.h"
#include "gtkbindings.h"
#include "gtkthemes.h"
@@ -333,11 +335,12 @@ gtk_rc_add_initial_default_files (void)
gtk_rc_add_default_file (files[i]);
i++;
}
+ g_strfreev (files);
}
else
{
- str = g_malloc (strlen(GTK_SYSCONFDIR) + strlen("/gtkrc") + 1);
- sprintf (str, "%s%s", GTK_SYSCONFDIR, "/gtkrc");
+ str = g_malloc (strlen(GTK_SYSCONFDIR) + strlen("/gtk/gtkrc") + 1);
+ sprintf (str, "%s%s", GTK_SYSCONFDIR, "/gtk/gtkrc");
gtk_rc_add_default_file (str);
var = g_get_home_dir ();
@@ -398,7 +401,12 @@ gtk_rc_get_default_files (void)
void
gtk_rc_init (void)
{
- guint i;
+ gchar *locale_suffixes[3];
+ gint n_locale_suffixes = 0;
+ gint i, j;
+ char *locale = setlocale (LC_MESSAGES, NULL);
+ guint length;
+ char *p;
rc_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_style_hash,
(GCompareFunc) gtk_rc_style_compare);
@@ -409,13 +417,50 @@ gtk_rc_init (void)
gtk_rc_add_initial_default_files ();
+ if (strcmp (locale, "C") && strcmp (locale, "POSIX"))
+ {
+ /* Determine locale-specific suffixes for RC files
+ */
+ p = strchr (locale, '@');
+ length = p ? (p -locale) : strlen (locale);
+
+ p = strchr (locale, '.');
+ if (p)
+ {
+ locale_suffixes[n_locale_suffixes++] = g_strndup (locale, length);
+ length = p - locale;
+ }
+
+ p = strchr (locale, '_');
+ if (p)
+ {
+ locale_suffixes[n_locale_suffixes++] = g_strndup (locale, length);
+ length = p - locale;
+ }
+
+ locale_suffixes[n_locale_suffixes++] = g_strndup (locale, length);
+ }
+
i = 0;
while (gtk_rc_default_files[i] != NULL)
{
+ /* Try to find a locale specific RC file corresponding to
+ * to parse before the default file.
+ */
+ for (j=n_locale_suffixes-1; j>=0; j--)
+ {
+ struct stat statbuf;
+ gchar *name = g_strconcat (gtk_rc_default_files[i],
+ ".",
+ locale_suffixes[j],
+ NULL);
+ gtk_rc_parse (name);
+ }
+
gtk_rc_parse (gtk_rc_default_files[i]);
i++;
}
-}
+ }
void
gtk_rc_parse_string (const gchar *rc_string)