From b0d012501a57508115fa41de524e92c77fcc5f30 Mon Sep 17 00:00:00 2001 From: Ivan Yarcev Date: Wed, 8 Oct 2025 18:36:17 +0600 Subject: [PATCH] WIP Advanced saving --- source/ubinstall-gtk-advanced.c | 98 ++++++++++++++++++++++++++--- source/ubinstall-gtk-installation.c | 2 +- source/ubinstall-gtk.h | 3 +- ubinstall-gtk-advanced-box.glade | 4 +- ubinstall-gtk.glade | 15 +++++ 5 files changed, 111 insertions(+), 11 deletions(-) diff --git a/source/ubinstall-gtk-advanced.c b/source/ubinstall-gtk-advanced.c index fcbbe4e..839fd21 100644 --- a/source/ubinstall-gtk-advanced.c +++ b/source/ubinstall-gtk-advanced.c @@ -129,6 +129,7 @@ void on_advanced_partition_create(GtkWidget *, main_window *widgets){ if (sections_size==2) break; advanced_section *section = yon_advanced_section_new(); section->part_source = PART_SOURCE_DEVICE; + section->device = target; section->partition = target; sections[sections_size]=section; sections_size++; @@ -144,6 +145,7 @@ void on_advanced_partition_create(GtkWidget *, main_window *widgets){ if (sections_size==2) return; advanced_section *section = yon_advanced_section_new(); section->part_source = PART_SOURCE_DEVICE; + section->device = target; section->partition = target; sections[sections_size]=section; sections_size++; @@ -154,14 +156,16 @@ void on_advanced_partition_create(GtkWidget *, main_window *widgets){ void on_advanced_partition_add(GtkWidget *, char *path, main_window *widgets){ GtkTreeIter iter; if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(widgets->PartitionsList),&iter,path)){ - char *target; + char *target, *device; int status; - gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&target,7,&status,-1); + gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&target,7,&status,9,&device,-1); gtk_list_store_set(widgets->DevicesList,&iter,7,!status,-1); if (!status){ if (sections_size==2) return; advanced_section *section = yon_advanced_section_new(); section->part_source = PART_SOURCE_PART; + section->device = device; + section->partition = target = device; sections[sections_size]=section; sections_size++; } else { @@ -173,7 +177,6 @@ void on_advanced_partition_add(GtkWidget *, char *path, main_window *widgets){ } void yon_install_advanced_init(main_window *){ - } void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_window *widgets){ @@ -185,8 +188,8 @@ void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_wi gtk_tree_model_get_iter_from_string(model,&iter,path); int status; - char *target_part; - gtk_tree_model_get(model,&iter,0,&target_part,7,&status,-1); + char *target_part, *device; + gtk_tree_model_get(model,&iter,0,&target_part,7,&status,9,&device,-1); if (!status){ if (chosen<2){ @@ -195,6 +198,8 @@ void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_wi advanced_section *section = yon_advanced_section_new(); section->part_source = PART_SOURCE_PART; section->partition = target_part; + section->device = device; + section->device = device; sections[sections_size]=section; sections_size++; } @@ -376,7 +381,8 @@ void on_advanced_section_toggled(GtkWidget *self, main_window *widgets){ } } -int yon_advanced_save(main_window *){ +int yon_advanced_save(main_window *widgets){ + yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"custom"); int devices_size; config_str devices = NULL; int parts_size; @@ -399,7 +405,7 @@ int yon_advanced_save(main_window *){ } advanced_section *cur_section = sections[0]->sys_section?sections[0]:sections[1]; yon_char_parsed_add_or_create_if_exists(devices,&devices_size,cur_section->device); - if (cur_section->user_section){ + if (cur_section->device){ yon_char_parsed_add_or_create_if_exists(devices,&devices_size,cur_section->device); } if (!yon_char_is_empty(cur_section->partition)){ @@ -466,38 +472,107 @@ int yon_advanced_save(main_window *){ if (devices_size){ char *devices_str = yon_char_parsed_to_string(devices,devices_size,","); + yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,devices_str); } if (parts_size){ char *parts_str = yon_char_parsed_to_string(parts,parts_size,","); + yon_config_register(part_parameter,part_parameter_command,parts_str); } if (part_size_size){ char *part_size_str = yon_char_parsed_to_string(part_size,part_size_size,","); + yon_config_register(part_size_parameter,part_size_parameter_command,part_size_str); } if (part_label_size){ char *part_label_str = yon_char_parsed_to_string(part_label,part_label_size,","); + yon_config_register(part_label_parameter,part_label_parameter_command,part_label_str); } if (fs_type_size){ char *fs_type_str = yon_char_parsed_to_string(fs_type,fs_type_size,","); + yon_config_register(part_fs_type_parameter,part_fs_type_parameter_command,fs_type_str); } if (fs_label_size){ char *fs_label_str = yon_char_parsed_to_string(fs_label,fs_label_size,","); + yon_config_register(part_fs_label_parameter,part_fs_label_parameter_command,fs_label_str); } if (encryption_size){ char *encryption_str = yon_char_parsed_to_string(encryption,encryption_size,","); + yon_config_register(part_crypt_parameter,part_crypt_parameter_command,encryption_str); } if (format_size){ char *format_str = yon_char_parsed_to_string(format,format_size,","); + yon_config_register(part_format_parameter,part_format_parameter_command,format_str); + + } + if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedLoadTypeSwitch))){ + char *boot = NULL; + if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedBiosSectorSwitch))){ + yon_char_append_element(boot,"bios","+"); + } + if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedEFISwitch))){ + yon_char_append_element(boot,"efi","+"); + } + if (!yon_char_is_empty(boot)){ + yon_config_register(boot_parameter,boot_parameter_command,boot); + } else { + yon_config_remove_by_key(boot_parameter); + } + } else { + yon_config_remove_by_key(boot_parameter); + } + if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedSwapSwitch))){ + if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedSwapAutoSwitch))){ + yon_config_register(swap_parameter,swap_parameter_command,"auto"); + + } else if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedSwapRamSwitch))){ + yon_config_register(swap_parameter,swap_parameter_command,"yes"); + yon_config_register(swap_size_parameter,swap_parameter_command,"ram"); + + } else if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedSwapFixedSwitch))){ + yon_config_register(swap_parameter,swap_parameter_command,"yes"); + long swap_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->AdvancedSwapFixedSpin)); + int size_letter = gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedSwapFixedSizeSwitch)); + char *swap_str = yon_char_from_long(swap_size); + char *size_final = yon_char_unite(swap_str,size_letter?"G":"M",NULL); + yon_config_register(swap_size_parameter,swap_parameter_command,size_final); + } else { + yon_config_remove_by_key(swap_parameter); + yon_config_remove_by_key(swap_size_parameter); + } } return 1; } + +void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *part){ + advanced_section *section = sections[yon_advanced_section_get(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))); + } else if (self == part->PartLabelEntry){ + section->part_label = yon_char_new(gtk_entry_get_text(GTK_ENTRY(part->PartLabelEntry))); + } else if (self == part->FileSystemTypeCombo){ + section->fs_type = yon_char_new(gtk_combo_box_get_active_id(GTK_COMBO_BOX(part->FileSystemTypeCombo))); + } else if (self == part->FileSystemLabelEntry){ + section->fs_label = yon_char_new(gtk_entry_get_text(GTK_ENTRY(part->FileSystemLabelEntry))); + } else if (self == part->EncryptionCombo||self == part->EncryptionEntry){ + section->encryption = yon_char_new(gtk_combo_box_get_active_id(GTK_COMBO_BOX(part->EncryptionCombo))); + section->encryption_password = yon_char_new(gtk_entry_get_text(GTK_ENTRY(part->EncryptionEntry))); + } else if (self == part->FormatSwitch){ + if (gtk_switch_get_active(GTK_SWITCH(part->FormatSwitch))){ + section->format=1; + } else { + section->format=0; + } + } +} + advanced_partition *yon_advanced_partition_new(){ advanced_partition *part = new(advanced_partition); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_advanced_part); @@ -523,6 +598,15 @@ advanced_partition *yon_advanced_partition_new(){ g_signal_connect(G_OBJECT(part->EncryptionButton),"clicked",G_CALLBACK(on_advanced_password_clicked),part); g_signal_connect(G_OBJECT(part->EncryptionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),part->EncryptionButton); g_signal_connect(G_OBJECT(part->EncryptionCombo),"changed",G_CALLBACK(yon_gtk_widget_set_sensitive_from_combo_box),part->EncryptionEntry); + g_signal_connect(G_OBJECT(part->EncryptionEntry),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->FormatSwitch),"activate",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->SizeCombo),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->SizeSpin),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->PartLabelEntry),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->FileSystemTypeCombo),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->FileSystemLabelEntry),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + g_signal_connect(G_OBJECT(part->EncryptionCombo),"changed",G_CALLBACK(yon_advanced_part_parameter_changed),part); + yon_fs_type_setup(GTK_COMBO_BOX_TEXT(part->FileSystemTypeCombo)); diff --git a/source/ubinstall-gtk-installation.c b/source/ubinstall-gtk-installation.c index 91062f9..ce9c789 100644 --- a/source/ubinstall-gtk-installation.c +++ b/source/ubinstall-gtk-installation.c @@ -355,7 +355,7 @@ void on_device_selection_changed(GtkWidget *self, main_window *widgets){ } 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); + 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,9,disk_path,-1); } yon_char_parsed_free(parsed,parsed_size); } diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 928ca8a..8095315 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -1171,4 +1171,5 @@ void on_advanced_section_toggled(GtkWidget *self, main_window *widgets); 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); \ No newline at end of file +int yon_advanced_save(main_window *widgets); +void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *part); \ No newline at end of file diff --git a/ubinstall-gtk-advanced-box.glade b/ubinstall-gtk-advanced-box.glade index 648d669..9594bbc 100644 --- a/ubinstall-gtk-advanced-box.glade +++ b/ubinstall-gtk-advanced-box.glade @@ -248,7 +248,7 @@ - + True True @@ -311,7 +311,7 @@ - + True True diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index 0c189a4..9a3a93a 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -202,6 +202,8 @@ + + @@ -6900,6 +6902,9 @@ separately into the selected partition. True DevicesList 0 + + + @@ -7071,6 +7076,9 @@ separately into the selected partition. True PartitionsList 0 + + + @@ -7528,6 +7536,7 @@ separately into the selected partition. True True + True False @@ -9846,6 +9855,9 @@ separately into the selected partition. True DevicesList 0 + + + Device @@ -9947,6 +9959,9 @@ separately into the selected partition. True PartitionsList 0 + + + Section