From 13dc1502c82e8148f9fc27b701c02cab44fffb96 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 16 Mar 2009 01:21:59 +0100 Subject: [PATCH] Use gtk_show_uri, GIO or Exo to open email adresses --- midori/compat.c | 17 ++++++++++++++++- midori/compat.h | 23 ++++++++++++++--------- midori/midori-browser.c | 10 +++++++--- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/midori/compat.c b/midori/compat.c index 253d93ed..b3be7e89 100644 --- a/midori/compat.c +++ b/midori/compat.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2008 Christian Dywan + Copyright (C) 2008-2009 Christian Dywan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -31,6 +31,21 @@ g_strcmp0 (const gchar* string1, #endif +#if !GTK_CHECK_VERSION (2, 14, 0) + +gboolean +gtk_show_uri (GdkScreen* screen, + const gchar* uri, + guint32 timestamp, + GError** error) +{ + g_return_val_if_fail (uri != NULL, FALSE); + + return g_app_info_launch_default_for_uri (uri, NULL, NULL); +} + +#endif + #if !GTK_CHECK_VERSION(2, 12, 0) void diff --git a/midori/compat.h b/midori/compat.h index 261a2a7a..2cd58882 100644 --- a/midori/compat.h +++ b/midori/compat.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2008 Christian Dywan + Copyright (C) 2008-2009 Christian Dywan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,20 +16,15 @@ #include #endif -#include +#include + +G_BEGIN_DECLS #if !GLIB_CHECK_VERSION (2, 14, 0) #define G_PARAM_STATIC_STRINGS \ (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) #endif -#if GLIB_CHECK_VERSION (2, 16, 0) - #include -#endif -#include - -G_BEGIN_DECLS - #if !GLIB_CHECK_VERSION (2, 16, 0) gint @@ -38,6 +33,16 @@ g_strcmp0 (const gchar* string1, #endif +#if !GTK_CHECK_VERSION (2, 14, 0) + +gboolean +gtk_show_uri (GdkScreen* screen, + const gchar* uri, + guint32 timestamp, + GError** error); + +#endif + #if !GTK_CHECK_VERSION(2, 12, 0) void diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 1b13ee37..05d367bb 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -2777,9 +2777,13 @@ _action_about_activate_email (GtkAboutDialog* about, const gchar* uri, gpointer user_data) { - gchar* command = g_strconcat ("xdg-open ", uri, NULL); - g_spawn_command_line_async (command, NULL); - g_free (command); + if (!gtk_show_uri (NULL, uri, GDK_CURRENT_TIME, NULL)) + { + /* Fallback to Exo for example if GConf isn't setup */ + gchar* command = g_strconcat ("exo-open ", uri, NULL); + g_spawn_command_line_async (command, NULL); + g_free (command); + } } static void