aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-08-19 01:03:24 +0800
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-08-19 04:19:14 +0800
commitc5cf2e489ecda8e8f2f53f29120388ba15e635c8 (patch)
tree46a8a5f4a437458e41922073e76a3965e3d8db97 /libempathy-gtk
parent04a8b6b56f3beaabbbc17fe7e54983325df2a8ea (diff)
downloadgsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar.gz
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar.bz2
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar.lz
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar.xz
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.tar.zst
gsoc2013-empathy-c5cf2e489ecda8e8f2f53f29120388ba15e635c8.zip
Make empathy_make_absolute_url visible
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c21
-rw-r--r--libempathy-gtk/empathy-ui-utils.h2
2 files changed, 14 insertions, 9 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 40c6134cf..32abc5884 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -1333,20 +1333,26 @@ empathy_get_toplevel_window (GtkWidget *widget)
return NULL;
}
-/* The URL opening code can't handle schemeless strings, so we try to be
+/** empathy_make_absolute_url:
+ * @url: an url
+ *
+ * The URL opening code can't handle schemeless strings, so we try to be
* smart and add http if there is no scheme or doesn't look like a mail
* address. This should work in most cases, and let us click on strings
* like "www.gnome.org".
+ *
+ * Returns: a newly allocated url with proper mailto: or http:// prefix, use
+ * g_free when your are done with it
*/
-static gchar *
-fixup_url (const gchar *url)
+gchar *
+empathy_make_absolute_url (const gchar *url)
{
g_return_val_if_fail (url != NULL, NULL);
if (g_str_has_prefix (url, "ghelp:") ||
g_str_has_prefix (url, "mailto:") ||
strstr (url, ":/")) {
- return NULL;
+ return g_strdup (url);
}
if (strstr (url, "@")) {
@@ -1366,12 +1372,9 @@ empathy_url_show (GtkWidget *parent,
g_return_if_fail (parent == NULL || GTK_IS_WIDGET (parent));
g_return_if_fail (url != NULL);
- real_url = fixup_url (url);
- if (real_url) {
- url = real_url;
- }
+ real_url = empathy_make_absolute_url (url);
- gtk_show_uri (parent ? gtk_widget_get_screen (parent) : NULL, url,
+ gtk_show_uri (parent ? gtk_widget_get_screen (parent) : NULL, real_url,
gtk_get_current_event_time (), &error);
if (error) {
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 10f889b0c..3299a44e0 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -112,6 +112,8 @@ GtkWidget * empathy_link_button_new (const gchar *url,
void empathy_send_file_with_file_chooser (EmpathyContact *contact);
void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler);
+gchar * empathy_make_absolute_url (const gchar *url);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */