diff --git a/src/st/st-widget.c b/src/st/st-widget.c index d606497d5..482d5c04a 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -66,6 +66,8 @@ struct _StWidgetPrivate gboolean draw_border_internal : 1; StTooltip *tooltip; + + StTextDirection direction; }; /** @@ -1272,6 +1274,40 @@ st_widget_ensure_style (StWidget *widget) st_widget_recompute_style (widget, NULL); } +static StTextDirection default_direction = ST_TEXT_DIRECTION_LTR; + +StTextDirection +st_widget_get_default_direction (void) +{ + return default_direction; +} + +void +st_widget_set_default_direction (StTextDirection dir) +{ + g_return_if_fail (dir != ST_TEXT_DIRECTION_NONE); + + default_direction = dir; +} + +StTextDirection +st_widget_get_direction (StWidget *self) +{ + g_return_val_if_fail (ST_IS_WIDGET (self), ST_TEXT_DIRECTION_LTR); + + if (self->priv->direction != ST_TEXT_DIRECTION_NONE) + return self->priv->direction; + else + return default_direction; +} + +void +st_widget_set_direction (StWidget *self, StTextDirection dir) +{ + g_return_if_fail (ST_IS_WIDGET (self)); + self->priv->direction = dir; +} + /** * st_widget_get_border_image: * @actor: A #StWidget diff --git a/src/st/st-widget.h b/src/st/st-widget.h index 66f7b0698..bebe28620 100644 --- a/src/st/st-widget.h +++ b/src/st/st-widget.h @@ -35,6 +35,12 @@ G_BEGIN_DECLS +typedef enum { + ST_TEXT_DIRECTION_NONE, + ST_TEXT_DIRECTION_LTR, + ST_TEXT_DIRECTION_RTL +} StTextDirection; + #define ST_TYPE_WIDGET (st_widget_get_type ()) #define ST_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_WIDGET, StWidget)) #define ST_IS_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ST_TYPE_WIDGET)) @@ -103,6 +109,11 @@ void st_widget_hide_tooltip (StWidget *widget); void st_widget_ensure_style (StWidget *widget); +StTextDirection st_widget_get_default_direction (void); +void st_widget_set_default_direction (StTextDirection dir); + +StTextDirection st_widget_get_direction (StWidget *self); +void st_widget_set_direction (StWidget *self, StTextDirection dir); /* Only to be used by sub-classes of StWidget */ void st_widget_style_changed (StWidget *widget);