How to Launch "Application in Terminal" from (your) GTK Application
system(3)
executes an external command. This is an example that the external command is a CUI application.
If system(3)
is called from CUI application, standard output can be write to the terminal and standard input can be read from the terminal. But GTK+ applications (or any other typical GUI application) don't have the terminal.
For GTK+ application (without the terminal), the external command must be launch with terminal emulator.
Here is a simple example of launching /path/to/shellscript.sh
with terminal emulator.
It's simple. But hard-coding "xterm -e "
is not smart.
Following example is depends on User's terminal emulator preference (e.g. Gnome Preferred Applications preference tool):
Note that:
- In this way, external application execute background. (
system(3)
function is foreground) - On my environment, following code does not work (segmentation fault at calling
g_app_info_create_from_commandline()
). GTK seems to be required.