[gtk/wip/ebassi/a11y-2: 15/28] Move orientable style classes into GtkWidget



commit 5a5a51ca4697f367cfbc97a131a8ddaaf04d522e
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Apr 23 17:48:29 2020 +0100

    Move orientable style classes into GtkWidget
    
    It feels slightly wrong to have GtkOrientable operate on widgets, but at
    least what happens when an orientable widget changes orientation should
    be part of GtkWidget.
    
    This will allow to add more state changes without accessing widget state
    from the outside of gtkwidget.c.

 docs/reference/gtk/meson.build |  1 -
 gtk/gtkbox.c                   |  5 ++--
 gtk/gtkboxlayout.c             |  4 ++--
 gtk/gtkcellview.c              | 15 +++++++-----
 gtk/gtkcenterbox.c             |  3 +--
 gtk/gtkflowbox.c               | 31 +++++++++++++-----------
 gtk/gtkgrid.c                  |  7 +++---
 gtk/gtkgridlayout.c            |  2 +-
 gtk/gtklevelbar.c              | 16 ++++++-------
 gtk/gtkorientable.c            | 27 +++------------------
 gtk/gtkorientableprivate.h     | 29 -----------------------
 gtk/gtkpaned.c                 | 53 ++++++++++++++++++++++--------------------
 gtk/gtkprogressbar.c           |  8 +++----
 gtk/gtkrange.c                 |  9 +++----
 gtk/gtkscrollbar.c             |  7 ++----
 gtk/gtkseparator.c             |  8 ++++---
 gtk/gtkspinbutton.c            |  6 ++---
 gtk/gtkwidget.c                | 31 +++++++++++++++++++++---
 gtk/gtkwidgetprivate.h         |  3 +++
 19 files changed, 125 insertions(+), 140 deletions(-)
---
diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build
index 07536264eb..a0283c62ef 100644
--- a/docs/reference/gtk/meson.build
+++ b/docs/reference/gtk/meson.build
@@ -140,7 +140,6 @@ private_headers = [
   'gtkmountoperationprivate.h',
   'gtknativedialogprivate.h',
   'gtknomediafileprivate.h',
-  'gtkorientableprivate.h',
   'gtkplacessidebarprivate.h',
   'gtkplacesviewprivate.h',
   'gtkplacesviewrowprivate.h',
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index e1539ff4ce..d4c296e7df 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -61,7 +61,6 @@
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkintl.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtksizerequest.h"
@@ -120,7 +119,7 @@ gtk_box_set_property (GObject      *object,
             priv->orientation = orientation;
             gtk_orientable_set_orientation (GTK_ORIENTABLE (box_layout),
                                             priv->orientation);
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+            gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
             g_object_notify (object, "orientation");
           }
       }
