From: António Fernandes Date: Fri, 2 Sep 2022 14:44:59 +0000 (+0100) Subject: columnview: Invert columns on RTL X-Git-Tag: archive/raspbian/4.8.3+ds-2+rpi1~3^2~20^2~2^2~27^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=91e6f8e4b9d504ead3cee50fe6f763ac71d7f0b0;p=gtk4.git columnview: Invert columns on RTL Respect text direction. Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2302 --- diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c index d16a4373b0..c46b7d8309 100644 --- a/gtk/gtkcolumnview.c +++ b/gtk/gtkcolumnview.c @@ -376,17 +376,24 @@ static int gtk_column_view_allocate_columns (GtkColumnView *self, int width) { + gboolean rtl; guint i, n; - int x; + int total_width, x; GtkRequestedSize *sizes; + rtl = gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_RTL; + n = g_list_model_get_n_items (G_LIST_MODEL (self->columns)); sizes = g_newa (GtkRequestedSize, n); gtk_column_view_distribute_width (self, width, sizes); - x = 0; + total_width = 0; + for (i = 0; i < n; i++) + total_width += sizes[i].minimum_size; + + x = rtl ? total_width : 0; for (i = 0; i < n; i++) { GtkColumnViewColumn *column; @@ -397,17 +404,21 @@ gtk_column_view_allocate_columns (GtkColumnView *self, { col_size = sizes[i].minimum_size; + if (rtl) + x -= col_size; + gtk_column_view_column_allocate (column, x, col_size); if (self->in_column_reorder && i == self->drag_pos) gtk_column_view_column_set_header_position (column, self->drag_x); - x += col_size; + if (!rtl) + x += col_size; } g_object_unref (column); } - return x; + return total_width; } static void