After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 508810 - Merge SexyUrlLabel
Merge SexyUrlLabel
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkLabel
2.13.x
Other All
: Normal enhancement
: Medium API
Assigned To: gtk-bugs
gtk-bugs
Depends on: 511130
Blocks:
 
 
Reported: 2008-01-11 17:59 UTC by Cody Russell
Modified: 2009-05-11 05:26 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Very unfinished :) (33.82 KB, patch)
2008-01-14 02:51 UTC, Cody Russell
needs-work Details | Review
fairly complete patch (58.51 KB, patch)
2009-05-05 06:20 UTC, Matthias Clasen
none Details | Review
minor cleanups (58.80 KB, patch)
2009-05-05 15:41 UTC, Matthias Clasen
none Details | Review

Description Cody Russell 2008-01-11 17:59:08 UTC
There seems to have been some interest in merging libsexy into gtk+, so I'm
filing bugs for individual widgets that seem merge-worthy.

Next up is SexyUrlLabel.  Again, I'll gtkify it and post a patch very soon.
Comment 1 Bastien Nocera 2008-01-11 18:15:01 UTC
This might need much cut'n'paste between apps to get the browser launching bits going. It might be a good idea to export the default browser info via XSettings in g-s-d so we can avoid that duplicated code.
Comment 2 David Zeuthen (not reading bugmail) 2008-01-12 01:34:29 UTC
Great, thanks for doing this! FWIW, this is the only sexy bit I use in PolicyKit-gnome and I'd love to see it go into the next GTK+ release.
Comment 3 Emmanuele Bassi (:ebassi) 2008-01-12 11:43:19 UTC
(In reply to comment #1)
> This might need much cut'n'paste between apps to get the browser launching bits
> going.

GtkLinkButton would also benefit from this. in the mean time, the label should probably use a hook function like the LinkButton.

about naming, LinkLabel would probably fit in better than UrlLabel.
Comment 4 Cody Russell 2008-01-12 21:47:24 UTC
I'm working on this right now (and thanks for the input everyone!), but I'm wondering if it's possible to do without breaking binary compatibility would it be a good idea to try to integrate this functionality into GtkLabel instead?

I want to get GtkLinkLabel finished using your suggestions first, but if people like the idea of juicing up GtkLabel instead then it should be really easy to move all of this code into it.
Comment 5 Cody Russell 2008-01-13 05:44:15 UTC
Emmanuele, what is the purpose of the hook func rather than using a signal?
Comment 6 Mathias Hasselmann (IRC: tbf) 2008-01-13 09:34:53 UTC
(In reply to comment #5)
> Emmanuele, what is the purpose of the hook func rather than using a signal?
> 

The signal would have to be connected for each single GtkLinkLabel. If you have many of them and forget one by accident, your app is broken. With a global hook you have to remember that step just once. 

Ideally GTK+ even would setup a default handler using XSETTINGS/xdg-open/BROWSER/whatever to open an URL. That default handler would be used by GtkAboutDialog, GtkLinkButton and GtkLinkLabel.
Comment 7 Behdad Esfahbod 2008-01-13 20:48:01 UTC
We should give this enough thought before rushing the merge.  Eventually one should be able to tag parts of text in a text buffer as a link and have it just work too, using the same browser setting...  And yes, I prefer just modifying GtkLabel instead of a new widget.
Comment 8 Cody Russell 2008-01-14 02:51:00 UTC
Yeah, I don't want to rush anything.  But I feel like a good first iteration of this patch should be getting the Sexy widget converted over to GTK and get the default URL handling stuff working.  Once that's done, it shouldn't be terribly difficult to abstract all the URL handling stuff so that it can be used by GtkLabel and GtkTextView.

I have to go to California next week and work from the office, so I probably won't have any time to invest in this during that time.  I'm going to go ahead and attach the GTKified widget as it is right now.  There is no default-handler code in here yet, the hook doesn't work yet (I was adding it this morning and got distracted to practice for my quartet rehearsal :) ), but I'm going to go ahead and post it as-is anyway.
Comment 9 Cody Russell 2008-01-14 02:51:52 UTC
Created attachment 102788 [details] [review]
Very unfinished :)
Comment 10 Reinout van Schouwen 2008-01-14 14:21:54 UTC
Adding Epiphany-maint in cc
Comment 11 Johan (not receiving bugmail) Dahlin 2008-03-02 18:20:47 UTC
What is GtkLinkLabel providing which GtkLinkButton isn't?
I don't think there's should be more than one widget in Gtk+ which opens a link.
Comment 12 Emmanuele Bassi (:ebassi) 2008-03-02 18:31:47 UTC
(In reply to comment #11)
> What is GtkLinkLabel providing which GtkLinkButton isn't?

you can set a link inside some other text, like:

  this application creates <a href="http://lolcats.com">lolcats</a> images

and set it into a label; the other way to implement this with a GtkLinkButton would be:

  GtkHBox homogenous:false, spacing:6
  +---- GtkLabel text:"this application creates"
  +---- GtkLinkButton uri:"http://lolcats.com, label:"lolcats"
  +---- GtkLabel text:"images"

which is kind of ugly, albeit perfectly doable.

the way I see it, it's the ability of setting a PangoLinkAttribute to any text set into a GtkLabel or a GtkTextBuffer that should be added; the default action would exactly be the same used by GtkLinkButton.
Comment 13 Johan (not receiving bugmail) Dahlin 2008-03-02 18:55:24 UTC
(moving back severity to enhancement, this is a new feature)
Comment 14 Matthias Clasen 2008-03-04 05:14:20 UTC
> the way I see it, it's the ability of setting a PangoLinkAttribute to any text
> set into a GtkLabel or a GtkTextBuffer that should be added; the default action
> would exactly be the same used by GtkLinkButton.

That would be nice. But it certainly needs GTK+ level support, eg to set the appropriate pointer etc.
Comment 15 Wang Xin 2008-06-10 02:23:21 UTC
Is this work still in progress or stopped?
Comment 16 Cody Russell 2008-06-11 04:27:10 UTC
I haven't worked on it recently.  I'm finishing up merging SexyIconEntry first, and then I was going to work on this next.
Comment 17 Wang Xin 2008-06-12 02:44:28 UTC
Thanks, Russell. I am just curious about if the work is still in progress. Do you have any plan in which release the work should be done?
Comment 18 Cody Russell 2008-06-12 02:53:31 UTC
No, I don't have any kind of projection yet on when it would be finished.  I got busy at work for awhile and wasn't able to work on the libsexy widgets.  But I've recently started working on SexyIconEntry again and will hopefully have that finished soon, and then I can work on SexyUrlLabel.
Comment 19 Wang Xin 2008-06-12 03:03:59 UTC
Got it. Thanks for your work:-)
Comment 20 chuchiperriman 2009-01-13 15:03:59 UTC
We need this feature too (by example something like a tooltip with documentation and a link for the main reference like eclipse do with the documentation popup)
Comment 21 Matthias Clasen 2009-05-05 06:20:07 UTC
Created attachment 133994 [details] [review]
fairly complete patch

Here is a patch that goes beyond what SexyUrlLabel does. 
It supports links like this:

Bla bla <a href="http://www.gtk.org: title="Our website">GTK+</a> bla.

Stuff that I've added:

- titles are turned into tooltips
- keep track of visited links
- default handler uses gtk_show_uri
- link context menu can be added to using ::populate-popup
- keybindings for 'open link' (hit enter while in a link) and 'copy link' (hit ctrl-c while in a link)
- keynav: can tab through links, the 'active' link gets a focus rectangle
- keynav: can open context menu with the menu key
- api: gtk_label_get_current_uri() for use in signal handlers


Left to do:
- consider an extension mechanism for pango markup instead of the somewhat gross pre-parsing/rewriting approach in this patch
- avoid recalculating everything just to update link colors
- when copying a url to the clipboard, support text/uri-list 
- a11y considerations other than keynav
Comment 22 Matthias Clasen 2009-05-05 15:41:29 UTC
Created attachment 134037 [details] [review]
minor cleanups
Comment 23 Matthias Clasen 2009-05-11 05:26:32 UTC
I've committed a substantially rewritten version of this patch.