Commit 99366453 authored by Julian Sparber's avatar Julian Sparber

ContactEditor: add fallback for webaddresses without a protocol

parent ee867dd5
......@@ -240,12 +240,11 @@ public class Contacts.ContactSheet : ContactForm {
var button = create_button ("web-browser-symbolic");
button.clicked.connect (() => {
var window = button.get_toplevel ();
/* FIXME: show_uri_on_window doesn't do anything if the url
* doesn't start with a protocol (e.g. http) */
try {
show_uri_on_window ((Window) window, url.value, Gdk.CURRENT_TIME);
show_uri_on_window ((Window) window, fallback_to_http (url.value), Gdk.CURRENT_TIME);
} catch (Error e) {
debug ("Failed to open url");
print ("Error");
}
});
add_row_with_label (_("Website"), url.value, button);
......@@ -253,6 +252,16 @@ public class Contacts.ContactSheet : ContactForm {
}
}
/* When the url doesn't contain a scheme we fallback to http
* We are sure that the url is a webaddress but GTK falls back to opening a file
*/
private string fallback_to_http (string url) {
string scheme = Uri.parse_scheme (url);
if (scheme == null)
return "http://" + url;
return url;
}
private void add_nickname (Persona persona) {
var name_details = persona as NameDetails;
if (name_details != null && is_set (name_details.nickname))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment