1
0
Fork 0

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.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
This commit is contained in:
Bilal Elmoussaoui 2022-05-09 11:29:11 +02:00
parent 64ee8d02f7
commit c710f14cc5
6 changed files with 20 additions and 6 deletions

View file

@ -1,3 +1,6 @@
/* The prefix for our gettext translation domains. */
#mesondefine GETTEXT_PACKAGE
/* Mutter version */
#mesondefine MUTTER_VERSION

View file

@ -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"
@ -204,7 +205,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;
@ -220,8 +221,13 @@ 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;

View file

@ -148,6 +148,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__ */

View file

@ -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)

View file

@ -11,6 +11,7 @@ src/backends/meta-input-settings.c
src/backends/meta-monitor.c
src/backends/meta-monitor-manager.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

View file

@ -508,11 +508,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 ();