[evolution] I#313 - Allow enter URL without scheme in component editor
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] I#313 - Allow enter URL without scheme in component editor
- Date: Fri, 22 Feb 2019 08:41:09 +0000 (UTC)
commit 16c338e4a6157bcbf637d59ef8c879b02e289f81
Author: Milan Crha <mcrha redhat com>
Date: Fri Feb 22 09:41:40 2019 +0100
I#313 - Allow enter URL without scheme in component editor
Closes https://gitlab.gnome.org/GNOME/evolution/issues/313
src/calendar/gui/e-cal-component-preview.c | 23 +++++++++++++++++++----
src/e-util/e-misc-utils.c | 18 +++++++++++++++++-
src/e-util/e-url-entry.c | 6 +-----
3 files changed, 37 insertions(+), 10 deletions(-)
---
diff --git a/src/calendar/gui/e-cal-component-preview.c b/src/calendar/gui/e-cal-component-preview.c
index af8e01758a..c751817b87 100644
--- a/src/calendar/gui/e-cal-component-preview.c
+++ b/src/calendar/gui/e-cal-component-preview.c
@@ -197,7 +197,7 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
icalcomponent *icalcomp;
icalproperty *icalprop;
icalproperty_status status;
- const gchar *location;
+ const gchar *location, *url;
gint *priority_value;
client = preview->priv->client;
@@ -388,11 +388,26 @@ cal_component_preview_write_html (ECalComponentPreview *preview,
}
/* URL */
- e_cal_component_get_url (comp, (const gchar **) &str);
- if (str) {
+ e_cal_component_get_url (comp, &url);
+ if (url) {
+ gchar *scheme;
+ const gchar *href = url;
+
+ str = NULL;
+
+ scheme = g_uri_parse_scheme (url);
+ if (!scheme || !*scheme) {
+ str = g_strconcat ("http://", url, NULL);
+ href = str;
+ }
+
+ g_free (scheme);
+
g_string_append_printf (
buffer, "<tr><th>%s</th><td><a href=\"%s\">%s</a></td></tr>",
- _("Web Page:"), str, str);
+ _("Web Page:"), href, url);
+
+ g_free (str);
}
g_string_append (buffer, "</table>");
diff --git a/src/e-util/e-misc-utils.c b/src/e-util/e-misc-utils.c
index e6a00a3e31..afc80c465b 100644
--- a/src/e-util/e-misc-utils.c
+++ b/src/e-util/e-misc-utils.c
@@ -242,8 +242,10 @@ e_show_uri (GtkWindow *parent,
{
GtkWidget *dialog;
GdkScreen *screen = NULL;
+ gchar *scheme;
GError *error = NULL;
guint32 timestamp;
+ gboolean success;
g_return_if_fail (uri != NULL);
@@ -252,7 +254,21 @@ e_show_uri (GtkWindow *parent,
if (parent != NULL)
screen = gtk_widget_get_screen (GTK_WIDGET (parent));
- if (gtk_show_uri (screen, uri, timestamp, &error))
+ scheme = g_uri_parse_scheme (uri);
+
+ if (!scheme || !*scheme) {
+ gchar *schemed_uri;
+
+ schemed_uri = g_strconcat ("http://", uri, NULL);
+ success = gtk_show_uri (screen, schemed_uri, timestamp, &error);
+ g_free (schemed_uri);
+ } else {
+ success = gtk_show_uri (screen, uri, timestamp, &error);
+ }
+
+ g_free (scheme);
+
+ if (success)
return;
dialog = gtk_message_dialog_new_with_markup (
diff --git a/src/e-util/e-url-entry.c b/src/e-util/e-url-entry.c
index d86ef40ec5..a38e108e9b 100644
--- a/src/e-util/e-url-entry.c
+++ b/src/e-util/e-url-entry.c
@@ -47,15 +47,11 @@ url_entry_text_to_sensitive (GBinding *binding,
text = g_value_get_string (source_value);
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);
+ sensitive = *text != '\0';
}
g_value_set_boolean (target_value, sensitive);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]