Added terminal window with rerun button

pull/34/head
parent 1a2d26aef1
commit 3230c4a960

@ -89,6 +89,17 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi
else yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(data->StatusBox),"terminal_done",data->fail_label,BACKGROUND_IMAGE_FAIL_TYPE);
}
struct terminal_window {
GtkWidget *window;
GtkWidget *header;
GtkWidget *terminal;
GtkWidget *status_box;
GtkWidget *scroll;
GtkWidget *button;
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));
@ -125,6 +136,58 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi
yon_terminal_integrated_start(terminal,command);
}
void __on_terminal_window_update_clicked(GtkWidget *,struct terminal_window *window){
vte_terminal_reset(VTE_TERMINAL(window->terminal),1,1);
yon_terminal_integrated_start(window->terminal,window->command);
}
void yon_terminal_window_update_button_launch(GtkWindow *parent_window, char *command, char *success_label,char *fail_label){
struct terminal_window_struct *data = malloc(sizeof(struct terminal_window_struct));
struct terminal_window *window = malloc(sizeof(struct terminal_window));
window->command=command;
window->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
window->header = gtk_header_bar_new();
window->terminal = vte_terminal_new();
window->status_box = gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
window->button = gtk_button_new_from_icon_name("com.ublinux.libublsettingsui-gtk3.reset-symbolic",GTK_ICON_SIZE_BUTTON);
GtkWidget *box = gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
GtkWidget *box2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
GtkWidget *box3 = gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
GtkWidget *terminal_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5);
window->scroll = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL,gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(window->terminal)));
gtk_window_set_titlebar(GTK_WINDOW(window->window),window->header);
gtk_container_add(GTK_CONTAINER(window->window),box);
gtk_box_pack_start(GTK_BOX(box),window->status_box,0,0,0);
gtk_box_pack_start(GTK_BOX(box),box2,1,1,0);
gtk_box_pack_start(GTK_BOX(box2),box3,0,0,0);
gtk_box_pack_start(GTK_BOX(box2),terminal_box,1,1,0);
gtk_box_pack_start(GTK_BOX(box3),window->button,0,0,0);
gtk_box_pack_start(GTK_BOX(terminal_box),window->terminal,1,1,0);
gtk_box_pack_start(GTK_BOX(terminal_box),window->scroll,0,0,0);
gtk_style_context_add_class(gtk_widget_get_style_context(window->button),"thin");
gtk_widget_set_margin_bottom(box2,5);
gtk_widget_set_margin_start(box2,5);
gtk_widget_set_margin_end(box2,5);
gtk_widget_show_all(window->window);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(window->terminal),-1);
gtk_window_set_modal(GTK_WINDOW(window->window),1);
gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(window->header),1);
gtk_window_set_title(GTK_WINDOW(window->window),gtk_window_get_title(parent_window));
gtk_window_set_icon_name(GTK_WINDOW(window->window),gtk_window_get_icon_name(parent_window));
data->StatusBox=window->status_box;
data->success_label=success_label;
data->fail_label=fail_label;
g_signal_connect(G_OBJECT(window->terminal), "child-exited", G_CALLBACK(__on_yon_terminal_done), data);
g_signal_connect(G_OBJECT(window->button), "clicked", G_CALLBACK(__on_terminal_window_update_clicked), window);
yon_terminal_integrated_start(window->terminal,command);
}
void yon_gtk_set_scroll(GtkWidget* self,GdkEventScroll *event, GtkAdjustment *adjustment){
if (self){};
gdouble val = gtk_adjustment_get_value(adjustment);

@ -44,6 +44,8 @@ void yon_terminal_integrated_start_shell(GtkWidget *terminal, char* command, voi
void yon_terminal_window_launch(GtkWindow *parent_window, char *command, char *success_label,char *fail_label);
void yon_terminal_window_update_button_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))
/**yon_gtk_widget_set_scroll_window_for_scroll(GtkWidget *target, GtkScrollbar *scroll)

Loading…
Cancel
Save