[Gtk-sharp-list] textbuffer urls
evan.arnold at gmail.com
Tue Jun 23 10:21:52 EDT 2009
Thanks - that was striaghtforward to implement. Also, I'm able to save the
content of the textbuffer as more/less html by replacing the texttags as
anchor tags. (or any other format)
Now, and perhaps this might be hard, is is possible to display the text WITH
the URL functionality? From what I understand the pango mark-up doesn't
recognize anchor tags, likewise the cellrenderertext doesn't appear to user
Any ideas on how to put URL functionality into a Treeview Cell?
On Mon, Jun 22, 2009 at 9:28 AM, Chris Howie <cdhowie at gmail.com> wrote:
> To create a link:
> * Create a TextTag with no name ("new TextTag(null)").
> * Set the visual appearance you want (blue, underlined, etc.).
> * Store the hyperlink target somewhere, probably a Dictionary<TextTag,
> string> would be the most useful.
> * Don't forget to add the tag to the TextBuffer.TagTable.
> * Apply the tag to the text where you want the link.
> Then during construction of the buffer you need to attach a handler to
> the mouse movement signal (I forget what it's called) as well as the
> clicked signal. When either are fired you will have to:
> * Obtain the X,Y coordinates of the movement/click.
> * Map these somehow to a TextIter.
> Then, in the movement handler you will then want to conditionally set
> the mouse pointer to the "hand" pointer or the normal one, based on
> whether or not a hyperlink tag is present. You could use a LINQ query
> to determine this, something like "bool hyperlink = (from i in
> iter.Tags where dictionary.ContainsKey(i) select i).FirstOrDefault()
> != null;" (this is from memory, you may have to tweak it).
> In the click handler you can do something like "TextTag linktag =
> (from i in iter.Tags where dictionary.ContainsKey(i) select
> i).FirstOrDefault();" and then if linktag != null you can do "string
> url = dictionary[linktag];" to obtain the URL you stored and use it
> however you wish.
> Don't forget that when you remove text containing a link you should
> remove the TextTag from the TextBuffer.TagTable and also
> Hope this helps!
> Chris Howie
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gtk-sharp-list