GNOME Bugzilla – Bug 314808
port GnomeHref to gtk
Last modified: 2011-02-04 16:10:23 UTC
Please describe the problem: tracer bug for porting the GnomeHref widget from libgnomeui into gtk+. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 51534 [details] proposed api for EggLinkButton
the EggLinkButton is a replacement for GnomeHref. basically, is the same widget: a button (with no relief) that has a "uri" property. since we don't know the handler for the uri, we can't spawn a process or use functions like gnome_url_show(); the action on user click will be entirely demanded to the user of this widget.
What is the "active" property used for? I think you should add a function similar to gtk_about_dialog_set_url_hook to set a global handler for the click action. Probably the new_with_label function should take also a url parameter. I think you should add a new_with_mnemonic function too. In the wiki page you wrote that URL should be utf-8 encoded. I do not agree, it should be a valid (properly escaped) URL (we should not promote the use of broken malformed URL).
1. the "active" property would enable a "off-line" status; if we just make the widget unsensitive, no tooltips and no events are propagated, so we can't - say - add a tooltip telling the user "we are off-line, so the link is disabled". maybe is overengineering, but I think that could be useful. 2. uhm, isn't the GtkButton::clicked signal enough? the about dialog doesn't expose the widgets used to show hyperlinks, but in this case the widget is obviously ther. 3. isn't there? GtkWidget *egg_link_button_new_with_label (const gchar *uri, const gchar *label); 4. yep, you're right about the new_with_mnemonic ctor, I'll add it. 5. okay, I'll promote the URI to UTF-8 in case no label has been passed.
Note that label is different from URL You can have a button with label "Gnome Website" associated to the www.gnome.org URL. I will reply to the other points later.
So, before spending too much more work on polishing here, can we please first go over gnome cvs and find the actual uses o GnomeHref ? No point porting such special-purpose widgets, if they are not widely used.
1. I don't have a strong opinion on this. It may be an useful feature, but I'm not so sure. Why do you need the tooltip for the button if you will not be able to use it? 2. In most cases the programmer will connect the clicked signal of all the href buttons to the same function or to different copies of the same function. I think we could simplify his/her life adding a way to autoconnect the click signals of all the href buttons to a given function. 3. ops... sorry (sorry also for comment #5) 5. You will have to use a function similar to gnome_vfs_format_uri_for_display (I don't remember if glib has such a function).
comment #6: AFAIR, it's used by rhythmbox and another couple of apps. but we could also use it internally in the GtkAboutDialog widget, instead on relying on a custom implementation of a hyperlink widget. comment #7: a state property different from the usual "sensitive" property should be used because the action taken by the button might not be available in a manner not dependent on the state of the widget itself. as for the hook, I think you're right.
Created attachment 51774 [details] revised API for EggLinkButton added the hook function and the new_with_mnemonic ctor.
The hook function must be global. There is no point in addding a per-button hook function (you can connect to the signal). As said by Jonathan in http://live.gnome.org/ProjectRidley_2fEggLinkButton, may be we should consider adding <a href=".."></a> support to GtkLabel.
yep, it's my mistake: I've sent a wrong header file. my local tree is correct. as for adding anchors to the markup used by GtkLabel, I'll investigate it, even though a separate widget might still be a better idea for the common case where GnomeHref was used.
Here's the initial implementation, replacing GnomeHref functionalities. Since Paolo requested a ctor with a mnemonic label, I have had to remove the underline to the widget's label; the underlined link appears only when hovering with the pointer. Possible enhancements: * different colors for the "link:hover" and "link:active" states; * a popup menu, showing the "copy link to clipboard" and "launch link in browser" items;
Created attachment 52566 [details] EggLinkButton header
Created attachment 52567 [details] EggLinkButton implementation
Created attachment 52568 [details] EggLinkButton screenshot
Created attachment 52569 [details] EggLinkButton screenshot (hover)
Just a note: bug 113649 adds thevisited-link-color style property while you name this link-active-color; also this patch adds link-hover-color which is missing from the patch in bug 113649 and should probably be added there.
Wondering if it would not be more usefull to extend Pango's markup language to support hyperlinks. Would be nice to have hyperlinks embedded into GtkLabel captions.
Ok, taking a detailed look now; I still think this is a fairly special case widget, but since it is very small, we may as well add it. But lets not overdo it. - I don't think a separate hover color is really needed. You already get the button prelighting on hover, which is more than enough to make it clear that this is an active ui element. - I don't like the active property much; we have the problem of tooltips on insensitive widgets everywhere, there is no need to special case it here. - I don't think the hook function is necessary at all. It is necessary for the about dialog, since there is no way to connect to a signal, but for the link button, just connecting to the clicked signal should work fine. - I don't like the mnemonic addition, and in particular the fact that it forces us to drop the underlining. Underlinedness is a big part of what makes links links, visually, so I'd rather see us use underlines all the time, and not have mnemonics (GnomeHRef does not have mnemonics either, does it ?) - It might be nice to support Copy and paste of the url too, if you allow DND. - Please use G_DEFINE_TYPE, and add "Since: 2.10" where appropriate
new attempt at the LinkButton, after Matthias' review. - I've removed the "underline on highlight" and the hook function; - I've added a popup menu with the "copy URL" item which copies the URL to the clipboard;
Created attachment 57789 [details] GtkLinkButton header
Created attachment 57790 [details] GtkLinkButton implementation
Created attachment 57791 [details] GtkLinkButton implementation (correct) correct version
I made it use the new link-color and visited-link-color style properties, and readded the underlining. 2006-01-23 Matthias Clasen <mclasen@redhat.com> Add GtkLinkButton, a port of GnomeHRef. (#314808, Emmanuele Bassi) * gtk/gtklinkbutton.h: * gtk/gtklinkbutton.c: New files. * gtk/gtk.h: * gtk/gtk.symbols: * gtk/Makefile.am: Glue. * gtk/gtkaboutdialog.c: Use GtkLinkButton.