Re: gtk_text_buffer with clickable links?



On Tue, 04 Mar 2008 11:11:36 -0500
Keith Maika <keithm aoeex com> wrote:

Andreas Rönnquist wrote:
Hi!

I have managed to make a gtk_text_buffer and colorize what appears to be links using 
gtk_text_buffer_apply_tag and some simple search algorithm.

Does someone have any resources explaining how to make those clickable - and (later problem) to open them 
in "default webbrowser" or such, and also make them underlined when mouse is hovering above them?

I have found an example, but that involves inserting actual buttons into the textview, and that isn't 
really what I am after. (There must be a simpler way to do what I want..)

Help and pointers to good documentation/tutorials/examples would be much appreciated.
I have looked at source that includes the requested behaviour, but it contains a _lot_ of other stuff 
too, so it is quite hard to make out what is important.

I would like to keep it as simple as possible (Editable textbuffer isn't at all required, also I am not 
interested in full syntax highligthing or similar. - as simple as possible.)

/Andreas


I needed to do this quite a while back, and at the time I took a look at 
the GAIM code to see how they did it.  It was a matter of connecting an 
event to the tag used to mark the text, and when activated, you'd open 
the URL.

You can check the code I wrote by downloading the source @ 
http://aoeex.com/projects/easydict/  The relevant functions are 
textview_add_url(), textview_url_activate(), and 
textview_motion_notify_cb().

-- 
Keith Maika

Thanks for the help guys!
        
I have managed to get my links showing as I like, but I have problems with the mouse-over effect... It's 
working some-what - But I can't get the mouse updated as it should.

I am checking for the event GDK_MOTION_NOTIFY, (through a g_signal_connect with "motion-notify-event" and 
then use gdk_window_set_cursor to update the mousepointer, but as I said, it doesn't actually update the 
mousecursor until I either click on the text, or press a key on the keyboard. I would like it to change by 
just hovering above the links.

Has anyone run into similar problems?

/Andreas


-- 
Andreas Rönnquist <andreas ronnquist meritkonsult se>



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