|
|
|
|
@ -258,56 +258,58 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
|
|
|
|
|
|
|
|
|
|
void yon_window_config_save();
|
|
|
|
|
void yon_window_config_save(){
|
|
|
|
|
if (__yon_window_config_path){{
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x);
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y);
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width);
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height);
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen);
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
if (__yon_main_window_config.deleted_parameters)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.deleted_parameters){
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL);
|
|
|
|
|
}
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
GValue *val = (GValue*)g_malloc0(sizeof(GValue));
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break;
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
if (__yon_main_window_config.deleted_parameters)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.deleted_parameters){
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (__yon_main_window_config.custom_parameters)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_parameters){
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
switch (param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
GValue *val = (GValue*)g_malloc0(sizeof(GValue));
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (__yon_main_window_config.custom_parameters)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_parameters){
|
|
|
|
|
__yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*);
|
|
|
|
|
switch (param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_get_is_fullscreen();
|
|
|
|
|
@ -358,58 +360,63 @@ char **yon_char_parse(char *parameters, int *size, char *divider){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_window_config_load(char *path){
|
|
|
|
|
__yon_window_config_file = g_key_file_new();
|
|
|
|
|
__yon_window_config_path=yon_char_new(path);
|
|
|
|
|
if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){
|
|
|
|
|
struct stat st;
|
|
|
|
|
int size;
|
|
|
|
|
config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,(char*)"/");
|
|
|
|
|
char *path = yon_char_unite(conf[0],(char*)"/",conf[1],(char*)"/",conf[2],(char*)"/",conf[3],(char*)"/",conf[4],(char*)"/",NULL);
|
|
|
|
|
if (stat(path, &st) == -1) {
|
|
|
|
|
mkdir(path, 0777);
|
|
|
|
|
}
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen(__yon_window_config_path,"w");
|
|
|
|
|
chmod(__yon_window_config_path,0777);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL);
|
|
|
|
|
}
|
|
|
|
|
__yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL);
|
|
|
|
|
__yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL);
|
|
|
|
|
__yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL);
|
|
|
|
|
__yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL);
|
|
|
|
|
__yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL);
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
GValue *val = (GValue*)g_malloc0(sizeof(GValue));
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
gboolean res=0;
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL);
|
|
|
|
|
g_value_set_boolean(val,res);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
case YON_TYPE_OTHER:break;
|
|
|
|
|
if(__yon_window_config_target_window){
|
|
|
|
|
if (!access(path,0)){
|
|
|
|
|
__yon_window_config_file = g_key_file_new();
|
|
|
|
|
__yon_window_config_path=yon_char_new(path);
|
|
|
|
|
if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){
|
|
|
|
|
struct stat st;
|
|
|
|
|
int size;
|
|
|
|
|
config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,(char*)"/");
|
|
|
|
|
char *path = yon_char_unite(conf[0],(char*)"/",conf[1],(char*)"/",conf[2],(char*)"/",conf[3],(char*)"/",conf[4],(char*)"/",NULL);
|
|
|
|
|
if (stat(path, &st) == -1) {
|
|
|
|
|
mkdir(path, 0777);
|
|
|
|
|
}
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen(__yon_window_config_path,"w");
|
|
|
|
|
chmod(__yon_window_config_path,0777);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL);
|
|
|
|
|
}
|
|
|
|
|
__yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL);
|
|
|
|
|
__yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL);
|
|
|
|
|
__yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL);
|
|
|
|
|
__yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL);
|
|
|
|
|
__yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL);
|
|
|
|
|
dictionary *dict=NULL;
|
|
|
|
|
if (__yon_main_window_config.custom_listeners)
|
|
|
|
|
for_dictionaries(dict,__yon_main_window_config.custom_listeners){
|
|
|
|
|
__yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*);
|
|
|
|
|
GValue *val = (GValue*)g_malloc0(sizeof(GValue));
|
|
|
|
|
g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
gboolean res=0;
|
|
|
|
|
switch(param->containing_type){
|
|
|
|
|
case YON_TYPE_STRING:
|
|
|
|
|
g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_INT:
|
|
|
|
|
g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL));
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_BOOLEAN:
|
|
|
|
|
res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL);
|
|
|
|
|
g_value_set_boolean(val,res);
|
|
|
|
|
break;
|
|
|
|
|
case YON_TYPE_STRING_LIST:break;
|
|
|
|
|
case YON_TYPE_OTHER:break;
|
|
|
|
|
}
|
|
|
|
|
g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
}
|
|
|
|
|
if (__yon_main_window_config.width==0) __yon_main_window_config.width=800;
|
|
|
|
|
if (__yon_main_window_config.height==0) __yon_main_window_config.height=600;
|
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
|
|
gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y);
|
|
|
|
|
pthread_t tid;
|
|
|
|
|
pthread_create(&tid, NULL, (&_yon_maximize), NULL);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val);
|
|
|
|
|
}
|
|
|
|
|
if (__yon_main_window_config.width==0) __yon_main_window_config.width=800;
|
|
|
|
|
if (__yon_main_window_config.height==0) __yon_main_window_config.height=600;
|
|
|
|
|
gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height);
|
|
|
|
|
gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y);
|
|
|
|
|
pthread_t tid;
|
|
|
|
|
pthread_create(&tid, NULL, (&_yon_maximize), NULL);
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_window_config_apply();
|
|
|
|
|
|