From d76e3d552e4b991cd3739cf3496884e66d77548e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jun 2008 23:40:35 +0000 Subject: =?UTF-8?q?Bug=20503071=20=E2=80=93=20Application=20direction=20ch?= =?UTF-8?q?anges=20to=20right=20to=20left=20even=20if?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-06-11 Behdad Esfahbod Bug 503071 – Application direction changes to right to left even if theres no translation * configure.in: Bump glib requirement. * gtk/gtkaccellabel.c (_gtk_accel_label_class_get_accelerator_label): * gtk/gtkactiongroup.c (dgettext_swapped): * gtk/gtkbuilder.c (gtk_builder_class_init): * gtk/gtkbuilderparser.c (_dpgettext), (_gtk_builder_parser_translate): * gtk/gtkfilechooserdefault.c (list_size_data_func): * gtk/gtkimmulticontext.c (gtk_im_multicontext_append_menuitems): * gtk/gtkintl.h: * gtk/gtkmain.c (setlocale_initialization), (do_pre_parse_initialization), (gettext_initialization): * gtk/gtkstock.c (gtk_stock_lookup), (sgettext_swapped): Use g_dgettext() and g_dngettext(). svn path=/trunk/; revision=20358 --- ChangeLog | 21 +++++++++++++++++++++ configure.in | 2 +- gtk/gtkaccellabel.c | 2 +- gtk/gtkactiongroup.c | 8 ++++---- gtk/gtkbuilder.c | 2 +- gtk/gtkbuilderparser.c | 14 +++++++------- gtk/gtkfilechooserdefault.c | 2 +- gtk/gtkimmulticontext.c | 2 +- gtk/gtkintl.h | 2 +- gtk/gtkmain.c | 38 +++++++++++++++++++++++++------------- gtk/gtkstock.c | 6 +++--- 11 files changed, 66 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90ae92404b..5f59525026 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-06-11 Behdad Esfahbod + + Bug 503071 – Application direction changes to right to left even if + theres no translation + + * configure.in: Bump glib requirement. + + * gtk/gtkaccellabel.c + (_gtk_accel_label_class_get_accelerator_label): + * gtk/gtkactiongroup.c (dgettext_swapped): + * gtk/gtkbuilder.c (gtk_builder_class_init): + * gtk/gtkbuilderparser.c (_dpgettext), + (_gtk_builder_parser_translate): + * gtk/gtkfilechooserdefault.c (list_size_data_func): + * gtk/gtkimmulticontext.c (gtk_im_multicontext_append_menuitems): + * gtk/gtkintl.h: + * gtk/gtkmain.c (setlocale_initialization), + (do_pre_parse_initialization), (gettext_initialization): + * gtk/gtkstock.c (gtk_stock_lookup), (sgettext_swapped): + Use g_dgettext() and g_dngettext(). + 2008-06-11 Matthias Clasen * docs/RELEASE-HOWTO: Updates diff --git a/configure.in b/configure.in index bbd3b17cb6..a72e7108f0 100644 --- a/configure.in +++ b/configure.in @@ -31,7 +31,7 @@ m4_define([gtk_api_version], [2.0]) m4_define([gtk_binary_version], [2.10.0]) # required versions of other packages -m4_define([glib_required_version], [2.15.0]) +m4_define([glib_required_version], [2.17.1]) m4_define([pango_required_version], [1.20]) m4_define([atk_required_version], [1.13.0]) m4_define([cairo_required_version], [1.6]) diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c index e31223cebb..a099d35453 100644 --- a/gtk/gtkaccellabel.c +++ b/gtk/gtkaccellabel.c @@ -750,7 +750,7 @@ _gtk_accel_label_class_get_accelerator_label (GtkAccelLabelClass *klass, strcpy (msg, "keyboard label|"); g_strlcat (msg, tmp, 128); - str = dgettext (GETTEXT_PACKAGE, msg); + str = _(msg); if (str == msg) { g_string_append (gstring, tmp); diff --git a/gtk/gtkactiongroup.c b/gtk/gtkactiongroup.c index 3a86464950..6bba6e75b4 100644 --- a/gtk/gtkactiongroup.c +++ b/gtk/gtkactiongroup.c @@ -1278,9 +1278,9 @@ static gchar * dgettext_swapped (const gchar *msgid, const gchar *domainname) { - /* Pass through dgettext if and only if msgid is nonempty. */ + /* Pass through g_dgettext if and only if msgid is nonempty. */ if (msgid && *msgid) - return dgettext (domainname, msgid); + return (gchar*) g_dgettext (domainname, msgid); else return (gchar*) msgid; } @@ -1288,9 +1288,9 @@ dgettext_swapped (const gchar *msgid, /** * gtk_action_group_set_translation_domain: * @action_group: a #GtkActionGroup - * @domain: the translation domain to use for dgettext() calls + * @domain: the translation domain to use for g_dgettext() calls * - * Sets the translation domain and uses dgettext() for translating the + * Sets the translation domain and uses g_dgettext() for translating the * @label and @tooltip of #GtkActionEntrys added by * gtk_action_group_add_actions(). * diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 77f416447d..2ded2b17cf 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -86,7 +86,7 @@ gtk_builder_class_init (GtkBuilderClass *klass) * The translation domain used when translating property values that * have been marked as translatable in interface descriptions. * If the translation domain is %NULL, #GtkBuilder uses gettext(), - * otherwise dgettext(). + * otherwise g_dgettext(). * * Since: 2.12 */ diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 33b4f1bd88..42404d9aac 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -827,9 +827,9 @@ start_element (GMarkupParseContext *context, * GNU gettext uses '\004' to separate context and msgid in .mo files. */ static const char * -dpgettext (const char *domain, - const char *msgctxt, - const char *msgid) +_dpgettext (const char *domain, + const char *msgctxt, + const char *msgid) { size_t msgctxt_len = strlen (msgctxt) + 1; size_t msgid_len = strlen (msgid) + 1; @@ -842,13 +842,13 @@ dpgettext (const char *domain, msg_ctxt_id[msgctxt_len - 1] = '\004'; memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dgettext (domain, msg_ctxt_id); + translation = g_dgettext (domain, msg_ctxt_id); if (translation == msg_ctxt_id) { /* try the old way of doing message contexts, too */ msg_ctxt_id[msgctxt_len - 1] = '|'; - translation = dgettext (domain, msg_ctxt_id); + translation = g_dgettext (domain, msg_ctxt_id); if (translation == msg_ctxt_id) return msgid; @@ -865,9 +865,9 @@ _gtk_builder_parser_translate (const gchar *domain, const char *s; if (context) - s = dpgettext (domain, context, text); + s = _dpgettext (domain, context, text); else - s = dgettext (domain, text); + s = g_dgettext (domain, text); return g_strdup (s); } diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 94149d01a3..de515adbeb 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -10817,7 +10817,7 @@ list_size_data_func (GtkTreeViewColumn *tree_column, size = gtk_file_info_get_size (info); #if 0 if (size < (gint64)1024) - str = g_strdup_printf (ngettext ("%d byte", "%d bytes", (gint)size), (gint)size); + str = g_strdup_printf (g_dngettext (GETTEXT_DOMAIN, "%d byte", "%d bytes", (gint)size), (gint)size); else if (size < (gint64)1024*1024) str = g_strdup_printf (_("%.1f KB"), size / (1024.)); else if (size < (gint64)1024*1024*1024) diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c index 484ae51e6d..3ee0cc565f 100644 --- a/gtk/gtkimmulticontext.c +++ b/gtk/gtkimmulticontext.c @@ -590,7 +590,7 @@ gtk_im_multicontext_append_menuitems (GtkIMMulticontext *context, #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (contexts[i]->domain, "UTF-8"); #endif - translated_name = dgettext (contexts[i]->domain, contexts[i]->context_name); + translated_name = g_dgettext (contexts[i]->domain, contexts[i]->context_name); } else { diff --git a/gtk/gtkintl.h b/gtk/gtkintl.h index 4b176bd9f6..caeb68eb60 100644 --- a/gtk/gtkintl.h +++ b/gtk/gtkintl.h @@ -4,7 +4,7 @@ #include #ifdef ENABLE_NLS -#define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String) +#define P_(String) g_dgettext(GETTEXT_PACKAGE "-properties",String) #else #define P_(String) (String) #endif diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index 241936185e..234deb684a 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -527,22 +527,13 @@ enum_locale_proc (LPTSTR locale) #endif static void -do_pre_parse_initialization (int *argc, - char ***argv) +setlocale_initialization (void) { - const gchar *env_string; - -#if 0 - g_set_error_handler (gtk_error); - g_set_warning_handler (gtk_warning); - g_set_message_handler (gtk_message); - g_set_print_handler (gtk_print); -#endif + static gboolean initialized = FALSE; - if (pre_initialized) + if (initialized) return; - - pre_initialized = TRUE; + initialized = TRUE; if (do_setlocale) { @@ -607,6 +598,25 @@ do_pre_parse_initialization (int *argc, g_warning ("Locale not supported by C library.\n\tUsing the fallback 'C' locale."); #endif } +} + +static void +do_pre_parse_initialization (int *argc, + char ***argv) +{ + const gchar *env_string; + +#if 0 + g_set_error_handler (gtk_error); + g_set_warning_handler (gtk_warning); + g_set_message_handler (gtk_message); + g_set_print_handler (gtk_print); +#endif + + if (pre_initialized) + return; + + pre_initialized = TRUE; gdk_pre_parse_libgtk_only (); gdk_event_handler_set ((GdkEventFunc)gtk_main_do_event, NULL, NULL); @@ -630,6 +640,8 @@ do_pre_parse_initialization (int *argc, static void gettext_initialization (void) { + setlocale_initialization (); + #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, GTK_LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE "-properties", GTK_LOCALEDIR); diff --git a/gtk/gtkstock.c b/gtk/gtkstock.c index c50cf9a236..76f10fc4b1 100644 --- a/gtk/gtkstock.c +++ b/gtk/gtkstock.c @@ -176,7 +176,7 @@ gtk_stock_lookup (const gchar *stock_id, if (translate != NULL && translate->func != NULL) item->label = (* translate->func) (item->label, translate->data); else - item->label = dgettext (item->translation_domain, item->label); + item->label = g_dgettext (item->translation_domain, item->label); } } @@ -417,7 +417,7 @@ static const GtkStockItem builtin_items [] = * a stock item. * * If no function is registered for a translation domain, - * dgettext() is used. + * g_dgettext() is used. * * Since: 2.8 * @@ -457,7 +457,7 @@ sgettext_swapped (const gchar *msgid, { gchar *domainname = data; - return (gchar *)g_strip_context (msgid, dgettext (domainname, msgid)); + return (gchar *)g_strip_context (msgid, g_dgettext (domainname, msgid)); } -- cgit v1.2.1