From 4e94ec8647af1335f84ebbedcd0369ca50eca3ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberts=20Muktup=C4=81vels?= Date: Thu, 3 Jul 2014 00:34:25 +0300 Subject: [PATCH] clock: fix Evolution opening from applet --- applets/clock/calendar-window.c | 64 ++++++++++------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 7fc6f86..a750fc1 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -128,30 +128,17 @@ static GtkWidget * create_hig_frame (CalendarWindow *calwin, #ifdef HAVE_EDS -/* - * Set the DISPLAY variable, to be use by g_spawn_async. - */ -static void -set_environment (gpointer display) -{ - g_setenv ("DISPLAY", display, TRUE); -} - static void clock_launch_calendar_tasks_app (CalendarWindow *calwin, const char *schema_program, const char *argument) { GSettings *settings; - char **argv; - int argc; char *program; + char *commandline; gboolean terminal; - char *command_line; - GdkScreen *screen; - GError *error; - gboolean result; - char *display; + GError *error = NULL; + GAppInfo *app_info; settings = g_settings_new (schema_program); program = g_settings_get_string (settings, "exec"); @@ -170,47 +157,26 @@ clock_launch_calendar_tasks_app (CalendarWindow *calwin, return; } - command_line = g_find_program_in_path (program); - if (command_line == NULL) { - g_printerr ("Cannot launch calendar/tasks application: %s in path\n", program); - g_free (program); - return; - } - g_free (command_line); - if (argument) { - argc = 2; - argv = g_new0 (char *, 3); - argv[1] = g_strdup (argument); + commandline = g_strdup_printf ("%s %s", program, argument); } else { - argc = 1; - argv = g_new0 (char *, 2); + commandline = g_strdup (program); } - argv[0] = program; /* no strdup, and it will get freed for free */ - - screen = gtk_widget_get_screen (calwin->priv->calendar); - error = NULL; - - display = gdk_screen_make_display_name (screen); - - result = g_spawn_async (NULL, /* working directory */ - argv, - NULL, /* envp */ - G_SPAWN_SEARCH_PATH, - set_environment, /* child setup func */ - &display, /* user data for child setup */ - NULL, /* child pid */ - &error); - g_free (display); + app_info = g_app_info_create_from_commandline (commandline, NULL, G_APP_INFO_CREATE_NONE, &error); + g_free (commandline); + g_free (program); - if (!result) { - g_printerr ("Cannot launch calendar/tasks application: %s\n", - error->message); + if (error) { + g_printerr ("Cannot launch calendar/tasks application: %s\n", error->message); g_error_free (error); + return; } - g_strfreev (argv); + if (!g_app_info_launch (app_info, NULL, NULL, &error)) { + g_printerr ("Cannot launch calendar/tasks application: %s\n", error->message); + g_error_free (error); + } } static void -- 2.0.1