]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-ui-utils.c
Add -Wformat and and fix some compile warnings with gcc 4.3. Fixes bug #537129 (Cosim...
[empathy.git] / libempathy-gtk / empathy-ui-utils.c
index f5c8d358946bbd80b0bf451216ed1db40da30dcb..6b02b1a929a6241f813a303f482c65012d77e796 100644 (file)
 
 #include <libmissioncontrol/mc-profile.h>
 
-#include <libempathy/empathy-debug.h>
-
 #include "empathy-ui-utils.h"
 #include "empathy-images.h"
 
-#define DEBUG_DOMAIN "UiUtils"
+#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
+#include <libempathy/empathy-debug.h>
 
 struct SizeData {
        gint     width;
@@ -61,20 +60,12 @@ get_glade_file (const gchar *filename,
                va_list      args)
 {
        GladeXML   *gui;
-       gchar      *path;
        const char *name;
        GtkWidget **widget_ptr;
 
-       path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "libempathy-gtk",
-                                filename, NULL);
-       if (!g_file_test (path, G_FILE_TEST_EXISTS)) {
-               g_free (path);
-               path = g_build_filename (DATADIR, "empathy", filename, NULL);
-       }
-       empathy_debug (DEBUG_DOMAIN, "Loading glade file %s", path);
+       DEBUG ("Loading glade file %s", filename);
 
-       gui = glade_xml_new (path, root, domain);
-       g_free (path);
+       gui = glade_xml_new (filename, root, domain);
 
        if (!gui) {
                g_warning ("Couldn't find necessary glade file '%s'", filename);
@@ -267,15 +258,15 @@ empathy_pixbuf_from_data (gchar *data,
 
        loader = gdk_pixbuf_loader_new ();
        if (!gdk_pixbuf_loader_write (loader, data, data_size, &error)) {
-               empathy_debug (DEBUG_DOMAIN, "Failed to write to pixbuf loader: %s",
-                              error ? error->message : "No error given");
+               DEBUG ("Failed to write to pixbuf loader: %s",
+                       error ? error->message : "No error given");
                g_clear_error (&error);
                g_object_unref (loader);
                return NULL;
        }
        if (!gdk_pixbuf_loader_close (loader, &error)) {
-               empathy_debug (DEBUG_DOMAIN, "Failed to close pixbuf loader: %s",
-                              error ? error->message : "No error given");
+               DEBUG ("Failed to close pixbuf loader: %s",
+                       error ? error->message : "No error given");
                g_clear_error (&error);
                g_object_unref (loader);
                return NULL;
@@ -535,7 +526,7 @@ empathy_pixbuf_from_icon_name (const gchar *icon_name,
                                           0,
                                           &error);
        if (error) {
-               empathy_debug (DEBUG_DOMAIN, "Error loading icon: %s", error->message);
+               DEBUG ("Error loading icon: %s", error->message);
                g_clear_error (&error);
        }
 
@@ -1303,38 +1294,45 @@ empathy_get_toplevel_window (GtkWidget *widget)
 static gchar *
 fixup_url (const gchar *url)
 {
-       gchar *real_url;
-
-       if (!g_str_has_prefix (url, "http://") &&
+       if (!g_str_has_prefix (url, "ghelp:") &&
            !strstr (url, ":/") &&
            !strstr (url, "@")) {
-               real_url = g_strdup_printf ("http://%s", url);
+               return g_strdup_printf ("http://%s", url);
        } else {
-               real_url = g_strdup (url);
+               return NULL;
        }
-
-       return real_url;
 }
 
 void
 empathy_url_show (const char *url)
 {
-       gchar          *real_url;
-       gboolean        res;
-       GError         *err;
+       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 (real_url,
-                                                NULL,
-                                                &err);
-       if (!res) {
-               empathy_debug (DEBUG_DOMAIN, "Couldn't show URL %s: %s",
-                             real_url,
-                             err->message);
-               g_error_free (err);
+       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),
+                                                         "%s", error->message);
+
+               g_signal_connect (dialog, "response",
+                                 G_CALLBACK (gtk_widget_destroy),
+                                 NULL);
+               gtk_window_present (GTK_WINDOW (dialog));
+
+               g_clear_error (&error);
        }
 
        g_free (real_url);