GNOME Bugzilla – Bug 589413
Support addition of text tags in textbuffers
Last modified: 2013-05-20 12:29:40 UTC
Being able to have text tags added to the text tag table associated with a textbuffer would allow to define a whole MVC component for text. Even if, as tristan pointed, there's currently problems to support adding preset text with tag support in glade due to gtk+ lack of support, it would be useful anyhow a way to define tags for a buffer as the TextBuffer.insert_with_tags(iter, text, tag1, tag2, ...) or, specially, the TextBuffer.insert_with_tags_by_name(iter, text, tagname1, tagname2, ...) method would allow using them from code. Not having preset text with support for rich format is a minor problem compared to having to support the more complex and usual case of programmatically added text, and this support could be improved in the future.
I've been investigating full GtkTextView/GtkTextBuffer MVC support in glade a bit more and it looks like there's some support in GTK+ to serialize and deserialize the contents of a textbuffer object including its tags using an internal format. The following GtkTextBuffer methods register the internal format handlers: gtk_text_buffer_register_serialize_tagset () gtk_text_buffer_register_deserialize_tagset () and the following ones allow serialization and deserialization of contents: gtk_text_buffer_serialize () gtk_text_buffer_deserialize () These could be used to have working tags in prefilled text. What looks like missing in GTK+ is an implementation of the GtkBuildable interface for GtkTextTagTable and that, from my limited understanding, would be needed to support appending child GtkTextTag elements to a GtkTextTagTable associated with a given GtkTextBuffer so tags can be used with it.
A new dependency on bug 590327 has been added as GtkTextBuffer needs to implement the GtkBuildable interface to register and unregister the internal format (or any other) and serialize/deserialize the buffer text.
As at least a starting point, I've added support in Glade master for adding GtkTextTags to a GtkTextTagTable. Currently it wont work until I can commit 75841f767431f5e258de08998da63257bb954104 to GTK+ master.
This was implemented years ago, you can add text tags to text tag tables. Just created this with Glade: <?xml version="1.0" encoding="UTF-8"?> <interface> <!-- interface-requires gtk+ 3.10 --> <object class="GtkTextTagTable" id="texttagtable1"> <child type="tag"> <object class="GtkTextTag" id="texttag1"> <property name="font">Normal</property> </object> </child> </object> </interface>