GNOME Bugzilla – Bug 380533
Request for gtk_text_view_set_markup function
Last modified: 2006-11-29 18:15:59 UTC
With a GtkLabel you can directly add marked up Text (using Pango syntax) using gtk_label_set_markup. However, this functionality does not seem to exist for a GtkTextView. Would it be possible to add a "gtk_text_view_set_markup" to the API so that you could drop Pango marked-up text right into a text view? Thanks.
This is a dup of another bug I couldn't point to quickly ... (the basic trick to this is that the text view uses tags to apply text styles, and there are no tags by default, they are all user-defined)
So, GtkTextView doesn't use Pango (or at least has no way to use pango_parse_markup)?
The only way to e.g. make text bold is to have a GtkTextTag that sets things to bold. By default there are no GtkTextTag defined, only apps define them. The other bug has more discussion I think
Found it. Yeah, bug #59390 offers a patch to do exactly what I was looking for by adding functions like "gtk_text_buffer_set_markup". The bug is five years old and apparently rejected--is there a reason why this patch wasn't accepted? Surely a lot of programmer are hoping for functionality. Marking up the TextBuffer isn't really useful if your text formatting code is separate from the GUI code. For example, in Win32 you can format a huge RTF string and drop it right into a Rich Edit control. Being able to format a char* string with (Pango's) html markup and then dropping it into a GtkTextView would be very helpful for a lot of programmers I imagine. Obviously someone that this would be convenient with labels (gtk_label_set_markup)--why would text views be any different?
Pango markup is not HTML. As soon as we accept that patch, people will start clamoring for extending it until it is HTML...
marking the dup, thanks for tracking it down. *** This bug has been marked as a duplicate of 59390 ***
How about call(In reply to comment #5) > Pango markup is not HTML. > > As soon as we accept that patch, people will start clamoring for extending it > until it is HTML... > How about calling the new functions something like "gtk_text_buffer_set_pango_markup" then? :-) Actually, that doesn't sound like too bad of an idea. I see what you mean, but I think most hackers would understand the limitations of Pango markup. I think the number of people that would greatly appreciate this feature would outweigh the number of people who complain that the text view isn't loading their style sheets and java script.