|
|
|
|
@ -13,6 +13,18 @@ advanced_section *yon_advanced_section_new(){
|
|
|
|
|
return section;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_section_remove_all(){
|
|
|
|
|
if (sections[0]){
|
|
|
|
|
free(sections[0]);
|
|
|
|
|
sections[0]=NULL;
|
|
|
|
|
}
|
|
|
|
|
if (sections[1]){
|
|
|
|
|
free(sections[1]);
|
|
|
|
|
sections[1]=NULL;
|
|
|
|
|
}
|
|
|
|
|
sections_size=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_section_remove(char *part){
|
|
|
|
|
int pos = yon_advanced_section_get(part);
|
|
|
|
|
switch(pos){
|
|
|
|
|
@ -41,52 +53,60 @@ void yon_advanced_section_remove(char *part){
|
|
|
|
|
|
|
|
|
|
int yon_advanced_section_get(char *partition){
|
|
|
|
|
if (yon_char_is_empty(partition)) return -1;
|
|
|
|
|
if (sections_size>0&&!strcmp(sections[0]->part_label,partition)){
|
|
|
|
|
if (sections_size>0&&!strcmp(sections[0]->partition,partition)){
|
|
|
|
|
return 0;
|
|
|
|
|
} else if (sections_size>1&&!strcmp(sections[1]->part_label,partition)){
|
|
|
|
|
} else if (sections_size>1&&!strcmp(sections[1]->partition,partition)){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_partition_set_from_section(advanced_partition *part, advanced_section *section){
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(part->SectionLabel),section->part_label);
|
|
|
|
|
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 (part&§ion){
|
|
|
|
|
gtk_label_set_text(GTK_LABEL(part->SectionLabel),section->partition);
|
|
|
|
|
part->part = yon_char_new(section->partition);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_update(main_window *widgets){
|
|
|
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->AdvancedPartitionAddBox));
|
|
|
|
|
GList *iter;
|
|
|
|
|
for (iter = list; iter; iter=iter->next){
|
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
|
|
|
|
}
|
|
|
|
|
yon_advanced_partition_clear(widgets);
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<sections_size;i++){
|
|
|
|
|
advanced_partition *part = yon_advanced_partition_new();
|
|
|
|
|
g_signal_connect(G_OBJECT(part->RemoveButton),"clicked",G_CALLBACK(on_advanced_part_remove),widgets);
|
|
|
|
|
yon_advanced_partition_set_from_section(part,sections[i]);
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(widgets->AdvancedPartitionAddBox),part->MainBox,0,0,0);
|
|
|
|
|
|
|
|
|
|
part->part_type = ADVANCED_PART_EXISTING;
|
|
|
|
|
}
|
|
|
|
|
if (sections_size==2){
|
|
|
|
|
gtk_widget_hide(widgets->AdvancedAddButton);
|
|
|
|
|
} else {
|
|
|
|
|
gtk_widget_show(widgets->AdvancedAddButton);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_advanced_partition_create(GtkWidget *, main_window *widgets){
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeIter iter, *last_found;
|
|
|
|
|
for_iter(GTK_TREE_MODEL(widgets->DevicesList),&iter){
|
|
|
|
|
char *target;
|
|
|
|
|
int active;
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->DevicesList),&iter,0,&target,3,&active,-1);
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,3,!active,-1);
|
|
|
|
|
if (!active){
|
|
|
|
|
if (sections_size==2) return;
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->DevicesList),&iter,0,&target,5,&active,-1);
|
|
|
|
|
if (active){
|
|
|
|
|
if (sections_size==2) break;
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->partition = target;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
}
|
|
|
|
|
@ -99,8 +119,8 @@ void on_advanced_partition_add(GtkWidget *, char *path, main_window *widgets){
|
|
|
|
|
if (gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(widgets->PartitionsList),&iter,path)){
|
|
|
|
|
char *target;
|
|
|
|
|
int status;
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&target,5,&status,-1);
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,3,!status,-1);
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(widgets->PartitionsList),&iter,0,&target,7,&status,-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();
|
|
|
|
|
@ -133,22 +153,17 @@ void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_wi
|
|
|
|
|
if (chosen<2){
|
|
|
|
|
gtk_list_store_set(widgets->PartitionsList,&iter,7,!status,-1);
|
|
|
|
|
chosen++;
|
|
|
|
|
advanced_partition *part = yon_advanced_partition_new();
|
|
|
|
|
part->part_type = ADVANCED_PART_EXISTING;
|
|
|
|
|
part->order_iter = g_sequence_append(widgets->advanced_partition_order,part);
|
|
|
|
|
part->part = target_part;
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(widgets->AdvancedPartitionAddBox),part->MainBox,0,0,0);
|
|
|
|
|
gtk_widget_show(part->MainBox);
|
|
|
|
|
yon_advanced_partition_setup(part,widgets);
|
|
|
|
|
on_advanced_parts_added(NULL,NULL,widgets);
|
|
|
|
|
|
|
|
|
|
advanced_section *section = yon_advanced_section_new();
|
|
|
|
|
section->partition = target_part;
|
|
|
|
|
sections[sections_size]=section;
|
|
|
|
|
sections_size++;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
gtk_list_store_set(widgets->PartitionsList,&iter,7,!status,-1);
|
|
|
|
|
advanced_partition *part = g_object_get_data(G_OBJECT(widgets->AdvancedPartitionAddBox),target_part);
|
|
|
|
|
if (part){
|
|
|
|
|
on_advanced_part_remove(part->RemoveButton,widgets);
|
|
|
|
|
}
|
|
|
|
|
yon_advanced_section_remove(target_part);
|
|
|
|
|
}
|
|
|
|
|
yon_advanced_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_parts_update(main_window *widgets){
|
|
|
|
|
@ -215,42 +230,91 @@ void yon_advanced_parts_update(main_window *widgets){
|
|
|
|
|
|
|
|
|
|
void on_install_advanced_device_chosen(GtkCellRenderer *, gchar *path, main_window *widgets){
|
|
|
|
|
gtk_list_store_clear(widgets->PartitionsList);
|
|
|
|
|
yon_advanced_partition_clear(widgets);
|
|
|
|
|
yon_advanced_section_remove_all();
|
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(widgets->DevicesList);
|
|
|
|
|
|
|
|
|
|
int chosen = 0;
|
|
|
|
|
chosen = yon_advanced_get_part_size(widgets);
|
|
|
|
|
// int chosen = 0;
|
|
|
|
|
// chosen = yon_advanced_get_part_size(widgets);
|
|
|
|
|
|
|
|
|
|
if (gtk_tree_model_get_iter_from_string(model,&iter,path)){
|
|
|
|
|
int status;
|
|
|
|
|
char *target;
|
|
|
|
|
gtk_tree_model_get(model,&iter,0,&target,5,&status,-1);
|
|
|
|
|
if (!status){ // checks
|
|
|
|
|
if (chosen <2){
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,5,!status,-1);
|
|
|
|
|
chosen++;
|
|
|
|
|
} else {
|
|
|
|
|
for_iter (model,&iter){
|
|
|
|
|
gtk_tree_model_get(model,&iter,5,&status,-1);
|
|
|
|
|
if (!status){
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,6,0,-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,5,!status,-1);
|
|
|
|
|
|
|
|
|
|
} else { // unchecks
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,5,!status,-1);
|
|
|
|
|
if (chosen == 2){
|
|
|
|
|
for_iter (model,&iter){
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,6,1,-1);
|
|
|
|
|
}
|
|
|
|
|
for_iter (model,&iter){
|
|
|
|
|
gtk_list_store_set(widgets->DevicesList,&iter,6,1,-1);
|
|
|
|
|
}
|
|
|
|
|
chosen--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chosen) gtk_widget_set_sensitive(widgets->AdvancedAddButton,1);
|
|
|
|
|
else gtk_widget_set_sensitive(widgets->AdvancedAddButton,0);
|
|
|
|
|
// if (chosen) gtk_widget_set_sensitive(widgets->AdvancedAddButton,1);
|
|
|
|
|
// else gtk_widget_set_sensitive(widgets->AdvancedAddButton,0);
|
|
|
|
|
yon_advanced_parts_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
yon_advanced_update(widgets);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_advanced_password_clicked(GtkWidget *, advanced_partition *part){
|
|
|
|
|
yon_password_open(GTK_ENTRY(part->EncryptionEntry));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_advanced_partition_clear(main_window *widgets){
|
|
|
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->AdvancedPartitionAddBox));
|
|
|
|
|
GList *iter;
|
|
|
|
|
for (iter=list;iter;iter=iter->next){
|
|
|
|
|
advanced_partition *part = g_object_get_data(G_OBJECT(iter->data),"advanced_partition");
|
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(iter->data));
|
|
|
|
|
free(part);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int yon_advanced_get_part_size(main_window *widgets){
|
|
|
|
|
int size = 0;
|
|
|
|
|
GList *list = gtk_container_get_children(GTK_CONTAINER(widgets->AdvancedPartitionAddBox));
|
|
|
|
|
size = g_list_length(list);
|
|
|
|
|
g_list_free(list);
|
|
|
|
|
return size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
advanced_partition *yon_advanced_partition_new(){
|
|
|
|
|
advanced_partition *part = new(advanced_partition);
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_advanced_part);
|
|
|
|
|
part->MainBox = yon_gtk_builder_get_widget(builder,"MainBox");
|
|
|
|
|
part->SectionLabel = yon_gtk_builder_get_widget(builder,"SectionLabel");
|
|
|
|
|
part->SystemSectionToggle = yon_gtk_builder_get_widget(builder,"SystemSectionToggle");
|
|
|
|
|
part->UserDataSectionToggle = yon_gtk_builder_get_widget(builder,"UserDataSectionToggle");
|
|
|
|
|
part->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton");
|
|
|
|
|
part->FormatSwitch = yon_gtk_builder_get_widget(builder,"FormatSwitch");
|
|
|
|
|
part->SizeSpin = yon_gtk_builder_get_widget(builder,"SizeSpin");
|
|
|
|
|
part->SizeCombo = yon_gtk_builder_get_widget(builder,"SizeCombo");
|
|
|
|
|
part->PartLabelEntry = yon_gtk_builder_get_widget(builder,"PartLabelEntry");
|
|
|
|
|
part->FileSystemTypeCombo = yon_gtk_builder_get_widget(builder,"FileSystemTypeCombo");
|
|
|
|
|
part->FileSystemLabelEntry = yon_gtk_builder_get_widget(builder,"FileSystemLabelEntry");
|
|
|
|
|
part->EncryptionCombo = yon_gtk_builder_get_widget(builder,"EncryptionCombo");
|
|
|
|
|
part->EncryptionEntry = yon_gtk_builder_get_widget(builder,"EncryptionEntry");
|
|
|
|
|
part->EncryptionButton = yon_gtk_builder_get_widget(builder,"EncryptionButton");
|
|
|
|
|
part->FormatRevealer = yon_gtk_builder_get_widget(builder,"FormatRevealer");
|
|
|
|
|
part->order_iter = NULL;
|
|
|
|
|
part->part = 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->SystemSectionToggle),"clicked",G_CALLBACK(on_advanced_system_toggled),part);
|
|
|
|
|
// g_signal_connect(G_OBJECT(part->UserDataSectionToggle),"clicked",G_CALLBACK(on_advanced_user_toggled),part);
|
|
|
|
|
|
|
|
|
|
g_object_set_data(G_OBJECT(part->MainBox),"advanced_partition",part);
|
|
|
|
|
g_object_set_data(G_OBJECT(part->RemoveButton),"advanced_partition",part);
|
|
|
|
|
|
|
|
|
|
return part;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_update(widgets);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|