*
* GtkCenterBox uses a single CSS node with the 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.
+ * The first child of the #GtkCenterBox will be allocated depending on the
+ * text direction, i.e. in left-to-right layouts it will be allocated on the
+ * left and in right-to-left layouts on the right.
*
* In vertical orientation, the nodes of the children are arranged from top to
* bottom.
}
}
-static void
-update_css_node_order (GtkCenterBox *self)
-{
- GtkCssNode *parent;
- GtkCssNode *first;
- GtkCssNode *last;
-
- parent = gtk_widget_get_css_node (GTK_WIDGET (self));
-
- if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
- {
- first = self->start_widget ? gtk_widget_get_css_node (self->start_widget) : NULL;
- last = self->end_widget ? gtk_widget_get_css_node (self->end_widget) : NULL;
- }
- else
- {
- first = self->end_widget ? gtk_widget_get_css_node (self->end_widget) : NULL;
- last = self->start_widget ? gtk_widget_get_css_node (self->start_widget) : NULL;
- }
-
- if (first)
- gtk_css_node_insert_after (parent, first, NULL);
- if (last)
- gtk_css_node_insert_before (parent, last, NULL);
-}
-
-static void
-gtk_center_box_direction_changed (GtkWidget *widget,
- GtkTextDirection previous_direction)
-{
- update_css_node_order (GTK_CENTER_BOX (widget));
-}
-
static GtkSizeRequestMode
gtk_center_box_get_request_mode (GtkWidget *widget)
{
widget_class->measure = gtk_center_box_measure;
widget_class->size_allocate = gtk_center_box_size_allocate;
- widget_class->direction_changed = gtk_center_box_direction_changed;
widget_class->get_request_mode = gtk_center_box_get_request_mode;
g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
self->start_widget = child;
if (child)
- gtk_widget_set_parent (child, GTK_WIDGET (self));
-
- update_css_node_order (self);
+ gtk_widget_insert_after (child, GTK_WIDGET (self), NULL);
}
/**
self->center_widget = child;
if (child)
- gtk_widget_set_parent (child, GTK_WIDGET (self));
-
- update_css_node_order (self);
+ gtk_widget_insert_after (child, GTK_WIDGET (self), self->start_widget);
}
/**
self->end_widget = child;
if (child)
- gtk_widget_set_parent (child, GTK_WIDGET (self));
-
- update_css_node_order (self);
+ gtk_widget_insert_before (child, GTK_WIDGET (self), NULL);
}
/**