aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-03 18:27:00 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-04 17:10:20 +0800
commit55c0b12101a314d838aa0ba5c6a6d741063c540f (patch)
tree108ffb90e7c56adce3d922c7db426f590f1c1561 /libempathy-gtk
parentf27e9f59c9b21d4097a805abe24a769446c2351f (diff)
downloadgsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar.gz
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar.bz2
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar.lz
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar.xz
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.tar.zst
gsoc2013-empathy-55c0b12101a314d838aa0ba5c6a6d741063c540f.zip
Factor out empathy_launch_program()
https://bugzilla.gnome.org/show_bug.cgi?id=655884
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-ui-utils.c52
-rw-r--r--libempathy-gtk/empathy-ui-utils.h4
2 files changed, 56 insertions, 0 deletions
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 322f836ae..8ad7dfb4b 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -2114,3 +2114,55 @@ empathy_create_dtmf_dialpad (GObject *self,
return box;
}
+
+void
+empathy_launch_program (const gchar *dir,
+ const gchar *name,
+ const gchar *args)
+{
+ GdkDisplay *display;
+ GError *error = NULL;
+ gchar *path, *cmd;
+ GAppInfo *app_info;
+ GdkAppLaunchContext *context = NULL;
+
+ /* Try to run from source directory if possible */
+ path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), "src",
+ name, NULL);
+
+ if (!g_file_test (path, G_FILE_TEST_EXISTS))
+ {
+ g_free (path);
+ path = g_build_filename (dir, name, NULL);
+ }
+
+ if (args != NULL)
+ cmd = g_strconcat (path, " ", args, NULL);
+ else
+ cmd = g_strdup (path);
+
+ app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
+ if (app_info == NULL)
+ {
+ DEBUG ("Failed to create app info: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ display = gdk_display_get_default ();
+ context = gdk_display_get_app_launch_context (display);
+
+ if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
+ &error))
+ {
+ g_warning ("Failed to launch %s: %s", name, error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+out:
+ tp_clear_object (&app_info);
+ tp_clear_object (&context);
+ g_free (path);
+ g_free (cmd);
+}
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 1bfaf24e6..b65206bbe 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -159,6 +159,10 @@ gboolean empathy_individual_match_string (
const gchar *text,
GPtrArray *words);
+void empathy_launch_program (const gchar *dir,
+ const gchar *name,
+ const gchar *args);
+
G_END_DECLS
#endif /* __EMPATHY_UI_UTILS_H__ */