Re: [gtk-list] Re: Active URLs



Ron Forrester <rjf@zero-ping.com> wrote:

> On Thu, Aug 26, 1999 at 06:42:35PM +0200, Anders Melchiorsen wrote:
> > What would be a reasonable way to achieve this? Should this be a
> > standard feature somehow?
> 
> Has anyone else mentioned anything about this to you? I defintely
> think it should be a standard feature of the text widgets. I have
> wanted it in XChat and have thought about trying to implement it. Alas
> I have not found the time so far.

I ended up doing this in a simplistic way. I use the button_release
event to see when the mouse is clicked in the widget and I then use
the selection to figure out where it was clicked.

If the selection starts and stops at different positions, I just
ignore the event (since it was used to mark the selection and not
because someone wanted to activate the URL).

If the selection starts and stops at the same position, however, there
is not really a selection. Then a simple matter of scanning the widget
contents for URLs near that position will do the job.

I do it by checking against a list of start-stop positions for URLs
that I build when I display the widget (this works best with static
content, I would think). I also color the discovered links red
(couldn't quite figure out how to underline :-) when building that
list but this is not required for a very simple implementation.

I think it would be rather easy to implement this into GTK+ itself
with some function to turn the URL discovering mode on/off and an
extra event to deliver the clicked address to the application. But
maybe one wants Gnome for that?

-- 
Mvh. Anders



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