Re: How to convert text with GtkTextTag from a GtkTextBuffer to Pango markup



On Sat, 2014-05-03 at 00:17 -0300, Andrés Fernández wrote:
Hi! this is my first message to this list. I don't know if is correct to
ask this in this mailing list or in vala mailing list. I think this I
more related with Gtk+ than with vala.

I'm writing a gtk app in vala. I'm trying to let the user to format some
text on a GtkTextView save that text on an sqlite db converted to Pango
markup, so then I can show it later on a GtkLabel formated.

I have to say that I'm not sure if I understand how all this things
works. Where I'm stuck is trying to handle the uint8[] data that I get
from Gtk.TextBuffer.serialize (...).

var serialized = buffer.serialize (buffer,
buffer.register_serialize_tagset (null), start, end );

Then when I try to convert that unit8[] to string I only get one line
with this text GTKTEXTBUFFERCONTENTS-0001. Searching a on the web I
realize that is the header of a XML. But I didn't get how to get tho
other lines to parse that data to Pango markup.

These links should help you understand:
https://developer.gnome.org/gtk3/unstable/GtkTextBuffer.html#gtk-text-buffer-register-serialize-format
https://developer.gnome.org/gtk3/unstable/GtkTextBuffer.html#gtk-text-buffer-register-serialize-tagset

GtkTextBuffer does not have any feature to serialize into pango markup
format, I suppose it would be possible to create such a serialization
but it would probably be lossy (I'm not sure pango markup can express
everything that can be expressed with GtkTextTags in a GtkTextBuffer,
notably transparency in text foreground/background colors).

The above two links should give you the means to serialize into an
internal GTK+ format which can later be used to deserialize it into
another GtkTextBuffer.

Cheers,
    -Tristan


I hope I made my issue clear. My English is quiet limited.

Best regards!

------------------------
Andres Fernandez
Software Peronista
_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list




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