Unify the spawn callers error messages: context action
This commit is contained in:
parent
421f8a0ce0
commit
897197ae51
@ -1452,6 +1452,7 @@ void on_context_action1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||
gchar *word, *command;
|
||||
GError *error = NULL;
|
||||
GeanyDocument *doc = document_get_current();
|
||||
const gchar *format;
|
||||
|
||||
g_return_if_fail(doc != NULL);
|
||||
|
||||
@ -1469,22 +1470,29 @@ void on_context_action1_activate(GtkMenuItem *menuitem, gpointer user_data)
|
||||
!EMPTY(doc->file_type->context_action_cmd))
|
||||
{
|
||||
command = g_strdup(doc->file_type->context_action_cmd);
|
||||
format = _("Cannot execute context action command \"%s\": %s. "
|
||||
"Check the path setting in Preferences.");
|
||||
}
|
||||
else
|
||||
{
|
||||
command = g_strdup(tool_prefs.context_action_cmd);
|
||||
format = _("Cannot execute context action command \"%s\": %s. "
|
||||
"Check the path setting in Filetype configuration.");
|
||||
}
|
||||
|
||||
/* substitute the wildcard %s and run the command if it is non empty */
|
||||
if (G_LIKELY(!EMPTY(command)))
|
||||
{
|
||||
utils_str_replace_all(&command, "%s", word);
|
||||
gchar *command_line = g_strdup(command);
|
||||
|
||||
if (!spawn_async(NULL, command, NULL, NULL, NULL, &error))
|
||||
utils_str_replace_all(&command_line, "%s", word);
|
||||
|
||||
if (!spawn_async(NULL, command_line, NULL, NULL, NULL, &error))
|
||||
{
|
||||
ui_set_statusbar(TRUE, "Context action command failed: %s", error->message);
|
||||
ui_set_statusbar(TRUE, format, command, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
g_free(command_line);
|
||||
}
|
||||
g_free(word);
|
||||
g_free(command);
|
||||
|
Loading…
x
Reference in New Issue
Block a user