@ -455,9 +455,9 @@ char *yon_char_append(char *source, char *append)
int size = strlen ( source ) + strlen ( append ) + 1 ;
char * final = malloc ( size ) ;
memset ( final , 0 , size ) ;
if ( strstr ( source , " %% " ) )
sprintf ( final , source , append ) ;
else
// if (strstr(source, "%%"))
// sprintf(final, source, append);
// else
sprintf ( final , " %s%s " , source , append ) ;
return final ;
}
@ -666,10 +666,10 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
char * paramline = yon_char_new ( parameters ) ;
char * param ;
while ( ( param = yon_char_divide_search ( paramline , divider , 1 ) ) ) {
if ( strcmp ( param , paramline ) = = 0 ) break ;
string = realloc ( string , sizeof ( char * ) * i ) ;
string [ i - 1 ] = yon_char_new ( param ) ;
i + + ;
if ( strcmp ( param , paramline ) = = 0 ) break ;
}
string = realloc ( string , sizeof ( char * ) * i ) ;
string [ i - 1 ] = yon_char_new ( paramline ) ;
@ -785,7 +785,7 @@ void yon_char_parsed_free(config_str source, int size){
* К о п и р у е т м а с с и в с т р о к [ to_copy ] в [ source ]
*/
void yon_char_parsed_copy ( config_str * source , config_str * to_copy ) {
if ( source & & ! * source & & to_copy & & * to_copy ) {
if ( source & & ! * source & & to_copy ) {
int size = 0 ;
config_str new_char = yon_char_parsed_new ( & size , ( * to_copy ) [ 0 ] ) ;
for ( int i = 0 ; ( * to_copy ) [ i ] ; i + + ) {
@ -802,7 +802,7 @@ void yon_char_parsed_copy(config_str *source, config_str *to_copy){
* Д о б а в л я е т с т р о к у [ string ] в к о н е ц м а с с и в а с т р о к [ parsed ] с д л и н н о й [ size ] .
*/
config_str yon_char_parsed_append ( config_str parsed , int * size , char * string ) {
config_str new_parsed = realloc ( parsed , ( ( * size ) + 2 ) * sizeof ( char * ) ) ;
config_str new_parsed = realloc ( parsed , ( * size + 1 ) * sizeof ( char * ) ) ;
new_parsed [ ( * size ) ] = yon_char_new ( string ) ;
( * size ) + + ;
return new_parsed ;
@ -969,18 +969,6 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size)
return NULL ;
} ;
config_str yon_file_open ( char * file_path , int * size ) {
* size = 0 ;
FILE * file = fopen ( file_path , " r " ) ;
if ( file ) {
char * str_loaded = malloc ( 4098 ) ;
config_str final_string = NULL ;
while ( fgets ( str_loaded , 4098 , file ) ) {
final_string = final_string ? yon_char_parsed_append ( final_string , size , str_loaded ) : yon_char_parsed_new ( size , str_loaded , NULL ) ;
}
return final_string ;
}
}
/**
* yon_dir_get_contents ( char * dir_path , int * size )
@ -1116,26 +1104,6 @@ int yon_config_remove_by_key(char *key){
return 0 ;
}
/**yon_config_remove_by_data(void *data)
* [ EN ]
*
* [ RU ]
* П р о и з в о д и т п о и с к п о к о н ф и г у н а н а л и ч и е п а р а м е т р а с о з н а ч е н и е м [ data ] и у д а л я е т н а й д е н н о е з н а ч е н и е и з к о н ф и г а .
*/
int yon_config_remove_by_data ( void * data ) {
check_config {
dictionary * dict = NULL ;
for_dictionaries ( dict , ( dictionary * ) __yon__config__strings ) {
if ( dict - > data = = data ) {
yon_dictionary_rip ( dict ) ;
return 1 ;
}
}
return 0 ;
}
return 0 ;
}
/**yon_config_remove_element(char *key, char *deleted)
* [ EN ]
*
@ -1331,12 +1299,50 @@ int yon_config_save_registered(char *path){
if ( dct - > data & & strcmp ( yon_dictionary_get_data ( dct , char * ) , " " ) ! = 0 ) {
if ( ( ( yon_config_parameter * ) dct ) - > flag1 = = 1 ) {
( ( yon_config_parameter * ) dct ) - > flag1 = 0 ;
if ( sections_add & & yon_dictionary_get ( & sections_add , ( ( yon_config_parameter * ) dct ) - > section ) ) sections_add - > data = ( void * ) yon_char_unite ( yon_dictionary_get_data ( sections_add , char * ) , " " , dct - > key , " = \" " , yon_dictionary_get_data ( dct , char * ) , " \" " , NULL ) ;
else yon_dictionary_add_or_create_if_exists_with_data ( sections_add , ( ( yon_config_parameter * ) dct ) - > section , yon_char_unite ( ubconfig_save_command , path ? yon_char_append ( " --target " , path ) : " " , " set " , ( ( yon_config_parameter * ) dct ) - > section , " " , dct - > key , " = \" " , yon_dictionary_get_data ( dct , char * ) , " \" " , NULL ) ) ;
if ( sections_add & & yon_dictionary_get ( & sections_add , ( ( yon_config_parameter * ) dct ) - > section ) ) sections_add - > data = ( void * ) yon_char_unite ( yon_dictionary_get_data ( sections_add , char * ) , " " , dct - > key , " = " , yon_dictionary_get_data ( dct , char * ) , NULL ) ;
else yon_dictionary_add_or_create_if_exists_with_data ( sections_add , ( ( yon_config_parameter * ) dct ) - > section , yon_char_unite ( ubconfig_save_command , path ? yon_char_append ( " --target " , path ) : " " , " set " , ( ( yon_config_parameter * ) dct ) - > section , " " , dct - > key , " = " , yon_dictionary_get_data ( dct , char * ) , NULL ) ) ;
} else if ( ( ( yon_config_parameter * ) dct ) - > flag1 = = - 1 ) {
( ( yon_config_parameter * ) dct ) - > flag1 = 0 ;
if ( sections_remove & & yon_dictionary_get ( & sections_remove , ( ( yon_config_parameter * ) dct ) - > section ) ) sections_remove - > data = ( void * ) yon_char_unite ( yon_dictionary_get_data ( sections_remove , char * ) , " " , dct - > key , NULL ) ;
else yon_dictionary_add_or_create_if_exists_with_data ( sections_remove , ( ( yon_config_parameter * ) dct ) - > section , yon_char_unite ( ubconfig_save_command , path ? yon_char_append ( " --target " , path ) : " " , " remove " , ( ( yon_config_parameter * ) dct ) - > section , " " , dct - > key , NULL ) ) ;
yon_dictionary_rip ( dct ) ;
}
}
}
if ( sections_add )
for_dictionaries ( dct , sections_add ) {
char * command = yon_dictionary_get_data ( dct , char * ) ;
yon_launch ( command ) ;
}
if ( sections_remove )
for_dictionaries ( dct , sections_remove ) {
char * command = yon_dictionary_get_data ( dct , char * ) ;
yon_launch ( command ) ;
}
return 1 ;
} else return 1 ;
}
/**int yon_config_force_save_registered(char *path, char *section)
* [ EN ]
* Saves config with [ command ]
* [ RU ]
* В ы п о л н я е т к о м а н д у [ command ] , д о б а в л я я в к о н е ц в с е з а п и с и к о н ф и г а в т а к о м в и д е :
* [ П А Р А М Е Т Р 1 ] = " [зна че ния1] " [ П А Р А М Е Т Р 2 ] = " [зна че ния2] "
*/
int yon_config_force_save_registered ( char * path ) {
check_config {
dictionary * dct ;
dictionary * sections_add = NULL ;
dictionary * sections_remove = NULL ;
for_dictionaries ( dct , ( dictionary * ) __yon__config__strings ) {
if ( dct - > data & & strcmp ( yon_dictionary_get_data ( dct , char * ) , " " ) ! = 0 ) {
if ( ( ( yon_config_parameter * ) dct ) - > flag1 = = 1 | | ( ( yon_config_parameter * ) dct ) - > flag1 = = 0 ) {
if ( sections_add & & yon_dictionary_get ( & sections_add , ( ( yon_config_parameter * ) dct ) - > section ) ) sections_add - > data = ( void * ) yon_char_unite ( yon_dictionary_get_data ( sections_add , char * ) , " " , dct - > key , " = " , yon_dictionary_get_data ( dct , char * ) , NULL ) ;
else yon_dictionary_add_or_create_if_exists_with_data ( sections_add , ( ( yon_config_parameter * ) dct ) - > section , yon_char_unite ( ubconfig_save_command , path ? yon_char_append ( " --target " , path ) : " " , " set " , ( ( yon_config_parameter * ) dct ) - > section , " " , dct - > key , " = " , yon_dictionary_get_data ( dct , char * ) , NULL ) ) ;
} else if ( ( ( yon_config_parameter * ) dct ) - > flag1 = = - 1 ) {
if ( sections_remove & & yon_dictionary_get ( & sections_remove , ( ( yon_config_parameter * ) dct ) - > section ) ) sections_remove - > data = ( void * ) yon_char_unite ( yon_dictionary_get_data ( sections_remove , char * ) , " " , dct - > key , NULL ) ;
else yon_dictionary_add_or_create_if_exists_with_data ( sections_remove , ( ( yon_config_parameter * ) dct ) - > section , yon_char_unite ( ubconfig_save_command , path ? yon_char_append ( " --target " , path ) : " " , " remove " , ( ( yon_config_parameter * ) dct ) - > section , " " , dct - > key , NULL ) ) ;
}
}
}
@ -1352,24 +1358,6 @@ int yon_config_save_registered(char *path){
}
// char *command = yon_char_unite(ubconfig_save_command,path ? yon_char_append(" --target ",path):"", " set ", section, " ", yon_dictionary_get_data(dct,char*),NULL);
// char *remove_command = yon_char_unite(ubconfig_save_command, path ? yon_char_append(" --target ",path):"", " remove "," ", yon_dictionary_get_data(dct,char*), section,NULL);
// dictionary *dict = NULL;
// int any_add = 0;
// int any_remove = 0;
// for_dictionaries(dict,(dictionary*)__yon__config__strings){
// char *data = yon_dictionary_get_data(dict,char*);
// if (((yon_config_parameter*)dict)->flag1==1&&strcmp(data,"")!=0){
// command = yon_char_unite(command, " ", dict->key,"=\"", yon_dictionary_get_data(dict,char*),"\"", NULL);
// any_add=1;
// }
// if (strcmp(data,"")==0){
// remove_command = yon_char_unite(remove_command, " ", dict->key, NULL);
// any_remove=1;
// }
// }
// if (any_add) yon_launch(command);
// if (any_remove) yon_launch(remove_command);
return 1 ;
} else return 1 ;
}
@ -1393,6 +1381,7 @@ config_str yon_config_get_all(int *size){
}
conf = yon_remalloc ( conf , sizeof ( char * ) * ( * size ) ) ;
conf [ * size - 1 ] = NULL ;
( * size ) = ( * size ) - 1 ;
return conf ;
} else return NULL ;
}
@ -1430,7 +1419,18 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param)
return NULL ;
}
config_str yon_file_open ( char * file_path , int * size ) {
* size = 0 ;
FILE * file = fopen ( file_path , " r " ) ;
if ( file ) {
char str_loaded [ 4098 ] ;
config_str final_string = NULL ;
while ( fgets ( str_loaded , 4098 , file ) ) {
final_string = final_string ? yon_char_parsed_append ( final_string , size , str_loaded ) : yon_char_parsed_new ( size , str_loaded , NULL ) ;
}
return final_string ;
}
}
// terminal-using functions
@ -1818,7 +1818,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end
param - > section = section ;
yon_dictionary_add_or_create_if_exists_with_data ( __yon_main_window_config . deleted_parameters , param - > parameter_name , param ) ;
}
int yon_window_config_get_parameter ( char * section , char * config_parameter , void * return_value , enum YON_TYPE type ) {
GError * err = NULL ;
switch ( type ) {
@ -1860,7 +1860,7 @@ GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){
GtkWidget * yon_ubl_menu_item_documentation_new ( char * buttonname ) {
GtkWidget * menu_item = gtk_menu_item_new ( ) ;
gtk_style_context_add_class ( gtk_widget_get_style_context ( menu_item ) , " menuitem top " ) ;
gtk_style_context_add_class ( gtk_widget_get_style_context ( menu_item ) , " menuitem middle " ) ;
GtkWidget * box = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL , 0 ) ;
GtkWidget * label = gtk_label_new ( buttonname ) ;
GtkWidget * image = gtk_image_new_from_icon_name ( " dialog-question-symbolic " , GTK_ICON_SIZE_BUTTON ) ;