aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2012-08-03 20:00:48 +0800
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-08-15 14:05:26 +0800
commitf4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1 (patch)
treea1a58418be88ae87be52200f5b1a216c13fc531f
parent1f872789f7cba0934744071fa85ad6bd7c35abdc (diff)
downloadgsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar.gz
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar.bz2
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar.lz
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar.xz
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.tar.zst
gsoc2013-empathy-f4fc6c6be76bb4cdfb4ebda9ca7de6758f2f18d1.zip
factor out empathy_launch_external_app()
https://bugzilla.gnome.org/show_bug.cgi?id=680778
-rw-r--r--libempathy-gtk/empathy-ui-utils.c48
-rw-r--r--libempathy-gtk/empathy-ui-utils.h3
-rw-r--r--src/empathy-accounts-dialog.c20
3 files changed, 53 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 7c6c6a7f0..905037bf8 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -37,6 +37,7 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <gio/gdesktopappinfo.h>
#include <telepathy-glib/util.h>
#include <folks/folks.h>
@@ -1641,3 +1642,50 @@ out:
g_free (filename);
g_object_unref (provider);
}
+
+static gboolean
+launch_app_info (GAppInfo *app_info,
+ GError **error)
+{
+ GdkAppLaunchContext *context = NULL;
+ GdkDisplay *display;
+ GError *err = NULL;
+
+ display = gdk_display_get_default ();
+ context = gdk_display_get_app_launch_context (display);
+
+ if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
+ &err))
+ {
+ DEBUG ("Failed to launch %s: %s",
+ g_app_info_get_display_name (app_info), err->message);
+ g_propagate_error (error, err);
+ return FALSE;
+ }
+
+ tp_clear_object (&context);
+ return TRUE;
+}
+
+gboolean
+empathy_launch_external_app (const gchar *desktop_file,
+ GError **error)
+{
+ GDesktopAppInfo *desktop_info;
+ gboolean result;
+
+ desktop_info = g_desktop_app_info_new (desktop_file);
+ if (desktop_info == NULL)
+ {
+ DEBUG ("%s not found", desktop_file);
+
+ g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ "%s not found", desktop_file);
+ return FALSE;
+ }
+
+ result = launch_app_info (G_APP_INFO (desktop_info), error);
+ g_object_unref (desktop_info);
+
+ return result;
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index fdf69df06..97777e5b6 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -147,6 +147,9 @@ void empathy_launch_program (const gchar *dir,
void empathy_set_css_provider (GtkWidget *widget);
+gboolean empathy_launch_external_app (const gchar *desktop_file,
+ GError **error);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 74e2e3d69..a4096b86f 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -662,22 +662,6 @@ start_external_app (GAppInfo *app_info)
}
static void
-start_from_desktop_file (const char *desktop)
-{
- GDesktopAppInfo *desktop_info;
-
- desktop_info = g_desktop_app_info_new (desktop);
- if (desktop_info == NULL)
- {
- g_critical ("Could not locate '%s'", desktop);
- return;
- }
-
- start_external_app (G_APP_INFO (desktop_info));
- g_object_unref (desktop_info);
-}
-
-static void
use_external_storage_provider (EmpathyAccountsDialog *self,
TpAccount *account)
{
@@ -721,12 +705,12 @@ use_external_storage_provider (EmpathyAccountsDialog *self,
}
else if (!tp_strdiff (provider, EMPATHY_GOA_PROVIDER))
{
- start_from_desktop_file ("gnome-online-accounts-panel.desktop");
+ empathy_launch_external_app ("gnome-online-accounts-panel.desktop", NULL);
return;
}
else if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER))
{
- start_from_desktop_file ("gnome-credentials-panel.desktop");
+ empathy_launch_external_app ("gnome-credentials-panel.desktop", NULL);
return;
}
else