|
|
|
|
@ -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;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,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);
|
|
|
|
|
}
|