Use the newly added ClutterTextDirection enumeration
Instead of using PangoDirection directly we should use the ClutterTextDirection enumeration. We also need a pair of accessor functions for setting and getting the default text direction.
This commit is contained in:
parent
3958df4ff9
commit
53a9d0c637
@ -74,7 +74,7 @@ static gboolean clutter_use_fuzzy_picking = FALSE;
|
|||||||
|
|
||||||
static guint clutter_default_fps = 60;
|
static guint clutter_default_fps = 60;
|
||||||
|
|
||||||
static PangoDirection clutter_text_direction = PANGO_DIRECTION_LTR;
|
static PangoDirection clutter_text_direction = CLUTTER_TEXT_DIRECTION_LTR;
|
||||||
|
|
||||||
static guint clutter_main_loop_level = 0;
|
static guint clutter_main_loop_level = 0;
|
||||||
static GSList *main_loops = NULL;
|
static GSList *main_loops = NULL;
|
||||||
@ -540,7 +540,7 @@ _clutter_do_pick (ClutterStage *stage,
|
|||||||
return clutter_get_actor_by_gid (id);
|
return clutter_get_actor_by_gid (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PangoDirection
|
static ClutterTextDirection
|
||||||
clutter_get_text_direction (void)
|
clutter_get_text_direction (void)
|
||||||
{
|
{
|
||||||
PangoDirection dir = PANGO_DIRECTION_LTR;
|
PangoDirection dir = PANGO_DIRECTION_LTR;
|
||||||
@ -550,9 +550,9 @@ clutter_get_text_direction (void)
|
|||||||
if (direction && *direction != '\0')
|
if (direction && *direction != '\0')
|
||||||
{
|
{
|
||||||
if (strcmp (direction, "rtl") == 0)
|
if (strcmp (direction, "rtl") == 0)
|
||||||
dir = PANGO_DIRECTION_RTL;
|
dir = CLUTTER_TEXT_DIRECTION_RTL;
|
||||||
else if (strcmp (direction, "ltr") == 0)
|
else if (strcmp (direction, "ltr") == 0)
|
||||||
dir = PANGO_DIRECTION_LTR;
|
dir = CLUTTER_TEXT_DIRECTION_LTR;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -565,9 +565,9 @@ clutter_get_text_direction (void)
|
|||||||
char *e = _("default:LTR");
|
char *e = _("default:LTR");
|
||||||
|
|
||||||
if (strcmp (e, "default:RTL") == 0)
|
if (strcmp (e, "default:RTL") == 0)
|
||||||
dir = PANGO_DIRECTION_RTL;
|
dir = CLUTTER_TEXT_DIRECTION_RTL;
|
||||||
else if (strcmp (e, "default:LTR") == 0)
|
else if (strcmp (e, "default:LTR") == 0)
|
||||||
dir = PANGO_DIRECTION_LTR;
|
dir = CLUTTER_TEXT_DIRECTION_LTR;
|
||||||
else
|
else
|
||||||
g_warning ("Whoever translated default:LTR did so wrongly.");
|
g_warning ("Whoever translated default:LTR did so wrongly.");
|
||||||
}
|
}
|
||||||
@ -582,10 +582,16 @@ update_pango_context (ClutterBackend *backend,
|
|||||||
PangoFontDescription *font_desc;
|
PangoFontDescription *font_desc;
|
||||||
const cairo_font_options_t *font_options;
|
const cairo_font_options_t *font_options;
|
||||||
const gchar *font_name;
|
const gchar *font_name;
|
||||||
|
PangoDirection pango_dir;
|
||||||
gdouble resolution;
|
gdouble resolution;
|
||||||
|
|
||||||
/* update the text direction */
|
/* update the text direction */
|
||||||
pango_context_set_base_dir (context, clutter_text_direction);
|
if (clutter_text_direction == CLUTTER_TEXT_DIRECTION_RTL)
|
||||||
|
pango_dir = PANGO_DIRECTION_RTL;
|
||||||
|
else
|
||||||
|
pango_dir = PANGO_DIRECTION_LTR;
|
||||||
|
|
||||||
|
pango_context_set_base_dir (context, pango_dir);
|
||||||
|
|
||||||
/* get the configuration for the PangoContext from the backend */
|
/* get the configuration for the PangoContext from the backend */
|
||||||
font_name = clutter_backend_get_font_name (backend);
|
font_name = clutter_backend_get_font_name (backend);
|
||||||
@ -1236,8 +1242,8 @@ clutter_arg_direction_cb (const char *key,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
clutter_text_direction =
|
clutter_text_direction =
|
||||||
(strcmp (value, "rtl") == 0) ? PANGO_DIRECTION_RTL
|
(strcmp (value, "rtl") == 0) ? CLUTTER_TEXT_DIRECTION_RTL
|
||||||
: PANGO_DIRECTION_LTR;
|
: CLUTTER_TEXT_DIRECTION_LTR;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1356,7 +1362,6 @@ clutter_init_real (GError **error)
|
|||||||
|
|
||||||
clutter_text_direction = clutter_get_text_direction ();
|
clutter_text_direction = clutter_get_text_direction ();
|
||||||
|
|
||||||
|
|
||||||
/* Figure out framebuffer masks used for pick */
|
/* Figure out framebuffer masks used for pick */
|
||||||
cogl_get_bitmasks (&ctx->fb_r_mask, &ctx->fb_g_mask, &ctx->fb_b_mask, NULL);
|
cogl_get_bitmasks (&ctx->fb_r_mask, &ctx->fb_g_mask, &ctx->fb_b_mask, NULL);
|
||||||
|
|
||||||
@ -3027,3 +3032,21 @@ clutter_check_version (guint major,
|
|||||||
clutter_minor_version == minor &&
|
clutter_minor_version == minor &&
|
||||||
clutter_micro_version >= micro));
|
clutter_micro_version >= micro));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_set_default_text_direction (ClutterTextDirection text_dir)
|
||||||
|
{
|
||||||
|
if (text_dir == CLUTTER_TEXT_DIRECTION_DEFAULT)
|
||||||
|
text_dir = clutter_get_text_direction ();
|
||||||
|
|
||||||
|
if (text_dir != clutter_text_direction)
|
||||||
|
clutter_text_direction = text_dir;
|
||||||
|
|
||||||
|
/* FIXME - queue a relayout on all stages */
|
||||||
|
}
|
||||||
|
|
||||||
|
ClutterTextDirection
|
||||||
|
clutter_get_default_text_direction (void)
|
||||||
|
{
|
||||||
|
return clutter_text_direction;
|
||||||
|
}
|
||||||
|
@ -164,6 +164,9 @@ void clutter_ungrab_pointer_for_device (gint id);
|
|||||||
|
|
||||||
PangoFontMap * clutter_get_font_map (void);
|
PangoFontMap * clutter_get_font_map (void);
|
||||||
|
|
||||||
|
void clutter_set_default_text_direction (ClutterTextDirection text_dir);
|
||||||
|
ClutterTextDirection clutter_get_default_text_direction (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _CLUTTER_MAIN_H__ */
|
#endif /* _CLUTTER_MAIN_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user