[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
GtkTooltips and markup...
- From: "Freddie Unpenstein" <fredderic excite com>
- To: gtk-app-devel-list gnome org
- Subject: GtkTooltips and markup...
- Date: Tue, 8 Jun 2004 12:49:40 -0400 (EDT)
This may all be redundant if I'm simply using an old version of the library, but if not... I'm trying to figure something out;
GtkTooltips use GtkLabel, which uses Pango. Pango allows markup, which means GtkLabel allows markup (and in fact, supports it), which means GtkTooltips should be able to provide this functionality fairly easily.
Now, as I understand it, the markup parser accepts optional <markup> </markup> tags to surround the text. They don't have to be there, but they do have to be balanced if they are.
I cloned the standard GtkTooltips widget code into my own home-grown tool kit, incorporating a very simple patch. If the text starts with the <markup> tag, it sets the label as a markup instead of as plain text. This isn't a perfect solution, but it works remarkably well.
To improve this situation, I'm looking at two options;
1) Adding a flag to the tooltip data to indicate whether the tooltip was set through the standard function, or a companion set_tooltip_markup function, and set the GtkLabel text appropriately.
2) Converting non-markup text into a form compatible with the markup parser (is there an easy way to do this?), and storing this text in the tooltip data structure instead, then providing the set_tooltip_markup function that simply stores the text unmodified just like the standard set_tooltip function does presently.
Option 2 is my current favorite, though I still need to track down the official way to protect text not intended to be marked up, from the Pango markup parser. However, aside from that, I'm wondering if there are any real issues that make method #1 prefered over #2, or even a new option that's better still?
Finally, I don't like having to have a 99.9% clone of the official GtkTooltips widget kicking around my otherwise home-grown tool kit. Not the least of which is because it's a terrible duplication of code. But, I can't see any other way to implement the change, since the GtkTooltips widget doesn't seem to use any virtual methods anywhere that's terribly useful (although I do notice there are four reserved vm's, so perhaps they're intending to make way for things like this?). Can anyone think of a better way than copying the entire code just so I can rename the existing set_tooltip function to set_tooltip_markup, then clone and modify the function (which will probably only need two or three lines added/changed) to provide backward compatibility, and insert a _markup in the line that sets the GtkLabel's text? All in all, modifications that affect only a tiny fraction of the total GtkTooltips code.
Suggestions, anyone? Or should I just continue as I am (and monitor the official code for changes) until the powers that be decide to fix this themselves?
fredderic
_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]