[gtk+/gtk-style-context: 152/347] GtkStyleContext: Add gtk_style_context_[gs]et_direction().



commit 264d4bf2eca954734c0f71070d4a5e5eba793b46
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 2 17:18:53 2010 +0200

    GtkStyleContext: Add gtk_style_context_[gs]et_direction().

 gtk/gtkstylecontext.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++-
 gtk/gtkstylecontext.h |    4 ++++
 2 files changed, 50 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index f7297f7..0e7cedb 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -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,
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index d1291a3..c3a4516 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]