Commit 698a11c6 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

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().
parent c46265c8
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'.
......
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'.
......
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'.
......
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'.
......
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'.
......
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'.
......
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'.
......
......@@ -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;
}
......@@ -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
*/
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment