[PATCH] Icon view RTL layout



The attached patch makes Nautilus lay out icons in the icon view lay out
from right to left instead of using LTR.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.410
diff -u -p -r1.410 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	27 Feb 2006 14:03:58 -0000	1.410
+++ libnautilus-private/nautilus-icon-container.c	27 Feb 2006 18:42:47 -0000
@@ -937,16 +937,30 @@ lay_down_one_line (NautilusIconContainer
 	double x, y_offset;
 	IconPositions *position;
 	int i;
+	gboolean is_rtl;
 
-	/* FIXME: Should layout differently when in RTL base mode */
+	g_assert (line_start != NULL);
+
+	if (line_end == NULL) {
+		line_end = g_list_last (line_start);
+	}
+
+	is_rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL;
+	if (is_rtl) {
+		i = g_list_position (line_start, line_end);
+		p = line_end;
+	} else {
+		i = 0;
+		p = line_start;
+	}
 
 	/* Lay out the icons along the baseline. */
 	x = ICON_PAD_LEFT;
-	i = 0;
-	for (p = line_start; p != line_end; p = p->next) {
+
+	while (1) {
 		icon = p->data;
 
-		position = &g_array_index (positions, IconPositions, i++);
+		position = &g_array_index (positions, IconPositions, is_rtl ? i-- : i++);
 		
 		if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
 			y_offset = (max_height - position->height) / 2;
@@ -960,6 +974,18 @@ lay_down_one_line (NautilusIconContainer
 			 y + y_offset);
 
 		x += position->width;
+
+		if (is_rtl) {
+			if (p == line_start) {
+				break;
+			}
+			p = p->prev;
+		} else {
+			if (p == line_end) {
+				break;
+			}
+			p = p->next;
+		}
 	}
 }
 
@@ -1069,7 +1095,7 @@ lay_down_icons_horizontal (NautilusIconC
 				y += ICON_PAD_TOP + max_height_above;
 			}
 
-			lay_down_one_line (container, line_start, p, y, max_height_above, positions);
+			lay_down_one_line (container, line_start, p->prev, y, max_height_above, positions);
 			
 			if (container->details->label_position == NAUTILUS_ICON_LABEL_POSITION_BESIDE) {
 				y += max_height_above + max_height_below + ICON_PAD_BOTTOM;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]