[evolution-patches] [gtkhtml] rtl fixes



Hi,

attached patch enhances RTL support by using keymap direction and also saves direction to html tags.

Cheers
Radek
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/ChangeLog,v
retrieving revision 1.2095
diff -u -p -r1.2095 ChangeLog
--- ChangeLog	21 Feb 2005 17:44:41 -0000	1.2095
+++ ChangeLog	28 Feb 2005 13:40:52 -0000
@@ -1,3 +1,25 @@
+2005-02-28  Radek Doulik  <rodo novell com>
+
+	* htmltext.c (html_text_direction_pango_to_html): new helper
+	function to convert pango direction to gtkhtml's html direction
+
+	* htmlengine.c: parse BR and P direction attribute
+
+	* htmlengine-save.c: save body direction
+
+	* htmlengine-edit.c (html_engine_edit_set_direction): new helper
+	function to set direction to cursor flow
+
+	* htmlengine-edit-cut-and-paste.c
+	(html_engine_insert_empty_paragraph): use keymap direction for new
+	flow
+
+	* htmlclueflow.c: save direction to HTML output
+
+	* gtkhtml.c: use keymap_direction signal on keymap to set flow
+	direction. handle widget's direction changed signal to set body
+	direction.
+
 2005-02-21  Radek Doulik  <rodo novell com>
 
 	* htmltextslave.c (html_text_slave_get_glyph_item_at_offset): add
Index: gtkhtml.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/gtkhtml.c,v
retrieving revision 1.589
diff -u -p -r1.589 gtkhtml.c
--- gtkhtml.c	9 Feb 2005 14:36:59 -0000	1.589
+++ gtkhtml.c	28 Feb 2005 13:41:18 -0000
@@ -25,6 +25,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdkprivate.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtkwidget.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <string.h>
@@ -34,6 +35,7 @@
 #include "../a11y/factory.h"
 
 #include "htmlcolorset.h"
+#include "htmlcluev.h"
 #include "htmlcursor.h"
 #include "htmldrawqueue.h"
 #include "htmlengine-edit.h"
@@ -1821,6 +1823,14 @@ button_release_event (GtkWidget *initial
 	return TRUE;
 }
 
+static void
+gtk_html_keymap_direction_changed (GdkKeymap *keymap, GtkHTML *html)
+{
+	if (html_engine_get_editable (html->engine)) {
+		html_engine_edit_set_direction (html->engine, html_text_direction_pango_to_html (gdk_keymap_get_direction (keymap)));
+	}		
+}
+
 static gint
 focus_in_event (GtkWidget *widget,
 		GdkEventFocus *event)
@@ -1840,6 +1850,11 @@ focus_in_event (GtkWidget *widget,
 	html->priv->need_im_reset = TRUE;
 	gtk_im_context_focus_in (html->priv->im_context);
 
+	gtk_html_keymap_direction_changed (gdk_keymap_get_for_display (gtk_widget_get_display (widget)),
+					   html);
+	g_signal_connect (gdk_keymap_get_for_display (gtk_widget_get_display (widget)),
+			  "direction_changed", G_CALLBACK (gtk_html_keymap_direction_changed), html);
+
 	return FALSE;
 }
 
@@ -1860,6 +1875,9 @@ focus_out_event (GtkWidget *widget,
 	html->priv->need_im_reset = TRUE;
 	gtk_im_context_focus_out (html->priv->im_context);
 
+	g_signal_handlers_disconnect_by_func (gdk_keymap_get_for_display (gtk_widget_get_display (widget)),
+					      gtk_html_keymap_direction_changed, html);
+
 	return FALSE;
 }
 
@@ -2672,6 +2690,33 @@ client_notify_monospace_font (GConfClien
 	}
 }
 
