]> git.0d.be Git - empathy.git/commitdiff
Make possible to show "ghelp:" URIs and display a dialog in case of error in empathy_...
authorXavier Claessens <xclaesse@src.gnome.org>
Sat, 19 Apr 2008 23:01:05 +0000 (23:01 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sat, 19 Apr 2008 23:01:05 +0000 (23:01 +0000)
svn path=/trunk/; revision=996

libempathy-gtk/empathy-ui-utils.c
src/empathy-chat-window.c
src/empathy-main-window.c

index 6aa800bb05e22684833a570d05eb5a59645469eb..e1a0188ddbc1a9b3cad816a916bfcbe3612e939a 100644 (file)
@@ -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);
        }
 
index dc7f2f102573b7984cc25c01b691739d5b9cc9e2..09a0e4589bceb70838ca61b4e38131632ad011c0 100644 (file)
@@ -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
index 065c6fcc82319370ca99d48aaacb4ac8d64afb16..7b616f4ab24e3083076823187fdb142497406263 100644 (file)
@@ -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