diff --git a/gresource.xml b/gresource.xml index 5535760..0c44160 100644 --- a/gresource.xml +++ b/gresource.xml @@ -15,6 +15,7 @@ ubinstall-gtk-service-window.glade ubinstall-gtk-bootloader-user.glade ubinstall-gtk-network-box.glade + ubinstall-gtk-advanced-box.glade ubinstall-gtk.css diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 188d38a..8d983f6 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -72,6 +72,7 @@ set(DEPENDFILES ../ubinstall-gtk-service-window.glade ../ubinstall-gtk-bootloader-user.glade ../ubinstall-gtk-network-box.glade + ../ubinstall-gtk-advanced-box.glade ../gresource.xml ../ubinstall-gtk.css ../modules.csv diff --git a/source/ubinstall-gtk-installation.c b/source/ubinstall-gtk-installation.c index 6fb2980..7fae166 100644 --- a/source/ubinstall-gtk-installation.c +++ b/source/ubinstall-gtk-installation.c @@ -139,10 +139,10 @@ int yon_install_same_partition_save(main_window *widgets){ 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; + advanced_partition *first_section = yon_dictionary_get_data(dict->first,advanced_partition*); + advanced_partition *last_section = NULL; if (dict->first->next){ - last_section = yon_dictionary_get_data(dict->first->next,advanced_section*); + last_section = yon_dictionary_get_data(dict->first->next,advanced_partition*); } char *part_first = first_section->part; @@ -302,7 +302,7 @@ void on_device_selection_changed(GtkWidget *self, main_window *widgets){ long free_space_long = 0; char *fs_type = NULL; char *label = NULL; - + if (parsed_size>2){ char sizemod='\0'; capacity_long = atol(parsed[2]); @@ -359,7 +359,7 @@ void yon_devices_setup(main_window *widgets){ json_object_object_get_ex(device, "serial", &serial); gtk_list_store_append(widgets->DevicesList,&iter); - gtk_list_store_set(widgets->DevicesList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),-1); + gtk_list_store_set(widgets->DevicesList,&iter,0,json_object_get_string(path),1,json_object_get_string(model),2,json_object_get_string(serial),3,json_object_get_string(size),4,json_object_get_string(vendor),6,1,-1); } yon_char_parsed_free(parsed,size); @@ -541,14 +541,187 @@ void yon_install_init(main_window *widgets, enum YON_PAGES page){ } +void on_advanced_password_clicked(GtkWidget *, advanced_partition *part){ + yon_password_open(GTK_ENTRY(part->EncryptionEntry)); +} + +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->SectionMarkEntry = yon_gtk_builder_get_widget(builder,"SectionMarkEntry"); + part->FileSystemTypeCombo = yon_gtk_builder_get_widget(builder,"FileSystemTypeCombo"); + part->FileSystemMarkentry = yon_gtk_builder_get_widget(builder,"FileSystemMarkentry"); + 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"); + + 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_install_advanced_add_new(GtkWidget *, main_window *){ } -void on_install_advanced_device_chosen(GtkCellRenderer, gchar *, main_window *){ +void on_install_advanced_device_chosen(GtkCellRenderer *, gchar *path, main_window *widgets){ + gtk_list_store_clear(widgets->PartitionsList); + + int size; + config_str partitions; + partitions = yon_config_load(yon_debug_output("%s\n",get_parts_and_devices_command),&size); + for (int i=0;iDevicesList); + + int chosen = 0; + for_iter (model,&iter){ + char *disk_path; + int status; + gtk_tree_model_get(model,&iter,0,&disk_path,5,&status,-1); + if (status) chosen++; + + } + + + if (gtk_tree_model_get_iter_from_string(model,&iter,path)){ + int status; + gtk_tree_model_get(model,&iter,5,&status,-1); + if (!status){ + 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); + } + } + + } + } else { + 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); + } + } + chosen--; + } + } + + if (chosen) gtk_widget_set_sensitive(widgets->AdvancedAddButton,1); + else gtk_widget_set_sensitive(widgets->AdvancedAddButton,0); + + for_iter (model,&iter){ + char *disk_path; + int status; + gtk_tree_model_get(model,&iter,0,&disk_path,5,&status,-1); + if (!status) continue; + + for (int i=0;i2){ + 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]; + } + + 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); + } + yon_char_parsed_free(parsed,parsed_size); + } + } + } } -void on_install_advanced_partition_chosen(GtkCellRenderer, gchar *, main_window *){ +void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_window *widgets){ + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(widgets->PartitionsList); + + int chosen = 0; + + for_iter(model,&iter){ + int status; + gtk_tree_model_get(model,&iter,7,&status,-1); + if (status) chosen++; + } + + gtk_tree_model_get_iter_from_string(model,&iter,path); + int status; + gtk_tree_model_get(model,&iter,7,&status,-1); + if (!status){ + if (chosen<2){ + gtk_list_store_set(widgets->PartitionsList,&iter,7,!status,-1); + chosen++; + advanced_partition *part = yon_advanced_partition_new(); + gtk_box_pack_start(GTK_BOX(widgets->AdvancedPartitionAddBox),part->MainBox,0,0,0); + gtk_widget_show(part->MainBox); + } + if (chosen>=2){ + for_iter(model,&iter){ + gtk_tree_model_get(model,&iter,7,&status,-1); + if (!status){ + gtk_list_store_set(widgets->PartitionsList,&iter,8,0,-1); + } + } + } + } else { + gtk_list_store_set(widgets->PartitionsList,&iter,7,!status,-1); + if (chosen==2) + for_iter (model,&iter){ + gtk_list_store_set(widgets->PartitionsList,&iter,8,1,-1); + } + chosen--; + } } \ No newline at end of file diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index 4ef6110..4b8b4a9 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -369,8 +369,8 @@ main_window *yon_main_window_complete(){ widgets->NextInstallationSysSectionTree = yon_gtk_builder_get_widget(builder,"NextInstallationSysSectionTree"); widgets->GpartedNextInstallationButton = yon_gtk_builder_get_widget(builder,"GpartedNextInstallationButton"); - widgets->AdvancedDevicesCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedDevicesCell")); - widgets->AdvancedPartitionsCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedPartitionsCell")); + widgets->AdvancedDeviceChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedDeviceChosenCell")); + widgets->AdvancedPartChosenCell = GTK_CELL_RENDERER(gtk_builder_get_object(builder,"AdvancedPartChosenCell")); widgets->AdvancedDeviceTree = yon_gtk_builder_get_widget(builder,"AdvancedDeviceTree"); widgets->AdvancedVirtualDeviceCombo = yon_gtk_builder_get_widget(builder,"AdvancedVirtualDeviceCombo"); widgets->AdvancedPartitionTree = yon_gtk_builder_get_widget(builder,"AdvancedPartitionTree"); @@ -631,8 +631,8 @@ main_window *yon_main_window_complete(){ g_signal_connect(G_OBJECT(widgets->NetworkNTPCombo),"changed",G_CALLBACK(on_ntp_sync),widgets); g_signal_connect(G_OBJECT(widgets->AdvancedAddButton),"clicked",G_CALLBACK(on_install_advanced_add_new),widgets); - g_signal_connect(G_OBJECT(widgets->AdvancedDevicesCell),"toggled",G_CALLBACK(on_install_advanced_device_chosen),widgets); - g_signal_connect(G_OBJECT(widgets->AdvancedPartitionsCell),"toggled",G_CALLBACK(on_install_advanced_partition_chosen),widgets); + g_signal_connect(G_OBJECT(widgets->AdvancedDeviceChosenCell),"toggled",G_CALLBACK(on_install_advanced_device_chosen),widgets); + g_signal_connect(G_OBJECT(widgets->AdvancedPartChosenCell),"toggled",G_CALLBACK(on_install_advanced_partition_chosen),widgets); { diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 94fd98c..25fc273 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -32,6 +32,7 @@ #define glade_path_kernel_row "/com/ublinux/ui/ubinstall-gtk-kernel-row.glade" #define glade_path_service "/com/ublinux/ui/ubinstall-gtk-service-window.glade" #define glade_path_bootloader_user "/com/ublinux/ui/ubinstall-gtk-bootloader-user.glade" +#define glade_path_advanced_part "/com/ublinux/ui/ubinstall-gtk-advanced-box.glade" #define CssPath "/com/ublinux/css/ubinstall-gtk.css" #define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) @@ -616,8 +617,8 @@ typedef struct { GtkWidget *NetworkConnectionsAddButton; GHashTable *network_connections; - GtkCellRenderer *AdvancedDevicesCell; - GtkCellRenderer *AdvancedPartitionsCell; + GtkCellRenderer *AdvancedDeviceChosenCell; + GtkCellRenderer *AdvancedPartChosenCell; GtkWidget *AdvancedDeviceTree; GtkWidget *AdvancedVirtualDeviceCombo; GtkWidget *AdvancedPartitionTree; @@ -644,11 +645,12 @@ typedef struct { typedef struct { GtkWidget *MainBox; + GtkWidget *SectionLabel; GtkWidget *SystemSectionToggle; GtkWidget *UserDataSectionToggle; GtkWidget *RemoveButton; GtkWidget *FormatSwitch; - GtkWidget *FormatExpander; + GtkWidget *FormatRevealer; GtkWidget *SizeSpin; GtkWidget *SizeCombo; GtkWidget *SectionMarkEntry; @@ -659,7 +661,7 @@ typedef struct { GtkWidget *EncryptionButton; char *part; -} advanced_section; +} advanced_partition; typedef struct { GtkWidget *Window; @@ -998,6 +1000,8 @@ void yon_os_components_init(main_window *widgets); void yon_pacman_init(main_window *widgets); void yon_software_init(main_window *widgets); void on_install_advanced_add_new(GtkWidget *, main_window *widgets); -void on_install_advanced_device_chosen(GtkCellRenderer, gchar *path, main_window *widgets); -void on_install_advanced_partition_chosen(GtkCellRenderer, gchar *path, main_window *widgets); -void yon_devices_setup(main_window *widgets); \ No newline at end of file +void on_install_advanced_device_chosen(GtkCellRenderer*, gchar *path, main_window *widgets); +void on_install_advanced_partition_chosen(GtkCellRenderer*, gchar *path, main_window *widgets); +void yon_devices_setup(main_window *widgets); +void on_advanced_password_clicked(GtkWidget *, advanced_partition *part); +advanced_partition *yon_advanced_partition_new(); \ No newline at end of file diff --git a/ubinstall-gtk-advanced-box.glade b/ubinstall-gtk-advanced-box.glade index 0a883d0..ead6d05 100644 --- a/ubinstall-gtk-advanced-box.glade +++ b/ubinstall-gtk-advanced-box.glade @@ -23,7 +23,7 @@ False com.ublinux.libublsettingsui-gtk3.edit-symbolic - + True False vertical @@ -55,7 +55,7 @@ - + True False /dev/sdb @@ -156,10 +156,9 @@ - + True - True - True + False True @@ -364,6 +363,9 @@ True True image4 + False @@ -380,9 +382,6 @@ - - - False diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index b5b1e9d..4151879 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1,5 +1,5 @@ - + @@ -44,6 +44,10 @@ + + + + @@ -161,6 +165,10 @@ + + + + @@ -6847,28 +6855,155 @@ separately into the selected partition. - + True - False - vertical - 5 + True + in - + True False - vertical - 5 True False + vertical 5 - + True False - Select device: - 0 + vertical + 5 + + + True + False + 5 + + + True + False + Select device: + 0 + + + False + True + 0 + + + + + True + True + True + image20 + + + + False + True + end + 1 + + + + + False + True + 0 + + + + + True + True + in + 105 + + + True + True + DevicesList + 0 + + + + + + 6 + 5 + + + + + + + Device + + + + 0 + + + + + + + Description + + + + 1 + + + + + + + Label + + + + 2 + + + + + + + Size + + + + 3 + + + + + + + Serial + + + + 4 + + + + + + + + + False + True + 1 + + False @@ -6877,476 +7012,149 @@ separately into the selected partition. - + True - True - True - image20 - + False + 5 + + + True + False + Virtual device type: + 0 + + + False + True + 0 + + + + + True + False + False + 0 + + No + RAID0 + RAID1 + DAID4 + RAID5 + RAID6 + LVM + LVM_DYNAMIC + + + + False + True + 1 + + False True - end 1 - - - False - True - 0 - - - - - True - True - in - + True - True - DevicesList - 0 - - - Device - - - - 0 - - - - - - - Description - - - - 1 - - - - - - - Label - - - - 2 - - - - + False + vertical + 5 - - Size - - - - 3 - - + + True + False + Select partiton: + 0 + + False + True + 0 + - - Serial + + True + True + in + 140 - - - 4 - - - - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - Virtual device type: - 0 - - - False - True - 0 - - - - - True - False - 0 - - No - RAID0 - RAID1 - DAID4 - RAID5 - RAID6 - LVM - LVM_DYNAMIC - - - - False - True - 1 - - - - - False - True - 1 - - - - - True - False - vertical - 5 - - - True - False - Select partiton: - 0 - - - False - True - 0 - - - - - True - True - in - - - True - True - PartitionsList - 0 - - - Section - - - - 0 - - - - - - - Capacity - - - - 1 - - - - - - - Free space - - - - 2 - - - - - - - File system - - - - 3 - - - - - - - Label - - - - 4 - - - - - - - - - False - True - 1 - - - - - False - True - 2 - - - - - True - False - vertical - 5 - - - - - - + - True - True - True - - - - False - True - 2 - - - - - False - True - 3 - - - - - True - False - 5 - - - True - False - start - 0 - none - - - True - False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - True - False - Load type - - - False - True - 0 - - - - + True True - False - True - - - - - - - False - True - end - 1 - - - - - True - True - - - False - True - end - 2 - - - - - False - True - 0 - - - - - True - False - none - True - - - True - False - vertical - 5 + PartitionsList + 0 - - True - False + + + + + 8 + 7 + + - - False - True - 0 - - - True - False - 5 + + Section - - True - False - BIOS Boot sector - - - False - True - 0 - + + + 0 + + + + + + Capacity - - True - True - - - False - True - end - 2 - + + + 1 + - - False - True - 1 - - - True - False + + Free space + + + + 2 + + - - False - True - 2 - - - True - False - 5 + + File system - - True - False - EFI section - - - False - True - 0 - + + + 3 + + + + + + Label - - True - True - - - False - True - end - 2 - + + + 4 + - - False - True - 4 - @@ -7358,86 +7166,26 @@ separately into the selected partition. + + False + True + 2 + - - - - - - - True - True - 0 - - - - - True - False - 0 - none True False - 5 - 5 - 5 - 5 vertical 5 - + True False + vertical 5 - - True - False - Swap file - - - False - True - 0 - - - - - True - True - False - True - - - - - - - False - True - end - 1 - - - - - True - True - - - False - True - end - 2 - + @@ -7447,28 +7195,51 @@ separately into the selected partition. - + + + + True + False + True + True + + + + False + True + 2 + + + + + False + True + 3 + + + + + True + False + 5 + + True False - none - True + start + 0 + none True False + 5 + 5 + 5 + 5 vertical 5 - - - True - False - - - False - True - 0 - - True @@ -7478,7 +7249,7 @@ separately into the selected partition. True False - Automatically + Load type False @@ -7487,54 +7258,29 @@ separately into the selected partition. - + True True + False + True + + + + False True end - 2 - - - - - False - True - 1 - - - - - True - False - - - False - True - 2 - - - - - True - False - 5 - - - True - False - Corresponds to RAM size - - - False - True - 0 + 1 - + True True @@ -7549,20 +7295,155 @@ separately into the selected partition. False True - 3 + 0 - + True False + none + True + + + True + False + vertical + 5 + + + True + False + + + False + True + 0 + + + + + True + False + 5 + + + True + False + BIOS Boot sector + + + False + True + 0 + + + + + True + True + + + False + True + end + 2 + + + + + False + True + 1 + + + + + True + False + + + False + True + 2 + + + + + True + False + 5 + + + True + False + EFI section + + + False + True + 0 + + + + + True + True + + + False + True + end + 2 + + + + + False + True + 4 + + + + False True - 4 + 1 + + + + + + + + + True + True + 0 + + + + + True + False + 0 + none + + + True + False + 5 + 5 + 5 + 5 + vertical + 5 True @@ -7572,7 +7453,7 @@ separately into the selected partition. True False - Fixed size: + Swap file False @@ -7581,18 +7462,29 @@ separately into the selected partition. - + True True + False + True + + + + False True + end 1 - + True True @@ -7603,82 +7495,250 @@ separately into the selected partition. 2 + + + False + True + 0 + + + + + True + False + none + True - - True - False - Mb - - - False - True - 3 - - - - - True - True - - - False - True - 4 - - - - + True False - Gb + vertical + 5 + + + True + False + + + False + True + 0 + + + + + True + False + 5 + + + True + False + Automatically + + + False + True + 0 + + + + + True + True + + + False + True + end + 2 + + + + + False + True + 1 + + + + + True + False + + + False + True + 2 + + + + + True + False + 5 + + + True + False + Corresponds to RAM size + + + False + True + 0 + + + + + True + True + + + False + True + end + 2 + + + + + False + True + 3 + + + + + True + False + + + False + True + 4 + + + + + True + False + 5 + + + True + False + Fixed size: + + + False + True + 0 + + + + + True + True + + + False + True + 1 + + + + + True + True + + + False + True + end + 2 + + + + + True + False + Mb + + + False + True + 3 + + + + + True + True + + + False + True + 4 + + + + + True + False + Gb + + + False + True + 5 + + + + + False + True + 5 + + - - False - True - 5 - False True - 5 + 1 + + + + - False + True True 1 + + False + True + 4 + - - - - - - True - True - 1 - - - False - True - 4 - - False + True True 2