diff --git a/source/controler.c b/source/controler.c index a3b34e0..65479b6 100644 --- a/source/controler.c +++ b/source/controler.c @@ -246,8 +246,8 @@ void device_remove() { GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.device.liststore); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.device.tree_view)); if(gtk_tree_selection_get_selected(selection, &model, &iter)) { - gtk_list_store_remove(cfg_custom_gui.device.liststore, &iter); int index = wrapper_select_tree_view(&cfg_custom_gui.device); + gtk_list_store_remove(cfg_custom_gui.device.liststore, &iter); if (index!=-1) { index_selected = -1; disk_status* _config = (disk_status*)all_config.v_disk_status.pfVectorGet(&all_config.v_disk_status, index); @@ -271,8 +271,7 @@ void device_remove() { -void template_remove(vector* vec_temp, hotebook* widgets) { - int index = wrapper_select_tree_view(widgets); +void template_remove(vector* vec_temp, hotebook* widgets, int index) { if (index!=-1) { index_selected = -1; config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index); @@ -290,9 +289,11 @@ void user_remove() { GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.user.liststore); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.user.tree_view)); if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + int index = wrapper_select_tree_view(&cfg_custom_gui.user); gtk_list_store_remove(cfg_custom_gui.user.liststore, &iter); + template_remove(&all_config.v_user, &cfg_custom_gui.user,index); } - template_remove(&all_config.v_user, &cfg_custom_gui.user); + } } @@ -302,9 +303,10 @@ void group_remove() { GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.group.liststore); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.group.tree_view)); if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + int index = wrapper_select_tree_view(&cfg_custom_gui.group); gtk_list_store_remove(cfg_custom_gui.group.liststore, &iter); + template_remove(&all_config.v_group ,&cfg_custom_gui.group,index); } - template_remove(&all_config.v_group ,&cfg_custom_gui.group); } } @@ -314,14 +316,16 @@ void project_remove() { GtkTreeModel *model = GTK_TREE_MODEL(cfg_custom_gui.project.liststore); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cfg_custom_gui.project.tree_view)); if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + int index = wrapper_select_tree_view(&cfg_custom_gui.project); gtk_list_store_remove(cfg_custom_gui.project.liststore, &iter); + template_remove(&all_config.v_project, &cfg_custom_gui.project, index); } - template_remove(&all_config.v_project , &cfg_custom_gui.project); + } } int wrapper_select_tree_view(hotebook* widgets) { - int index = 0; + int index = -1; GtkTreeIter iter; GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore); GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view)); diff --git a/source/model/my_device.c b/source/model/my_device.c index 8ece330..8b05ec6 100644 --- a/source/model/my_device.c +++ b/source/model/my_device.c @@ -66,9 +66,10 @@ void device_fill_disk(GtkWidget *combo_box_text, vector* vec_filt) disk_status* _config_disk_remove = (disk_status*)vec_filt->pfVectorGet(vec_filt, i); for (int index = 0; index < vec.vectorList.total; index++) { device_config* _config_disk = (device_config*)vec.pfVectorGet(&vec, index); - if (strstr(_config_disk->name_disk, _config_disk_remove->device)) { + if (strcmp(_config_disk->name_disk, _config_disk_remove->device) == 0) { vec.pfVectorDelete(&vec, index); - } + } + } }