Changed terminal window launching functions

pull/32/head
Ivan Dmitrievich Yartsev 10 months ago
parent 9b24caa262
commit a4634ea57f

@ -308,4 +308,17 @@ void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int ti
g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),statusstruct); g_signal_connect(G_OBJECT(revealer),"destroy", G_CALLBACK(__yon_ubl_status_box_destroyed),statusstruct);
GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct); GThread *thread = g_thread_new("StatusThread",(GThreadFunc)_yon_ubl_status_box_timed_remove,statusstruct);
} }
}
int yon_ubl_status_set_text(GtkContainer *status_placeholder,char *text){
GList *placeholder_children = gtk_container_get_children(status_placeholder);
if (placeholder_children){
GList *status_children = gtk_container_get_children(GTK_CONTAINER(placeholder_children->data));
if (status_children){
gtk_label_set_text(GTK_LABEL(g_list_nth_data(status_children,1)),text);
g_list_free(status_children);
}
g_list_free(placeholder_children);
}
return 0;
} }

@ -78,13 +78,20 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi
gtk_widget_show_all(terminal); gtk_widget_show_all(terminal);
} }
struct terminal_window_struct{
GtkWidget *StatusBox;
char *success_label;
char *fail_label;
};
void __on_yon_terminal_done(GtkWidget *, int state, GtkWidget *status_box){ void __on_yon_terminal_done(GtkWidget *, int state, struct terminal_window_struct *data){
if (!state) yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(status_box),"terminal_done","",BACKGROUND_IMAGE_SUCCESS_TYPE); if (!state) yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(data->StatusBox),"terminal_done",data->success_label,BACKGROUND_IMAGE_SUCCESS_TYPE);
else yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(status_box),"terminal_done","",BACKGROUND_IMAGE_FAIL_TYPE); else yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(data->StatusBox),"terminal_done",data->fail_label,BACKGROUND_IMAGE_FAIL_TYPE);
} }
void yon_terminal_window_launch(GtkWindow *parent_window, char *command){ void yon_terminal_window_launch(GtkWindow *parent_window, char *command, char *success_label,char *fail_label){
struct terminal_window_struct *data = malloc(sizeof(struct terminal_window_struct));
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *header = gtk_header_bar_new(); GtkWidget *header = gtk_header_bar_new();
GtkWidget *terminal = vte_terminal_new(); GtkWidget *terminal = vte_terminal_new();
@ -110,7 +117,11 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi
gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1);
gtk_window_set_title(GTK_WINDOW(window),gtk_window_get_title(parent_window)); gtk_window_set_title(GTK_WINDOW(window),gtk_window_get_title(parent_window));
gtk_window_set_icon_name(GTK_WINDOW(window),gtk_window_get_icon_name(parent_window)); gtk_window_set_icon_name(GTK_WINDOW(window),gtk_window_get_icon_name(parent_window));
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(__on_yon_terminal_done), status_box);
data->StatusBox=status_box;
data->success_label=success_label;
data->fail_label=fail_label;
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(__on_yon_terminal_done), data);
yon_terminal_integrated_start(terminal,command); yon_terminal_integrated_start(terminal,command);
} }

@ -42,7 +42,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command);
*/ */
void yon_terminal_integrated_start_shell(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);
void yon_terminal_window_launch(GtkWindow *parent_window, char *command); void yon_terminal_window_launch(GtkWindow *parent_window, char *command, char *success_label,char *fail_label);
#define for_iter(model,iter) for(int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),iter);valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model),iter)) #define for_iter(model,iter) for(int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model),iter);valid;valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model),iter))
@ -418,6 +418,8 @@ int yon_ubl_status_box_despawn_infinite(GtkContainer *container);
*/ */
void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type); void yon_ubl_status_box_spawn(GtkContainer *container,char *display_text, int timeout,BACKGROUND_IMAGE_TYPE type);
int yon_ubl_status_set_text(GtkContainer *status_placeholder,char *text);
/**yon_ubl_header_setup(overlay, head, image, imag_path) /**yon_ubl_header_setup(overlay, head, image, imag_path)
* [EN] * [EN]
* Sets up header of app. * Sets up header of app.

Loading…
Cancel
Save