#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
#include <glade/glade.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#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;
va_list args)
{
GladeXML *gui;
- gchar *path;
const char *name;
GtkWidget **widget_ptr;
- path = g_build_filename (UNINSTALLED_GLADE_DIR, 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);
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;
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);
}
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;
- GnomeVFSResult res;
+ gchar *real_url;
+ GError *error = NULL;
real_url = fixup_url (url);
- res = gnome_vfs_url_show (real_url);
- if (res != GNOME_VFS_OK) {
- empathy_debug (DEBUG_DOMAIN, "Couldn't show URL %s: %s",
- real_url,
- gnome_vfs_result_to_string (res));
+ if (real_url) {
+ url = real_url;
+ }
+
+ /* FIXME: this does not work for multihead, we should use
+ * GdkAppLaunchContext or gtk_show_url, see bug #514396.
+ */
+ 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);