Commit 4e0cb334 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

Changes for help i18n in the core, the rest will take place in the help

2004-03-17  Sven Neumann  <sven@gimp.org>

	Changes for help i18n in the core, the rest will take place in the
	help plug-in:

	* app/text/gimptext.[ch]: removed gimp_text_get_default_language()

	* app/core/gimp-utils.[ch]: ... and added it here as
	gimp_get_default_language().

	* app/config/gimprc-blurbs.h
	* app/config/gimpdisplayconfig.[ch]: added property "help-locales".

	* app/widgets/gimphelp.c: use the new property and pass it to the
	help plug-in.

	* app/core/gimpselection.c (gimp_selection_invalidate_boundary):
	removed unused variable.
parent 021cc537
2004-03-17 Sven Neumann <sven@gimp.org>
Changes for help i18n in the core, the rest will take place in the
help plug-in:
* app/text/gimptext.[ch]: removed gimp_text_get_default_language()
* app/core/gimp-utils.[ch]: ... and added it here as
gimp_get_default_language().
* app/config/gimprc-blurbs.h
* app/config/gimpdisplayconfig.[ch]: added property "help-locales".
* app/widgets/gimphelp.c: use the new property and pass it to the
help plug-in.
* app/core/gimpselection.c (gimp_selection_invalidate_boundary):
removed unused variable.
2004-03-17 Simon Budig <simon@gimp.org>
* app/widgets/gimplayertreeview.c
......@@ -82,6 +82,7 @@ enum
PROP_THEME_PATH,
PROP_THEME,
PROP_USE_HELP,
PROP_HELP_LOCALES,
PROP_HELP_BROWSER,
PROP_WEB_BROWSER,
PROP_TOOLBOX_WINDOW_HINT,
......@@ -218,6 +219,10 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
"use-help", USE_HELP_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_HELP_LOCALES,
"help-locales", HELP_LOCALES_BLURB,
NULL,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_HELP_BROWSER,
"help-browser", HELP_BROWSER_BLURB,
GIMP_TYPE_HELP_BROWSER_TYPE,
......@@ -249,6 +254,7 @@ gimp_gui_config_finalize (GObject *object)
g_free (gui_config->theme_path);
g_free (gui_config->theme);
g_free (gui_config->help_locales);
g_free (gui_config->web_browser);
G_OBJECT_CLASS (parent_class)->finalize (object);
......@@ -326,6 +332,10 @@ gimp_gui_config_set_property (GObject *object,
case PROP_USE_HELP:
gui_config->use_help = g_value_get_boolean (value);
break;
case PROP_HELP_LOCALES:
g_free (gui_config->help_locales);
gui_config->help_locales = g_value_dup_string (value);
break;
case PROP_HELP_BROWSER:
gui_config->help_browser = g_value_get_enum (value);
break;
......@@ -416,6 +426,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_USE_HELP:
g_value_set_boolean (value, gui_config->use_help);
break;
case PROP_HELP_LOCALES:
g_value_set_string (value, gui_config->help_locales);
break;
case PROP_HELP_BROWSER:
g_value_set_enum (value, gui_config->help_browser);
break;
......
......@@ -60,6 +60,7 @@ struct _GimpGuiConfig
gchar *theme_path;
gchar *theme;
gboolean use_help;
gchar *help_locales;
GimpHelpBrowserType help_browser;
gchar *web_browser;
GimpWindowHint toolbox_window_hint;
......
......@@ -142,6 +142,11 @@ N_("When enabled, the selected pattern will be used for all tools.")
#define HELP_BROWSER_BLURB \
N_("Sets the browser used by the help system.")
#define HELP_LOCALES_BLURB \
"Specifies the language preferences used by the help system. This is a" \
"colon-separated list of language identifiers with decreasing priority. " \
"If empty, the language is taken from the user's locale setting."
#define IMAGE_STATUS_FORMAT_BLURB \
N_("Sets the text to appear in image window status bars.")
......
......@@ -93,3 +93,44 @@ gimp_g_list_get_memsize (GList *list,
{
return g_list_length (list) * (data_size + sizeof (GList));
}
/*
* basically copied from gtk_get_default_language()
*/
gchar *
gimp_get_default_language (void)
{
gchar *lang;
gchar *p;
#ifdef G_OS_WIN32
p = getenv ("LC_ALL");
if (p != NULL)
lang = g_strdup (p);
else
{
p = getenv ("LANG");
if (p != NULL)
lang = g_strdup (p);
else
{
p = getenv ("LC_CTYPE");
if (p != NULL)
lang = g_strdup (p);
else
lang = g_win32_getlocale ();
}
}
#else
lang = g_strdup (setlocale (LC_CTYPE, NULL));
#endif
p = strchr (lang, '.');
if (p)
*p = '\0';
p = strchr (lang, '@');
if (p)
*p = '\0';
return lang;
}
......@@ -40,5 +40,7 @@ gint64 gimp_g_slist_get_memsize (GSList *slist,
gint64 gimp_g_list_get_memsize (GList *list,
gint64 data_size);
gchar * gimp_get_default_language (void);
#endif /* __APP_GIMP_UTILS_H__ */
......@@ -324,8 +324,7 @@ gimp_selection_stroke (GimpItem *item,
static void
gimp_selection_invalidate_boundary (GimpDrawable *drawable)
{
GimpChannel *selection = GIMP_CHANNEL (drawable);
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (drawable));
GimpLayer *layer;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......
......@@ -83,7 +83,6 @@ static void gimp_text_set_property (GObject *object,
GParamSpec *pspec);
static gint64 gimp_text_get_memsize (GimpObject *object,
gint64 *gui_size);
static gchar * gimp_text_get_default_language (void);
static GimpObjectClass *parent_class = NULL;
......@@ -149,7 +148,7 @@ gimp_text_class_init (GimpTextClass *klass)
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
gimp_matrix2_identity (&identity);
language = gimp_text_get_default_language ();
language = gimp_get_default_language ();
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_TEXT,
"text", NULL,
......@@ -487,44 +486,3 @@ gimp_text_get_memsize (GimpObject *object,
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
gui_size);
}
/*
* basically copied from gtk_get_default_language()
*/
static gchar *
gimp_text_get_default_language (void)
{
gchar *lang;
gchar *p;
#ifdef G_OS_WIN32
p = getenv ("LC_ALL");
if (p != NULL)
lang = g_strdup (p);
else
{
p = getenv ("LANG");
if (p != NULL)
lang = g_strdup (p);
else
{
p = getenv ("LC_CTYPE");
if (p != NULL)
lang = g_strdup (p);
else
lang = g_win32_getlocale ();
}
}
#else
lang = g_strdup (setlocale (LC_CTYPE, NULL));
#endif
p = strchr (lang, '.');
if (p)
*p = '\0';
p = strchr (lang, '@');
if (p)
*p = '\0';
return lang;
}
......@@ -59,7 +59,7 @@ struct _GimpIdleHelp
{
Gimp *gimp;
gchar *help_domain;
gchar *help_locale;
gchar *help_locales;
gchar *help_id;
};
......@@ -71,7 +71,7 @@ static gboolean gimp_help_internal (Gimp *gimp);
static void gimp_help_call (Gimp *gimp,
const gchar *procedure,
const gchar *help_domain,
const gchar *help_locale,
const gchar *help_locales,
const gchar *help_id);
......@@ -82,9 +82,13 @@ gimp_help (Gimp *gimp,
const gchar *help_domain,
const gchar *help_id)
{
GimpGuiConfig *config;
g_return_if_fail (GIMP_IS_GIMP (gimp));
if (GIMP_GUI_CONFIG (gimp->config)->use_help)
config = GIMP_GUI_CONFIG (gimp->config);
if (config->use_help)
{
GimpIdleHelp *idle_help = g_new0 (GimpIdleHelp, 1);
......@@ -93,7 +97,10 @@ gimp_help (Gimp *gimp,
if (help_domain && strlen (help_domain))
idle_help->help_domain = g_strdup (help_domain);
idle_help->help_locale = g_strdup ("C");
if (config->help_locales)
idle_help->help_locales = g_strdup (config->help_locales);
else
idle_help->help_locales = gimp_get_default_language ();
if (help_id && strlen (help_id))
idle_help->help_id = g_strdup (help_id);
......@@ -136,11 +143,11 @@ gimp_idle_help (gpointer data)
gimp_help_call (idle_help->gimp,
procedure,
idle_help->help_domain,
idle_help->help_locale,
idle_help->help_locales,
idle_help->help_id);
g_free (idle_help->help_domain);
g_free (idle_help->help_locale);
g_free (idle_help->help_locales);
g_free (idle_help->help_id);
g_free (idle_help);
......@@ -248,7 +255,7 @@ static void
gimp_help_call (Gimp *gimp,
const gchar *procedure,
const gchar *help_domain,
const gchar *help_locale,
const gchar *help_locales,
const gchar *help_id)
{
ProcRecord *proc_rec;
......@@ -305,9 +312,9 @@ gimp_help_call (Gimp *gimp,
#ifdef DEBUG_HELP
g_printerr ("Calling help via %s: %s %s %s\n",
procedure,
help_domain ? help_domain : NULL,
help_locale ? help_locale : NULL,
help_id ? help_id : NULL);
help_domain ? help_domain : NULL,
help_locales ? help_locales : NULL,
help_id ? help_id : NULL);
#endif
return_vals =
......@@ -316,7 +323,7 @@ gimp_help_call (Gimp *gimp,
&n_return_vals,
GIMP_PDB_STRING, procedure,
GIMP_PDB_STRING, help_domain,
GIMP_PDB_STRING, help_locale,
GIMP_PDB_STRING, help_locales,
GIMP_PDB_STRING, help_id,
GIMP_PDB_END);
......
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