@ -53,7 +53,9 @@ void on_subwindow_close(GtkWidget *self){
}
void yon_open_browser ( GtkWidget * self , char * link ) {
yon_ubl_browser_window_open ( link , template_app_information . app_title ) ;
GtkWidget * window = yon_ubl_browser_window_open ( link , template_app_information . app_title ) ;
if ( window )
gtk_window_set_icon_name ( GTK_WINDOW ( window ) , yon_char_append ( " com.ublinux. " , template_app_information . app_tech_name ) ) ;
}
void on_open_documentation_confirmation ( GtkWidget * self , char * link ) {
@ -104,6 +106,7 @@ void on_about(GtkWidget *self, char *version_application){
gtk_about_dialog_set_version ( GTK_ABOUT_DIALOG ( window ) , version_application ) ;
gtk_about_dialog_set_comments ( GTK_ABOUT_DIALOG ( window ) , template_app_information . app_title ) ;
gtk_about_dialog_set_logo_icon_name ( GTK_ABOUT_DIALOG ( window ) , yon_char_append ( " com.ublinux. " , template_app_information . app_tech_name ) ) ;
gtk_window_set_icon_name ( GTK_WINDOW ( window ) , yon_char_append ( " com.ublinux. " , template_app_information . app_tech_name ) ) ;
gtk_about_dialog_set_program_name ( GTK_ABOUT_DIALOG ( window ) , template_app_information . app_tech_name ) ;
gtk_label_set_text ( GTK_LABEL ( title ) , template_app_information . app_title ) ;
g_signal_connect ( G_OBJECT ( window ) , " activate-link " , G_CALLBACK ( on_link ) , NULL ) ;
@ -113,7 +116,7 @@ void on_about(GtkWidget *self, char *version_application){
}
//functions
void ( * save_success_function ) ( void * )= NULL ;
void ( * save_success_function ) ( void * ,config_str , int )= NULL ;
void * save_success_argument = NULL ;
void yon_save_window_set_postsave_function ( void * function , void * data ) {
@ -124,19 +127,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 ) {
GtkTreeIter iter , itar ;
if ( path ) {
if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( window - > filteredModel ) , & 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 ) ) {
if ( gtk_tree_model_get_iter_from_string ( GTK_TREE_MODEL ( window - > list ) , & itar , path ) ) {
gboolean is_active ;
gtk_tree_model_get ( GTK_TREE_MODEL ( window - > list ) , & iter , 0 , & is_active , - 1 ) ;
gtk_list_store_set ( 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 , & itar , 0 , ! is_active , - 1 ) ;
}
}
int once_active = 0 ;
@ -151,7 +145,6 @@ void on_save_window_parameter_switched(GtkCellRendererToggle *self, gchar *path,
}
if ( ! once_active ) gtk_widget_set_sensitive ( window - > SaveButton , 0 ) ;
else gtk_widget_set_sensitive ( window - > SaveButton , 1 ) ;
gtk_tree_model_filter_refilter ( GTK_TREE_MODEL_FILTER ( window - > filteredModel ) ) ;
}
@ -173,189 +166,148 @@ template_debug_window *template_debugger_window_new(){
}
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 ;
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 ) ) {
gboolean is_active , can_save ;
char * parameter , * old_value , * new_value , * section ;
gtk_tree_model_get ( GTK_TREE_MODEL ( window - > list ) , & iter , 0 , & is_active , 1 , & parameter , 2 , & old_value , 3 , & new_value , 5 , & can_save , 6 , & section , - 1 ) ;
if ( is_active & & can_save ) {
if ( ! yon_char_is_empty ( parameter ) ) {
if ( yon_char_is_empty ( new_value ) ) { // empty new value - delete
if ( yon_dictionary_get ( & final_remove , section ) ) {
final_remove - > data = yon_char_unite ( ( char * ) final_remove - > data , " " , parameter , NULL ) ;
} 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 ) ;
}
}
if ( final_append ) {
for_dictionaries ( dict , final_append ) {
char * final_command = yon_char_unite ( append_command , " " , dict - > key , " " , ( char * ) dict - > data , NULL ) ;
system ( final_command ) ;
printf ( " %s \n " , final_command ) ;
free ( final_command ) ;
GtkTreeModel * model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( window - > ParametersTree ) ) ;
int valid = gtk_tree_model_get_iter_first ( model , & iter ) ;
int saved_size = 0 ;
config_str saved_parameters = NULL ;
for ( ; valid ; valid = gtk_tree_model_iter_next ( model , & iter ) ) {
char * parameter ;
int is_active ;
gtk_tree_model_get ( model , & iter , 0 , & is_active , 1 , & parameter , - 1 ) ;
if ( is_active ) {
yon_char_parsed_add_or_create_if_exists ( saved_parameters , & saved_size , parameter ) ;
}
}
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 " ) ;
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 ) ;
}
else {
yon_char_parsed_prepend_strings ( commands , size , ubconfig_set_command ( target ) ) ;
}
} else {
yon_char_parsed_prepend_strings ( commands , size , ubconfig_set_command ( window - > custom_save_path ) ) ;
}
char * final_command = yon_char_parsed_to_string ( commands , size , " ; " ) ;
FILE * file = popen ( final_command , " r " ) ;
int file_save ;
config_str file_return = yon_config_load_file ( file , & file_save ) ;
file_return = yon_char_parsed_append ( file_return , & file_save , final_command ) ;
if ( save_success_function )
{
save_success_function ( save_success_argument , file_return , file_save ) ;
}
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 , . . . ) {
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 ;
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 {
char * config_to_save = NULL ;
if ( type = = YON_CONFIG_GLOBAL ) config_to_save = " global " ;
else if ( type = = YON_CONFIG_LOCAL ) config_to_save = " system " ;
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 " ;
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 ] ) ;
}
}
yon_char_parsed_free ( config , size ) ;
}
config_str config_compare = NULL ;
struct loaded_config * loaded = yon_config_convert_parameter ( temporary , temp_size ) ;
return loaded ;
}
}
template_saving_window * yon_save_proceed ( char * path , YON_CONFIG_TYPE type , . . . ) {
char * config_to_save = NULL ;
config_to_save = yon_config_get_type_path ( type ) ;
struct loaded_config * config_compare = NULL ;
int compare_size = 0 ;
va_list args ;
va_start ( args , type ) ;
char * cur_section = NULL ;
dictionary * section_commands = NULL ;
while ( ( cur_section = va_arg ( args , char * ) ) ) {
char * cur_parameter = va_arg ( args , char * ) ;
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 * compare_command = " " ;
char * cur_command ;
if ( ! path & & type = = YON_CONFIG_CUSTOM ) {
GtkWidget * dialog = gtk_file_chooser_dialog_new ( template_app_information . app_title , NULL , GTK_FILE_CHOOSER_ACTION_SAVE , CANCEL_LABEL , GTK_RESPONSE_CANCEL , SAVE_LABEL , GTK_RESPONSE_ACCEPT , NULL ) ;
GtkFileFilter * filter = gtk_file_filter_new ( ) ;
gtk_file_filter_add_pattern ( filter , " *.ini " ) ;
gtk_file_chooser_add_filter ( GTK_FILE_CHOOSER ( dialog ) , filter ) ;
int response = gtk_dialog_run ( GTK_DIALOG ( dialog ) ) ;
if ( response = = GTK_RESPONSE_ACCEPT ) {
char * file = yon_file_path_proceed_spaces ( gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER ( dialog ) ) ) ;
char * directory = gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER ( dialog ) ) ;
if ( ! yon_char_is_empty ( file ) ) {
if ( ! strstr ( file , " .ini " ) ) file = yon_char_append ( file , " .ini " ) ;
if ( access ( file , 0 ) ! = F_OK ) {
char * command_creation = ubconfig_file_create ( file ) ;
system ( command_creation ) ;
if ( access ( file , 0 ) ! = F_OK ) {
yon_ubl_status_box_render ( CUSTOM_CONFIG_CREATION_ERROR_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
return NULL ;
}
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 ) ;
}
}
path = file ;
gtk_widget_destroy ( dialog ) ;
} else {
gtk_widget_destroy ( dialog ) ;
return NULL ;
}
}
while ( ( cur_command = va_arg ( args , char * ) ) ) {
char * temp = cur_command ;
cur_command = yon_config_parameter_prepare_command ( cur_command , type ! = YON_CONFIG_CUSTOM ? yon_config_get_type_path ( type ) : path , NULL , NULL ) ;
compare_command = yon_char_unite ( compare_command , ! yon_char_is_empty ( compare_command ) ? " ; " : " " , cur_command , NULL ) ;
free ( temp ) ;
}
config_compare = yon_config_get_compared ( compare_command , & compare_size ) ;
GtkBuilder * builder = gtk_builder_new_from_resource ( ui_glade_path_saving ) ;
template_saving_window * window = malloc ( sizeof ( template_saving_window ) ) ;
window - > Window = yon_gtk_builder_get_widget ( builder , " Window " ) ;
@ -371,6 +323,17 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
window - > OldValueCell = GTK_CELL_RENDERER ( gtk_builder_get_object ( builder , " OldValueCell " ) ) ;
window - > NewValueColumn = GTK_TREE_VIEW_COLUMN ( gtk_builder_get_object ( builder , " NewValueColumn " ) ) ;
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 " ) ) ;
window - > custom_save_path = path ;
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 ) ;
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 ) ;
@ -382,115 +345,70 @@ template_saving_window *yon_save_proceed(char *path,YON_CONFIG_TYPE type, ...){
}
textdomain ( template_app_information . app_locale ) ;
window - > type = type ;
window - > filteredModel = GTK_TREE_MODEL ( gtk_builder_get_object ( builder , " listfilter1 " ) ) ;
gtk_tree_model_filter_set_visible_column ( GTK_TREE_MODEL_FILTER ( window - > filteredModel ) , 5 ) ;
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 ) ;
int config_size = 0 ;
config_str config_strings = yon_config_get_all ( & config_size ) ;
if ( config_strings ) { //untracked parameters
int current_size = 0 ;
config_str current_config = yon_config_get_all ( & current_size ) ;
struct loaded_config * current_loaded = yon_config_convert_parameter ( current_config , current_size ) ;
struct loaded_config * current = NULL ;
if ( current_loaded ) {
for_dictionaries ( current , current_loaded ) {
dictionary * dict = yon_dictionary_get ( ( dictionary * * ) & config_compare , current - > key ) ;
gboolean status = 0 ;
status = yon_config_get_status ( current - > key ) ;
if ( dict & & ! yon_char_is_empty ( ( char * ) dict - > data ) & & status ! = - 2 ) {
if ( strcmp ( ( char * ) dict - > data , ( char * ) current - > data ) ) {
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 ;
gtk_tree_view_set_model ( GTK_TREE_VIEW ( window - > ParametersTree ) , NULL ) ;
config_str compare_keys = NULL ;
compare_keys = yon_char_parsed_copy ( config_compare , compare_size ) ;
int compare_keys_size = compare_size ;
yon_char_parsed_divide_search_full ( compare_keys , compare_keys_size , " = " , - 1 ) ;
int config_keys_size = 0 ;
config_str config_keys = yon_config_get_all_keys ( & config_keys_size ) ;
int final_size = 0 ;
if ( status = = 0 | | status = = - 2 ) status = 0 ;
else status = 1 ;
char * compare_string = yon_char_unite ( " \n " , ( char * ) current - > data , NULL ) ;
gtk_list_store_append ( window - > list , & iter ) ;
gtk_list_store_set ( window - > list , & iter , 0 , status , 1 , current - > key , 3 , ( char * ) current - > data , 4 , compare_string , 6 , 1 , - 1 ) ;
free ( compare_string ) ;
}
}
if ( config_compare ) {
for_dictionaries ( current , config_compare ) {
GtkTreeIter iter ;
dictionary * dict = yon_dictionary_get ( ( dictionary * * ) & current_loaded , current - > key ) ;
if ( ! dict ) {
GdkRGBA rgba ;
rgba . alpha = 0.8 ;
rgba . red = 1 ;
rgba . blue = 0.3 ;
rgba . green = 0.65 ;
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_set ( window - > list , & iter , 0 , 0 , 1 , compare_keys [ i ] , 5 , 1 , - 1 ) ;
for ( int j = 0 ; j < compare_size ; j + + ) {
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 ) ;
gtk_list_store_set ( window - > list , & iter , 0 , 0 , 1 , current - > key , 2 , ( char * ) current - > data , 4 , compare_string , 5 , rgba_string , 6 , 1 , - 1 ) ;
free ( compare_string ) ;
}
} ;
} ;
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 ) ;
if ( ! gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( window - > fi lteredModel ) , & iter ) ) {
GtkTreeIter iter ;
if ( ! gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( window - > list ) , & iter ) ) {
gtk_widget_destroy ( window - > Window ) ;
textdomain ( template_ui_LocaleName ) ;
yon_ubl_status_box_render ( NOTHING_TO_SAVE_LABEL , BACKGROUND_IMAGE_FAIL_TYPE ) ;
textdomain ( template_app_information . app_locale ) ;
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 ) ;
on_save_window_parameter_switched ( NULL , NULL , window ) ;
return window ;
}
}
int yon_confirmation_dialog_call ( GtkWidget * self , dialog_confirmation_data * data ) {
@ -579,10 +497,12 @@ template_main_window *setup_window(){
widgets - > SaveMenuItem = yon_gtk_builder_get_widget ( builder , " SaveGlobalLocalConfigurationMenuItem " ) ;
widgets - > SaveGlobalMenuItem = yon_gtk_builder_get_widget ( builder , " SaveGlobalConfigurationMenuItem " ) ;
widgets - > SaveLocalMenuItem = yon_gtk_builder_get_widget ( builder , " SaveLocalConfigurationMenuItem " ) ;
widgets - > SaveCustomMenuItem = yon_gtk_builder_get_widget ( builder , " SaveExternalConfigurationMenuItem " ) ;
widgets - > RightBox = yon_gtk_builder_get_widget ( builder , " HeaderRightBox " ) ;
widgets - > LoadGlobalMenuItem = yon_gtk_builder_get_widget ( builder , " LoadGlobalConfigurationMenuItem " ) ;
widgets - > LoadLocalMenuItem = yon_gtk_builder_get_widget ( builder , " LoadLocalConfigurationMenuItem " ) ;
widgets - > LoadCustomMenuItem = yon_gtk_builder_get_widget ( builder , " LoadExternalConfigurationMenuItem " ) ;
widgets - > LeftBox = yon_gtk_builder_get_widget ( builder , " HeaderLeftBox " ) ;
widgets - > InterfaceBox = yon_gtk_builder_get_widget ( builder , " InterfaceBox " ) ;