[StWidget] add API support for right-to-left UI

https://bugzilla.gnome.org/show_bug.cgi?id=584662
This commit is contained in:
Abderrahim Kitouni 2009-11-14 18:20:31 +01:00 committed by Dan Winship
parent cdd508e12d
commit a5edc78fac
2 changed files with 47 additions and 0 deletions

View File

@ -66,6 +66,8 @@ struct _StWidgetPrivate
gboolean draw_border_internal : 1; gboolean draw_border_internal : 1;
StTooltip *tooltip; StTooltip *tooltip;
StTextDirection direction;
}; };
/** /**
@ -1272,6 +1274,40 @@ st_widget_ensure_style (StWidget *widget)
st_widget_recompute_style (widget, NULL); 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: * st_widget_get_border_image:
* @actor: A #StWidget * @actor: A #StWidget

View File

@ -35,6 +35,12 @@
G_BEGIN_DECLS 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_TYPE_WIDGET (st_widget_get_type ())
#define ST_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ST_TYPE_WIDGET, StWidget)) #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)) #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); 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 */ /* Only to be used by sub-classes of StWidget */
void st_widget_style_changed (StWidget *widget); void st_widget_style_changed (StWidget *widget);