|
|
|
|
@ -5,12 +5,34 @@ config main_config;
|
|
|
|
|
//functions
|
|
|
|
|
|
|
|
|
|
void yon_load_proceed(YON_CONFIG_TYPE type){
|
|
|
|
|
if (yon_config_load_register(type,hostname_section,hostname_parameter,id_section,id_parameter,console_font_section,console_font_parameter,locale_section,locale_parameter,language_section,language_parameter,NULL)){}
|
|
|
|
|
else{
|
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
|
yon_ubl_status_box_render(LOAD_FAILED_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
textdomain(LocaleName);
|
|
|
|
|
}
|
|
|
|
|
yon_config_clean();
|
|
|
|
|
if (!yon_char_is_empty(config_get_default_command))
|
|
|
|
|
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
|
|
|
|
|
if (type==YON_CONFIG_GLOBAL){
|
|
|
|
|
yon_config_load_config(type,config_get_command("global"),NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (type==YON_CONFIG_LOCAL){
|
|
|
|
|
yon_config_load_config(type,config_get_command("system"),NULL);
|
|
|
|
|
} else if (type==YON_CONFIG_CUSTOM){
|
|
|
|
|
char *path;
|
|
|
|
|
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);
|
|
|
|
|
GtkFileFilter *filter = gtk_file_filter_new();
|
|
|
|
|
gtk_file_filter_add_pattern(filter,"*.ini");
|
|
|
|
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
|
|
|
|
|
gtk_widget_show(dialog);
|
|
|
|
|
int response = gtk_dialog_run(GTK_DIALOG(dialog));
|
|
|
|
|
if (response == GTK_RESPONSE_ACCEPT){
|
|
|
|
|
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
|
|
|
|
if (!yon_char_is_empty(file)){
|
|
|
|
|
path=file;
|
|
|
|
|
}
|
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
yon_config_load_config(type,config_get_command(path),NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -164,45 +186,117 @@ void yon_config_global_load(GtkWidget *self, main_window *widgets){
|
|
|
|
|
|
|
|
|
|
void yon_config_global_local_save(){
|
|
|
|
|
int changed = yon_config_get_status(id_parameter)==1;
|
|
|
|
|
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,hostname_section,hostname_parameter,id_section,id_parameter,console_font_section,console_font_parameter,locale_section,locale_parameter,language_section,language_parameter,NULL);
|
|
|
|
|
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_command("global"),NULL);
|
|
|
|
|
if (window){
|
|
|
|
|
if (changed){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"warning",SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// yon_ubl_status_box_render(yon_char_unite(SAVE_SUCCESS,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_config_custom_load(GtkWidget *self, main_window *widgets){
|
|
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(widgets->IDEntry),G_CALLBACK(on_id_changed),widgets);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),"");
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),"");
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),DEFAULT_LABEL);
|
|
|
|
|
int size;
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
config_str rtn = yon_config_load(get_id_command,&size);
|
|
|
|
|
rtn[0]=yon_char_divide_search(rtn[0],"\n",-1);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),*rtn);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->ConsoleFontCombo),0);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0);
|
|
|
|
|
yon_load_proceed(YON_CONFIG_CUSTOM);
|
|
|
|
|
char *hostname = yon_config_get_by_key(hostname_parameter);
|
|
|
|
|
if (!yon_char_is_empty(hostname)){
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->HostnameEntry),hostname);
|
|
|
|
|
}
|
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->languagelist),&iter);
|
|
|
|
|
for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->languagelist),&iter)){
|
|
|
|
|
gtk_list_store_set(widgets->languagelist,&iter,2,0,-1);
|
|
|
|
|
}
|
|
|
|
|
char *id = yon_config_get_by_key(id_parameter);
|
|
|
|
|
if (id&&!strcmp(id,"random"))
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),1);
|
|
|
|
|
else if (id&&!strcmp(id,"hardware"))
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),2);
|
|
|
|
|
else if (id){
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->IDEntry),id);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),3);
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_render(SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->IDCombo),0);
|
|
|
|
|
gtk_widget_set_sensitive(widgets->IDEntry,0);
|
|
|
|
|
}
|
|
|
|
|
// yon_ubl_status_box_render(yon_char_unite(SAVE_SUCCESS,"\n", SAVE_WARNING_LABEL,NULL),BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
|
|
|
|
|
char *code;
|
|
|
|
|
char *cons_font = yon_config_get_by_key(console_font_parameter);
|
|
|
|
|
if (cons_font){
|
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->fontlist),&iter);
|
|
|
|
|
for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->fontlist),&iter)){
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->fontlist),&iter,0,&code,-1);
|
|
|
|
|
if (code&&!strcmp(code,cons_font)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->ConsoleFontCombo),&iter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char *lang = yon_config_get_by_key(language_parameter);
|
|
|
|
|
char *avlocale = yon_config_get_by_key(locale_parameter);
|
|
|
|
|
int locsize;
|
|
|
|
|
if (avlocale);
|
|
|
|
|
config_str locale_parsed = yon_char_parse(avlocale,&locsize,",");
|
|
|
|
|
gboolean is_active;
|
|
|
|
|
char *locale_string="";
|
|
|
|
|
char *loc_name;
|
|
|
|
|
if (lang){
|
|
|
|
|
int valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(widgets->languagelist),&iter);
|
|
|
|
|
for(;valid;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(widgets->languagelist),&iter)){
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->languagelist),&iter,0,&loc_name,1,&code,2,&is_active,-1);
|
|
|
|
|
if (code&&!strcmp(code,lang)) gtk_combo_box_set_active_iter(GTK_COMBO_BOX(widgets->LanguageCombo),&iter);
|
|
|
|
|
if (avlocale)
|
|
|
|
|
for (int i=0;i<locsize;i++)
|
|
|
|
|
if (!strcmp(code,locale_parsed[i])) {
|
|
|
|
|
gtk_list_store_set(widgets->languagelist,&iter,2,1,-1);
|
|
|
|
|
locale_string = yon_char_unite(strcmp(locale_string,"") ? yon_char_append(locale_string,"; ") : locale_string, loc_name,NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strcmp(locale_string,"")) gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),locale_string);
|
|
|
|
|
}
|
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->IDEntry),G_CALLBACK(on_id_changed),widgets);
|
|
|
|
|
if (getuid()==0){
|
|
|
|
|
textdomain(template_ui_LocaleName);
|
|
|
|
|
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
textdomain(LocaleName);
|
|
|
|
|
}
|
|
|
|
|
main_config.load_mode=1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_config_local_save(){
|
|
|
|
|
int changed = yon_config_get_status(id_parameter)==1;
|
|
|
|
|
template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,hostname_section,hostname_parameter,id_section,id_parameter,console_font_section,console_font_parameter,locale_section,locale_parameter,language_section,language_parameter,NULL);
|
|
|
|
|
template_saving_window *window = yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_command("system"),NULL);
|
|
|
|
|
if (window){
|
|
|
|
|
if (changed){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"warning",SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_render(SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_config_global_save(){
|
|
|
|
|
int changed = yon_config_get_status(id_parameter)==1;
|
|
|
|
|
template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,hostname_section,hostname_parameter,id_section,id_parameter,console_font_section,console_font_parameter,locale_section,locale_parameter,language_section,language_parameter,NULL);
|
|
|
|
|
template_saving_window *window = yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_command("global"),NULL);
|
|
|
|
|
if (window){
|
|
|
|
|
if (changed){
|
|
|
|
|
yon_ubl_status_box_spawn_infinite(GTK_CONTAINER(window->StatusBox),"warning",SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
yon_ubl_status_box_render(SAVE_WARNING_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_config_custom_save(){
|
|
|
|
|
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,config_get_command("system"),NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_locale_toggle(GtkCellRendererToggle *self,GtkTreePath* path,GtkTreeViewColumn* column,locals_window *window){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(window->MainTree));
|
|
|
|
|
@ -230,7 +324,7 @@ void on_locale_accept(GtkWidget *self, dictionary *dict){
|
|
|
|
|
}
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(widgets->LocaleEntry),final_string);
|
|
|
|
|
if (yon_config_get_by_key("LOCALE")) yon_config_set("LOCALE",final_ids);
|
|
|
|
|
else yon_config_register("LOCALE",locale_section,final_ids);
|
|
|
|
|
else yon_config_register("LOCALE",LOCALE_get_command,final_ids);
|
|
|
|
|
on_subwindow_close(self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -260,7 +354,7 @@ void on_hostname_changed(GtkEntry *self, main_window *widgets){
|
|
|
|
|
if (yon_config_get_by_key(hostname_parameter)){
|
|
|
|
|
yon_config_set(hostname_parameter,text);
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_register(hostname_parameter,hostname_section,text);
|
|
|
|
|
yon_config_register(hostname_parameter,HOSTNAME_get_command,text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -270,7 +364,7 @@ void on_id_combo_toggled(GtkComboBox *self, main_window *widgets){
|
|
|
|
|
if (yon_config_get_by_key(id_parameter)){
|
|
|
|
|
yon_config_set(id_parameter, id == 1 ? "random" : "hardware");
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_register(id_parameter,id_section, id == 1 ? "random":"hardware");
|
|
|
|
|
yon_config_register(id_parameter,MACHINEID_get_command, id == 1 ? "random":"hardware");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (id<3){
|
|
|
|
|
@ -287,7 +381,7 @@ void on_id_changed(GtkEntry *self, main_window *widgets){
|
|
|
|
|
if (yon_config_get_by_key(id_parameter)){
|
|
|
|
|
yon_config_set(id_parameter,text);
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_register(id_parameter,id_section,text);
|
|
|
|
|
yon_config_register(id_parameter,MACHINEID_get_command,text);
|
|
|
|
|
}
|
|
|
|
|
if (!main_config.lock_save_global)
|
|
|
|
|
gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,1);
|
|
|
|
|
@ -326,7 +420,7 @@ void on_console_font_changed(GtkComboBox *self, main_window *widgets){
|
|
|
|
|
if (yon_config_get_by_key(console_font_parameter)){
|
|
|
|
|
yon_config_set(console_font_parameter,code);
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_register(console_font_parameter,console_font_section,code);
|
|
|
|
|
yon_config_register(console_font_parameter,CONSOLE_FONT_get_command,code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -340,7 +434,7 @@ void on_language_changed(GtkComboBox *self, main_window *widgets){
|
|
|
|
|
if (yon_config_get_by_key(language_parameter)){
|
|
|
|
|
yon_config_set(language_parameter,code);
|
|
|
|
|
} else {
|
|
|
|
|
yon_config_register(language_parameter,language_section,code);
|
|
|
|
|
yon_config_register(language_parameter,LANG_get_command,code);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -396,10 +490,12 @@ main_window *yon_main_window_complete(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(yon_config_global_load),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(yon_config_local_load),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(yon_config_custom_load),widgets);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(yon_config_global_local_save),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(yon_config_global_save),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(yon_config_local_save),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(yon_config_custom_save),widgets);
|
|
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->HostnameEntry),"changed",G_CALLBACK(on_hostname_changed),widgets);
|
|
|
|
|
g_signal_connect(G_OBJECT(widgets->IDCombo),"changed",G_CALLBACK(on_id_combo_toggled),widgets);
|
|
|
|
|
|