|
|
|
@ -113,7 +113,7 @@ void on_about(GtkWidget *self, char *version_application){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//functions
|
|
|
|
//functions
|
|
|
|
void (*save_success_function)(void*)=NULL;
|
|
|
|
void (*save_success_function)(void*,config_str,int)=NULL;
|
|
|
|
void *save_success_argument=NULL;
|
|
|
|
void *save_success_argument=NULL;
|
|
|
|
|
|
|
|
|
|
|
|
void yon_save_window_set_postsave_function(void *function, void *data){
|
|
|
|
void yon_save_window_set_postsave_function(void *function, void *data){
|
|
|
|
@ -124,19 +124,10 @@ void yon_save_window_set_postsave_function(void *function, void *data){
|
|
|
|
void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, template_saving_window *window){
|
|
|
|
void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path, template_saving_window *window){
|
|
|
|
GtkTreeIter iter,itar;
|
|
|
|
GtkTreeIter iter,itar;
|
|
|
|
if (path){
|
|
|
|
if (path){
|
|
|
|
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->filteredModel),&itar,path)){
|
|
|
|
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(window->list),&itar,path)){
|
|
|
|
char *seek_name;
|
|
|
|
|
|
|
|
gtk_tree_model_get(window->filteredModel,&itar,1,&seek_name,-1);
|
|
|
|
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter);
|
|
|
|
|
|
|
|
for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){
|
|
|
|
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,1,&name,-1);
|
|
|
|
|
|
|
|
if (!strcmp(seek_name,name)){
|
|
|
|
|
|
|
|
gboolean is_active;
|
|
|
|
gboolean is_active;
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&is_active,-1);
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&itar,0,&is_active,-1);
|
|
|
|
gtk_list_store_set(window->list,&iter,0,!is_active,-1);
|
|
|
|
gtk_list_store_set(window->list,&itar,0,!is_active,-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int once_active=0;
|
|
|
|
int once_active=0;
|
|
|
|
@ -151,7 +142,6 @@ void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!once_active) gtk_widget_set_sensitive(window->SaveButton,0);
|
|
|
|
if (!once_active) gtk_widget_set_sensitive(window->SaveButton,0);
|
|
|
|
else gtk_widget_set_sensitive(window->SaveButton,1);
|
|
|
|
else gtk_widget_set_sensitive(window->SaveButton,1);
|
|
|
|
gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(window->filteredModel));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -173,189 +163,113 @@ template_debug_window *template_debugger_window_new(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_save_parameters(GtkWidget *self, template_saving_window *window){
|
|
|
|
void on_save_parameters(GtkWidget *self, template_saving_window *window){
|
|
|
|
char *append_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," set ",NULL);
|
|
|
|
|
|
|
|
char *remove_command = yon_char_unite("ubconfig --target ",template_config->load_mode==1?"global":"system"," remove ",NULL);
|
|
|
|
|
|
|
|
dictionary *final_append=NULL;
|
|
|
|
|
|
|
|
dictionary *final_remove=NULL;
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter);
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(window->ParametersTree));
|
|
|
|
for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){
|
|
|
|
int valid = gtk_tree_model_get_iter_first(model,&iter);
|
|
|
|
gboolean is_active,can_save;
|
|
|
|
int saved_size=0;
|
|
|
|
char *parameter,*old_value,*new_value,*section;
|
|
|
|
config_str saved_parameters=NULL;
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,0,&is_active,1,¶meter,2,&old_value,3,&new_value,5,&can_save,6,§ion,-1);
|
|
|
|
for (;valid;valid = gtk_tree_model_iter_next(model,&iter)){
|
|
|
|
if (is_active&&can_save){
|
|
|
|
char *parameter;
|
|
|
|
if(!yon_char_is_empty(parameter)){
|
|
|
|
int is_active;
|
|
|
|
if (yon_char_is_empty(new_value)){ // empty new value - delete
|
|
|
|
gtk_tree_model_get(model,&iter,0,&is_active,1,¶meter,-1);
|
|
|
|
if (yon_dictionary_get(&final_remove,section)){
|
|
|
|
if (is_active){
|
|
|
|
final_remove->data = yon_char_unite((char*)final_remove->data," ",parameter,NULL);
|
|
|
|
yon_char_parsed_add_or_create_if_exists(saved_parameters,&saved_size,parameter);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(final_remove,section, parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { // non-empty new value - add
|
|
|
|
|
|
|
|
if (yon_dictionary_get(&final_append,section)){
|
|
|
|
|
|
|
|
final_append->data=yon_char_unite((char*)final_append->data," ",yon_char_unite(parameter,"=\'",new_value,"\'",NULL),NULL);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(final_append,section, yon_char_unite(parameter,"=",new_value[0]!='\''?"\'":"",new_value,new_value[strlen(new_value)-1]!='\''?"\'":"",NULL));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (debug_output==1){
|
|
|
|
|
|
|
|
// template_debug_window *debug_window = template_debugger_window_new();
|
|
|
|
|
|
|
|
// gtk_widget_show(debug_window->Window);
|
|
|
|
|
|
|
|
// dictionary *dict = NULL;
|
|
|
|
|
|
|
|
// char *final_command_line = "";
|
|
|
|
|
|
|
|
// if (final_remove){
|
|
|
|
|
|
|
|
// for_dictionaries(dict,final_remove){
|
|
|
|
|
|
|
|
// char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL);
|
|
|
|
|
|
|
|
// char *temp = yon_char_unite(final_command_line,!yon_char_is_empty(final_command_line)?";echo \"":"echo \"",final_command,"\";",final_command,NULL);
|
|
|
|
|
|
|
|
// if (!yon_char_is_empty(final_command_line))
|
|
|
|
|
|
|
|
// free(final_command_line);
|
|
|
|
|
|
|
|
// final_command_line=temp;
|
|
|
|
|
|
|
|
// free(final_command);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (final_append){
|
|
|
|
|
|
|
|
// for_dictionaries(dict,final_append){
|
|
|
|
|
|
|
|
// char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL);
|
|
|
|
|
|
|
|
// char *temp = yon_char_unite(final_command_line,!yon_char_is_empty(final_command_line)?";echo \"":"echo \"",final_command,"\";",final_command,NULL);
|
|
|
|
|
|
|
|
// if (!yon_char_is_empty(final_command_line))
|
|
|
|
|
|
|
|
// free(final_command_line);
|
|
|
|
|
|
|
|
// final_command_line=temp;
|
|
|
|
|
|
|
|
// free(final_command);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (window->type==YON_CONFIG_BOTH) {
|
|
|
|
|
|
|
|
// if (template_config->load_mode==1){
|
|
|
|
|
|
|
|
// yon_config_save_registered("system");
|
|
|
|
|
|
|
|
// } else if (template_config->load_mode==0){
|
|
|
|
|
|
|
|
// yon_config_save_registered("global");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (!yon_char_is_empty(final_command_line)){
|
|
|
|
|
|
|
|
// if (debug_output)
|
|
|
|
|
|
|
|
// printf("%s\n",final_command_line);
|
|
|
|
|
|
|
|
// yon_terminal_integrated_start(debug_window->Vte,final_command_line,NULL,NULL);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dictionary *dict = NULL;
|
|
|
|
|
|
|
|
if (final_remove){
|
|
|
|
|
|
|
|
for_dictionaries(dict,final_remove){
|
|
|
|
|
|
|
|
char *final_command = yon_char_unite(remove_command," ",dict->key," ",(char*)dict->data,NULL);
|
|
|
|
|
|
|
|
system(final_command);
|
|
|
|
|
|
|
|
printf("%s\n",final_command);
|
|
|
|
|
|
|
|
free(final_command);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int size=0;
|
|
|
|
|
|
|
|
config_str commands = yon_config_get_save_parameters_by_list(&size,saved_parameters,saved_size);
|
|
|
|
|
|
|
|
char *target = yon_config_get_type_path(window->type);
|
|
|
|
|
|
|
|
if (target){
|
|
|
|
|
|
|
|
if (yon_char_is_empty(target)){
|
|
|
|
|
|
|
|
yon_char_parsed_prepend_strings(commands,size,ubconfig_dull_command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (final_append){
|
|
|
|
yon_char_parsed_prepend_strings(commands,size,ubconfig_set_command(target));
|
|
|
|
for_dictionaries(dict,final_append){
|
|
|
|
} else return;
|
|
|
|
char *final_command = yon_char_unite(append_command," ",dict->key," ",(char*)dict->data,NULL);
|
|
|
|
char *final_command = yon_char_parsed_to_string(commands,size,";");
|
|
|
|
system(final_command);
|
|
|
|
FILE *file = popen(final_command,"r");
|
|
|
|
printf("%s\n",final_command);
|
|
|
|
int file_save;
|
|
|
|
free(final_command);
|
|
|
|
config_str file_return = yon_config_load_file(file,&file_save);
|
|
|
|
|
|
|
|
if (save_success_function)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
save_success_function(save_success_argument,file_return,file_save);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow");
|
|
|
|
|
|
|
|
on_subwindow_close(self);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct loaded_config {
|
|
|
|
|
|
|
|
dictionary_fields(loaded_config);
|
|
|
|
|
|
|
|
char *section;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct loaded_config *yon_config_convert_parameter(config_str parsed, int size){
|
|
|
|
|
|
|
|
struct loaded_config *loaded=NULL;
|
|
|
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
|
|
|
char *value = yon_char_new(parsed[i]);
|
|
|
|
|
|
|
|
char *key = yon_char_divide_search(value,"=",-1);
|
|
|
|
|
|
|
|
yon_char_remove_brackets(value);
|
|
|
|
|
|
|
|
if (!loaded){
|
|
|
|
|
|
|
|
loaded = (struct loaded_config*)malloc(sizeof(struct loaded_config));
|
|
|
|
|
|
|
|
loaded->key=key;
|
|
|
|
|
|
|
|
loaded->first=loaded;
|
|
|
|
|
|
|
|
loaded->next=NULL;
|
|
|
|
|
|
|
|
loaded->prev=NULL;
|
|
|
|
|
|
|
|
loaded->section=NULL;
|
|
|
|
|
|
|
|
loaded->data=value;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
loaded->next = (struct loaded_config*)malloc(sizeof(struct loaded_config));
|
|
|
|
|
|
|
|
struct loaded_config *next=loaded->next;
|
|
|
|
|
|
|
|
next->first=loaded->first;
|
|
|
|
|
|
|
|
next->prev=loaded;
|
|
|
|
|
|
|
|
next->key=key;
|
|
|
|
|
|
|
|
next->first=loaded->first;
|
|
|
|
|
|
|
|
next->next=NULL;
|
|
|
|
|
|
|
|
next->section=NULL;
|
|
|
|
|
|
|
|
next->data=value;
|
|
|
|
|
|
|
|
loaded=next;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return loaded;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct loaded_config *yon_config_get_compared(char *command, int *final_size){
|
|
|
|
|
|
|
|
if (command){
|
|
|
|
|
|
|
|
*final_size=0;
|
|
|
|
|
|
|
|
int size;
|
|
|
|
|
|
|
|
config_str config = yon_config_load(command,&size);
|
|
|
|
|
|
|
|
config_str temporary = NULL;
|
|
|
|
|
|
|
|
int temp_size;
|
|
|
|
|
|
|
|
if (config&&size>0){
|
|
|
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(config[i])&&strcmp(config[i],"(null)\n")){
|
|
|
|
|
|
|
|
if (config[i][strlen(config[i])-1]=='\n') config[i][strlen(config[i])-1]='\0';
|
|
|
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(temporary,&temp_size,config[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (window->type==YON_CONFIG_BOTH) {
|
|
|
|
|
|
|
|
if (template_config->load_mode==1){
|
|
|
|
|
|
|
|
yon_config_save_registered("system");
|
|
|
|
|
|
|
|
} else if (template_config->load_mode==0){
|
|
|
|
|
|
|
|
yon_config_save_registered("global");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_char_parsed_free(config,size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct loaded_config *loaded = yon_config_convert_parameter(temporary,temp_size);
|
|
|
|
|
|
|
|
return loaded;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
|
|
|
|
if (window->type == YON_CONFIG_GLOBAL)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
else if (window->type == YON_CONFIG_LOCAL)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
else if (window->type == YON_CONFIG_BOTH)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yon_window_config_custom_window_set(GTK_WINDOW(window->Window),"SaveWindow");
|
|
|
|
|
|
|
|
on_subwindow_close(self);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
|
|
|
|
template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
|
|
|
|
if (((type==YON_CONFIG_LOCAL&& template_config->load_mode==1)||(type==YON_CONFIG_GLOBAL&& template_config->load_mode==0))){
|
|
|
|
|
|
|
|
yon_config_save_registered(path);
|
|
|
|
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
|
|
|
|
if (type == YON_CONFIG_GLOBAL)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
else if (type == YON_CONFIG_LOCAL)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
else if (type == YON_CONFIG_BOTH)
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
char *config_to_save = NULL;
|
|
|
|
char *config_to_save = NULL;
|
|
|
|
if (type==YON_CONFIG_GLOBAL) config_to_save="global";
|
|
|
|
config_to_save = yon_config_get_type_path(type);
|
|
|
|
else if (type==YON_CONFIG_LOCAL) config_to_save="system";
|
|
|
|
struct loaded_config *config_compare=NULL;
|
|
|
|
else if (type==YON_CONFIG_BOTH) {
|
|
|
|
|
|
|
|
if (template_config->load_mode==1){
|
|
|
|
|
|
|
|
config_to_save="global";
|
|
|
|
|
|
|
|
} else if (template_config->load_mode==0){
|
|
|
|
|
|
|
|
config_to_save="system";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
config_str config_compare=NULL;
|
|
|
|
|
|
|
|
int compare_size=0;
|
|
|
|
int compare_size=0;
|
|
|
|
va_list args;
|
|
|
|
va_list args;
|
|
|
|
va_start(args,type);
|
|
|
|
va_start(args,type);
|
|
|
|
char *cur_section = NULL;
|
|
|
|
char *compare_command="";
|
|
|
|
dictionary *section_commands=NULL;
|
|
|
|
char *cur_command;
|
|
|
|
while ((cur_section=va_arg(args,char*))){
|
|
|
|
while ((cur_command=va_arg(args,char*))){
|
|
|
|
char *cur_parameter = va_arg(args,char*);
|
|
|
|
compare_command = yon_char_unite(compare_command,!yon_char_is_empty(compare_command)?";":"",cur_command,NULL);
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(section_commands,cur_section,cur_parameter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct loaded_config {
|
|
|
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
|
|
|
char *section;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct loaded_config loaded;
|
|
|
|
|
|
|
|
loaded.dict = yon_dictionary_new();
|
|
|
|
|
|
|
|
dictionary *dct;
|
|
|
|
|
|
|
|
for_dictionaries(dct,section_commands){
|
|
|
|
|
|
|
|
char *command = yon_char_unite(ubconfig_load_command," ", config_to_save," get ", dct->key," ", yon_dictionary_get_data(dct,char*),NULL);
|
|
|
|
|
|
|
|
FILE *output = popen(command, "r");
|
|
|
|
|
|
|
|
char **output_strings = NULL;
|
|
|
|
|
|
|
|
output_strings = malloc(sizeof(char*));
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
char str[4096];
|
|
|
|
|
|
|
|
memset(str, 0, 4096);
|
|
|
|
|
|
|
|
while (fgets(str, 4096, output))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(str)&& strcmp(str,"(null)\n")!=0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char *final_str = yon_char_new(str);
|
|
|
|
|
|
|
|
char *key = yon_char_divide_search(final_str,"=",-1);
|
|
|
|
|
|
|
|
final_str=yon_char_divide_search(final_str,"\n",-1);
|
|
|
|
|
|
|
|
if ((final_str[0]=='\''&&final_str[strlen(final_str)-1]=='\'')||(final_str[0]=='\"'&&final_str[strlen(final_str)-1]=='\"')){
|
|
|
|
|
|
|
|
final_str[strlen(final_str)-1] = '\0';
|
|
|
|
|
|
|
|
free(yon_char_divide(final_str,0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
char *str_copy = yon_char_unite(key,"=",final_str,NULL);
|
|
|
|
|
|
|
|
dictionary *found=NULL;
|
|
|
|
|
|
|
|
if (!(found=yon_dictionary_get(&loaded.dict,key))){
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(loaded.dict,NULL,yon_char_new(dct->key));
|
|
|
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(loaded.dict,key,yon_char_new(final_str));
|
|
|
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(config_compare,&compare_size,yon_char_new(str_copy));
|
|
|
|
|
|
|
|
} else{
|
|
|
|
|
|
|
|
int element = yon_char_parsed_check_exist(config_compare,compare_size,(char*)loaded.dict->data);
|
|
|
|
|
|
|
|
if (element>-1){
|
|
|
|
|
|
|
|
free(config_compare[element]);
|
|
|
|
|
|
|
|
config_compare[element]=yon_char_new(str_copy);
|
|
|
|
|
|
|
|
loaded.dict->data = yon_char_new(final_str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
config_compare = yon_config_get_compared(compare_command,&compare_size); ///////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_saving);
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_saving);
|
|
|
|
template_saving_window *window = malloc(sizeof(template_saving_window));
|
|
|
|
template_saving_window *window = malloc(sizeof(template_saving_window));
|
|
|
|
window->Window = yon_gtk_builder_get_widget(builder,"Window");
|
|
|
|
window->Window = yon_gtk_builder_get_widget(builder,"Window");
|
|
|
|
@ -371,6 +285,16 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
|
|
|
|
window->OldValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"OldValueCell"));
|
|
|
|
window->OldValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"OldValueCell"));
|
|
|
|
window->NewValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"NewValueColumn"));
|
|
|
|
window->NewValueColumn = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"NewValueColumn"));
|
|
|
|
window->NewValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"NewValueCell"));
|
|
|
|
window->NewValueCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"NewValueCell"));
|
|
|
|
|
|
|
|
window->type=type;
|
|
|
|
|
|
|
|
window->filteredModel = GTK_TREE_MODEL(gtk_builder_get_object(builder,"listfilter1"));
|
|
|
|
|
|
|
|
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"SaveWindow");
|
|
|
|
|
|
|
|
gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
|
|
|
|
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title);
|
|
|
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title);
|
|
|
|
|
|
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL));
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_save_parameters),window);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(window->ToggleCell),"toggled", G_CALLBACK(on_save_window_parameter_switched),window);
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
if (type==YON_CONFIG_BOTH){
|
|
|
|
if (type==YON_CONFIG_BOTH){
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"savingTarget",SAVING_GLOBAL_LOCAL_STATE_LABEL,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
@ -382,115 +306,66 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
window->type=type;
|
|
|
|
|
|
|
|
window->filteredModel = GTK_TREE_MODEL(gtk_builder_get_object(builder,"listfilter1"));
|
|
|
|
int current_size=0;
|
|
|
|
gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(window->filteredModel),5);
|
|
|
|
config_str current_config = yon_config_get_all(¤t_size);
|
|
|
|
yon_window_config_custom_window_setup(GTK_WINDOW(window->Window),"SaveWindow");
|
|
|
|
|
|
|
|
gtk_window_set_icon_name(GTK_WINDOW(window->Window),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
|
|
|
|
struct loaded_config *current_loaded = yon_config_convert_parameter(current_config,current_size);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window->Window),template_app_information.app_title);
|
|
|
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(window->HeaderTopic),template_app_information.app_title);
|
|
|
|
struct loaded_config *current = NULL;
|
|
|
|
gtk_image_set_from_pixbuf(GTK_IMAGE(window->HeaderImage),gtk_icon_theme_load_icon_for_scale(gtk_icon_theme_get_default(),yon_char_append("com.ublinux.",template_app_information.app_tech_name),32,1,GTK_ICON_LOOKUP_FORCE_SIZE,NULL));
|
|
|
|
for_dictionaries(current,current_loaded){
|
|
|
|
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)&config_compare,current->key);
|
|
|
|
g_signal_connect(G_OBJECT(window->SaveButton),"clicked", G_CALLBACK(on_save_parameters),window);
|
|
|
|
gboolean status=0;
|
|
|
|
g_signal_connect(G_OBJECT(window->ToggleCell),"toggled", G_CALLBACK(on_save_window_parameter_switched),window);
|
|
|
|
status = yon_config_get_status(current->key);
|
|
|
|
int config_size=0;
|
|
|
|
if (dict&&!yon_char_is_empty((char*)dict->data)&&status!=-2){
|
|
|
|
config_str config_strings = yon_config_get_all(&config_size);
|
|
|
|
if (strcmp((char*)dict->data,(char*)current->data)){
|
|
|
|
if (config_strings){ //untracked parameters
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if (status==0||status==-2) status = 0;
|
|
|
|
|
|
|
|
else status=1;
|
|
|
|
|
|
|
|
char *compare_string = yon_char_unite("<s>",(char*)dict->data,"</s>\n",(char*)current->data,NULL);
|
|
|
|
|
|
|
|
gtk_list_store_append(window->list,&iter);
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,0,status,1,current->key,2,(char*)dict->data,3,(char*)current->data,4,compare_string,6,1,-1);
|
|
|
|
|
|
|
|
free(compare_string);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ((strcmp((char*)current->data,""))&&status!=-2){
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),NULL);
|
|
|
|
if (status==0||status==-2) status = 0;
|
|
|
|
config_str compare_keys = NULL;
|
|
|
|
else status=1;
|
|
|
|
compare_keys = yon_char_parsed_copy(config_compare,compare_size);
|
|
|
|
char *compare_string = yon_char_unite("\n",(char*)current->data,NULL);
|
|
|
|
int compare_keys_size=compare_size;
|
|
|
|
gtk_list_store_append(window->list,&iter);
|
|
|
|
yon_char_parsed_divide_search_full(compare_keys,compare_keys_size,"=",-1);
|
|
|
|
gtk_list_store_set(window->list,&iter,0,status,1,current->key,3,(char*)current->data,4,compare_string,6,1,-1);
|
|
|
|
int config_keys_size=0;
|
|
|
|
free(compare_string);
|
|
|
|
config_str config_keys = yon_config_get_all_keys(&config_keys_size);
|
|
|
|
}
|
|
|
|
int final_size=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for_dictionaries(current,config_compare){
|
|
|
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
dictionary *dict = yon_dictionary_get((dictionary**)¤t_loaded,current->key);
|
|
|
|
|
|
|
|
if (!dict){
|
|
|
|
GdkRGBA rgba;
|
|
|
|
GdkRGBA rgba;
|
|
|
|
rgba.alpha=0.8;
|
|
|
|
rgba.alpha=0.8;
|
|
|
|
rgba.red=1;
|
|
|
|
rgba.red=1;
|
|
|
|
rgba.blue=0.3;
|
|
|
|
rgba.blue=0.3;
|
|
|
|
rgba.green=0.65;
|
|
|
|
rgba.green=0.65;
|
|
|
|
char *rgba_string = gdk_rgba_to_string(&rgba);
|
|
|
|
char *rgba_string = gdk_rgba_to_string(&rgba);
|
|
|
|
for (int i=0;i<compare_keys_size;i++){
|
|
|
|
int status=0;
|
|
|
|
|
|
|
|
char *compare_string = yon_char_unite((char*)current->data,"\n",NULL);
|
|
|
|
gtk_list_store_append(window->list,&iter);
|
|
|
|
gtk_list_store_append(window->list,&iter);
|
|
|
|
gtk_list_store_set(window->list,&iter,0,0,1,compare_keys[i],5,1,-1);
|
|
|
|
gtk_list_store_set(window->list,&iter,0,0,1,current->key,3,(char*)current->data,4,compare_string,5,rgba_string,6,1,-1);
|
|
|
|
for (int j=0;j<compare_size;j++){
|
|
|
|
free(compare_string);
|
|
|
|
if(config_compare[j][strlen(config_compare[j])-1]=='\n') config_compare[j][strlen(config_compare[j])-1]='\0';
|
|
|
|
|
|
|
|
char *compare_value = yon_char_new(config_compare[j]);
|
|
|
|
|
|
|
|
char *compare_name = yon_char_divide_search(compare_value,"=",-1);
|
|
|
|
|
|
|
|
if (!strcmp(compare_name,compare_keys[i])){
|
|
|
|
|
|
|
|
char *cur_section = (char*)yon_dictionary_get(&loaded.dict->first,compare_keys[i])->prev->data;
|
|
|
|
|
|
|
|
char *combined = yon_char_unite("<s>",compare_value,"</s>\n",NULL);
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,2,compare_value,4,rgba_string,6,cur_section,7,combined,-1);
|
|
|
|
|
|
|
|
free(combined);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(compare_value);
|
|
|
|
|
|
|
|
free(compare_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (yon_config_check_ignore(compare_keys[i])){
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,0,0,1,compare_keys[i],4,NULL,5,0,-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
char *name,*value;
|
|
|
|
|
|
|
|
for (int i=0;i<config_keys_size;i++){
|
|
|
|
|
|
|
|
int found=0;
|
|
|
|
|
|
|
|
char *compare_value = yon_char_new(config_strings[i]);
|
|
|
|
|
|
|
|
char *compare_name = yon_char_divide_search(compare_value,"=",-1);
|
|
|
|
|
|
|
|
char *section = yon_config_get_section_for_key(compare_name);
|
|
|
|
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter);
|
|
|
|
|
|
|
|
for (;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(window->list),&iter)){ // found parameter
|
|
|
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(window->list),&iter,1,&name,2,&value,-1);
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(name)&&!strcmp(name,config_keys[i])){
|
|
|
|
|
|
|
|
if (!yon_config_check_ignore(name)){
|
|
|
|
|
|
|
|
char *combined = yon_char_unite("<s>",value,"</s>\n",compare_value,NULL);
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,3,compare_value,4,NULL,6,section,7,combined,-1);
|
|
|
|
|
|
|
|
free(combined);
|
|
|
|
|
|
|
|
if ((value&&!strcmp(value,compare_value))){
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,0,0,3,value,5,0,-1);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (yon_config_get_status(name)!=0){
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&iter,0,1,5,1,-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
found=1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found){ // new parameter
|
|
|
|
|
|
|
|
if (!yon_config_check_ignore(compare_name)&&!yon_char_is_empty(compare_value)){
|
|
|
|
|
|
|
|
GtkTreeIter itar;
|
|
|
|
|
|
|
|
gtk_list_store_append(window->list,&itar);
|
|
|
|
|
|
|
|
char *combined = yon_char_append("\n",compare_value);
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&itar,0,0,1,compare_name,3,compare_value,5,1,6,section,7,combined,-1);
|
|
|
|
|
|
|
|
if (yon_config_get_status(compare_name)==1){
|
|
|
|
|
|
|
|
gtk_list_store_set(window->list,&itar,0,1,-1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
free(combined);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(compare_value);
|
|
|
|
|
|
|
|
free(compare_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(rgba_string);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->filteredModel),&iter)){
|
|
|
|
if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->list),&iter)){
|
|
|
|
gtk_widget_destroy(window->Window);
|
|
|
|
gtk_widget_destroy(window->Window);
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
yon_ubl_status_box_render(NOTHING_TO_SAVE_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
textdomain(template_app_information.app_locale);
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),window->filteredModel);
|
|
|
|
gtk_tree_view_set_model(GTK_TREE_VIEW(window->ParametersTree),GTK_TREE_MODEL(window->list));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
on_save_window_parameter_switched(NULL,NULL,window);
|
|
|
|
on_save_window_parameter_switched(NULL,NULL,window);
|
|
|
|
return window;
|
|
|
|
return window;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){
|
|
|
|
int yon_confirmation_dialog_call(GtkWidget *self,dialog_confirmation_data *data){
|
|
|
|
|