diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9a5fe02..a9b8cd1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -116,6 +116,12 @@ set(SOURCE_FILES ubinstall-gtk-separate.c ubinstall-gtk-users.c ubinstall-gtk-configuration-mode.c + ubinstall-gtk-decorations.c + ubinstall-gtk-log.c + ubinstall-gtk-password.c + ubinstall-gtk-saving.c + ubinstall-gtk-standard.c + ubinstall-gtk-install-start.c ubinstall-gtk.h ubl-strings.h ) diff --git a/source/ubinstall-gtk-decorations.c b/source/ubinstall-gtk-decorations.c new file mode 100644 index 0000000..e69de29 diff --git a/source/ubinstall-gtk-grub.c b/source/ubinstall-gtk-grub.c index ea8b0fa..8999484 100644 --- a/source/ubinstall-gtk-grub.c +++ b/source/ubinstall-gtk-grub.c @@ -20,7 +20,6 @@ int yon_grub_install_save(main_window *widgets){ yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,cur_device); yon_config_register(part_parameter,part_parameter_command,partition); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"grub_install"); - yon_config_remove_by_key(part_parameter); return 1; } @@ -44,6 +43,5 @@ int yon_grub_update_save(main_window *widgets){ yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,cur_device); yon_config_register(part_parameter,part_parameter_command,partition); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"grub_update"); - yon_config_remove_by_key(part_parameter); return 1; } \ No newline at end of file diff --git a/source/ubinstall-gtk-install-start.c b/source/ubinstall-gtk-install-start.c new file mode 100644 index 0000000..e4e97a8 --- /dev/null +++ b/source/ubinstall-gtk-install-start.c @@ -0,0 +1,6 @@ +#include "ubinstall-gtk.h" + +int yon_installation_start(main_window *widgets){ + g_thread_new("install_thread",(GThreadFunc)on_config_save,widgets); + return 1; +} \ No newline at end of file diff --git a/source/ubinstall-gtk-installation.c b/source/ubinstall-gtk-installation.c index 6fcdfc4..0d7f8ea 100644 --- a/source/ubinstall-gtk-installation.c +++ b/source/ubinstall-gtk-installation.c @@ -233,4 +233,206 @@ int yon_install_advanced_save(main_window *widgets){ } return 1; -} \ No newline at end of file +} + +void yon_set_max_size_from_partition(GtkTreeView *table, GtkSpinButton *spin_button, GtkComboBox *spin_combo){ + GtkTreeModel *model; + GtkTreeIter iter; + long selected_size; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(table),&model,&iter)){ + gtk_tree_model_get(model,&iter,6,&selected_size,-1); + if (!selected_size){ + gtk_tree_model_get(model,&iter,5,&selected_size,-1); + } + if (selected_size){ + GtkAdjustment *adj = gtk_spin_button_get_adjustment(spin_button); + const char *sizemod = gtk_combo_box_get_active_id(spin_combo); + double new_size = yon_size_long_convert_to_mod(selected_size,sizemod[0]); + gtk_adjustment_set_upper(adj,new_size); + gdouble old_value = gtk_adjustment_get_value(adj); + if (old_value>new_size){ + gtk_adjustment_set_value(adj,new_size); + } + } + } +} + +void on_partition_changed(GtkWidget *self, main_window *widgets){ + if (self==widgets->InstallationNearSysSectionTree||self == widgets->InstallationNearSizeTypeSpin){ + yon_set_max_size_from_partition(GTK_TREE_VIEW(widgets->InstallationNearSysSectionTree),GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin)); + } + +} + +// void on_separate_installation_changed(GtkWidget *self, main_window *widgets){ + +// gtk_list_store_clear(widgets->PartitionsList); +// GtkTreeIter iter; +// GtkTreeModel *model; +// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(self)),&model,&iter)){ +// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SeparateUserDevicesTree)),&iter); +// char *disk_path=""; +// gtk_tree_model_get(model,&iter,0,&disk_path,-1); +// int size; +// config_str partitions; +// partitions = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); +// for (int i=0;i1024;sz=sz+1){ +// free_space=free_space/1024; +// } +// if (sz==-1) { +// sz=0; +// free_space=free_space/1024; +// } +// free_space_string = yon_char_append(yon_char_from_double(free_space)," "); +// free_space_string[strlen(free_space_string)-1]=*(yon_size_get_mod(sz)); +// } +// gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); +// gtk_list_store_append(widgets->PartitionsList,&iter); +// gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),-1); +// } +// yon_char_parsed_free(parsed,size); +// } +// } + +void on_device_selection_changed(GtkWidget *self, main_window *widgets){ + gtk_list_store_clear(widgets->PartitionsList); + GtkTreeIter iter; + GtkTreeModel *model; + if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(self)),&model,&iter)){ + char *disk_path; + gtk_tree_model_get(model,&iter,0,&disk_path,-1); + int size; + config_str partitions; + partitions = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); + for (int i=0;i2){ + char sizemod='\0'; + capacity_long = atol(parsed[2]); + + char *temp = yon_char_from_double(yon_size_long_convert_automatic(capacity_long,&sizemod)); + capacity = yon_char_append_c(temp,sizemod); + free(temp); + } + if (parsed_size>7&&!yon_char_is_empty(parsed[7])){ + char sizemod='\0'; + free_space_long = capacity_long-atol(parsed[7]); + char *temp = yon_char_from_double(yon_size_long_convert_automatic(free_space_long,&sizemod)); + free_space = yon_char_append_c(temp,sizemod); + free(temp); + } + if (parsed_size>3){ + fs_type = parsed[3]; + } + if (parsed_size>4){ + label = parsed[4]; + } + + gtk_list_store_append(widgets->PartitionsList,&iter); + gtk_list_store_set(widgets->PartitionsList,&iter,0,name,1,capacity,2,free_space,3,fs_type,4,label,5,capacity_long,6,free_space_long,-1); + } + yon_char_parsed_free(parsed,parsed_size); + } + } + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); + gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); + } +} + +// void on_same_installation_device_changed(GtkWidget *, main_window *widgets){ +// gtk_list_store_clear(widgets->PartitionsList); +// GtkTreeIter iter; +// GtkTreeModel *model; +// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SamePlaceDeviceTree)),&model,&iter)){ +// char *disk_path=""; +// gtk_tree_model_get(model,&iter,0,&disk_path,-1); +// int size; +// config_str parsed; +// parsed = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); +// char *string = yon_char_parsed_to_string(parsed,size,""); +// struct json_object *root; +// struct json_object *blockdevices; +// root = json_tokener_parse(string); +// json_object_object_get_ex(root, "blockdevices", &blockdevices); +// for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { +// struct json_object *device = json_object_array_get_idx(blockdevices, i); +// struct json_object *type, *path, *size, *model, *vendor, *serial; + +// json_object_object_get_ex(device, "type", &type); +// if (strcmp("part",json_object_get_string(type))) +// continue; +// json_object_object_get_ex(device, "path", &path); +// if (!strstr(json_object_get_string(path),disk_path)){ +// continue; +// } +// json_object_object_get_ex(device, "size", &size); +// json_object_object_get_ex(device, "model", &model); +// json_object_object_get_ex(device, "vendor", &vendor); +// json_object_object_get_ex(device, "serial", &serial); + +// gtk_list_store_append(widgets->PartitionsList,&iter); +// gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); +// } +// yon_char_parsed_free(parsed,size); +// } +// } diff --git a/source/ubinstall-gtk-log.c b/source/ubinstall-gtk-log.c new file mode 100644 index 0000000..cf51915 --- /dev/null +++ b/source/ubinstall-gtk-log.c @@ -0,0 +1,127 @@ +#include "ubinstall-gtk.h" + + +// void on_log_closed(GtkWidget *, dictionary *dict){ +// main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); +// log_window *window = yon_dictionary_get_data(dict->first->next,log_window*); +// +// gtk_widget_set_sensitive(widgets->ReadFullLogButton,1); +// gtk_widget_set_sensitive(widgets->ReadShortLogButton,1); +// +// free(window->command); +// window->Window=NULL; +// } + +// log_window *yon_log_window_new(){ +// log_window *window = malloc(sizeof(log_window)); +// GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_log_view); +// window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); +// window->ScrollWindow = yon_gtk_builder_get_widget(builder,"ScrollWindow"); +// window->HeadLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); +// window->LogLabel = yon_gtk_builder_get_widget(builder,"LogLabel"); +// window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); +// window->ScrollToEndCheck = yon_gtk_builder_get_widget(builder,"ScrollToEndCheck"); +// gtk_widget_show(window->Window); +// return window; +// } + +// gboolean yon_read_log(void *data){ +// log_window *window = (log_window*)data; +// if (window->Window){ +// int size; +// g_mutex_lock(&main_config.progress_mutex); +// config_str parsed = yon_file_open(window->command,&size); +// g_mutex_unlock(&main_config.progress_mutex); +// if (size){ +// char *final = yon_char_parsed_to_string(parsed,size,""); +// gtk_label_set_text(GTK_LABEL(window->LogLabel),final); +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->ScrollToEndCheck))){ +// gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window->ScrollWindow)),gtk_adjustment_get_upper(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window->ScrollWindow)))); +// } +// free(final); +// yon_char_parsed_free(parsed,size); +// } +// g_mutex_lock(&main_config.install_mutex); +// if (!main_config.install_complete){ +// g_mutex_unlock(&main_config.install_mutex); +// return 1; +// } else { +// g_mutex_unlock(&main_config.install_mutex); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->ScrollToEndCheck),0); +// gtk_widget_set_sensitive(window->ScrollToEndCheck,0); +// } +// } +// return 0; +// } + +// void on_process_log_view(GtkWidget *,main_window *widgets){ +// log_window *window = yon_log_window_new(); +// dictionary *dict=NULL; +// yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); +// yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); +// g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),dict); +// gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); +// gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); +// yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,INSTALL_LOG_LABEL,icon_path,"log_viewer"); +// window->command = yon_char_new(short_log_path); +// gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); +// } + +// void on_summary_log_view(GtkWidget *,main_window *widgets){ +// log_window *window = yon_log_window_new(); +// dictionary *dict=NULL; +// yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); +// yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); +// g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),dict); +// gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); +// gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); +// yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,PROGRESS_LOG_LABEL,icon_path,"log_viewer"); +// window->command = yon_char_new(full_log_path); +// gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); +// +// } + +// gboolean yon_installation_progress_update(void *data) { +// main_window *widgets = (main_window*)data; +// int size; +// +// g_mutex_lock(&main_config.progress_mutex); +// config_str text = yon_file_open(progress_path, &size); +// g_mutex_unlock(&main_config.progress_mutex); +// +// if (size) { +// if (!yon_char_is_empty(text[size-1]) && text[size-1][0] == '(') { +// char *current_copy = yon_char_new(text[size-1]); +// char *percentage = yon_char_divide_search(current_copy, ")", -1); +// +// if (!strstr(percentage, "#pb")) { +// double fraction = atof(percentage+1); +// gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel), current_copy); +// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress), fraction / 100); +// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress), 0); +// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), ""); +// } else { +// gtk_widget_show(gtk_widget_get_parent(widgets->PackageInstallationProgress)); +// +// config_str parsed = yon_char_parse(current_copy, &size, " "); +// if (size >= 3) { +// double fraction = atof(parsed[2]) / 100; +// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress), fraction); +// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), yon_char_parsed_to_string(parsed, size, " ")); +// } +// } +// +// } +// yon_char_parsed_free(text, size); +// } +// +// g_mutex_lock(&main_config.install_mutex); +// if (main_config.install_thread) { +// g_mutex_unlock(&main_config.install_mutex); +// return 1; +// } else { +// g_mutex_unlock(&main_config.install_mutex); +// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), ""); +// return 0; +// } +// } diff --git a/source/ubinstall-gtk-network.c b/source/ubinstall-gtk-network.c index c1d4e4f..877a371 100644 --- a/source/ubinstall-gtk-network.c +++ b/source/ubinstall-gtk-network.c @@ -1,5 +1,34 @@ #include "ubinstall-gtk.h" +// void on_autohostname_check(GtkWidget *, main_window *widgets){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ +// gtk_widget_set_sensitive(widgets->HotnameEntry,0); +// gtk_entry_set_placeholder_text(GTK_ENTRY(widgets->HotnameEntry),"auto"); +// }else{ +// gtk_widget_set_sensitive(widgets->HotnameEntry,1); +// gtk_entry_set_placeholder_text(GTK_ENTRY(widgets->HotnameEntry),"ublinux-install"); +// } +// } + +// void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets){ +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck))){ +// gtk_widget_set_sensitive(widgets->AutoHostnameCheck,1); +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ +// gtk_widget_set_sensitive(widgets->HotnameEntry,0); +// } else +// gtk_widget_set_sensitive(widgets->HotnameEntry,1); +// } else { +// gtk_widget_set_sensitive(widgets->HotnameEntry,0); +// gtk_widget_set_sensitive(widgets->AutoHostnameCheck,0); +// } +// } + +// void on_hostname_entry_changed (GtkWidget *, main_window *widgets){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),0); +// } + network_info *yon_network_info_new(){ network_info *info = new(network_info); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_network_info); @@ -79,9 +108,35 @@ void on_connection_add(main_window *widgets){ int yon_network_save(main_window *widgets){ if (gtk_switch_get_active(GTK_SWITCH(widgets->NetworkDomainSwitch))){ - // const char *domain_name = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainNameEntry)); - // const char *domain_admin = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainAdminEntry)); - // const char *domain_password = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainPasswordEntry)); + const char *domain_name = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainNameEntry)); + if (!yon_char_is_empty(domain_name)){ + yon_ubl_status_box_render(EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(widgets->NetworkDomainNameEntry); + return 0; + } + const char *domain_admin = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainAdminEntry)); + const char *domain_password = gtk_entry_get_text(GTK_ENTRY(widgets->NetworkDomainPasswordEntry)); + if (!yon_char_is_empty(domain_name)) yon_config_register(DOMAIN_parameter,DOMAIN_parameter_command,(char*)domain_name); + else yon_config_remove_by_key(DOMAIN_parameter); + if ((!yon_char_is_empty(domain_admin)&&yon_char_is_empty(domain_password))||(yon_char_is_empty(domain_admin)&&!yon_char_is_empty(domain_password))){ + yon_ubl_status_box_render(EMPTY_IMPORTANT_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(widgets->NetworkDomainAdminEntry); + yon_ubl_status_highlight_incorrect(widgets->NetworkDomainPasswordEntry); + return 0; + } + if (!yon_char_is_empty(domain_admin)&&!yon_char_is_empty(domain_password)){ + int size; + config_str encrypted_password = yon_config_load(encrypt_domain_password_command(domain_password),&size); + if (!size){ + yon_ubl_status_box_render(ENCRYPT_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + yon_ubl_status_highlight_incorrect(widgets->NetworkDomainPasswordEntry); + return 0; + } + char *admin_string_full = yon_char_unite(domain_admin,":",encrypted_password[0],NULL); + yon_config_register(DOMAIN_admanger_parameter,DOMAIN_parameter_command,admin_string_full); + } else { + yon_config_remove_by_key(DOMAIN_admanger_parameter); + } } if (gtk_switch_get_active(GTK_SWITCH(widgets->NetworkNTPServerSwitch))){ diff --git a/source/ubinstall-gtk-page-switch.c b/source/ubinstall-gtk-page-switch.c index da2ac11..d6504e5 100644 --- a/source/ubinstall-gtk-page-switch.c +++ b/source/ubinstall-gtk-page-switch.c @@ -18,15 +18,15 @@ enum YON_PAGES yon_page_get_next(main_window *widgets, enum YON_PAGES page){ case YON_PAGE_STARTUP: return YON_PAGE_BOOTLOADER; break; case YON_PAGE_BOOTLOADER: return YON_PAGE_NETWORK; break; case YON_PAGE_NETWORK: return main_config.configure_mode? YON_PAGE_CONFIGURE_END : YON_PAGE_INSTALLATION; break; - case YON_PAGE_INSTALL_COMMON: return YON_PAGE_KERNEL; break; - case YON_PAGE_INSTALL_SEPARATE: return YON_PAGE_KERNEL; break; - case YON_PAGE_INSTALL_SAME_PARTITION: return YON_PAGE_KERNEL; break; - case YON_PAGE_INSTALL_ADVANCED: return YON_PAGE_KERNEL; break; + case YON_PAGE_INSTALL_COMMON: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_INSTALL_SEPARATE: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_INSTALL_SAME_PARTITION: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_INSTALL_ADVANCED: return main_config.configure_mode?YON_PAGE_KERNEL:YON_PAGE_INSTALLATION_BEGIN; break; case YON_PAGE_INSTALL_RECOVERY: return yon_recovery_get_next(widgets); break; - case YON_PAGE_RECOVERY_GRUB_INSTALL: return YON_PAGE_INSTALLATION; break; - case YON_PAGE_RECOVERY_GRUB_UPDATE: return YON_PAGE_INSTALLATION; break; - case YON_PAGE_RECOVERY_OS_ONLY: return YON_PAGE_INSTALLATION; break; - case YON_PAGE_RECOVERY_USRDATA_ONLY: return YON_PAGE_INSTALLATION; break; + case YON_PAGE_RECOVERY_GRUB_INSTALL: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_RECOVERY_GRUB_UPDATE: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_RECOVERY_OS_ONLY: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; + case YON_PAGE_RECOVERY_USRDATA_ONLY: return main_config.configure_mode?YON_PAGE_INSTALLATION:YON_PAGE_INSTALLATION_BEGIN; break; default:return YON_PAGE_WELCOME; } return YON_PAGE_WELCOME; @@ -158,6 +158,9 @@ int yon_page_save(main_window *widgets, enum YON_PAGES page){ case YON_PAGE_RECOVERY_USRDATA_ONLY: return yon_install_options_save(widgets->UserdataDevicesTree,widgets->UserdataSysSectionTree,"data_only",widgets); break; + case YON_PAGE_INSTALLATION_BEGIN: + return yon_installation_start(widgets); + break; default:return 1; } return 1; @@ -207,4 +210,165 @@ enum YON_PAGES yon_recovery_get_next(main_window *widgets){ else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->UserDataOnlyRadio))) return YON_PAGE_RECOVERY_USRDATA_ONLY; return YON_PAGE_SECTIONS; -} \ No newline at end of file +} + +void on_page_next_clicked(GtkWidget *, main_window *widgets){ + enum YON_PAGES page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook)); + page = yon_page_get_next(widgets,page); + if ((int)page!=-1){ + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page); + } + yon_page_update(widgets); +} + +void on_page_prev_clicked(GtkWidget *, main_window *widgets){ + enum YON_PAGES page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook)); + page = yon_page_get_prev(page); + if ((int)page!=-1){ + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page); + } + yon_page_update(widgets); +} + +// void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ +// if (widgets){}; +// switch(page){ +// case YON_PAGE_WELCOME: { +// gtk_widget_hide(widgets->SaveButton); +// gtk_widget_set_sensitive(widgets->CancelInstallButton,0); +// gtk_widget_set_sensitive(widgets->BackButton,0); +// gtk_widget_set_sensitive(widgets->NextButton,1); +// textdomain(LocaleName); +// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),NEXT_LABEL); +// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),CANCEL_LABEL); +// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))),"com.ublinux.ubinstall-gtk.arrow-right-symbolic",GTK_ICON_SIZE_BUTTON); +// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->CancelInstallButton))),"com.ublinux.ubinstall-gtk.circle-exit-symbolic",GTK_ICON_SIZE_BUTTON); +// gtk_widget_set_sensitive(widgets->ConfigurationModeMenuItem,1); +// yon_switch_page_render(widgets,0); +// } break; +// +// case YON_PAGE_LICENCE:{ +// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); +// gtk_widget_set_sensitive(widgets->BackButton,1); +// yon_switch_page_render(widgets,1); +// } break; +// +// case YON_PAGE_REGION: { +// yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); +// yon_switch_page_render(widgets,4); +// } break; +// +// case YON_PAGE_KEYBOARD: { +// +// yon_switch_page_render(widgets,5); +// yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); +// } break; +// +// case YON_PAGE_OS_COMPONENTS: +// case YON_PAGE_SOFTWARE: +// case YON_PAGE_INSTALLATION_BEGIN: +// yon_switch_page_render(widgets,3); +// +// break; +// case YON_PAGE_INSTALLATION:{ +// yon_switch_page_render(widgets,3); +// gtk_widget_set_sensitive(widgets->BackButton,0); +// if ((!main_config.configure_mode)) +// gtk_widget_set_sensitive(widgets->CancelInstallButton,0); +// if (!main_config.progress_thread&&!main_config.configure_mode) +// main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); +// +// if (!main_config.slider_thread&&!main_config.configure_mode) +// main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); +// gtk_widget_show(gtk_widget_get_parent(widgets->InstallationProgress)); +// } break; +// +// case YON_PAGE_USERS: +// yon_switch_page_render(widgets,6); +// gtk_widget_set_sensitive(widgets->NextButton,1); +// gtk_widget_hide(widgets->SaveButton); +// break; +// +// case YON_PAGE_INSTALL_ERROR:{ +// on_summary_log_view((GtkWidget*)NULL,widgets); +// +// yon_switch_page_render(widgets,7); +// gtk_widget_set_sensitive(widgets->BackButton,0); +// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); +// gtk_widget_hide(widgets->InstallationLabel); +// gtk_widget_hide(widgets->PackageInstallationLabel); +// gtk_widget_set_sensitive(widgets->NextButton,1); +// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); +// g_mutex_lock(&main_config.install_mutex); +// main_config.install_complete=0; +// g_mutex_unlock(&main_config.install_mutex); +// main_config.save_done=0; +// textdomain(LocaleName); +// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); +// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); +// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), +// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); +// +// } break; +// case YON_PAGE_COMPLETION:{ +// yon_switch_page_render(widgets,7); +// gtk_widget_set_sensitive(widgets->BackButton,0); +// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); +// gtk_widget_hide(widgets->InstallationLabel); +// gtk_widget_hide(widgets->PackageInstallationLabel); +// gtk_widget_set_sensitive(widgets->NextButton,1); +// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); +// g_mutex_lock(&main_config.install_mutex); +// main_config.install_complete=0; +// g_mutex_unlock(&main_config.install_mutex); +// main_config.save_done=0; +// textdomain(LocaleName); +// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); +// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); +// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), +// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); +// } +// gtk_widget_hide(gtk_widget_get_parent(widgets->InstallationProgress)); +// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); +// break; +// +// case YON_PAGE_COMPLETED:{ +// yon_switch_page_render(widgets,7); +// gtk_widget_set_sensitive(widgets->BackButton,1); +// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); +// gtk_widget_hide(widgets->InstallationLabel); +// gtk_widget_hide(widgets->PackageInstallationLabel); +// gtk_widget_set_sensitive(widgets->NextButton,0); +// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); +// g_mutex_lock(&main_config.install_mutex); +// main_config.install_complete=0; +// g_mutex_unlock(&main_config.install_mutex); +// main_config.save_done=0; +// textdomain(LocaleName); +// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); +// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), +// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); +// +// }break; +// +// case YON_PAGE_SECTIONS: +// case YON_PAGE_INSTALL_COMMON: +// case YON_PAGE_INSTALL_SEPARATE: +// case YON_PAGE_INSTALL_SAME_PARTITION: +// case YON_PAGE_INSTALL_RECOVERY: +// case YON_PAGE_OPTIONS_GRUB_INSTALL: +// case YON_PAGE_OPTIONS_GRUB_UPDATE: +// case YON_PAGE_OPTIONS_SEPARATE: +// case YON_PAGE_OPTIONS_SEPARATE_USRDATA: +// case YON_PAGE_OPTIONS_OS_ONLY: +// case YON_PAGE_OPTIONS_USRDATA_ONLY: { +// yon_switch_page_render(widgets,2); +// } break; +// case YON_PAGE_CONFIGURE_END: { +// gtk_widget_set_sensitive(widgets->BackButton,1); +// gtk_widget_set_sensitive(widgets->NextButton,0); +// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); +// gtk_widget_show(widgets->SaveButton); +// } +// } +// } diff --git a/source/ubinstall-gtk-password.c b/source/ubinstall-gtk-password.c new file mode 100644 index 0000000..a90df7d --- /dev/null +++ b/source/ubinstall-gtk-password.c @@ -0,0 +1,44 @@ +#include "ubinstall-gtk.h" + + +// void yon_password_set_sensitive_from_toggle(GtkWidget *self, main_window *widgets){ +// GtkWidget *combo = NULL; +// GtkWidget *entry = NULL; +// if (self == widgets->PasswordSensitiveCheck){ +// combo = widgets->PasswordCombo; +// entry = widgets->PasswordEntry; +// } else { +// combo = widgets->AdminPasswordCombo; +// entry = widgets->AdminPasswordEntry; +// } +// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self))){ +// gtk_widget_set_sensitive(combo,1); +// if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo))){ +// gtk_widget_set_sensitive(entry,1); +// } else { +// gtk_widget_set_sensitive(entry,0); +// } +// } else { +// gtk_widget_set_sensitive(combo,0); +// gtk_widget_set_sensitive(entry,0); +// +// } +// } + +// void yon_password_combo_set_sensitive(GtkWidget *self, main_window *widgets){ +// GtkWidget *entry = NULL; +// GtkWidget *toggle = NULL; +// if (self == widgets->PasswordCombo){ +// entry = widgets->PasswordEntry; +// toggle = widgets->PasswordSensitiveCheck; +// } else if (self == widgets->AdminPasswordCombo){ +// entry = widgets->AdminPasswordEntry; +// toggle = widgets->RootPasswordSensitiveCheck; +// } +// if (gtk_combo_box_get_active(GTK_COMBO_BOX(self))&>k_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))){ +// gtk_widget_set_sensitive(entry,1); +// } else { +// gtk_widget_set_sensitive(entry,0); +// +// } +// } diff --git a/source/ubinstall-gtk-region.c b/source/ubinstall-gtk-region.c index 27b85da..2c3fce1 100644 --- a/source/ubinstall-gtk-region.c +++ b/source/ubinstall-gtk-region.c @@ -1,5 +1,11 @@ #include "ubinstall-gtk.h" +// void on_region_resized(GtkWidget *,main_window *widgets){ +// yon_image_resize_from_container(GTK_IMAGE(widgets->SlidesImage), (GdkPixbuf*)g_list_nth_data(widgets->slides_original,cur_slide)); +// yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); +// yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); +// } + int yon_region_save(main_window *widgets){ if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->RegionCombo))==-1){ yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),REGION_EMPTY_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE); diff --git a/source/ubinstall-gtk-saving.c b/source/ubinstall-gtk-saving.c new file mode 100644 index 0000000..93685b9 --- /dev/null +++ b/source/ubinstall-gtk-saving.c @@ -0,0 +1,544 @@ +#include "ubinstall-gtk.h" + + + +// void _yon_saving_threaded(char *final_command){ +// FILE *file = popen(final_command,"r"); +// int file_save; +// config_str file_return = yon_config_load_file(file,&file_save); +// pclose(file); +// file_return = yon_char_parsed_append(file_return,&file_save,final_command); +// char *result = yon_char_parsed_to_string(file_return,file_save,""); +// yon_debug_output("%s\n",result); +// yon_char_parsed_free(file_return,file_save); +// free(result); +// } + +// void yon_save_proceed(char *path, YON_CONFIG_TYPE type){ +// yon_debug_output("%s\n",yon_config_save_simple(type,path)); +// } + +// void yon_load_proceed(YON_CONFIG_TYPE type){ +// yon_config_clean(); +// if (!yon_char_is_empty(config_get_default_command)) +// yon_config_load_config(YON_CONFIG_DEFAULT,yon_debug_output("%s\n",config_get_default_command),NULL); +// if (type==YON_CONFIG_GLOBAL){ +// yon_config_load_config(type,yon_debug_output("%s\n",config_get_global_command),NULL); +// } else if (type==YON_CONFIG_LOCAL){ +// yon_config_load_config(type,yon_debug_output("%s\n",config_get_local_command),NULL); +// } else if (type==YON_CONFIG_CUSTOM){ +// char *path=""; +// GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); +// yon_gtk_window_setup(GTK_WINDOW(dialog),NULL,TITLE_LABEL,icon_path,"FileChooserWindow"); +// textdomain(LocaleName); +// gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubinstall"); +// gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); +// GtkFileFilter *filter = gtk_file_filter_new(); +// gtk_file_filter_add_pattern(filter,"*.ini"); +// gtk_file_filter_set_name(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=yon_char_unite("'",file,"'",NULL); +// free(file); +// } +// gtk_widget_destroy(dialog); +// } else { +// gtk_widget_destroy(dialog); +// } +// yon_config_load_config(type,yon_debug_output("%s\n",yon_config_get_custom_command(path)),NULL); +// if (path) free(path); +// } +// } + + +// void on_config_local_load(GtkWidget *,main_window *widgets){ +// yon_load_proceed(YON_CONFIG_LOCAL); +// yon_interface_update(widgets); +// main_config.load_mode=1; +// } + +// void on_config_global_load(GtkWidget *,main_window *widgets){ +// yon_load_proceed(YON_CONFIG_GLOBAL); +// yon_interface_update(widgets); +// main_config.load_mode=0; +// } + +// void on_config_custom_load(GtkWidget *,main_window *widgets){ +// yon_load_proceed(YON_CONFIG_CUSTOM); +// yon_interface_update(widgets); +// main_config.load_mode=3; +// } + +// void on_config_global_local_save(GtkWidget *,main_window *widgets){ +// yon_save_proceed(NULL,YON_CONFIG_BOTH); +// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); +// } + +// void on_config_local_save(GtkWidget *,main_window *widgets){ +// yon_save_proceed("system",YON_CONFIG_LOCAL); +// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); +// +// } + +// void on_config_global_save(GtkWidget *,main_window *widgets){ +// yon_save_proceed("global",YON_CONFIG_GLOBAL); +// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); +// +// } + +// void on_config_custom_save(GtkWidget *, main_window *widgets){ +// char *path = NULL; +// GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,SAVE_LABEL,GTK_RESPONSE_ACCEPT,NULL); +// textdomain(TITLE_LABEL); +// GtkFileFilter *filter = gtk_file_filter_new(); +// gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",LocaleName)); +// gtk_file_filter_add_pattern(filter,"*.ini"); +// gtk_file_filter_set_name(filter, "*.ini"); +// gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); +// 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)){ +// if (!strstr(file,".ini")) file = yon_char_append(file,".ini"); +// if (access(file,0)!=F_OK){ +// char *command_creation = ubconfig_file_create(file); +// int a = system(yon_debug_output("%s\n",command_creation)); +// if (access(file,0)!=F_OK||a){ +// yon_ubl_status_box_render(CUSTOM_CONFIG_CREATION_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); +// return; +// } +// } +// } +// path = yon_char_unite("'",file,"'",NULL); +// free(file); +// gtk_widget_destroy(dialog); +// } else { +// gtk_widget_destroy(dialog); +// return; +// } +// yon_save_proceed(path,YON_CONFIG_CUSTOM); +// if (path) free(path); +// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); +// } +// +// void yon_open_browser(GtkWidget *, char *link); +// void yon_open_browser(GtkWidget *, char *link){ +// GtkWidget *window = yon_ubl_browser_window_open(link,TITLE_LABEL); +// if (window) +// gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName)); +// } + +// void yon_interface_update(main_window *widgets){ +// if (widgets){}; +// enum YON_PAGES page=YON_PAGE_COMPLETED; +// char *type = config(AUTOINSTALL_TYPE_INSTALL); +// if (!yon_char_is_empty(type)){ +// if (!strcmp(type,"fast")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio),1); +// page = YON_PAGE_INSTALL_COMMON; +// } else if (!strcmp(type,"next")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationNearRadio),1); +// page = YON_PAGE_INSTALL_SEPARATE; +// } else if (!strcmp(type,"part")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationLinuxRadio),1); +// page = YON_PAGE_INSTALL_SAME_PARTITION; +// } else if (!strcmp(type,"grub_install")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubInstallRadio),1); +// page = YON_PAGE_OPTIONS_GRUB_INSTALL; +// } else if (!strcmp(type,"grub_update")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubUpdateRadio),1); +// page = YON_PAGE_OPTIONS_GRUB_UPDATE; +// } else if (!strcmp(type,"system_only")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OSRadio),1); +// page = YON_PAGE_OPTIONS_OS_ONLY; +// } else if (!strcmp(type,"data_only")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserDataOnlyRadio),1); +// page = YON_PAGE_OPTIONS_USRDATA_ONLY; +// } else if (!strcmp(type,"custom")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SeparateRadio),1); +// page = YON_PAGE_OPTIONS_SEPARATE; +// } +// } +// char *device = config(AUTOINSTALL_DEVICE); +// char *part = NULL; +// if (page!=YON_PAGE_INSTALL_COMMON) +// part = config(part_parameter); +// char *fs_type = config(part_type_parameter); +// char *device_label = config(device_label_parameter); +// char *format = config(device_format_parameter); +// char *part_size = config(part_size_parameter); +// GtkListStore *device_list = widgets->DevicesList; +// GtkListStore *part_list=widgets->PartitionsList; +// GtkWidget *device_tree=NULL; +// GtkWidget *part_tree=NULL; +// switch (page){ +// case YON_PAGE_INSTALL_COMMON:{ +// device_tree = widgets->CommonInstallationDevicesTree; +// } break; +// +// case YON_PAGE_INSTALL_SEPARATE:{ +// device_tree = widgets->InstallationNearSysDevicesTree; +// part_tree = widgets->InstallationNearSysSectionTree; +// if (!yon_char_is_empty(part_size)){ +// gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),atof(part_size)); +// if (part_size[strlen(part_size)-1]=='M') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),0); +// if (part_size[strlen(part_size)-1]=='G') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),1); +// if (part_size[strlen(part_size)-1]=='T') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),2); +// } +// if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),1); +// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),main_config.format_default); +// if (!yon_char_is_empty(fs_type)) +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->NextInstallationFilesystemTypeCombo),fs_type); +// if (device_label) +// gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),device_label); +// else +// gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),""); +// +// } break; +// +// case YON_PAGE_INSTALL_SAME_PARTITION:{ +// device_tree = widgets->SamePlaceDeviceTree; +// part_tree = widgets->SamePlacePartTree; +// if (!yon_char_is_empty(fs_type)) +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type); +// if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),1); +// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),main_config.format_default); +// if (device_label) +// gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),device_label); +// else +// gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),""); +// +// } break; +// case YON_PAGE_OPTIONS_GRUB_INSTALL:{ +// device_tree = widgets->GrubInstallDevicesTree; +// } break; +// +// case YON_PAGE_OPTIONS_GRUB_UPDATE:{ +// device_tree = widgets->GrubUpdateDevicesTree; +// } break; +// +// case YON_PAGE_OPTIONS_SEPARATE:{ +// GtkTreeIter iter; +// device_tree = widgets->SeparateDevicesTree; +// part_tree = widgets->SeparateSysSectionTree; +// for_iter(GTK_TREE_MODEL(device_list),&iter){ +// char *cur_device; +// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_device,-1); +// if (!strcmp(cur_device,device)){ +// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter); +// break; +// } +// } +// on_near_installation_device_changed(device_tree,widgets); +// for_iter(GTK_TREE_MODEL(part_list),&iter){ +// char *cur_part; +// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_part,-1); +// if (!strcmp(cur_part,part)){ +// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter); +// } +// } +// } break; +// +// case YON_PAGE_OPTIONS_OS_ONLY:{ +// device_tree = widgets->OSDevicesTree; +// part_tree = widgets->OSSysSectionTree; +// } break; +// +// case YON_PAGE_OPTIONS_USRDATA_ONLY:{ +// device_tree = widgets->UserdataDevicesTree; +// part_tree = widgets->UserdataSysSectionTree; +// } break; +// +// default:{}break; +// } +// GtkTreeIter iter; +// char *cur_device=""; +// if (page!=YON_PAGE_OPTIONS_SEPARATE && !yon_char_is_empty(device)){ +// for_iter (widgets->DevicesList,&iter){ +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->DevicesList),&iter,0,&cur_device,-1); +// if (!strcmp(device,cur_device)){ +// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter); +// break; +// } +// } +// on_near_installation_device_changed(device_tree,widgets); +// if (!yon_char_is_empty(part)){ +// for_iter (widgets->PartitionsList,&iter){ +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&part,-1); +// if (!strcmp(device,cur_device)){ +// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter); +// break; +// } +// } +// } +// } +// char *system_locale = config(locale_parameter); +// if (!yon_char_is_empty(system_locale)){ +// char *chosen_langs = ""; +// for_iter(widgets->LanguagesList,&iter){ +// char *cur=NULL, *render = NULL; +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,1,&render,2,&cur,-1); +// if (strstr(system_locale,cur)){ +// gtk_list_store_set((widgets->LanguagesList),&iter,0,1,-1); +// chosen_langs = yon_char_unite(chosen_langs,!yon_char_is_empty(chosen_langs)?";":"",render,NULL); +// } else { +// gtk_list_store_set((widgets->LanguagesList),&iter,0,0,-1); +// } +// } +// if (!yon_char_is_empty(chosen_langs)){ +// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),chosen_langs); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),1); +// free(chosen_langs); +// } else { +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); +// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); +// } +// } else { +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); +// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); +// int langsize; +// config_str lang = default_langs(&langsize); +// for_iter(widgets->LanguagesList,&iter){ +// char *cur=NULL; +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,2,&cur,-1); +// if (lang&&yon_char_parsed_check_exist(lang,langsize,cur)>-1){ +// gtk_list_store_set(widgets->LanguagesList,&iter,0,1,-1); +// } else { +// gtk_list_store_set(widgets->LanguagesList,&iter,0,0,-1); +// } +// if (cur) free(cur); +// } +// if (langsize) yon_char_parsed_free(lang,langsize); +// } +// char *zone = config(zone_parameter); +// char *region = NULL; +// +// if (!yon_char_is_empty(zone)) region = yon_char_divide_search(zone,"/",-1); else {gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0);} +// if (!yon_char_is_empty(region)){ +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),region); +// } else { +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),"Europe"); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0); +// } +// if (!yon_char_is_empty(zone)){ +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),zone); +// } else { +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),"Moscow"); +// } +// char *language = config(lang_parameter); +// if (!yon_char_is_empty(language)){ +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LanguageCombo),language); +// } else { +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->MainLanguageSensitiveCheck),0); +// } +// char *kbmodel = config (xkbmodel_parameter); +// char *optinos = config(xkboptions_parameter); +// char *layout = config(xkblayout_parameter); +// if (!yon_char_is_empty(kbmodel)){ +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->KeyboardModelCombo),kbmodel); +// } else { +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->KeyboardModelSensitiveCheck),0); +// +// } +// if (!yon_char_is_empty(optinos)){ +// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LayoutBindingCombo),optinos); +// } else { +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LayoutBindingCombo),0); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OptionsSensitiveCheck),0); +// } +// if (!yon_char_is_empty(layout)){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->ManualLayoutRadio),1); +// for_iter(widgets->LayoutList,&iter){ +// char *cur=NULL; +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&cur,-1); +// if (strstr(layout,cur)){ +// gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); +// } else { +// gtk_tree_store_set(widgets->LayoutList,&iter,3,0,-1); +// } +// } +// } else { +// for_iter(widgets->LayoutList,&iter){ +// char *id; +// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&id,-1); +// if (!strcmp(id,"ru")||!strcmp(id,"us")){ +// gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); +// } else { +// gtk_tree_store_set((widgets->LayoutList),&iter,3,0,-1); +// } +// } +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LayoutSensitiveCheck),0); +// } +// char *user_name = config(user_name_parameter); +// char *user_gecos = config(user_gecos_parameter); +// char *user_password = config(user_password_parameter); +// char *root_password = config(root_password_parameter); +// char *autologin = config(autologin_parameter); +// char *hostname = config(hostname_parameter); +// if (!yon_char_is_empty(user_name)){ +// if (!strcmp(user_name,"root")){ +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserRootOnlyCheck),1); +// } else { +// gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),user_name); +// } +// } else { +// gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LoginSensitiveCheck),0); +// } +// if (!yon_char_is_empty(user_gecos)){ +// gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),_(user_gecos)); +// } else { +// gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck),0); +// } +// int def_size=0; +// config_str default_password = NULL; +// if (!getuid()){ +// default_password = yon_config_load(yon_debug_output("%s\n",get_default_password_command), &def_size); +// if (def_size>0&&default_password){ +// yon_char_remove_last_symbol(default_password[0],'\n'); +// } +// } +// if ((def_size>0&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),0); +// gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->PasswordSensitiveCheck),0); +// +// } else if (!yon_char_is_empty(user_password)){ +// gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),user_password); +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),1); +// } +// if ((def_size>0&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),0); +// gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RootPasswordSensitiveCheck),0); +// +// } else if (!yon_char_is_empty(root_password)){ +// gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),root_password); +// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),1); +// } +// if (!yon_char_is_empty(autologin)){ +// if (!strcmp(autologin,"yes")) +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),1); +// else +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),0); +// } else { +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),main_config.autologin_default); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinSensitiveCheck),0); +// } +// if (!yon_char_is_empty(hostname)){ +// if (strcmp(hostname,"auto")){ +// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),hostname); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),0); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); +// } else{ +// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),""); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),1); +// } +// } else { +// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),""); +// g_signal_handlers_block_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),1); +// g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); +// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),0); +// } +// } + +gboolean on_install_success(main_window *widgets){ + gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); + yon_page_update(widgets); + + return 0; +} + +gboolean on_install_error(main_window *widgets){ + gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); + yon_page_update(widgets); + + return 0; +} + + +void *on_config_save(void *data){ + main_window *widgets = (main_window*)data; + + int size=0; + config_str parameters = yon_config_get_selection_by_key_no_ignored(&size, + AUTOINSTALL_TYPE_INSTALL, + AUTOINSTALL_DEVICE, + device_format_parameter, + device_label_parameter, + part_parameter, + part_type_parameter, + part_size_parameter, + NULL); + FILE *file = fopen(progress_path,"w"); + if (file) + fclose(file); + char *command = yon_debug_output("%s\n",save_config_command(yon_char_parsed_to_string(parameters,size," "))); + yon_char_parsed_free(parameters,size); + yon_debug_output("%s\n","Entered installation"); + if (system(yon_debug_output("%s\n",command))){ + + gdk_threads_add_idle((GSourceFunc)on_install_error,widgets); + free(command); + g_mutex_lock(&main_config.install_mutex); + main_config.install_complete=1; + g_mutex_unlock(&main_config.install_mutex); + return 0; + }; + free(command); + g_mutex_lock(&main_config.install_mutex); + main_config.install_complete=1; + g_mutex_unlock(&main_config.install_mutex); + if (!main_config.save_done&&main_config.save_configured){ + on_setup_system_configuration(widgets); + } + return 0; +} + +void *on_setup_system_configuration(void * data){ + yon_debug_output("%s\n","Entered thread"); + main_window *widgets = (main_window*)data; + if (widgets){}; + int size; + config_str all_parameters = yon_config_get_selection_by_key(&size, + user_name_parameter, + user_gecos_parameter, + user_password_parameter, + root_password_parameter, + autologin_parameter, + xkbmodel_parameter, + xkblayout_parameter, + xkbvariant_parameter, + xkboptions_parameter, + hostname_parameter, + zone_parameter, + lang_parameter, + locale_parameter, + NULL); + if (all_parameters){ + char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); + char *command = set_user_config_command(parameter_string); + if (system(yon_debug_output("%s\n",command))){}; + yon_char_parsed_free(all_parameters,size); + free(command); + if (parameter_string) free(parameter_string); + } + g_idle_add((GSourceFunc)on_install_success,widgets); + return NULL; +} diff --git a/source/ubinstall-gtk-standard.c b/source/ubinstall-gtk-standard.c new file mode 100644 index 0000000..e857c0d --- /dev/null +++ b/source/ubinstall-gtk-standard.c @@ -0,0 +1,48 @@ +#include "ubinstall-gtk.h" + + +// void on_open_documentation_confirmation(GtkWidget *self, char *link); +// void on_open_documentation_confirmation(GtkWidget *self, char *link){ +// if (main_config.always_open_documentation==0){ +// GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_documentation); +// documentation_confirmation_window *window = malloc(sizeof(documentation_confirmation_window)); +// window->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); +// window->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); +// window->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); +// window->HeaderLabel = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); +// window->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); +// gtk_label_set_text(GTK_LABEL(window->HeaderLabel),TITLE_LABEL); +// gtk_widget_show_all(window->Window); +// g_signal_connect(G_OBJECT(window->CloseButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); +// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); +// +// +// } else { +// yon_open_browser(self,link); +// } +// } + +// void on_link(GtkWidget *self, char* uri); +// void on_link(GtkWidget *self, char* uri){ +// gtk_widget_destroy(self); +// on_open_documentation_confirmation(self,uri); +// } + +// void on_about(GtkWidget *); +// void on_about(GtkWidget *){ +// GtkBuilder *builder=gtk_builder_new_from_resource(ui_glade_path_about); +// GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); +// GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); +// GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); +// gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); +// gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); +// gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(window),yon_char_append("com.ublinux.",LocaleName)); +// gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName)); +// gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),LocaleName); +// gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); +// g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),WIKI_LINK); +// gtk_widget_set_visible(hideButtonBox,0); +// gtk_widget_destroy(hideButtonBox); +// gtk_widget_show(window); +// } diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 2c5022c..dd35e3a 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -33,598 +33,37 @@ void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle){ gtk_toggle_button_set_active(toggle,1); } -// void on_autohostname_check(GtkWidget *, main_window *widgets){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); -// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ -// gtk_widget_set_sensitive(widgets->HotnameEntry,0); -// gtk_entry_set_placeholder_text(GTK_ENTRY(widgets->HotnameEntry),"auto"); -// }else{ -// gtk_widget_set_sensitive(widgets->HotnameEntry,1); -// gtk_entry_set_placeholder_text(GTK_ENTRY(widgets->HotnameEntry),"ublinux-install"); -// } -// } - -// void yon_password_set_sensitive_from_toggle(GtkWidget *self, main_window *widgets){ -// GtkWidget *combo = NULL; -// GtkWidget *entry = NULL; -// if (self == widgets->PasswordSensitiveCheck){ -// combo = widgets->PasswordCombo; -// entry = widgets->PasswordEntry; -// } else { -// combo = widgets->AdminPasswordCombo; -// entry = widgets->AdminPasswordEntry; -// } -// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self))){ -// gtk_widget_set_sensitive(combo,1); -// if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo))){ -// gtk_widget_set_sensitive(entry,1); -// } else { -// gtk_widget_set_sensitive(entry,0); -// } -// } else { -// gtk_widget_set_sensitive(combo,0); -// gtk_widget_set_sensitive(entry,0); -// -// } -// } - -// void yon_password_combo_set_sensitive(GtkWidget *self, main_window *widgets){ -// GtkWidget *entry = NULL; -// GtkWidget *toggle = NULL; -// if (self == widgets->PasswordCombo){ -// entry = widgets->PasswordEntry; -// toggle = widgets->PasswordSensitiveCheck; -// } else if (self == widgets->AdminPasswordCombo){ -// entry = widgets->AdminPasswordEntry; -// toggle = widgets->RootPasswordSensitiveCheck; -// } -// if (gtk_combo_box_get_active(GTK_COMBO_BOX(self))&>k_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle))){ -// gtk_widget_set_sensitive(entry,1); -// } else { -// gtk_widget_set_sensitive(entry,0); -// -// } -// } - -// void on_autohostname_sensitiveness_check(GtkWidget *, main_window *widgets){ -// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck))){ -// gtk_widget_set_sensitive(widgets->AutoHostnameCheck,1); -// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck))){ -// gtk_widget_set_sensitive(widgets->HotnameEntry,0); -// } else -// gtk_widget_set_sensitive(widgets->HotnameEntry,1); -// } else { -// gtk_widget_set_sensitive(widgets->HotnameEntry,0); -// gtk_widget_set_sensitive(widgets->AutoHostnameCheck,0); -// } -// } - -// void on_hostname_entry_changed (GtkWidget *, main_window *widgets){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),0); -// } - -// void _yon_saving_threaded(char *final_command){ -// FILE *file = popen(final_command,"r"); -// int file_save; -// config_str file_return = yon_config_load_file(file,&file_save); -// pclose(file); -// file_return = yon_char_parsed_append(file_return,&file_save,final_command); -// char *result = yon_char_parsed_to_string(file_return,file_save,""); -// yon_debug_output("%s\n",result); -// yon_char_parsed_free(file_return,file_save); -// free(result); -// } - -// void yon_save_proceed(char *path, YON_CONFIG_TYPE type){ -// yon_debug_output("%s\n",yon_config_save_simple(type,path)); -// } - -// void yon_load_proceed(YON_CONFIG_TYPE type){ -// yon_config_clean(); -// if (!yon_char_is_empty(config_get_default_command)) -// yon_config_load_config(YON_CONFIG_DEFAULT,yon_debug_output("%s\n",config_get_default_command),NULL); -// if (type==YON_CONFIG_GLOBAL){ -// yon_config_load_config(type,yon_debug_output("%s\n",config_get_global_command),NULL); -// } else if (type==YON_CONFIG_LOCAL){ -// yon_config_load_config(type,yon_debug_output("%s\n",config_get_local_command),NULL); -// } else if (type==YON_CONFIG_CUSTOM){ -// char *path=""; -// GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); -// yon_gtk_window_setup(GTK_WINDOW(dialog),NULL,TITLE_LABEL,icon_path,"FileChooserWindow"); -// textdomain(LocaleName); -// gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubinstall"); -// gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); -// GtkFileFilter *filter = gtk_file_filter_new(); -// gtk_file_filter_add_pattern(filter,"*.ini"); -// gtk_file_filter_set_name(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=yon_char_unite("'",file,"'",NULL); -// free(file); -// } -// gtk_widget_destroy(dialog); -// } else { -// gtk_widget_destroy(dialog); -// } -// yon_config_load_config(type,yon_debug_output("%s\n",yon_config_get_custom_command(path)),NULL); -// if (path) free(path); -// } -// } - -// void yon_interface_update(main_window *widgets){ -// if (widgets){}; -// enum YON_PAGES page=YON_PAGE_COMPLETED; -// char *type = config(AUTOINSTALL_TYPE_INSTALL); -// if (!yon_char_is_empty(type)){ -// if (!strcmp(type,"fast")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationRadio),1); -// page = YON_PAGE_INSTALL_COMMON; -// } else if (!strcmp(type,"next")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationNearRadio),1); -// page = YON_PAGE_INSTALL_SEPARATE; -// } else if (!strcmp(type,"part")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationLinuxRadio),1); -// page = YON_PAGE_INSTALL_SAME_PARTITION; -// } else if (!strcmp(type,"grub_install")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubInstallRadio),1); -// page = YON_PAGE_OPTIONS_GRUB_INSTALL; -// } else if (!strcmp(type,"grub_update")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->GrubUpdateRadio),1); -// page = YON_PAGE_OPTIONS_GRUB_UPDATE; -// } else if (!strcmp(type,"system_only")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OSRadio),1); -// page = YON_PAGE_OPTIONS_OS_ONLY; -// } else if (!strcmp(type,"data_only")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserDataOnlyRadio),1); -// page = YON_PAGE_OPTIONS_USRDATA_ONLY; -// } else if (!strcmp(type,"custom")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->InstallationWindowsRadio),1); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SeparateRadio),1); -// page = YON_PAGE_OPTIONS_SEPARATE; -// } -// } -// char *device = config(AUTOINSTALL_DEVICE); -// char *part = NULL; -// if (page!=YON_PAGE_INSTALL_COMMON) -// part = config(part_parameter); -// char *fs_type = config(part_type_parameter); -// char *device_label = config(device_label_parameter); -// char *format = config(device_format_parameter); -// char *part_size = config(part_size_parameter); -// GtkListStore *device_list = widgets->DevicesList; -// GtkListStore *part_list=widgets->PartitionsList; -// GtkWidget *device_tree=NULL; -// GtkWidget *part_tree=NULL; -// switch (page){ -// case YON_PAGE_INSTALL_COMMON:{ -// device_tree = widgets->CommonInstallationDevicesTree; -// } break; -// -// case YON_PAGE_INSTALL_SEPARATE:{ -// device_tree = widgets->InstallationNearSysDevicesTree; -// part_tree = widgets->InstallationNearSysSectionTree; -// if (!yon_char_is_empty(part_size)){ -// gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),atof(part_size)); -// if (part_size[strlen(part_size)-1]=='M') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),0); -// if (part_size[strlen(part_size)-1]=='G') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),1); -// if (part_size[strlen(part_size)-1]=='T') gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin),2); -// } -// if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),1); -// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck),main_config.format_default); -// if (!yon_char_is_empty(fs_type)) -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->NextInstallationFilesystemTypeCombo),fs_type); -// if (device_label) -// gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),device_label); -// else -// gtk_entry_set_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry),""); -// -// } break; -// -// case YON_PAGE_INSTALL_SAME_PARTITION:{ -// device_tree = widgets->SamePlaceDeviceTree; -// part_tree = widgets->SamePlacePartTree; -// if (!yon_char_is_empty(fs_type)) -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->SameInstallationFilesystemTypeCombo),fs_type); -// if (format&&!strcmp(format,"yes")) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),1); -// else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->SameInstallationFormatCheck),main_config.format_default); -// if (device_label) -// gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),device_label); -// else -// gtk_entry_set_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry),""); -// -// } break; -// case YON_PAGE_OPTIONS_GRUB_INSTALL:{ -// device_tree = widgets->GrubInstallDevicesTree; -// } break; -// -// case YON_PAGE_OPTIONS_GRUB_UPDATE:{ -// device_tree = widgets->GrubUpdateDevicesTree; -// } break; -// -// case YON_PAGE_OPTIONS_SEPARATE:{ -// GtkTreeIter iter; -// device_tree = widgets->SeparateDevicesTree; -// part_tree = widgets->SeparateSysSectionTree; -// for_iter(GTK_TREE_MODEL(device_list),&iter){ -// char *cur_device; -// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_device,-1); -// if (!strcmp(cur_device,device)){ -// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter); -// break; -// } -// } -// on_near_installation_device_changed(device_tree,widgets); -// for_iter(GTK_TREE_MODEL(part_list),&iter){ -// char *cur_part; -// gtk_tree_model_get(GTK_TREE_MODEL(device_list),&iter, 0,&cur_part,-1); -// if (!strcmp(cur_part,part)){ -// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter); -// } -// } -// } break; -// -// case YON_PAGE_OPTIONS_OS_ONLY:{ -// device_tree = widgets->OSDevicesTree; -// part_tree = widgets->OSSysSectionTree; -// } break; -// -// case YON_PAGE_OPTIONS_USRDATA_ONLY:{ -// device_tree = widgets->UserdataDevicesTree; -// part_tree = widgets->UserdataSysSectionTree; -// } break; -// -// default:{}break; -// } -// GtkTreeIter iter; -// char *cur_device=""; -// if (page!=YON_PAGE_OPTIONS_SEPARATE && !yon_char_is_empty(device)){ -// for_iter (widgets->DevicesList,&iter){ -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->DevicesList),&iter,0,&cur_device,-1); -// if (!strcmp(device,cur_device)){ -// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(device_tree)),&iter); -// break; -// } -// } -// on_near_installation_device_changed(device_tree,widgets); -// if (!yon_char_is_empty(part)){ -// for_iter (widgets->PartitionsList,&iter){ -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&part,-1); -// if (!strcmp(device,cur_device)){ -// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(part_tree)),&iter); -// break; -// } -// } -// } -// } -// char *system_locale = config(locale_parameter); -// if (!yon_char_is_empty(system_locale)){ -// char *chosen_langs = ""; -// for_iter(widgets->LanguagesList,&iter){ -// char *cur=NULL, *render = NULL; -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,1,&render,2,&cur,-1); -// if (strstr(system_locale,cur)){ -// gtk_list_store_set((widgets->LanguagesList),&iter,0,1,-1); -// chosen_langs = yon_char_unite(chosen_langs,!yon_char_is_empty(chosen_langs)?";":"",render,NULL); -// } else { -// gtk_list_store_set((widgets->LanguagesList),&iter,0,0,-1); -// } -// } -// if (!yon_char_is_empty(chosen_langs)){ -// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),chosen_langs); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),1); -// free(chosen_langs); -// } else { -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); -// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); -// } -// } else { -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); -// gtk_entry_set_text(GTK_ENTRY(widgets->AvailableLanguagesEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LanguagesSensitiveCheck),0); -// int langsize; -// config_str lang = default_langs(&langsize); -// for_iter(widgets->LanguagesList,&iter){ -// char *cur=NULL; -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LanguagesList),&iter,2,&cur,-1); -// if (lang&&yon_char_parsed_check_exist(lang,langsize,cur)>-1){ -// gtk_list_store_set(widgets->LanguagesList,&iter,0,1,-1); -// } else { -// gtk_list_store_set(widgets->LanguagesList,&iter,0,0,-1); -// } -// if (cur) free(cur); -// } -// if (langsize) yon_char_parsed_free(lang,langsize); -// } -// char *zone = config(zone_parameter); -// char *region = NULL; -// -// if (!yon_char_is_empty(zone)) region = yon_char_divide_search(zone,"/",-1); else {gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0);} -// if (!yon_char_is_empty(region)){ -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),region); -// } else { -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->RegionCombo),"Europe"); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RegionSensitiveCheck),0); -// } -// if (!yon_char_is_empty(zone)){ -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),zone); -// } else { -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->ZoneCombo),"Moscow"); -// } -// char *language = config(lang_parameter); -// if (!yon_char_is_empty(language)){ -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LanguageCombo),language); -// } else { -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LanguageCombo),0); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->MainLanguageSensitiveCheck),0); -// } -// char *kbmodel = config (xkbmodel_parameter); -// char *optinos = config(xkboptions_parameter); -// char *layout = config(xkblayout_parameter); -// if (!yon_char_is_empty(kbmodel)){ -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->KeyboardModelCombo),kbmodel); -// } else { -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->KeyboardModelCombo),0); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->KeyboardModelSensitiveCheck),0); -// -// } -// if (!yon_char_is_empty(optinos)){ -// gtk_combo_box_set_active_id(GTK_COMBO_BOX(widgets->LayoutBindingCombo),optinos); -// } else { -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->LayoutBindingCombo),0); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->OptionsSensitiveCheck),0); -// } -// if (!yon_char_is_empty(layout)){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->ManualLayoutRadio),1); -// for_iter(widgets->LayoutList,&iter){ -// char *cur=NULL; -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&cur,-1); -// if (strstr(layout,cur)){ -// gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); -// } else { -// gtk_tree_store_set(widgets->LayoutList,&iter,3,0,-1); -// } -// } -// } else { -// for_iter(widgets->LayoutList,&iter){ -// char *id; -// gtk_tree_model_get(GTK_TREE_MODEL(widgets->LayoutList),&iter,0,&id,-1); -// if (!strcmp(id,"ru")||!strcmp(id,"us")){ -// gtk_tree_store_set(widgets->LayoutList,&iter,3,1,-1); -// } else { -// gtk_tree_store_set((widgets->LayoutList),&iter,3,0,-1); -// } -// } -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LayoutSensitiveCheck),0); -// } -// char *user_name = config(user_name_parameter); -// char *user_gecos = config(user_gecos_parameter); -// char *user_password = config(user_password_parameter); -// char *root_password = config(root_password_parameter); -// char *autologin = config(autologin_parameter); -// char *hostname = config(hostname_parameter); -// if (!yon_char_is_empty(user_name)){ -// if (!strcmp(user_name,"root")){ -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UserRootOnlyCheck),1); -// } else { -// gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),user_name); -// } -// } else { -// gtk_entry_set_text(GTK_ENTRY(widgets->LoginEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->LoginSensitiveCheck),0); -// } -// if (!yon_char_is_empty(user_gecos)){ -// gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),_(user_gecos)); -// } else { -// gtk_entry_set_text(GTK_ENTRY(widgets->UserNameEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->UsernameSensitiveCheck),0); -// } -// int def_size=0; -// config_str default_password = NULL; -// if (!getuid()){ -// default_password = yon_config_load(yon_debug_output("%s\n",get_default_password_command), &def_size); -// if (def_size>0&&default_password){ -// yon_char_remove_last_symbol(default_password[0],'\n'); -// } -// } -// if ((def_size>0&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),0); -// gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->PasswordSensitiveCheck),0); -// -// } else if (!yon_char_is_empty(user_password)){ -// gtk_entry_set_text(GTK_ENTRY(widgets->PasswordEntry),user_password); -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->PasswordCombo),1); -// } -// if ((def_size>0&&!strcmp(default_password[0],user_password))||yon_char_is_empty(user_password)){ -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),0); -// gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->RootPasswordSensitiveCheck),0); -// -// } else if (!yon_char_is_empty(root_password)){ -// gtk_entry_set_text(GTK_ENTRY(widgets->AdminPasswordEntry),root_password); -// gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdminPasswordCombo),1); -// } -// if (!yon_char_is_empty(autologin)){ -// if (!strcmp(autologin,"yes")) -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),1); -// else -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),0); -// } else { -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinCheck),main_config.autologin_default); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutologinSensitiveCheck),0); -// } -// if (!yon_char_is_empty(hostname)){ -// if (strcmp(hostname,"auto")){ -// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),hostname); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),0); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),1); -// } else{ -// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),""); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),1); -// } -// } else { -// gtk_entry_set_text(GTK_ENTRY(widgets->HotnameEntry),""); -// g_signal_handlers_block_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->AutoHostnameCheck),1); -// g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AutoHostnameCheck),on_autohostname_check,widgets); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->HostnameSensitiveCheck),0); -// } -// } - -// void on_config_local_load(GtkWidget *,main_window *widgets){ -// yon_load_proceed(YON_CONFIG_LOCAL); -// yon_interface_update(widgets); -// main_config.load_mode=1; -// } - -// void on_config_global_load(GtkWidget *,main_window *widgets){ -// yon_load_proceed(YON_CONFIG_GLOBAL); -// yon_interface_update(widgets); -// main_config.load_mode=0; -// } - -// void on_config_custom_load(GtkWidget *,main_window *widgets){ -// yon_load_proceed(YON_CONFIG_CUSTOM); -// yon_interface_update(widgets); -// main_config.load_mode=3; -// } - -// void on_config_global_local_save(GtkWidget *,main_window *widgets){ -// yon_save_proceed(NULL,YON_CONFIG_BOTH); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); -// } - -// void on_config_local_save(GtkWidget *,main_window *widgets){ -// yon_save_proceed("system",YON_CONFIG_LOCAL); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); -// -// } - -// void on_config_global_save(GtkWidget *,main_window *widgets){ -// yon_save_proceed("global",YON_CONFIG_GLOBAL); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); -// -// } - -// void on_config_custom_save(GtkWidget *, main_window *widgets){ -// char *path = NULL; -// GtkWidget *dialog = gtk_file_chooser_dialog_new(TITLE_LABEL,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,SAVE_LABEL,GTK_RESPONSE_ACCEPT,NULL); -// textdomain(TITLE_LABEL); -// GtkFileFilter *filter = gtk_file_filter_new(); -// gtk_window_set_icon_name(GTK_WINDOW(dialog),yon_char_append("com.ublinux.",LocaleName)); -// gtk_file_filter_add_pattern(filter,"*.ini"); -// gtk_file_filter_set_name(filter, "*.ini"); -// gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); -// 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)){ -// if (!strstr(file,".ini")) file = yon_char_append(file,".ini"); -// if (access(file,0)!=F_OK){ -// char *command_creation = ubconfig_file_create(file); -// int a = system(yon_debug_output("%s\n",command_creation)); -// if (access(file,0)!=F_OK||a){ -// yon_ubl_status_box_render(CUSTOM_CONFIG_CREATION_ERROR_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); -// return; -// } -// } -// } -// path = yon_char_unite("'",file,"'",NULL); -// free(file); -// gtk_widget_destroy(dialog); -// } else { -// gtk_widget_destroy(dialog); -// return; -// } -// yon_save_proceed(path,YON_CONFIG_CUSTOM); -// if (path) free(path); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETED); -// } -// -// void yon_open_browser(GtkWidget *, char *link); -// void yon_open_browser(GtkWidget *, char *link){ -// GtkWidget *window = yon_ubl_browser_window_open(link,TITLE_LABEL); -// if (window) -// gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName)); -// } - -// void on_open_documentation_confirmation(GtkWidget *self, char *link); -// void on_open_documentation_confirmation(GtkWidget *self, char *link){ -// if (main_config.always_open_documentation==0){ -// GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_documentation); -// documentation_confirmation_window *window = malloc(sizeof(documentation_confirmation_window)); -// window->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); -// window->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); -// window->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); -// window->HeaderLabel = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); -// window->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); -// gtk_label_set_text(GTK_LABEL(window->HeaderLabel),TITLE_LABEL); -// gtk_widget_show_all(window->Window); -// g_signal_connect(G_OBJECT(window->CloseButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); -// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); -// g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_subwindow_close),NULL); -// -// -// } else { -// yon_open_browser(self,link); -// } -// } - -// void on_link(GtkWidget *self, char* uri); -// void on_link(GtkWidget *self, char* uri){ -// gtk_widget_destroy(self); -// on_open_documentation_confirmation(self,uri); -// } - -// void on_about(GtkWidget *); -// void on_about(GtkWidget *){ -// GtkBuilder *builder=gtk_builder_new_from_resource(ui_glade_path_about); -// GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); -// GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); -// GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); -// gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); -// gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); -// gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(window),yon_char_append("com.ublinux.",LocaleName)); -// gtk_window_set_icon_name(GTK_WINDOW(window),yon_char_append("com.ublinux.",LocaleName)); -// gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(window),LocaleName); -// gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); -// g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),WIKI_LINK); -// gtk_widget_set_visible(hideButtonBox,0); -// gtk_widget_destroy(hideButtonBox); -// gtk_widget_show(window); -// } +double yon_size_long_convert_to_mod(double size, char mod){ + int sizemod = yon_get_size_get_from_letter(mod); + double final_size = size; + for (int i=-1;i1024;repeats++){ -// byte_float=byte_float/1024; -// } -// if (repeats==-1) { -// repeats=0; -// byte_float=byte_float/1024; -// } -// switch(repeats){ -// case 0: (*size)='K'; -// break; -// case 1: (*size)='M'; -// break; -// case 2: (*size)='G'; -// break; -// case 3: (*size)='T'; -// break; -// } -// return byte_float; -// } +double yon_size_long_convert_automatic(unsigned long bytes, char *size){ + int repeats; + double byte_float=bytes; + for (repeats=-1;byte_float>1024;repeats++){ + byte_float=byte_float/1024; + } + if (repeats==-1) { + repeats=0; + byte_float=byte_float/1024; + } + switch(repeats){ + case 0: (*size)='K'; + break; + case 1: (*size)='M'; + break; + case 2: (*size)='G'; + break; + case 3: (*size)='T'; + break; + } + return byte_float; +} // // standard functions // /**config_init() @@ -686,12 +125,6 @@ void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle){ // return 1; // } -// void on_region_resized(GtkWidget *,main_window *widgets){ -// yon_image_resize_from_container(GTK_IMAGE(widgets->SlidesImage), (GdkPixbuf*)g_list_nth_data(widgets->slides_original,cur_slide)); -// yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); -// yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); -// } - void yon_switch_page_render(main_window *widgets){ enum YON_PAGES page = yon_page_get_current(GTK_NOTEBOOK(widgets->Notebook)); @@ -779,364 +212,6 @@ void yon_switch_page_render(main_window *widgets){ // void *on_setup_system_configuration(void *data); -// void *on_config_save(void *data){ -// main_window *widgets = (main_window*)data; -// -// int size=0; -// config_str parameters = yon_config_get_selection_by_key_no_ignored(&size, -// AUTOINSTALL_TYPE_INSTALL, -// AUTOINSTALL_DEVICE, -// device_format_parameter, -// device_label_parameter, -// main_config.install_mode!=1&&main_config.install_mode!=2?NULL:part_parameter, -// part_type_parameter, -// device_format_parameter, -// main_config.install_mode!=1?NULL:part_size_parameter, -// NULL); -// FILE *file = fopen(progress_path,"w"); -// if (file) -// fclose(file); -// char *command = save_config_command(yon_char_parsed_to_string(parameters,size," ")); -// yon_char_parsed_free(parameters,size); -// yon_debug_output("%s\n","Entered installation"); -// if (system(yon_debug_output("%s\n",command))){ -// -// gdk_threads_add_idle((GSourceFunc)on_install_error,widgets); -// free(command); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_thread=0; -// g_mutex_unlock(&main_config.install_mutex); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_complete=1; -// g_mutex_unlock(&main_config.install_mutex); -// return 0; -// }; -// free(command); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_thread=0; -// g_mutex_unlock(&main_config.install_mutex); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_complete=1; -// g_mutex_unlock(&main_config.install_mutex); -// if (!main_config.save_done&&main_config.save_configured){ -// on_setup_system_configuration(widgets); -// } -// return 0; -// } - -// gboolean yon_installation_progress_update(void *data) { -// main_window *widgets = (main_window*)data; -// int size; -// -// g_mutex_lock(&main_config.progress_mutex); -// config_str text = yon_file_open(progress_path, &size); -// g_mutex_unlock(&main_config.progress_mutex); -// -// if (size) { -// if (!yon_char_is_empty(text[size-1]) && text[size-1][0] == '(') { -// char *current_copy = yon_char_new(text[size-1]); -// char *percentage = yon_char_divide_search(current_copy, ")", -1); -// -// if (!strstr(percentage, "#pb")) { -// double fraction = atof(percentage+1); -// gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel), current_copy); -// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress), fraction / 100); -// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress), 0); -// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), ""); -// } else { -// gtk_widget_show(gtk_widget_get_parent(widgets->PackageInstallationProgress)); -// -// config_str parsed = yon_char_parse(current_copy, &size, " "); -// if (size >= 3) { -// double fraction = atof(parsed[2]) / 100; -// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress), fraction); -// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), yon_char_parsed_to_string(parsed, size, " ")); -// } -// } -// -// } -// yon_char_parsed_free(text, size); -// } -// -// g_mutex_lock(&main_config.install_mutex); -// if (main_config.install_thread) { -// g_mutex_unlock(&main_config.install_mutex); -// return 1; -// } else { -// g_mutex_unlock(&main_config.install_mutex); -// gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel), ""); -// return 0; -// } -// } - -// void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){ -// if (widgets){}; -// switch(page){ -// case YON_PAGE_WELCOME: { -// gtk_widget_hide(widgets->SaveButton); -// gtk_widget_set_sensitive(widgets->CancelInstallButton,0); -// gtk_widget_set_sensitive(widgets->BackButton,0); -// gtk_widget_set_sensitive(widgets->NextButton,1); -// textdomain(LocaleName); -// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),NEXT_LABEL); -// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),CANCEL_LABEL); -// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))),"com.ublinux.ubinstall-gtk.arrow-right-symbolic",GTK_ICON_SIZE_BUTTON); -// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->CancelInstallButton))),"com.ublinux.ubinstall-gtk.circle-exit-symbolic",GTK_ICON_SIZE_BUTTON); -// gtk_widget_set_sensitive(widgets->ConfigurationModeMenuItem,1); -// yon_switch_page_render(widgets,0); -// } break; -// -// case YON_PAGE_LICENCE:{ -// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); -// gtk_widget_set_sensitive(widgets->BackButton,1); -// yon_switch_page_render(widgets,1); -// } break; -// -// case YON_PAGE_REGION: { -// yon_image_resize_from_container(GTK_IMAGE(widgets->RegionImage), widgets->regions_original); -// yon_switch_page_render(widgets,4); -// } break; -// -// case YON_PAGE_KEYBOARD: { -// -// yon_switch_page_render(widgets,5); -// yon_image_resize_from_container(GTK_IMAGE(widgets->KeyboardImage), widgets->keyboard_original); -// } break; -// -// case YON_PAGE_OS_COMPONENTS: -// case YON_PAGE_SOFTWARE: -// case YON_PAGE_INSTALLATION_BEGIN: -// yon_switch_page_render(widgets,3); -// -// break; -// case YON_PAGE_INSTALLATION:{ -// yon_switch_page_render(widgets,3); -// gtk_widget_set_sensitive(widgets->BackButton,0); -// if ((!main_config.configure_mode)) -// gtk_widget_set_sensitive(widgets->CancelInstallButton,0); -// if (!main_config.progress_thread&&!main_config.configure_mode) -// main_config.progress_thread = gdk_threads_add_timeout(500,(GSourceFunc)yon_installation_progress_update,widgets); -// -// if (!main_config.slider_thread&&!main_config.configure_mode) -// main_config.slider_thread = g_timeout_add(5000,(GSourceFunc)on_image_slide,widgets); -// gtk_widget_show(gtk_widget_get_parent(widgets->InstallationProgress)); -// } break; -// -// case YON_PAGE_USERS: -// yon_switch_page_render(widgets,6); -// gtk_widget_set_sensitive(widgets->NextButton,1); -// gtk_widget_hide(widgets->SaveButton); -// break; -// -// case YON_PAGE_INSTALL_ERROR:{ -// on_summary_log_view((GtkWidget*)NULL,widgets); -// -// yon_switch_page_render(widgets,7); -// gtk_widget_set_sensitive(widgets->BackButton,0); -// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); -// gtk_widget_hide(widgets->InstallationLabel); -// gtk_widget_hide(widgets->PackageInstallationLabel); -// gtk_widget_set_sensitive(widgets->NextButton,1); -// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_complete=0; -// g_mutex_unlock(&main_config.install_mutex); -// main_config.save_done=0; -// textdomain(LocaleName); -// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); -// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); -// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), -// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); -// -// } break; -// case YON_PAGE_COMPLETION:{ -// yon_switch_page_render(widgets,7); -// gtk_widget_set_sensitive(widgets->BackButton,0); -// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); -// gtk_widget_hide(widgets->InstallationLabel); -// gtk_widget_hide(widgets->PackageInstallationLabel); -// gtk_widget_set_sensitive(widgets->NextButton,1); -// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_complete=0; -// g_mutex_unlock(&main_config.install_mutex); -// main_config.save_done=0; -// textdomain(LocaleName); -// gtk_button_set_label(GTK_BUTTON(widgets->NextButton),RESTART_LABEL); -// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); -// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), -// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); -// } -// gtk_widget_hide(gtk_widget_get_parent(widgets->InstallationProgress)); -// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); -// break; -// -// case YON_PAGE_COMPLETED:{ -// yon_switch_page_render(widgets,7); -// gtk_widget_set_sensitive(widgets->BackButton,1); -// gtk_widget_hide(gtk_widget_get_parent(widgets->PackageInstallationProgress)); -// gtk_widget_hide(widgets->InstallationLabel); -// gtk_widget_hide(widgets->PackageInstallationLabel); -// gtk_widget_set_sensitive(widgets->NextButton,0); -// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); -// g_mutex_lock(&main_config.install_mutex); -// main_config.install_complete=0; -// g_mutex_unlock(&main_config.install_mutex); -// main_config.save_done=0; -// textdomain(LocaleName); -// gtk_button_set_label(GTK_BUTTON(widgets->CancelInstallButton),EXIT_LABEL); -// gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))), -// "com.ublinux.ubinstall-gtk.sync-symbolic",GTK_ICON_SIZE_BUTTON); -// -// }break; -// -// case YON_PAGE_SECTIONS: -// case YON_PAGE_INSTALL_COMMON: -// case YON_PAGE_INSTALL_SEPARATE: -// case YON_PAGE_INSTALL_SAME_PARTITION: -// case YON_PAGE_INSTALL_RECOVERY: -// case YON_PAGE_OPTIONS_GRUB_INSTALL: -// case YON_PAGE_OPTIONS_GRUB_UPDATE: -// case YON_PAGE_OPTIONS_SEPARATE: -// case YON_PAGE_OPTIONS_SEPARATE_USRDATA: -// case YON_PAGE_OPTIONS_OS_ONLY: -// case YON_PAGE_OPTIONS_USRDATA_ONLY: { -// yon_switch_page_render(widgets,2); -// } break; -// case YON_PAGE_CONFIGURE_END: { -// gtk_widget_set_sensitive(widgets->BackButton,1); -// gtk_widget_set_sensitive(widgets->NextButton,0); -// gtk_widget_set_sensitive(widgets->CancelInstallButton,1); -// gtk_widget_show(widgets->SaveButton); -// } -// } -// } - -// gboolean on_install_success(main_window *widgets){ -// gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); -// -// return 0; -// } - -// gboolean on_install_error(main_window *widgets){ -// gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),""); -// gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALL_ERROR); -// return 0; -// } - -// void *on_setup_system_configuration(void * data){ -// yon_debug_output("%s\n","Entered thread"); -// main_window *widgets = (main_window*)data; -// if (widgets){}; -// int size; -// config_str all_parameters = yon_config_get_selection_by_key(&size, -// user_name_parameter, -// user_gecos_parameter, -// user_password_parameter, -// root_password_parameter, -// autologin_parameter, -// xkbmodel_parameter, -// xkblayout_parameter, -// xkbvariant_parameter, -// xkboptions_parameter, -// hostname_parameter, -// zone_parameter, -// lang_parameter, -// locale_parameter, -// NULL); -// if (all_parameters){ -// char *parameter_string = yon_char_parsed_to_string(all_parameters,size," "); -// char *command = set_user_config_command(parameter_string); -// if (system(yon_debug_output("%s\n",command))){}; -// yon_char_parsed_free(all_parameters,size); -// free(command); -// if (parameter_string) free(parameter_string); -// } -// g_idle_add((GSourceFunc)on_install_success,widgets); -// return NULL; -// } - -// void on_log_closed(GtkWidget *, dictionary *dict){ -// main_window *widgets = yon_dictionary_get_data(dict->first,main_window*); -// log_window *window = yon_dictionary_get_data(dict->first->next,log_window*); -// -// gtk_widget_set_sensitive(widgets->ReadFullLogButton,1); -// gtk_widget_set_sensitive(widgets->ReadShortLogButton,1); -// -// free(window->command); -// window->Window=NULL; -// } - -// log_window *yon_log_window_new(){ -// log_window *window = malloc(sizeof(log_window)); -// GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_log_view); -// window->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); -// window->ScrollWindow = yon_gtk_builder_get_widget(builder,"ScrollWindow"); -// window->HeadLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); -// window->LogLabel = yon_gtk_builder_get_widget(builder,"LogLabel"); -// window->StatusBox = yon_gtk_builder_get_widget(builder,"StatusBox"); -// window->ScrollToEndCheck = yon_gtk_builder_get_widget(builder,"ScrollToEndCheck"); -// gtk_widget_show(window->Window); -// return window; -// } - -// gboolean yon_read_log(void *data){ -// log_window *window = (log_window*)data; -// if (window->Window){ -// int size; -// g_mutex_lock(&main_config.progress_mutex); -// config_str parsed = yon_file_open(window->command,&size); -// g_mutex_unlock(&main_config.progress_mutex); -// if (size){ -// char *final = yon_char_parsed_to_string(parsed,size,""); -// gtk_label_set_text(GTK_LABEL(window->LogLabel),final); -// if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->ScrollToEndCheck))){ -// gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window->ScrollWindow)),gtk_adjustment_get_upper(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(window->ScrollWindow)))); -// } -// free(final); -// yon_char_parsed_free(parsed,size); -// } -// g_mutex_lock(&main_config.install_mutex); -// if (!main_config.install_complete){ -// g_mutex_unlock(&main_config.install_mutex); -// return 1; -// } else { -// g_mutex_unlock(&main_config.install_mutex); -// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->ScrollToEndCheck),0); -// gtk_widget_set_sensitive(window->ScrollToEndCheck,0); -// } -// } -// return 0; -// } - -// void on_process_log_view(GtkWidget *,main_window *widgets){ -// log_window *window = yon_log_window_new(); -// dictionary *dict=NULL; -// yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); -// yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); -// g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),dict); -// gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); -// gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); -// yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,INSTALL_LOG_LABEL,icon_path,"log_viewer"); -// window->command = yon_char_new(short_log_path); -// gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); -// } - -// void on_summary_log_view(GtkWidget *,main_window *widgets){ -// log_window *window = yon_log_window_new(); -// dictionary *dict=NULL; -// yon_dictionary_add_or_create_if_exists_with_data(dict,"widgets",widgets); -// yon_dictionary_add_or_create_if_exists_with_data(dict,"window",window); -// g_signal_connect(G_OBJECT(window->Window),"destroy",G_CALLBACK(on_log_closed),dict); -// gtk_widget_set_sensitive(widgets->ReadFullLogButton,0); -// gtk_widget_set_sensitive(widgets->ReadShortLogButton,0); -// yon_gtk_window_setup(GTK_WINDOW(window->Window),NULL,PROGRESS_LOG_LABEL,icon_path,"log_viewer"); -// window->command = yon_char_new(full_log_path); -// gdk_threads_add_timeout(500,(GSourceFunc)yon_read_log,window); -// -// } - // void on_locale_changed(GtkWidget *,main_window *){ // // } @@ -1145,242 +220,6 @@ void yon_switch_page_render(main_window *widgets){ // // } -// void yon_set_max_size_from_partition(GtkTreeView *table, GtkSpinButton *spin_size, GtkComboBox *size_type){ -// GtkTreeModel *model; -// GtkTreeIter iter; -// char *selected_size=NULL; -// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(table),&model,&iter)){ -// gtk_tree_model_get(model,&iter,2,&selected_size,-1); -// if (yon_char_is_empty(selected_size)) -// gtk_tree_model_get(model,&iter,1,&selected_size,-1); -// if (!yon_char_is_empty(selected_size)){ -// int size = gtk_combo_box_get_active(size_type); -// double cur_size = atof(selected_size); -// char cur_size_letter = selected_size[strlen(selected_size)-1]; -// int cur_size_type=0; -// switch (cur_size_letter){ -// case 'M': -// cur_size_type=0; -// break; -// case 'G': -// cur_size_type=1; -// break; -// case 'T': -// cur_size_type=2; -// break; -// } -// if (size-cur_size_type>0){ -// for (int i=0;iInstallationNearSysSectionTree) -// yon_set_max_size_from_partition(GTK_TREE_VIEW(widgets->InstallationNearSysSectionTree),GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),GTK_COMBO_BOX(widgets->InstallationNearSizeTypeSpin)); -// -// } - -// void on_separate_installation_changed(GtkWidget *self, main_window *widgets){ -// -// gtk_list_store_clear(widgets->PartitionsList); -// GtkTreeIter iter; -// GtkTreeModel *model; -// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(self)),&model,&iter)){ -// gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SeparateUserDevicesTree)),&iter); -// char *disk_path=""; -// gtk_tree_model_get(model,&iter,0,&disk_path,-1); -// int size; -// config_str parsed; -// parsed = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); -// char *string = yon_char_parsed_to_string(parsed,size,""); -// struct json_object *root; -// struct json_object *blockdevices; -// root = json_tokener_parse(string); -// json_object_object_get_ex(root, "blockdevices", &blockdevices); -// for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { -// struct json_object *device = json_object_array_get_idx(blockdevices, i); -// struct json_object *type, *path, *size, *model, *fstype, *fsused; -// -// json_object_object_get_ex(device, "type", &type); -// if (strcmp("part",json_object_get_string(type))) -// continue; -// json_object_object_get_ex(device, "path", &path); -// if (!strstr(json_object_get_string(path),disk_path)){ -// continue; -// } -// json_object_object_get_ex(device, "size", &size); -// json_object_object_get_ex(device, "model", &model); -// json_object_object_get_ex(device, "fstype", &fstype); -// json_object_object_get_ex(device, "fsused", &fsused); -// -// double free_space=0; -// char *free_space_string=""; -// if (size&&fsused){ -// char *fsused_str = (char*)json_object_get_string(fsused); -// double fsused_kbytes = atof(fsused_str); -// for (int i=0;i1024;sz=sz+1){ -// free_space=free_space/1024; -// } -// if (sz==-1) { -// sz=0; -// free_space=free_space/1024; -// } -// free_space_string = yon_char_append(yon_char_from_double(free_space)," "); -// free_space_string[strlen(free_space_string)-1]=*(yon_size_get_mod(sz)); -// } -// gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); -// gtk_list_store_append(widgets->PartitionsList,&iter); -// gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),-1); -// } -// yon_char_parsed_free(parsed,size); -// } -// } - -// void on_near_installation_device_changed(GtkWidget *self, main_window *widgets){ -// gtk_list_store_clear(widgets->PartitionsList); -// GtkTreeIter iter; -// GtkTreeModel *model; -// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(self)),&model,&iter)){ -// char *disk_path=""; -// gtk_tree_model_get(model,&iter,0,&disk_path,-1); -// int size; -// config_str parsed; -// parsed = yon_config_load((get_parts_and_devices_command),&size); -// char *string = yon_char_parsed_to_string(parsed,size,""); -// struct json_object *root; -// struct json_object *blockdevices; -// root = json_tokener_parse(string); -// json_object_object_get_ex(root, "blockdevices", &blockdevices); -// for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { -// struct json_object *device = json_object_array_get_idx(blockdevices, i); -// struct json_object *type, *path, *size, *model, *fstype, *fsused, *label; -// -// json_object_object_get_ex(device, "type", &type); -// if (strcmp("part",json_object_get_string(type))) -// continue; -// json_object_object_get_ex(device, "path", &path); -// if (!strstr(json_object_get_string(path),disk_path)){ -// continue; -// } -// json_object_object_get_ex(device, "size", &size); -// json_object_object_get_ex(device, "model", &model); -// json_object_object_get_ex(device, "label", &label); -// json_object_object_get_ex(device, "fstype", &fstype); -// json_object_object_get_ex(device, "fsused", &fsused); -// -// double free_space=0; -// char *free_space_string=""; -// if (size&&fsused){ -// char *fsused_str = (char*)json_object_get_string(fsused); -// double fsused_kbytes = atof(fsused_str); -// for (int i=0;i1024;sz=sz+1){ -// free_space=free_space/1024; -// } -// if (sz==-1) { -// sz=0; -// free_space=free_space/1024; -// } -// free_space_string = yon_char_append(yon_char_from_double(free_space)," "); -// free_space_string[strlen(free_space_string)-1]=*(yon_size_get_mod(sz)); -// } -// // gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin),0.0); -// gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->InstallationNearSizeSpin)),0.0); -// gtk_list_store_append(widgets->PartitionsList,&iter); -// gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(size),2,free_space_string,3,json_object_get_string(fstype),4,json_object_get_string(label),-1); -// } -// yon_char_parsed_free(parsed,size); -// } -// } - -// void on_same_installation_device_changed(GtkWidget *, main_window *widgets){ -// gtk_list_store_clear(widgets->PartitionsList); -// GtkTreeIter iter; -// GtkTreeModel *model; -// if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SamePlaceDeviceTree)),&model,&iter)){ -// char *disk_path=""; -// gtk_tree_model_get(model,&iter,0,&disk_path,-1); -// int size; -// config_str parsed; -// parsed = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); -// char *string = yon_char_parsed_to_string(parsed,size,""); -// struct json_object *root; -// struct json_object *blockdevices; -// root = json_tokener_parse(string); -// json_object_object_get_ex(root, "blockdevices", &blockdevices); -// for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { -// struct json_object *device = json_object_array_get_idx(blockdevices, i); -// struct json_object *type, *path, *size, *model, *vendor, *serial; -// -// json_object_object_get_ex(device, "type", &type); -// if (strcmp("part",json_object_get_string(type))) -// continue; -// json_object_object_get_ex(device, "path", &path); -// if (!strstr(json_object_get_string(path),disk_path)){ -// continue; -// } -// json_object_object_get_ex(device, "size", &size); -// json_object_object_get_ex(device, "model", &model); -// json_object_object_get_ex(device, "vendor", &vendor); -// json_object_object_get_ex(device, "serial", &serial); -// -// gtk_list_store_append(widgets->PartitionsList,&iter); -// gtk_list_store_set(widgets->PartitionsList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); -// } -// yon_char_parsed_free(parsed,size); -// } -// } - -void on_page_next_clicked(GtkWidget *, main_window *widgets){ - enum YON_PAGES page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook)); - page = yon_page_get_next(widgets,page); - if ((int)page!=-1){ - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page); - } - yon_page_update(widgets); -} - -void on_page_prev_clicked(GtkWidget *, main_window *widgets){ - enum YON_PAGES page = gtk_notebook_get_current_page(GTK_NOTEBOOK(widgets->Notebook)); - page = yon_page_get_prev(page); - if ((int)page!=-1){ - gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),page); - } - yon_page_update(widgets); -} - void on_gparted_open(){ yon_launch_app_with_arguments(open_gparted_command,NULL); } @@ -1405,7 +244,7 @@ void on_exit_accepted(main_window *widgets){ g_mutex_unlock(&main_config.install_mutex); } main_config.exit_accepted=1; - g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event"); + // g_signal_emit_by_name(G_OBJECT(widgets->MainWindow),"delete-event"); while(gtk_events_pending()) gtk_main_iteration(); gtk_widget_destroy(widgets->MainWindow); } @@ -1418,10 +257,11 @@ gboolean on_yon_exit(GtkWidget *,GdkEvent*, main_window *widgets){ 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; } return 0; @@ -1447,6 +287,9 @@ main_window *yon_main_window_complete(){ widgets->MainWindow=yon_gtk_builder_get_widget(builder,"MainWindow"); widgets->WelcomeToggle=yon_gtk_builder_get_widget(builder,"WelcomeToggle"); widgets->LicenceToggle=yon_gtk_builder_get_widget(builder,"LicenceToggle"); + widgets->StartScenarioButton=yon_gtk_builder_get_widget(builder,"StartScenarioButton"); + widgets->SourceButton=yon_gtk_builder_get_widget(builder,"SourceButton"); + widgets->SkipInstallationButton=yon_gtk_builder_get_widget(builder,"SkipInstallationButton"); widgets->LocationToggle=yon_gtk_builder_get_widget(builder,"LocationToggle"); widgets->KeyboardToggle=yon_gtk_builder_get_widget(builder,"KeyboardToggle"); widgets->SectionsToggle=yon_gtk_builder_get_widget(builder,"SectionsToggle"); @@ -1681,31 +524,32 @@ main_window *yon_main_window_complete(){ // g_signal_connect(G_OBJECT(widgets->AddButton),"clicked",G_CALLBACK(on_keyboard_clicked),widgets); // g_signal_connect(G_OBJECT(widgets->RemoveButton),"clicked",G_CALLBACK(on_keyboard_removed),widgets); - // g_signal_connect(G_OBJECT(widgets->GrubInstallDevicesTree),"cursor-changed",G_CALLBACK(on_separate_installation_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->GrubUpdateDevicesTree),"cursor-changed",G_CALLBACK(on_separate_installation_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->InstallationNearSysDevicesTree),"cursor-changed",G_CALLBACK(on_near_installation_device_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->SamePlaceDeviceTree),"cursor-changed",G_CALLBACK(on_near_installation_device_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->UserdataDevicesTree),"cursor-changed",G_CALLBACK(on_near_installation_device_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->OSDevicesTree),"cursor-changed",G_CALLBACK(on_near_installation_device_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->SeparateDevicesTree),"cursor-changed",G_CALLBACK(on_separate_installation_changed),widgets); + g_signal_connect(G_OBJECT(widgets->GrubInstallDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->GrubUpdateDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->InstallationNearSysDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->SamePlaceDeviceTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->UserdataDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->OSDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); + g_signal_connect(G_OBJECT(widgets->SeparateDevicesTree),"cursor-changed",G_CALLBACK(on_device_selection_changed),widgets); g_signal_connect(G_OBJECT(widgets->ConfigurationModeMenuItem),"toggled",G_CALLBACK(on_configuration_mode_switch),widgets); // g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),widgets); // g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),widgets); - // g_signal_connect(G_OBJECT(widgets->SamePlacePartTree),"cursor-changed",G_CALLBACK(on_partition_changed),widgets); - // g_signal_connect(G_OBJECT(widgets->InstallationNearSysSectionTree),"cursor-changed",G_CALLBACK(on_partition_changed),widgets); + g_signal_connect(G_OBJECT(widgets->SamePlacePartTree),"cursor-changed",G_CALLBACK(on_partition_changed),widgets); + g_signal_connect(G_OBJECT(widgets->InstallationNearSysSectionTree),"cursor-changed",G_CALLBACK(on_partition_changed),widgets); + g_signal_connect(G_OBJECT(widgets->InstallationNearSizeTypeSpin),"changed",G_CALLBACK(on_partition_changed),widgets); // gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LayoutsFilter),3); // g_signal_connect(G_OBJECT(widgets->LanguageCombo),"changed",G_CALLBACK(on_locale_changed),widgets); // g_signal_connect(G_OBJECT(widgets->AdditionalSoftwareCell),"toggled",G_CALLBACK(on_additional_software_toggled),widgets); - // g_signal_connect(G_OBJECT(widgets->ManualLayoutRadio),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),gtk_widget_get_parent(gtk_widget_get_parent(widgets->AddButton))); + g_signal_connect(G_OBJECT(widgets->ManualLayoutRadio),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),gtk_widget_get_parent(gtk_widget_get_parent(widgets->AddButton))); - // g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->HotnameEntry); + g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button_inversed),widgets->HotnameEntry); - // g_signal_connect(G_OBJECT(widgets->NextInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->NextInstallationFilesystemTypeCombo); - // g_signal_connect(G_OBJECT(widgets->SameInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->SameInstallationFilesystemTypeCombo); + g_signal_connect(G_OBJECT(widgets->NextInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->NextInstallationFilesystemTypeCombo); + g_signal_connect(G_OBJECT(widgets->SameInstallationFormatCheck),"toggled",G_CALLBACK(yon_gtk_widget_set_sensitive_from_toggle_button),widgets->SameInstallationFilesystemTypeCombo); // g_signal_connect(G_OBJECT(widgets->HostnameSensitiveCheck),"toggled",G_CALLBACK(on_autohostname_sensitiveness_check),widgets); // g_signal_connect(G_OBJECT(widgets->AutoHostnameCheck),"toggled",G_CALLBACK(on_autohostname_check),widgets); // g_signal_connect(G_OBJECT(widgets->HotnameEntry),"changed",G_CALLBACK(on_hostname_entry_changed),widgets); @@ -1714,174 +558,176 @@ main_window *yon_main_window_complete(){ // g_signal_connect(G_OBJECT(widgets->AdminPasswordCombo),"changed",G_CALLBACK(yon_password_combo_set_sensitive),widgets); // g_signal_connect(G_OBJECT(widgets->RootPasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); // g_signal_connect(G_OBJECT(widgets->PasswordSensitiveCheck),"toggled",G_CALLBACK(yon_password_set_sensitive_from_toggle),widgets); - yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->PasswordEntry)); - yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->AdminPasswordEntry)); + { + yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->PasswordEntry)); + yon_gtk_entry_set_password_visibility_icon(GTK_ENTRY(widgets->AdminPasswordEntry)); - if (main_config.lock_load_global == 1){ - gtk_widget_set_sensitive(widgets->LoadGlobalConfigurationMenuItem,0); - } - if (main_config.lock_save_global == 1){ - gtk_widget_set_sensitive(widgets->SaveGlobalConfigurationMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); - } - if (main_config.lock_save_local == 1){ - gtk_widget_set_sensitive(widgets->SaveLocalConfigurationMenuItem,0); - gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); - } - if (getuid()){ - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets->ConfigurationModeMenuItem),1); - } + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalConfigurationMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + if (main_config.lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalConfigurationMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveGlobalLocalConfigurationMenuItem,0); + } + if (getuid()){ + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widgets->ConfigurationModeMenuItem),1); + } - gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter),0); - gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); + gtk_tree_model_filter_set_visible_column(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter),0); + gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(widgets->LanguagesFilter)); - gtk_window_set_title(GTK_WINDOW(widgets->MainWindow),TITLE_LABEL); - gtk_window_set_icon_name(GTK_WINDOW(widgets->MainWindow),icon_path); + gtk_window_set_title(GTK_WINDOW(widgets->MainWindow),TITLE_LABEL); + gtk_window_set_icon_name(GTK_WINDOW(widgets->MainWindow),icon_path); - int size; - config_str parsed = NULL; - parsed = yon_file_open(licence_path,&size); - if (size){ - char *licence = yon_char_parsed_to_string(parsed,size,""); - gtk_label_set_text(GTK_LABEL(widgets->LicenceLabel),licence); - free(licence); - yon_char_parsed_free(parsed,size); - } + int size; + config_str parsed = NULL; + parsed = yon_file_open(licence_path,&size); + if (size){ + char *licence = yon_char_parsed_to_string(parsed,size,""); + gtk_label_set_text(GTK_LABEL(widgets->LicenceLabel),licence); + free(licence); + yon_char_parsed_free(parsed,size); + } - config_str slides = yon_char_parsed_new(&size,slide_repeat_path); - widgets->regions_original = gdk_pixbuf_new_from_resource(regions_path,NULL); - widgets->keyboard_original = gdk_pixbuf_new_from_resource(keyboard_path,NULL); - widgets->slides_original = NULL; - widgets->slides_original = g_list_prepend(widgets->slides_original,gdk_pixbuf_new_from_resource(slide_0_path,NULL)); - for (int i=1;islides_original = g_list_prepend(widgets->slides_original,gdk_pixbuf_new_from_resource(slides[i-1],NULL)); - } - widgets->slides_original = g_list_reverse(widgets->slides_original); - yon_char_parsed_free(slides,size); - int width = gdk_pixbuf_get_width(widgets->regions_original); - int height = gdk_pixbuf_get_height(widgets->regions_original); - widgets->region_height_mult = (float)height/width; - GdkPixbuf *pix = gdk_pixbuf_scale_simple(widgets->regions_original,600,400,GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->RegionImage),pix); - g_object_unref(pix); - pix = gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),pix); - g_object_unref(pix); - pix = gdk_pixbuf_scale_simple((GdkPixbuf*)g_list_nth_data(widgets->slides_original,0),600,400,GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),pix); - g_object_unref(pix); - - int langsize; - config_str lang = default_langs(&langsize); - - GtkTreeIter iter; - gtk_list_store_clear(widgets->LanguagesList); - parsed = yon_file_open(languages_path,&size); - for (int i=0;iLanguagesList,&iter); - gtk_list_store_set(widgets->LanguagesList,&iter,0,0,1,_(cur[1]),2,cur[0],-1); + config_str slides = yon_char_parsed_new(&size,slide_repeat_path); + widgets->regions_original = gdk_pixbuf_new_from_resource(regions_path,NULL); + widgets->keyboard_original = gdk_pixbuf_new_from_resource(keyboard_path,NULL); + widgets->slides_original = NULL; + widgets->slides_original = g_list_prepend(widgets->slides_original,gdk_pixbuf_new_from_resource(slide_0_path,NULL)); + for (int i=1;islides_original = g_list_prepend(widgets->slides_original,gdk_pixbuf_new_from_resource(slides[i-1],NULL)); } - yon_char_parsed_free(cur,cur_size); - } - yon_char_parsed_free(parsed,size); - if (lang) - yon_char_parsed_free(lang,langsize); - - parsed = yon_dir_get_contents(zone_path,&size); - for (int i=0;iRegionCombo),parsed[i],_(parsed[i])); + widgets->slides_original = g_list_reverse(widgets->slides_original); + yon_char_parsed_free(slides,size); + int width = gdk_pixbuf_get_width(widgets->regions_original); + int height = gdk_pixbuf_get_height(widgets->regions_original); + widgets->region_height_mult = (float)height/width; + GdkPixbuf *pix = gdk_pixbuf_scale_simple(widgets->regions_original,600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->RegionImage),pix); + g_object_unref(pix); + pix = gdk_pixbuf_scale_simple(widgets->keyboard_original,600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->KeyboardImage),pix); + g_object_unref(pix); + pix = gdk_pixbuf_scale_simple((GdkPixbuf*)g_list_nth_data(widgets->slides_original,0),600,400,GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(widgets->SlidesImage),pix); + g_object_unref(pix); + + int langsize; + config_str lang = default_langs(&langsize); + + GtkTreeIter iter; + gtk_list_store_clear(widgets->LanguagesList); + parsed = yon_file_open(languages_path,&size); + for (int i=0;iLanguagesList,&iter); + gtk_list_store_set(widgets->LanguagesList,&iter,0,0,1,_(cur[1]),2,cur[0],-1); } - free(path); + yon_char_parsed_free(cur,cur_size); } - } - gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->RegionCombo),0); - yon_char_parsed_free(parsed,size); - parsed = yon_config_load(yon_debug_output("%s\n",get_layouts_command),&size); - GtkTreeIter itar; - for (int i=0;iLayoutList,&iter,NULL); - gtk_tree_store_set(widgets->LayoutList,&iter,0,layout[0],1,_(layout[1]),2,1,-1); - yon_char_parsed_free(layout,layout_size); - char *command = get_layouts_local_command(layout_id); - config_str layout_local = yon_config_load(yon_debug_output("%s\n",command),&layout_size); - free(command); - free(layout_id); - for (int j=0;jLayoutList,&itar,&iter); - gtk_tree_store_set(widgets->LayoutList,&itar,0,layouts_parsed[0],1,_(layouts_parsed[1]),2,1,3,0,-1); - yon_char_parsed_free(layouts_parsed,parsed_size); + yon_char_parsed_free(parsed,size); + if (lang) + yon_char_parsed_free(lang,langsize); + + parsed = yon_dir_get_contents(zone_path,&size); + for (int i=0;iRegionCombo),parsed[i],_(parsed[i])); } + free(path); } - if (layout_size==-1) { - gtk_tree_store_set(widgets->LayoutList,&iter,2,1,-1); - } - yon_char_parsed_free(layout_local,layout_size); } - } - yon_char_parsed_free(parsed,size); - { - parsed = yon_config_load(yon_debug_output("%s\n",get_devices_command),&size); - char *string = yon_char_parsed_to_string(parsed,size,""); - struct json_object *root; - struct json_object *blockdevices; - root = json_tokener_parse(string); - free(string); - json_object_object_get_ex(root, "blockdevices", &blockdevices); - for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { - struct json_object *device = json_object_array_get_idx(blockdevices, i); - struct json_object *path, *size, *model, *vendor, *serial; - - json_object_object_get_ex(device, "path", &path); - json_object_object_get_ex(device, "size", &size); - json_object_object_get_ex(device, "model", &model); - json_object_object_get_ex(device, "vendor", &vendor); - json_object_object_get_ex(device, "serial", &serial); - - gtk_list_store_append(widgets->DevicesList,&iter); - gtk_list_store_set(widgets->DevicesList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); - + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->RegionCombo),0); + yon_char_parsed_free(parsed,size); + parsed = yon_config_load(yon_debug_output("%s\n",get_layouts_command),&size); + GtkTreeIter itar; + for (int i=0;iLayoutList,&iter,NULL); + gtk_tree_store_set(widgets->LayoutList,&iter,0,layout[0],1,_(layout[1]),2,1,-1); + yon_char_parsed_free(layout,layout_size); + char *command = get_layouts_local_command(layout_id); + config_str layout_local = yon_config_load(yon_debug_output("%s\n",command),&layout_size); + free(command); + free(layout_id); + for (int j=0;jLayoutList,&itar,&iter); + gtk_tree_store_set(widgets->LayoutList,&itar,0,layouts_parsed[0],1,_(layouts_parsed[1]),2,1,3,0,-1); + yon_char_parsed_free(layouts_parsed,parsed_size); + } + } + if (layout_size==-1) { + gtk_tree_store_set(widgets->LayoutList,&iter,2,1,-1); + } + yon_char_parsed_free(layout_local,layout_size); + } } yon_char_parsed_free(parsed,size); - } - - parsed = yon_resource_open_file(additional_software_path,&size); - for (int i=1;iAdditionalSoftwareList,&iter); - gtk_list_store_set(widgets->AdditionalSoftwareList,&iter,0,1,1,module_parsed[0],3,module_parsed[1],-1); //2,module_parsed[2] - yon_char_parsed_free(module_parsed,module_size); + { + parsed = yon_config_load(yon_debug_output("%s\n",get_devices_command),&size); + char *string = yon_char_parsed_to_string(parsed,size,""); + struct json_object *root; + struct json_object *blockdevices; + root = json_tokener_parse(string); + free(string); + json_object_object_get_ex(root, "blockdevices", &blockdevices); + for (long unsigned int i = 0; i < json_object_array_length(blockdevices); i++) { + struct json_object *device = json_object_array_get_idx(blockdevices, i); + struct json_object *path, *size, *model, *vendor, *serial; + + json_object_object_get_ex(device, "path", &path); + json_object_object_get_ex(device, "size", &size); + json_object_object_get_ex(device, "model", &model); + json_object_object_get_ex(device, "vendor", &vendor); + json_object_object_get_ex(device, "serial", &serial); + + gtk_list_store_append(widgets->DevicesList,&iter); + gtk_list_store_set(widgets->DevicesList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); + + } + yon_char_parsed_free(parsed,size); } - } - if (size) yon_char_parsed_free(parsed,size); + + parsed = yon_resource_open_file(additional_software_path,&size); + for (int i=1;iAdditionalSoftwareList,&iter); + gtk_list_store_set(widgets->AdditionalSoftwareList,&iter,0,1,1,module_parsed[0],3,module_parsed[1],-1); //2,module_parsed[2] + yon_char_parsed_free(module_parsed,module_size); + } + } + if (size) yon_char_parsed_free(parsed,size); - config_str models = yon_config_load(yon_debug_output("%s\n",get_models_command),&size); - for (int i=0;iKeyboardModelCombo),models[i],_(models[i+1])); + config_str models = yon_config_load(yon_debug_output("%s\n",get_models_command),&size); + for (int i=0;iKeyboardModelCombo),models[i],_(models[i+1])); + } + if (size) yon_char_parsed_free(models,size); + gtk_builder_connect_signals(builder,NULL); + // yon_load_proceed(YON_CONFIG_DEFAULT); + // yon_interface_update(widgets); } - if (size) yon_char_parsed_free(models,size); - gtk_builder_connect_signals(builder,NULL); - // yon_load_proceed(YON_CONFIG_DEFAULT); - // yon_interface_update(widgets); return widgets; } @@ -1901,6 +747,11 @@ int main(int argc, char *argv[]){ yon_window_config_load(path); main_config.launch_arguments=yon_char_parsed_copy(argv,argc); main_config.launch_size=argc; + GtkCssProvider *css=gtk_css_provider_new(); + gtk_css_provider_load_from_resource(css,CssPath); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), + GTK_STYLE_PROVIDER(css), + -1); if (getuid()!=0){ textdomain(template_ui_LocaleName); yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 7aef6a5..c781494 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -65,6 +65,8 @@ "/com/ublinux/images/slide-12.png", \ NULL +#define encrypt_domain_password_command(target) yon_char_unite("echo '",target,"' | base64",NULL) + #define get_ntp_default_command "ubconfig --default get [network] NTPSERVERS_DEFAULT" #define get_ntp_ru_command "ubconfig --default get [network] NTPSERVERS_RU" @@ -75,7 +77,7 @@ NULL #define get_layouts_command "xkbcli list --load-exotic | awk \"layout && /description:/ {match(\\$0,/: *(.*)/,matches);description=matches[1];printf \\\"%s|%s\\n\\\",layout,description;layout=\\\"\\\"} /layout:/ {match(\\$0, /: *'([^']+)'/,matches);l=matches[1];if (layouts[l]) next;layout=layouts[l]=l}\" | sort -u" #define get_layouts_local_command(layout) yon_char_unite("xkbcli list --load-exotic | awk -v layout=\"",layout,"\" \"BEGIN {layout_pattern = sprintf(\\\"^ *- *layout: *'%s'\\\",layout);matched=0} matched && /variant:/ {match(\\$0, /: *'([^']+)'/, matches);variant = matches[1]} matched && /description:/ {match(\\$0, /: *(.+)/, matches);description = matches[1]} matched && /^ *-/{matched=0; if (variant) printf \\\"%s|%s\\n\\\",variant,description} \\$0 ~ layout_pattern {matched=1;variant=\\\"\\\";description=\\\"\\\";next}\" | sort -u",NULL) #define get_devices_command "lsblk --noheadings --nodeps -Jo PATH,SIZE,MODEL,VENDOR,SERIAL --exclude 7,253" -#define get_parts_and_devices_command "lsblk --noheadings -Jo TYPE,PATH,SIZE,FSTYPE,LABEL,PARTLABEL,MOUNTPOINT,FSUSED,FSUSE% --exclude 7,253" +#define get_parts_and_devices_command "lsblk --noheadings --bytes -o TYPE,PATH,SIZE,FSTYPE,LABEL,PARTLABEL,MOUNTPOINT,FSUSED,FSUSE% --exclude 7,253 |awk '{print ($1\";\"$2\";\"$3\";\"$4\";\"$5\";\"$6\";\"$7\";\"$8\";\"$9)}'" #define AUTOINSTALL_TYPE_INSTALL "AUTOINSTALL[install_type]" #define AUTOINSTALL_TYPE_INSTALL_command "ubconfig --source global get [autoinstall] AUTOINSTALL[install_type]" @@ -142,6 +144,10 @@ NULL #define device_typevfs_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[device_typevfs]" #define NTPSERVERS_parameter "AOUTINSTALL[ubconfig set [network] NTPSERVERS]" #define NTPSERVERS_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[ubconfig set [network] NTPSERVERS]" +#define DOMAIN_parameter "AOUTINSTALL[ubconfig set [network] DOMAIN]" +#define DOMAIN_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[ubconfig set [network] DOMAIN]" +#define DOMAIN_admanger_parameter "AOUTINSTALL[ubconfig set [network] DOMAIN[admanger]]" +#define DOMAIN_admanger_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[ubconfig set [network] DOMAIN[admanger]]" #define save_config_command(parameters) yon_char_unite("ubconfig --target system set [autoinstall] AUTOINSTALL[log]=yes ",parameters, "; nice ubinstall2 --debug autoinstall", NULL) @@ -274,6 +280,10 @@ typedef struct { GtkWidget *MainWindow; + GtkWidget *StartScenarioButton; + GtkWidget *SourceButton; + GtkWidget *SkipInstallationButton; + GtkWidget *StatusBox; GtkWidget *WelcomeToggle; GtkWidget *LicenceToggle; @@ -466,6 +476,11 @@ typedef struct { GtkWidget *AdvancedSwapFixedSwitch; GtkWidget *AdvancedSwapFixedSizeSwitch; dictionary *advanced_sections; + + GFile *install_progress_file; + GFileMonitor *install_progress_monitor; + GFile *install_info_file; + GFileMonitor *install_info_monitor; } main_window; typedef struct { @@ -577,7 +592,7 @@ void on_password_accept(GtkWidget *self, dictionary *dict); void yon_interface_update(main_window *widgets); void on_summary_log_view(GtkWidget *,main_window *widgets); -void on_near_installation_device_changed(GtkWidget *self, main_window *widgets); +void on_device_selection_changed(GtkWidget *self, main_window *widgets); void on_toggle_button_switch_on(GtkWidget *, GtkToggleButton *toggle); @@ -602,7 +617,7 @@ void on_language_window_accept(GtkWidget *,dictionary *dict); void on_keyboard_removed(GtkWidget *, main_window *widgets); void on_exit_accepted(main_window *widgets); void on_gparted_open(); -void on_same_installation_device_changed(GtkWidget *, main_window *widgets); +// void on_same_installation_device_changed(GtkWidget *, main_window *widgets); void on_separate_installation_changed(GtkWidget *self, main_window *widgets); void on_partition_changed(GtkWidget *self, main_window *widgets); void yon_set_max_size_from_partition(GtkTreeView *table, GtkSpinButton *spin_size, GtkComboBox *size_type); @@ -618,11 +633,13 @@ void on_log_closed(GtkWidget *, dictionary *dict); void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets); gboolean yon_installation_progress_update(void *data); void *on_config_save(void *data); +void *on_setup_system_configuration(void * data); gboolean on_image_slide(void *data); void on_region_resized(GtkWidget *,main_window *widgets); int yon_image_resize_from_container(GtkImage *target, GdkPixbuf *pixbuf_unscaled); void on_configuration_mode_switch(GtkWidget *self,main_window *widgets); double yon_size_long_convert_automatic(unsigned long bytes, char *size); +double yon_size_long_convert_to_mod(double size, char mod); void on_root_get_root(char *argline); void on_config_custom_save(GtkWidget *, main_window *widgets); void on_config_global_save(GtkWidget *,main_window *widgets); @@ -668,4 +685,6 @@ void on_connection_add(main_window *widgets); void on_ntp_sync(GtkWidget *, main_window *widgets); int yon_advanced_sections_save(dictionary *dict); void yon_configuration_mode_check(main_window *widgets); -void on_configuration_mode_switch(GtkWidget *self,main_window *widgets); \ No newline at end of file +void on_configuration_mode_switch(GtkWidget *self,main_window *widgets); +void *_yon_installation_start(main_window *widgets); +int yon_installation_start(main_window *widgets); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 114ba74..e0930c3 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -100,7 +100,6 @@ #define PASSWORD_SHORT_LABEL(min_size_char) yon_char_unite(_("Password must be at least")," ", min_size_char," ",_("characters")) #define RESTART_LABEL _("Restart PC") -#define EXIT_LABEL _("Exit") #define CHOOSE_LABEL _("Choose file system type for the section:") #define SECTION_NAME_LABEL _("Section name:") #define FORMAT_LABEL _("Format") @@ -185,4 +184,5 @@ #define WARNING_TEXT_LABEL _("Are you sure want to exit and\ninterrupt installation process?") #define WARNING_REBOOT_TEXT_LABEL _("Are you sure want to reboot system?") -#define DEFAULT_BOOTLOAD_MENU_ITEM_LABEL _("Default (Use last succeeded)") \ No newline at end of file +#define DEFAULT_BOOTLOAD_MENU_ITEM_LABEL _("Default (Use last succeeded)") +#define ENCRYPT_ERROR_LABEL _("Password encryption error") \ No newline at end of file diff --git a/ubinstall-gtk.css b/ubinstall-gtk.css index 9b28bc6..0dba73b 100644 --- a/ubinstall-gtk.css +++ b/ubinstall-gtk.css @@ -16,6 +16,14 @@ background:transparent; color: @theme_text_color; } +.bggrey{ + border-radius:5px; + border-color:@theme_text_color; + border-style:solid; + border-width:0.3px; + box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.15); +} + .inherited>* { border:none; background:inherit; diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 821b93c..ed605d0 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -27,6 +27,11 @@ + + 60 + 1 + 10 + @@ -95,18 +100,28 @@ + + 999999 + 16 + 1 + 10 + - + - + - + - + - + + + + + @@ -121,28 +136,15 @@ - + True False - - - - - - 999999 - 16 - 1 - 10 - - - 60 - 1 - 10 + com.ublinux.libublsettingsui-gtk3.properties-symbolic - + True False - com.ublinux.libublsettingsui-gtk3.properties-symbolic + com.ublinux.libublsettingsui-gtk3.edit-symbolic True @@ -209,6 +211,11 @@ False com.ublinux.libublsettingsui-gtk3.properties-symbolic + + True + False + com.ublinux.libublsettingsui-gtk3.edit-symbolic + True False @@ -2801,67 +2808,6 @@ and help you install UBLinux on your computer 5 - - - True - False - 5 - - - True - True - False - True - - - True - False - Host name: - 0 - - - - - False - True - 0 - - - - - True - False - True - auto - - - True - True - 2 - - - - - Automatically - True - False - True - False - True - - - False - True - 3 - - - - - False - True - 6 - - False @@ -3097,7 +3043,7 @@ and help you install UBLinux on your computer True True - adjustment2 + BootloaderTimer False @@ -3584,6 +3530,67 @@ and help you install UBLinux on your computer 1 + + + True + False + 5 + + + True + True + False + True + + + True + False + Host name: + 0 + + + + + False + True + 0 + + + + + True + False + True + auto + + + True + True + 2 + + + + + Automatically + True + False + True + False + True + + + False + True + 3 + + + + + False + True + 2 + + True @@ -3627,7 +3634,7 @@ and help you install UBLinux on your computer False True - 2 + 3 @@ -4917,7 +4924,7 @@ installed. False True 0,0 - adjustment1 + PartitionSize 1 @@ -5148,6 +5155,10 @@ installed. True False + center + center + 20 + 20 vertical 5 @@ -5495,120 +5506,226 @@ installed. True False - 5 + vertical - + True - True - False - True - + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 5 - + True False - Choose file system type for the section: + 5 + + + True + False + Partition: + 0 + + + False + True + 0 + + + + + True + False + label + 0 + + + False + True + 1 + + + + False + True + 0 + - - - False - True - 0 - - - - - True - False - True - 1 - - ext3 - ext4 - fat16 - fat32 - exfat - riserfs - udf - xfs - zfs - - - - - True - True - 2 - - - - - Format - True - False - True - False - True - - - - False - True - 3 - - - - - False - True - 2 - - - - - True - False - 5 - - - True - True - False - True - - + True False - Section name: + 5 + + + True + True + + + False + True + 0 + + + + + True + False + Format + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + vertical + 5 + + + True + False + + + False + True + 0 + + + + + True + False + none + True + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Partition label: + + + False + True + 3 + + + + + True + False + True + + + + True + True + 4 + + + + + True + False + File system type: + + + False + True + 5 + + + + + True + False + False + 1 + + ext3 + ext4 + fat16 + fat32 + exfat + riserfs + udf + xfs + zfs + + + + + True + True + 6 + + + + + False + True + 0 + + + + + + + False + True + 1 + + + + False + True + 2 + False True - 0 - - - - - True - False - True - - - - True - True 2 + False True - 3 + 4 @@ -5860,7 +5977,14 @@ separately into the selected partition. False 0 - No + No + RAID0 + RAID1 + DAID4 + RAID5 + RAID6 + LVM + LVM_DYNAMIC @@ -8058,6 +8182,365 @@ separately into the selected partition. 1 + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Partition: + 0 + + + False + True + 0 + + + + + True + False + label + 0 + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + True + + + False + True + 0 + + + + + True + False + Format + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + vertical + 5 + + + True + False + + + False + True + 0 + + + + + True + False + none + True + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Size: + + + False + True + 0 + + + + + True + True + PartitionSize + + + False + True + 1 + + + + + True + False + 1 + + Mb + Gb + Tb + + + + False + True + 2 + + + + + True + False + Partition mark: + + + False + True + 3 + + + + + True + True + + + False + True + 4 + + + + + True + False + File system type: + + + False + True + 5 + + + + + True + False + False + 1 + + ext3 + ext4 + fat16 + fat32 + exfat + riserfs + udf + xfs + zfs + + + + True + True + 6 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + File system mark: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + True + False + Encryption: + + + False + True + 2 + + + + + True + False + + + False + True + 3 + + + + + True + False + Encryption password: + + + False + True + 4 + + + + + True + True + + + False + True + 5 + + + + + True + True + True + image4 + + + + False + True + 6 + + + + + False + True + 1 + + + + + + + False + True + 1 + + + + + False + True + 2 + + + + + False + True + 2 + + + + + + False + True + 2 + + @@ -8426,6 +8909,369 @@ separately into the selected partition. 1 + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 5 + + + True + False + 5 + + + True + False + Partition: + 0 + + + False + True + 0 + + + + + True + False + label + 0 + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + True + + + False + True + 0 + + + + + True + False + Format + + + False + True + 1 + + + + + False + True + 1 + + + + + True + False + vertical + 5 + + + True + False + + + False + True + 0 + + + + + True + False + none + True + + + True + False + vertical + 5 + + + True + False + 5 + + + True + False + Size: + + + False + True + 0 + + + + + True + True + 16 + PartitionSize + 16 + + + False + True + 1 + + + + + True + False + 1 + + Mb + Gb + Tb + + + + False + True + 2 + + + + + True + False + Partition mark: + + + False + True + 3 + + + + + True + True + + + False + True + 4 + + + + + True + False + File system type: + + + False + True + 5 + + + + + True + False + False + 1 + + ext3 + ext4 + fat16 + fat32 + exfat + riserfs + udf + xfs + zfs + + + + True + True + 6 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + File system mark: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + True + False + Encryption: + + + False + True + 2 + + + + + True + False + + + False + True + 3 + + + + + True + False + Encryption password: + + + False + True + 4 + + + + + True + True + + + False + True + 5 + + + + + True + True + True + image10 + + + + False + True + 6 + + + + + False + True + 1 + + + + + + + False + True + 1 + + + + + False + True + 2 + + + + + False + True + 2 + + + + + + False + True + 2 + + @@ -8464,63 +9310,6 @@ separately into the selected partition. 0 - - - True - False - center - 5 - - - Cancel - True - False - True - True - image7 - - - False - True - 0 - - - - - Back - False - True - True - image8 - - - False - True - 1 - - - - - Next - True - True - True - image9 - - - False - True - 2 - - - - - False - True - end - 1 - - True @@ -8656,6 +9445,115 @@ separately into the selected partition. + + False + True + 1 + + + + + True + False + 5 + + + True + False + center + 5 + + + Cancel + True + False + True + True + image7 + + + False + True + 0 + + + + + Back + False + True + True + image8 + + + False + True + 1 + + + + + Next + True + True + True + image9 + + + False + True + 2 + + + + + False + True + end + 3 + + + + + Start installation scenario + True + True + True + + + False + True + 0 + + + + + Source + True + True + True + + + False + True + 1 + + + + + Skip installation + True + True + True + + + False + True + end + 2 + + + False True