From 4e0cb334726e54c0c55caf3b6db1319b77e8960b Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Wed, 17 Mar 2004 13:59:42 +0000 Subject: [PATCH] Changes for help i18n in the core, the rest will take place in the help 2004-03-17 Sven Neumann 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. --- ChangeLog | 19 ++++++++++++++++ app/config/gimpguiconfig.c | 13 +++++++++++ app/config/gimpguiconfig.h | 1 + app/config/gimprc-blurbs.h | 5 +++++ app/core/gimp-utils.c | 41 +++++++++++++++++++++++++++++++++++ app/core/gimp-utils.h | 2 ++ app/core/gimpselection.c | 3 +-- app/text/gimptext.c | 44 +------------------------------------- app/widgets/gimphelp.c | 29 +++++++++++++++---------- 9 files changed, 101 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3ce9f3598..baee059b9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2004-03-17 Sven Neumann + + 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 * app/widgets/gimplayertreeview.c diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c index f3f0cba206..6f635186ae 100644 --- a/app/config/gimpguiconfig.c +++ b/app/config/gimpguiconfig.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; diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h index 2bd5deb46d..1aa39dbb4c 100644 --- a/app/config/gimpguiconfig.h +++ b/app/config/gimpguiconfig.h @@ -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; diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h index 5980d82ec8..1dcc5277e9 100644 --- a/app/config/gimprc-blurbs.h +++ b/app/config/gimprc-blurbs.h @@ -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.") diff --git a/app/core/gimp-utils.c b/app/core/gimp-utils.c index f5d96a92bc..124fb4f602 100644 --- a/app/core/gimp-utils.c +++ b/app/core/gimp-utils.c @@ -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; +} diff --git a/app/core/gimp-utils.h b/app/core/gimp-utils.h index d3042c32cb..2308688fda 100644 --- a/app/core/gimp-utils.h +++ b/app/core/gimp-utils.h @@ -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__ */ diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c index 247887ba51..fa68b5093d 100644 --- a/app/core/gimpselection.c +++ b/app/core/gimpselection.c @@ -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)); diff --git a/app/text/gimptext.c b/app/text/gimptext.c index 29efad1a8f..79e6824f3b 100644 --- a/app/text/gimptext.c +++ b/app/text/gimptext.c @@ -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; -} diff --git a/app/widgets/gimphelp.c b/app/widgets/gimphelp.c index da808d9e3e..6d2d2b15a4 100644 --- a/app/widgets/gimphelp.c +++ b/app/widgets/gimphelp.c @@ -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);