@@ -288,7 +287,7 @@ gtk_box_init (GtkBox *box)
   GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
 
   priv->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+  gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
 }
 
 static GtkBuildableIface *parent_buildable_iface;
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 098375973b..d06f5983a8 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -22,7 +22,7 @@
 
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkintl.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
@@ -89,7 +89,7 @@ gtk_box_layout_set_orientation (GtkBoxLayout   *self,
 
   widget = gtk_layout_manager_get_widget (layout_manager);
   if (widget != NULL && GTK_IS_ORIENTABLE (widget))
-    _gtk_orientable_set_style_classes (GTK_ORIENTABLE (widget));
+    gtk_widget_update_orientation (widget, self->orientation);
 
   gtk_layout_manager_layout_changed (layout_manager);
 
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 12132c2944..a7b5a9c3a9 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -16,19 +16,22 @@
  */
 
 #include "config.h"
-#include <string.h>
+
 #include "gtkcellview.h"
+
+#include "gtkbuildable.h"
 #include "gtkcelllayout.h"
 #include "gtkcellareabox.h"
-#include "gtkintl.h"
-#include "gtkcellrenderertext.h"
 #include "gtkcellrendererpixbuf.h"
+#include "gtkcellrenderertext.h"
+#include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
-#include "gtkorientableprivate.h"
 #include "gtkwidgetprivate.h"
+
 #include <gobject/gmarshal.h>
-#include "gtkbuildable.h"
 
+#include <string.h>
 
 /**
  * SECTION:gtkcellview
@@ -385,7 +388,7 @@ gtk_cell_view_set_property (GObject      *object,
           priv->orientation = g_value_get_enum (value);
           if (priv->context)
             gtk_cell_area_context_reset (priv->context);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
+          gtk_widget_update_orientation (GTK_WIDGET (object), priv->orientation);
           g_object_notify_by_pspec (object, pspec);
         }
       break;
diff --git a/gtk/gtkcenterbox.c b/gtk/gtkcenterbox.c
index 8bd0a7fda0..e3536be6d9 100644
--- a/gtk/gtkcenterbox.c
+++ b/gtk/gtkcenterbox.c
@@ -58,7 +58,6 @@
 #include "gtkcssnodeprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkbuildable.h"
 #include "gtksizerequest.h"
 #include "gtktypebuiltins.h"
@@ -140,7 +139,7 @@ gtk_center_box_set_property (GObject      *object,
         if (current != orientation)
           {
             gtk_center_layout_set_orientation (GTK_CENTER_LAYOUT (layout), orientation);
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+            gtk_widget_update_orientation (GTK_WIDGET (self), orientation);
             gtk_widget_queue_resize (GTK_WIDGET (self));
             g_object_notify (object, "orientation");
           }
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index ddbf34fa33..373a89c261 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -75,7 +75,6 @@
 
 #include <config.h>
 
-#include "gtkflowbox.h"
 #include "gtkflowboxprivate.h"
 
 #include "gtkadjustment.h"
@@ -83,13 +82,14 @@
 #include "gtkbuildable.h"
 #include "gtkcsscolorvalueprivate.h"
 #include "gtkcssnodeprivate.h"
-#include "gtkgesturedrag.h"
+#include "gtkeventcontrollerkey.h"
 #include "gtkgestureclick.h"
+#include "gtkgesturedrag.h"
 #include "gtkintl.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
-#include "gtkorientableprivate.h"
 #include "gtkrender.h"
 #include "gtksizerequest.h"
 #include "gtksnapshot.h"
@@ -97,7 +97,6 @@
 #include "gtktypebuiltins.h"
 #include "gtkviewport.h"
 #include "gtkwidgetprivate.h"
-#include "gtkeventcontrollerkey.h"
 
 #include "a11y/gtkflowboxaccessibleprivate.h"
 #include "a11y/gtkflowboxchildaccessible.h"
@@ -3441,14 +3440,20 @@ gtk_flow_box_set_property (GObject      *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      if (priv->orientation != g_value_get_enum (value))
-        {
-          priv->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
-          /* Re-box the children in the new orientation */
-          gtk_widget_queue_resize (GTK_WIDGET (box));
-          g_object_notify_by_pspec (object, pspec);
-        }
+      {
+        GtkOrientation orientation = g_value_get_enum (value);
+
+        if (priv->orientation != orientation)
+          {
+            priv->orientation = orientation;
+
+            gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
+
+            /* Re-box the children in the new orientation */
+            gtk_widget_queue_resize (GTK_WIDGET (box));
+            g_object_notify_by_pspec (object, pspec);
+          }
+      }
       break;
     case PROP_HOMOGENEOUS:
       gtk_flow_box_set_homogeneous (box, g_value_get_boolean (value));
@@ -3890,7 +3895,7 @@ gtk_flow_box_init (GtkFlowBox *box)
   priv->row_spacing = 0;
   priv->activate_on_single_click = TRUE;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (box));
+  gtk_widget_update_orientation (GTK_WIDGET (box), priv->orientation);
 
   priv->children = g_sequence_new (NULL);
 
diff --git a/gtk/gtkgrid.c b/gtk/gtkgrid.c
index 2a1fec3491..fcee1db685 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -25,8 +25,8 @@
 #include "gtkbuildable.h"
 #include "gtkcsspositionvalueprivate.h"
 #include "gtkgridlayout.h"
