Commit dc216ffb authored by Carlos Garnacho's avatar Carlos Garnacho

GtkStyleContext: Add gtk_style_context_[gs]et_direction().

parent e15dc89f
......@@ -81,11 +81,14 @@ struct GtkStyleContextPrivate
GSList *regions;
GtkThemingEngine *theming_engine;
GtkTextDirection direction;
};
enum {
PROP_0,
PROP_SCREEN
PROP_SCREEN,
PROP_DIRECTION
};
static void gtk_style_context_finalize (GObject *object);
......@@ -118,6 +121,14 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
P_("The associated GdkScreen"),
GDK_TYPE_SCREEN,
GTK_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_DIRECTION,
g_param_spec_enum ("direction",
P_("Direction"),
P_("Text direction"),
GTK_TYPE_TEXT_DIRECTION,
GTK_TEXT_DIR_LTR,
GTK_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GtkStyleContextPrivate));
}
......@@ -171,6 +182,8 @@ gtk_style_context_init (GtkStyleContext *style_context)
priv->store = gtk_style_set_new ();
priv->theming_engine = (GtkThemingEngine *) gtk_theming_engine_load (NULL);
priv->direction = GTK_TEXT_DIR_RTL;
/* Create default region */
region = style_region_new ();
priv->regions = g_slist_prepend (priv->regions, region);
......@@ -261,6 +274,10 @@ gtk_style_context_impl_set_property (GObject *object,
gtk_style_context_set_screen (style_context,
g_value_get_object (value));
break;
case PROP_DIRECTION:
gtk_style_context_set_direction (style_context,
g_value_get_enum (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -284,6 +301,9 @@ gtk_style_context_impl_get_property (GObject *object,
case PROP_SCREEN:
g_value_set_object (value, priv->screen);
break;
case PROP_DIRECTION:
g_value_set_enum (value, priv->direction);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -1210,6 +1230,31 @@ gtk_style_context_get_screen (GtkStyleContext *context)
return priv->screen;
}
void
gtk_style_context_set_direction (GtkStyleContext *context,
GtkTextDirection direction)
{
GtkStyleContextPrivate *priv;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
priv = context->priv;
priv->direction = direction;
g_object_notify (G_OBJECT (context), "direction");
}
GtkTextDirection
gtk_style_context_get_direction (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), GTK_TEXT_DIR_LTR);
priv = context->priv;
return priv->direction;
}
/* Paint methods */
void
gtk_render_check (GtkStyleContext *context,
......
......@@ -114,6 +114,10 @@ void gtk_style_context_set_screen (GtkStyleContext *context,
GdkScreen *screen);
GdkScreen * gtk_style_context_get_screen (GtkStyleContext *context);
void gtk_style_context_set_direction (GtkStyleContext *context,
GtkTextDirection direction);
GtkTextDirection gtk_style_context_get_direction (GtkStyleContext *context);
/* Semi-private API */
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment