GtkTextView周りの注意事項

GtkTextIterの値は、GtkTextBufferの内容が変更されると無効になる。

http://developer.gnome.org/doc/API/2.4/gtk/TextWidgetObjects.html

GtkTextViewに書式を付けるための準備

  1. GtkTextTagTableを生成(gtk_text_tag_table_new())
  2. GtkTextTagを生成し、書式を付けてGtkTextTagTableに追加していく。
    1. gtk_text_tag_new()
    2. g_object_set()
    3. gtk_text_tag_table_add()
  3. GtkTextBufferを生成し、GtkTextTagTableと関連づける。(gtk_text_buffer_new())
  4. GtkTextViewを生成し、GtkTextBufferと関連づける。(gtk_text_view_new_with_buffer())

  1. GtkTextBuffer *gtBuffer;
  2. GtkTextTag *gtTag;
  3. GtkTextTagTable *gtTagTable;
  4. GtkTextView *gtView;
  5. gtTagTable = gtk_text_tag_table_new ();
  6. gtTag = gtk_text_tag_new ("TagName");
  7. g_object_set (G_OBJECT (gtTag), "family", "Monospace", "weight",
  8. PANGO_WEIGHT_BOLD, "foreground", "red",NULL);
  9. gtk_text_tag_table_add (gtTagTable, gtTag);
  10. gtBuffer = gtk_text_buffer_new (gtTagTable);
  11. gtView = gtk_text_view_new_with_buffer (gtBuffer);