|
|
|
|
@ -310,6 +310,59 @@ void config_init(){
|
|
|
|
|
|
|
|
|
|
// void *on_setup_system_configuration(void *data);
|
|
|
|
|
|
|
|
|
|
void on_additional_software_toggled(GtkWidget *, char *path, main_window *widgets){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
int status;
|
|
|
|
|
gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(widgets->AdditionalSoftwareList),&iter,path);
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->AdditionalSoftwareList),&iter,0,&status,-1);
|
|
|
|
|
gtk_list_store_set(widgets->AdditionalSoftwareList,&iter,0,!status,-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_gparted_open(){
|
|
|
|
|
yon_launch_app_with_arguments(open_gparted_command,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_reboot_accepted(main_window *widgets){
|
|
|
|
|
g_mutex_lock(&main_config.install_mutex);
|
|
|
|
|
if (main_config.install_thread){
|
|
|
|
|
pthread_cancel((pthread_t)main_config.install_thread);
|
|
|
|
|
g_mutex_unlock(&main_config.install_mutex);
|
|
|
|
|
}
|
|
|
|
|
main_config.exit_accepted=1;
|
|
|
|
|
g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event");
|
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
|
if (system("reboot")){};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_exit_accepted(main_window *widgets){
|
|
|
|
|
g_mutex_lock(&main_config.install_mutex);
|
|
|
|
|
if (main_config.install_thread){
|
|
|
|
|
pthread_cancel((pthread_t)main_config.install_thread);
|
|
|
|
|
g_mutex_unlock(&main_config.install_mutex);
|
|
|
|
|
}
|
|
|
|
|
main_config.exit_accepted=1;
|
|
|
|
|
// g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event");
|
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
|
gtk_widget_destroy(widgets->MainWindow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){
|
|
|
|
|
if (!main_config.exit_accepted||(main_config.save_done&&main_config.install_complete)){
|
|
|
|
|
if (widgets){};
|
|
|
|
|
dialog_confirmation_data *data = yon_confirmation_dialog_data_new();
|
|
|
|
|
data->action_text=WARNING_TEXT_LABEL;
|
|
|
|
|
data->title=WARNING_TITLE_LABEL;
|
|
|
|
|
if (yon_confirmation_dialog_call(widgets->MainWindow,data)==GTK_RESPONSE_ACCEPT ){
|
|
|
|
|
on_exit_accepted(widgets);
|
|
|
|
|
gtk_main_quit();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_locale_changed(GtkWidget *,main_window *widgets){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
@ -368,59 +421,6 @@ void on_installer_language_changed(GtkWidget *self, main_window *widgets){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_additional_software_toggled(GtkWidget *, char *path, main_window *widgets){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
int status;
|
|
|
|
|
gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(widgets->AdditionalSoftwareList),&iter,path);
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->AdditionalSoftwareList),&iter,0,&status,-1);
|
|
|
|
|
gtk_list_store_set(widgets->AdditionalSoftwareList,&iter,0,!status,-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_gparted_open(){
|
|
|
|
|
yon_launch_app_with_arguments(open_gparted_command,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void on_reboot_accepted(main_window *widgets){
|
|
|
|
|
g_mutex_lock(&main_config.install_mutex);
|
|
|
|
|
if (main_config.install_thread){
|
|
|
|
|
pthread_cancel((pthread_t)main_config.install_thread);
|
|
|
|
|
g_mutex_unlock(&main_config.install_mutex);
|
|
|
|
|
}
|
|
|
|
|
main_config.exit_accepted=1;
|
|
|
|
|
g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event");
|
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
|
if (system("reboot")){};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_exit_accepted(main_window *widgets){
|
|
|
|
|
g_mutex_lock(&main_config.install_mutex);
|
|
|
|
|
if (main_config.install_thread){
|
|
|
|
|
pthread_cancel((pthread_t)main_config.install_thread);
|
|
|
|
|
g_mutex_unlock(&main_config.install_mutex);
|
|
|
|
|
}
|
|
|
|
|
main_config.exit_accepted=1;
|
|
|
|
|
// g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event");
|
|
|
|
|
while(gtk_events_pending()) gtk_main_iteration();
|
|
|
|
|
gtk_widget_destroy(widgets->MainWindow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){
|
|
|
|
|
if (!main_config.exit_accepted||(main_config.save_done&&main_config.install_complete)){
|
|
|
|
|
if (widgets){};
|
|
|
|
|
dialog_confirmation_data *data = yon_confirmation_dialog_data_new();
|
|
|
|
|
data->action_text=WARNING_TEXT_LABEL;
|
|
|
|
|
data->title=WARNING_TITLE_LABEL;
|
|
|
|
|
if (yon_confirmation_dialog_call(widgets->MainWindow,data)==GTK_RESPONSE_ACCEPT ){
|
|
|
|
|
on_exit_accepted(widgets);
|
|
|
|
|
gtk_main_quit();
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct{
|
|
|
|
|
char *locale_name;
|
|
|
|
|
char *code;
|
|
|
|
|
@ -428,99 +428,47 @@ typedef struct{
|
|
|
|
|
char *code_full;
|
|
|
|
|
} locale_struct;
|
|
|
|
|
|
|
|
|
|
int yon_char_parsed_compare(const void *a, const void *b){
|
|
|
|
|
const config_str str_a = (const config_str)a;
|
|
|
|
|
const config_str str_b = (const config_str)b;
|
|
|
|
|
|
|
|
|
|
return strcmp(*str_a,*str_b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_locales_list(main_window *widgets){
|
|
|
|
|
gtk_list_store_clear(widgets->InstallerLanguageList);
|
|
|
|
|
gtk_list_store_clear(widgets->InstallerCountryList);
|
|
|
|
|
|
|
|
|
|
GHashTable *localisations = g_hash_table_new(g_str_hash,g_str_equal);
|
|
|
|
|
int locales_size;
|
|
|
|
|
config_str locales = yon_dir_get_contents(locales_list_command,&locales_size);
|
|
|
|
|
dictionary *locale_dict = NULL;
|
|
|
|
|
for (int i=0;i<locales_size;i++){
|
|
|
|
|
if (!strcmp(locales[i],".")) continue;
|
|
|
|
|
if (!strcmp(locales[i],"..")) continue;
|
|
|
|
|
char *path = yon_char_unite(locales_list_command,locales[i],NULL);
|
|
|
|
|
int info_size;
|
|
|
|
|
config_str code_info = yon_file_open(path,&info_size);
|
|
|
|
|
char *code = yon_char_parsed_check_exist_begins_with(code_info,info_size,"lang_ab");
|
|
|
|
|
if (yon_char_is_empty(code)) continue;
|
|
|
|
|
yon_char_remove_last_symbol(code,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(code,'"');
|
|
|
|
|
free(yon_char_divide_search(code,"\"",-1));
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
char *region = yon_char_parsed_check_exist_begins_with(code_info,info_size,"territory");
|
|
|
|
|
if (!yon_char_is_empty(region)){
|
|
|
|
|
yon_char_remove_last_symbol(region,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(region,'"');
|
|
|
|
|
free(yon_char_divide_search(region,"\"",-1));
|
|
|
|
|
}
|
|
|
|
|
char *lang_name = yon_char_parsed_check_exist_begins_with(code_info,info_size,"language");
|
|
|
|
|
if (!yon_char_is_empty(lang_name)){
|
|
|
|
|
yon_char_remove_last_symbol(lang_name,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(lang_name,'"');
|
|
|
|
|
free(yon_char_divide_search(lang_name,"\"",-1));
|
|
|
|
|
}
|
|
|
|
|
char *tooltip = yon_char_parsed_check_exist_begins_with(code_info,info_size,"title");
|
|
|
|
|
if (!yon_char_is_empty(tooltip)){
|
|
|
|
|
yon_char_remove_last_symbol(tooltip,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(tooltip,'"');
|
|
|
|
|
free(yon_char_divide_search(tooltip,"\"",-1));
|
|
|
|
|
}
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
char *country = yon_char_unite(lang_name," (",region,")",NULL);
|
|
|
|
|
gtk_list_store_append(widgets->InstallerCountryList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->InstallerCountryList,&iter,0,code,1,_(country),2,locales[i],3,_(tooltip),-1);
|
|
|
|
|
}
|
|
|
|
|
if (!g_hash_table_contains(localisations,code)) {
|
|
|
|
|
locale_struct *locale = malloc(sizeof(locale_struct));
|
|
|
|
|
memset(locale,0,sizeof(locale_struct));
|
|
|
|
|
|
|
|
|
|
locale->locale_name = yon_char_parsed_check_exist_begins_with(code_info,info_size,"language");
|
|
|
|
|
locale->code = code;
|
|
|
|
|
locale->localised_name = yon_char_parsed_check_exist_begins_with(code_info,info_size,"lang_name");
|
|
|
|
|
locale->code_full = yon_char_new(locales[i]);
|
|
|
|
|
|
|
|
|
|
if (!yon_char_is_empty(locale->locale_name)){
|
|
|
|
|
yon_char_remove_last_symbol(locale->locale_name,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(locale->locale_name,'"');
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(locale->localised_name)){
|
|
|
|
|
yon_char_remove_last_symbol(locale->localised_name,'\n');
|
|
|
|
|
yon_char_remove_last_symbol(locale->localised_name,'"');
|
|
|
|
|
}
|
|
|
|
|
yon_dictionary_add_or_create_if_exists_with_data(locale_dict,locales[i],locale);
|
|
|
|
|
free(yon_char_divide_search(locale->locale_name,"\"",-1));
|
|
|
|
|
free(yon_char_divide_search(locale->localised_name,"\"",-1));
|
|
|
|
|
g_hash_table_add(localisations,code);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(code_info,info_size);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(locales,locales_size);
|
|
|
|
|
|
|
|
|
|
int size;
|
|
|
|
|
config_str locales = yon_locale_get_all_codes(&size);
|
|
|
|
|
qsort(locales,size,sizeof(char*),yon_char_parsed_compare);
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
dictionary *dict;
|
|
|
|
|
char *config_val = yon_char_new(config(installer_lang_parameter));
|
|
|
|
|
char *config_code = NULL;
|
|
|
|
|
if (yon_char_is_empty(config_val)) config_val = yon_char_new(setlocale(LC_ALL,NULL));
|
|
|
|
|
if(strstr(config_val,"_")){
|
|
|
|
|
config_code = yon_char_divide_search(config_val,"_",-1);
|
|
|
|
|
free(config_val);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
for_dictionaries(dict,locale_dict){
|
|
|
|
|
locale_struct *locale = yon_dictionary_get_data(dict,locale_struct*);
|
|
|
|
|
gtk_list_store_append(widgets->InstallerLanguageList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->InstallerLanguageList,&iter,0,locale->code,1,locale->locale_name,2,_(locale->localised_name),3,locale->code_full,-1);
|
|
|
|
|
if (!yon_char_is_empty(config_code)){
|
|
|
|
|
if (!strcmp(config_code,locale->code)){
|
|
|
|
|
g_signal_handlers_block_by_func(G_OBJECT(widgets->CountryLanguagesTree),G_CALLBACK(on_installer_language_changed),widgets);
|
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->LanguagesTree)),&iter);
|
|
|
|
|
on_locale_changed(NULL,widgets);
|
|
|
|
|
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->CountryLanguagesTree),G_CALLBACK(on_installer_language_changed),widgets);
|
|
|
|
|
}
|
|
|
|
|
GHashTable *added = g_hash_table_new(g_str_hash,g_str_equal);
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
char *lang_ab = yon_locale_get_parameter(locales[i],YON_LOCALE_LANG_AB);
|
|
|
|
|
char *language = yon_locale_get_parameter(locales[i],YON_LOCALE_LANGUAGE);
|
|
|
|
|
char *lang_name = yon_locale_get_parameter(locales[i],YON_LOCALE_LANG_NAME);
|
|
|
|
|
char *territory = yon_locale_get_parameter(locales[i],YON_LOCALE_TERRITORY);
|
|
|
|
|
char *title = yon_locale_get_parameter(locales[i],YON_LOCALE_TITLE);
|
|
|
|
|
if (yon_char_is_empty(lang_ab)||yon_char_is_empty(language)||yon_char_is_empty(lang_name)||yon_char_is_empty(territory)||yon_char_is_empty(title)) continue;
|
|
|
|
|
char *country = yon_char_unite(language,", ",territory,NULL);
|
|
|
|
|
if (!g_hash_table_contains(added,lang_ab)){
|
|
|
|
|
g_hash_table_add(added,yon_char_new(lang_ab));
|
|
|
|
|
gtk_list_store_append(widgets->InstallerLanguageList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->InstallerLanguageList,&iter,
|
|
|
|
|
0,lang_ab,
|
|
|
|
|
1,_(language),
|
|
|
|
|
2,lang_name,
|
|
|
|
|
3,locales[i],
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gtk_list_store_append(widgets->InstallerCountryList,&iter);
|
|
|
|
|
gtk_list_store_set(widgets->InstallerCountryList,&iter,
|
|
|
|
|
0,lang_ab,
|
|
|
|
|
1,_(country),
|
|
|
|
|
2,locales[i],
|
|
|
|
|
3,title,
|
|
|
|
|
-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@ -988,6 +936,7 @@ void yon_main_window_create(main_window *widgets){
|
|
|
|
|
// locale = setlocale(LC_ALL,NULL);
|
|
|
|
|
// }
|
|
|
|
|
// yon_ubl_window_init(TITLE_LABEL,DESCRIPTION_LABEL,locale,CssPath,LocaleName,version_application,WIKI_LINK);
|
|
|
|
|
yon_locale_init();
|
|
|
|
|
set_locales_list(widgets);
|
|
|
|
|
// {
|
|
|
|
|
// char *parameter = config(installer_lang_parameter);
|
|
|
|
|
|