Re: [evolution-patches] 41498: use unicode ellipsis and fix for tight loop on small cells



Slightly modified, thanks to a crash report from danw upon trying out
the previous patch.

On Mon, 2003-04-21 at 12:07, Mike Kestner wrote:
> Here's some rework to the last patch to incorporate lewing's feedback
> and to fix a tight loop that occurred when small cells were encountered.
> 
> Mike
Index: gal/e-table/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
retrieving revision 1.886
diff -u -p -r1.886 ChangeLog
--- gal/e-table/ChangeLog	21 Apr 2003 14:18:58 -0000	1.886
+++ gal/e-table/ChangeLog	21 Apr 2003 18:41:51 -0000
@@ -1,5 +1,12 @@
 2003-04-21  Mike Kestner  <mkestner ximian com>
 
+	* e-cell-text.c (build_layout): use unicode ellipsis char for 
+	breaking lines. Use g_utf8_find_prev_char and check for failure
+	so that we don't tight loop for small cells that can't display
+	any chars.
+
+2003-04-21  Mike Kestner  <mkestner ximian com>
+
 	* e-cell-tree.c (ect_draw): use e_tree_table_adapter_node_get_next 
 	to determine how to draw sibling lines.
 	(ect_print): ditto
Index: gal/e-table/e-cell-text.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-cell-text.c,v
retrieving revision 1.123
diff -u -p -r1.123 e-cell-text.c
--- gal/e-table/e-cell-text.c	18 Apr 2003 19:51:01 -0000	1.123
+++ gal/e-table/e-cell-text.c	21 Apr 2003 18:41:51 -0000
@@ -486,18 +486,23 @@ build_layout (ECellTextView *text_view, 
 		pango_layout_set_width (layout, width * PANGO_SCALE);
 	pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
 
-	while (pango_layout_get_line_count (layout) > 1) {
+	if (pango_layout_get_line_count (layout) > 1) {
 		PangoLayoutLine *line = pango_layout_get_line (layout, 0);
 		gchar *line_text = g_strdup (pango_layout_get_text (layout));
-		gchar *last_char = g_utf8_prev_char (line_text + line->length - 1);
-		gchar *new_text;
-		while (*last_char == '.')
-			last_char = g_utf8_prev_char (last_char);
-		*last_char = '\0';
-		new_text = g_strconcat (line_text, " ...", NULL);
-		pango_layout_set_text (layout, new_text, g_utf8_strlen (new_text, -1));
+		gchar *last_char = g_utf8_find_prev_char (line_text, line_text + line->length - 1);
+		gchar ellipsis[7];
+		int len = g_unichar_to_utf8 (8230, ellipsis);
+		ellipsis[len] = '\0';
+		while (last_char && pango_layout_get_line_count (layout) > 1) {
+			gchar *new_text;
+			last_char = g_utf8_find_prev_char (line_text, last_char);
+			if (last_char)
+				*last_char = '\0';
+			new_text = g_strconcat (line_text, ellipsis, NULL);
+			pango_layout_set_text (layout, new_text, -1);
+			g_free (new_text);
+		}
 		g_free (line_text);
-		g_free (new_text);
 	}
 
 	switch (ect->justify) {


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