|
|
|
|
@ -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,12 +62,47 @@ 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;
|
|
|
|
|
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;
|
|
|
|
|
@ -66,26 +110,40 @@ 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);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(part->SizeCombo),yon_get_size_get_from_letter(section->size_letter));
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->PartLabelEntry),section->part_label);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->FileSystemLabelEntry),section->fs_label);
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(part->FileSystemTypeCombo),section->fs_type);
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(part->EncryptionCombo),section->encryption);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->EncryptionEntry),section->encryption_password);
|
|
|
|
|
if (section->size){
|
|
|
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(part->SizeSpin),section->size);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(part->SizeCombo),yon_get_size_get_from_letter(section->size_letter));
|
|
|
|
|
}
|
|
|
|
|
if (section->part_label){
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->PartLabelEntry),section->part_label);
|
|
|
|
|
}
|
|
|
|
|
if (section->fs_label)
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->FileSystemLabelEntry),section->fs_label);
|
|
|
|
|
if (!yon_char_is_empty(section->fs_type)){
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(part->FileSystemTypeCombo),section->fs_type);
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(section->encryption)){
|
|
|
|
|
gtk_combo_box_set_active_id(GTK_COMBO_BOX(part->EncryptionCombo),section->encryption);
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(part->EncryptionEntry),section->encryption_password);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_update(main_window *widgets){
|
|
|
|
|
yon_advanced_partition_clear(widgets);
|
|
|
|
|
|
|
|
|
|
int virtual_found = 0;
|
|
|
|
|
for (int i=0;i<sections_size;i++){
|
|
|
|
|
advanced_partition *part = yon_advanced_partition_new();
|
|
|
|
|
if (sections[i]->partition_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,16 +155,34 @@ 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);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
if (sections_size==2){
|
|
|
|
|
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]->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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sections_size>=2){
|
|
|
|
|
gtk_widget_hide(widgets->AdvancedAddButton);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_widget_show(widgets->AdvancedAddButton);
|
|
|
|
|
@ -130,7 +206,7 @@ void on_advanced_partition_create(GtkWidget *, main_window *widgets){
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->part_source = PART_SOURCE_DEVICE;
|
|
|
|
|
section->device = target;
|
|
|
|
|
section->partition = target;
|
|
|
|
|
section->partition = NULL;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
break;
|
|
|
|
|
@ -146,7 +222,7 @@ void on_advanced_partition_create(GtkWidget *, main_window *widgets){
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->part_source = PART_SOURCE_DEVICE;
|
|
|
|
|
section->device = target;
|
|
|
|
|
section->partition = target;
|
|
|
|
|
section->partition = NULL;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
}
|
|
|
|
|
@ -164,19 +240,31 @@ void on_advanced_partition_add(GtkWidget *, char *path, main_window *widgets){
|
|
|
|
|
if (sections_size==2) return;
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->part_source = PART_SOURCE_PART;
|
|
|
|
|
section->device = device;
|
|
|
|
|
section->device = NULL;
|
|
|
|
|
section->partition = target = device;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
} else {
|
|
|
|
|
yon_advanced_section_remove(target);
|
|
|
|
|
yon_advanced_section_remove_by_name(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
yon_advanced_update(widgets);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_install_advanced_init(main_window *){
|
|
|
|
|
void yon_install_advanced_init(main_window *widgets){
|
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->AdvancedVirtualDeviceCombo));
|
|
|
|
|
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->AdvancedVirtualDeviceCombo),NO_LABEL);
|
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo),0);
|
|
|
|
|
int size;
|
|
|
|
|
config_str vmf_file = yon_resource_open_file(vfs_list_path,&size);
|
|
|
|
|
for (int i=1;i<size;i++){
|
|
|
|
|
int parsed_size;
|
|
|
|
|
config_str parsed = yon_char_parse(vmf_file[i],&parsed_size,";");
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(widgets->AdvancedVirtualDeviceCombo),parsed[2],parsed[0]);
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(vmf_file,size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_window *widgets){
|
|
|
|
|
@ -198,14 +286,13 @@ 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;
|
|
|
|
|
section->device = NULL;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
}
|
|
|
|
|
} 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);
|
|
|
|
|
}
|
|
|
|
|
@ -263,7 +350,7 @@ void yon_advanced_parts_update(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
GtkTreeIter itar;
|
|
|
|
|
gtk_list_store_append(widgets->PartitionsList,&itar);
|
|
|
|
|
gtk_list_store_set(widgets->PartitionsList,&itar,0,name,1,capacity,2,free_space,3,fs_type,4,label,5,capacity_long,6,free_space_long,8,1,-1);
|
|
|
|
|
gtk_list_store_set(widgets->PartitionsList,&itar,0,name,1,capacity,2,free_space,3,fs_type,4,label,5,capacity_long,6,free_space_long,8,1,9,disk_path,-1);
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
}
|
|
|
|
|
@ -273,14 +360,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){
|
|
|
|
|
@ -310,7 +397,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 +413,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,154 +451,187 @@ 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){
|
|
|
|
|
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"custom");
|
|
|
|
|
int devices_size;
|
|
|
|
|
config_str devices = NULL;
|
|
|
|
|
int parts_size;
|
|
|
|
|
config_str parts = NULL;
|
|
|
|
|
int part_size_size;
|
|
|
|
|
config_str part_size = NULL;
|
|
|
|
|
int part_label_size;
|
|
|
|
|
config_str part_label = NULL;
|
|
|
|
|
int fs_type_size;
|
|
|
|
|
config_str fs_type = NULL;
|
|
|
|
|
int fs_label_size;
|
|
|
|
|
config_str fs_label = NULL;
|
|
|
|
|
int encryption_size;
|
|
|
|
|
config_str encryption = NULL;
|
|
|
|
|
int format_size;
|
|
|
|
|
config_str format = NULL;
|
|
|
|
|
char *devices[2] = {NULL};
|
|
|
|
|
char *parts[2] = {NULL};
|
|
|
|
|
char *part_size[2] = {NULL};
|
|
|
|
|
char *part_label[2] = {NULL};
|
|
|
|
|
char *fs_type[2] = {NULL};
|
|
|
|
|
char *fs_label[2] = {NULL};
|
|
|
|
|
char *encryption[2] = {NULL};
|
|
|
|
|
char *format[2] = {NULL};
|
|
|
|
|
if (!sections_size){
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
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->device){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(devices,&devices_size,cur_section->device);
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->partition)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parts,&parts_size,cur_section->partition);
|
|
|
|
|
if (!yon_char_is_empty(cur_section->partition)){
|
|
|
|
|
parts[0]=cur_section->partition;
|
|
|
|
|
} else {
|
|
|
|
|
parts[0]="";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parts,&parts_size,"");
|
|
|
|
|
devices[0]=cur_section->device;
|
|
|
|
|
}
|
|
|
|
|
if (cur_section->user_section){
|
|
|
|
|
if (!yon_char_is_empty(cur_section->device)){
|
|
|
|
|
if (!yon_char_is_empty(cur_section->partition)){
|
|
|
|
|
parts[1]=cur_section->partition;
|
|
|
|
|
} else {
|
|
|
|
|
parts[1]="";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
devices[1]=cur_section->device;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (cur_section->size){
|
|
|
|
|
char *size_str = yon_char_from_long(cur_section->size);
|
|
|
|
|
char *sz_str = yon_char_append_c(size_str,cur_section->size_letter);
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(part_size,&part_size_size,sz_str);
|
|
|
|
|
part_size[0]=sz_str;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->part_label)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(part_label,&part_label_size,cur_section->part_label);
|
|
|
|
|
part_label[0]=cur_section->part_label;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->fs_type)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(fs_type,&fs_type_size,cur_section->fs_type);
|
|
|
|
|
fs_type[0]=cur_section->fs_type;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->fs_label)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(fs_label,&fs_label_size,cur_section->fs_label);
|
|
|
|
|
fs_label[0]=cur_section->fs_label;
|
|
|
|
|
}
|
|
|
|
|
if (cur_section->format){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(format,&format_size,"yes");
|
|
|
|
|
format[0]="yes";
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(format,&format_size,"no");
|
|
|
|
|
format[0]="no";
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->encryption)){
|
|
|
|
|
char *encrypt_str = yon_char_unite(cur_section->encryption,":",cur_section->encryption_password,NULL);
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(encryption,&encryption_size,encrypt_str);
|
|
|
|
|
encryption[0]=encrypt_str;
|
|
|
|
|
}
|
|
|
|
|
if (sections_size>1){
|
|
|
|
|
cur_section = sections[0]->sys_section?sections[1]:sections[0];
|
|
|
|
|
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(devices,&devices_size,cur_section->device);
|
|
|
|
|
devices[1]=cur_section->device;
|
|
|
|
|
if (!yon_char_is_empty(cur_section->partition)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parts,&parts_size,cur_section->partition);
|
|
|
|
|
parts[1]=cur_section->partition;
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(parts,&parts_size,"");
|
|
|
|
|
parts[1]="";
|
|
|
|
|
}
|
|
|
|
|
if (cur_section->size){
|
|
|
|
|
char *size_str = yon_char_from_long(cur_section->size);
|
|
|
|
|
char *sz_str = yon_char_append_c(size_str,cur_section->size_letter);
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(part_size,&part_size_size,sz_str);
|
|
|
|
|
part_size[1]=sz_str;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->part_label)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(part_label,&part_label_size,cur_section->part_label);
|
|
|
|
|
part_label[1]=cur_section->part_label;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->fs_type)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(fs_type,&fs_type_size,cur_section->fs_type);
|
|
|
|
|
fs_type[1]=cur_section->fs_type;
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->fs_label)){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(fs_label,&fs_label_size,cur_section->fs_label);
|
|
|
|
|
fs_label[1]=cur_section->fs_label;
|
|
|
|
|
}
|
|
|
|
|
if (cur_section->format){
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(format,&format_size,"yes");
|
|
|
|
|
format[1]="yes";
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(format,&format_size,"no");
|
|
|
|
|
format[1]="no";
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(cur_section->encryption)){
|
|
|
|
|
char *encrypt_str = yon_char_unite(cur_section->encryption,":",cur_section->encryption_password,NULL);
|
|
|
|
|
yon_char_parsed_add_or_create_if_exists(encryption,&encryption_size,encrypt_str);
|
|
|
|
|
encryption[1]=encrypt_str;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (devices[0]||devices[1]){
|
|
|
|
|
char *devices_str = yon_char_parsed_to_string_full(devices,2,",");
|
|
|
|
|
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 (!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);
|
|
|
|
|
}
|
|
|
|
|
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_size[0]||part_size[1]){
|
|
|
|
|
char *part_size_str = yon_char_parsed_to_string_full(part_size,2,",");
|
|
|
|
|
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 (part_label[0]||part_label[1]){
|
|
|
|
|
char *part_label_str = yon_char_parsed_to_string_full(part_label,2,",");
|
|
|
|
|
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_type[0]||fs_type[1]){
|
|
|
|
|
char *fs_type_str = yon_char_parsed_to_string_full(fs_type,2,",");
|
|
|
|
|
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 (fs_label[0]||fs_label[1]){
|
|
|
|
|
char *fs_label_str = yon_char_parsed_to_string_full(fs_label,2,",");
|
|
|
|
|
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 (encryption[0]||encryption[1]){
|
|
|
|
|
char *encryption_str = yon_char_parsed_to_string_full(encryption,2,",");
|
|
|
|
|
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 (format[0]||format[1]){
|
|
|
|
|
char *format_str = yon_char_parsed_to_string_full(format,2,",");
|
|
|
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,format_str);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedLoadTypeSwitch))){
|
|
|
|
|
@ -546,15 +671,18 @@ int yon_advanced_save(main_window *widgets){
|
|
|
|
|
yon_config_remove_by_key(swap_size_parameter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
char *parameters = yon_config_get_all_info();
|
|
|
|
|
yon_debug_output("%s\n",parameters);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
int size_id = gtk_combo_box_get_active(GTK_COMBO_BOX(part->SizeCombo));
|
|
|
|
|
section->size_letter = *yon_size_get_mod(size_id>-1?size_id:0);
|
|
|
|
|
} else if (self == part->PartLabelEntry){
|
|
|
|
|
section->part_label = yon_char_new(gtk_entry_get_text(GTK_ENTRY(part->PartLabelEntry)));
|
|
|
|
|
} else if (self == part->FileSystemTypeCombo){
|
|
|
|
|
@ -573,6 +701,11 @@ void yon_advanced_part_parameter_changed(GtkWidget *self, advanced_partition *pa
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean on_format_changed(GtkWidget *self, gboolean , advanced_partition *part){
|
|
|
|
|
yon_advanced_part_parameter_changed(self, part);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
advanced_partition *yon_advanced_partition_new(){
|
|
|
|
|
advanced_partition *part = new(advanced_partition);
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_advanced_part);
|
|
|
|
|
@ -593,13 +726,14 @@ 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);
|
|
|
|
|
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->FormatSwitch),"state-set",G_CALLBACK(on_format_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);
|
|
|
|
|
@ -627,8 +761,68 @@ 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));
|
|
|
|
|
int size;
|
|
|
|
|
config_str vfs_file = yon_resource_open_file(vfs_list_path,&size);
|
|
|
|
|
config_str cur_device = NULL;
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
int parsed_size;
|
|
|
|
|
config_str parsed = yon_char_parse(vfs_file[i],&parsed_size,";");
|
|
|
|
|
if (!yon_char_is_empty(device)&&!yon_char_is_empty(parsed[2])&!strcmp(parsed[2],device)){
|
|
|
|
|
cur_device = parsed;
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(widgets->AdvancedVirtualDeviceLabel),parsed[1]);
|
|
|
|
|
} else {
|
|
|
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!yon_char_is_empty(device)){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(widgets->DevicesList);
|
|
|
|
|
int active_devices=0;
|
|
|
|
|
for_iter(model,&iter){
|
|
|
|
|
int status;
|
|
|
|
|
gtk_tree_model_get(model,&iter,5,&status,-1);
|
|
|
|
|
if (status) active_devices++;
|
|
|
|
|
}
|
|
|
|
|
if (atoi(cur_device[3])>active_devices){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),COUNT_INVALID_LABEL(cur_device[3]),5,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(widgets->AdvancedVirtualDeviceCombo);
|
|
|
|
|
yon_char_parsed_free(cur_device,4);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (atoi(cur_device[4])%active_devices!=0){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),PARITY_INVALID_LABEL(cur_device[4]),5,BACKGROUND_IMAGE_INFO_TYPE);
|
|
|
|
|
yon_ubl_status_highlight_incorrect(widgets->AdvancedVirtualDeviceCombo);
|
|
|
|
|
yon_char_parsed_free(cur_device,4);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->part_source = PART_SOURCE_VIRTUAL;
|
|
|
|
|
section->partition = device;
|
|
|
|
|
section->device = device;
|
|
|
|
|
yon_advanced_section_append(section);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
yon_char_parsed_free(vfs_file,size);
|
|
|
|
|
yon_advanced_update(widgets);
|
|
|
|
|
}
|