[mutter/bilelmoussaoui/gdk-x11-only: 16/21] core: Replace gtk_get_default_locale usage
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/gdk-x11-only: 16/21] core: Replace gtk_get_default_locale usage
- Date: Tue, 17 May 2022 10:02:10 +0000 (UTC)
commit 5849e6cdf8fc5b98d50281e56ad86af843123306
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Mon May 9 11:29:11 2022 +0200
core: Replace gtk_get_default_locale usage
Clutter has an API to get the text direction but used to depend
on gtk3's translation domain. In order to avoid broken i18n
in case gtk3 is not installed, move the transtalable string to
clutter itself.
clutter/clutter/clutter-build-config.h.meson | 3 +++
clutter/clutter/clutter-main.c | 11 ++++++++---
clutter/clutter/clutter-main.h | 3 +++
clutter/clutter/meson.build | 1 +
po/POTFILES.in | 1 +
src/core/util.c | 6 +++---
6 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/clutter/clutter/clutter-build-config.h.meson b/clutter/clutter/clutter-build-config.h.meson
index 7ca19deabf..a859f78f9c 100644
--- a/clutter/clutter/clutter-build-config.h.meson
+++ b/clutter/clutter/clutter-build-config.h.meson
@@ -1,3 +1,6 @@
+/* The prefix for our gettext translation domains. */
+#mesondefine GETTEXT_PACKAGE
+
/* Mutter version */
#mesondefine MUTTER_VERSION
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 5b01783e5e..90ef09234b 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -50,6 +50,7 @@
#include "clutter-build-config.h"
#include <stdlib.h>
+#include <glib/gi18n-lib.h>
#include "clutter-actor-private.h"
#include "clutter-backend-private.h"
@@ -209,7 +210,7 @@ clutter_context_get_pango_fontmap (void)
return self->font_map;
}
-static ClutterTextDirection
+ClutterTextDirection
clutter_get_text_direction (void)
{
ClutterTextDirection dir = CLUTTER_TEXT_DIRECTION_LTR;
@@ -225,8 +226,12 @@ clutter_get_text_direction (void)
}
else
{
- /* Re-use GTK+'s LTR/RTL handling */
- const char *e = g_dgettext ("gtk30", "default:LTR");
+ /* Translate to default:RTL if you want your widgets
+ * to be RTL, otherwise translate to default:LTR.
+ * Do *not* translate it to "predefinito:LTR", if it
+ * it isn't default:LTR or default:RTL it will not work
+ */
+ const char *e = _("default:LTR");
if (strcmp (e, "default:RTL") == 0)
dir = CLUTTER_TEXT_DIRECTION_RTL;
diff --git a/clutter/clutter/clutter-main.h b/clutter/clutter/clutter-main.h
index a2d8400f47..24851071dc 100644
--- a/clutter/clutter/clutter-main.h
+++ b/clutter/clutter/clutter-main.h
@@ -150,6 +150,9 @@ void clutter_remove_debug_flags (ClutterDebugFla
CLUTTER_EXPORT
void clutter_debug_set_max_render_time_constant (int max_render_time_constant_us);
+CLUTTER_EXPORT
+ClutterTextDirection clutter_get_text_direction (void);
+
G_END_DECLS
#endif /* _CLUTTER_MAIN_H__ */
diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build
index 2b8764a0f1..ff834f6200 100644
--- a/clutter/clutter/meson.build
+++ b/clutter/clutter/meson.build
@@ -267,6 +267,7 @@ clutter_built_private_headers = []
cdata = configuration_data()
cdata.set_quoted('MUTTER_VERSION', meson.project_version())
+cdata.set_quoted('GETTEXT_PACKAGE', meson.project_name())
cdata.set('CLUTTER_DRIVERS', '"*"')
cdata.set('HAVE_PANGO_FT2', have_pango_ft2)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index cf3563416f..345b396a23 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -12,6 +12,7 @@ src/backends/meta-monitor.c
src/backends/meta-monitor-manager.c
src/backends/meta-profiler.c
src/backends/x11/meta-clutter-backend-x11.c
+src/clutter/clutter/clutter-main.c
src/compositor/compositor.c
src/compositor/meta-background.c
src/core/bell.c
diff --git a/src/core/util.c b/src/core/util.c
index 10c59ed7db..08e26c6492 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -505,11 +505,11 @@ meta_external_binding_name_for_action (guint keybinding_action)
MetaLocaleDirection
meta_get_locale_direction (void)
{
- switch (gtk_get_locale_direction ())
+ switch (clutter_get_text_direction ())
{
- case GTK_TEXT_DIR_LTR:
+ case CLUTTER_TEXT_DIRECTION_LTR:
return META_LOCALE_DIRECTION_LTR;
- case GTK_TEXT_DIR_RTL:
+ case CLUTTER_TEXT_DIRECTION_RTL:
return META_LOCALE_DIRECTION_RTL;
default:
g_assert_not_reached ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]