Let the terminal emulation program be configured
This commit is contained in:
parent
38a446a4eb
commit
acb229a6c8
20
src/run.c
20
src/run.c
|
@ -20,6 +20,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <libgen.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
@ -323,21 +324,32 @@ static void _on_run_execute(gpointer data)
|
||||||
| G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD;
|
| G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD;
|
||||||
const unsigned int timeout = 30000;
|
const unsigned int timeout = 30000;
|
||||||
Run * run = data;
|
Run * run = data;
|
||||||
char const * path;
|
|
||||||
char * argv_shell[] = { "/bin/sh", PROGNAME, "-c", NULL, NULL };
|
char * argv_shell[] = { "/bin/sh", PROGNAME, "-c", NULL, NULL };
|
||||||
char * argv_xterm[] = { PROGNAME_XTERM, PROGNAME_XTERM, "-e", "sh",
|
char * argv_xterm[] = { PROGNAME_XTERM, PROGNAME_XTERM, "-e", "sh",
|
||||||
"-c", NULL, NULL };
|
"-c", NULL, NULL };
|
||||||
|
char * xterm = NULL;
|
||||||
char ** argv = argv_shell;
|
char ** argv = argv_shell;
|
||||||
|
char const * p;
|
||||||
GError * error = NULL;
|
GError * error = NULL;
|
||||||
|
|
||||||
path = gtk_entry_get_text(GTK_ENTRY(run->entry));
|
p = gtk_entry_get_text(GTK_ENTRY(run->entry));
|
||||||
if((argv_shell[3] = strdup(path)) == NULL)
|
if((argv_shell[3] = strdup(p)) == NULL)
|
||||||
{
|
{
|
||||||
_run_error(run, strerror(errno), 1);
|
_run_error(run, strerror(errno), 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(run->terminal)
|
if(run->terminal)
|
||||||
{
|
{
|
||||||
|
if((p = config_get(run->config, NULL, "xterm")) != NULL)
|
||||||
|
{
|
||||||
|
if((xterm = strdup(p)) == NULL)
|
||||||
|
{
|
||||||
|
_run_error(run, strerror(errno), 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
argv_xterm[0] = xterm;
|
||||||
|
argv_xterm[1] = basename(xterm);
|
||||||
|
}
|
||||||
argv_xterm[5] = argv_shell[3];
|
argv_xterm[5] = argv_shell[3];
|
||||||
argv = argv_xterm;
|
argv = argv_xterm;
|
||||||
}
|
}
|
||||||
|
@ -347,9 +359,11 @@ static void _on_run_execute(gpointer data)
|
||||||
_run_error(run, error->message, 1);
|
_run_error(run, error->message, 1);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
free(argv_shell[3]);
|
free(argv_shell[3]);
|
||||||
|
free(xterm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(argv_shell[3]);
|
free(argv_shell[3]);
|
||||||
|
free(xterm);
|
||||||
gtk_widget_hide(run->window);
|
gtk_widget_hide(run->window);
|
||||||
g_child_watch_add(run->pid, _execute_watch, run);
|
g_child_watch_add(run->pid, _execute_watch, run);
|
||||||
run->source = g_timeout_add(timeout, _execute_timeout, run);
|
run->source = g_timeout_add(timeout, _execute_timeout, run);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user