-#include "gtkorientableprivate.h"
 #include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
@@ -135,7 +135,8 @@ gtk_grid_set_orientation (GtkGrid        *grid,
   if (priv->orientation != orientation)
     {
       priv->orientation = orientation;
-      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
+
+      gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
 
       g_object_notify (G_OBJECT (grid), "orientation");
     }
@@ -435,7 +436,7 @@ gtk_grid_init (GtkGrid *grid)
   priv->layout_manager = gtk_widget_get_layout_manager (GTK_WIDGET (grid));
 
   priv->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (grid));
+  gtk_widget_update_orientation (GTK_WIDGET (grid), priv->orientation);
 }
 
 /**
diff --git a/gtk/gtkgridlayout.c b/gtk/gtkgridlayout.c
index b77169e76f..08fce7fbde 100644
--- a/gtk/gtkgridlayout.c
+++ b/gtk/gtkgridlayout.c
@@ -48,7 +48,7 @@
 #include "gtkdebug.h"
 #include "gtkintl.h"
 #include "gtklayoutchild.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtksizerequest.h"
 #include "gtkstylecontextprivate.h"
diff --git a/gtk/gtklevelbar.c b/gtk/gtklevelbar.c
index d00a03f1f3..b94e02bcdd 100644
--- a/gtk/gtklevelbar.c
+++ b/gtk/gtklevelbar.c
@@ -122,18 +122,16 @@
 #include "gtkbinlayout.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
+#include "gtkcssstylepropertyprivate.h"
+#include "gtkcssnodeprivate.h"
+#include "gtkgizmoprivate.h"
 #include "gtkintl.h"
-#include "gtkorientableprivate.h"
 #include "gtklevelbar.h"
 #include "gtkmarshalers.h"
-#include "gtkstylecontext.h"
+#include "gtkorientable.h"
+#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
-#include "gtkwidget.h"
 #include "gtkwidgetprivate.h"
-#include "gtkstylecontextprivate.h"
-#include "gtkcssstylepropertyprivate.h"
-#include "gtkcssnodeprivate.h"
-#include "gtkgizmoprivate.h"
 
 #include <math.h>
 #include <stdlib.h>
@@ -798,7 +796,7 @@ gtk_level_bar_set_orientation (GtkLevelBar    *self,
   if (self->orientation != orientation)
     {
       self->orientation = orientation;
-      _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+      gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
       gtk_widget_queue_resize (GTK_WIDGET (self));
       g_object_notify (G_OBJECT (self), "orientation");
     }
@@ -1014,7 +1012,7 @@ gtk_level_bar_init (GtkLevelBar *self)
 
   /* set initial orientation and style classes */
   self->orientation = GTK_ORIENTATION_HORIZONTAL;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+  gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
 
   self->inverted = FALSE;
 
diff --git a/gtk/gtkorientable.c b/gtk/gtkorientable.c
index 4987a6c76c..8bfb629285 100644
--- a/gtk/gtkorientable.c
+++ b/gtk/gtkorientable.c
@@ -21,9 +21,10 @@
 
 #include "config.h"
 
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 
 #include "gtkprivate.h"
+#include "gtkwidgetprivate.h"
 #include "gtkstylecontext.h"
 #include "gtktypebuiltins.h"
 #include "gtkintl.h"
@@ -81,7 +82,7 @@ gtk_orientable_set_orientation (GtkOrientable  *orientable,
                 NULL);
 
   if (GTK_IS_WIDGET (orientable))
