From 3d6fafaa192150a01e409b7137b6d039f6258c23 Mon Sep 17 00:00:00 2001 From: Andre Miranda <andreldm@xfce.org> Date: Sat, 17 Feb 2018 11:14:50 -0300 Subject: [PATCH] Fix the --open command line option (Bug #14225) This option doesn't use AppInfo, so I had to restore the code that used g_spawn_command_line_async, removed in e86731e. --- lib/screenshooter-utils.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/screenshooter-utils.c b/lib/screenshooter-utils.c index 76080d4f..de6d69e6 100644 --- a/lib/screenshooter-utils.c +++ b/lib/screenshooter-utils.c @@ -159,9 +159,11 @@ screenshooter_write_rc_file (const gchar *file, ScreenshotData *sd) void screenshooter_open_screenshot (const gchar *screenshot_path, const gchar *application, GAppInfo *const app_info) { - GError *error = NULL; gpointer screenshot_file = NULL; - GList *files = NULL; + gboolean success = TRUE; + gchar *command; + GError *error = NULL; + GList *files = NULL; g_return_if_fail (screenshot_path != NULL); @@ -172,23 +174,31 @@ screenshooter_open_screenshot (const gchar *screenshot_path, const gchar *applic TRACE ("Application was not none"); - g_return_if_fail (app_info != NULL); + if (app_info != NULL) + { + TRACE ("Launch the app"); - TRACE ("app_info was != NULL"); + screenshot_file = g_file_new_for_path (screenshot_path); + files = g_list_append (NULL, screenshot_file); + success = g_app_info_launch (app_info, files, NULL, &error); + g_list_free_full (files, g_object_unref); + } + else if (application != NULL) + { + TRACE ("Launch the command"); - screenshot_file = g_file_new_for_path (screenshot_path); - files = g_list_append (NULL, screenshot_file); + command = g_strconcat (application, " ", "\"", screenshot_path, "\"", NULL); + success = g_spawn_command_line_async (command, &error); + g_free (command); + } - TRACE ("Launch the command"); - if (!g_app_info_launch (app_info, files, NULL, &error)) + /* report any error */ + if (!success && error != NULL) { TRACE ("An error occured"); - screenshooter_error (_("<b>The application could not be launched.</b>\n%s"), error->message); g_error_free (error); } - - g_list_free_full (files, g_object_unref); } -- GitLab