summaryrefslogtreecommitdiff
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
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().
-rw-r--r--ChangeLog15
-rw-r--r--ChangeLog.pre-2-015
-rw-r--r--ChangeLog.pre-2-1015
-rw-r--r--ChangeLog.pre-2-215
-rw-r--r--ChangeLog.pre-2-415
-rw-r--r--ChangeLog.pre-2-615
-rw-r--r--ChangeLog.pre-2-815
-rw-r--r--gtk/gtkitemfactory.c38
-rw-r--r--gtk/gtkitemfactory.h10
-rw-r--r--gtk/gtkrc.c53
10 files changed, 196 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index b8c05509a6..cd3e02de72 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,18 @@
+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().
+
1998-12-14 Nuno Ferreira <nmrf@rnl.ist.utl.pt>
* configure.in (ALL_LINGUAS): Added 'pt'.
diff --git a/gtk/gtkitemfactory.c b/gtk/gtkitemfactory.c
index 009ec5d3b3..72f5b859d4 100644
--- a/gtk/gtkitemfactory.c
+++ b/gtk/gtkitemfactory.c
@@ -684,6 +684,9 @@ gtk_item_factory_finalize (GtkObject *object)
g_free (ifactory->path);
g_assert (ifactory->widget == NULL);
+ if (ifactory->translate_data && ifactory->translate_notify)
+ ifactory->translate_notify (ifactory->translate_data);
+
parent_class->finalize (object);
}
@@ -893,11 +896,13 @@ gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory,
}
static gboolean
-gtk_item_factory_parse_path (gchar *str,
- gchar **path,
- gchar **parent_path,
- gchar **item)
+gtk_item_factory_parse_path (GtkItemFactory *ifactory,
+ gchar *str,
+ gchar **path,
+ gchar **parent_path,
+ gchar **item)
{
+ gchar *translation;
gchar *p, *q;
*path = g_strdup (str);
@@ -922,7 +927,12 @@ gtk_item_factory_parse_path (gchar *str,
}
*p = 0;
- p = strrchr (str, '/');
+ if (ifactory->translate_func)
+ translation = ifactory->translate_func (str, ifactory->translate_data);
+ else
+ translation = str;
+
+ p = strrchr (translation, '/');
p++;
*item = g_strdup (p);
@@ -1006,7 +1016,7 @@ gtk_item_factory_create_item (GtkItemFactory *ifactory,
}
}
- if (!gtk_item_factory_parse_path (entry->path,
+ if (!gtk_item_factory_parse_path (ifactory, entry->path,
&path, &parent_path, &name))
return;
@@ -1599,3 +1609,19 @@ gtk_item_factory_parse_rc (const gchar *file_name)
close (fd);
}
+
+void
+gtk_item_factory_set_translate_func (GtkItemFactory *ifactory,
+ GtkTranslateFunc func,
+ gpointer data,
+ GtkDestroyNotify notify)
+{
+ g_return_if_fail (ifactory != NULL);
+
+ if (ifactory->translate_data && ifactory->translate_notify)
+ ifactory->translate_notify (ifactory->translate_data);
+
+ ifactory->translate_func = func;
+ ifactory->translate_data = data;
+ ifactory->translate_notify = notify;
+}
diff --git a/gtk/gtkitemfactory.h b/gtk/gtkitemfactory.h
index 1f93e1cbd5..4110cc6f5c 100644
--- a/gtk/gtkitemfactory.h
+++ b/gtk/gtkitemfactory.h
@@ -35,6 +35,8 @@ extern "C" {
typedef void (*GtkPrintFunc) (gpointer func_data,
gchar *str);
+typedef gchar * (*GtkTranslateFunc) (const gchar *path,
+ gpointer func_data);
typedef void (*GtkItemFactoryCallback) ();
typedef void (*GtkItemFactoryCallback1) (gpointer callback_data,
guint callback_action,
@@ -63,6 +65,10 @@ struct _GtkItemFactory
GtkAccelGroup *accel_group;
GtkWidget *widget;
GSList *widgets_by_action;
+
+ GtkTranslateFunc translate_func;
+ gpointer translate_data;
+ GtkDestroyNotify translate_notify;
};
struct _GtkItemFactoryClass
@@ -185,6 +191,10 @@ void gtk_item_factory_popup_with_data(GtkItemFactory *ifactory,
guint32 time);
gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory);
gpointer gtk_item_factory_popup_data_from_widget (GtkWidget *widget);
+void gtk_item_factory_set_translate_func (GtkItemFactory *ifactory,
+ GtkTranslateFunc func,
+ gpointer data,
+ GtkDestroyNotify notify);
/* Compatibility functions for deprecated GtkMenuFactory code
*/
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)