-    _gtk_orientable_set_style_classes (orientable);
+    gtk_widget_update_orientation (GTK_WIDGET (orientable), orientation);
 }
 
 /**
@@ -106,25 +107,3 @@ gtk_orientable_get_orientation (GtkOrientable *orientable)
 
   return orientation;
 }
-
-void
-_gtk_orientable_set_style_classes (GtkOrientable *orientable)
-{
-  GtkOrientation orientation;
-
-  g_return_if_fail (GTK_IS_ORIENTABLE (orientable));
-  g_return_if_fail (GTK_IS_WIDGET (orientable));
-
-  orientation = gtk_orientable_get_orientation (orientable);
-
-  if (orientation == GTK_ORIENTATION_HORIZONTAL)
-    {
-      gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
-      gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
-    }
-  else
-    {
-      gtk_widget_add_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_VERTICAL);
-      gtk_widget_remove_css_class (GTK_WIDGET (orientable), GTK_STYLE_CLASS_HORIZONTAL);
-    }
-}
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index 6c233c4b62..9a0313c5af 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -26,6 +26,7 @@
 
 #include "gtkpaned.h"
 
+#include "gtkcssboxesprivate.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkeventcontrollermotion.h"
@@ -34,7 +35,7 @@
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkrendericonprivate.h"
 #include "gtkstylecontextprivate.h"
@@ -389,6 +390,30 @@ gtk_paned_get_request_mode (GtkWidget *widget)
         GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
 }
 
+static void
+gtk_paned_set_orientation (GtkPaned       *self,
+                           GtkOrientation  orientation)
+{
+  if (self->orientation != orientation)
+    {
+      static const char *cursor_name[2] = {
+        "col-resize",
+        "row-resize",
+      };
+
+      self->orientation = orientation;
+
+      gtk_widget_update_orientation (GTK_WIDGET (self), self->orientation);
+      gtk_widget_set_cursor_from_name (self->handle_widget,
+                                       cursor_name[orientation]);
+      gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (self->pan_gesture),
+                                       orientation);
+
+      gtk_widget_queue_resize (GTK_WIDGET (self));
+      g_object_notify (G_OBJECT (self), "orientation");
+    }
+}
+
 static void
 gtk_paned_class_init (GtkPanedClass *class)
 {
@@ -919,29 +944,7 @@ gtk_paned_set_property (GObject        *object,
   switch (prop_id)
     {
     case PROP_ORIENTATION:
-      if (paned->orientation != g_value_get_enum (value))
-        {
-          paned->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
-
-          if (paned->orientation == GTK_ORIENTATION_HORIZONTAL)
-            {
-              gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (paned->pan_gesture),
-                                               GTK_ORIENTATION_HORIZONTAL);
-              gtk_widget_set_cursor_from_name (paned->handle_widget,
-                                               "col-resize");
-            }
-          else
-            {
-              gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (paned->pan_gesture),
-                                               GTK_ORIENTATION_VERTICAL);
-              gtk_widget_set_cursor_from_name (paned->handle_widget,
-                                               "row-resize");
-            }
-
-          gtk_widget_queue_resize (GTK_WIDGET (paned));
-          g_object_notify_by_pspec (object, pspec);
-        }
+      gtk_paned_set_orientation (paned, g_value_get_enum (value));
       break;
     case PROP_POSITION:
       gtk_paned_set_position (paned, g_value_get_int (value));
@@ -1450,7 +1453,7 @@ gtk_paned_init (GtkPaned *paned)
   paned->shrink_start_child = TRUE;
   paned->shrink_end_child = TRUE;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
+  gtk_widget_update_orientation (GTK_WIDGET (paned), paned->orientation);
 
   /* Touch gesture */
   gesture = gtk_gesture_pan_new (GTK_ORIENTATION_HORIZONTAL);
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 83f2aeaf89..c5d2b79caf 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -26,18 +26,18 @@
 
 #include "gtkprogressbar.h"
 
+#include "gtkboxlayout.h"
 #include "gtkcssnodeprivate.h"
 #include "gtkcssnumbervalueprivate.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtklabel.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprogresstrackerprivate.h"
 #include "gtkprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtkwidgetprivate.h"
-#include "gtkboxlayout.h"
 
 #include "a11y/gtkprogressbaraccessible.h"
 
@@ -459,7 +459,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
   /* horizontal is default */
   pbar->orientation = GTK_ORIENTATION_VERTICAL; /* Just to force an update... */
   gtk_progress_bar_set_orientation (pbar, GTK_ORIENTATION_HORIZONTAL);
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
+  gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
 }
 
 static void
