diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-24 07:27:41 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-24 07:33:00 +0800 |
commit | 1bf44c8b97a1255c1be31d24f5c7be12951f8873 (patch) | |
tree | bf728b9f35d89ab1af5580741b43aa09c4b9d89a /e-util | |
parent | d2bf13d734424b12f3a92791624aa637b11c8500 (diff) | |
download | gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar.gz gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar.bz2 gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar.lz gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar.xz gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.tar.zst gsoc2013-evolution-1bf44c8b97a1255c1be31d24f5c7be12951f8873.zip |
EUrlEntry: Try harder to recognize a valid URL.
Skip leading whitespace and hand the rest to g_uri_parse_scheme().
If that can identify a scheme then make the open button sensitive.
(Have to be careful to skip leading whitespace when opening, too.)
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-url-entry.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/e-util/e-url-entry.c b/e-util/e-url-entry.c index 5b90f4a14f..501f4e5760 100644 --- a/e-util/e-url-entry.c +++ b/e-util/e-url-entry.c @@ -45,10 +45,22 @@ url_entry_text_to_sensitive (GBinding *binding, gpointer user_data) { const gchar *text; - gboolean sensitive; + gboolean sensitive = FALSE; text = g_value_get_string (source_value); - sensitive = (text != NULL && *text != '\0'); + + if (text != NULL) { + gchar *scheme; + + /* Skip leading whitespace. */ + while (g_ascii_isspace (*text)) + text++; + + scheme = g_uri_parse_scheme (text); + sensitive = (scheme != NULL); + g_free (scheme); + } + g_value_set_boolean (target_value, sensitive); return TRUE; @@ -70,6 +82,10 @@ url_entry_icon_release_cb (GtkEntry *entry, text = gtk_entry_get_text (entry); g_return_if_fail (text != NULL); + /* Skip leading whitespace. */ + while (g_ascii_isspace (*text)) + text++; + e_show_uri (toplevel, text); } } |