diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 7914616..7aaa0de 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -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;iInstallerCountryList,&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;iInstallerLanguageList,&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); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 541ba2a..5ab7220 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -1133,4 +1133,5 @@ void on_vnc_toggled(GtkWidget *self, main_window *widgets); void yon_main_window_create(main_window *widgets); void set_locales_list(main_window *widgets); void on_installer_language_changed(GtkWidget *self, main_window *widgets); -gboolean on_country_filter(GtkTreeModel *self, GtkTreeIter *iter, main_window *widgets); \ No newline at end of file +gboolean on_country_filter(GtkTreeModel *self, GtkTreeIter *iter, main_window *widgets); +int yon_char_parsed_compare(const void *a, const void *b); \ No newline at end of file diff --git a/ubinstall-gtk.css b/ubinstall-gtk.css index 9823f36..f7f4c36 100644 --- a/ubinstall-gtk.css +++ b/ubinstall-gtk.css @@ -318,4 +318,9 @@ treeview row:nth-child(even) { background-color: #ffffff; } border-style: solid; border-color: @theme_fg_color; +} + +button { + min-width: 26px; + min-height: 24px; } \ No newline at end of file