@@ -924,7 +924,7 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
       gtk_widget_set_valign (pbar->trough_widget, GTK_ALIGN_FILL);
     }
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
+  gtk_widget_update_orientation (GTK_WIDGET (pbar), pbar->orientation);
   update_node_classes (pbar);
 
   layout = GTK_BOX_LAYOUT (gtk_widget_get_layout_manager (GTK_WIDGET (pbar)));
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index bc765d1f67..916b63e2fc 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -29,6 +29,7 @@
 
 #include "gtkadjustmentprivate.h"
 #include "gtkcolorscaleprivate.h"
+#include "gtkeventcontrollerkey.h"
 #include "gtkeventcontrollerscroll.h"
 #include "gtkgesturedrag.h"
 #include "gtkgesturelongpressprivate.h"
@@ -36,11 +37,11 @@
 #include "gtkgizmoprivate.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkscale.h"
 #include "gtktypebuiltins.h"
-#include "gtkeventcontrollerkey.h"
+#include "gtkwidgetprivate.h"
 
 #include "a11y/gtkrangeaccessible.h"
 
@@ -458,7 +459,7 @@ gtk_range_set_property (GObject      *object,
       if (priv->orientation != g_value_get_enum (value))
         {
           priv->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
+          gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
           gtk_widget_queue_resize (GTK_WIDGET (range));
           g_object_notify_by_pspec (object, pspec);
         }
@@ -542,7 +543,7 @@ gtk_range_init (GtkRange *range)
   priv->fill_level = G_MAXDOUBLE;
   priv->timer = NULL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (range));
