GtkPaned: alignment of 1st child changed between GTK 2 and 3
GtkPaned child alignment
When migrating from Gtk+-2.24 to Gtk+-3.24 you will see a slight shift in behavior of a horizontal GtkPaned, depending on the text direction:
with Gtk 2.24
|GtkPaned |childs |child1 |child2 |
|GtkTextDirection |flipped |attached to |attached to |
|:--- |:--- |:--- |:--- |
|GTK_TEXT_DIR_NONE |no |left edge |left edge |
|GTK_TEXT_DIR_LTR |no |left edge |left edge |
|GTK_TEXT_DIR_RTL |yes |left edge |left edge |
with Gtk 3.24
|GtkPaned |childs |child1 |child2 |
|GtkTextDirection |flipped |attached to |attached to |
|:--- |:--- |:--- |:--- |
|GTK_TEXT_DIR_NONE |no |right edge |left edge |
|GTK_TEXT_DIR_LTR |no |right edge |left edge |
|GTK_TEXT_DIR_RTL |yes |left edge |left edge |
left edge: means the left edge of the child is aligned to the left edge of the pane. When you reduce the size of the pane the left part of the child remains visible and the right part of the child gets hidden. This is convenient for LTR readers.
right edge: means the right edge of the child is aligned to the right edge of the pane. When you reduce the size of the pane the right part of the child remains visible and the left part of the child gets hidden. This is convenient for RTL readers.
Pitfalls
Because children are flipped depending on LTR/RTL in both Gtk versions, and child1 attachment also depends on LTR/RTL in Gtk3, it is not possible to reproduce the same behavior under Gtk3 as with Gtk2.
Because attachment of child2 does not depend on LTR/RTL, it is not possible to setup a convenient 2-pane display for RTL readers.
When you try put LTR text into the left pane and RTL text into the right pane, you will never get a convenient display.
Adding a GtkAligmnent to the children does not help.
Conclusion
child alignment should be controllable via child properties, independent of the LTR/RTL setting of the paned widget
Details
In Gtk 3.24.4 have a look at the following code lines:
the function is_rtl() in gtkpaned.c(1999)
in function gtk_paned_allocate() the calls to gtk_widget_get_direction() on line 1423,1435,1445 in gtkpaned.c
A quick fix to obtain same behaviour as with Gtk2, change line 1435 in gtkpaned.c from GTK_TEXT_DIR_LTR to GTK_TEXT_DIR_RTL
if (child1_width > child1_allocation.width)
{
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
child1_allocation.x -= child1_width - child1_allocation.width;
child1_allocation.width = child1_width;
}
Proposal
Shall i propose a patch to add a "alignment" child property based on GTK_TYPE_POSITION_TYPE ?