/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2002-2007 Imendio AB
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 Collabora Ltd.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
#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;
gboolean preserve_aspect_ratio;
};
-GladeXML *
-empathy_glade_get (const gchar *filename,
- const gchar *root,
- const gchar *domain)
-{
- GladeXML *gui;
- gchar *path;
-
- 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);
-
- gui = glade_xml_new (path, root, domain);
- g_free (path);
-
- if (!gui) {
- g_warning ("Couldn't find necessary glade file '%s'", filename);
- }
-
- return gui;
-}
-
static GladeXML *
get_glade_file (const gchar *filename,
const gchar *root,
const char *name;
GtkWidget **widget_ptr;
- gui = empathy_glade_get (filename, root, domain);
+ DEBUG ("Loading glade file %s", filename);
+
+ gui = glade_xml_new (filename, root, domain);
+
+ if (!gui) {
+ g_warning ("Couldn't find necessary glade file '%s'", filename);
+ }
for (name = first_required_widget; name; name = va_arg (args, char *)) {
widget_ptr = va_arg (args, void *);
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);
}
timestamp = gtk_get_current_event_time ();
gtk_window_set_skip_taskbar_hint (window, FALSE);
gtk_window_present_with_time (window, timestamp);
+ /* FIXME: This shouldn't be required as gtk_window_present's doc says
+ * it deiconify automatically. */
+ gtk_window_deiconify (window);
}
GtkWindow *
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);