+  gtk_widget_update_orientation (GTK_WIDGET (range), priv->orientation);
 
   priv->trough_widget = gtk_gizmo_new ("trough",
                                        gtk_range_measure_trough,
diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c
index ab23a53095..7e9bdaae80 100644
--- a/gtk/gtkscrollbar.c
+++ b/gtk/gtkscrollbar.c
@@ -31,7 +31,6 @@
 #include "gtkadjustment.h"
 #include "gtkintl.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtkwidgetprivate.h"
 #include "gtkboxlayout.h"
@@ -162,8 +161,7 @@ gtk_scrollbar_set_property (GObject      *object,
             gtk_orientable_set_orientation (GTK_ORIENTABLE (layout), orientation);
             gtk_orientable_set_orientation (GTK_ORIENTABLE (priv->range), orientation);
             priv->orientation = orientation;
-            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
-
+            gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
             gtk_widget_queue_resize (GTK_WIDGET (self));
             g_object_notify_by_pspec (object, pspec);
           }
@@ -223,8 +221,7 @@ gtk_scrollbar_init (GtkScrollbar *self)
   gtk_widget_set_hexpand (priv->range, TRUE);
   gtk_widget_set_vexpand (priv->range, TRUE);
   gtk_widget_set_parent (priv->range, GTK_WIDGET (self));
-
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
+  gtk_widget_update_orientation (GTK_WIDGET (self), priv->orientation);
 }
 
 /**
diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c
index 59cc5050a0..4c2f23adb0 100644
--- a/gtk/gtkseparator.c
+++ b/gtk/gtkseparator.c
@@ -26,8 +26,8 @@
 
 #include "gtkseparator.h"
 
-#include "gtkorientableprivate.h"
 #include "gtkintl.h"
+#include "gtkorientable.h"
 #include "gtkprivate.h"
 #include "gtkwidgetprivate.h"
 
@@ -85,7 +85,8 @@ gtk_separator_set_property (GObject      *object,
       if (separator->orientation != g_value_get_enum (value))
         {
           separator->orientation = g_value_get_enum (value);
-          _gtk_orientable_set_style_classes (GTK_ORIENTABLE (object));
+          gtk_widget_update_orientation (GTK_WIDGET (object),
+                                         separator->orientation);
           gtk_widget_queue_resize (GTK_WIDGET (object));
           g_object_notify_by_pspec (object, pspec);
         }
@@ -120,7 +121,8 @@ gtk_separator_init (GtkSeparator *separator)
 {
   separator->orientation = GTK_ORIENTATION_HORIZONTAL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (separator));
+  gtk_widget_update_orientation (GTK_WIDGET (separator),
+                                 separator->orientation);
 }
 
 static void
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index b159d341e5..5a80cbbe2d 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -47,7 +47,6 @@
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
 #include "gtkorientable.h"
-#include "gtkorientableprivate.h"
 #include "gtkprivate.h"
 #include "gtksettings.h"
 #include "gtkstylecontextprivate.h"
@@ -922,7 +921,8 @@ gtk_spin_button_init (GtkSpinButton *spin_button)
 
   spin_button->orientation = GTK_ORIENTATION_HORIZONTAL;
 
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin_button));
+  gtk_widget_update_orientation (GTK_WIDGET (spin_button),
+                                 spin_button->orientation);
 
   spin_button->entry = gtk_text_new ();
   gtk_editable_init_delegate (GTK_EDITABLE (spin_button));
@@ -1089,7 +1089,7 @@ gtk_spin_button_set_orientation (GtkSpinButton  *spin,
     return;
 
   spin->orientation = orientation;
-  _gtk_orientable_set_style_classes (GTK_ORIENTABLE (spin));
+  gtk_widget_update_orientation (GTK_WIDGET (spin), spin->orientation);
 
   /* change alignment if it's the default */
   if (spin->orientation == GTK_ORIENTATION_VERTICAL &&
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 73142cc234..ea37424cce 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -31,6 +31,7 @@
 #include "gtkapplicationprivate.h"
 #include "gtkbuildable.h"
 #include "gtkbuilderprivate.h"
+#include "gtkconstraint.h"
 #include "gtkcssboxesprivate.h"
 #include "gtkcssfiltervalueprivate.h"
 #include "gtkcsstransformvalueprivate.h"
@@ -48,12 +49,12 @@
 #include "gtklayoutmanagerprivate.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
+#include "gtknativeprivate.h"
 #include "gtkpopover.h"
 #include "gtkprivate.h"
 #include "gtkrenderbackgroundprivate.h"
 #include "gtkrenderborderprivate.h"
 #include "gtkrootprivate.h"
-#include "gtknativeprivate.h"
 #include "gtkscrollable.h"
 #include "gtksettingsprivate.h"
 #include "gtkshortcut.h"
@@ -71,8 +72,6 @@
 #include "gtkwidgetpaintableprivate.h"
 #include "gtkwindowgroup.h"
 #include "gtkwindowprivate.h"
-#include "gtknativeprivate.h"
-#include "gtkconstraint.h"
 
 #include "a11y/gtkwidgetaccessibleprivate.h"
 #include "inspector/window.h"
@@ -12776,3 +12775,29 @@ gtk_widget_set_css_classes (GtkWidget   *widget,
   gtk_css_node_set_classes (priv->cssnode, classes);
   g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
 }
+
+/*< private >
+ * gtk_widget_update_orientation:
+ * @widget: a #GtkWidget implementing #GtkOrientable
+ * @orientation: the orientation
+ *
+ * Update the internal state associated to the given @orientation of a
+ * #GtkWidget.
+ */
+void
+gtk_widget_update_orientation (GtkWidget      *widget,
+                               GtkOrientation  orientation)
+{
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+
+  if (orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
+      gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
+      gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
+    }
+  else
+    {
+      gtk_widget_add_css_class (widget, GTK_STYLE_CLASS_VERTICAL);
+      gtk_widget_remove_css_class (widget, GTK_STYLE_CLASS_HORIZONTAL);
+    }
+}
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 639cb84bb5..43e37aaed8 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -369,6 +369,9 @@ gboolean gtk_widget_grab_focus_self  (GtkWidget        *widget);
 gboolean gtk_widget_focus_self       (GtkWidget        *widget,
                                       GtkDirectionType  direction);
 
+void    gtk_widget_update_orientation   (GtkWidget      *widget,
+                                         GtkOrientation  orientation);
+
 /* inline getters */
 
 static inline GtkWidget *


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