+ gulong remove_handler_id = g_signal_connect (text_buffer, "remove_tag",
+ G_CALLBACK (wxGtkOnRemoveTag), gpointer("WX"));
+ gtk_text_buffer_remove_all_tags(text_buffer, start, end);
+ g_signal_handler_disconnect (text_buffer, remove_handler_id);
+
+ if (attr.HasFont())
+ {
+ char *font_string;
+ PangoFontDescription *font_description = attr.GetFont().GetNativeFontInfo()->description;
+ font_string = pango_font_description_to_string(font_description);
+ g_snprintf(buf, sizeof(buf), "WXFONT %s", font_string);
+ tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
+ buf );
+ if (!tag)
+ tag = gtk_text_buffer_create_tag( text_buffer, buf,
+ "font-desc", font_description,
+ NULL );
+ gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
+ g_free (font_string);
+ }
+
+ if (attr.HasTextColour())
+ {
+ GdkColor *colFg = attr.GetTextColour().GetColor();
+ g_snprintf(buf, sizeof(buf), "WXFORECOLOR %d %d %d",
+ colFg->red, colFg->green, colFg->blue);
+ tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
+ buf );
+ if (!tag)
+ tag = gtk_text_buffer_create_tag( text_buffer, buf,
+ "foreground-gdk", colFg, NULL );
+ gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
+ }
+
+ if (attr.HasBackgroundColour())
+ {
+ GdkColor *colBg = attr.GetBackgroundColour().GetColor();
+ g_snprintf(buf, sizeof(buf), "WXBACKCOLOR %d %d %d",
+ colBg->red, colBg->green, colBg->blue);
+ tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ),
+ buf );
+ if (!tag)
+ tag = gtk_text_buffer_create_tag( text_buffer, buf,
+ "background-gdk", colBg, NULL );
+ gtk_text_buffer_apply_tag (text_buffer, tag, start, end);
+ }
+
+ if (attr.HasAlignment())
+ {
+ GtkTextIter para_start, para_end = *end;
+ gtk_text_buffer_get_iter_at_line( text_buffer,
+ ¶_start,
+ gtk_text_iter_get_line(start) );
+ gtk_text_iter_forward_line(¶_end);
+
+ remove_handler_id = g_signal_connect (text_buffer, "remove_tag",
+ G_CALLBACK(wxGtkOnRemoveTag),
+ gpointer("WXALIGNMENT"));
+ gtk_text_buffer_remove_all_tags( text_buffer, ¶_start, ¶_end );
+ g_signal_handler_disconnect (text_buffer, remove_handler_id);
+
+ GtkJustification align;
+ switch (attr.GetAlignment())
+ {
+ default:
+ align = GTK_JUSTIFY_LEFT;
+ break;
+ case wxTEXT_ALIGNMENT_RIGHT:
+ align = GTK_JUSTIFY_RIGHT;
+ break;
+ case wxTEXT_ALIGNMENT_CENTER:
+ align = GTK_JUSTIFY_CENTER;
+ break;
+ // gtk+ doesn't support justify as of gtk+-2.7.4
+ }