diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index dc25088..b0fba42 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -24,7 +24,7 @@ set(SOURCE_FILES set(LIBRARIES ${GTK_LIBRARIES} pthread - vte) + vte-2.91) add_executable(ubl-settings-video ${SOURCE_FILES}) diff --git a/source/ubl-settings-video.c b/source/ubl-settings-video.c index 944aff4..d758d57 100644 --- a/source/ubl-settings-video.c +++ b/source/ubl-settings-video.c @@ -72,6 +72,12 @@ void on_monitor_config_save(GtkWidget *self, monitor_edit_window *window){ on_subwindow_close(self); } +static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) +{ + if (!terminal) return; + if (pid == -1) printf("Error\n\n\n"); +} + void on_driver_pack_install(GtkWidget *self,widgets_dict *widgets){ GtkTreeIter iter; char *name; @@ -80,7 +86,50 @@ void on_driver_pack_install(GtkWidget *self,widgets_dict *widgets){ gtk_tree_selection_get_selected(selection,&list_s,&iter); gtk_tree_model_get(list_s,&iter,1,&name,-1); pthread_t tid; - pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(install_proprietary_command,name)); + char **command=new_arr(char*,2); + gchar **envp = g_get_environ(); + command[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); + command[1]=NULL; + char **env=new_arr(char*,2); + env[0]=""; + env[1]=NULL; + + GtkWidget *terminal = vte_terminal_new(); + // vte_terminal_set_size(VTE_TERMINAL(terminal),50,100); + gtk_box_pack_start(GTK_BOX(widgets->TerminalBox),terminal,1,1,0); + VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); + // VtePty *pty = vte_terminal_pty_new_sync(VTE_TERMINAL(terminal),VTE_PTY_DEFAULT,NULL,NULL); + vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); + vte_terminal_spawn_async(VTE_TERMINAL(terminal), + VTE_PTY_DEFAULT, + NULL, /* working directory */ + command, /* command */ + NULL, /* environment */ + 0, /* spawn flags */ + NULL, NULL, /* child setup */ + NULL, /* child pid */ + -1, /* timeout */ + NULL, /* cancellable */ + child_ready, /* callback */ + NULL); /* user_data */ + vte_pty_spawn_async(pty, + NULL, /* working directory */ + command, /* command */ + NULL, /* environment */ + 0, /* spawn flags */ + NULL, NULL, /* child setup */ + NULL, /* child pid */ + -1, /* timeout */ + NULL, /* cancellable */ + NULL, /* callback */ + NULL); /* user_data */ + char *install_command=yon_char_unite(install_proprietary_command,name,"\n",NULL); + vte_terminal_feed_child(VTE_TERMINAL(terminal),install_command,strlen(install_command)); + vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 0); + vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), FALSE); + vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); + gtk_widget_show_all(widgets->TerminalWindow); + // pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(install_proprietary_command,name)); } @@ -93,7 +142,7 @@ void on_driver_install(GtkWidget *self,widgets_dict *widgets){ gtk_tree_selection_get_selected(selection,&list_s,&iter); gtk_tree_model_get(list_s,&iter,1,&name,-1); pthread_t tid; - pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(install_proprietary_command,name)); + // pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(install_proprietary_command,name)); } @@ -106,7 +155,7 @@ void on_driver_pack_delete(GtkWidget *self,widgets_dict *widgets){ gtk_tree_selection_get_selected(selection,&list_s,&iter); gtk_tree_model_get(list_s,&iter,1,&name,-1); pthread_t tid; - pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(delete_proprietary_command,name)); + // pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(delete_proprietary_command,name)); } @@ -119,7 +168,7 @@ void on_driver_delete(GtkWidget *self,widgets_dict *widgets){ gtk_tree_selection_get_selected(selection,&list_s,&iter); gtk_tree_model_get(list_s,&iter,1,&name,-1); pthread_t tid; - pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(delete_proprietary_command,name)); + // pthread_create(&tid,NULL,(void*)yon_launch_with_output,(void*)yon_char_get_augumented(delete_proprietary_command,name)); } @@ -562,29 +611,33 @@ void yon_popen(thread_input *input){ *(FILE**)input->data=popen(input->command,"r"); } -void yon_launch_with_output(char *command){ - pthread_t tid; - FILE *output =NULL; - FILE **output_file=&output; - thread_input input; - input.command=command; - input.data=output_file; - pthread_create(&tid,NULL,(void*)yon_popen,&input); - // char **output_strings = NULL; - // output_strings = malloc(sizeof(char)); - // int i = 0; - // char str[1000]; - // memset(str, 0, 1000); - // while (1){ - // if (output){ - // if (fgets(str, 1000, output)){ - // videoconfig.status_render.text_to_render=str; - // videoconfig.status_render.type=BACKGROUND_IMAGE_SUCCESS_TYPE; - // _yon_ubl_status_box_render(&videoconfig.status_render); - // } - // } - // } -} +// void yon_launch_with_output(char *command){ +// pthread_t tid; +// FILE *output =NULL; +// FILE **output_file=&output; +// thread_input input; +// input.command=command; +// input.data=output_file; +// pthread_create(&tid,NULL,(void*)yon_popen,&input); +// char *output_strings = ""; +// int i = 0; +// char str[1000]; +// memset(str, 0, 1000); +// while (1){ +// clock(); +// if (output){ +// if (fgets(str, 1000, output)){ +// output_strings=yon_char_get_augumented(output_strings,str); +// videoconfig.status_render.text_to_render=output_strings; +// videoconfig.status_render.type=BACKGROUND_IMAGE_SUCCESS_TYPE; +// _yon_ubl_status_box_render(&videoconfig.status_render); +// } +// } +// float passed = clock(); +// if ((passed=passed/_SC_CLK_TCK)<0.5) +// sleep(passed); +// } +// } /**void yon_monitor_view_draw_all(GtkWidget *cnt) * [EN] @@ -1224,6 +1277,9 @@ void yon_setup_widgets(widgets_dict *widgets) widgets->driversInfoButton = yon_gtk_builder_get_widget(widgets->builder, "driversInfoButton"); widgets->driversDeleteButton = yon_gtk_builder_get_widget(widgets->builder, "driversDeleteButton"); widgets->driversInstallButton = yon_gtk_builder_get_widget(widgets->builder, "driversInstallButton"); + widgets->TerminalWindow = yon_gtk_builder_get_widget(widgets->builder, "TerminalWindow"); + widgets->TerminalBox = yon_gtk_builder_get_widget(widgets->builder, "TerminalBox"); + widgets->TerminalHeaderTitleLabel = yon_gtk_builder_get_widget(widgets->builder, "TerminalHeaderTitleLabel"); widgets->driversTreeSelection = GTK_TREE_SELECTION(gtk_builder_get_object(widgets->builder, "driversTreeSelection")); widgets->proprietartInstalledColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(widgets->builder, "proprietartInstalledColumn")); diff --git a/source/ubl-settings-video.h b/source/ubl-settings-video.h index 4708913..9845eba 100644 --- a/source/ubl-settings-video.h +++ b/source/ubl-settings-video.h @@ -1,7 +1,9 @@ #include #include +#include #include #include +#include #include #include #include @@ -51,7 +53,7 @@ #define remove_drivers_local_command "/usr/bin/ubconfig --target global remove video " -#define install_proprietary_command "pkexec pacman -Sy --noconfirm " +#define install_proprietary_command "pkexec pacman -Sy " #define delete_proprietary_command "pkexec pacman -R --noconfirm " @@ -230,6 +232,10 @@ typedef struct GtkTreeViewColumn *driverDriverColumn; GtkTreeViewColumn *driverDescriptionColumn; GtkTreeViewColumn *driverSupportedColumn; + + GtkWidget *TerminalWindow; + GtkWidget *TerminalBox; + GtkWidget *TerminalHeaderTitleLabel; } widgets_dict; typedef struct diff --git a/ubl-settings-video.glade b/ubl-settings-video.glade index b6a02ac..a7e9fd4 100644 --- a/ubl-settings-video.glade +++ b/ubl-settings-video.glade @@ -99,6 +99,59 @@ + + 800 + 400 + False + 800 + 400 + com.ublinux.ubl-settings-video + + + True + False + vertical + + + + + + + + True + False + True + + + True + False + start + 5 + 5 + 5 + 5 + False + UBlinux Video Configuration + + + + + + + + True + False + 5 + 5 + 5 + 5 + 32 + com.ublinux.ubl-settings-video + + + + + False @@ -989,20 +1042,38 @@ - + True - False - start - 5 - 5 - 5 - 5 - 6 - 6 - - - - + True + + + True + False + + + True + False + start + 5 + 5 + 5 + 5 + 6 + 6 + + + + + + + + + + True