Merge pull request 'Test fix for terminal' (#15) from YanTheKaller/libublsettings-gtk3:master into master

Reviewed-on: #15
master v1.13
Dmitry Razumov 2 years ago
commit c42a9f0611

@ -1,7 +1,10 @@
#define VTE_INCLUDE
#include "libublsettings-gtk3.h"
#undef VTE_INCLUDE
#ifdef __GTK_H__
static render_data render;
// vte section
@ -16,7 +19,10 @@ static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){
GtkWidget *terminal = vte_terminal_new();
int size;
config_str parsed = yon_char_parse(command,&size," ");
config_str parsed = NULL;
yon_char_parsed_add_or_create_if_exists(parsed,&size,"/usr/bin/bash");
yon_char_parsed_add_or_create_if_exists(parsed,&size,"-c");
yon_char_parsed_add_or_create_if_exists(parsed,&size,yon_char_unite("\"",command,"\"",NULL));
yon_char_parsed_add_or_create_if_exists(parsed,&size,NULL);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),VTE_PTY_NO_HELPER,NULL,parsed,NULL,G_SPAWN_SEARCH_PATH,NULL,NULL,NULL,2000,NULL,NULL,NULL);
vte_terminal_set_size(VTE_TERMINAL(terminal),10,15);
@ -28,14 +34,57 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi
gtk_widget_show_all(terminal);
}
void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){
void yon_terminal_integrated_start(GtkWidget *terminal, char* command){
int size;
gchar *envv[] = { NULL };
config_str parsed = yon_char_parse(command,&size," ");
yon_char_parsed_add_or_create_if_exists(parsed,&size,"\0");
yon_char_parsed_add_or_create_if_exists(parsed,&size,NULL);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),VTE_PTY_NO_HELPER,NULL,parsed,NULL,G_SPAWN_SEARCH_PATH,NULL,NULL,NULL,2000,NULL,NULL,NULL);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),VTE_PTY_NO_HELPER,"/bin",parsed,envv,G_SPAWN_SEARCH_PATH,NULL,NULL,NULL,20,NULL,NULL,NULL);
vte_terminal_set_size(VTE_TERMINAL(terminal),10,15);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1);
vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE);
gtk_widget_show_all(terminal);
}
void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){
char **commands=new_arr(char*,2);
gchar **envp = g_get_environ();
commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL"));
commands[1]=NULL;
char **env=new_arr(char*,2);
env[0]="";
env[1]=NULL;
vte_terminal_set_size(VTE_TERMINAL(terminal),10,15);
VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL);
vte_terminal_set_pty(VTE_TERMINAL(terminal),pty);
char *install_command=yon_char_unite("clear;tput cup 0 0 && tput ed && ",command," ; stty -echo; unset PS1","\n",NULL);
if(endwork_function)
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),
VTE_PTY_DEFAULT,
NULL,
commands,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
child_ready,
install_command);
vte_pty_spawn_async(pty,
NULL,
commands,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
NULL,
NULL);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1);
vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE);

@ -22,16 +22,25 @@
*/
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument);
/**yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument)
/**yon_terminal_integrated_start(GtkWidget *terminal, char* command)
* [EN]
* launches terminal with specific [command],
* terminal is shown in [place_to_show] container.
* [RU]
* Запускает терминал с командой [command].
*/
void yon_terminal_integrated_start(GtkWidget *terminal, char* command);
/**yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument)
* [EN]
* launches terminal with shell and executes specific [command],
* terminal is shown in [place_to_show] container,
* after terminal done its work [endwork_function] is called with [endwork_function_argument] argument.
* [RU]
* Запускает терминал с командой [command],
* Запускает терминал оболочкой для выполнения команды [command],
* после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument].
*/
void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
#endif

Loading…
Cancel
Save