diff --git a/source/ubinstall-gtk.c b/source/ubinstall-gtk.c index b5183c4..0594050 100644 --- a/source/ubinstall-gtk.c +++ b/source/ubinstall-gtk.c @@ -256,6 +256,21 @@ double yon_size_long_convert_to_mod(double size, char mod){ return final_size; } +void on_source_changed(GtkComboBox *self){ + GtkWidget *devices_combo = g_object_get_data(G_OBJECT(self),"target"); + GtkWidget *path_button = g_object_get_data(G_OBJECT(self),"button"); + GtkWidget *path_combo = g_object_get_data(G_OBJECT(self),"combo"); + if (gtk_combo_box_get_active(self)){ + gtk_widget_show(path_button); + gtk_widget_show(path_combo); + gtk_widget_hide(devices_combo); + } else{ + gtk_widget_hide(path_button); + gtk_widget_hide(path_combo); + gtk_widget_show(devices_combo); + } +} + source_element *yon_source_element_new(){ source_element *element = new(source_element); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path_source_element); @@ -263,12 +278,30 @@ source_element *yon_source_element_new(){ element->MainBox = yon_gtk_builder_get_widget(builder,"MainBox"); element->TypeCombo = yon_gtk_builder_get_widget(builder,"TypeCombo"); element->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry"); + element->DeviceCombo = yon_gtk_builder_get_widget(builder,"DeviceCombo"); element->PathButton = yon_gtk_builder_get_widget(builder,"PathButton"); element->RemoveButton = yon_gtk_builder_get_widget(builder,"RemoveButton"); g_signal_connect(G_OBJECT(element->RemoveButton),"clicked",G_CALLBACK(on_source_remove),element); g_signal_connect(G_OBJECT(element->PathButton),"clicked",G_CALLBACK(on_source_choose),element); + g_signal_connect(G_OBJECT(element->TypeCombo),"changed",G_CALLBACK(on_source_changed),element); g_object_set_data(G_OBJECT(element->PathButton),"combo",element->TypeCombo); + g_object_set_data(G_OBJECT(element->PathButton),"target_combo",element->TypeCombo); + g_object_set_data(G_OBJECT(element->TypeCombo),"target",element->DeviceCombo); + g_object_set_data(G_OBJECT(element->TypeCombo),"button",element->PathButton); + g_object_set_data(G_OBJECT(element->TypeCombo),"combo",element->PathEntry); + int size; + config_str parts = yon_config_load(get_parts_and_devices_command, &size); + for (int i=0;iDeviceCombo),parsed[1],parsed[1]); + } + yon_char_parsed_free(parsed,parsed_size); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(element->DeviceCombo),0); + yon_char_parsed_free(parts,size); return element; } @@ -291,7 +324,7 @@ void yon_source_update(source_window *window){ } void on_source_add(GtkWidget *,source_window *window){ - const char *path = gtk_entry_get_text(GTK_ENTRY(window->PathEntry)); + const char *path = gtk_widget_get_visible(window->PathEntry)?gtk_entry_get_text(GTK_ENTRY(window->PathEntry)):gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceCombo)); if (!g_hash_table_contains(window->sources,path)){ g_hash_table_add(window->sources,yon_char_new(path)); yon_source_update(window); @@ -311,9 +344,6 @@ void on_source_choose(GtkWidget *self){ GtkWidget *target_entry = g_object_get_data(G_OBJECT(self),"target"); GtkWidget *target_mode = g_object_get_data(G_OBJECT(self),"combo"); switch (gtk_combo_box_get_active(GTK_COMBO_BOX(target_mode))){ - case 0: { - - } break; case 1:{ filechooser_window *dialog = yon_file_chooser_window_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); yon_gtk_window_setup(GTK_WINDOW(dialog->Window),GTK_WINDOW(dialog->Window),OPEN_LABEL,icon_path,"filechooser_window"); @@ -343,6 +373,8 @@ void on_source_choose(GtkWidget *self){ void on_source_accept(GtkWidget *,source_window *window){ if (gtk_switch_get_active(GTK_SWITCH(window->AutoSwitch))){ yon_config_register(source_parameter,source_parameter_command,"auto"); + on_subwindow_close(window->Window); + return; } guint size; config_str paths = (config_str)g_hash_table_get_keys_as_array(window->sources,&size); @@ -380,6 +412,7 @@ source_window *yon_source_window_new(){ window->AutoSwitch = yon_gtk_builder_get_widget(builder,"AutoSwitch"); window->TypeCombo = yon_gtk_builder_get_widget(builder,"TypeCombo"); window->PathEntry = yon_gtk_builder_get_widget(builder,"PathEntry"); + window->DeviceCombo = yon_gtk_builder_get_widget(builder,"DeviceCombo"); window->PathButton = yon_gtk_builder_get_widget(builder,"PathButton"); window->AddButton = yon_gtk_builder_get_widget(builder,"AddButton"); window->AddBox = yon_gtk_builder_get_widget(builder,"AddBox"); @@ -389,13 +422,25 @@ source_window *yon_source_window_new(){ g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_source_accept),window); g_signal_connect(G_OBJECT(window->AddButton),"clicked",G_CALLBACK(on_source_add),window); g_signal_connect(G_OBJECT(window->PathButton),"clicked",G_CALLBACK(on_source_choose),window); - g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),window->AddBox); - g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),window->TypeCombo); - g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),window->AddButton); - g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),window->PathButton); - g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),window->PathEntry); + g_signal_connect(G_OBJECT(window->TypeCombo),"changed",G_CALLBACK(on_source_changed),window); + g_signal_connect(G_OBJECT(window->AutoSwitch),"state-set",G_CALLBACK(yon_gtk_widget_set_sensitive_from_switch_inversed),gtk_widget_get_parent(window->AddBox)); g_object_set_data(G_OBJECT(window->PathButton),"combo",window->TypeCombo); g_object_set_data(G_OBJECT(window->PathButton),"target",window->PathEntry); + g_object_set_data(G_OBJECT(window->TypeCombo),"target",window->DeviceCombo); + g_object_set_data(G_OBJECT(window->TypeCombo),"button",window->PathButton); + g_object_set_data(G_OBJECT(window->TypeCombo),"combo",window->PathEntry); + int size; + config_str parts = yon_config_load(get_parts_and_devices_command, &size); + for (int i=0;iDeviceCombo),parsed[1],parsed[1]); + } + yon_char_parsed_free(parsed,parsed_size); + } + gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceCombo),0); + yon_char_parsed_free(parts,size); return window; } diff --git a/source/ubinstall-gtk.h b/source/ubinstall-gtk.h index 05e46ed..0279f03 100755 --- a/source/ubinstall-gtk.h +++ b/source/ubinstall-gtk.h @@ -923,6 +923,7 @@ typedef struct { GtkWidget *AutoSwitch; GtkWidget *TypeCombo; GtkWidget *PathEntry; + GtkWidget *DeviceCombo; GtkWidget *PathButton; GtkWidget *AddButton; GtkWidget *AddBox; @@ -933,6 +934,7 @@ typedef struct { GtkWidget *MainBox; GtkWidget *TypeCombo; GtkWidget *PathEntry; + GtkWidget *DeviceCombo; GtkWidget *PathButton; GtkWidget *RemoveButton; @@ -1197,4 +1199,5 @@ void on_advanced_virtual_device_changed(GtkWidget *, main_window *widgets); int yon_advanced_section_append(advanced_section *section); gboolean on_format_changed(GtkWidget *self, gboolean state, advanced_partition *part); int yon_layouts_get(); -void on_link(GtkWidget *self, char* uri, gpointer ); \ No newline at end of file +void on_link(GtkWidget *self, char* uri, gpointer ); +void on_source_changed(GtkComboBox *self); \ No newline at end of file diff --git a/ubinstall-gtk-source-element.glade b/ubinstall-gtk-source-element.glade index 8f1447b..3db4218 100644 --- a/ubinstall-gtk-source-element.glade +++ b/ubinstall-gtk-source-element.glade @@ -1,8 +1,18 @@ - + + + True + False + com.ublinux.libublsettingsui-gtk3.zoom-symbolic + + + True + False + com.ublinux.libublsettingsui-gtk3.trash-symbolic + True False @@ -26,7 +36,6 @@ - True True @@ -36,8 +45,19 @@ - + True + False + 0 + + + True + True + 2 + + + + True True image1 @@ -48,7 +68,7 @@ False True - 2 + 3 @@ -64,18 +84,8 @@ False True - 3 + 4 - - True - False - com.ublinux.libublsettingsui-gtk3.zoom-symbolic - - - True - False - com.ublinux.libublsettingsui-gtk3.trash-symbolic - diff --git a/ubinstall-gtk-source.glade b/ubinstall-gtk-source.glade index 6f95c26..dfc5a72 100644 --- a/ubinstall-gtk-source.glade +++ b/ubinstall-gtk-source.glade @@ -1,5 +1,5 @@ - + @@ -131,6 +131,7 @@ True + False False vertical 5 @@ -142,7 +143,6 @@ True - False False 0 @@ -159,8 +159,6 @@ - True - False True @@ -170,9 +168,19 @@ - + True - False + False + 0 + + + True + True + 2 + + + + True True image1 @@ -183,13 +191,12 @@ False True - 2 + 3 True - False True True image2 @@ -200,7 +207,7 @@ False True - 3 + 4 @@ -213,7 +220,6 @@ True - False False vertical 5 diff --git a/ubinstall-gtk.glade b/ubinstall-gtk.glade index da30ef4..35168c2 100644 --- a/ubinstall-gtk.glade +++ b/ubinstall-gtk.glade @@ -1,5 +1,5 @@ - + @@ -1532,40 +1532,90 @@ and help you install UBLinux on your computer True False - + True - True - in + False + vertical + 5 - + True False - 5 - 5 5 5 - 5 - 5 + 5 - + + True + True + + + False + True + 0 + + + + True False - vertical + Default + + + False + True + 1 + + + + + False + True + 0 + + + + + True + True + in + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 - + True False - none + vertical + + + True + False + none + + + True + True + 1 + + - - True - True - 1 - + + True + True + 1 +