+static void 
+gtk_html_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir)
+{
+	GtkHTML *html = GTK_HTML (widget);
+
+	if (html->engine->clue) {
+		HTMLDirection old_direction = html_object_get_direction (html->engine->clue);
+
+		switch (gtk_widget_get_direction (widget)) {
+		case GTK_TEXT_DIR_NONE:
+			HTML_CLUEV (html->engine->clue)->dir = HTML_DIRECTION_DERIVED;
+			break;
+		case GTK_TEXT_DIR_LTR:
+			HTML_CLUEV (html->engine->clue)->dir = HTML_DIRECTION_LTR;
+			break;
+		case GTK_TEXT_DIR_RTL:
+			HTML_CLUEV (html->engine->clue)->dir = HTML_DIRECTION_RTL;
+			break;
+		}
+			
+		if (old_direction != html_object_get_direction (html->engine->clue))
+			html_engine_schedule_update (html->engine);
+	}
+
+	GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
+}
+
 static void
 gtk_html_class_init (GtkHTMLClass *klass)
 {
@@ -3020,6 +3065,7 @@ gtk_html_class_init (GtkHTMLClass *klass
 	widget_class->drag_data_received = drag_data_received;
 	widget_class->drag_motion = drag_motion;
 	widget_class->focus = focus;
+	widget_class->direction_changed = gtk_html_direction_changed;
 
 	container_class->set_focus_child = set_focus_child;
 
Index: htmlclueflow.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlclueflow.c,v
retrieving revision 1.320
diff -u -p -r1.320 htmlclueflow.c
--- htmlclueflow.c	11 Feb 2005 15:40:25 -0000	1.320
+++ htmlclueflow.c	28 Feb 2005 13:41:53 -0000
@@ -375,6 +375,7 @@ merge (HTMLObject *self, HTMLObject *wit
 		HTML_CLUE  (cf1)->halign = HTML_CLUE (cf2)->halign;
 		HTML_CLUE  (cf1)->valign = HTML_CLUE (cf2)->valign;
 		html_object_copy_data_from_object (self, with);
+		cf1->dir = cf2->dir;
 	}
 
 	rv = (* HTML_OBJECT_CLASS (parent_class)->merge) (self, with, e, left, right, cursor);
@@ -1605,6 +1606,28 @@ save_indent_string (HTMLClueFlow *self, 
 	return retval;
 }
 
+static char *
+get_p_str (HTMLClueFlow *self, HTMLEngineSaveState *state)
+{
+	char *p_str = NULL;
+
+	if (self->dir != html_object_get_direction (state->engine->clue)) {
+		switch (self->dir) {
+		case HTML_DIRECTION_RTL:
+			p_str = "<P DIR=RTL>\n";
+			break;
+		case HTML_DIRECTION_LTR:
+			if (html_object_get_direction (state->engine->clue) != HTML_DIRECTION_DERIVED)
+				p_str = "<P DIR=LTR>\n";
+			break;
+		default:
+			;
+		}
+	}
+
+	return p_str;
+}
+
 static gboolean
 write_flow_tag (HTMLClueFlow *self, HTMLEngineSaveState *state) 
 {
@@ -1612,13 +1635,37 @@ write_flow_tag (HTMLClueFlow *self, HTML
 	HTMLClueFlow *next = NULL;
 	HTMLClueFlow *prev = NULL;
 	HTMLHAlignType halign;
-	
+	char *br_str = "<BR>\n";
+
 	if (HTML_IS_CLUEFLOW (HTML_OBJECT (self)->next))
 		next = HTML_CLUEFLOW (HTML_OBJECT (self)->next);
 	    
 	if (HTML_IS_CLUEFLOW (HTML_OBJECT (self)->prev))
 		prev = HTML_CLUEFLOW (HTML_OBJECT (self)->prev);
 
+	if (next && next->dir != html_object_get_direction (state->engine->clue)) {
+		switch (next->dir) {
+		case HTML_DIRECTION_RTL:
+			br_str = "<BR DIR=RTL>\n";
+			break;
+		case HTML_DIRECTION_LTR:
+			if (html_object_get_direction (state->engine->clue) != HTML_DIRECTION_DERIVED)
+				br_str = "<BR DIR=LTR>\n";
+			break;
+		default:
+			;
+		}
+	}
+
+	if (!prev) {
+		char *p_str = get_p_str (self, state);
+
+		if (p_str) {
+			if (! html_engine_save_output_string (state, p_str))
+				return FALSE;
+		}
+	}
+
 	d = get_similar_depth (self, prev);
 	if (is_item (self)) {
 		char *li = get_list_start_tag (self);
@@ -1666,13 +1713,13 @@ write_flow_tag (HTMLClueFlow *self, HTML
 
 	if (is_item (self)) {
 		if (next && is_levels_equal (self, next) && !is_item (next) && !html_clueflow_contains_table (self)) {
-			if (!html_engine_save_output_string (state, "<BR>\n"))
+			if (!html_engine_save_output_string (state, br_str))
 				return FALSE;
 		} else if (!html_engine_save_output_string (state, "\n"))
 			return FALSE;
 	} else if (is_levels_equal (self, next) && self->style == next->style) {
 		if (self->style != HTML_CLUEFLOW_STYLE_PRE && !html_clueflow_contains_table (self)) {
-			if (!html_engine_save_output_string (state, "<BR>\n"))
+			if (!html_engine_save_output_string (state, br_str))
 				return FALSE;
 		} else {
 			if (!html_engine_save_output_string (state, "\n"))
@@ -1683,7 +1730,7 @@ write_flow_tag (HTMLClueFlow *self, HTML
 
 		if (self->style != HTML_CLUEFLOW_STYLE_PRE) {
 			if ((!html_clueflow_contains_table (self) && !end && next && self->style == next->style) || html_clueflow_is_empty (self)) {
-				if (!html_engine_save_output_string (state, "<BR>\n"))
+				if (!html_engine_save_output_string (state, br_str))
 					return FALSE;
 			} else {
 				if (!html_engine_save_output_string (state, "\n"))
@@ -1700,6 +1747,21 @@ write_flow_tag (HTMLClueFlow *self, HTML
 		}
 	}
 	
+	if (!next) {
+		if (HTML_OBJECT (self)->parent && html_object_is_clue (HTML_OBJECT (self)->parent)) {
+			HTMLObject *head = HTML_CLUE (HTML_OBJECT (self)->parent)->head;
+
+			if (head && HTML_IS_CLUEFLOW (head)) {
+				char *head_p_str = get_p_str (HTML_CLUEFLOW (head), state);
+
+				if (head_p_str) {
+					if (! html_engine_save_output_string (state, "</P>\n"))
+						return FALSE;
+				}
+			}
+		}
+	}
+
 	return TRUE;
 }
 
@@ -2386,17 +2448,7 @@ html_clueflow_real_get_direction (HTMLOb
 				if (child == HTML_CLUE (o)->head && html_object_get_length (child) == 0 && o->prev)
 					return html_object_get_direction (o->prev);
 
-				PangoDirection pdir = html_text_get_pango_direction (HTML_TEXT (child));
-				switch (pdir) {
-				case PANGO_DIRECTION_RTL:
-					dir = HTML_DIRECTION_RTL;
-					break;
-				case PANGO_DIRECTION_LTR:
-					dir = HTML_DIRECTION_LTR;
-					break;
-				default:
-					break;
-				}
+				dir = html_text_direction_pango_to_html (html_text_get_pango_direction (HTML_TEXT (child)));
 
 				break;
 			}
Index: htmlengine-edit-cut-and-paste.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit-cut-and-paste.c,v
retrieving revision 1.106
diff -u -p -r1.106 htmlengine-edit-cut-and-paste.c
--- htmlengine-edit-cut-and-paste.c	3 Feb 2005 17:18:43 -0000	1.106
+++ htmlengine-edit-cut-and-paste.c	28 Feb 2005 13:41:55 -0000
@@ -1200,7 +1200,15 @@ insert_empty_paragraph (HTMLEngine *e, H
 void
 html_engine_insert_empty_paragraph (HTMLEngine *e)
 {
+	HTMLClueFlow *cf;
+
+	html_engine_freeze (e);
 	insert_empty_paragraph (e, HTML_UNDO_UNDO, TRUE);
+	cf = html_object_get_flow (e->cursor->object);
+	if (cf) {
+		cf->dir = html_text_direction_pango_to_html (gdk_keymap_get_direction (gdk_keymap_get_for_display (gtk_widget_get_display (GTK_WIDGET (e->widget)))));
+	}
+	html_engine_thaw (e);
 }
 
 static char *picto_chars = "DO)(|/PQ\0:-\0:\0:-\0:\0:;=-\0:;\0:-~\0:\0:\0:-\0:\0:-\0:\0:-\0:\0:-\0:\0";
Index: htmlengine-edit.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit.c,v
retrieving revision 1.107
diff -u -p -r1.107 htmlengine-edit.c
--- htmlengine-edit.c	14 May 2004 15:54:45 -0000	1.107
+++ htmlengine-edit.c	28 Feb 2005 13:42:02 -0000
@@ -750,3 +750,15 @@ html_engine_set_title (HTMLEngine *e, co
 	e->title = g_string_new (title);
 	g_signal_emit_by_name (e, "title_changed");
 }
+
+void html_engine_edit_set_direction (HTMLEngine *e,
+				     HTMLDirection dir)
+{
+	HTMLClueFlow *cf = html_object_get_flow (e->cursor->object);
+
+	if (cf && cf->dir != dir && html_clueflow_is_empty (cf)) {
+		html_engine_freeze (e);
+		cf->dir = dir;
+		html_engine_thaw (e);
+	}
+}
Index: htmlengine-edit.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-edit.h,v
retrieving revision 1.44
diff -u -p -r1.44 htmlengine-edit.h
--- htmlengine-edit.h	12 Dec 2003 12:45:53 -0000	1.44
+++ htmlengine-edit.h	28 Feb 2005 13:42:02 -0000
@@ -84,6 +84,8 @@ gboolean                   html_engine_n
 gboolean                   html_engine_prev_cell                   (HTMLEngine                *e);
 void                       html_engine_set_title                   (HTMLEngine                *e,
 								    const gchar               *title);
+void html_engine_edit_set_direction (HTMLEngine *e,
+				     HTMLDirection dir);
 /*
   static (non instance) methods
 */
Index: htmlengine-save.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine-save.c,v
retrieving revision 1.54
diff -u -p -r1.54 htmlengine-save.c
--- htmlengine-save.c	8 Jun 2004 20:31:25 -0000	1.54
+++ htmlengine-save.c	28 Feb 2005 13:42:05 -0000
@@ -28,6 +28,7 @@
 #include <string.h>
 
 #include "config.h"
+#include "htmlcluev.h"
 #include "htmlcolor.h"
 #include "htmlengine.h"
 #include "htmlimage.h"
@@ -221,6 +222,7 @@ get_body (HTMLEngine *e)
 	gchar *bg;
 	gchar *bg_image;
 	gchar *link;
+	char *dir = NULL;
 	gchar *lm, *rm, *tm, *bm;
 	gchar *url = NULL;
 
@@ -233,6 +235,12 @@ get_body (HTMLEngine *e)
 						     (e->widget, ((HTMLImagePointer *) e->bgPixmapPtr)->url))
 		: g_strdup ("");
 	g_free (url);
+	if (HTML_CLUEV (e->clue)->dir != HTML_DIRECTION_DERIVED) {
+		if (HTML_CLUEV (e->clue)->dir == HTML_DIRECTION_RTL)
+			dir = " DIR=RTL";
+		else
+			dir = " DIR=LTR";
+	}
 
 	lm = e->leftBorder != LEFT_BORDER ? g_strdup_printf (" LEFTMARGIN=\"%d\"", e->leftBorder) : g_strdup ("");
 	rm = e->rightBorder != RIGHT_BORDER ? g_strdup_printf (" RIGHTMARGIN=\"%d\"", e->rightBorder) : g_strdup ("");
Index: htmlengine.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmlengine.c,v
retrieving revision 1.628
diff -u -p -r1.628 htmlengine.c
--- htmlengine.c	9 Feb 2005 14:21:27 -0000	1.628
+++ htmlengine.c	28 Feb 2005 13:42:44 -0000
@@ -700,7 +700,7 @@ pop_clueflow_style (HTMLEngine *e)
 
 /* Utility functions.  */
 
-static void new_flow (HTMLEngine *e, HTMLObject *clue, HTMLObject *first_object, HTMLClearType clear);
+static void new_flow (HTMLEngine *e, HTMLObject *clue, HTMLObject *first_object, HTMLClearType clear, HTMLDirection dir);
 static void close_flow (HTMLEngine *e, HTMLObject *clue);
 static void finish_flow (HTMLEngine *e, HTMLObject *clue);
 static void pop_element (HTMLEngine *e, char *name);
@@ -755,11 +755,12 @@ create_empty_text (HTMLEngine *e)
 static void
 add_line_break (HTMLEngine *e,
 		HTMLObject *clue,
-		HTMLClearType clear)
+		HTMLClearType clear,
+		HTMLDirection dir)
 {
 	if (!e->flow)
-		new_flow (e, clue, create_empty_text (e), HTML_CLEAR_NONE);
-	new_flow (e, clue, NULL, clear);
+		new_flow (e, clue, create_empty_text (e), HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
+	new_flow (e, clue, NULL, clear, dir);
 }
 
 static void
@@ -798,6 +799,7 @@ close_flow (HTMLEngine *e, HTMLObject *c
 static void
 update_flow_align (HTMLEngine *e, HTMLObject *clue)
 {
+	printf ("update flow align\n");
 	if (e->flow != NULL) {
 		if (HTML_CLUE (e->flow)->head != NULL)
 			close_flow (e, clue);
@@ -807,11 +809,14 @@ update_flow_align (HTMLEngine *e, HTMLOb
 }
 
 static void
-new_flow (HTMLEngine *e, HTMLObject *clue, HTMLObject *first_object, HTMLClearType clear)
+new_flow (HTMLEngine *e, HTMLObject *clue, HTMLObject *first_object, HTMLClearType clear, HTMLDirection dir)
 {
 	close_flow (e, clue);
 
 	e->flow = flow_new (e, current_clueflow_style (e), HTML_LIST_TYPE_BLOCKQUOTE, 0, clear);
+	HTML_CLUEFLOW (e->flow)->dir = dir;
+	if (dir == HTML_DIRECTION_RTL)
+		printf ("rtl\n");
 
 	HTML_CLUE (e->flow)->halign = current_alignment (e);
 
@@ -829,7 +834,7 @@ append_element (HTMLEngine *e,
 	e->avoid_para = FALSE;
 
 	if (e->flow == NULL)
-		new_flow (e, clue, obj, HTML_CLEAR_NONE);
+		new_flow (e, clue, obj, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 	else
 		html_clue_append (HTML_CLUE (e->flow), obj);
 }
@@ -1157,8 +1162,8 @@ block_end_p (HTMLEngine *e, HTMLObject *
 	if (e->avoid_para) {
 		finish_flow (e, clue);
 	} else {
-		new_flow (e, clue, NULL, HTML_CLEAR_NONE);
-		new_flow (e, clue, NULL, HTML_CLEAR_NONE);
+		new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
+		new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 		e->avoid_para = TRUE;
 	}
 }
@@ -1254,7 +1259,7 @@ static void
 block_end_cell (HTMLEngine *e, HTMLObject *clue, HTMLElement *elem)
 {
 	if (html_clue_is_empty (HTML_CLUE (clue)))
-		new_flow (e, clue, create_empty_text (e), HTML_CLEAR_NONE);
+		new_flow (e, clue, create_empty_text (e), HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 	pop_clue (e);
 }
 
@@ -1332,7 +1337,7 @@ new_parse_body (HTMLEngine *e, const gch
 			/* The tag used for line break when we are in <pre>...</pre> */
 			if (*str == '\n') {
 				if (e->inPre)
-					add_line_break (e, clue, HTML_CLEAR_NONE);
+					add_line_break (e, clue, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 				else {
 					char *str_copy = g_strdup (str);
 					*str_copy = ' ';
@@ -1904,31 +1909,41 @@ element_parse_p (HTMLEngine *e, HTMLObje
 {
 	if (*str != '/') {
 		HTMLStyle *style = NULL;
+		HTMLDirection dir = HTML_DIRECTION_DERIVED;
 		gchar *class = NULL;
 		gchar *token;
 
 		html_string_tokenizer_tokenize (e->st, (gchar *)(str + 2), " >");
 		while (html_string_tokenizer_has_more_tokens (e->st)) {
 			token = html_string_tokenizer_next_token (e->st);
+			printf ("p token: %s\n", token);
 			if (strncasecmp (token, "align=", 6) == 0) {
 				style = html_style_add_text_align (style, parse_halign (token + 6, HTML_HALIGN_NONE));
 			} else if (strncasecmp (token, "class=", 6) == 0) {
 				class = g_strdup (token + 6);
+			} else if (strncasecmp (token, "dir=", 4) == 0) {
+				if (!strncasecmp (token + 4, "ltr", 3))
+					dir = HTML_DIRECTION_LTR;
+				else if (!strncasecmp (token + 4, "rtl", 3))
+					dir = HTML_DIRECTION_RTL;
 			}
 		}
 		
 		push_block_element (e, ID_P, style, DISPLAY_BLOCK, block_end_p, 0, 0);
 		if (!e->avoid_para) {	
-			new_flow (e, clue, NULL, HTML_CLEAR_NONE);
-			new_flow (e, clue, NULL, HTML_CLEAR_NONE);
+			if (e->parser_clue && HTML_CLUE (e->parser_clue)->head)
+				new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
+			new_flow (e, clue, NULL, HTML_CLEAR_NONE, dir);
 		} else {
 #if 1
 			update_flow_align (e, clue);
+			if (e->flow)
+				HTML_CLUEFLOW (e->flow)->dir = dir;
 #else
 			if (e->flow)
 				HTML_CLUE (e->flow)->halign = current_alignment (e);
 			else 
-				new_flow (e, clue, NULL, HTML_CLEAR_NONE);
+				new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 
 #endif
 		}
@@ -1938,8 +1953,8 @@ element_parse_p (HTMLEngine *e, HTMLObje
 	} else {
 		pop_element (e, ID_P);
 		if (!e->avoid_para) {
-			new_flow (e, clue, NULL, HTML_CLEAR_NONE);
-			new_flow (e, clue, NULL, HTML_CLEAR_NONE);
+			new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
+			new_flow (e, clue, NULL, HTML_CLEAR_NONE, HTML_DIRECTION_DERIVED);
 			e->avoid_para = TRUE;
 		}		
 	}
@@ -1949,6 +1964,7 @@ static void
 element_parse_br (HTMLEngine *e, HTMLObject *clue, const gchar *str)
 {
 	HTMLClearType clear;
+	HTMLDirection dir = HTML_DIRECTION_DERIVED;
 	
 	clear = HTML_CLEAR_NONE;
 
@@ -1969,10 +1985,16 @@ element_parse_br (HTMLEngine *e, HTMLObj
 				clear = HTML_CLEAR_RIGHT;
 			else if (strncasecmp (token + 6, "all", 3) == 0)
 				clear = HTML_CLEAR_ALL;
+			
+		} else if (strncasecmp (token, "dir=", 4) == 0) {
+			if (!strncasecmp (token + 4, "ltr", 3))
+				dir = HTML_DIRECTION_LTR;
+			else if (!strncasecmp (token + 4, "rtl", 3))
+				dir = HTML_DIRECTION_RTL;
 		}
 	}
 	
-	add_line_break (e, clue, clear);
+	add_line_break (e, clue, clear, dir);
 }
 
 
Index: htmltext.c
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltext.c,v
retrieving revision 1.274
diff -u -p -r1.274 htmltext.c
--- htmltext.c	3 Feb 2005 17:18:43 -0000	1.274
+++ htmltext.c	28 Feb 2005 13:43:38 -0000
@@ -3687,3 +3687,16 @@ html_text_set_color (HTMLText *text, HTM
 {
 	html_text_set_color_in_range (text, color, 0, text->text_bytes);
 }
+
+HTMLDirection
+html_text_direction_pango_to_html (PangoDirection pdir)
+{
+	switch (pdir) {
+	case PANGO_DIRECTION_RTL:
+		return HTML_DIRECTION_RTL;
+	case PANGO_DIRECTION_LTR:
+		return HTML_DIRECTION_LTR;
+	default:
+		return HTML_DIRECTION_DERIVED;
+	}
+}
Index: htmltext.h
===================================================================
RCS file: /cvs/gnome/gtkhtml/src/htmltext.h,v
retrieving revision 1.71
diff -u -p -r1.71 htmltext.h
--- htmltext.h	25 Jan 2005 15:09:40 -0000	1.71
+++ htmltext.h	28 Feb 2005 13:43:39 -0000
@@ -294,36 +294,37 @@ void      html_link_set_url_and_target  
 /*
  * protected
  */
-HTMLTextPangoInfo *html_text_pango_info_new        (gint                   n);
-void               html_text_pango_info_destroy    (HTMLTextPangoInfo     *pi);
-HTMLTextPangoInfo *html_text_get_pango_info        (HTMLText              *text,
-						    HTMLPainter           *painter);
-gint               html_text_pango_info_get_index  (HTMLTextPangoInfo     *pi,
-						    gint                   byte_offset,
-						    gint                   idx);
-PangoAttribute    *html_pango_attr_font_size_new   (GtkHTMLFontStyle       style);
-void               html_pango_attr_font_size_calc  (HTMLPangoAttrFontSize *attr,
-						    HTMLEngine            *e);
-PangoAttrList     *html_text_get_attr_list         (HTMLText              *text,
-						    gint                   start_index,
-						    gint                   end_index);
-void               html_text_calc_text_size        (HTMLText              *t,
-						    HTMLPainter           *painter,
-						    gint                   start_byte_offset,
-						    guint                  len,
-						    HTMLTextPangoInfo     *pi,
-						    GList                 *glyphs,
-						    gint                  *line_offset,
-						    gint                  *width,
-						    gint                  *asc,
-						    gint                  *dsc);
-void               html_text_change_attrs          (PangoAttrList         *attr_list,
-						    GtkHTMLFontStyle       style,
-						    HTMLEngine            *e,
-						    gint                   start_index,
-						    gint                   end_index,
-						    gboolean               avoid_default_size);
-PangoDirection     html_text_get_pango_direction   (HTMLText              *text);
+HTMLTextPangoInfo *html_text_pango_info_new           (gint                   n);
+void               html_text_pango_info_destroy       (HTMLTextPangoInfo     *pi);
+HTMLTextPangoInfo *html_text_get_pango_info           (HTMLText              *text,
+						       HTMLPainter           *painter);
+gint               html_text_pango_info_get_index     (HTMLTextPangoInfo     *pi,
+						       gint                   byte_offset,
+						       gint                   idx);
+PangoAttribute    *html_pango_attr_font_size_new      (GtkHTMLFontStyle       style);
+void               html_pango_attr_font_size_calc     (HTMLPangoAttrFontSize *attr,
+						       HTMLEngine            *e);
+PangoAttrList     *html_text_get_attr_list            (HTMLText              *text,
+						       gint                   start_index,
+						       gint                   end_index);
+void               html_text_calc_text_size           (HTMLText              *t,
+						       HTMLPainter           *painter,
+						       gint                   start_byte_offset,
+						       guint                  len,
+						       HTMLTextPangoInfo     *pi,
+						       GList                 *glyphs,
+						       gint                  *line_offset,
+						       gint                  *width,
+						       gint                  *asc,
+						       gint                  *dsc);
+void               html_text_change_attrs             (PangoAttrList         *attr_list,
+						       GtkHTMLFontStyle       style,
+						       HTMLEngine            *e,
+						       gint                   start_index,
+						       gint                   end_index,
+						       gboolean               avoid_default_size);
+PangoDirection     html_text_get_pango_direction      (HTMLText              *text);
+HTMLDirection      html_text_direction_pango_to_html  (PangoDirection         pdir);
 
 gboolean  html_text_is_line_break                (PangoLogAttr  attr);
 void      html_text_remove_unwanted_line_breaks  (char         *s,


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