|
|
|
@ -12,88 +12,100 @@ char *config_set_global_command = NULL;
|
|
|
|
char *config_set_local_command = NULL;
|
|
|
|
char *config_set_local_command = NULL;
|
|
|
|
char *config_set_custom_command = NULL;
|
|
|
|
char *config_set_custom_command = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
void yon_load_proceed(YON_CONFIG_TYPE type){
|
|
|
|
int __yon_load_proceed(YON_CONFIG_TYPE type){
|
|
|
|
yon_config_clean();
|
|
|
|
if (type!=YON_CONFIG_CUSTOM){
|
|
|
|
|
|
|
|
yon_config_clean();
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!yon_char_is_empty(config_get_default_command))
|
|
|
|
if (!yon_char_is_empty(config_get_default_command))
|
|
|
|
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
|
|
|
|
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
|
|
|
|
if (type==YON_CONFIG_GLOBAL){
|
|
|
|
if (type==YON_CONFIG_GLOBAL){
|
|
|
|
yon_config_load_config(type,config_get_global_command,NULL);
|
|
|
|
if (yon_config_load_config(type,config_get_global_command,NULL)){
|
|
|
|
} else if (type==YON_CONFIG_LOCAL){
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
yon_config_load_config(type,config_get_local_command,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (type==YON_CONFIG_LOCAL){
|
|
|
|
|
|
|
|
if (yon_config_load_config(type,config_get_local_command,NULL)){
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (type==YON_CONFIG_CUSTOM){
|
|
|
|
} else if (type==YON_CONFIG_CUSTOM){
|
|
|
|
char *path="";
|
|
|
|
char *path;
|
|
|
|
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
|
|
|
|
GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
|
|
|
|
gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
|
|
|
|
gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",template_app_information.app_tech_name));
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog),template_app_information.app_title);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(dialog),template_app_information.app_title);
|
|
|
|
GtkFileFilter *filter = gtk_file_filter_new();
|
|
|
|
GtkFileFilter *filter = gtk_file_filter_new();
|
|
|
|
gtk_file_filter_add_pattern(filter,"*.ini");
|
|
|
|
gtk_file_filter_add_pattern(filter,"*.ini");
|
|
|
|
gtk_file_filter_set_name(filter, "*.ini");
|
|
|
|
gtk_file_filter_set_name(filter,"*.ini");
|
|
|
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
|
|
|
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
|
|
|
|
gtk_widget_show(dialog);
|
|
|
|
gtk_widget_show(dialog);
|
|
|
|
int response = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
int response = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT){
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT){
|
|
|
|
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
|
|
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
|
|
if (!yon_char_is_empty(file)){
|
|
|
|
if (!yon_char_is_empty(file)){
|
|
|
|
path=file;
|
|
|
|
path=yon_char_unite("'",file,"'",NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
yon_config_clean();
|
|
|
|
|
|
|
|
char *final_command = yon_config_parameter_prepare_command(config_get_custom_command,file,NULL,NULL);
|
|
|
|
|
|
|
|
if (yon_config_load_config(type,final_command,NULL)){
|
|
|
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
char *command = yon_config_parameter_prepare_command(config_get_custom_command,path,NULL,NULL);
|
|
|
|
|
|
|
|
yon_config_load_config(type,command,NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_local_load(GtkWidget *){
|
|
|
|
void __on_config_local_load(GtkWidget *){
|
|
|
|
yon_load_proceed(YON_CONFIG_LOCAL);
|
|
|
|
__yon_load_proceed(YON_CONFIG_LOCAL);
|
|
|
|
template_config->load_mode=1;
|
|
|
|
template_config->load_mode=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_global_load(GtkWidget *){
|
|
|
|
void __on_config_global_load(GtkWidget *){
|
|
|
|
yon_load_proceed(YON_CONFIG_GLOBAL);
|
|
|
|
__yon_load_proceed(YON_CONFIG_GLOBAL);
|
|
|
|
template_config->load_mode=0;
|
|
|
|
template_config->load_mode=0;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_custom_load(GtkWidget *){
|
|
|
|
void __on_config_custom_load(GtkWidget *){
|
|
|
|
yon_load_proceed(YON_CONFIG_CUSTOM);
|
|
|
|
__yon_load_proceed(YON_CONFIG_CUSTOM);
|
|
|
|
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
template_config->load_mode=3;
|
|
|
|
template_config->load_mode=3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_global_local_save(){
|
|
|
|
void __on_config_global_local_save(){
|
|
|
|
yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
|
|
|
|
yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_global_save(){
|
|
|
|
void __on_config_global_save(){
|
|
|
|
yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
|
|
|
|
yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_local_save(){
|
|
|
|
void __on_config_local_save(){
|
|
|
|
yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_global_command,NULL);
|
|
|
|
yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_global_command,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void on_config_custom_save(){
|
|
|
|
void __on_config_custom_save(){
|
|
|
|
yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_custom_command,NULL);
|
|
|
|
yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_custom_command,NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void yon_ubl_settings_window_set_standard_callbacks(template_main_window *widgets, char *get_global_command, char *get_local_command,char *get_custom_command, char *get_default_command, char *get_global_only_command, char *get_local_only_command){
|
|
|
|
void yon_ubl_settings_window_set_standard_callbacks(template_main_window *widgets, char *get_global_command, char *get_local_command,char *get_custom_command, char *get_default_command, char *get_global_only_command, char *get_local_only_command){
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(__on_config_global_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(__on_config_global_load),NULL);
|
|
|
|
config_get_global_command = yon_char_new(get_global_command);
|
|
|
|
config_get_global_command = yon_char_new(get_global_command);
|
|
|
|
config_set_global_command = yon_char_replace_single(get_global_command,"get","set");
|
|
|
|
config_set_global_command = yon_char_replace_single(get_global_command,"get","set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(__on_config_local_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_local_save),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(__on_config_local_save),NULL);
|
|
|
|
config_get_local_command = yon_char_new(get_local_command);
|
|
|
|
config_get_local_command = yon_char_new(get_local_command);
|
|
|
|
config_set_local_command = yon_char_replace_single(get_local_command,"get","set");
|
|
|
|
config_set_local_command = yon_char_replace_single(get_local_command,"get","set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
if (!yon_char_is_empty(get_global_command)){
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(__on_config_custom_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),NULL);
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(__on_config_custom_load),NULL);
|
|
|
|
config_get_custom_command = yon_char_new(get_custom_command);
|
|
|
|
config_get_custom_command = yon_char_new(get_custom_command);
|
|
|
|
config_set_custom_command = yon_char_replace_single(get_custom_command,"get","set");
|
|
|
|
config_set_custom_command = yon_char_replace_single(get_custom_command,"get","set");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|