Jeremy wrote:
While thinking about stylesheet issues I noticed a UI problem: the stylesheet menu uses URLs as the labels of the menu items. This is unfortunate because some sites have stylesheets with insanely long URLs. (Try Wikipedia if you don't believe me!) So I'm attaching a patch that trims long URLs in the menu. This is just a UI change - no functionality is affected.
Here's a demonstration of the patch on the front page of Wikipedia:
Good. It would be nice to improve the labels. It's interesting that FLTK decides to clip a little bit from the end there. I wonder what it was thinking...
Notes:
Since the label is no longer always the same as the label the callback must find the URL elsewhere. We put it in the user_data() of the menu item.
We just copy the pointer to the DilloUrl structure, so we are assuming it will never be free()-ed while the menu is up. If I'm wrong about this the patch will need to be revised.
I don't know the details of when Jorge's code decides to free cache entries, but I think it would be best not to assume that the url remains valid.