box: Don't reorder children based on text direction
authorTimm Bäder <mail@baedert.org>
Sun, 10 Jun 2018 19:54:25 +0000 (21:54 +0200)
committerTimm Bäder <mail@baedert.org>
Mon, 18 Jun 2018 15:35:02 +0000 (17:35 +0200)
Make :first-child always be the first child, i.e. the leftest one in LTR
and the rightest one in RTL.

gtk/gtkbox.c
testsuite/css/nodes/box-packing.rtl.nodes
testsuite/css/nodes/box.rtl.nodes
testsuite/css/nodes/expander.rtl.nodes

index f89c3fd3bcddd1b40d52d306d66933f742f158ca..fd0ebbb573544342990e10f0966dd92f3485ace9 100644 (file)
  * # CSS nodes
  *
  * GtkBox uses a single CSS node with name box.
- *
- * In horizontal orientation, the nodes of the children are always arranged
- * from left to right. So :first-child will always select the leftmost child,
- * regardless of text direction.
  */
 
 #include "config.h"
@@ -145,9 +141,6 @@ static void gtk_box_size_allocate         (GtkWidget              *widget,
                                            const GtkAllocation    *allocation,
                                            int                     baseline);
 
-static void gtk_box_direction_changed  (GtkWidget        *widget,
-                                        GtkTextDirection  previous_direction);
-
 static void gtk_box_set_property       (GObject        *object,
                                         guint           prop_id,
                                         const GValue   *value,
@@ -201,7 +194,6 @@ gtk_box_class_init (GtkBoxClass *class)
 
   widget_class->size_allocate = gtk_box_size_allocate;
   widget_class->measure = gtk_box_measure;
-  widget_class->direction_changed = gtk_box_direction_changed;
 
   container_class->add = gtk_box_add;
   container_class->remove = gtk_box_remove;
@@ -852,9 +844,6 @@ gtk_box_update_child_css_position (GtkBox      *box,
     }
 
   reverse = child_info->pack == GTK_PACK_END;
-  if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
-      _gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
-    reverse = !reverse;
 
   if (reverse)
     gtk_css_node_insert_before (gtk_widget_get_css_node (GTK_WIDGET (box)),
@@ -866,17 +855,6 @@ gtk_box_update_child_css_position (GtkBox      *box,
                                prev ? gtk_widget_get_css_node (prev->widget) : NULL);
 }
 
-static void
-gtk_box_direction_changed (GtkWidget        *widget,
-                           GtkTextDirection  previous_direction)
-{
-  GtkBox *box = GTK_BOX (widget);
-  GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
-
-  if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-    gtk_css_node_reverse_children (gtk_widget_get_css_node (widget));
-}
-
 static void
 gtk_box_pack (GtkBox      *box,
               GtkWidget   *child,
index 899e36b762236a2fc8924a3eeae21c6329ddedc5..b95854f09818b10053d0991955f5fe6cddadbd30 100644 (file)
@@ -1,5 +1,5 @@
 [window.background:dir(rtl)]
   decoration:dir(rtl)
   box.horizontal:dir(rtl)
-    label#end:dir(rtl)
     label#start:dir(rtl)
+    label#end:dir(rtl)
index 10f899a9875c5bbc0dd273d57caa68664d577b20..1179f23dc45d68fd9ce210c00047c806e30f3fb0 100644 (file)
@@ -1,6 +1,6 @@
 [window.background:dir(rtl)]
   decoration:dir(rtl)
   box.horizontal:dir(rtl)
-    label#label3:dir(rtl)
-    label#label2:dir(rtl)
     label#label1:dir(rtl)
+    label#label2:dir(rtl)
+    label#label3:dir(rtl)
index 7e5b7c853f4c97baa7e4004cb3a44d5bde7dfa05..30b4804e513f7d518b8b407b9129150a7ecefeb3 100644 (file)
@@ -3,5 +3,5 @@
   expander:dir(rtl)
     box.vertical:dir(rtl)
       title.horizontal:dir(rtl)
-        label:dir(rtl)
         arrow.horizontal:dir(rtl)
+        label:dir(rtl)