diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 8481d45bad..f175815124 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -219,6 +219,7 @@ struct _GtkNotebookPrivate guint show_tabs : 1; guint scrollable : 1; guint tab_pos : 2; + guint tabs_reversed : 1; }; enum { @@ -1290,6 +1291,11 @@ gtk_notebook_init (GtkNotebook *notebook) priv->during_detach = FALSE; priv->has_scrolled = FALSE; + if (gtk_widget_get_direction (GTK_WIDGET (notebook)) == GTK_TEXT_DIR_RTL) + priv->tabs_reversed = TRUE; + else + priv->tabs_reversed = FALSE; + gtk_drag_dest_set (GTK_WIDGET (notebook), 0, notebook_targets, G_N_ELEMENTS (notebook_targets), GDK_ACTION_MOVE); @@ -1825,49 +1831,17 @@ static void update_node_ordering (GtkNotebook *notebook) { GtkNotebookPrivate *priv = notebook->priv; - GtkPositionType tab_pos; - gboolean is_rtl; - GtkCssNode *node, *header_node, *tabs_node; + gboolean reverse_tabs; - tab_pos = get_effective_tab_pos (notebook); - is_rtl = gtk_widget_get_direction (GTK_WIDGET (notebook)) == GTK_TEXT_DIR_RTL; - header_node = gtk_css_gadget_get_node (priv->header_gadget); - tabs_node = gtk_css_gadget_get_node (priv->tabs_gadget); + reverse_tabs = (priv->tab_pos == GTK_POS_TOP || priv->tab_pos == GTK_POS_BOTTOM) && + gtk_widget_get_direction (GTK_WIDGET (notebook)) == GTK_TEXT_DIR_RTL; - switch (tab_pos) + if ((reverse_tabs && !priv->tabs_reversed) || + (!reverse_tabs && priv->tabs_reversed)) { - case GTK_POS_TOP: - case GTK_POS_BOTTOM: - if (priv->action_widget[ACTION_WIDGET_START]) - { - node = gtk_widget_get_css_node (priv->action_widget[ACTION_WIDGET_START]); - if (is_rtl) - gtk_css_node_insert_after (header_node, node, tabs_node); - else - gtk_css_node_insert_before (header_node, node, tabs_node); - } - if (priv->action_widget[ACTION_WIDGET_END]) - { - node = gtk_widget_get_css_node (priv->action_widget[ACTION_WIDGET_END]); - if (is_rtl) - gtk_css_node_insert_before (header_node, node, tabs_node); - else - gtk_css_node_insert_after (header_node, node, tabs_node); - } - break; - case GTK_POS_LEFT: - case GTK_POS_RIGHT: - if (priv->action_widget[ACTION_WIDGET_START]) - { - node = gtk_widget_get_css_node (priv->action_widget[ACTION_WIDGET_START]); - gtk_css_node_insert_before (header_node, node, tabs_node); - } - if (priv->action_widget[ACTION_WIDGET_END]) - { - node = gtk_widget_get_css_node (priv->action_widget[ACTION_WIDGET_END]); - gtk_css_node_insert_after (header_node, node, tabs_node); - } - break; + gtk_box_gadget_reverse_children (GTK_BOX_GADGET (priv->header_gadget)); + gtk_css_node_reverse_children (gtk_css_gadget_get_node (priv->tabs_gadget)); + priv->tabs_reversed = reverse_tabs; } } @@ -4767,6 +4741,9 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook, else sibling = priv->arrow_gadget[ARROW_RIGHT_AFTER]; + if (priv->tabs_reversed) + gtk_css_node_reverse_children (gtk_css_gadget_get_node (priv->tabs_gadget)); + page->gadget = gtk_css_custom_gadget_new ("tab", GTK_WIDGET (notebook), priv->tabs_gadget, @@ -4776,6 +4753,9 @@ gtk_notebook_real_insert_page (GtkNotebook *notebook, draw_tab, page, NULL); + if (priv->tabs_reversed) + gtk_css_node_reverse_children (gtk_css_gadget_get_node (priv->tabs_gadget)); + gtk_css_gadget_set_state (page->gadget, gtk_css_node_get_state (gtk_css_gadget_get_node (priv->tabs_gadget))); if (!tab_label) @@ -7050,6 +7030,8 @@ gtk_notebook_update_tab_pos (GtkNotebook *notebook) gtk_box_gadget_set_orientation (GTK_BOX_GADGET (priv->header_gadget), GTK_ORIENTATION_VERTICAL); break; } + + update_node_ordering (notebook); } /** @@ -8017,14 +7999,19 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook, if (widget) { + int pos; + gtk_css_node_set_parent (gtk_widget_get_css_node (widget), gtk_css_gadget_get_node (priv->header_gadget)); - gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->header_gadget), - pack_type == GTK_PACK_START ? 0 : -1, - widget); + + if (priv->tabs_reversed) + pos = pack_type == GTK_PACK_START ? -1 : 0; + else + pos = pack_type == GTK_PACK_START ? 0 : -1; + + gtk_box_gadget_insert_widget (GTK_BOX_GADGET (priv->header_gadget), pos, widget); gtk_widget_set_child_visible (widget, priv->show_tabs); gtk_widget_set_parent (widget, GTK_WIDGET (notebook)); - update_node_ordering (notebook); } gtk_widget_queue_resize (GTK_WIDGET (notebook)); diff --git a/testsuite/css/nodes/Makefile.am b/testsuite/css/nodes/Makefile.am index c00eaef18b..10dcc27ae4 100644 --- a/testsuite/css/nodes/Makefile.am +++ b/testsuite/css/nodes/Makefile.am @@ -28,23 +28,27 @@ test_css_nodes_SOURCES = \ $(NULL) test_data = \ - box.ltr.ui box.ltr.nodes \ - box.rtl.ui box.rtl.nodes \ - buttons.ui buttons.nodes \ - checkbutton.ltr.ui checkbutton.ltr.nodes \ - checkbutton.rtl.ui checkbutton.rtl.nodes \ - entries.ui entries.nodes \ - expander.ltr.ui expander.ltr.nodes \ - expander.rtl.ui expander.rtl.nodes \ - levelbar.ltr.ui levelbar.ltr.nodes \ - levelbar.rtl.ui levelbar.rtl.nodes \ - notebook.top.ui notebook.top.nodes \ - notebook.left.ui notebook.left.nodes \ - notebook.right.ui notebook.right.nodes \ - notebook.bottom.ui notebook.bottom.nodes \ - paned.ltr.ui paned.ltr.nodes \ - paned.rtl.ui paned.rtl.nodes \ - progressbar.ui progressbar.nodes \ + box.ltr.ui box.ltr.nodes \ + box.rtl.ui box.rtl.nodes \ + buttons.ui buttons.nodes \ + checkbutton.ltr.ui checkbutton.ltr.nodes \ + checkbutton.rtl.ui checkbutton.rtl.nodes \ + entries.ui entries.nodes \ + expander.ltr.ui expander.ltr.nodes \ + expander.rtl.ui expander.rtl.nodes \ + levelbar.ltr.ui levelbar.ltr.nodes \ + levelbar.rtl.ui levelbar.rtl.nodes \ + notebook.top.ltr.ui notebook.top.ltr.nodes \ + notebook.top.rtl.ui notebook.top.rtl.nodes \ + notebook.left.ltr.ui notebook.left.ltr.nodes \ + notebook.left.rtl.ui notebook.left.rtl.nodes \ + notebook.right.ltr.ui notebook.right.ltr.nodes \ + notebook.right.rtl.ui notebook.right.rtl.nodes \ + notebook.bottom.ltr.ui notebook.bottom.ltr.nodes \ + notebook.bottom.rtl.ui notebook.bottom.rtl.nodes \ + paned.ltr.ui paned.ltr.nodes \ + paned.rtl.ui paned.rtl.nodes \ + progressbar.ui progressbar.nodes \ $(NULL) EXTRA_DIST += $(test_in_files) $(test_data) diff --git a/testsuite/css/nodes/notebook.bottom.nodes b/testsuite/css/nodes/notebook.bottom.ltr.nodes similarity index 100% rename from testsuite/css/nodes/notebook.bottom.nodes rename to testsuite/css/nodes/notebook.bottom.ltr.nodes diff --git a/testsuite/css/nodes/notebook.bottom.ui b/testsuite/css/nodes/notebook.bottom.ltr.ui similarity index 100% rename from testsuite/css/nodes/notebook.bottom.ui rename to testsuite/css/nodes/notebook.bottom.ltr.ui diff --git a/testsuite/css/nodes/notebook.bottom.rtl.nodes b/testsuite/css/nodes/notebook.bottom.rtl.nodes new file mode 100644 index 0000000000..fdf8204b80 --- /dev/null +++ b/testsuite/css/nodes/notebook.bottom.rtl.nodes @@ -0,0 +1,18 @@ +[window.background:dir(rtl)] + decoration:dir(ltr) + notebook.frame:dir(rtl) + stack:dir(ltr) + button#page1.text-button:dir(rtl) + label:dir(ltr) + button#page2.text-button:dir(rtl) + label:dir(ltr) + header.bottom:dir(ltr) + button#end.text-button:dir(rtl) + label:dir(ltr) + tabs:dir(ltr) + tab:dir(ltr) + label#tab2:dir(ltr) + tab:active:dir(ltr) + label#tab1:dir(ltr) + button#start.text-button:dir(rtl) + label:dir(ltr) diff --git a/testsuite/css/nodes/notebook.bottom.rtl.ui b/testsuite/css/nodes/notebook.bottom.rtl.ui new file mode 100644 index 0000000000..176d2b8664 --- /dev/null +++ b/testsuite/css/nodes/notebook.bottom.rtl.ui @@ -0,0 +1,56 @@ + + + + + False + popup + + + True + bottom + + + page1 + Yes + True + + + + + tab1 + Tab 1 + True + + + + + page2 + No + True + + + + + tab2 + Tab 2 + True + + + + + start + Action + True + + + + + end + Action + True + + + + + + diff --git a/testsuite/css/nodes/notebook.left.nodes b/testsuite/css/nodes/notebook.left.ltr.nodes similarity index 100% rename from testsuite/css/nodes/notebook.left.nodes rename to testsuite/css/nodes/notebook.left.ltr.nodes diff --git a/testsuite/css/nodes/notebook.left.ui b/testsuite/css/nodes/notebook.left.ltr.ui similarity index 100% rename from testsuite/css/nodes/notebook.left.ui rename to testsuite/css/nodes/notebook.left.ltr.ui diff --git a/testsuite/css/nodes/notebook.left.rtl.nodes b/testsuite/css/nodes/notebook.left.rtl.nodes new file mode 100644 index 0000000000..b1d4e2fb84 --- /dev/null +++ b/testsuite/css/nodes/notebook.left.rtl.nodes @@ -0,0 +1,18 @@ +[window.background:dir(rtl)] + decoration:dir(ltr) + notebook.frame:dir(rtl) + stack:dir(ltr) + button#page1.text-button:dir(rtl) + label:dir(ltr) + button#page2.text-button:dir(rtl) + label:dir(ltr) + header.right:dir(ltr) + button#start.text-button:dir(rtl) + label:dir(ltr) + tabs:dir(ltr) + tab:active:dir(ltr) + label#tab1:dir(ltr) + tab:dir(ltr) + label#tab2:dir(ltr) + button#end.text-button:dir(rtl) + label:dir(ltr) diff --git a/testsuite/css/nodes/notebook.left.rtl.ui b/testsuite/css/nodes/notebook.left.rtl.ui new file mode 100644 index 0000000000..6c2d820ac0 --- /dev/null +++ b/testsuite/css/nodes/notebook.left.rtl.ui @@ -0,0 +1,56 @@ + + + + + False + popup + + + True + left + + + page1 + Yes + True + + + + + tab1 + Tab 1 + True + + + + + page2 + No + True + + + + + tab2 + Tab 2 + True + + + + + start + Action + True + + + + + end + Action + True + + + + + + diff --git a/testsuite/css/nodes/notebook.right.nodes b/testsuite/css/nodes/notebook.right.ltr.nodes similarity index 100% rename from testsuite/css/nodes/notebook.right.nodes rename to testsuite/css/nodes/notebook.right.ltr.nodes diff --git a/testsuite/css/nodes/notebook.right.ui b/testsuite/css/nodes/notebook.right.ltr.ui similarity index 100% rename from testsuite/css/nodes/notebook.right.ui rename to testsuite/css/nodes/notebook.right.ltr.ui diff --git a/testsuite/css/nodes/notebook.right.rtl.nodes b/testsuite/css/nodes/notebook.right.rtl.nodes new file mode 100644 index 0000000000..fe9dd83a85 --- /dev/null +++ b/testsuite/css/nodes/notebook.right.rtl.nodes @@ -0,0 +1,18 @@ +[window.background:dir(rtl)] + decoration:dir(ltr) + notebook.frame:dir(rtl) + header.left:dir(ltr) + button#start.text-button:dir(rtl) + label:dir(ltr) + tabs:dir(ltr) + tab:active:dir(ltr) + label#tab1:dir(ltr) + tab:dir(ltr) + label#tab2:dir(ltr) + button#end.text-button:dir(rtl) + label:dir(ltr) + stack:dir(ltr) + button#page1.text-button:dir(rtl) + label:dir(ltr) + button#page2.text-button:dir(rtl) + label:dir(ltr) diff --git a/testsuite/css/nodes/notebook.right.rtl.ui b/testsuite/css/nodes/notebook.right.rtl.ui new file mode 100644 index 0000000000..7bea7d947e --- /dev/null +++ b/testsuite/css/nodes/notebook.right.rtl.ui @@ -0,0 +1,56 @@ + + + + + False + popup + + + True + right + + + page1 + Yes + True + + + + + tab1 + Tab 1 + True + + + + + page2 + No + True + + + + + tab2 + Tab 2 + True + + + + + start + Action + True + + + + + end + Action + True + + + + + + diff --git a/testsuite/css/nodes/notebook.top.nodes b/testsuite/css/nodes/notebook.top.ltr.nodes similarity index 100% rename from testsuite/css/nodes/notebook.top.nodes rename to testsuite/css/nodes/notebook.top.ltr.nodes diff --git a/testsuite/css/nodes/notebook.top.ui b/testsuite/css/nodes/notebook.top.ltr.ui similarity index 100% rename from testsuite/css/nodes/notebook.top.ui rename to testsuite/css/nodes/notebook.top.ltr.ui diff --git a/testsuite/css/nodes/notebook.top.rtl.nodes b/testsuite/css/nodes/notebook.top.rtl.nodes new file mode 100644 index 0000000000..4d460491f8 --- /dev/null +++ b/testsuite/css/nodes/notebook.top.rtl.nodes @@ -0,0 +1,18 @@ +[window.background:dir(rtl)] + decoration:dir(ltr) + notebook.frame:dir(rtl) + header.top:dir(ltr) + button#end.text-button:dir(rtl) + label:dir(ltr) + tabs:dir(ltr) + tab:dir(ltr) + label#tab2:dir(ltr) + tab:active:dir(ltr) + label#tab1:dir(ltr) + button#start.text-button:dir(rtl) + label:dir(ltr) + stack:dir(ltr) + button#page1.text-button:dir(rtl) + label:dir(ltr) + button#page2.text-button:dir(rtl) + label:dir(ltr) diff --git a/testsuite/css/nodes/notebook.top.rtl.ui b/testsuite/css/nodes/notebook.top.rtl.ui new file mode 100644 index 0000000000..a080a52d1d --- /dev/null +++ b/testsuite/css/nodes/notebook.top.rtl.ui @@ -0,0 +1,55 @@ + + + + + False + popup + + + True + + + page1 + Yes + True + + + + + tab1 + Tab 1 + True + + + + + page2 + No + True + + + + + tab2 + Tab 2 + True + + + + + start + Action + True + + + + + end + Action + True + + + + + +