From 53aa1e8e60b7c9a48348caddccebefe81249d28f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sat, 19 Apr 2008 23:01:05 +0000 Subject: Make possible to show "ghelp:" URIs and display a dialog in case of error in empathy_url_show. Use that to show empathy's doc. svn path=/trunk/; revision=996 --- libempathy-gtk/empathy-ui-utils.c | 29 ++++++++++++++++++++--------- src/empathy-chat-window.c | 2 +- src/empathy-main-window.c | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 6aa800bb0..e1a0188dd 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -1295,7 +1295,7 @@ empathy_get_toplevel_window (GtkWidget *widget) static gchar * fixup_url (const gchar *url) { - if (!g_str_has_prefix (url, "http://") && + if (!g_str_has_prefix (url, "ghelp:") && !strstr (url, ":/") && !strstr (url, "@")) { return g_strdup_printf ("http://%s", url); @@ -1307,21 +1307,32 @@ fixup_url (const gchar *url) void empathy_url_show (const char *url) { - gchar *real_url; - gboolean res; - GError *error = NULL; + gchar *real_url; + GError *error = NULL; real_url = fixup_url (url); if (real_url) { url = real_url; } + /* FIXME: this does not work for multihead, we should use - * GdkAppLaunchContext for that, when we can depend on GTK+ trunk + * GdkAppLaunchContext or gtk_show_url, see bug #514396. */ - res = g_app_info_launch_default_for_uri (url, NULL, &error); - if (!res) { - empathy_debug (DEBUG_DOMAIN, "Couldn't show URL %s: %s", - url, error->message); + g_app_info_launch_default_for_uri (url, NULL, &error); + if (error) { + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + _("Unable to open uri")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + error->message); + + g_signal_connect (dialog, "response", + G_CALLBACK (gtk_widget_destroy), + NULL); + gtk_window_present (GTK_WINDOW (dialog)); + g_clear_error (&error); } diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c index dc7f2f102..09a0e4589 100644 --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -676,7 +676,7 @@ static void chat_window_help_contents_cb (GtkWidget *menuitem, EmpathyChatWindow *window) { - //empathy_help_show (); + empathy_url_show ("ghelp:empathy?chat"); } static void diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c index 065c6fcc8..7b616f4ab 100644 --- a/src/empathy-main-window.c +++ b/src/empathy-main-window.c @@ -706,7 +706,7 @@ static void main_window_help_contents_cb (GtkWidget *widget, EmpathyMainWindow *window) { - //empathy_help_show (); + empathy_url_show ("ghelp:empathy"); } static gboolean -- cgit v1.2.3