[gtk/wip/ebassi/a11y-2] Move orientable style classes into GtkWidget
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/ebassi/a11y-2] Move orientable style classes into GtkWidget
- Date: Thu, 23 Apr 2020 17:36:33 +0000 (UTC)
commit 20454177f866087d46af585ccd1a4d153e8bce38
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 | 8 ++++----
gtk/gtkprogressbar.c | 8 ++++----
gtk/gtkrange.c | 9 +++++----
gtk/gtkscrollbar.c | 7 ++-----
gtk/gtkseparator.c | 7 ++++---
gtk/gtkspinbutton.c | 6 +++---
gtk/gtkwidget.c | 33 ++++++++++++++++++++++++++++++---
gtk/gtkwidgetprivate.h | 3 +++
19 files changed, 102 insertions(+), 119 deletions(-)
---
diff --git a/docs/reference/gtk/meson.build b/docs/reference/gtk/meson.build
index 8b66214e207..e711e6c04b9 100644
--- a/docs/reference/gtk/meson.build
+++ b/docs/reference/gtk/meson.build
@@ -138,7 +138,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 dc3b16abb61..5fbe970b59d 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"
@@ -117,7 +116,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");
}
}
@@ -259,7 +258,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);
}
/**
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 098375973b2..d06f5983a8d 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 12132c29440..a7b5a9c3a95 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 01885bb3c73..adb5e550f14 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 e0f0a613177..4e09481cc65 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -75,19 +75,19 @@
#include <config.h>
-#include "gtkflowbox.h"
#include "gtkflowboxprivate.h"
#include "gtkadjustment.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"
@@ -95,7 +95,6 @@
#include "gtktypebuiltins.h"
#include "gtkviewport.h"
#include "gtkwidgetprivate.h"
-#include "gtkeventcontrollerkey.h"
#include "a11y/gtkflowboxaccessibleprivate.h"
#include "a11y/gtkflowboxchildaccessible.h"
@@ -3278,14 +3277,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));
@@ -3697,7 +3702,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 89af6bc3117..64251ae8f04 100644
--- a/gtk/gtkgrid.c
+++ b/gtk/gtkgrid.c
@@ -24,8 +24,8 @@
#include "gtkcsspositionvalueprivate.h"
#include "gtkgridlayout.h"
-#include "gtkorientableprivate.h"
#include "gtkintl.h"
+#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
@@ -134,7 +134,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");
}
@@ -391,7 +392,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 b77169e76f8..08fce7fbdea 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 cd9d6531dd1..c5d82a55229 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");
}
@@ -1016,7 +1014,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 4987a6c76c9..8bfb629285d 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 b39d5bd56a8..2eb4968d655 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,13 +35,12 @@
#include "gtkgizmoprivate.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
-#include "gtkorientableprivate.h"
+#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkrendericonprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
-#include "gtkcssboxesprivate.h"
#include "a11y/gtkpanedaccessible.h"
@@ -826,7 +826,7 @@ gtk_paned_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 (paned));
+ gtk_widget_update_orientation (GTK_WIDGET (paned), priv->orientation);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -1368,7 +1368,7 @@ gtk_paned_init (GtkPaned *paned)
priv->child1_shrink = TRUE;
priv->child2_shrink = TRUE;
- _gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
+ gtk_widget_update_orientation (GTK_WIDGET (paned), priv->orientation);
/* Touch gesture */
gesture = gtk_gesture_pan_new (GTK_ORIENTATION_HORIZONTAL);
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index dab0b3da3b4..fd06b55b8a4 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"
@@ -471,7 +471,7 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
/* horizontal is default */
priv->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), priv->orientation);
}
static void
@@ -960,7 +960,7 @@ gtk_progress_bar_set_orientation (GtkProgressBar *pbar,
gtk_widget_set_valign (priv->trough_widget, GTK_ALIGN_FILL);
}
- _gtk_orientable_set_style_classes (GTK_ORIENTABLE (pbar));
+ gtk_widget_update_orientation (GTK_WIDGET (pbar), priv->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 d6995fce4cd..54292f1725f 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 66cede913b3..1b414b28937 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);
}
@@ -226,8 +224,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 b83d2742289..3669c112f36 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"
@@ -92,7 +92,8 @@ gtk_separator_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 (object));
+ gtk_widget_update_orientation (GTK_WIDGET (object),
+ priv->orientation);
gtk_widget_queue_resize (GTK_WIDGET (object));
g_object_notify_by_pspec (object, pspec);
}
@@ -130,7 +131,7 @@ gtk_separator_init (GtkSeparator *separator)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
- _gtk_orientable_set_style_classes (GTK_ORIENTABLE (separator));
+ gtk_widget_update_orientation (GTK_WIDGET (separator), priv->orientation);
}
static void
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index c59ef30ab8c..3eae9b23a6d 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 b91ccb19f2a..7530fa51134 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,13 @@
#include "gtklayoutmanagerprivate.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
+#include "gtknativeprivate.h"
+#include "gtkorientable.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 +73,6 @@
#include "gtkwidgetpaintableprivate.h"
#include "gtkwindowgroup.h"
#include "gtkwindowprivate.h"
-#include "gtknativeprivate.h"
-#include "gtkconstraint.h"
#include "a11y/gtkwidgetaccessibleprivate.h"
#include "inspector/window.h"
@@ -12725,3 +12725,30 @@ 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 implementing the #GtkOrientable interface.
+ */
+void
+gtk_widget_update_orientation (GtkWidget *widget,
+ GtkOrientation orientation)
+{
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (GTK_IS_ORIENTABLE (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 f151ead6da9..8948315e13a 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -381,6 +381,9 @@ gboolean gtk_widget_focus_self (GtkWidget *widget,
gboolean gtk_widget_focus_all (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]