From 80c5d6634bad86457a102764e0e8ace8efb191eb Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Tue, 14 Oct 2025 17:00:06 +0600 Subject: [PATCH] WIP advanced installation configuration --- locale/ubinstall-gtk_ru.po | 2 +- source/ubinstall-gtk-advanced.c | 168 +++++++++++++++++++++++++++----- source/ubinstall-gtk.c | 1 + source/ubinstall-gtk.h | 12 ++- ubinstall-gtk.glade | 10 +- 5 files changed, 166 insertions(+), 27 deletions(-) diff --git a/locale/ubinstall-gtk_ru.po b/locale/ubinstall-gtk_ru.po index 9af6a32..4843548 100644 --- a/locale/ubinstall-gtk_ru.po +++ b/locale/ubinstall-gtk_ru.po @@ -296,7 +296,7 @@ msgstr "Расширенный режим установки" msgid "" "Installing OS files, user data on different partitions, creating RAID, etc." msgstr "" -"Установка файлов ОС, пользовательских данныъ на разные разделы, создание " +"Установка файлов ОС, пользовательских данных на разные разделы, создание " "RAID и др." #: source/ubl-strings.h:77 diff --git a/source/ubinstall-gtk-advanced.c b/source/ubinstall-gtk-advanced.c index 839fd21..7307fae 100644 --- a/source/ubinstall-gtk-advanced.c +++ b/source/ubinstall-gtk-advanced.c @@ -13,6 +13,15 @@ advanced_section *yon_advanced_section_new(){ if (sections_size>=2) return NULL; advanced_section *section = malloc(sizeof(advanced_section)); memset(section,0,sizeof(advanced_section)); + if (!sections_size){ + section->sys_section=1; + section->user_section=1; + } else { + section->sys_section=0; + section->user_section=1; + sections[0]->sys_section=1; + sections[0]->user_section=0; + } return section; } @@ -28,7 +37,7 @@ void yon_advanced_section_remove_all(){ sections_size=0; } -void yon_advanced_section_remove(char *part){ +void yon_advanced_section_remove_by_name(char *part){ int pos = yon_advanced_section_get(part); switch(pos){ case 0: @@ -53,6 +62,41 @@ void yon_advanced_section_remove(char *part){ default: return; } } +void yon_advanced_section_remove(advanced_partition *part){ + int pos = yon_advanced_section_get_by_part(part); + switch(pos){ + case 0: + if (sections[0]){ + free(sections[0]); + if (sections[1]){ + sections[0]=sections[1]; + sections[1]=NULL; + } else { + sections[0]=NULL; + } + sections_size--; + } + break; + case 1: + if (sections[1]){ + free(sections[1]); + sections[1]=NULL; + sections_size--; + } + break; + default:return; + } +} + +int yon_advanced_section_get_by_part(advanced_partition *part){ + if (!part) return -1; + if (sections_size>0&§ions[0]->partition_widgets==part){ + return 0; + } else if (sections_size>1&§ions[1]->partition_widgets==part){ + return 1; + } + return -1; +} int yon_advanced_section_get(char *partition){ if (yon_char_is_empty(partition)) return -1; @@ -83,9 +127,11 @@ void yon_advanced_partition_set_from_section(advanced_partition *part, advanced_ void yon_advanced_update(main_window *widgets){ yon_advanced_partition_clear(widgets); - + int virtual_found = 0; for (int i=0;ipartition_widgets) sections[i]->partition_widgets = NULL; + sections[i]->partition_widgets = part; g_signal_connect(G_OBJECT(part->RemoveButton),"clicked",G_CALLBACK(on_advanced_part_remove),widgets); g_signal_connect(G_OBJECT(part->SystemSectionToggle),"clicked",G_CALLBACK(on_advanced_section_toggled),widgets); g_signal_connect(G_OBJECT(part->UserDataSectionToggle),"clicked",G_CALLBACK(on_advanced_section_toggled),widgets); @@ -97,15 +143,31 @@ void yon_advanced_update(main_window *widgets){ GtkWidget *UserImage = gtk_button_get_image(GTK_BUTTON(part->UserDataSectionToggle)); gtk_image_set_from_icon_name(GTK_IMAGE(SystemImage),toggled_icon_name,GTK_ICON_SIZE_BUTTON); gtk_image_set_from_icon_name(GTK_IMAGE(UserImage),toggled_icon_name,GTK_ICON_SIZE_BUTTON); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(part->SystemSectionToggle),1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(part->UserDataSectionToggle),1); } yon_advanced_partition_set_from_section(part,sections[i]); yon_advanced_set_max_size_from_partition(part,widgets); gtk_box_pack_start(GTK_BOX(widgets->AdvancedPartitionAddBox),part->MainBox,0,0,0); + if (!virtual_found&>k_combo_box_set_active_id(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo),sections[i]->partition)){ + virtual_found=1; + } part->part_type = ADVANCED_PART_EXISTING; } + if (!virtual_found||!sections_size) { + g_signal_handlers_block_by_func(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),G_CALLBACK(on_advanced_virtual_device_changed),widgets); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo),0); + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),G_CALLBACK(on_advanced_virtual_device_changed),widgets); + } + yon_advanced_section_update(widgets); + GtkTreeIter itar; + for_iter(GTK_TREE_MODEL(widgets->PartitionsList),&itar){ + int status; + char *target; + gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&itar,0,&target,7,&status,-1); + if (!((sections_size>0&&!strcmp(target,sections[0]->partition))||(sections_size>1&&!strcmp(target,sections[1]->partition)))){ + gtk_list_store_set(widgets->PartitionsList,&itar,7,0,-1); + } + } if (sections_size==2){ gtk_widget_hide(widgets->AdvancedAddButton); } else { @@ -169,7 +231,7 @@ void on_advanced_partition_add(GtkWidget *, char *path, main_window *widgets){ sections[sections_size]=section; sections_size++; } else { - yon_advanced_section_remove(target); + yon_advanced_section_remove_by_name(target); } } yon_advanced_update(widgets); @@ -205,7 +267,7 @@ void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_wi } } else { gtk_list_store_set(widgets->PartitionsList,&iter,7,!status,-1); - yon_advanced_section_remove(target_part); + yon_advanced_section_remove_by_name(target_part); } yon_advanced_update(widgets); } @@ -310,7 +372,6 @@ void on_install_advanced_device_chosen(GtkCellRenderer *, gchar *path, main_wind yon_advanced_section_remove_all(); GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->DevicesList); - // int chosen = 0; // chosen = yon_advanced_get_part_size(widgets); if (gtk_tree_model_get_iter_from_string(model,&iter,path)){ @@ -327,7 +388,13 @@ void on_install_advanced_device_chosen(GtkCellRenderer *, gchar *path, main_wind } } } - + int chosen_amount = 0; + for_iter(model,&iter){ + int status; + gtk_tree_model_get(model,&iter,5,&status,-1); + if (status)chosen_amount++; + } + gtk_widget_set_sensitive(widgets->AdvancedVirtualDeviceCombo,chosen_amount==2); // if (chosen) gtk_widget_set_sensitive(widgets->AdvancedAddButton,1); // else gtk_widget_set_sensitive(widgets->AdvancedAddButton,0); yon_advanced_parts_update(widgets); @@ -359,26 +426,59 @@ int yon_advanced_get_part_size(main_window *widgets){ return size; } +void yon_advanced_section_update_section(advanced_partition *part,GtkWidget *cur_toggle,main_window *widgets){ + int systoggle = cur_toggle == part->SystemSectionToggle; + advanced_section *section = sections[yon_advanced_section_get_by_part(part)]; + g_signal_handlers_block_by_func(G_OBJECT(cur_toggle),G_CALLBACK(on_advanced_section_toggled),widgets); + gboolean active = systoggle?section->sys_section:section->user_section; + gtk_widget_set_sensitive(cur_toggle,!active); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cur_toggle),active); + g_signal_handlers_unblock_by_func(G_OBJECT(cur_toggle),G_CALLBACK(on_advanced_section_toggled),widgets); + GtkWidget *compare_image = gtk_button_get_image(GTK_BUTTON(cur_toggle)); + gtk_image_set_from_icon_name(GTK_IMAGE(compare_image),!active?untoggled_icon_name:toggled_icon_name,GTK_ICON_SIZE_BUTTON); +} + +void yon_advanced_section_update(main_window *widgets){ + GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->AdvancedPartitionAddBox)); + GList *iter; + for (iter=list;iter;iter=iter->next){ + advanced_partition *compare_part = g_object_get_data(G_OBJECT(iter->data),"advanced_partition"); + GtkWidget *cur_toggle = compare_part->SystemSectionToggle; + yon_advanced_section_update_section(compare_part,cur_toggle,widgets); + cur_toggle = compare_part->UserDataSectionToggle; + yon_advanced_section_update_section(compare_part,cur_toggle,widgets); + } +} + void on_advanced_section_toggled(GtkWidget *self, main_window *widgets){ advanced_partition *part = g_object_get_data(G_OBJECT(self),"advanced_partition"); - gtk_widget_set_sensitive(self,0); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(self),1); - GtkWidget *image = gtk_button_get_image(GTK_BUTTON(self)); - gtk_image_set_from_icon_name(GTK_IMAGE(image),toggled_icon_name,GTK_ICON_SIZE_BUTTON); + int pos = yon_advanced_section_get_by_part(part); + if (self == part->SystemSectionToggle){ + sections[pos]->sys_section = 1; + if (sections[!pos]&§ions[pos]->user_section){ + sections[pos]->user_section=0; + sections[!pos]->user_section=1; + } + } else { + sections[pos]->user_section = 1; + if (sections[!pos]&§ions[pos]->sys_section){ + sections[pos]->sys_section=0; + sections[!pos]->sys_section=1; + } + } GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->AdvancedPartitionAddBox)); GList *iter; for (iter=list;iter;iter=iter->next){ advanced_partition *compare_part = g_object_get_data(G_OBJECT(iter->data),"advanced_partition"); if (part != compare_part) { - GtkWidget *cur_toggle = self == part->SystemSectionToggle?compare_part->SystemSectionToggle:compare_part->UserDataSectionToggle; - g_signal_handlers_block_by_func(G_OBJECT(cur_toggle),G_CALLBACK(on_advanced_section_toggled),widgets); - gtk_widget_set_sensitive(cur_toggle,1); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cur_toggle),0); - g_signal_handlers_unblock_by_func(G_OBJECT(cur_toggle),G_CALLBACK(on_advanced_section_toggled),widgets); - GtkWidget *compare_image = gtk_button_get_image(GTK_BUTTON(cur_toggle)); - gtk_image_set_from_icon_name(GTK_IMAGE(compare_image),untoggled_icon_name,GTK_ICON_SIZE_BUTTON); + if (self == part->SystemSectionToggle){ + sections[yon_advanced_section_get_by_part(compare_part)]->sys_section = 0; + } else { + sections[yon_advanced_section_get_by_part(compare_part)]->user_section = 0; + } } } + yon_advanced_section_update(widgets); } int yon_advanced_save(main_window *widgets){ @@ -551,7 +651,7 @@ int yon_advanced_save(main_window *widgets){ void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *part){ - advanced_section *section = sections[yon_advanced_section_get(part->part)]; + advanced_section *section = sections[yon_advanced_section_get_by_part(part)]; if (self == part->SizeCombo||self == part->SizeSpin){ section->size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(part->SizeSpin)); section->size_letter = *yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(part->SizeCombo))); @@ -627,8 +727,32 @@ advanced_partition *yon_advanced_partition_new(){ void on_advanced_part_remove(GtkWidget *self, main_window *widgets){ advanced_partition *part = g_object_get_data(G_OBJECT(self),"advanced_partition"); - - yon_advanced_section_remove(part->part); + yon_advanced_section_remove(part); + if (sections_size){ + sections[0]->sys_section=1; + sections[0]->user_section=1; + } yon_advanced_update(widgets); } + +int yon_advanced_section_append(advanced_section *section){ + if (sections_size==2) return -1; + sections[sections_size] = section; + sections_size++; + return sections_size-1; +} + +void on_advanced_virtual_device_changed(GtkWidget *, main_window *widgets){ + yon_advanced_section_remove_all(); + char *device = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo)); + if (!yon_char_is_empty(device)){ + advanced_section *section = yon_advanced_section_new(); + section->part_source = PART_SOURCE_VIRTUAL; + section->partition = device; + section->device = device; + section->device = device; + yon_advanced_section_append(section); + } + yon_advanced_update(widgets); +} \ No newline at end of file diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index b2c195b..cd9e897 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -932,6 +932,7 @@ void yon_main_window_create(main_window *widgets){ g_signal_connect(G_OBJECT(widgets->SkipInstallationButton),"clicked",G_CALLBACK(on_system_setup_pass),widgets); g_signal_connect(G_OBJECT(widgets->AdvancedAddButton),"clicked",G_CALLBACK(on_advanced_partition_create),widgets); g_signal_connect(G_OBJECT(widgets->AdvancedPartChosenCell),"toggled",G_CALLBACK(on_install_advanced_partition_chosen),widgets); + g_signal_connect(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),"changed",G_CALLBACK(on_advanced_virtual_device_changed),widgets); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(widgets->InstallerCountryFilter),(GtkTreeModelFilterVisibleFunc)on_country_filter,widgets,NULL); { diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 8095315..f10e799 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -934,7 +934,8 @@ typedef struct { enum PART_SOURCE { PART_SOURCE_DEVICE, - PART_SOURCE_PART + PART_SOURCE_PART, + PART_SOURCE_VIRTUAL }; typedef struct { @@ -951,6 +952,7 @@ typedef struct { char *encryption; char *encryption_password; enum PART_SOURCE part_source; + advanced_partition *partition_widgets; } advanced_section; @@ -1172,4 +1174,10 @@ void yon_fs_type_setup(GtkComboBoxText *target); void yon_advanced_set_max_size_from_partition(advanced_partition *part, main_window *widgets); void on_advanced_size_changed(GtkWidget *self,main_window *widgets); int yon_advanced_save(main_window *widgets); -void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *part); \ No newline at end of file +void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *part); +void yon_advanced_section_update(main_window *widgets); +void yon_advanced_section_update_section(advanced_partition *part,GtkWidget *cur_toggle,main_window *widgets); +int yon_advanced_section_get_by_part(advanced_partition *part); +void yon_advanced_section_remove_by_name(char *part); +void on_advanced_virtual_device_changed(GtkWidget *, main_window *widgets); +int yon_advanced_section_append(advanced_section *section); \ No newline at end of file diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 9a3a93a..cd362c1 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1,5 +1,5 @@ - + @@ -15,6 +15,11 @@ + + 100 + 1 + 10 + @@ -7017,7 +7022,7 @@ separately into the selected partition. False 0 - No + No RAID0 RAID1 DAID4 @@ -7632,6 +7637,7 @@ separately into the selected partition. True False True + AdvancedSwapAdjustment False