Handle more tokens in sokoke_spawn_program

This commit is contained in:
Christian Dywan 2012-07-08 14:39:42 +02:00
parent 8ad44b86c3
commit 0c201ca2b8
3 changed files with 12 additions and 9 deletions

View file

@ -491,7 +491,7 @@ addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
g_object_get (settings, "text-editor", &text_editor, NULL); g_object_get (settings, "text-editor", &text_editor, NULL);
if (text_editor && *text_editor) if (text_editor && *text_editor)
sokoke_spawn_program (text_editor, TRUE, element->fullpath, TRUE); sokoke_spawn_program (text_editor, FALSE, element->fullpath, TRUE);
else else
{ {
gchar* element_uri = g_filename_to_uri (element->fullpath, NULL, NULL); gchar* element_uri = g_filename_to_uri (element->fullpath, NULL, NULL);

View file

@ -3498,7 +3498,7 @@ _action_source_view_activate (GtkAction* action,
} }
else else
{ {
sokoke_spawn_program (text_editor, TRUE, filename, TRUE); sokoke_spawn_program (text_editor, FALSE, filename, TRUE);
g_free (filename); g_free (filename);
} }
g_free (text_editor); g_free (text_editor);

View file

@ -408,16 +408,19 @@ sokoke_prepare_command (const gchar* command,
gchar* real_command; gchar* real_command;
gchar* command_ready; gchar* command_ready;
/* .desktop files accept %u as URI, we cheap and treat it like %s */
if ((uri_format = strstr (command, "%u")))
uri_format[1] = 's';
real_command = quote_command ? g_shell_quote (command) : g_strdup (command); real_command = quote_command ? g_shell_quote (command) : g_strdup (command);
if (strstr (command, "%s")) /* .desktop files accept %u, %U, %f, %F as URI/ filename, we treat it like %s */
if ((uri_format = strstr (real_command, "%u"))
|| (uri_format = strstr (real_command, "%U"))
|| (uri_format = strstr (real_command, "%f"))
|| (uri_format = strstr (real_command, "%F")))
uri_format[1] = 's';
if (strstr (real_command, "%s"))
{ {
gchar* argument_quoted = g_shell_quote (argument); gchar* argument_quoted = quote_argument ? g_shell_quote (argument) : g_strdup (argument);
command_ready = sokoke_replace_variables (real_command, "%s", argument_quoted); command_ready = g_strdup_printf (real_command, argument_quoted);
g_free (argument_quoted); g_free (argument_quoted);
} }
else if (quote_argument) else if (quote_argument)