diff options
author | Juhani Krekelä | 2021-07-24 19:15:11 +0300 |
---|---|---|
committer | Wolfgang Müller | 2021-07-24 18:55:06 +0200 |
commit | adc794f2533fa3c56d30d6906a9c4b328baeb632 (patch) | |
tree | 9f1f8ee2b7a0d3831a1b9b0b99aab1cffdbb6803 | |
parent | 4295134455ea99ad14a0eb43ed31e03fbeebb623 (diff) | |
download | weltschmerz-adc794f2533fa3c56d30d6906a9c4b328baeb632.tar.gz |
Move spawning a subprocess into its own function
The upcoming "Open with …" feature will need to spawn subprocesses in
very similar way as open_terminal(). Moving process creation to its own
function allows the same logic to be reused.
Diffstat (limited to '')
-rw-r--r-- | terminal.vala | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/terminal.vala b/terminal.vala index 13409f4..0013abd 100644 --- a/terminal.vala +++ b/terminal.vala @@ -352,16 +352,11 @@ class Terminal : Gtk.Overlay { return path; } - [GtkCallback] - void open_terminal() { - var cwd = get_local_directory_path(); - if (cwd == null) - return; - + void spawn_process(string? cwd, string[] argv) { Pid child; try { - Process.spawn_async(cwd, {PROGRAM_NAME}, Environ.get(), SpawnFlags.SEARCH_PATH, null, out child); + Process.spawn_async(cwd, argv, null, SpawnFlags.SEARCH_PATH, null, out child); } catch (Error e) { warning(e.message); infobar_show(e.message, Gtk.MessageType.ERROR); @@ -371,6 +366,14 @@ class Terminal : Gtk.Overlay { } [GtkCallback] + void open_terminal() { + var cwd = get_local_directory_path(); + if (cwd == null) + return; + spawn_process(cwd, {PROGRAM_NAME}); + } + + [GtkCallback] void open_directory() { var cwd = get_local_directory_path(); if (cwd == null) |