Added terminal function, added socket set up function, added function for freeing dictionary

pull/11/head
parent 57d51956bb
commit 6f0941a528

@ -232,6 +232,24 @@ dictionary *yon_dictionary_create_with_data(char *key, void *data)
return dct;
}
/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation)
* [EN]
* Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary.
* [RU]
* Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря.
*/
void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){
dictionary *dict=NULL;
for_dictionaries(dict,dictionary_to_free){
if(data_manipulation)
data_manipulation(dict->data);
if(dict->prev)
free(dict->prev);
}
free(dict);
return NULL;
}
dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data)
{
dictionary *dct = yon_dictionary_create_conneced(dict);
@ -781,8 +799,61 @@ int yon_launch(thread_output *thread)
// Gtk functions
#ifdef __GTK_H__
#ifdef VTE_TERMINAL
/**
* void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument)
* [EN]
* launches terminal with 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],
* терминал добавляется в контейнер [place_to_show] виджета,
* после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument].
*/
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument){
GtkWidget *terminal = vte_terminal_new();
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("tput cup 0 0 && tput ed; ",command," ; sleep 5;exit 0","\n",NULL);
g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(on_terminal_done), widgets);
vte_terminal_spawn_async(VTE_TERMINAL(terminal),
VTE_PTY_DEFAULT,
NULL,
install_command,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
NULL,
NULL);
vte_pty_spawn_async(pty,
NULL,
install_command,
NULL,
0,
NULL, NULL,
NULL,
-1,
NULL,
NULL,
NULL);
vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), 100);
vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE);
vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE);
gtk_widget_show_all(widgets->TerminalRevealer);
}
#endif
// dictionary *yon_gtk_app_chooser_create(GtkBuilder *builder){
// GtkWidget *chooserWindow=gtk_window_new(GTK_WINDOW_TOPLEVEL);
// GtkWidget *Box=gtk_box_new(GTK_ORIENTATION_VERTICAL,5);
@ -953,4 +1024,43 @@ void _yon_ubl_status_box_render(render_data *datav)
sleep(2);
}
}
void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){
if (main_window&&socket_main_id>-1){
gtk_widget_hide(gtk_widget_get_toplevel(main_window));
GtkWidget *plug_main=gtk_plug_new(socket_main_id);
GtkWidget *plug_left=NULL;
GtkWidget *plug_right=NULL;
g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL);
if (socket_left_id>-1&&left_window){
plug_left=gtk_plug_new(socket_left_id);
g_object_ref(left_window);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window);
gtk_container_add(GTK_CONTAINER(plug_left),left_window);
gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar");
gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button");
gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited");
gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color");
gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder");
gtk_widget_show(plug_left);
}
if (socket_right_id>-1&&right_window){
plug_right=gtk_plug_new(socket_right_id);
g_object_ref(right_window);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window);
gtk_container_add(GTK_CONTAINER(plug_right),right_window);
gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar");
gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button");
gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited");
gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color");
gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder");
gtk_widget_show(plug_right);
}
g_object_ref(main_window);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window);
gtk_container_add(GTK_CONTAINER(plug_main),main_window);
gtk_widget_show(plug_main);
}
}
#endif

@ -94,6 +94,8 @@ dictionary *yon_dictionary_rip(dictionary *dict);
dictionary *yon_dictionary_get_nth(dictionary *dict, int place);
void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*));
// char functions
char *yon_char_get_augumented(char *source, char *append);
@ -147,6 +149,9 @@ int yon_launch(thread_output *thread);
// Gtk functions
#ifdef __GTK_H__
#ifdef VTE_TERMINAL
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument);
#endif
#define yon_gtk_builder_get_widget(obj, obj2) GTK_WIDGET(gtk_builder_get_object(obj, obj2))
@ -208,5 +213,6 @@ typedef struct {
void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path);
void _yon_ubl_status_box_render(render_data *datav);
void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id);
#endif
#endif
Loading…
Cancel
Save