diff options
author | Matthias Clasen <mclasen@redhat.com> | 2016-01-13 00:40:11 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2016-01-13 00:40:11 -0500 |
commit | fb77ebe17e19c1f3061914cf41f49c067b390092 (patch) | |
tree | 70f787a2a76dfe5eaf91f178dd0c919d72b26a0f /gtk/gtkpaned.c | |
parent | 7743944124371a93c029ab0cba145b8d3aa6bf0e (diff) | |
download | gtk+-fb77ebe17e19c1f3061914cf41f49c067b390092.tar.gz |
paned: Update node ordering according to text direction
This was overlooked in the initial node conversion.
Diffstat (limited to 'gtk/gtkpaned.c')
-rw-r--r-- | gtk/gtkpaned.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index d7d791e7c1..8ea97df005 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -94,6 +94,10 @@ * the separator with name separator. The subnodes gets a .wide style * class when the paned is supposed to be wide. * + * 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. + * * ## Creating a paned widget with minimum sizes. * * |[<!-- language="C" --> @@ -227,6 +231,8 @@ static void gtk_paned_map (GtkWidget *widget); static void gtk_paned_unmap (GtkWidget *widget); static void gtk_paned_state_flags_changed (GtkWidget *widget, GtkStateFlags previous_state); +static void gtk_paned_direction_changed (GtkWidget *widget, + GtkTextDirection previous_direction); static gboolean gtk_paned_draw (GtkWidget *widget, cairo_t *cr); static gboolean gtk_paned_enter (GtkWidget *widget, @@ -334,6 +340,7 @@ gtk_paned_class_init (GtkPanedClass *class) widget_class->enter_notify_event = gtk_paned_enter; widget_class->leave_notify_event = gtk_paned_leave; widget_class->state_flags_changed = gtk_paned_state_flags_changed; + widget_class->direction_changed = gtk_paned_direction_changed; container_class->add = gtk_paned_add; container_class->remove = gtk_paned_remove; @@ -2099,6 +2106,16 @@ gtk_paned_state_flags_changed (GtkWidget *widget, GTK_WIDGET_CLASS (gtk_paned_parent_class)->state_flags_changed (widget, previous_state); } +static void +gtk_paned_direction_changed (GtkWidget *widget, + GtkTextDirection previous_direction) +{ + GtkPaned *paned = GTK_PANED (widget); + + if (paned->priv->orientation == GTK_ORIENTATION_HORIZONTAL) + gtk_css_node_reverse_children (gtk_widget_get_css_node (widget)); +} + /** * gtk_paned_new: * @orientation: the paned’s orientation. @@ -2181,7 +2198,10 @@ gtk_paned_pack1 (GtkPaned *paned, widget_node = gtk_widget_get_css_node (GTK_WIDGET (paned)); child_node = gtk_widget_get_css_node (child); - gtk_css_node_insert_before (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); + if (gtk_widget_get_direction (GTK_WIDGET (paned)) == GTK_TEXT_DIR_RTL) + gtk_css_node_insert_after (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); + else + gtk_css_node_insert_before (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); gtk_widget_set_parent_window (child, priv->child1_window); gtk_widget_set_parent (child, GTK_WIDGET (paned)); @@ -2220,7 +2240,10 @@ gtk_paned_pack2 (GtkPaned *paned, widget_node = gtk_widget_get_css_node (GTK_WIDGET (paned)); child_node = gtk_widget_get_css_node (child); - gtk_css_node_insert_after (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); + if (gtk_widget_get_direction (GTK_WIDGET (paned)) == GTK_TEXT_DIR_RTL) + gtk_css_node_insert_before (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); + else + gtk_css_node_insert_after (widget_node, child_node, gtk_css_gadget_get_node (priv->handle_gadget)); gtk_widget_set_parent_window (child, priv->child2_window); gtk_widget_set_parent (child, GTK_WIDGET (paned)); |