You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
333 lines
18 KiB
333 lines
18 KiB
#include "ubinstall-gtk.h"
|
|
|
|
int yon_install_common_save(main_window *widgets){
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->CommonInstallationDevicesTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->CommonInstallationDevicesTree));
|
|
return 0;
|
|
}
|
|
char *device;
|
|
yon_config_remove_by_key(part_size_parameter);
|
|
yon_config_remove_by_key(part_parameter);
|
|
gtk_tree_model_get(model,&iter,0,&device,-1);
|
|
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"fast");
|
|
yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
|
|
|
|
char *device_name = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->CommonInstallationSectionNameEntry));
|
|
if (!yon_char_is_empty(device_name)){
|
|
yon_config_register(part_label_parameter,part_label_parameter_command,device_name);
|
|
} else {
|
|
yon_config_remove_by_key(part_label_parameter);
|
|
}
|
|
|
|
char *file_system_type = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->CommonInstallationFilesystemTypeCombo));
|
|
if (!yon_char_is_empty(file_system_type)){
|
|
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
|
|
} else {
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int yon_install_separate_save(main_window *widgets){
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->NextInstallationSysDevicesTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->CommonInstallationDevicesTree));
|
|
return 0;
|
|
}
|
|
char *device;
|
|
gtk_tree_model_get(model,&iter,0,&device,-1);
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->NextInstallationSysSectionTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->CommonInstallationDevicesTree));
|
|
return 0;
|
|
}
|
|
if (gtk_switch_get_active(GTK_SWITCH(widgets->NextInstallationFormatSwitch))){
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,"yes");
|
|
double part_size = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->NextInstallationSizeSpin));
|
|
if (part_size){
|
|
char *size_letter = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->NextInstallationSizeTypeSpin));
|
|
char *size_final = yon_char_append(yon_char_from_long((long)part_size),size_letter);
|
|
yon_config_register(part_size_parameter,part_size_parameter_command,size_final);
|
|
} else {
|
|
yon_config_remove_by_key(part_size_parameter);
|
|
}
|
|
|
|
char *device_name = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->NextInstallationSectionNameEntry));
|
|
if (!yon_char_is_empty(device_name)){
|
|
yon_config_register(part_label_parameter,part_label_parameter_command,device_name);
|
|
} else {
|
|
yon_config_remove_by_key(part_label_parameter);
|
|
|
|
}
|
|
|
|
char *file_system_type = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->NextInstallationFilesystemTypeCombo));
|
|
if (!yon_char_is_empty(file_system_type)){
|
|
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
|
|
|
|
} else {
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
|
|
}
|
|
} else {
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,"no");
|
|
yon_config_remove_by_key(part_label_parameter);
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
yon_config_remove_by_key(part_format_parameter);
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
yon_config_remove_by_key(part_format_parameter);
|
|
}
|
|
|
|
char *part;
|
|
gtk_tree_model_get(model,&iter,0,&part,-1);
|
|
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"next");
|
|
yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
|
|
yon_config_register(part_parameter,part_parameter_command,part);
|
|
return 1;
|
|
}
|
|
|
|
int yon_install_same_partition_save(main_window *widgets){
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SamePlaceDeviceTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->CommonInstallationDevicesTree));
|
|
return 0;
|
|
}
|
|
char *device;
|
|
gtk_tree_model_get(model,&iter,0,&device,-1);
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->SamePlacePartTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->CommonInstallationDevicesTree));
|
|
return 0;
|
|
}
|
|
yon_config_remove_by_key(part_size_parameter);
|
|
char *part;
|
|
gtk_tree_model_get(model,&iter,0,&part,-1);
|
|
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"part");
|
|
yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
|
|
yon_config_register(part_parameter,part_parameter_command,part);
|
|
|
|
if (gtk_switch_get_active(GTK_SWITCH(widgets->SameInstallationFormatSwitch))){
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,"yes");
|
|
char *device_name = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->SameInstallationSectionNameEntry));
|
|
if (!yon_char_is_empty(device_name)){
|
|
yon_config_register(part_label_parameter,part_label_parameter_command,device_name);
|
|
} else {
|
|
yon_config_remove_by_key(part_label_parameter);
|
|
}
|
|
|
|
char *file_system_type = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->SameInstallationFilesystemTypeCombo));
|
|
if (!yon_char_is_empty(file_system_type)){
|
|
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
|
|
} else {
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
|
|
}
|
|
} else {
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,"no");
|
|
yon_config_remove_by_key(part_label_parameter);
|
|
yon_config_remove_by_key(part_format_parameter);
|
|
yon_config_remove_by_key(part_type_parameter);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int yon_advanced_sections_save(dictionary *dict){
|
|
if (!dict) return 0;
|
|
advanced_section *first_section = yon_dictionary_get_data(dict->first,advanced_section*);
|
|
advanced_section *last_section = NULL;
|
|
if (dict->first->next){
|
|
last_section = yon_dictionary_get_data(dict->first->next,advanced_section*);
|
|
}
|
|
|
|
char *part_first = first_section->part;
|
|
char *part_last = last_section?last_section->part:NULL;
|
|
char *part = yon_char_unite(part_first,last_section?",":NULL,part_last,NULL);
|
|
yon_config_register(part_parameter,part_parameter_command,part);
|
|
|
|
char * format_first = gtk_switch_get_active(GTK_SWITCH(first_section->FormatSwitch))?"yes":"no";
|
|
char * format_last = last_section?gtk_switch_get_active(GTK_SWITCH(last_section->FormatSwitch))?"yes":"no":NULL;
|
|
char *format = yon_char_unite(format_first,part_last?",":NULL,format_last,NULL);
|
|
yon_config_register(part_format_parameter,part_format_parameter_command,format);
|
|
|
|
if (!yon_char_is_empty(format)){
|
|
char *size_first = g_strdup_printf("%d%s",gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(first_section->SizeSpin)),yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(first_section->SizeCombo))));
|
|
char *size_last = last_section&&!strcmp(format_last,"yes")?g_strdup_printf("%d%s",gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(last_section->SizeSpin)),yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(last_section->SizeCombo)))):NULL;
|
|
char *size = yon_char_unite(size_first,size_last?",":NULL,size_last,NULL);
|
|
yon_config_register(part_size_parameter,part_size_parameter_command,size);
|
|
|
|
char *part_label_first = (char*)gtk_entry_get_text(GTK_ENTRY(first_section->SectionMarkEntry));
|
|
char *part_label_last = last_section&&!strcmp(format_last,"yes")?(char*)gtk_entry_get_text(GTK_ENTRY(last_section->SectionMarkEntry)):NULL;
|
|
char *part_label = yon_char_unite(part_label_first,part_label_last?",":NULL,part_label_last,NULL);
|
|
yon_config_register(part_label_parameter,part_label_parameter_command,part_label);
|
|
|
|
char *fs_label_first = (char*)gtk_entry_get_text(GTK_ENTRY(first_section->FileSystemMarkentry));
|
|
char *fs_label_last = last_section&&!strcmp(format_last,"yes")?(char*)gtk_entry_get_text(GTK_ENTRY(last_section->FileSystemMarkentry)):NULL;
|
|
char *fs_label = yon_char_unite(fs_label_first,fs_label_last?",":NULL,fs_label_last,NULL);
|
|
yon_config_register(part_fs_label_parameter,part_fs_label_parameter_command,fs_label);
|
|
|
|
char *fs_type_first = (char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(first_section->FileSystemTypeCombo));
|
|
char *fs_type_last = last_section&&!strcmp(format_last,"yes")?(char*)gtk_combo_box_get_active_id(GTK_COMBO_BOX(last_section->FileSystemTypeCombo)):NULL;
|
|
char *fs_type = yon_char_unite(fs_type_first,fs_type_last?",":NULL,fs_type_last,NULL);
|
|
yon_config_register(part_type_parameter,part_type_parameter_command,fs_type);
|
|
|
|
char *part_crypt_first = gtk_combo_box_get_active(GTK_COMBO_BOX(first_section->EncryptionCombo))?(char*)gtk_entry_get_text(GTK_ENTRY(first_section->EncryptionEntry)):NULL;
|
|
char *part_crypt_last = last_section&&!strcmp(format_last,"yes")&>k_combo_box_get_active(GTK_COMBO_BOX(last_section->EncryptionCombo))?(char*)gtk_entry_get_text(GTK_ENTRY(first_section->EncryptionEntry)):NULL;
|
|
char *part_crypt = NULL;
|
|
if (part_crypt_first||part_crypt_last){
|
|
part_crypt = yon_char_unite(part_crypt_first,part_crypt_last?",":NULL,part_crypt_last,NULL);
|
|
}
|
|
if (part_crypt){
|
|
yon_config_register(part_crypt_parameter,part_crypt_parameter_command,part_crypt);
|
|
} else {
|
|
yon_config_remove_by_key(part_crypt_parameter);
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
int yon_install_advanced_save(main_window *widgets){
|
|
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->AdvancedDeviceTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->AdvancedDeviceTree));
|
|
return 0;
|
|
}
|
|
char *device;
|
|
gtk_tree_model_get(model,&iter,0,&device,-1);
|
|
if (!gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->AdvancedPartitionTree)),&model,&iter)){
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(widgets->StatusBox),NO_DEVICE_CHOSEN_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
yon_ubl_status_highlight_incorrect(gtk_widget_get_parent(widgets->AdvancedPartitionTree));
|
|
return 0;
|
|
}
|
|
yon_config_remove_by_key(part_size_parameter);
|
|
char *part;
|
|
gtk_tree_model_get(model,&iter,0,&part,-1);
|
|
|
|
if (!yon_advanced_sections_save(widgets->advanced_sections)){
|
|
return 0;
|
|
}
|
|
|
|
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_size_parameter_command,"ram");
|
|
} else {
|
|
yon_config_register(swap_parameter,swap_parameter_command,"yes");
|
|
char *swap = g_strdup_printf("%d%s",gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->AdvancedSwapFixedSpin)),yon_size_get_mod(gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->AdvancedSwapFixedSizeSwitch))+1));
|
|
yon_config_register(swap_size_parameter,swap_size_parameter_command,swap);
|
|
}
|
|
}
|
|
const char *device_typevfs = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widgets->AdvancedVirtualDeviceCombo));
|
|
if (!yon_char_is_empty(device_typevfs)){
|
|
yon_config_register(device_typevfs_parameter,device_typevfs_parameter_command,(char*)device_typevfs);
|
|
} else {
|
|
yon_config_remove_by_key(device_typevfs_parameter);
|
|
}
|
|
if (gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedLoadTypeSwitch))){
|
|
char *bios = gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedBiosSectorSwitch))?"bios":"";
|
|
char *efi = gtk_switch_get_active(GTK_SWITCH(widgets->AdvancedEFISwitch))?"efi":NULL;
|
|
char *boot = yon_char_unite(bios,!yon_char_is_empty(bios)&&!yon_char_is_empty(efi)?"+":"",efi,NULL);
|
|
yon_config_register(boot_parameter,boot_parameter_command,boot);
|
|
} else {
|
|
yon_config_register(boot_parameter,boot_parameter_command,"none");
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
void yon_set_max_size_from_partition(GtkTreeView *table, GtkSpinButton *spin_button, GtkComboBox *spin_combo){
|
|
GtkTreeModel *model;
|
|
GtkTreeIter iter;
|
|
long selected_size;
|
|
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(table),&model,&iter)){
|
|
gtk_tree_model_get(model,&iter,6,&selected_size,-1);
|
|
if (!selected_size){
|
|
gtk_tree_model_get(model,&iter,5,&selected_size,-1);
|
|
}
|
|
if (selected_size){
|
|
GtkAdjustment *adj = gtk_spin_button_get_adjustment(spin_button);
|
|
const char *sizemod = gtk_combo_box_get_active_id(spin_combo);
|
|
double new_size = yon_size_long_convert_to_mod(selected_size,sizemod[0]);
|
|
gtk_adjustment_set_upper(adj,new_size);
|
|
gdouble old_value = gtk_adjustment_get_value(adj);
|
|
if (old_value>new_size){
|
|
gtk_adjustment_set_value(adj,new_size);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void on_partition_changed(GtkWidget *self, main_window *widgets){
|
|
if (self==widgets->NextInstallationSysSectionTree||self == widgets->NextInstallationSizeTypeSpin){
|
|
yon_set_max_size_from_partition(GTK_TREE_VIEW(widgets->NextInstallationSysSectionTree),GTK_SPIN_BUTTON(widgets->NextInstallationSizeSpin),GTK_COMBO_BOX(widgets->NextInstallationSizeTypeSpin));
|
|
}
|
|
|
|
}
|
|
|
|
void on_device_selection_changed(GtkWidget *self, main_window *widgets){
|
|
gtk_list_store_clear(widgets->PartitionsList);
|
|
GtkTreeIter iter;
|
|
GtkTreeModel *model;
|
|
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(self)),&model,&iter)){
|
|
char *disk_path;
|
|
gtk_tree_model_get(model,&iter,0,&disk_path,-1);
|
|
int size;
|
|
config_str partitions;
|
|
partitions = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size);
|
|
for (int i=0;i<size;i++){
|
|
yon_char_remove_last_symbol(partitions[i],'\n');
|
|
int parsed_size;
|
|
config_str parsed = yon_char_parse(partitions[i],&parsed_size,";");
|
|
if (!strcmp(parsed[0],"part")){
|
|
char *name = parsed[1];
|
|
if (strstr(name,disk_path)){
|
|
char *capacity = NULL;
|
|
long capacity_long = 0;
|
|
char *free_space = NULL;
|
|
long free_space_long = 0;
|
|
char *fs_type = NULL;
|
|
char *label = NULL;
|
|
|
|
if (parsed_size>2){
|
|
char sizemod='\0';
|
|
capacity_long = atol(parsed[2]);
|
|
|
|
char *temp = yon_char_from_double(yon_size_long_convert_automatic(capacity_long,&sizemod));
|
|
capacity = yon_char_append_c(temp,sizemod);
|
|
free(temp);
|
|
}
|
|
if (parsed_size>7&&!yon_char_is_empty(parsed[7])){
|
|
char sizemod='\0';
|
|
free_space_long = capacity_long-atol(parsed[7]);
|
|
char *temp = yon_char_from_double(yon_size_long_convert_automatic(free_space_long,&sizemod));
|
|
free_space = yon_char_append_c(temp,sizemod);
|
|
free(temp);
|
|
}
|
|
if (parsed_size>3){
|
|
fs_type = parsed[3];
|
|
}
|
|
if (parsed_size>4){
|
|
label = parsed[4];
|
|
}
|
|
|
|
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);
|
|
}
|
|
yon_char_parsed_free(parsed,parsed_size);
|
|
}
|
|
}
|
|
gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->NextInstallationSizeSpin),0.0);
|
|
gtk_adjustment_set_upper(gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(widgets->NextInstallationSizeSpin)),0.0);
|
|
}
|
|
}
|