[gtk+] Mark orientable widgets with the vertical/horizontal css classes



commit 48a4f88ab1d49ad405710ba0908ee31e50a1bc2e
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Jan 10 23:38:47 2011 +0100

    Mark orientable widgets with the vertical/horizontal css classes
    
    This can be used to theme widgets differently depending on the
    orientation. Bug 639157, reported by Christian Dywan.

 gtk/gtkorientable.c   |   18 ++++++++++++++++++
 gtk/gtkstylecontext.h |   14 ++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkorientable.c b/gtk/gtkorientable.c
index dfc0dd6..d362725 100644
--- a/gtk/gtkorientable.c
+++ b/gtk/gtkorientable.c
@@ -80,11 +80,29 @@ void
 gtk_orientable_set_orientation (GtkOrientable  *orientable,
                                 GtkOrientation  orientation)
 {
+  GtkStyleContext *context;
+
   g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
 
   g_object_set (orientable,
                 "orientation", orientation,
                 NULL);
+
+  if (GTK_IS_WIDGET (orientable))
+    {
+      context = gtk_widget_get_style_context (GTK_WIDGET (orientable));
+
+      if (orientation == GTK_ORIENTATION_HORIZONTAL)
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+        }
+      else
+        {
+          gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+          gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+        }
+    }
 }
 
 /**
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index 00836d6..291b8a7 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -399,6 +399,20 @@ struct _GtkStyleContextClass
  */
 #define GTK_STYLE_CLASS_ERROR "error"
 
+/**
+ * GTK_STYLE_CLASS_HORIZONTAL:
+ *
+ * A widget class for horizontally layered widgets.
+ */
+#define GTK_STYLE_CLASS_HORIZONTAL "horizontal"
+
+/**
+ * GTK_STYLE_CLASS_VERTICAL:
+ *
+ * A widget class for vertically layered widgets.
+ */
+#define GTK_STYLE_CLASS_VERTICAL "vertical"
+
 
 /* Predefined set of widget regions */
 



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