diff --git a/source/libublsettingsui-gtk3-save.c b/source/libublsettingsui-gtk3-save.c index 4f9ea4f..79c60ba 100644 --- a/source/libublsettingsui-gtk3-save.c +++ b/source/libublsettingsui-gtk3-save.c @@ -7,6 +7,11 @@ ============== */ +gboolean _yon_presave_function_start(struct presave_info *data){ + presave_function(data->presave_argument,data->save_path); + return G_SOURCE_REMOVE; +} + gboolean _yon_postsave_function_start(struct save_return *data){ save_success_function(data->save_success_argument,data->file_return,data->file_save); return G_SOURCE_REMOVE; @@ -144,6 +149,11 @@ config_str yon_loaded_config_convert_to_save_command(struct loaded_config *targe } } +void yon_save_window_set_presave_function(void *function, void *data){ + presave_function=function; + presave_argument=data; +} + void yon_save_window_set_postsave_function(void *function, void *data){ save_success_function=function; save_success_argument=data; @@ -521,8 +531,17 @@ void on_save_parameters(GtkWidget *self, template_saving_window *window){ yon_config_parameter_prepare_elements(commands,&size); char *final_command = yon_char_parsed_to_string(commands,size,";"); + char *new_str_closed = yon_char_replace(final_command,"\n","\\n"); + + if (presave_function) + { + struct presave_info *data = malloc(sizeof(struct presave_info)); + data->presave_argument = save_success_argument; + data->save_path = yon_config_command_get_path(new_str_closed); + _yon_presave_function_start(data); + } pthread_t thread_id; - pthread_create(&thread_id, NULL, (void *)_yon_saving_threaded,final_command); + pthread_create(&thread_id, NULL, (void *)_yon_saving_threaded,new_str_closed); yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow"); on_subwindow_close(self); diff --git a/source/libublsettingsui-gtk3-save.h b/source/libublsettingsui-gtk3-save.h index c380028..eb27666 100644 --- a/source/libublsettingsui-gtk3-save.h +++ b/source/libublsettingsui-gtk3-save.h @@ -13,6 +13,10 @@ struct save_return { config_str file_return; int file_save; }; +struct presave_info { + void *presave_argument; + char *save_path; +}; /**function and argument, which called after successful config saving. * Example: @@ -20,6 +24,8 @@ struct save_return { */ void (*save_success_function)(void*,config_str,int)=NULL; void *save_success_argument=NULL; +void (*presave_function)(void*, char*)=NULL; +void *presave_argument=NULL; void (*save_failure_function)(void*,config_str,int)=NULL; void *save_failure_argument=NULL; diff --git a/source/libublsettingsui-gtk3-service.c b/source/libublsettingsui-gtk3-service.c index cf9417c..60e79ac 100644 --- a/source/libublsettingsui-gtk3-service.c +++ b/source/libublsettingsui-gtk3-service.c @@ -23,7 +23,7 @@ void __on_service_update_clicked(GtkWidget *, service_window *window); void __on_service_start_clicked(GtkWidget *, service_window *window){ if (system(yon_debug_output("%s\n",window->start_command))){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; __on_service_update_clicked(NULL,window); @@ -32,7 +32,7 @@ void __on_service_start_clicked(GtkWidget *, service_window *window){ void __on_service_stop_clicked(GtkWidget *, service_window *window){ if (system(window->stop_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; __on_service_update_clicked(NULL,window); @@ -43,7 +43,7 @@ void __on_service_enable_clicked(GtkWidget *, service_window *window){ if (system(window->enable_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; __on_service_update_clicked(NULL,window); @@ -53,7 +53,7 @@ void __on_service_enable_clicked(GtkWidget *, service_window *window){ void __on_service_disable_clicked(GtkWidget *, service_window *window){ if (system(window->disable_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; __on_service_update_clicked(NULL,window); @@ -63,11 +63,11 @@ void __on_service_restart_clicked(GtkWidget *, service_window *window){ if (system(window->stop_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; if (system(window->start_command)){ - yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),yon_char_get_localised_from_lib(FAIL_LABEL),5,BACKGROUND_IMAGE_FAIL_TYPE); return; }; __on_service_update_clicked(NULL,window); diff --git a/source/libublsettingsui-gtk3.h b/source/libublsettingsui-gtk3.h index fec78cf..98c9faa 100644 --- a/source/libublsettingsui-gtk3.h +++ b/source/libublsettingsui-gtk3.h @@ -11,7 +11,6 @@ #include #include #include -#include #ifdef WEBKIT_INCLUDE #include #endif @@ -175,6 +174,7 @@ typedef struct { char *last_any_selection; GtkResponseType responce; } filechooser_window; + filechooser_window *yon_file_chooser_window_new(GtkFileChooserAction action); GtkResponseType yon_file_chooser_start(filechooser_window *window); void yon_file_chooser_set_button_label(char *label); @@ -274,6 +274,7 @@ typedef struct { char *custom_save_path; } template_saving_window; +void yon_save_window_set_presave_function(void *function, void *data); void yon_save_window_set_postsave_function(void *function, void *data);