From 1301ee0dcd4e62fe5f604c6411f95c5af2f82e68 Mon Sep 17 00:00:00 2001 From: Igor Belitskiy Date: Wed, 26 Jul 2023 15:00:18 +0600 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D1=82=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BF=D0=BE=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=8A=D0=B5=D0=B4=D0=B8=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=84?= =?UTF-8?q?=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=D1=85=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/controler.c | 228 +++++++++++++++++++++++++-------------------- source/controler.h | 1 - 2 files changed, 126 insertions(+), 103 deletions(-) diff --git a/source/controler.c b/source/controler.c index 49bd85a..cb783a3 100644 --- a/source/controler.c +++ b/source/controler.c @@ -8,7 +8,66 @@ int index_selected = -1; int note_selected = -1; // 0 user // 1 group -// 3 project +// 2 project + + + +void entry_user_disk(GtkWidget *self, int* flag_update) { + if (flag_update) { + all_config.flag_set_data = 1; + all_config.flag_save = 3; + temp_on_destroy_subwindow(self); + } + int find = fill_tree_view_user_group(&all_config, &cfg_custom_gui.user, "usrquota", 0); + if (find == 0) { + g_object_ref(cfg_custom_gui.user.liststore); + gtk_list_store_clear(cfg_custom_gui.user.liststore); + } + wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); +} + +void entry_device_disk(GtkWidget *self, int* flag_update) { + if (flag_update) { + all_config.flag_set_data = 1; + all_config.flag_save = 3; + view_device_get_gui_data(); + view_device_on_destroy_subwindow(self); + } + int find = fill_tree_view_device(&all_config.v_disk_status, &cfg_custom_gui.device, 0); + if (find == 0) { + g_object_ref(cfg_custom_gui.device.liststore); + gtk_list_store_clear(cfg_custom_gui.device.liststore); + } + wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); +} + +void entry_groups_disk(GtkWidget *self,int* flag_update) { + if (flag_update) { + all_config.flag_set_data = 1; + all_config.flag_save = 3; + temp_on_destroy_subwindow(self); + } + int find = fill_tree_view_user_group(&all_config, &cfg_custom_gui.group,"usrquota", 0); + if (find == 0) { + g_object_ref(cfg_custom_gui.group.liststore); + gtk_list_store_clear(cfg_custom_gui.group.liststore); + } + wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); +} + +void entry_project_disk(GtkWidget *self,int* flag_update) { + if (flag_update) { + all_config.flag_set_data = 1; + all_config.flag_save = 3; + temp_on_destroy_subwindow(self); + } + int find = fill_tree_view_project(&all_config, &cfg_custom_gui.project,"prjquota", 0); + if (find == 0) { + g_object_ref(cfg_custom_gui.project.liststore); + gtk_list_store_clear(cfg_custom_gui.project.liststore); + } + wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); +} void wrapper_filters_user_show() { filters_get_tree_view(cfg_custom_gui.user.tree_view); @@ -27,24 +86,16 @@ void wrapper_filters_project_show() { } void wrapper_add_user_show() { - /* - char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox)); - activ_text = yon_char_divide_search(activ_text, " ", -1); - set_disk(activ_text); set_temp_menu("usrquota", "add"); set_all_config(&all_config); set_vector(&all_config.v_user); temp_show(NULL, glade_path); int i = 0; g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_user_disk),&i); - */ } + void wrapper_edit_user_show() { - /* int index = wrapper_select_tree_view(&cfg_custom_gui.user); - char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox)); - activ_text= yon_char_divide_search(activ_text, " ", -1); - set_disk(activ_text); set_temp_menu("usrquota", "edit"); temp_set_index(index); set_all_config(&all_config); @@ -53,28 +104,19 @@ void wrapper_edit_user_show() { set_edit_gui_data_base(&all_config, index); int i = 0; g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_user_disk),&i); -*/ } void wrapper_add_group_show() { - /* - char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox)); - activ_text = yon_char_divide_search(activ_text, " ", -1); - set_disk(activ_text); set_temp_menu("grpquota", "add"); set_all_config(&all_config); set_vector(&all_config.v_group); temp_show(NULL, glade_path); int i = 0; g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_groups_disk),&i); - */ } + void wrapper_edit_group_show() { - /* int index = wrapper_select_tree_view(&cfg_custom_gui.group); - char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox)); - activ_text= yon_char_divide_search(activ_text, " ", -1); - set_disk(activ_text); set_temp_menu("grpquota", "edit"); temp_set_index(index); set_all_config(&all_config); @@ -83,8 +125,9 @@ void wrapper_edit_group_show() { set_edit_gui_data_base(&all_config, index); int i = 0; g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_groups_disk),&i); - */ + } + void wrapper_add_project_show() { set_temp_menu("prjquota", "add"); set_all_config(&all_config); @@ -93,6 +136,7 @@ void wrapper_add_project_show() { int i = 0; g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_project_disk),&i); } + void wrapper_edit_project_show() { int index = wrapper_select_tree_view(&cfg_custom_gui.project); set_temp_menu("prjquota", "edit"); @@ -105,75 +149,30 @@ void wrapper_edit_project_show() { g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_project_disk),&i); } -void block_tree_view(hotebook* widgets,void (*f)()) { - g_signal_handlers_block_by_func(G_OBJECT(widgets->tree_view), G_CALLBACK(f), NULL); -} -void unlock_tree_view(hotebook* widgets,void (*f)()) { - g_signal_handlers_unblock_by_func(G_OBJECT(widgets->tree_view), G_CALLBACK(f), NULL); -} -/* -void block_button_add_edit_del(hotebook* obj_note) { - int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(obj_note->comboBox)); - int flag_block = 0; - if (menu_id == -1) { - flag_block = 0; - } - else { - flag_block = 1; - } - gtk_widget_set_sensitive(obj_note->btnAdd, flag_block); - gtk_widget_set_sensitive(obj_note->btnDel, flag_block); - gtk_widget_set_sensitive(obj_note->btnEdit, flag_block); - if (index_selected==-1) { - } -} -*/ -void entry_user_disk(GtkWidget *self, int* flag_update) { - /* - if (flag_update) { - all_config.flag_set_data = 1; - all_config.flag_save = 3; - temp_on_destroy_subwindow(self); - } - get_status_disk(&cfg_custom_gui.user); - char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox)); - activ_text= yon_char_divide_search(activ_text, " ", -1); - int find = fill_tree_view_user_group(&all_config, activ_text, &cfg_custom_gui.user,"usrquota", 0); - if (find == 0) { - g_object_ref(cfg_custom_gui.user.liststore); - gtk_list_store_clear(cfg_custom_gui.user.liststore); - } - wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); - */ -} - - - -void entry_groups_disk(GtkWidget *self,int* flag_update) { +void wrapper_edit_view_device_show() { + view_device_set_vector_device(&all_config.v_disk_status); + view_device_set_index(index_selected); + set_view_device_menu("edit"); + view_device_show(NULL, glade_path); + int i = 0; + g_signal_connect(G_OBJECT(get_widget_view_device()->btnSaveTempSave),"clicked",G_CALLBACK(entry_device_disk),&i); } -void wrapper_entry_groups_disk(GtkWidget *self) { - //block_button_add_edit_del(&cfg_custom_gui.group); - entry_groups_disk(0,0); +void wrapper_add_view_device_show() { + view_device_set_vector_device(&all_config.v_disk_status); + view_device_set_index(-1); + set_view_device_menu("add"); + view_device_show(NULL, glade_path); + int i = 0; + g_signal_connect(G_OBJECT(get_widget_view_device()->btnSaveTempSave),"clicked",G_CALLBACK(entry_device_disk),&i); } -void wrapper_entry_user_disk(GtkWidget *self) { - //block_button_add_edit_del(&cfg_custom_gui.user); - entry_user_disk(0,0); +void block_tree_view(hotebook* widgets,void (*f)()) { + g_signal_handlers_block_by_func(G_OBJECT(widgets->tree_view), G_CALLBACK(f), NULL); } -void entry_project_disk(GtkWidget *self,int* flag_update) { - if (flag_update) { - all_config.flag_set_data = 1; - all_config.flag_save = 3; - temp_on_destroy_subwindow(self); - } - int find = fill_tree_view_project(&all_config, &cfg_custom_gui.project,"prjquota", 0); - if (find == 0) { - g_object_ref(cfg_custom_gui.project.liststore); - gtk_list_store_clear(cfg_custom_gui.project.liststore); - } - wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); +void unlock_tree_view(hotebook* widgets,void (*f)()) { + g_signal_handlers_unblock_by_func(G_OBJECT(widgets->tree_view), G_CALLBACK(f), NULL); } void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets) { @@ -212,7 +211,24 @@ void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets) { } - +void device_remove() { + if (note_selected == 3) { + GtkTreeIter iter; + 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); + if (index!=-1) { + index_selected = -1; + disk_status* _config = (disk_status*)all_config.v_disk_status.pfVectorGet(&all_config.v_disk_status, index); + model_clear_cfg_device(_config); + all_config.v_disk_status.pfVectorDelete(&all_config.v_disk_status, index); + all_config.flag_save = 1; + } + } + } +} void template_remove(vector* vec_temp, hotebook* widgets) { int index = wrapper_select_tree_view(widgets); if (index!=-1) { @@ -279,9 +295,7 @@ int wrapper_select_tree_view(hotebook* widgets) { } void wrapper_all_save() { - int flag_mess_save = 0; - if (all_config.flag_load == 0) { flag_mess_save = wrapper_template_save(&all_config, CMD_ALL_SAVE, CMD_ALL_REMOVE); } @@ -328,14 +342,22 @@ void load_global_cfg() { entry_project_disk(0, 0); } -void wrapper_edit_view_device_show() { - set_view_device_menu("edit"); - view_device_show(NULL, glade_path); +void tree_view_select_device(GtkWidget* self) { + note_selected = 3; + tree_view_select(NULL,&all_config.v_disk_status , &cfg_custom_gui.device); } -void wrapper_add_view_device_show() { - set_view_device_menu("add"); - view_device_show(NULL, glade_path); +void tree_view_select_user(GtkWidget* self) { + note_selected = 0; + tree_view_select(NULL,&all_config.v_user , &cfg_custom_gui.user); +} +void tree_view_select_group(GtkWidget* sel) { + note_selected = 1; + tree_view_select(NULL,&all_config.v_group ,&cfg_custom_gui.group); +} +void tree_view_select_project(GtkWidget* self) { + note_selected = 2; + tree_view_select(NULL,&all_config.v_project , &cfg_custom_gui.project); } void control_event(main_window* _config_main_gui, custom_window* _config_custom_gui) { @@ -357,17 +379,16 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_ g_signal_connect(G_OBJECT(_config_custom_gui->group.btnFilter),"clicked",G_CALLBACK(wrapper_filters_group_show), glade_path); g_signal_connect(G_OBJECT(_config_custom_gui->project.btnFilter),"clicked",G_CALLBACK(wrapper_filters_project_show), glade_path); - //g_signal_connect(G_OBJECT(_config_custom_gui->user.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_user), NULL); - //g_signal_connect(G_OBJECT(_config_custom_gui->group.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_group), NULL); - //g_signal_connect(G_OBJECT(_config_custom_gui->project.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_project), NULL); - g_signal_connect(G_OBJECT(_config_custom_gui->btnEditDevice), "clicked", G_CALLBACK(wrapper_edit_view_device_show), glade_path); - g_signal_connect(G_OBJECT(_config_custom_gui->btnAddDevice), "clicked", G_CALLBACK(wrapper_add_view_device_show), glade_path); + g_signal_connect(G_OBJECT(_config_custom_gui->user.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_user), NULL); + g_signal_connect(G_OBJECT(_config_custom_gui->group.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_group), NULL); + g_signal_connect(G_OBJECT(_config_custom_gui->project.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_project), NULL); + g_signal_connect(G_OBJECT(_config_custom_gui->device.tree_view), "cursor-changed", G_CALLBACK(tree_view_select_device), NULL); + g_signal_connect(G_OBJECT(_config_custom_gui->device.btnEdit), "clicked", G_CALLBACK(wrapper_edit_view_device_show), glade_path); + g_signal_connect(G_OBJECT(_config_custom_gui->device.btnAdd), "clicked", G_CALLBACK(wrapper_add_view_device_show), glade_path); + g_signal_connect(G_OBJECT(_config_custom_gui->device.btnDel),"clicked",G_CALLBACK(device_remove), glade_path); + } - - - - int main(int argc, char *argv[]){ all_config.flag_not_data = 0; vector_init(&all_config.v_user); @@ -489,6 +510,9 @@ int main(int argc, char *argv[]){ -1); //block_button_add_edit_del(&cfg_custom_gui.user); //block_button_add_edit_del(&cfg_custom_gui.group); + tree_view_select(NULL,&all_config.v_user , &cfg_custom_gui.user); + tree_view_select(NULL,&all_config.v_group , &cfg_custom_gui.group); tree_view_select(NULL,&all_config.v_project , &cfg_custom_gui.project); + tree_view_select(NULL,&all_config.v_disk_status , &cfg_custom_gui.device); gtk_main(); } \ No newline at end of file diff --git a/source/controler.h b/source/controler.h index bdc6db4..0d14736 100644 --- a/source/controler.h +++ b/source/controler.h @@ -10,7 +10,6 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_ void wrapper_all_save(); void wrapper_global_save(); void wrapper_system_save(); -int fill_tree_view_user_group(config_all* all_config, char* disk, hotebook* widget,char* str_fill , int flag_gui_add); int fill_tree_view_project(config_all* all_config, hotebook* widget, char* str_fill , int flag_gui_add); void entry_user_disk(GtkWidget *self,int* flag_update); void entry_groups_disk(GtkWidget *self,int* flag_update);