diff --git a/source/ubinstall-gtk-advanced.c b/source/ubinstall-gtk-advanced.c index 487ce90..d696a53 100644 --- a/source/ubinstall-gtk-advanced.c +++ b/source/ubinstall-gtk-advanced.c @@ -100,9 +100,9 @@ int yon_advanced_section_get_by_part(advanced_partition *part){ int yon_advanced_section_get(char *partition){ if (yon_char_is_empty(partition)) return -1; - if (sections_size>0&&!strcmp(sections[0]->partition,partition)){ + if (sections_size>0&&!strcmp(sections[0]->part_source==PART_SOURCE_PART?sections[0]->partition:sections[0]->device,partition)){ return 0; - } else if (sections_size>1&&!strcmp(sections[1]->partition,partition)){ + } else if (sections_size>1&&!strcmp(sections[1]->part_source==PART_SOURCE_PART?sections[1]->partition:sections[1]->device,partition)){ return 1; } return -1; @@ -110,8 +110,11 @@ int yon_advanced_section_get(char *partition){ void yon_advanced_partition_set_from_section(advanced_partition *part, advanced_section *section){ if (part&§ion){ - gtk_label_set_text(GTK_LABEL(part->SectionLabel),section->partition); + gtk_label_set_text(GTK_LABEL(part->SectionLabel),section->part_source==PART_SOURCE_PART?section->partition:section->device); part->part = yon_char_new(section->partition); + part->device = yon_char_new(section->device); + if (!yon_char_is_empty(part->part)) part->part_type = ADVANCED_PART_NEW; + else part->part_type = ADVANCED_PART_EXISTING; if (section->format){ gtk_switch_set_active(GTK_SWITCH(part->FormatSwitch),1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(part->SizeSpin),section->size); @@ -147,9 +150,11 @@ void yon_advanced_update(main_window *widgets){ 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)){ + g_signal_handlers_block_by_func(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),G_CALLBACK(on_advanced_virtual_device_changed),widgets); + if (!virtual_found&>k_combo_box_set_active_id(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo),sections[i]->part_source==PART_SOURCE_PART?sections[i]->partition:sections[i]->device)){ virtual_found=1; } + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->AdvancedVirtualDeviceCombo),G_CALLBACK(on_advanced_virtual_device_changed),widgets); part->part_type = ADVANCED_PART_EXISTING; } @@ -164,7 +169,7 @@ void yon_advanced_update(main_window *widgets){ 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)))){ + if (!((sections_size>0&&!strcmp(target,sections[0]->part_source==PART_SOURCE_PART?sections[0]->partition:sections[0]->device))||(sections_size>1&&!strcmp(target,sections[1]->part_source==PART_SOURCE_PART?sections[1]->partition:sections[1]->device)))){ gtk_list_store_set(widgets->PartitionsList,&itar,7,0,-1); } } @@ -334,14 +339,14 @@ void yon_advanced_parts_update(main_window *widgets){ } void yon_advanced_set_max_size_from_partition(advanced_partition *part, main_window *widgets){ - char *cur_name = part->part; + char *cur_name = part->part_type == ADVANCED_PART_EXISTING?part->device:part->part; GtkTreeModel *model = GTK_TREE_MODEL(widgets->PartitionsList); GtkTreeIter iter; long selected_size; for_iter(model,&iter){ char *target; - gtk_tree_model_get(model,&iter,0,&target,-1); + gtk_tree_model_get(model,&iter,part->part_type == ADVANCED_PART_EXISTING?9:0,&target,-1); if (!strcmp(target,cur_name)){ gtk_tree_model_get(model,&iter,6,&selected_size,-1); if (!selected_size){ @@ -564,7 +569,7 @@ int yon_advanced_save(main_window *widgets){ char *devices_str = yon_char_parsed_to_string_full(devices,2,","); yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,devices_str); } - if (parts[0]||parts[1]){ + if (!yon_char_is_empty(parts[0])||!yon_char_is_empty(parts[1])){ char *parts_str = yon_char_parsed_to_string_full(parts,2,","); yon_config_register(part_parameter,part_parameter_command,parts_str); @@ -690,6 +695,7 @@ advanced_partition *yon_advanced_partition_new(){ part->FormatRevealer = yon_gtk_builder_get_widget(builder,"FormatRevealer"); part->order_iter = NULL; part->part = NULL; + part->device = NULL; yon_gtk_revealer_set_from_switch(GTK_REVEALER(part->FormatRevealer),GTK_SWITCH(part->FormatSwitch)); g_signal_connect(G_OBJECT(part->EncryptionButton),"clicked",G_CALLBACK(on_advanced_password_clicked),part); diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 7a6413c..0600b76 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -714,6 +714,7 @@ typedef struct { enum ADVANCED_PART_TYPE part_type; char *part; + char *device; } advanced_partition; typedef struct {