Merge pull request 'master' (#24) from Igor1/ubl-settings-diskquota:master into master
	
		
	
				
					
				
			Reviewed-on: #24pull/70/head
						commit
						5097e4c959
					
				| @ -1,3 +1,9 @@ | ||||
| .vscode/ | ||||
| ubl-settings-diskquota.glade~ | ||||
| ubl-settings-diskquota_ru.po~ | ||||
| ubl-settings-diskquota | ||||
| *~ | ||||
| build/ | ||||
| compile/ | ||||
| *# | ||||
| terminal-commands/ | ||||
| source/ubl-cmake.h | ||||
| vgcore* | ||||
| @ -0,0 +1,6 @@ | ||||
| make | ||||
| gcc compile/resources.c compile/ubl-cmake.h source/view_set_disk.h source/view_set_disk.c source/view_check_user_table.c source/view_check_user_table.h source/view_filters.c source/model/vector.c source/model/vector.h source/view_filters.h source/view_temp_u_g_p.c source/view_temp_u_g_p.h source/controler.h source/controler.c source/model/philos_utils.h source/model/philos_utils.c source/model/my_device.h source/model/save.h source/model/save.c source/model/my_device.c source/model/model.h source/model/load.h source/model/load.c source/model/model.c source/ubl-settings-diskquota.c source/ubl-settings-diskquota.h source/ubl-strings.h  source/model/ubl-utils.c source/model/ubl-utils.h -o ubl-settings-diskquota `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g | ||||
| sudo make install clean | ||||
| cd  ./terminal-commands | ||||
| make | ||||
| cd ../ | ||||
| @ -0,0 +1,12 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <gresources> | ||||
|   <gresource prefix="/com/ublinux/ui"> | ||||
|     <file>ubl-settings-diskquota.glade</file> | ||||
|   </gresource> | ||||
|   <gresource prefix="/com/ublinux/css"> | ||||
|     <file>ubl-settings-diskquota.css</file> | ||||
|   </gresource> | ||||
|   <gresource prefix="/com/ublinux/images"> | ||||
|     <file>ubl-settings-diskquota-banner.png</file> | ||||
|   </gresource> | ||||
| </gresources> | ||||
| Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 70 KiB | 
| @ -0,0 +1,589 @@ | ||||
| #include "controler.h" | ||||
| 
 | ||||
| main_window cfg_main_gui; | ||||
| custom_window cfg_custom_gui; | ||||
| config_settings_gui main_config; | ||||
| config_all all_config; | ||||
| int index_selected = -1; | ||||
| int note_selected = -1; | ||||
| // note_selected = 0; user
 | ||||
| // note_selected = 1; group
 | ||||
| // note_selected = 2; project
 | ||||
| 
 | ||||
| void update_time_table(vector* vec_temp) { | ||||
|     for (int index = 0; index < all_config.v_disk_status.vectorList.total; index++) { | ||||
|         disk_status* _config_device = (disk_status*)all_config.v_disk_status.pfVectorGet(&all_config.v_disk_status, index); | ||||
|         for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|             config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|             if (strstr(_config->UNIX_file, _config_device->device)) { | ||||
|                 _config->deferring_size = _config_device->deferring_size; | ||||
|                 _config->deferring_file = _config_device->deferring_file; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void entry_user_disk(GtkWidget *self, int* flag_update) { | ||||
|     update_time_table(&all_config.v_user); | ||||
|     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); | ||||
|     } | ||||
|     entry_user_disk(0, 0); | ||||
|     entry_groups_disk(0, 0); | ||||
|     entry_project_disk(0, 0); | ||||
|     wrapper_fill_tree_view_generate(&all_config, &cfg_custom_gui); | ||||
|     tree_view_select_user(NULL); | ||||
|     tree_view_select_group(NULL); | ||||
|     tree_view_select_project(NULL); | ||||
| } | ||||
| 
 | ||||
| void entry_groups_disk(GtkWidget *self,int* flag_update) { | ||||
|     update_time_table(&all_config.v_group); | ||||
|     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,"grpquota", 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) { | ||||
|     update_time_table(&all_config.v_project); | ||||
|     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); | ||||
|     filters_set_name("usrquota"); | ||||
|     filters_show(NULL, glade_path); | ||||
| } | ||||
| void wrapper_filters_group_show() { | ||||
|     filters_get_tree_view(cfg_custom_gui.group.tree_view); | ||||
|     filters_set_name("grpquota"); | ||||
|     filters_show(NULL, glade_path); | ||||
| } | ||||
| void wrapper_filters_project_show() { | ||||
|     filters_get_tree_view(cfg_custom_gui.project.tree_view); | ||||
|     filters_set_name("prjquota"); | ||||
|     filters_show(NULL, glade_path); | ||||
| } | ||||
| 
 | ||||
| void wrapper_add_user_show() { | ||||
|     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); | ||||
|     set_temp_menu("usrquota", "edit"); | ||||
|     temp_set_index(index); | ||||
|     set_all_config(&all_config); | ||||
|     set_vector(&all_config.v_user); | ||||
|     temp_show(NULL, glade_path); | ||||
|     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() { | ||||
|     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); | ||||
|     set_temp_menu("grpquota", "edit"); | ||||
|     temp_set_index(index); | ||||
|     set_all_config(&all_config); | ||||
|     set_vector(&all_config.v_group); | ||||
|     temp_show(NULL, glade_path); | ||||
|     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); | ||||
|     set_vector(&all_config.v_project); | ||||
|     temp_show(NULL, glade_path); | ||||
|     int i = 0; | ||||
|     g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_project_disk),&i); | ||||
| } | ||||
| 
 | ||||
| void wrapper_edit_project_show(GtkWidget* self, vector* vec_temp) { | ||||
|     int index = wrapper_select_tree_view(&cfg_custom_gui.project); | ||||
|     set_temp_menu("prjquota", "edit"); | ||||
|     temp_set_index(index); | ||||
|     set_all_config(&all_config); | ||||
|     set_vector(&all_config.v_project); | ||||
|     temp_show(NULL, glade_path); | ||||
|     set_edit_gui_data_base(&all_config, index); | ||||
|     int i = 0; | ||||
|     g_signal_connect(G_OBJECT(get_widget_temp()->btnSaveTempSave),"clicked",G_CALLBACK(entry_project_disk),&i); | ||||
| } | ||||
| 
 | ||||
| void wrapper_edit_view_device_show(GtkWidget* self) { | ||||
|     view_device_set_vector_device(&all_config.v_disk_status); | ||||
|     view_device_set_index(index_selected); | ||||
|     set_view_device_menu("edit"); | ||||
|     view_device_all_config(&all_config); | ||||
|     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_add_view_device_show(GtkWidget* self) { | ||||
|     view_device_set_vector_device(&all_config.v_disk_status); | ||||
|     view_device_set_index(-1); | ||||
|     set_view_device_menu("add"); | ||||
|     view_device_all_config(&all_config); | ||||
|     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 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 tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets) { | ||||
|     if (self) {} | ||||
|     if (vec_temp->vectorList.total > 0 && all_config.v_disk_status.vectorList.total>0) { | ||||
|         wrapper_select_tree_view(widgets); | ||||
|         GtkTreeIter iter; | ||||
|         GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore); | ||||
|         GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view)); | ||||
|         if(gtk_tree_selection_get_selected(selection, &model, &iter)) { | ||||
|             gtk_widget_set_sensitive(widgets->btnAdd, 1); | ||||
|             gtk_widget_set_sensitive(widgets->btnDel, 1); | ||||
|             gtk_widget_set_sensitive(widgets->btnEdit, 1); | ||||
|         }  | ||||
|         else { | ||||
|             if (main_config.lock_save_global == 0 || main_config.lock_save_local == 0) { | ||||
|                 gtk_widget_set_sensitive(widgets->btnAdd,1); | ||||
|             } | ||||
|             gtk_widget_set_sensitive(widgets->btnDel, 0); | ||||
|             gtk_widget_set_sensitive(widgets->btnEdit, 0); | ||||
|         } | ||||
|     } | ||||
|     if (vec_temp->vectorList.total > 0 && all_config.v_disk_status.vectorList.total==0) { | ||||
|         GtkTreeIter iter; | ||||
|         GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore); | ||||
|         GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->tree_view)); | ||||
|         if(gtk_tree_selection_get_selected(selection, &model, &iter)) { | ||||
|             gtk_widget_set_sensitive(widgets->btnDel, 1); | ||||
|         }  | ||||
|         else { | ||||
|             if (main_config.lock_save_global == 0 || main_config.lock_save_local == 0) { | ||||
|                 gtk_widget_set_sensitive(widgets->btnAdd,1); | ||||
|             } | ||||
|             gtk_widget_set_sensitive(widgets->btnAdd, 0); | ||||
|             gtk_widget_set_sensitive(widgets->btnDel, 0); | ||||
|             gtk_widget_set_sensitive(widgets->btnEdit, 0); | ||||
|         } | ||||
|     } | ||||
|     else if (!all_config.v_disk_status.vectorList.total && note_selected != 3) { | ||||
|         gtk_widget_set_sensitive(widgets->btnAdd, 0); | ||||
|     } | ||||
|     else if (all_config.v_disk_status.vectorList.total > 0 && note_selected != 3) { | ||||
|         gtk_widget_set_sensitive(widgets->btnAdd, 1); | ||||
|     } | ||||
|     else { | ||||
|         gtk_widget_set_sensitive(widgets->btnDel, 0); | ||||
|         gtk_widget_set_sensitive(widgets->btnEdit, 0); | ||||
|     } | ||||
|     if (widgets->note_selected == note_selected && index_selected>= 0) { | ||||
|         gtk_widget_set_sensitive(widgets->btnAdd, 1); | ||||
|         gtk_widget_set_sensitive(widgets->btnDel, 1); | ||||
|         gtk_widget_set_sensitive(widgets->btnEdit, 1); | ||||
|     } | ||||
|     else { | ||||
|         gtk_widget_set_sensitive(widgets->btnDel, 0); | ||||
|         gtk_widget_set_sensitive(widgets->btnEdit, 0); | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| 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)) { | ||||
|             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); | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, "deferring_size"); | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, "deferring_file"); | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, _config->device); | ||||
|                 all_config.v_disk_remove.pfVectorAdd(&all_config.v_disk_remove, yon_char_new(_config->device)); | ||||
|                 model_search_disk_remove(&all_config.v_user, &all_config.v_remove, _config->device); | ||||
|                 model_search_disk_remove(&all_config.v_group, &all_config.v_remove, _config->device); | ||||
|                 model_search_disk_remove_project(&all_config.v_project,&all_config.v_disk_status, &all_config.v_remove, _config->device); | ||||
|                 model_clear_cfg_device(_config); | ||||
|                 all_config.v_disk_status.pfVectorDelete(&all_config.v_disk_status, index); | ||||
|                 all_config.flag_save = 1; | ||||
|                  | ||||
|             }     | ||||
|         } | ||||
|     } | ||||
|     entry_user_disk(0, 0); | ||||
|     entry_groups_disk(0, 0); | ||||
|     entry_project_disk(0, 0); | ||||
|     tree_view_select_user(NULL); | ||||
|     tree_view_select_group(NULL); | ||||
|     tree_view_select_project(NULL); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void user_remove() { | ||||
|     if (note_selected == 0) { | ||||
|         GtkTreeIter iter; | ||||
|         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); | ||||
|             model_template_remove(&all_config.v_user, &all_config.v_remove, index); | ||||
|             index_selected = -1; | ||||
|             all_config.flag_save = 1; | ||||
|         } | ||||
|          | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void group_remove() { | ||||
|     if (note_selected == 1) { | ||||
|         GtkTreeIter iter; | ||||
|         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); | ||||
|             model_template_remove(&all_config.v_group, &all_config.v_remove, index); | ||||
|             index_selected = -1; | ||||
|             all_config.flag_save = 1; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void project_remove() { | ||||
|     if (note_selected == 2) { | ||||
|         GtkTreeIter iter; | ||||
|         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); | ||||
|             model_template_remove(&all_config.v_project, &all_config.v_remove, index); | ||||
|             index_selected = -1; | ||||
|             all_config.flag_save = 1; | ||||
|         } | ||||
|          | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| int wrapper_select_tree_view(hotebook* widgets) { | ||||
|     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)); | ||||
|     if(gtk_tree_selection_get_selected(selection, &model, &iter)) { | ||||
|         char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); | ||||
|         index = atoi(str_iter); | ||||
|         index_selected = index; | ||||
|     } | ||||
|     else { | ||||
|         index_selected = -1; | ||||
|     } | ||||
|     return index; | ||||
| } | ||||
| 
 | ||||
| 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); | ||||
|     } | ||||
|     else { | ||||
|         flag_mess_save = wrapper_template_save(&all_config, CMD_ALL_SAVE, CMD_ALL_REMOVE); | ||||
|     } | ||||
|     if (flag_mess_save) { | ||||
|         yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|         all_config.flag_load=0; | ||||
|     } | ||||
|     else { | ||||
|         yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|     } | ||||
| } | ||||
| void wrapper_global_save() { | ||||
|     if (wrapper_template_save(&all_config, CMD_SAVE_GLOBAL, CMD_REMOVE_GLOBAL)) { | ||||
|         yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|         all_config.flag_load-=1; | ||||
|     } | ||||
|     else { | ||||
|         yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|     } | ||||
| } | ||||
| void wrapper_system_save() { | ||||
|     if (wrapper_template_save(&all_config, CMD_SAVE_SYSTEM, CMD_REMOVE_SYSTEM)) { | ||||
|         yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|         all_config.flag_load-=1; | ||||
|     } | ||||
|     else { | ||||
|         yon_ubl_status_box_render(MESS_NOTHING_SAVE, BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|     } | ||||
| } | ||||
| void load_system_cfg() { | ||||
|     all_config.flag_load = 0; | ||||
|     load_template_load_cfg(&all_config, CMD_LOAD_SYSTEM); | ||||
|     yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS_LABEL, BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|     entry_device_disk(0, 0); | ||||
|     entry_user_disk(0, 0); | ||||
|     entry_groups_disk(0, 0); | ||||
|     entry_project_disk(0, 0); | ||||
|     tree_view_select_user(NULL); | ||||
|     tree_view_select_group(NULL); | ||||
|     tree_view_select_project(NULL); | ||||
|     tree_view_select_device(NULL); | ||||
| } | ||||
| 
 | ||||
| void load_global_cfg() { | ||||
|     all_config.flag_load = 1; | ||||
|     load_template_load_cfg(&all_config, CMD_LOAD_GLOBAL); | ||||
|     yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|     entry_device_disk(0, 0); | ||||
|     entry_user_disk(0, 0); | ||||
|     entry_groups_disk(0, 0); | ||||
|     entry_project_disk(0, 0); | ||||
|     tree_view_select_user(NULL); | ||||
|     tree_view_select_group(NULL); | ||||
|     tree_view_select_project(NULL); | ||||
|     tree_view_select_device(NULL); | ||||
| } | ||||
| 
 | ||||
| void tree_view_select_device(GtkWidget* self) { | ||||
|     note_selected = 3; | ||||
|     tree_view_select(NULL,&all_config.v_disk_status , &cfg_custom_gui.device); | ||||
| } | ||||
| 
 | ||||
| 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* self) { | ||||
|     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) { | ||||
|     g_signal_connect(G_OBJECT(_config_main_gui->LoadLocalMenuItem), "activate", G_CALLBACK(load_system_cfg), NULL); | ||||
|     g_signal_connect(G_OBJECT(_config_main_gui->LoadGlobalMenuItem), "activate", G_CALLBACK(load_global_cfg), NULL); | ||||
|     g_signal_connect(G_OBJECT(_config_main_gui->SaveGlobalMenuItem), "activate", G_CALLBACK(wrapper_global_save), NULL); | ||||
|     g_signal_connect(G_OBJECT(_config_main_gui->SaveLocalMenuItem), "activate", G_CALLBACK(wrapper_system_save), NULL); | ||||
|     g_signal_connect(G_OBJECT(_config_main_gui->SaveMenuItem), "activate", G_CALLBACK(wrapper_all_save), NULL); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->user.btnAdd),"clicked",G_CALLBACK(wrapper_add_user_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->user.btnEdit),"clicked",G_CALLBACK(wrapper_edit_user_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->user.btnDel),"clicked",G_CALLBACK(user_remove), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->group.btnAdd),"clicked",G_CALLBACK(wrapper_add_group_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->group.btnEdit),"clicked",G_CALLBACK(wrapper_edit_group_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->group.btnDel),"clicked",G_CALLBACK(group_remove), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->project.btnAdd),"clicked",G_CALLBACK(wrapper_add_project_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->project.btnEdit),"clicked",G_CALLBACK(wrapper_edit_project_show), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->project.btnDel),"clicked",G_CALLBACK(project_remove), glade_path); | ||||
|     g_signal_connect(G_OBJECT(_config_custom_gui->user.btnFilter),"clicked",G_CALLBACK(wrapper_filters_user_show), glade_path); | ||||
|     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->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); | ||||
|     vector_init(&all_config.v_group); | ||||
|     vector_init(&all_config.v_project); | ||||
|     vector_init(&all_config.v_disk_status); | ||||
|     vector_init(&all_config.v_remove); | ||||
|     local=setlocale(LC_ALL, ""); | ||||
|     textdomain(LocaleName); | ||||
|     config_init(&main_config); | ||||
|     int size_array_size_pow = 0; | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_KB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_MB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_GB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_TB); | ||||
|      | ||||
|     int option_index=0; | ||||
|     int show_help=0; | ||||
|     int debug_mode=0; | ||||
|     { | ||||
|         struct option long_options[] = { | ||||
|                 {"help", 0, 0, 'h'}, | ||||
|                 {"version", 0, 0, 'V'}, | ||||
|                 {"lock-help", 0,0, 1}, | ||||
|                 {"lock-save", 0,0, 2}, | ||||
|                 {"lock-save-local", 0,0, 3}, | ||||
|                 {"lock-save-global", 0,0, 4}, | ||||
|                 {"lock-load-global", 0,0, 5}, | ||||
|                 {"socket-id", 1, 0, 's'}, | ||||
|                 {"socket-ext-id", 1,0, 'e'}, | ||||
|                 {"socket-trd-id", 1,0, 't'}, | ||||
|                 {"debug", 0,0, 'd'}, | ||||
|                 { NULL, 0, NULL, 0 } | ||||
|         }; | ||||
|         for (int i=0;i<argc;i++){ | ||||
|             int argument=getopt_long(argc,argv,"hVvs:e:t:d",long_options,&option_index); | ||||
|             switch(argument){ | ||||
|                 case 'h': | ||||
|                     show_help=1; | ||||
|                     break; | ||||
|                 case 'v': | ||||
|                 case 'V': | ||||
|                     printf("%s\n",VERSION_LABEL); | ||||
|                     exit(0); | ||||
|                     break; | ||||
|                 case 's': | ||||
|                     if(optarg) | ||||
|                         main_config.socket_id=atoi(optarg); | ||||
|                     break; | ||||
|                 case 'e': | ||||
|                     if(optarg) | ||||
|                         main_config.save_socket_id=atoi(optarg); | ||||
|                     break; | ||||
|                 case 't': | ||||
|                     if(optarg) | ||||
|                         main_config.load_socket_id=atoi(optarg);  | ||||
|                     break; | ||||
|                 case 1: | ||||
|                     main_config.lock_help=1; | ||||
|                     break; | ||||
|                 case 2: | ||||
|                     main_config.lock_save_local=1; | ||||
|                     main_config.lock_save_global=1; | ||||
|                     break; | ||||
|                 case 3: | ||||
|                     main_config.lock_save_local=1; | ||||
|                     break; | ||||
|                 case 4: | ||||
|                     main_config.lock_save_global=1; | ||||
|                     break; | ||||
|                 case 5: | ||||
|                     main_config.lock_load_global=1; | ||||
|                     break; | ||||
|             } | ||||
|         } | ||||
|         if (show_help==1&&main_config.lock_help!=1){ | ||||
|             printf("%s\n",HELP_LABEL); | ||||
|             exit(0); | ||||
|             } | ||||
|     } | ||||
| 
 | ||||
|     if (getuid()!=0){ | ||||
|         main_config.lock_load_global=1; | ||||
|         main_config.lock_save_global=1; | ||||
|         main_config.lock_save_local=1; | ||||
|     } | ||||
|     gtk_init(&argc,&argv); | ||||
|      | ||||
|     main_window *widgets = setup_window(&cfg_main_gui,&cfg_custom_gui); | ||||
|     filters_set_name("prjquota"); | ||||
|     filters_init_flag(); | ||||
|     control_event(widgets, &cfg_custom_gui); | ||||
|      | ||||
|      | ||||
|     yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); | ||||
|      | ||||
|     yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); | ||||
|     yon_window_config_setup(GTK_WINDOW(widgets->Window)); | ||||
|     yon_window_config_load(config_path); | ||||
|     if (getuid()!=0) { | ||||
|         load_system_cfg(); | ||||
|         yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); | ||||
|     }  | ||||
|     else { | ||||
|         yon_ubl_status_box_render(LOAD_LOCAL_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); | ||||
|         if (main_config.lock_load_global == 0) { | ||||
|             load_global_cfg(); | ||||
|         } | ||||
|         if (main_config.lock_save_local == 0) { | ||||
|             load_system_cfg(); | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); | ||||
|     GtkCssProvider *css=gtk_css_provider_new(); | ||||
|     gtk_css_provider_load_from_resource(css,CssPath); | ||||
|     gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), | ||||
|                             GTK_STYLE_PROVIDER(css), | ||||
|                             -1); | ||||
|     tree_view_select_user(NULL); | ||||
|     tree_view_select_group(NULL); | ||||
|     tree_view_select_project(NULL); | ||||
|     tree_view_select_device(NULL); | ||||
|     gtk_main(); | ||||
| } | ||||
| @ -0,0 +1,38 @@ | ||||
| #include "ubl-settings-diskquota.h" | ||||
| #include "ubl-strings.h" | ||||
| #include "view_set_disk.h" | ||||
| char *local; | ||||
| 
 | ||||
| int main(int argc, char *argv[]); | ||||
| void load_global_cfg(); | ||||
| void load_system_cfg(); | ||||
| void control_event(main_window* _config_main_gui, custom_window* _config_custom_gui); | ||||
| void wrapper_all_save(); | ||||
| void wrapper_global_save(); | ||||
| void wrapper_system_save(); | ||||
| 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); | ||||
| void entry_project_disk(GtkWidget *self,int* flag_update); | ||||
| void wrapper_add_user_show(); | ||||
| void wrapper_edit_user_show(); | ||||
| void wrapper_add_group_show(); | ||||
| void wrapper_edit_group_show(); | ||||
| void wrapper_add_project_show(); | ||||
| void wrapper_edit_project_show(); | ||||
| void wrapper_filters_user_show(); | ||||
| void wrapper_filters_group_show(); | ||||
| void wrapper_filters_project_show(); | ||||
| void wrapper_get_spin_time_gui_user(); | ||||
| void wrapper_get_spin_time_gui_group(); | ||||
| void wrapper_get_spin_time_gui_project(); | ||||
| void tree_view_select_user(GtkWidget* self); | ||||
| void tree_view_select_group(GtkWidget* self); | ||||
| void tree_view_select_project(GtkWidget* self); | ||||
| void tree_view_select_device(GtkWidget* self); | ||||
| void get_spin_time_gui(vector* vec_u_g_p, hotebook* widgets); | ||||
| void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets); | ||||
| void block_spin_time(hotebook* widgets,void (*f)()); | ||||
| void unlock_spin_time(hotebook* widgets,void (*f)()); | ||||
| void template_set_status_disk(GtkWidget* self, hotebook* widgets); | ||||
| void get_status_disk(hotebook* widgets); | ||||
| @ -1,68 +0,0 @@ | ||||
| #include "controller.h" | ||||
| 
 | ||||
| int socket_ext_id_I = 0; | ||||
| int socket_trd_id_I = 0; | ||||
| 
 | ||||
| Controller::Controller(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder) | ||||
|     :Gtk::ApplicationWindow(obj), builder{builder} { | ||||
|     this->builder = builder; | ||||
|     this->settings(); | ||||
| } | ||||
| 
 | ||||
| Controller::Controller(Glib::RefPtr<Gtk::Builder> const& builder) { | ||||
|     this->builder =  builder; | ||||
|     this->settings(); | ||||
| } | ||||
| 
 | ||||
| Controller::~Controller() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void Controller::settings() { | ||||
|     obj_open_browser->set_obj_about(obj_view_about); | ||||
|     obj_main_window = new MainWindow(builder, obj_open_browser, &socket_ext_id_I, &socket_trd_id_I); | ||||
|     obj_main_window->set_obj_wrapper_load_save(obj_wrapper_load_save); | ||||
|     obj_open_browser->settings(); | ||||
|     obj_main_window->set_map_gui(&map_gui_cfg); | ||||
|     obj_main_window->set_map_global(&map_global_cfg); | ||||
|     obj_main_window->set_map_local(&map_system_cfg); | ||||
|     obj_main_window->set_obj_view_filters(&obj_view_filters); | ||||
|     obj_main_window->set_obj_view_edit(&obj_view_edit); | ||||
|     obj_main_window->set_obj_view_add(&obj_view_add); | ||||
|     obj_main_window->set_obj_view_add_project(&obj_view_add_project); | ||||
|     obj_main_window->set_obj_view_edit_project(&obj_view_edit_project); | ||||
|     obj_main_window->settings(); | ||||
| } | ||||
| 
 | ||||
| CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help) | ||||
| : Glib::OptionGroup{p_name, p_description, p_help} { | ||||
|     Glib::OptionEntry socketIDArg; | ||||
|     socketIDArg.set_long_name("socket-id"); | ||||
|     socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); | ||||
|     socketIDArg.set_description("Settings manager socket"); | ||||
|     Glib::OptionEntry socketExtId; | ||||
|     socketExtId.set_long_name("socket-ext-id"); | ||||
|     socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); | ||||
|     socketExtId.set_description("Settings manager secondary socket"); | ||||
|     Glib::OptionEntry socketTrdId; | ||||
|     socketTrdId.set_long_name("socket-trd-id"); | ||||
|     socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); | ||||
|     socketTrdId.set_description("Settings manager secondary socket"); | ||||
|     add_entry(socketIDArg, m_socketID); | ||||
|     add_entry(socketExtId, socket_ext_id_I); | ||||
|     add_entry(socketTrdId, socket_trd_id_I); | ||||
| } | ||||
| 
 | ||||
| ::Window CmdArgParser::GetSocketID() const{ | ||||
|     return m_socketID; | ||||
| } | ||||
| 
 | ||||
| SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder) | ||||
|     :Gtk::Plug{p_socketID} { | ||||
|     Controller* wnd = nullptr; | ||||
|     builder->get_widget_derived("window", wnd); | ||||
|     builder->get_widget("plugBox", plugBox); | ||||
|     plugBox->get_parent()->remove(*plugBox); | ||||
|     add(*plugBox); | ||||
|     show_all_children(); | ||||
| } | ||||
| @ -1,59 +0,0 @@ | ||||
| #ifndef CONTROLLER_H | ||||
| #define CONTROLLER_H | ||||
| #include "my_type.h" | ||||
| #include "view/view_open_browser.h" | ||||
| #include "view/view_about.h" | ||||
| #include "view/ubl-settings-diskquota.h" | ||||
| #include "view/model/wrapper_load_save.h" | ||||
| #include "view/view_filters.h" | ||||
| #include "view/view_add_user_group.h" | ||||
| #include "view/view_edit_user_group.h" | ||||
| #include "view/view_edit_project.h" | ||||
| #include "view/view_add_project.h" | ||||
| 
 | ||||
| extern int socket_ext_id_I; | ||||
| extern int socket_trd_id_I; | ||||
| 
 | ||||
| class Controller : public Gtk::ApplicationWindow | ||||
| { | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     map_str_str map_gui_cfg; | ||||
|     map_str_str map_global_cfg; | ||||
|     map_str_str map_system_cfg; | ||||
| public: | ||||
|     ~Controller(); | ||||
|     void settings(); | ||||
|     View_open_browser* obj_open_browser = new View_open_browser(); | ||||
|     View_about* obj_view_about = new View_about(); | ||||
|     MainWindow* obj_main_window; | ||||
|     Wrapper_load_save *obj_wrapper_load_save = new Wrapper_load_save(); | ||||
|     View_filters obj_view_filters = View_filters(); | ||||
|     View_add_user_group obj_view_add = View_add_user_group(); | ||||
|     View_edit_user_group obj_view_edit = View_edit_user_group(); | ||||
|     View_edit_project obj_view_edit_project = View_edit_project(); | ||||
|     View_add_project obj_view_add_project = View_add_project(); | ||||
|     Controller(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder); | ||||
|     Controller(Glib::RefPtr<Gtk::Builder> const& builder); | ||||
| 
 | ||||
| 
 | ||||
| }; | ||||
| 
 | ||||
| class CmdArgParser : public Glib::OptionGroup { | ||||
| public: | ||||
|     CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help); | ||||
|     ::Window GetSocketID() const; | ||||
| private: | ||||
|     int m_socketID = 0; | ||||
| 
 | ||||
| }; | ||||
| class SettingsPlug : public Gtk::Plug{ | ||||
| public: | ||||
|     Gtk::Window *window; | ||||
|     SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder); | ||||
| 
 | ||||
| private: | ||||
|     Gtk::Widget *plugBox; | ||||
|     Gtk::Widget *parent; | ||||
| }; | ||||
| #endif | ||||
| @ -1,99 +0,0 @@ | ||||
| #include "controller.h" | ||||
| #include "var.h" | ||||
| 
 | ||||
| void pars_flag(int index_start, int argc, char* argv[]); | ||||
| 
 | ||||
| int main(int argc, char** argv) { | ||||
|     string str_argv= ""; | ||||
|     string str_cmd_argv = ""; | ||||
|     for (int i=1; i<argc; i++){ | ||||
|         str_cmd_argv+= to_string(*argv[i]) + " "; | ||||
|     } | ||||
|     if (geteuid()!=0){ | ||||
|         string cmd = ""; | ||||
|         cmd = cmd + "pkexec " + app_name + " " + str_cmd_argv; | ||||
|         return system(cmd.c_str()); | ||||
|     } | ||||
|     if (argc > 1){ | ||||
|         str_argv = argv[1]; | ||||
|     } | ||||
|     bindtextdomain(app_name, "/usr/share/locale/"); | ||||
|     bind_textdomain_codeset(app_name, "UTF-8"); | ||||
|     textdomain(app_name); | ||||
|     if (str_argv.find("--socket-id") != std::string::npos) { | ||||
|         auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); | ||||
|         auto builder = Gtk::Builder::create_from_file(path_glade); | ||||
|         Glib::init(); | ||||
|         setlocale(LC_ALL, ""); | ||||
|         Glib::OptionContext context; | ||||
|      | ||||
|         CmdArgParser parser{ | ||||
|             "Socket ID", | ||||
|             "Command line argument for socket ID communication.", | ||||
|             "No help available, sorry" | ||||
|         }; | ||||
| 
 | ||||
|         context.set_main_group(parser); | ||||
|         context.parse(argc, argv);  | ||||
| 
 | ||||
|         ::Window socketID = parser.GetSocketID(); | ||||
| 
 | ||||
|         // Handle plug:
 | ||||
|         SettingsPlug plug{socketID, builder}; | ||||
|         plug.show(); | ||||
|      | ||||
|         app->run(plug); | ||||
|         return 0; | ||||
|     } | ||||
|     else if (str_argv.find("-") != std::string::npos || argc == 1) { | ||||
|         int len_argv = 1; | ||||
|         auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); | ||||
|         auto builder = Gtk::Builder::create_from_file(path_glade); | ||||
|         pars_flag(1, argc, argv); | ||||
|         Controller* wnd = nullptr; | ||||
|         builder->get_widget_derived("window", wnd); | ||||
|         auto r = app->run(*wnd); | ||||
|         delete wnd; | ||||
|         return r; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void pars_flag(int index_start, int argc, char* argv[]) { | ||||
|     string str_argv = ""; | ||||
|     for (int i = index_start; i<argc; i++){ | ||||
|         str_argv = argv[i]; | ||||
|         if (str_argv == "--help" || str_argv == "-h"){ | ||||
|             help(); | ||||
|             exit(1); | ||||
|         } | ||||
|         else if (str_argv == "--version" || str_argv == "-v"){ | ||||
|             string version = string(str_version) + version_application + "\n"; | ||||
|             cout << version.c_str(); | ||||
|             exit(1); | ||||
|         } | ||||
|         else if (str_argv == "--lock-help") { | ||||
|             flag_lock_help = true; | ||||
|         } | ||||
|         else if (str_argv == "--lock-save") { | ||||
|             flag_save = true; | ||||
|             flag_save_local = true; | ||||
|             flag_save_global = true; | ||||
|         } | ||||
|         else if (str_argv == "--lock-save-local"){ | ||||
|             flag_save_local = true; | ||||
|         } | ||||
|         else if (str_argv == "--lock-save-global"){ | ||||
|             flag_save_global = true; | ||||
|         } | ||||
|         else if (str_argv == "--lock-load-global"){ | ||||
|             flag_load_global = true; | ||||
|         } | ||||
|         else{ | ||||
|             if (index_start == 1){ | ||||
|                 g_print(no_recognized); | ||||
|             } | ||||
|         } | ||||
|          | ||||
|              | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,290 @@ | ||||
| #include "load.h" | ||||
| 
 | ||||
| 
 | ||||
| void load_template_load_cfg(config_all* _all_config, char* cmd) { | ||||
|     int size = 0; | ||||
|     char** cfg = yon_config_load(cmd, &size); | ||||
|     philos_array_string_remove_char(&cfg, "\n", size); | ||||
|     int size_loaded_keys = 0; | ||||
|     load_free_vector(_all_config, &_all_config->v_user); | ||||
|     load_free_vector(_all_config, &_all_config->v_group); | ||||
|     load_free_vector(_all_config, &_all_config->v_project); | ||||
|     free_remove_vector(_all_config, &_all_config->v_remove); | ||||
|     model_free_vector_string(&_all_config->v_disk_remove); | ||||
|     device_disk_parsed(); | ||||
|     vector_init(&_all_config->v_user); | ||||
|     vector_init(&_all_config->v_group); | ||||
|     vector_init(&_all_config->v_project); | ||||
|     vector_init(&_all_config->v_disk_status); | ||||
|     vector_init(&_all_config->v_remove); | ||||
|     vector_init(&_all_config->v_disk_remove); | ||||
|     if (size == 1 && strcmp(cfg[0], "(null)") == 0) { | ||||
|         for (int index_1 = 0; index_1 < get_device_vec()->vectorList.total; index_1++) { | ||||
|             char* device = NULL; | ||||
|             device_config* _config_disk = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), index_1); | ||||
|             if (yon_window_config_get_parameter(_config_disk->name_disk, _config_disk->name_disk, &device, YON_TYPE_STRING)) { | ||||
|                 if (strstr(device, _config_disk->name_disk)) { | ||||
|                     size_t deferring_size = 0; | ||||
|                     size_t deferring_file = 0; | ||||
|                     disk_status* disk_cfg =  malloc(sizeof(disk_status)); | ||||
|                     disk_cfg->status = 1; | ||||
|                     _all_config->v_disk_status.pfVectorAdd(&_all_config->v_disk_status, disk_cfg); | ||||
|                     disk_cfg->device = yon_char_new(device); | ||||
|                     disk_cfg->fs = yon_char_new(_config_disk->file_system); | ||||
|                     disk_cfg->mount_point = yon_char_new(_config_disk->mounted); | ||||
|                     disk_cfg->name = yon_char_new(_config_disk->type_dick); | ||||
|                     if (yon_window_config_get_parameter("deferring_size", _config_disk->name_disk, &deferring_size, YON_TYPE_INT)) { | ||||
|                         disk_cfg->deferring_size = deferring_size; | ||||
|                     } | ||||
|                     else { | ||||
|                         disk_cfg->deferring_size = 0; | ||||
|                     } | ||||
|                     if (yon_window_config_get_parameter("deferring_file", _config_disk->name_disk, &deferring_file, YON_TYPE_INT)) { | ||||
|                         disk_cfg->deferring_file = deferring_file; | ||||
|                     } | ||||
|                     else { | ||||
|                         disk_cfg->deferring_file = 0; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     for (int index = 0; index < size; index++) { | ||||
|         char* str_key_value = yon_char_new(cfg[index]); | ||||
|         char* str_key = yon_char_divide_search(str_key_value, "=",-1); | ||||
|         yon_char_divide_search(str_key, "[",-1); | ||||
|         str_key = yon_char_divide_search(str_key, "]",-1); | ||||
|         char* str_value = str_key_value; | ||||
|         int flag_find = 0; | ||||
|         for (int j=0; j < _all_config->v_disk_status.vectorList.total;j++) { | ||||
|             disk_status* config_disk_status = (disk_status*)_all_config->v_disk_status.pfVectorGet(&_all_config->v_disk_status, j); | ||||
|             if (strstr(str_key, config_disk_status->device)) { | ||||
|                 flag_find = 1; | ||||
|             } | ||||
|         } | ||||
|         if (((strstr(str_value, "enable") || strstr(str_value, "disable")) || yon_char_find_count(str_key, ":") == 1) && flag_find == 0) { | ||||
|             disk_status* disk_cfg =  malloc(sizeof(disk_status)); | ||||
|             disk_cfg->deferring_size = 0; | ||||
|             disk_cfg->deferring_file = 0; | ||||
|             load_pars_values_status(disk_cfg, str_key, str_value); | ||||
|             _all_config->v_disk_status.pfVectorAdd(&_all_config->v_disk_status, disk_cfg); | ||||
|             for (int index = 0; index < get_device_vec()->vectorList.total; index++) { | ||||
|                 device_config* _config_disk = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), index); | ||||
|                 for (int j=0; j < _all_config->v_disk_status.vectorList.total;j++) { | ||||
|                     disk_status* config_disk_status = (disk_status*)_all_config->v_disk_status.pfVectorGet(&_all_config->v_disk_status, j); | ||||
|                     if (strstr(config_disk_status->device, _config_disk->name_disk)) { | ||||
|                         config_disk_status->device = yon_char_new(_config_disk->name_disk); | ||||
|                         config_disk_status->fs = yon_char_new(_config_disk->file_system); | ||||
|                         config_disk_status->mount_point = yon_char_new(_config_disk->mounted); | ||||
|                         config_disk_status->name = yon_char_new(_config_disk->type_dick); | ||||
|                         if (yon_char_find_count(str_key, ":") == 1 && (!strstr(str_value, "enable") && !strstr(str_value, "disable"))) { | ||||
|                             int size_value = 0; | ||||
|                             char** arr_values = philos_str_split(str_value, &size_value, ":"); | ||||
|                             config_disk_status->deferring_size = atoll(arr_values[4]); | ||||
|                             config_disk_status->deferring_file = atoll(arr_values[5]); | ||||
|                             config_disk_status->status = 2; | ||||
|                             philos_free_string_array(&arr_values, size_value); | ||||
|                         } | ||||
|                         else { | ||||
|                              | ||||
|                         } | ||||
|                          | ||||
|                     }            | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         else if ((strstr(str_value, "enable") || strstr(str_value, "disable")) && flag_find) { | ||||
| 
 | ||||
|         } | ||||
|         else { | ||||
|             if (yon_char_find_count(str_key, ":") == 1) { | ||||
|                  | ||||
|             } | ||||
|             else { | ||||
|                 config_u_g_p* _config =  malloc(sizeof(config_u_g_p)); | ||||
|                 model_null_str_writing(_config); | ||||
|                 _config->loaded_keys = yon_char_new(str_key); | ||||
|                 load_pars_keys(_config, yon_char_new(str_key), index); | ||||
|                 load_pars_values(_config, _all_config,str_key, yon_char_new(str_value), index); | ||||
|                  | ||||
|                 if (strstr(str_key, "prjquota")) { | ||||
|                     _all_config->v_project.pfVectorAdd(&_all_config->v_project,_config); | ||||
|                 } | ||||
|                 else if (strstr(str_key, "usrquota")) { | ||||
|                     _all_config->v_user.pfVectorAdd(&_all_config->v_user,_config); | ||||
|                 } | ||||
|                 else if (strstr(str_key, "grpquota")){ | ||||
|                     _all_config->v_group.pfVectorAdd(&_all_config->v_group,_config); | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     _all_config->flag_set_data = 0; | ||||
|     _all_config->flag_not_data = 1; | ||||
|     _all_config->flag_save = 0; | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void load_pars_keys(config_u_g_p* _config, char* str_key, int index) { | ||||
|     load_pars_keys_u_g(_config, yon_char_new(str_key), index); | ||||
|     load_pars_keys_p(_config, yon_char_new(str_key), index); | ||||
| } | ||||
| 
 | ||||
| void load_pars_keys_u_g(config_u_g_p* _config, char* str_key, int index) { | ||||
|     if (strstr(str_key, "prjquota")) { | ||||
|         return; | ||||
|     } | ||||
|     if (yon_char_find_count(str_key, ":") == 1) { | ||||
|         return; | ||||
|     } | ||||
|     if (yon_char_find_count(str_key, ":") || yon_char_find_count(str_key, ",")) { | ||||
|         int size_point = 0; | ||||
|         char** arr_keys = philos_str_split(yon_char_new(str_key), &size_point, ":"); | ||||
|         _config->type_arr = yon_char_new(arr_keys[0]); | ||||
|         int size_users = 0; | ||||
|         if (yon_char_find_count(str_key, ":") == 1) { | ||||
|             int size_comma = 0; | ||||
|             char** arr_user = philos_str_split(arr_keys[size_point-1], &size_comma, ","); | ||||
|             _config->UNIX_file = yon_char_new(arr_keys[1]); | ||||
|         } | ||||
|         else if (yon_char_find_count(str_key, ":") == 2) { | ||||
|             if (yon_char_find_count(str_key, ",")) { | ||||
|                 int size_comma = 0; | ||||
|                 char** arr_user = philos_str_split(arr_keys[size_point-1], &size_comma, ","); | ||||
|                 _config->UNIX_file = yon_char_new(arr_keys[1]); | ||||
|                 for (int i = 0; i < size_comma; i++) { | ||||
|                     _config->actors.pfVectorAdd(&_config->actors,yon_char_new(arr_user[i])); | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
|                 _config->UNIX_file = yon_char_new(arr_keys[1]); | ||||
|                 if (size_point == 3) { | ||||
|                     _config->actors.pfVectorAdd(&_config->actors,yon_char_new(arr_keys[2])); | ||||
|                 } | ||||
|                  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index) { | ||||
|     if (yon_char_find_count(str_key, ":") == 1) { | ||||
|         return; | ||||
|     } | ||||
|     if (strstr(str_key, "prjquota")) { | ||||
|         if (yon_char_find_count(str_key, ":") || yon_char_find_count(str_key, ",")) { | ||||
|             int size_point = 0; | ||||
|             char** arr_keys = philos_str_split(yon_char_new(str_key), &size_point, ":"); | ||||
|             _config->type_arr = yon_char_new(arr_keys[0]); | ||||
|             int size_users = 0; | ||||
|             if (yon_char_find_count(str_key, ":") == 2) { | ||||
|                 _config->UNIX_file = yon_char_new(arr_keys[1]); | ||||
|                 int size_comma = 0; | ||||
|                 if (yon_char_find_count(str_key, ",")) { | ||||
|                     char** arr_user = philos_str_split(arr_keys[size_point-1], &size_comma, ","); | ||||
|                     if (strstr(str_key, "AUTO")) { | ||||
|                         _config->id = -1; | ||||
|                     } | ||||
|                     else { | ||||
|                         _config->id = atoi(arr_user[0]); | ||||
|                     } | ||||
|                     _config->actors.pfVectorAdd(&_config->actors,yon_char_new(arr_user[size_comma-1])); | ||||
|                 } | ||||
|                 else { | ||||
|                     if (strstr(str_key, "AUTO")) { | ||||
|                         _config->id = -1; | ||||
|                     } | ||||
|                     else { | ||||
|                         _config->id = atoi(arr_keys[size_point-1]); | ||||
|                     } | ||||
|                 } | ||||
|             }   | ||||
|     } | ||||
|     } | ||||
|     else {  | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void load_pars_values_status(disk_status* _config, char* key, char* value) { | ||||
|     _config->device = yon_char_new(key); | ||||
|     if (strstr(value,"enable")) { | ||||
|         _config->status = 2; | ||||
|         return; | ||||
|     } | ||||
|     else if (strstr(value,"disable")) { | ||||
|         _config->status = 1; | ||||
|         return; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void load_pars_values(config_u_g_p* _config, config_all* _all_config, char* str_key, char* str_value, int index) { | ||||
|     int size_array_size_pow = 0; | ||||
|     char** array_size_pow = NULL; | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_KB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_MB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_GB); | ||||
|     array_size_pow = yon_char_parsed_append(array_size_pow,&size_array_size_pow, STR_TB); | ||||
|     int size = 0; | ||||
|     char* new_value = yon_char_new(str_value); | ||||
|     char** arr_values = philos_str_split(new_value, &size, ":"); | ||||
|     int index_split = yon_char_find_count(str_value, ":"); | ||||
|     if (index_split == 3 || index_split == 5) { | ||||
|         philos_set_pow_size_memory(yon_char_new(arr_values[0]), &_config->soft_restriction_size_pow, array_size_pow); | ||||
|         philos_set_size_memory_integer(yon_char_new(arr_values[0]), &_config->soft_restriction_size); | ||||
|         philos_set_pow_size_memory(yon_char_new(arr_values[1]), &_config->severe_limitation_size_pow, array_size_pow); | ||||
|         philos_set_size_memory_integer(yon_char_new(arr_values[1]), &_config->severe_limitation_size); | ||||
|         philos_set_size_memory_integer(yon_char_new(arr_values[2]), &_config->soft_restriction_file); | ||||
|         philos_set_size_memory_integer(yon_char_new(arr_values[3]), &_config->severe_limitation_file); | ||||
|         if (index_split == 5) { | ||||
|             _config->deferring_size = atoll(arr_values[4]); | ||||
|             _config->deferring_file = atoll(arr_values[5]); | ||||
|         } | ||||
|         else { | ||||
|             philos_set_size_memory_integer("-", &_config->deferring_size); | ||||
|             philos_set_size_memory_integer("-", &_config->deferring_file); | ||||
|         } | ||||
|         for (int j=0; j < _all_config->v_disk_status.vectorList.total;j++) { | ||||
|             disk_status* config_disk_status = (disk_status*)_all_config->v_disk_status.pfVectorGet(&_all_config->v_disk_status, j); | ||||
|             if (strstr(str_key, config_disk_status->device)){ | ||||
|                 config_disk_status->deferring_file = _config->deferring_file; | ||||
|                 config_disk_status->deferring_size = _config->deferring_size; | ||||
|             } | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     else { | ||||
| 
 | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void load_free_vector(config_all* _all_config, vector* vec_config) { | ||||
|      | ||||
|     if (_all_config->flag_not_data == 1) { | ||||
|         for (int i = 0; i < vec_config->pfVectorTotal(vec_config); i++) { | ||||
|         config_u_g_p* _config = (config_u_g_p*)vec_config->pfVectorGet(vec_config, i); | ||||
|             model_clear_cfg(_config); | ||||
|         } | ||||
|         vec_config->pfVectorFree(vec_config); | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void free_remove_vector(config_all* _all_config, vector* vec_remove) { | ||||
|     if (_all_config->flag_not_data == 1) { | ||||
|         if (vec_remove->vectorList.total > 0) { | ||||
|             for (int i = 0; i < vec_remove->vectorList.total; i++) { | ||||
|                 char* str_remove = (char*)vec_remove->pfVectorGet(vec_remove, i); | ||||
|                 free(str_remove); | ||||
|             } | ||||
|             vec_remove->pfVectorFree(vec_remove); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -0,0 +1,16 @@ | ||||
| #ifndef LOAD_H | ||||
| #define LOAD_H | ||||
| #include "ubl-utils.h" | ||||
| #include "philos_utils.h" | ||||
| #include "my_device.h" | ||||
| 
 | ||||
| void load_template_load_cfg(config_all* _all_config, char* cmd); | ||||
| void load_pars_keys(config_u_g_p* _config, char* str_key, int index); | ||||
| void load_pars_keys_u_g(config_u_g_p* _config, char* str_key, int index); | ||||
| void load_pars_keys_p(config_u_g_p* _config, char* str_key, int index); | ||||
| void load_pars_values(config_u_g_p* _config, config_all* _all_config, char* str_key, char* str_value, int index); | ||||
| void load_free_vector(config_all* _all_config,vector* vec_config); | ||||
| void load_pars_values_status(disk_status* _config, char* key, char* value); | ||||
| void free_remove_vector(config_all* _all_config, vector* vec_remove); | ||||
| 
 | ||||
| #endif | ||||
| @ -0,0 +1,425 @@ | ||||
| #include "model.h" | ||||
| 
 | ||||
| size_t check_null(size_t num) { | ||||
|     if (num == 0) { | ||||
|         return -1; | ||||
|     } | ||||
|     return num; | ||||
| } | ||||
| 
 | ||||
| char* check_null_to_str(size_t num) { | ||||
|     if (num == 0) { | ||||
|         return yon_char_new("-"); | ||||
|     } | ||||
|     return philos_char_from_size_t(num); | ||||
| } | ||||
| 
 | ||||
| void model_clear_cfg(config_u_g_p* _config) { | ||||
|     free(_config->quota); | ||||
|     free(_config->size_memory); | ||||
|     free(_config->device); | ||||
|     free(_config->UNIX_file); | ||||
|     free(_config->files); | ||||
|     model_free_vector_string(&_config->actors); | ||||
|     vectorFree(&_config->actors); | ||||
|     free(_config->loaded_keys); | ||||
| } | ||||
| 
 | ||||
| void model_clear_cfg_device(disk_status* _config) { | ||||
|     free(_config->device); | ||||
|     free(_config->fs); | ||||
|     free(_config->mount_point); | ||||
|     free(_config->name); | ||||
| } | ||||
| 
 | ||||
| void model_free_vector_string(vector* vec_str) { | ||||
|     if (vec_str) { | ||||
|         if (vec_str->vectorList.total> 0) { | ||||
|             for (int i = 0; i < vec_str->vectorList.total; i++) { | ||||
|                 vectorDelete(vec_str, i); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| void model_free_vector_disk_status(vector* vec_disk_status) { | ||||
|     if (vec_disk_status) { | ||||
|         if (vec_disk_status->vectorList.total> 0) { | ||||
|             for (int i = 0; i < vec_disk_status->vectorList.total; i++) { | ||||
|                 disk_status* _config = (disk_status*)vec_disk_status->pfVectorGet(vec_disk_status, i); | ||||
|                 // model_clear_cfg_device(_config);
 | ||||
|                 vectorDelete(vec_disk_status, i); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void model_tree_view_add(config_u_g_p* _config) { | ||||
|     model_null_str_writing(_config); | ||||
| } | ||||
| 
 | ||||
| void model_null_str_writing(config_u_g_p* _config) { | ||||
|     _config->type_arr = yon_char_new(empty_str); | ||||
|     _config->quota = yon_char_new(empty_str); | ||||
|     _config->size_memory = yon_char_new(empty_str); | ||||
|     _config->device = yon_char_new(empty_str); | ||||
|     _config->UNIX_file = yon_char_new(empty_str); | ||||
|     _config->files = yon_char_new(empty_str); | ||||
|     _config->loaded_keys = yon_char_new(empty_str); | ||||
|     _config->type_arr = yon_char_new(empty_str); | ||||
|     _config->id = 0; | ||||
|     _config->soft_restriction_size = 0; | ||||
|     _config->soft_restriction_file = 0; | ||||
|     _config->severe_limitation_size = 0; | ||||
|     _config->severe_limitation_file = 0; | ||||
|     _config->deferring_size = 0; | ||||
|     _config->deferring_file = 0; | ||||
|     _config->size_memory_pow = 0; | ||||
|     _config->soft_restriction_size_pow = 0; | ||||
|     _config->severe_limitation_size_pow = 0; | ||||
|     vector_init(&_config->actors); | ||||
| } | ||||
| 
 | ||||
| char* format_actors(vector* vec_actors) { | ||||
|     char* str_all = yon_char_new(""); | ||||
|     char split_simvol[2] = {0}; | ||||
|     split_simvol[0] = 0; | ||||
|     split_simvol[1] = 0; | ||||
|     char* str_actors = NULL; | ||||
|     if (vec_actors->vectorList.total> 0) { | ||||
|         for (int i = 0; i < vec_actors->vectorList.total; i++) { | ||||
|             str_actors = (char*)vec_actors->pfVectorGet(vec_actors, i); | ||||
|             if (str_actors) { | ||||
|                 str_all = yon_char_unite(str_all,split_simvol, str_actors, NULL); | ||||
|                 split_simvol[0] = ','; | ||||
|                 split_simvol[1] = '\0'; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     if (strlen(str_all) < 3) { | ||||
|         return yon_char_new("-"); | ||||
|     } | ||||
|     return str_all; | ||||
| } | ||||
| 
 | ||||
| int fill_tree_view_project(config_all* all_config,hotebook* widget , char* str_fill, int flag_gui_add) { | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(widget->liststore); | ||||
|     if (flag_gui_add == 0) { | ||||
|         g_object_ref(widget->liststore); | ||||
|         gtk_list_store_clear(widget->liststore); | ||||
|     } | ||||
|     int flag_searhc = 0; | ||||
|     for (int i = 0; i < all_config->v_project.pfVectorTotal(&all_config->v_project); i++) { | ||||
|         config_u_g_p* _config = (config_u_g_p*)all_config->v_project.pfVectorGet(&all_config->v_project, i); | ||||
|         if (strcmp(_config->type_arr, str_fill) == 0) { | ||||
|             GtkTreeIter iter; | ||||
|             flag_searhc++; | ||||
|             gtk_list_store_append(widget->liststore,&iter); | ||||
|             char* deferring_size = wrapper_str_time(_config->deferring_size); | ||||
|             char* deferring_file = wrapper_str_time(_config->deferring_file); | ||||
|             gtk_list_store_set(widget->liststore,&iter, | ||||
|                     0,model_find_path_to_disk(&all_config->v_disk_status, _config->UNIX_file), | ||||
|                     1,_config->UNIX_file, | ||||
|                     2,fill_tree_view_id(_config->id), | ||||
|                     3,format_actors(&_config->actors), | ||||
|                     4,philos_format_cfg_str_size_memory("", check_null(_config->soft_restriction_size),_config->soft_restriction_size_pow), | ||||
|                     5,philos_format_cfg_str_size_memory("", check_null(_config->severe_limitation_size),_config->severe_limitation_size_pow), | ||||
|                     6,deferring_size, | ||||
|                     7,check_null_to_str(_config->soft_restriction_file), | ||||
|                     8,check_null_to_str(_config->severe_limitation_file), | ||||
|                     9,deferring_file, | ||||
|                     -1); | ||||
|          | ||||
|         } | ||||
|     } | ||||
|     if (flag_gui_add != 0) { | ||||
|         gtk_tree_view_set_model(GTK_TREE_VIEW(widget->tree_view), model); | ||||
|     } | ||||
|     return flag_searhc; | ||||
| } | ||||
| 
 | ||||
| int fill_tree_view_user_group(config_all* all_config, hotebook* widget, char* str_fill ,int flag_gui_add) { | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(widget->liststore); | ||||
|     if (flag_gui_add == 0) { | ||||
|         g_object_ref(widget->liststore); | ||||
|         gtk_list_store_clear(widget->liststore); | ||||
|     } | ||||
|     int flag_searhc = 0; | ||||
|     vector* vec_temp = NULL; | ||||
|     if (strcmp(str_fill, "usrquota")==0) { | ||||
|         vec_temp = &all_config->v_user; | ||||
|     } | ||||
|     else { | ||||
|         vec_temp = &all_config->v_group; | ||||
|     } | ||||
|     if (vec_temp->vectorList.total > 0) { | ||||
|         for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|             config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|             if (strcmp(_config->type_arr, str_fill) == 0) { | ||||
|                 GtkTreeIter iter; | ||||
|                 flag_searhc++; | ||||
|                 gtk_list_store_append(widget->liststore,&iter); | ||||
|                 char* deferring_size = wrapper_str_time(_config->deferring_size); | ||||
|                 char* deferring_file = wrapper_str_time(_config->deferring_file); | ||||
|                 gtk_list_store_set(widget->liststore,&iter, | ||||
|                                 0,format_actors(&_config->actors), | ||||
|                                 1,_config->UNIX_file, | ||||
|                                 2,philos_format_cfg_str_size_memory("", check_null(_config->soft_restriction_size),_config->soft_restriction_size_pow), | ||||
|                                 3,philos_format_cfg_str_size_memory("", check_null(_config->severe_limitation_size),_config->severe_limitation_size_pow), | ||||
|                                 4,deferring_size, | ||||
|                                 5,check_null_to_str(_config->soft_restriction_file), | ||||
|                                 6,check_null_to_str(_config->severe_limitation_file), | ||||
|                                 7,deferring_file, | ||||
|                                 -1); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     if (flag_gui_add != 0) { | ||||
|         gtk_tree_view_set_model(GTK_TREE_VIEW(widget->tree_view), model); | ||||
|     } | ||||
|     return flag_searhc; | ||||
| } | ||||
| 
 | ||||
| char* wrapper_str_time(size_t seconds) { | ||||
|     me_time t; | ||||
|     if (seconds>0) { | ||||
|         t = time_convert(seconds); | ||||
|         t.str_time =  yon_char_unite(yon_char_from_int(t.weeks),WEEKS,  | ||||
|                 yon_char_from_int(t.days), DAYS, | ||||
|                 yon_char_from_int(t.hours), HOURS, | ||||
|                 yon_char_from_int(t.minutes), MINUTES, NULL); | ||||
|     } | ||||
|     else { | ||||
|         t.str_time = yon_char_new("-"); | ||||
|     } | ||||
|      | ||||
|     return t.str_time; | ||||
| } | ||||
| 
 | ||||
| char* quota_type(char* str_quota) { | ||||
|     if (strcmp(str_quota, "usrquota")==0) { | ||||
|         return STR_USER; | ||||
|     } | ||||
|     else if (strcmp(str_quota, "grpquota")==0) { | ||||
|         return STR_GROUP; | ||||
|     } | ||||
|     else if (strcmp(str_quota, "prjquota")==0) { | ||||
|         return STR_PROJECT; | ||||
|     } | ||||
| } | ||||
| char quota_fill_generate(char* str_quota, config_u_g_p* _config, GtkListStore* list_store, GtkTreeIter* iter) { | ||||
|     int index = -1; | ||||
|     if (strcmp(str_quota, "usrquota")==0) { | ||||
|         index = 4; | ||||
|     } | ||||
|     else if (strcmp(str_quota, "grpquota")==0) { | ||||
|         index = 5; | ||||
|     } | ||||
|     else if (strcmp(str_quota, "prjquota")==0) { | ||||
|         index = 6; | ||||
|     } | ||||
|     if (index != -1) { | ||||
|         gtk_list_store_set(list_store,iter,index,format_actors(&_config->actors), -1); | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| int pars_status_generate(vector* vec_status, config_u_g_p* _config_u_g_p) { | ||||
|     int flag = 0; | ||||
|     if (vec_status->vectorList.total > 0) { | ||||
|         for (int i = 0; i < vec_status->vectorList.total; i++) { | ||||
|             disk_status* _config = (disk_status*)vec_status->pfVectorGet(vec_status, i); | ||||
|             if (strstr(_config_u_g_p->type_arr,"prjquota")) { | ||||
|                 if (strstr(_config_u_g_p->UNIX_file, _config->mount_point)) { | ||||
|                     if (_config->status == 0 ||  _config->status == 1) { | ||||
|                         flag = 0; | ||||
|                     } | ||||
|                     else { | ||||
|                         flag = 1; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
|                 if (strstr(_config_u_g_p->UNIX_file, _config->device)) { | ||||
|                     if (_config->status == 0 ||  _config->status == 1) { | ||||
|                         flag = 0; | ||||
|                     } | ||||
|                     else { | ||||
|                         flag = 1; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
|     return flag; | ||||
| } | ||||
| 
 | ||||
| int fill_tree_view_generate(vector* vec_fill, vector* vec_status_disk, char* str_fill, GtkWidget* tree_view, GtkListStore* liststoreGeneral) { | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(liststoreGeneral); | ||||
|     if (vec_fill->vectorList.total > 0) { | ||||
|         for (int i = 0; i < vec_fill->vectorList.total; i++) { | ||||
|             config_u_g_p* _config = (config_u_g_p*)vec_fill->pfVectorGet(vec_fill, i); | ||||
|             GtkTreeIter iter; | ||||
|             gtk_list_store_append(liststoreGeneral,&iter); | ||||
|             char* deferring_size = wrapper_str_time(_config->deferring_size); | ||||
|             char* deferring_file = wrapper_str_time(_config->deferring_file); | ||||
|             quota_fill_generate(str_fill, _config,liststoreGeneral,&iter); | ||||
|             gtk_list_store_set(liststoreGeneral,&iter, | ||||
|                     0,pars_status_generate(vec_status_disk,_config), | ||||
|                     1,_config->quota, | ||||
|                     2,quota_type(str_fill), | ||||
|                     3,_config->UNIX_file, | ||||
|                     7,philos_format_cfg_str_size_memory("", check_null(_config->soft_restriction_size),_config->soft_restriction_size_pow), | ||||
|                     8,philos_format_cfg_str_size_memory("", check_null(_config->severe_limitation_size),_config->severe_limitation_size_pow), | ||||
|                     9,deferring_size, | ||||
|                     10,check_null_to_str(_config->soft_restriction_file), | ||||
|                     11,check_null_to_str(_config->severe_limitation_file), | ||||
|                     12,deferring_file, | ||||
|                     -1); | ||||
|         } | ||||
|     } | ||||
|     gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), model); | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| int pars_status_device(disk_status* _config) { | ||||
|     if (_config->status == 2) { | ||||
|         return 1; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int fill_tree_view_device(vector* vec_device, hotebook* widget, int flag_gui_add) { | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(widget->liststore); | ||||
|     if (flag_gui_add == 0) { | ||||
|         g_object_ref(widget->liststore); | ||||
|         gtk_list_store_clear(widget->liststore); | ||||
|     } | ||||
|     int flag_searhc = 0; | ||||
|     if (vec_device->vectorList.total > 0) { | ||||
|         for (int i = 0; i < vec_device->vectorList.total; i++) { | ||||
|             disk_status* _config = (disk_status*)vec_device->pfVectorGet(vec_device, i); | ||||
|             GtkTreeIter iter; | ||||
|             flag_searhc++; | ||||
|             gtk_list_store_append(widget->liststore,&iter); | ||||
|             char* deferring_size = wrapper_str_time(_config->deferring_size); | ||||
|             char* deferring_file = wrapper_str_time(_config->deferring_file); | ||||
|             gtk_list_store_set(widget->liststore,&iter, | ||||
|                             0,pars_status_device(_config), | ||||
|                             1,_config->device, | ||||
|                             2,_config->mount_point, | ||||
|                             3,_config->fs, | ||||
|                             4,_config->name, | ||||
|                             5,deferring_size, | ||||
|                             6,deferring_file, | ||||
|                             -1); | ||||
|         } | ||||
|     } | ||||
|     if (flag_gui_add != 0) { | ||||
|         gtk_tree_view_set_model(GTK_TREE_VIEW(widget->tree_view), model); | ||||
|     } | ||||
|     return flag_searhc; | ||||
| } | ||||
| void del_disk_to_vector_device(vector* vec_temp, char* str_disk) { | ||||
|     for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|         config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|         if (strstr(_config->UNIX_file, str_disk)) { | ||||
|             vec_temp->pfVectorDelete(vec_temp, i); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char* format_str_del_config(config_u_g_p* _config) { | ||||
|     char* space = g_malloc0(sizeof(char)*2); | ||||
|     char* actors = yon_char_new(""); | ||||
|     char* cmd = NULL; | ||||
|     char* unix_file = NULL; | ||||
|     if (strstr(_config->UNIX_file, " ") && !strstr(_config->UNIX_file, "\"")) { | ||||
|         unix_file = yon_char_unite("\"", _config->UNIX_file, "\"", NULL); | ||||
|     } | ||||
|     else { | ||||
|         unix_file = yon_char_new(_config->UNIX_file); | ||||
|     } | ||||
|     for (int i = 0; i < _config->actors.vectorList.total; i++) { | ||||
|         actors = yon_char_unite(actors, space, _config->actors.pfVectorGet(&_config->actors, i), NULL); | ||||
|         space[0] = ','; | ||||
|         space[1] = '\0'; | ||||
|     } | ||||
|     if (strstr(_config->type_arr, "prjquota")) { | ||||
|         if (_config->actors.vectorList.total == 0) { | ||||
|             cmd = yon_char_unite(_config->type_arr, ":", unix_file, ":",fill_tree_view_id(_config->id), NULL); | ||||
|         } | ||||
|         else { | ||||
|             cmd = yon_char_unite(_config->type_arr, ":", unix_file, ":",fill_tree_view_id(_config->id), ",", actors, NULL); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     else { | ||||
|         cmd = yon_char_unite(_config->type_arr, ":", unix_file, ":", actors, NULL); | ||||
|     } | ||||
|     free(space); | ||||
|     free(unix_file); | ||||
|     return cmd; | ||||
| } | ||||
| 
 | ||||
| void model_template_remove(vector* vec_temp, vector* vec_remove, int index) { | ||||
|     if (index!=-1) { | ||||
|         config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index); | ||||
|         vec_remove->pfVectorAdd(vec_remove, format_str_del_config(_config)); | ||||
|         model_clear_cfg(_config); | ||||
|         vec_temp->pfVectorDelete(vec_temp, index); | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| void model_search_disk_remove(vector* vec_temp, vector* vec_remove, char* str_disk) { | ||||
|     for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|         config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|         if (strstr(_config->UNIX_file, str_disk)) { | ||||
|             model_template_remove(vec_temp,vec_remove, i); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char* model_find_path_to_disk(vector* vec_temp, char* str_path) { | ||||
|     for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|         disk_status* _config = (disk_status*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|         if (strstr(str_path, _config->mount_point)) { | ||||
|             return _config->device; | ||||
|         } | ||||
|     } | ||||
|     return "-"; | ||||
| } | ||||
| 
 | ||||
| void model_search_disk_remove_project(vector* vec_temp,vector* vec_status, vector* vec_remove, char* str_disk) { | ||||
|     for (int i = 0; i < vec_temp->vectorList.total; i++) { | ||||
|         config_u_g_p* _config_project = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|         for (int j = 0; j < vec_status->vectorList.total; j++) { | ||||
|             disk_status* _config = (disk_status*)vec_status->pfVectorGet(vec_status, j); | ||||
|             if (strstr(_config_project->UNIX_file, _config->mount_point)) { | ||||
|                 model_template_remove(vec_temp,vec_remove, i); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void model_format_del_str(config_u_g_p* _config) { | ||||
|     char* loaded_keys = yon_char_new(""); | ||||
|     if (strstr(_config->type_arr,"prjquota")) { | ||||
|         if (strcmp(format_actors(&_config->actors), "-") == 0) { | ||||
|             loaded_keys = yon_char_unite(_config->type_arr,":" , _config->UNIX_file,":", fill_tree_view_id(_config->id), ",", format_actors(&_config->actors), NULL);  | ||||
|         } | ||||
|         else { | ||||
|             loaded_keys = yon_char_unite(_config->type_arr,":" , _config->UNIX_file,":", fill_tree_view_id(_config->id), NULL);  | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         if (strcmp(format_actors(&_config->actors), "-") == 0) { | ||||
|             loaded_keys = yon_char_unite(_config->type_arr,":" , _config->UNIX_file, NULL);  | ||||
|         } | ||||
|         else { | ||||
|             loaded_keys = yon_char_unite(_config->type_arr,":" , _config->UNIX_file,":", format_actors(&_config->actors), NULL);  | ||||
|         } | ||||
|     } | ||||
|     _config->loaded_keys = loaded_keys; | ||||
| } | ||||
| @ -0,0 +1,84 @@ | ||||
| #ifndef MODEL_H | ||||
| #define MODEL_H | ||||
| #include "ubl-utils.h" | ||||
| #include "philos_utils.h" | ||||
| #include "vector.h" | ||||
| #include "../ubl-strings.h" | ||||
| typedef struct{ | ||||
|     char* type_arr; | ||||
|     int id; | ||||
|     char* quota; | ||||
|     char* size_memory; | ||||
|     char* UNIX_file; | ||||
|     char* files; | ||||
|     vector actors; | ||||
|     size_t actors_size; | ||||
|     char* loaded_keys; | ||||
|     size_t soft_restriction_size; | ||||
|     size_t soft_restriction_file; | ||||
|     size_t severe_limitation_size; | ||||
|     size_t severe_limitation_file; | ||||
|     size_t deferring_size; | ||||
|     size_t deferring_file; | ||||
| 
 | ||||
|     int size_memory_pow; | ||||
|     int soft_restriction_size_pow; | ||||
|     int severe_limitation_size_pow; | ||||
|     char* device; | ||||
|     size_t size; | ||||
|      | ||||
| } config_u_g_p; | ||||
| 
 | ||||
| typedef struct { | ||||
|     vector v_general; | ||||
|     vector v_user; | ||||
|     vector v_group; | ||||
|     vector v_project; | ||||
|     vector v_disk_status; | ||||
|     vector v_disk_remove; | ||||
|     vector v_remove; | ||||
|     int flag_set_data; | ||||
|     int flag_save; | ||||
|     int flag_load; | ||||
|     int count_remove; | ||||
|     int flag_not_data; | ||||
| } config_all; | ||||
| 
 | ||||
| typedef struct{ | ||||
|     char* device; | ||||
|     int status; | ||||
|     size_t deferring_size; | ||||
|     size_t deferring_file; | ||||
|     char* fs; | ||||
|     char* mount_point; | ||||
|     char* name; | ||||
|      | ||||
| } disk_status; | ||||
| 
 | ||||
| typedef struct{ | ||||
|     int flag_status; | ||||
|     int size; | ||||
| } config_general; | ||||
| 
 | ||||
| typedef struct{ | ||||
|     int flag_load; | ||||
| } config_gui; | ||||
| 
 | ||||
| void model_clear_cfg_device(disk_status* _config); | ||||
| char* wrapper_str_time(size_t seconds); | ||||
| void model_template_remove(vector* vec_temp, vector* vec_remove, int index); | ||||
| void model_search_disk_remove(vector* vec_temp, vector* vec_remove, char* str_disk); | ||||
| void model_null_str_writing(config_u_g_p* _config); | ||||
| void model_clear_cfg(config_u_g_p* _config); | ||||
| void model_array_size_memory(); | ||||
| char* format_actors(vector* vec_actors); | ||||
| char* model_find_path_to_disk(vector* vec_temp, char* str_path); | ||||
| void model_search_disk_remove_project(vector* vec_temp,vector* vec_status, vector* vec_remove, char* str_disk); | ||||
| void model_free_vector_string(vector* vec_str); | ||||
| void model_format_del_str(config_u_g_p* _config); | ||||
| void del_disk_to_vector_device(vector* vec_temp, char* str_disk); | ||||
| int fill_tree_view_user_group(config_all* all_config, 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); | ||||
| int fill_tree_view_generate(vector* vec_fill, vector* vec_status_disk, char* str_fill, GtkWidget* tree_view, GtkListStore* liststoreGeneral); | ||||
| int fill_tree_view_device(vector* vec_device, hotebook* widget, int flag_gui_add); | ||||
| #endif | ||||
| @ -0,0 +1,99 @@ | ||||
| #include "my_device.h" | ||||
| 
 | ||||
| vector vec_disk; | ||||
| 
 | ||||
| vector *get_device_vec() | ||||
| { | ||||
|     return &vec_disk; | ||||
| } | ||||
| 
 | ||||
| void device_disk_parsed() { | ||||
|     char *cmd = "findmnt -lo source,target,fstype,label,size -t ext4"; | ||||
|     device_device_config_free(get_device_vec()); | ||||
|     vector_init(get_device_vec()); | ||||
|     int size = 0; | ||||
|     char **responce = yon_config_load(cmd, &size); | ||||
|     char *split_simvol = "    "; | ||||
|     for (int index = 1; index < size; index++) | ||||
|     { | ||||
|         char *disk = yon_char_divide_search(responce[index], "\n", -1); | ||||
|         if (yon_char_find_count(disk, " ") != 0 && !strstr(disk, "zram") && !strstr(disk, "[")) | ||||
|         { | ||||
|             int size_str = 0; | ||||
|             char** name_disk = yon_char_parse(disk, &size_str, " "); | ||||
|             int flag = 0; | ||||
|             device_config* obj_device_config = malloc(sizeof(device_config)); | ||||
|             for (int index_1 = 0; index_1 < size_str; index_1++) { | ||||
|                 if (strlen(name_disk[index_1])) { | ||||
|                     if (flag == 0) { | ||||
|                         obj_device_config->name_disk = yon_char_new(name_disk[index_1]); | ||||
|                     } | ||||
|                     else if (flag == 1) { | ||||
|                         obj_device_config->mounted = yon_char_new(name_disk[index_1]);  | ||||
|                     } | ||||
|                     else if (flag == 2) { | ||||
|                         obj_device_config->file_system = yon_char_new(name_disk[index_1]); | ||||
|                     } | ||||
|                     else if (flag == 3) { | ||||
|                         obj_device_config->type_dick = yon_char_new(name_disk[index_1]); | ||||
|                     } | ||||
|                     else if (flag == 4) { | ||||
|                         obj_device_config->size_disk = philos_convert_memory(yon_char_new(name_disk[index_1])); | ||||
|                     } | ||||
|                     flag+=1; | ||||
|                 }  | ||||
|             } | ||||
|             obj_device_config->description_disk = yon_char_unite(obj_device_config->name_disk,split_simvol, | ||||
|                                     obj_device_config->file_system, | ||||
|                                     split_simvol, | ||||
|                                     obj_device_config->mounted, | ||||
|                                     split_simvol, | ||||
|                                     obj_device_config->type_dick, NULL); | ||||
|             get_device_vec()->pfVectorAdd(get_device_vec(), obj_device_config); | ||||
|             philos_free_string_array(&name_disk, size_str); | ||||
|         } | ||||
|         free(disk); | ||||
|     } | ||||
|     philos_free_string_array(&responce, size); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void device_fill_disk(GtkWidget *combo_box_text, vector* vec_filt) | ||||
| {    | ||||
|     vector vec; | ||||
|     vector_init(&vec); | ||||
|     vec.pfVectorCopy(&vec, get_device_vec()); | ||||
|     for (int i = 0; i < vec_filt->vectorList.total; i++) { | ||||
|         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 (strcmp(_config_disk->name_disk, _config_disk_remove->device) == 0) { | ||||
|                 vec.pfVectorDelete(&vec, index); | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
|      | ||||
|     if (vec.vectorList.total > 0) { | ||||
|         for (int index = 0; index < vec.vectorList.total; index++) | ||||
|         { | ||||
|             device_config* _config_disk_remove = (device_config*)vec.pfVectorGet(&vec, index); | ||||
|             gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box_text), yon_char_new(_config_disk_remove->description_disk)); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void device_device_config_free() { | ||||
|     if (get_device_vec()) { | ||||
|         for (int i = 0; i < get_device_vec()->vectorList.total; i++) { | ||||
|             device_config* _config_disk_remove = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), i); | ||||
|             free(_config_disk_remove->description_disk); | ||||
|             free(_config_disk_remove->type_dick); | ||||
|             free(_config_disk_remove->mounted); | ||||
|             free(_config_disk_remove->file_system); | ||||
|             free(_config_disk_remove->name_disk); | ||||
|             get_device_vec()->pfVectorDelete(get_device_vec(), i); | ||||
|         } | ||||
|     } | ||||
|      | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| #ifndef MY_DEVICE_H | ||||
| #define MY_DEVICE_H | ||||
| #include "ubl-utils.h" | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| #include "philos_utils.h" | ||||
| #include "model.h" | ||||
| typedef struct {  | ||||
|     char* name_disk; | ||||
|     char* file_system; | ||||
|     char* mounted; | ||||
|     char* type_dick; | ||||
|     char* description_disk; | ||||
|     size_t size_disk; | ||||
| } device_config; | ||||
| 
 | ||||
| void device_disk_parsed(); | ||||
| vector *get_device_vec(); | ||||
| void device_fill_disk(GtkWidget* combo_box_text, vector* vec_filt); | ||||
| size_t get_mem_total(); | ||||
| float get_size_pow_memory(size_t size_memory, int size); | ||||
| size_t get_resurs_total(char* cmd); | ||||
| void device_device_config_free(); | ||||
| 
 | ||||
| #endif | ||||
| @ -0,0 +1,873 @@ | ||||
| #include "philos_utils.h" | ||||
| 
 | ||||
| void philos_array_string_remove_char(char*** array, char* str_remove,  int size) { | ||||
|     for (int index = 0; index < size; index++) { | ||||
|        (*array)[index] = yon_char_divide_search((*array)[index], str_remove, -1); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void philos_set_pow_size_memory(char* str_find, int* array_size, char** array_size_pow) { | ||||
|     char* STR_KB = array_size_pow[0]; | ||||
|     char* STR_MB = array_size_pow[1]; | ||||
|     char* STR_GB = array_size_pow[2]; | ||||
|     char* STR_TB = array_size_pow[3]; | ||||
|     size_t length = strlen(str_find); | ||||
|     if (strstr(str_find,"K") != NULL) { | ||||
|         (*array_size) = 0; | ||||
|         str_find = yon_char_divide(str_find, length-1); | ||||
|         str_find = yon_char_unite(str_find, " ", STR_KB, NULL); | ||||
|     } | ||||
|     else if (strstr(str_find,"M") != NULL) { | ||||
|         (*array_size) = 1; | ||||
|         str_find = yon_char_divide(str_find, length-1); | ||||
|         str_find = yon_char_unite(str_find," ", STR_MB, NULL); | ||||
|     } | ||||
|     else if (strstr(str_find,"G") != NULL) { | ||||
|         (*array_size) = 2; | ||||
|         str_find = yon_char_divide(str_find, length-1); | ||||
|         str_find = yon_char_unite(str_find," ", STR_GB, NULL); | ||||
|     } | ||||
|     else if (strstr(str_find,"T") != NULL) { | ||||
|         (*array_size) = 3; | ||||
|         str_find = yon_char_divide(str_find, length-1); | ||||
|          | ||||
|         str_find = yon_char_unite(str_find," ", STR_TB, NULL); | ||||
|     } | ||||
|     else if (strstr(str_find,"%%") != NULL) { | ||||
|         (*array_size) = -1; | ||||
|         str_find = yon_char_divide(str_find, length-1); | ||||
|     } | ||||
|     else if (strstr(str_find,"-") != NULL) { | ||||
|         (*array_size) = -1; | ||||
|     } | ||||
|     else { | ||||
|         (*array_size) = 0; | ||||
|     } | ||||
|       | ||||
| } | ||||
| 
 | ||||
| void philos_set_size_memory_integer_char(char* str_find, char*** array_data, int index) { | ||||
|     char* simv_del_array[10] = {"K","M","G","T","k","m","g","t"," ","%"}; | ||||
|     for (size_t i = 0; i < 10; i++) { | ||||
|         if (strstr(str_find, simv_del_array[i])) { | ||||
|             str_find =  yon_char_divide_search(str_find, simv_del_array[i], -1); | ||||
|         } | ||||
|     } | ||||
|     if (strstr(str_find, " ") != NULL) { | ||||
|         char* mem_s = yon_char_new(str_find); | ||||
|         yon_char_divide_search(mem_s, " ", -1); | ||||
|         *array_data = yon_char_parsed_append(*array_data, &index, mem_s);  | ||||
|     } | ||||
|     if (strstr(str_find, "-") != NULL) { | ||||
|         *array_data = yon_char_parsed_append(*array_data, &index, "-"); | ||||
|     } | ||||
|     else { | ||||
|         if (str_find[0] == '\"') { | ||||
|             yon_char_divide(str_find, 0); | ||||
|             size_t length = strlen(str_find); | ||||
|             str_find = yon_char_divide(str_find, length-2); | ||||
|         } | ||||
|         if (strstr(str_find, " ") == NULL) { | ||||
|             *array_data = yon_char_parsed_append(*array_data, &index, str_find); | ||||
|         } | ||||
|           | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| void philos_free_string_array(char ***array, int size) { | ||||
|     if ((*array) == NULL) { | ||||
|         return; | ||||
|     } | ||||
|     for (int i = 0; i < size; i++){ | ||||
|         free((*array)[i]); | ||||
|     } | ||||
|     if (size!= 0) { | ||||
|         free(*array); | ||||
|         (*array) = NULL; | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| void philos_free_string_array_n3(char ****array, int size) { | ||||
|     if ((*array) == NULL || size == 0) { | ||||
|         return; | ||||
|     } | ||||
|     int index_to_l2 = 0; | ||||
|     for (int i = 0; i < size; i++){ | ||||
|         index_to_l2 = 0; | ||||
|         if ((*array)[i]!=NULL) { | ||||
|             while ((*array)[i][index_to_l2] != NULL) { | ||||
|                 if ((*array)[i][index_to_l2] != NULL) { | ||||
|                     free((*array)[i][index_to_l2]); | ||||
|                     index_to_l2++; | ||||
|                 } | ||||
|                  | ||||
|             } | ||||
|         } | ||||
|         free((*array)[i]); | ||||
|          | ||||
|     } | ||||
|     if (size!= 0) { | ||||
|         free(*array); | ||||
|         (*array) = NULL; | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| void philos_free_int_array(int **array, int size) { | ||||
|     if (size!= 0) { | ||||
|         free(*array); | ||||
|         *array = NULL; | ||||
|     } | ||||
| } | ||||
| void philos_free_int_array_n2(int ***array, int size) { | ||||
|     if ((*array) == NULL || size == 0) { | ||||
|         return; | ||||
|     } | ||||
|     for (int i = 0; i < size; i++){ | ||||
|         free((*array)[i]); | ||||
|     } | ||||
|     if (size!= 0) { | ||||
|         free(*array); | ||||
|         (*array) = NULL; | ||||
|     }  | ||||
| } | ||||
| 
 | ||||
| config_str philos_list_user(int* size, int flag_lim) { | ||||
|     char* str_uid_min = "UID_MIN"; | ||||
|     char* str_uid_max = "UID_MAX"; | ||||
|     unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min); | ||||
|     unsigned short uid_max = philos_read_uid_min_max(file_source_login_min_max, str_uid_max); | ||||
|     config_str str_users = malloc(1); | ||||
|     while (1) { | ||||
|         errno = 0; | ||||
|         struct passwd* entry = getpwent(); | ||||
|         if (!entry) { | ||||
|             if (errno) { | ||||
|                 return str_users; | ||||
|             } | ||||
|             break; | ||||
|         } | ||||
|         if (flag_lim == 1) { | ||||
|             if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { | ||||
|                 str_users = yon_char_parsed_append(str_users, size, entry->pw_name); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             str_users = yon_char_parsed_append(str_users, size, entry->pw_name); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|     endpwent(); | ||||
|     return str_users; | ||||
| } | ||||
| 
 | ||||
| unsigned short philos_read_uid_min_max(char* filename, char* search) { | ||||
|     int uid = 0; | ||||
|     char* remove_tab = "\t"; | ||||
|     char* remove_space = " "; | ||||
|     char* search_uid_min = "UID_MIN"; | ||||
|     int buff_size = 255; | ||||
|     char* line = g_malloc0(buff_size); | ||||
|     char* search_true = yon_char_get_augumented("SYS_", search); | ||||
|     FILE *fp = fopen(filename, "r"); | ||||
|     if(fp) { | ||||
|         while((fgets(line, buff_size, fp)) != NULL) { | ||||
|             try{ | ||||
|                 if (yon_char_find_count(line, search) != 0 && yon_char_find_count(line, search_true) == 0) { | ||||
|                     line = philos_str_remove(line, search); | ||||
|                     line = philos_str_remove(line, remove_space); | ||||
|                     line = philos_str_remove(line, remove_tab); | ||||
|                     uid = atoi(line); | ||||
|                      | ||||
|                 } | ||||
|             } | ||||
|             catch (...) { | ||||
|                 if (yon_char_find_count(search, search_uid_min) != 0){ | ||||
|                     uid = 1000; | ||||
|                 } | ||||
|                 else{ | ||||
|                     uid = 65534; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else{ | ||||
|         if (yon_char_find_count(search, search_uid_min) != 0) { | ||||
|             uid = 1000; | ||||
|         } | ||||
|         else{ | ||||
|             uid = 65534; | ||||
|         } | ||||
|     } | ||||
|     fclose(fp); | ||||
|     free(line); | ||||
|     free(search_true); | ||||
|     return uid; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| config_str philos_list_group(int* size, int flag_lim) { | ||||
|     char* str_uid_min = "UID_MIN"; | ||||
|     char* str_uid_max = "UID_MAX"; | ||||
|     unsigned short uid_min = philos_read_uid_min_max(file_source_login_min_max, str_uid_min); | ||||
|     unsigned short uid_max = philos_read_uid_min_max(file_source_login_min_max, str_uid_max); | ||||
|     config_str str_users = malloc(1); | ||||
|     char *cmd = "cat /etc/group"; | ||||
|     int size_groups = 0; | ||||
|     size_t pw_gid = 0; | ||||
|     char **responce = yon_config_load(cmd, &size_groups); | ||||
|     for (int i = 0; i< size_groups; i++) { | ||||
|         char* str_data = yon_char_new(responce[i]); | ||||
|         char* str_group = yon_char_divide_search(str_data,":x:",-1); | ||||
|         char* num = yon_char_divide_search(str_data, ":", -1); | ||||
|         pw_gid = atoll(yon_char_divide_search(str_data, ":", -1)); | ||||
|         if (flag_lim == 1) { | ||||
|             if ((pw_gid >= uid_min && pw_gid < uid_max) || pw_gid == 0) { | ||||
|                 str_users = yon_char_parsed_append(str_users, size, str_group); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             str_users = yon_char_parsed_append(str_users, size, str_group); | ||||
|         } | ||||
|     } | ||||
|     endpwent(); | ||||
|     return str_users; | ||||
| } | ||||
| 
 | ||||
| char* philos_str_size_pow_byte(GtkWidget *combo_box_text) { | ||||
|     int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_box_text)); | ||||
|     if (menu_id == 0) { | ||||
|         return "K"; | ||||
|     } | ||||
|     else if (menu_id == 1) { | ||||
|         return "M"; | ||||
|     } | ||||
|     else if (menu_id == 2) { | ||||
|         return "G"; | ||||
|     } | ||||
|     else if (menu_id == 3) { | ||||
|         return "T"; | ||||
|     } | ||||
|     else { | ||||
|         return " "; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char* philos_str_remove(char *str, const char *sub) { | ||||
|     size_t len = strlen(sub); | ||||
|     if (len > 0) { | ||||
|         char *p = str; | ||||
|         size_t size = 0; | ||||
|         while ((p = strstr(p, sub)) != NULL) { | ||||
|             size = (size == 0) ? (p - str) + strlen(p + len) + 1 : size - len; | ||||
|             memmove(p, p + len, size - (p - str)); | ||||
|         } | ||||
|     } | ||||
|     return str; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void philos_split_size_memory(char* str_value, int* size, char* pow_memory) { | ||||
|     (*size) = atoi(yon_char_divide_search(pow_memory, " ", -1)); | ||||
| } | ||||
| 
 | ||||
| char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_memory) { | ||||
|     if (value == -1 || value == -3 || pow_size_memory == -3) { | ||||
|         return yon_char_new("-"); | ||||
|     } | ||||
|     char* str_value = yon_char_from_int(value); | ||||
|     if (value == 0) { | ||||
|         return str_value; | ||||
|     } | ||||
|     if (pow_size_memory==0) { | ||||
|         return yon_char_unite(str_key, str_value, "K" ,NULL); | ||||
|     } | ||||
|     else if (pow_size_memory==1) { | ||||
|         return yon_char_unite(str_key,  str_value, "M" ,NULL); | ||||
|     } | ||||
|     else if (pow_size_memory==2){ | ||||
|         return yon_char_unite(str_key,  str_value, "G" ,NULL); | ||||
|     } | ||||
|     else if (pow_size_memory== 3) { | ||||
|         return yon_char_unite(str_key,  str_value, "T" ,NULL); | ||||
|     } | ||||
|     else if (pow_size_memory== -1) { | ||||
|         return yon_char_unite(str_key,  str_value, "%" ,NULL); | ||||
|     } | ||||
|     else if (pow_size_memory== -3) { | ||||
|         return yon_char_new("-"); | ||||
|     } | ||||
|     else { | ||||
|         return yon_char_new("-"); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char** philos_str_split(char *parameters, int *size, char *divider) { | ||||
|     char** array_split = NULL; | ||||
|     char* ch= NULL; | ||||
|     ch = strtok(parameters, divider); | ||||
|     if (ch != NULL) { | ||||
|         array_split = yon_char_parsed_append(array_split, size, ch); | ||||
|         while (ch != NULL) { | ||||
|             ch = strtok(NULL, divider); | ||||
|             array_split = yon_char_parsed_append(array_split, size, ch); | ||||
|         } | ||||
|     } | ||||
|     (*size) -= 1; | ||||
|     return array_split; | ||||
| } | ||||
| 
 | ||||
| void philos_array_str_copy(char*** source, char*** copy) { | ||||
|     int index = 0; | ||||
|     if (copy == NULL || source == NULL) { | ||||
|         return; | ||||
|     } | ||||
|     while (1) { | ||||
|         if ((*copy)[index] != NULL) { | ||||
|             (*source) = yon_char_parsed_append((*source), &index, yon_char_new((*copy)[index])); | ||||
|         } | ||||
|         else { | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| void philos_array_int_copy(int** source, int** copy) { | ||||
|     int * new_int = g_malloc0(sizeof(int)*2); | ||||
|     if ((*copy)[0] != -2) { | ||||
|         new_int[0] = (*copy)[0]; | ||||
|         new_int[1] = -2; | ||||
|         int i = 2; | ||||
|         for (i=1;(*copy)[i]!=-2;i++) { | ||||
|             yon_int_array_append(&new_int,(*copy)[i]); | ||||
|         } | ||||
|         *source=new_int; | ||||
|     } | ||||
|     else { | ||||
|         new_int[0] = (*copy)[0]; | ||||
|         *source=new_int; | ||||
|     } | ||||
|      | ||||
| } | ||||
| char** philos_pars_terminal_systemd_cgls(char* CMD_GET_SLICE_SERVICE, char* str_find, int* size_array_data) { | ||||
|     int size = 0; | ||||
|     char** terminal_print = yon_config_load(CMD_GET_SLICE_SERVICE, &size); | ||||
|     char** array_data = NULL; | ||||
|     for (int index = 0; index < size; index++) { | ||||
|         if (strstr(terminal_print[index], str_find) != NULL) { | ||||
|             yon_char_divide_search(terminal_print[index],"─",-1); | ||||
|             terminal_print[index] = yon_char_divide_search(terminal_print[index]," ", -1); | ||||
|             yon_char_divide(terminal_print[index],1); | ||||
|             array_data = yon_char_parsed_append(array_data, size_array_data, terminal_print[index]); | ||||
|              | ||||
|         } | ||||
|     } | ||||
|     return array_data; | ||||
| } | ||||
| char* philos_pard_array_add_cmd(char* cmd, temp_config* _config, char* key, int* array_io, int* array_io_pow_size, char** disk, int size) { | ||||
|     char* split_simvol = g_malloc0(sizeof(char)*2); | ||||
|     int flag_format = 0; | ||||
|     char* cmd_old = yon_char_new(cmd); | ||||
|     char* cmd_new = ""; | ||||
|     if (disk && size && array_io && array_io_pow_size) { | ||||
|         int index_find = 0; | ||||
|         for (int index = 0; index < size; index++) { | ||||
|             if (array_io_pow_size[index] >= 0 && array_io[index]>= 0 && !strstr(disk[index], "-")) { | ||||
|                 char* num_and_pow_size = philos_format_cfg_str_size_memory(" ", array_io[index], array_io_pow_size[index]); | ||||
|                 if (!strstr(num_and_pow_size, "-")) { | ||||
|                     cmd_new = yon_char_unite(cmd_new,  | ||||
|                         split_simvol, | ||||
|                         disk[index], | ||||
|                         num_and_pow_size, NULL); | ||||
|                     split_simvol[0] = ','; | ||||
|                     split_simvol[1] = '\0'; | ||||
|                     flag_format = 1; | ||||
|                 } | ||||
|                 free(num_and_pow_size); | ||||
|             }    | ||||
|         } | ||||
|     } | ||||
|     free(split_simvol); | ||||
|     if (flag_format) { | ||||
|         if (strlen(cmd_new)>2) { | ||||
|             if (strlen(cmd_old) > 3) { | ||||
|                 cmd = yon_char_unite(cmd_old, ",", key, cmd_new, NULL); | ||||
|             } | ||||
|             else { | ||||
|                 cmd = yon_char_unite(key, cmd_new, NULL); | ||||
|             } | ||||
|              | ||||
|         } | ||||
|         return cmd; | ||||
|     } | ||||
|     else { | ||||
|         return cmd_old; | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void philos_temp_config_init(temp_config* _config) { | ||||
|     if (_config->size_disk != 0) { | ||||
|         philos_free_string_array(&_config->disk_read, _config->size_disk); | ||||
|         philos_free_int_array(&_config->i_o_limit_read, _config->size_disk); | ||||
|         philos_free_int_array(&_config->i_o_limit_read_size, _config->size_disk);  | ||||
|     } | ||||
|     else if (_config->size_disk != 0) { | ||||
|         philos_free_string_array(&_config->disk_write, _config->size_disk); | ||||
|         philos_free_int_array(&_config->i_o_limit_write, _config->size_disk); | ||||
|         philos_free_int_array(&_config->i_o_limit_write_size, _config->size_disk); | ||||
|     } | ||||
|     _config->disk_read = NULL; | ||||
|     _config->disk_write = NULL; | ||||
|     _config->i_o_limit_read = NULL; | ||||
|     _config->i_o_limit_write = NULL; | ||||
|     _config->i_o_limit_read_size = NULL; | ||||
|     _config->i_o_limit_write_size = NULL; | ||||
|     _config->size_disk = 0; | ||||
|     _config->size_disk = 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int find_null_array(temp_config* _config) { | ||||
|     int index = 0; | ||||
|     for (index = 0; (_config->disk_read[index]!=NULL && _config->disk_write[index]!=NULL); index++) { | ||||
|         if (strcmp(_config->disk_read[index], "-") == 0 && strcmp(_config->disk_write[index], "-") == 0) { | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
|     return index; | ||||
|      | ||||
| 
 | ||||
| } | ||||
| int* philos_int_append(int* array, int* size, int value) { | ||||
|     array = yon_remalloc(array, (*size+1)*sizeof(int)); | ||||
|     array[(*size)] = value; | ||||
|     (*size)++; | ||||
|     return array; | ||||
|      | ||||
| } | ||||
| 
 | ||||
| int* remove_element_int_array(int* array, int* size, int item_to_delete) { | ||||
|     int *new_int_parsed=NULL; | ||||
|     new_int_parsed=malloc(sizeof(int)*((*size)-1)); | ||||
|     int flag = 0; | ||||
|     for (int i=0;i < (*size);i++){ | ||||
|         if (i==item_to_delete) { | ||||
|             flag = 1; | ||||
|         } | ||||
|         if (flag == 0) { | ||||
|             memcpy(&(new_int_parsed[i]),&(array[i]),sizeof(int)); | ||||
|         } | ||||
|         else if (flag == 1 && i!=item_to_delete) { | ||||
|             memcpy(&(new_int_parsed[i-1]),&(array[i]),sizeof(int)); | ||||
|         } | ||||
|     } | ||||
|     (*size)=(*size)-1; | ||||
|     return new_int_parsed; | ||||
| } | ||||
| 
 | ||||
| int** remove_element_int_array_n3(int** array, int* size, int item_to_delete) { | ||||
|     int **new_int_parsed=NULL; | ||||
|     new_int_parsed=malloc(sizeof(int*)*((*size)-1)); | ||||
|     int flag = 0; | ||||
|     for (int i=0;i < (*size);i++){ | ||||
|         if (i==item_to_delete) { | ||||
|             flag = 1; | ||||
|         } | ||||
|         if (flag == 0) { | ||||
|             philos_array_int_copy(&new_int_parsed[i],&array[i]); | ||||
|         } | ||||
|         else if (flag == 1 && i!=item_to_delete) { | ||||
|             philos_array_int_copy(&new_int_parsed[i-1],&array[i]); | ||||
|         } | ||||
|     } | ||||
|     (*size)=(*size)-1; | ||||
|     return new_int_parsed; | ||||
| } | ||||
| char* philos_get_size_bite(GtkWidget* chk_button, GtkWidget* spin, GtkWidget* combo_box_text) { | ||||
|     if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(chk_button))) { | ||||
|         char* size_prifics = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combo_box_text)); | ||||
|         int size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | ||||
|         char* str_size_bute = yon_char_unite(yon_char_from_int(size_bite), " ", size_prifics, NULL); | ||||
|         return str_size_bute; | ||||
|     } | ||||
|     else { | ||||
|         char* str = (char*)malloc(sizeof(char*)*2); | ||||
|         str[0] = '-'; | ||||
|         str[1] = '\0'; | ||||
|         return str; | ||||
|     } | ||||
| } | ||||
| void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size) { | ||||
|     for (int index = 0; index < size; index++) { | ||||
|         gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(cbt), list_data[index]); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value) { | ||||
|     gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)); | ||||
|     //guint value_spin = gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin));
 | ||||
|     guint value_spin = atoi((char*)gtk_entry_get_text(GTK_ENTRY(spin))); | ||||
|     if (active != -1) { | ||||
|         GtkAdjustment* adjustment = NULL; | ||||
|         adjustment = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(spin)); | ||||
|         gtk_adjustment_set_lower(adjustment, 0.0); | ||||
|         gtk_adjustment_set_page_increment(adjustment, 1.0); | ||||
|         if (combo == NULL) { | ||||
|             gtk_adjustment_set_upper(adjustment, (value*100)); | ||||
|             if ((value*100)<value_spin) { | ||||
|                 gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), (value*100)); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             int index = gtk_combo_box_get_active(GTK_COMBO_BOX(combo)); | ||||
|             if (index == 0) { | ||||
|                 gtk_adjustment_set_upper(adjustment, value); | ||||
|                 if (value<value_spin) { | ||||
|                     gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), value); | ||||
|                 } | ||||
|             } | ||||
|             else if (index == -1) {} | ||||
|             else { | ||||
|                 size_t pow_mem_size = (size_t)get_size_pow_memory(value, index); | ||||
|                 gtk_adjustment_set_upper(adjustment, pow_mem_size); | ||||
|                 if (pow_mem_size<value_spin) { | ||||
|                     //gtk_spin_button_set_digits(GTK_SPIN_BUTTON(spin), (int)pow_mem_size);
 | ||||
|                 } | ||||
|             } | ||||
|               | ||||
|         } | ||||
|     } | ||||
| } | ||||
| void philos_set_active_widgets(GtkWidget *check, GtkWidget *spin, GtkWidget *combo) { | ||||
|     gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)); | ||||
|     size_t value_spin = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin)); | ||||
|     gtk_widget_set_sensitive(spin, active); | ||||
|     if (combo) { | ||||
|         if (!active) { | ||||
|             gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); | ||||
|         } | ||||
|         gtk_widget_set_sensitive(combo, active); | ||||
|     }      | ||||
| } | ||||
| 
 | ||||
| size_t get_resurs_total(char* cmd) { | ||||
|     int size = 0; | ||||
|     size_t size_memory = 0; | ||||
|     char **responce = yon_config_load(cmd, &size); | ||||
|     for (int index = 0; index < size; index++ ) { | ||||
|         char* mem_size_kb = yon_char_divide_search(responce[index], "\n", -1); | ||||
|         size_memory = atoll(mem_size_kb); | ||||
|         free(mem_size_kb); | ||||
|     } | ||||
|     philos_free_string_array(&responce, size); | ||||
|     return size_memory; | ||||
| } | ||||
| 
 | ||||
| float get_size_pow_memory(size_t size_memory, int size) { | ||||
|     float res = size_memory; | ||||
|     for (size_t index = 0; index < size; index++) { | ||||
|         res = res/1024; | ||||
|     } | ||||
|     return res; | ||||
| } | ||||
| 
 | ||||
| void philos_set_active_widgets_device_io(GtkWidget* combo_to_l2,GtkWidget *check, GtkWidget *spin, GtkWidget *combo) { | ||||
|     int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(combo_to_l2)); | ||||
|     if (menu_id != -1) { | ||||
|         gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check)); | ||||
|         if (active == 0) { | ||||
|             gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0); | ||||
|         } | ||||
|         else if (gtk_spin_button_get_digits(GTK_SPIN_BUTTON(spin))>0) { | ||||
|             gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),1); | ||||
|         } | ||||
|         gtk_widget_set_sensitive(spin, active); | ||||
|         gtk_widget_set_sensitive(combo, active); | ||||
|     } | ||||
|     else { | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0); | ||||
|         gtk_widget_set_sensitive(spin, 0); | ||||
|         gtk_widget_set_sensitive(combo, 0); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), 0); | ||||
|     } | ||||
|     philos_set_spin_adjustment(check, spin, combo, 12582912); | ||||
| } | ||||
| char *yon_char_get_augumented(char *source, char *append) | ||||
| { | ||||
|     if (source && append) | ||||
|     { | ||||
|         int size = strlen(source) + strlen(append) + 1; | ||||
|         char *final = malloc(size); | ||||
|         memset(final, 0, size); | ||||
|         if (strstr(source, "%%")) | ||||
|             sprintf(final, source, append); | ||||
|         else | ||||
|             sprintf(final, "%s%s", source, append); | ||||
|         return final; | ||||
|     } | ||||
|     else | ||||
|         return NULL; | ||||
| } | ||||
| dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data) { | ||||
|     dictionary *dct = yon_dictionary_create_conneced(dict); | ||||
|     dct->key = yon_char_new(key); | ||||
|     dct->data = data; | ||||
|     dct->data_type = DICTIONARY_OTHER_TYPE; | ||||
|     return dct; | ||||
| } | ||||
| char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete) { | ||||
|     char **new_char_parsed=NULL; | ||||
|     new_char_parsed=malloc(sizeof(char*)*((*size)-1)); | ||||
|     int flag = 0; | ||||
|     for (int i=0;i < (*size);i++){ | ||||
|         if (i==item_to_delete) { | ||||
|             flag = 1; | ||||
|         } | ||||
|         if (flag == 0) { | ||||
|             new_char_parsed[i]=yon_char_new(char_string[i]); | ||||
|         } | ||||
|         else if (flag == 1 && i!=item_to_delete) { | ||||
|             new_char_parsed[i-1]=yon_char_new(char_string[i]); | ||||
|         } | ||||
|     } | ||||
|     (*size)=(*size)-1; | ||||
|     return new_char_parsed; | ||||
| } | ||||
| char*** yon_char_parsed_shrink_n3(char ***char_string, int *size, int item_to_delete) { | ||||
|     char ***new_char_parsed=NULL; | ||||
|     new_char_parsed=malloc(sizeof(char**)*((*size)-1)); | ||||
|     int flag = 0; | ||||
|     for (int i=0;i < (*size);i++){ | ||||
|         if (i==item_to_delete) { | ||||
|             flag = 1; | ||||
|         } | ||||
|         if (flag == 0) { | ||||
|             yon_char_parsed_copy(&new_char_parsed[i],&char_string[i]); | ||||
|         } | ||||
|         else if (flag == 1 && i!=item_to_delete) { | ||||
|             yon_char_parsed_copy(&new_char_parsed[i-1], &char_string[i]); | ||||
|         } | ||||
|     } | ||||
|     (*size)=(*size)-1; | ||||
|     return new_char_parsed; | ||||
| } | ||||
| dictionary *yon_dictionary_create_empty() { | ||||
|     dictionary *dict = malloc(sizeof(dictionary)); | ||||
|     dict->data = NULL; | ||||
|     dict->key = NULL; | ||||
|     dict->next = NULL; | ||||
|     dict->prev = NULL; | ||||
|     dict->first = dict; | ||||
|     dict->data_type = DICTIONARY_OTHER_TYPE; | ||||
|     return dict; | ||||
| } | ||||
| #ifdef VTE_TERMINAL | ||||
| void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument){ | ||||
|     char **commands=new_arr(char*,2); | ||||
|     gchar **envp = g_get_environ(); | ||||
|     commands[0]=(gchar *)g_strdup(g_environ_getenv(envp, "SHELL")); | ||||
|     commands[1]=NULL; | ||||
|     char **env=new_arr(char*,2); | ||||
|     env[0]=""; | ||||
|     env[1]=NULL; | ||||
|     vte_terminal_set_size(VTE_TERMINAL(terminal),10,15); | ||||
|     VtePty *pty = vte_pty_new_sync(VTE_PTY_DEFAULT,NULL,NULL); | ||||
|     vte_terminal_set_pty(VTE_TERMINAL(terminal),pty); | ||||
|     char *install_command=yon_char_unite("tput cup 0 0 && tput ed; ",command, "; exit 0\n",NULL);  | ||||
|     if(endwork_function) | ||||
|         g_signal_connect(G_OBJECT(terminal), "child-exited", G_CALLBACK(endwork_function), endwork_function_argument); | ||||
|      vte_terminal_spawn_async(VTE_TERMINAL(terminal), | ||||
|         VTE_PTY_DEFAULT, | ||||
|         NULL,    | ||||
|         commands,    | ||||
|         NULL,   | ||||
|         0,       | ||||
|         NULL, NULL, | ||||
|         NULL,    | ||||
|         -1,  | ||||
|         NULL,  | ||||
|         child_ready,     | ||||
|         install_command);  | ||||
|     vte_pty_spawn_async(pty, | ||||
|         NULL,         | ||||
|         commands,       | ||||
|         NULL,          | ||||
|         0,             | ||||
|         NULL, NULL,    | ||||
|         NULL,          | ||||
|         -1,            | ||||
|         NULL,          | ||||
|         NULL,            | ||||
|         NULL);         | ||||
|         vte_terminal_set_scrollback_lines(VTE_TERMINAL(terminal), -1); | ||||
|         vte_terminal_set_scroll_on_output(VTE_TERMINAL(terminal), TRUE); | ||||
|         vte_terminal_set_scroll_on_keystroke(VTE_TERMINAL(terminal), TRUE); | ||||
|         gtk_widget_show_all(terminal); | ||||
| } | ||||
| static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) | ||||
| { | ||||
|     if (!terminal) return; | ||||
|     if (pid == -1) printf("Error\n\n\n"); | ||||
|     else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); | ||||
| } | ||||
| #endif | ||||
| dictionary *yon_dictionary_create_conneced(dictionary *targetdict) | ||||
| { | ||||
|     targetdict = yon_dictionary_get_last(targetdict); | ||||
|     targetdict->next = yon_dictionary_create_empty(); | ||||
|     targetdict->next->prev = targetdict; | ||||
|     targetdict->next->first = targetdict->first; | ||||
|     targetdict->next->data_type = DICTIONARY_OTHER_TYPE; | ||||
|     return targetdict->next; | ||||
| } | ||||
| void yon_int_array_append(int **source, int append){ | ||||
|     int size=0; | ||||
|     for (size=0;(*source)[size]!=-2;size++); | ||||
|     *source = realloc(*source,(size+2)*sizeof(int)); | ||||
|     (*source)[size] = append; | ||||
|     (*source)[size+1] = -2; | ||||
| } | ||||
| 
 | ||||
| /**[EN]
 | ||||
|  * int yon_config_save(char *command) | ||||
|  * Saves config with [command] | ||||
|  * [RU] | ||||
| */ | ||||
| int philos_config_save(char *command) | ||||
| {    | ||||
|     FILE *output = popen(command, "r"); | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| void philos_array_int_pars_to(int** array, int to) { | ||||
|     int flag = 0; | ||||
|     int i = 0; | ||||
|     for (i = 0; (*array)[i] != -2; i++) { | ||||
|         if ((*array)[i]==-3) { | ||||
|             (*array)[i] = to; | ||||
|             flag = 1; | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void philos_array_char_pars_to(char*** array, char* to) { | ||||
|     int flag = 0; | ||||
|     int i = 0; | ||||
|     for (i = 0; (*array)[i] != NULL; i++) { | ||||
|         if (strcmp((*array)[i], "-") == 0) { | ||||
|             (*array)[i] = yon_char_new(to); | ||||
|             flag = 1; | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char** philos_char_parsed_append(char** parsed, int *size, char *string) { | ||||
|     parsed = yon_char_parsed_append(parsed, size, string);  | ||||
|     (*size)--; | ||||
|     return parsed; | ||||
| } | ||||
| 
 | ||||
| void philos_set_size_memory_integer(char* str_find, size_t* array_data) { | ||||
|     if (strstr(str_find, " ")) { | ||||
|         yon_char_divide_search(str_find, " ", -1); | ||||
|     } | ||||
|     char* simv_del_array[9] = {"K","M","G","T","k","m","g","t","%"}; | ||||
|     for (size_t i = 0; i < 9; i++) { | ||||
|         if (strstr(str_find, simv_del_array[i])) { | ||||
|             str_find =  yon_char_divide_search(str_find, simv_del_array[i], -1); | ||||
|         } | ||||
|     } | ||||
|     if (strstr(str_find, "-")==NULL) { | ||||
|         (*array_data) = atoll(str_find);  | ||||
|     } | ||||
|     else { | ||||
|        (*array_data) = -1;  | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| me_time time_convert(size_t seconds) { | ||||
|     me_time t; | ||||
|     if (seconds != -1) { | ||||
|         double weeks = seconds / (7*24*60*60); | ||||
|         double days = seconds / (24*60*60) - 7*weeks; | ||||
|         double hours = seconds / (60*60) - 7*24*weeks - 24*days; | ||||
|         double minutes = seconds / 60 - 7*24*60*weeks - 24*60*days - 60*hours; | ||||
|         if (weeks>0) { | ||||
|             t.weeks = (int)weeks; | ||||
|         } | ||||
|         else { | ||||
|             t.weeks = 0; | ||||
|         } | ||||
|         if (days>0) { | ||||
|             t.days = (int)days; | ||||
|         } | ||||
|         else { | ||||
|             t.days = 0; | ||||
|         } | ||||
|         if (hours>0) { | ||||
|             t.hours = (int)hours; | ||||
|         } | ||||
|         else { | ||||
|             t.hours = 0; | ||||
|         } | ||||
|         if (minutes>0) { | ||||
|             t.minutes = (int)minutes; | ||||
|         } | ||||
|         else { | ||||
|             t.minutes = 0; | ||||
|         } | ||||
|         t.str_time = NULL; | ||||
|     } | ||||
|     else { | ||||
|         t.weeks = 0; | ||||
|         t.days = 0; | ||||
|         t.hours = 0; | ||||
|         t.hours = 0; | ||||
|         t.str_time = NULL; | ||||
|     } | ||||
|      | ||||
|      | ||||
|     return t;  | ||||
| } | ||||
| 
 | ||||
| char* fill_tree_view_id(int id) { | ||||
|     if (id < 0) { | ||||
|         return yon_char_new("AUTO"); | ||||
|     } | ||||
|     else { | ||||
|         return yon_char_from_int(id); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| char *philos_char_from_size_t(size_t int_to_convert) { | ||||
|     int i = 1; | ||||
|     float convert_check = (float)int_to_convert; | ||||
|     for (i = 1; convert_check >= 10; i++) | ||||
|     { | ||||
|         convert_check = convert_check / 10; | ||||
|     } | ||||
|     char *ch = g_malloc0(i * sizeof(char) + 1); | ||||
|     sprintf(ch, "%d", int_to_convert); | ||||
|     return ch; | ||||
| } | ||||
| size_t philos_convert_memory(char* num_memory_pow) { | ||||
|     float num_f = atof(yon_char_new(num_memory_pow)); | ||||
|     if (strstr(num_memory_pow,"K") != NULL) { | ||||
|         return (size_t)(num_f); | ||||
|     } | ||||
|     else if (strstr(num_memory_pow,"M") != NULL) { | ||||
|         return (size_t)(num_f*1024); | ||||
|     } | ||||
|     else if (strstr(num_memory_pow,"G") != NULL) { | ||||
|         return (size_t)(num_f*1024*1024); | ||||
|     } | ||||
|     else if (strstr(num_memory_pow,"T") != NULL) { | ||||
|         return (size_t)(num_f*1024*1024*1024); | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,158 @@ | ||||
| #ifndef PHILOS_UTILS_H | ||||
| #define PHILOS_UTILS_H | ||||
| #include "ubl-utils.h" | ||||
| #include <pthread.h> | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| #include <stdarg.h> | ||||
| #include <pthread.h> | ||||
| #include <string.h> | ||||
| #include <dirent.h> | ||||
| #include <locale.h> | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #ifdef VTE_TERMINAL | ||||
|     #include <vte/vte.h> | ||||
| #endif | ||||
| 
 | ||||
| #include <pwd.h> | ||||
| #include <stdbool.h> | ||||
| 
 | ||||
| #define catch(x) ExitJmp:if(__HadError) | ||||
| #define throw(x) {__HadError=true;goto ExitJmp;} | ||||
| #define file_source_login_min_max "/etc/login.defs" | ||||
| static char** array_size_pow; | ||||
| typedef struct { | ||||
|     char** disk_read; | ||||
|     char** disk_write; | ||||
|     int* i_o_limit_read; | ||||
|     int* i_o_limit_write; | ||||
|     int* i_o_limit_read_size; | ||||
|     int* i_o_limit_write_size; | ||||
|     int size; | ||||
|     int size_disk; | ||||
| } temp_config; | ||||
| 
 | ||||
| typedef struct { | ||||
|     GtkWidget* Window; | ||||
|     GtkWidget* btnSaveTempSave; | ||||
|     GtkWidget* btnTempCancel; | ||||
|     GtkWidget* lblSetUGP; | ||||
|     GtkWidget* lblHeadQuotasEditWindow; | ||||
|      | ||||
|     GtkWidget* btnOpenUserGroup; | ||||
| 
 | ||||
|     GtkWidget* btnReviewProject; | ||||
|     GtkWidget* btnGenerateProject; | ||||
|     GtkWidget* entryCatalogProject; | ||||
|     GtkWidget* chbAuto; | ||||
|     GtkWidget* entryProjectName; | ||||
|     GtkWidget* boxProjectAddEdit; | ||||
|     GtkWidget* boxProject; | ||||
|     GtkWidget* lblCatalogProjectEdit; | ||||
|     GtkWidget* lblProjectIdValueEdit; | ||||
|     GtkWidget* entryProjectId; | ||||
|     GtkWidget*  boxTempDevice; | ||||
|      | ||||
|     GtkWidget* wndChooseFileWallpaper; | ||||
|     GtkWidget* btnFilemangerOk; | ||||
|     GtkWidget* btnFilemangerExit; | ||||
|     GtkWidget* quotegroupSizeSoftLimitCheck; | ||||
|     GtkWidget* quotegroupSizeSoftLimitSpin; | ||||
|     GtkWidget* quotegroupSizeSoftLimitCombo;  | ||||
|     GtkWidget* quotegroupSizeHardLimitCheck;  | ||||
|     GtkWidget* quotegroupSizeHardLimitSpin; | ||||
|     GtkWidget* quotegroupSizeHardLimitCombo; | ||||
|     GtkWidget* quotegroupFilesSoftLimitCheck; | ||||
|     GtkWidget* quotegroupFilesSoftLimitSpin;  | ||||
|     GtkWidget* quotegroupFilesHardLimitCheck; | ||||
|     GtkWidget* quotegroupFilesHardLimitSpin;  | ||||
|     GtkWidget* lblSetNameDevice; | ||||
|     GtkWidget* boxProjectAddEditboxProjectId; | ||||
|     GtkWidget* entryUser; | ||||
|     GtkWidget* UserDeviceCombo; | ||||
|     GtkWidget* lblSetQuotasStatus; | ||||
|     GtkWidget* lblWarningText; | ||||
|     GtkWidget* WarrningWindow; | ||||
|     GtkWidget* CancelWarrningButton; | ||||
|     GtkWidget* boxBlockGuiAddEdit; | ||||
| } temp_set_window; | ||||
| 
 | ||||
| typedef struct { | ||||
|     char* name; | ||||
|     int note_selected; | ||||
|     GtkListStore *liststore; | ||||
|     GtkWidget* tree_view; | ||||
|     GtkWidget* btnAdd; | ||||
|     GtkWidget* btnEdit; | ||||
|     GtkWidget* btnDel; | ||||
|     GtkWidget* btnFilter; | ||||
|     GtkWidget* lblSetNameDevice; | ||||
| } hotebook; | ||||
| typedef struct { | ||||
|     int weeks; | ||||
|     int days; | ||||
|     int hours; | ||||
|     int minutes; | ||||
|     char* str_time;  | ||||
| } me_time; | ||||
| 
 | ||||
| void philos_array_string_remove_char(char*** array, char* str_remove,  int size); | ||||
| void philos_set_pow_size_memory(char* str_find, int* array_size, char** array_size_pow); | ||||
| void philos_set_size_memory_integer_char(char* str_find, char*** array_data, int index); | ||||
| void philos_free_string_array(char ***array, int size); | ||||
| void philos_free_string_array_n3(char ****array, int size); | ||||
| void philos_free_int_array(int **array, int size); | ||||
| void philos_free_int_array_n2(int ***array, int size); | ||||
| unsigned short philos_read_uid_min_max(char* filename, char* search); | ||||
| config_str philos_list_user(int* size, int flag_lim); | ||||
| config_str philos_list_group(int* size, int flag_lim); | ||||
| char* philos_str_size_pow_byte(GtkWidget *combo_box_text); | ||||
| char* philos_str_remove(char *str, const char *sub); | ||||
| void philos_split_size_memory(char* str_value, int* size, char* pow_memory); | ||||
| char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_memory); | ||||
| char** philos_str_split(char *parameters, int *size, char *divider); | ||||
| void philos_array_str_copy(char*** source, char*** copy); | ||||
| void philos_array_int_copy(int** source, int** copy); | ||||
| char** philos_pars_terminal_systemd_cgls(char* CMD_GET_SLICE_SERVICE, char* str_find, int* size_array_data); | ||||
| char* philos_pard_array_add_cmd(char* cmd, temp_config* _config, char* key, int* array_io, int* array_io_pow_size, char** disk, int size); | ||||
| int philos_check_activ_disk(temp_set_window *widgets, temp_config* _config); | ||||
| void philos_temp_generate_cmd(temp_set_window *widgets, temp_config* _config); | ||||
| void philos_temp_del_disk(temp_set_window *widgets, temp_config* _config, int flag_check_array); | ||||
| void philos_temp_config_init(temp_config* _config); | ||||
| void philos_update_device_to_entry(temp_set_window *widgets, temp_config* _config, int flag_check_array); | ||||
| void philos_temp_add_disk(temp_set_window *widgets, temp_config* _config, int flag_check_array); | ||||
| int* philos_int_append(int* array, int* size, int value); | ||||
| int* remove_element_int_array(int* array, int* size, int item_to_delete); | ||||
| int** remove_element_int_array_n3(int** array, int* size, int item_to_delete); | ||||
| char* philos_get_size_bite(GtkWidget* chk_button, GtkWidget* spin, GtkWidget* combo_box_text); | ||||
| void philos_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size); | ||||
| void philos_set_spin_adjustment(GtkWidget *check, GtkWidget *spin, GtkWidget *combo, size_t value); | ||||
| void philos_set_active_widgets(GtkWidget *check, GtkWidget *spin, GtkWidget *combo); | ||||
| size_t get_resurs_total(char* cmd); | ||||
| float get_size_pow_memory(size_t size_memory, int size); | ||||
| void philos_set_active_widgets_device_io(GtkWidget* combo_to_l2,GtkWidget *check, GtkWidget *spin, GtkWidget *combo); | ||||
| char *yon_char_get_augumented(char *source, char *append); | ||||
| dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data); | ||||
| char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete); | ||||
| char*** yon_char_parsed_shrink_n3(char ***char_string, int *size, int item_to_delete); | ||||
| dictionary *yon_dictionary_create_empty(); | ||||
| void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); | ||||
| dictionary *yon_dictionary_create_conneced(dictionary *targetdict); | ||||
| void yon_int_array_append(int **source, int append); | ||||
| #ifdef VTE_TERMINAL | ||||
| static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data); | ||||
| #endif | ||||
| int philos_config_save(char *command); | ||||
| void philos_array_int_pars_to(int** array, int to); | ||||
| void philos_array_char_pars_to(char*** array, char* to); | ||||
| int find_null_array(temp_config* _config); | ||||
| void init_device_disk(temp_config* _config); | ||||
| char** philos_char_parsed_append(char** parsed, int *size, char *string); | ||||
| void philos_set_size_memory_integer(char* str_find, size_t* array_data); | ||||
| me_time time_convert(size_t seconds); | ||||
| char* fill_tree_view_id(int id); | ||||
| char *philos_char_from_size_t(size_t int_to_convert); | ||||
| size_t philos_convert_memory(char* num_memory_pow); | ||||
| 
 | ||||
| #endif | ||||
| @ -0,0 +1,264 @@ | ||||
| #ifndef SAVE_H | ||||
| #define SAVE_H | ||||
| #include "save.h" | ||||
| 
 | ||||
| char* save_str_users(config_u_g_p* config, int index, char* start_split) { | ||||
|     char* cmd = yon_char_new(""); | ||||
|     char split_simvol[2] = {0}; | ||||
|     split_simvol[0] = 0; | ||||
|     split_simvol[1] = 0; | ||||
|     vector* vec_actors = &config->actors; | ||||
|     char* str_actors = NULL; | ||||
|     if (vec_actors->vectorList.total> 0) { | ||||
|         for (int i = 0; i < vec_actors->vectorList.total; i++) { | ||||
|             if (i==0) { | ||||
|                 cmd = yon_char_unite(cmd, start_split, NULL); | ||||
|             } | ||||
|             str_actors = (char*)vec_actors->pfVectorGet(vec_actors, i); | ||||
|             cmd = yon_char_unite(cmd, split_simvol, str_actors, NULL); | ||||
|             split_simvol[0] = ','; | ||||
|             split_simvol[1] = '\0'; | ||||
|         } | ||||
|     } | ||||
|     return cmd; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| char* template_format_save(vector* vec_temp) { | ||||
|     char* cmd = yon_char_new(""); | ||||
|     if (vec_temp->vectorList.total> 0) { | ||||
|         for (int i = 0; i < vec_temp->pfVectorTotal(vec_temp); i++) { | ||||
|             config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|             char* key = save_format_key(_config, i); | ||||
|             char* value = save_format_str_value(_config, i); | ||||
|             if (key!= NULL) { | ||||
|                 cmd = yon_char_unite(cmd, key, "=" , value, " ", NULL); | ||||
|                 free(key); | ||||
|                 free(value); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return cmd; | ||||
| } | ||||
| 
 | ||||
| char* save_format_status_cmd_all(vector* vec_temp, vector* vec_status_disk) { | ||||
|     char* cmd = yon_char_new(""); | ||||
|     char* str_cmd_format = NULL; | ||||
|     if (vec_temp->vectorList.total > 0 && vec_status_disk->vectorList.total > 0) { | ||||
|         for (int i=0; i < vec_temp->vectorList.total; i++) { | ||||
|             config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, i); | ||||
|             for (int j=0; j < vec_status_disk->vectorList.total;j++) { | ||||
|                 disk_status* config_disk_status = (disk_status*)vec_status_disk->pfVectorGet(vec_status_disk, j); | ||||
|                 if (strstr(config_disk_status->device, _config->UNIX_file) ) { | ||||
|                     str_cmd_format = save_format_status_cmd(config_disk_status, _config); | ||||
|                     if (str_cmd_format) { | ||||
|                         cmd = yon_char_unite(cmd, " ", str_cmd_format, NULL); | ||||
|                         free(str_cmd_format); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     return cmd; | ||||
| } | ||||
| 
 | ||||
| char* set_status_and_del(config_all* _all_config) { | ||||
|     char* cmd = yon_char_new(""); | ||||
|     for (int j=0; j < _all_config->v_disk_status.vectorList.total;j++) { | ||||
|         disk_status* config_disk_status = (disk_status*)_all_config->v_disk_status.pfVectorGet(&_all_config->v_disk_status, j); | ||||
|         if (config_disk_status->status == 2 && (config_disk_status->deferring_size == 0 && config_disk_status->deferring_file == 0)) { | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:" , config_disk_status->device, "]=enable ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:" , config_disk_status->device, "]=enable ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:" , config_disk_status->device, "]=enable ", NULL); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_size"); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_file"); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, config_disk_status->device); | ||||
|         } | ||||
|         else if (config_disk_status->status == 1) { | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:" , config_disk_status->device, "]=disable ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:" , config_disk_status->device, "]=disable ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:" , config_disk_status->device, "]=disable ", NULL); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_size"); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, "deferring_file"); | ||||
|             yon_window_config_erase_custom_parameter(config_disk_status->device, config_disk_status->device); | ||||
|         } | ||||
|         if (config_disk_status->status == 2 && (config_disk_status->deferring_size != 0 || config_disk_status->deferring_file != 0)) { | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[usrquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[grpquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL); | ||||
|             cmd = yon_char_unite(cmd, "DISK_QUOTA[prjquota:", config_disk_status->device, "]=0:0:0:0:",yon_char_from_int(config_disk_status->deferring_size), ":", yon_char_from_int(config_disk_status->deferring_file)," ", NULL); | ||||
|         } | ||||
|     } | ||||
|     return cmd; | ||||
| } | ||||
| 
 | ||||
| char* wrapper_save_format_status_cmd_all(config_all* _all_config) { | ||||
|     return set_status_and_del(_all_config); | ||||
| } | ||||
| 
 | ||||
| char* save_format_status_cmd(disk_status* config_disk_status, config_u_g_p* config) { | ||||
|     char* cmd = yon_char_unite("DISK_QUOTA[", config->type_arr, ":", config->UNIX_file,"]=", NULL);; | ||||
|     if (config_disk_status->status == 2) { | ||||
|         cmd = yon_char_unite(cmd,"enable", NULL); | ||||
|         return cmd; | ||||
|     } | ||||
|     else if (config_disk_status->status == 1) { | ||||
|         return yon_char_unite(cmd,"disable", NULL); | ||||
|     } | ||||
|     else { | ||||
|         return NULL; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| char* wrapper_template_format_save(config_all* _all_config, char* source_set_cmd) { | ||||
|     char* cmd_user = template_format_save(&_all_config->v_user); | ||||
|     char* cmd_group = template_format_save(&_all_config->v_group); | ||||
|     char* cmd_project = template_format_save(&_all_config->v_project); | ||||
|     char* cmd_status_disk =  wrapper_save_format_status_cmd_all(_all_config); | ||||
|     if ((strlen(cmd_status_disk) > 3 || strlen(cmd_user) > 3 || strlen(cmd_group) > 3 || strlen(cmd_project) > 3) && !save_check_save(_all_config)) { | ||||
|         return yon_char_unite(source_set_cmd," ", cmd_status_disk, " ", cmd_user, " ", cmd_group, " ", cmd_project, NULL); | ||||
|     } | ||||
|     return NULL; | ||||
|      | ||||
| } | ||||
| char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd) { | ||||
|     if (_all_config->v_remove.vectorList.total > 0) { | ||||
|         char* cmd = yon_char_new(source_remove_cmd); | ||||
|         for (int i = 0; i < _all_config->v_remove.vectorList.total; i++) { | ||||
|             char* str_remove = (char*)_all_config->v_remove.pfVectorGet(&_all_config->v_remove, i); | ||||
|             cmd = yon_char_unite(cmd, " DISK_QUOTA[" , str_remove, "] ", NULL); | ||||
|         } | ||||
|         if (strlen(cmd) > strlen(source_remove_cmd) && save_check_save(_all_config)== 0) { | ||||
|             return cmd; | ||||
|         } | ||||
|     } | ||||
|     return NULL; | ||||
| 
 | ||||
| } | ||||
| char* template_format_remove_save_device(config_all* _all_config, char* source_remove_cmd) { | ||||
|     char* cmd = yon_char_new(""); | ||||
|     if (_all_config->v_disk_remove.vectorList.total > 0) { | ||||
|         for (int i=0; i < _all_config->v_disk_remove.vectorList.total; i++) { | ||||
|             char* str_del = (char*)_all_config->v_disk_remove.pfVectorGet(&_all_config->v_disk_remove, i); | ||||
|             if (str_del) { | ||||
|                 cmd = yon_char_unite(cmd, " DISK_QUOTA[usrquota:" , str_del, "] ", NULL); | ||||
|                 cmd = yon_char_unite(cmd, " DISK_QUOTA[grpquota:" , str_del, "] ", NULL); | ||||
|                 cmd = yon_char_unite(cmd, " DISK_QUOTA[prjquota:" , str_del, "] ", NULL); | ||||
|                 yon_window_config_erase_custom_parameter(str_del, "deferring_size"); | ||||
|                 yon_window_config_erase_custom_parameter(str_del, "deferring_file"); | ||||
|                 yon_window_config_erase_custom_parameter(str_del, str_del); | ||||
|             } | ||||
|              | ||||
|         } | ||||
|     } | ||||
|     if (strlen(cmd)>5) { | ||||
|         for (int i=0; i < _all_config->v_disk_remove.vectorList.total; i++) { | ||||
|             _all_config->v_disk_remove.pfVectorDelete(&_all_config->v_disk_remove, i); | ||||
|         } | ||||
|         return cmd; | ||||
|     } | ||||
|     else { | ||||
|         return NULL; | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int wrapper_template_save(config_all* _all_config, char* source_set_cmd, char* source_remove_cmd) { | ||||
|     char* str_cmd_remove = template_format_remove_save(_all_config,source_remove_cmd); | ||||
|     char* str_cmd_remove_device = template_format_remove_save_device(_all_config,source_remove_cmd); | ||||
|     char* str_cmd_set = wrapper_template_format_save(_all_config,source_set_cmd); | ||||
|     if (str_cmd_set != NULL && str_cmd_remove != NULL && str_cmd_remove_device != NULL) { | ||||
|         philos_config_save(yon_char_unite(str_cmd_remove, " " ,str_cmd_remove_device, "; " , str_cmd_set, NULL)); | ||||
|     } | ||||
|     else { | ||||
|         if (str_cmd_remove != NULL) { | ||||
|             philos_config_save(str_cmd_remove); | ||||
|         } | ||||
|         if (str_cmd_remove_device != NULL) { | ||||
|             philos_config_save(yon_char_unite(source_remove_cmd, " " , str_cmd_remove_device, NULL)); | ||||
|         } | ||||
|         if (str_cmd_set != NULL) { | ||||
|             philos_config_save(str_cmd_set); | ||||
|         } | ||||
|          | ||||
|     } | ||||
|      | ||||
|     if (str_cmd_remove != NULL) { | ||||
|         free(str_cmd_remove); | ||||
|     } | ||||
|     if (str_cmd_set != NULL) { | ||||
|         free(str_cmd_set); | ||||
|     } | ||||
|     if (str_cmd_remove_device != NULL) { | ||||
|         free(str_cmd_remove_device); | ||||
|     } | ||||
|     vector_init(&_all_config->v_remove); | ||||
|     _all_config->flag_set_data = 0; | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| char* save_format_key(config_u_g_p* config, int index) { | ||||
|     char* value = yon_char_new(""); | ||||
|     char* key = yon_char_new("");  | ||||
|     int number = config->id; | ||||
|     key = yon_char_unite("DISK_QUOTA[", config->type_arr, ":", NULL); | ||||
|     char* unix_file = NULL; | ||||
|     if (strstr(config->UNIX_file, " ") && !strstr(config->UNIX_file, "\"") ) { | ||||
|         unix_file = yon_char_unite("\"", config->UNIX_file, "\"", NULL); | ||||
|     } | ||||
|     else { | ||||
|         unix_file = yon_char_new(config->UNIX_file); | ||||
|     } | ||||
|     if (strstr(config->type_arr, "prjquota")) { | ||||
|         if (number!=-1) { | ||||
|             key = yon_char_unite(key, unix_file,":",yon_char_from_int(number), NULL); | ||||
|         } | ||||
|         else { | ||||
|             key = yon_char_unite(key, unix_file,":AUTO", NULL); | ||||
|         } | ||||
|         key = yon_char_unite(key, save_str_users(config, index, ",") , "]", NULL); | ||||
|     } | ||||
|     else { | ||||
|         key = yon_char_unite(key, unix_file, NULL); | ||||
|         key = yon_char_unite(key, save_str_users(config, index, ":") , "]", NULL); | ||||
|     } | ||||
|     free(unix_file); | ||||
|     return key; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| char* save_format_str_value(config_u_g_p* config, int index) { | ||||
|     char* value = NULL; | ||||
|     if (config->soft_restriction_size) { | ||||
|         value = yon_char_unite(philos_format_cfg_str_size_memory("", config->soft_restriction_size,config->soft_restriction_size_pow), NULL); | ||||
|     } | ||||
|     else { | ||||
|         value = yon_char_new("0"); | ||||
|     } | ||||
|     if (config->severe_limitation_size) { | ||||
|         value = yon_char_unite(value, ":", philos_format_cfg_str_size_memory("", config->severe_limitation_size,config->severe_limitation_size_pow), NULL); | ||||
|     } | ||||
|     else { | ||||
|         value = yon_char_unite(value,":0", NULL); | ||||
|     } | ||||
|     value = yon_char_unite(value, ":", yon_char_from_int(config->soft_restriction_file), NULL); | ||||
|     value = yon_char_unite(value, ":", NULL); | ||||
|     value = yon_char_unite(value, yon_char_from_int(config->severe_limitation_file), NULL); | ||||
|     value = yon_char_unite(value, ":", NULL); | ||||
|     value = yon_char_unite(value, philos_char_from_size_t(config->deferring_size), ":", NULL); | ||||
|     value = yon_char_unite(value, philos_char_from_size_t(config->deferring_file), NULL); | ||||
|     return value; | ||||
| } | ||||
| 
 | ||||
| int save_check_save(config_all* _all_config) { | ||||
|     if (_all_config->flag_set_data == 1 || _all_config->flag_save>0) { | ||||
|         return 0; | ||||
|     } | ||||
|     else if (_all_config->flag_set_data == 0 || _all_config->flag_save<=0) { | ||||
|         return 1; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
| @ -0,0 +1,14 @@ | ||||
| #ifndef SAVE | ||||
| #define SAVE | ||||
| #include "ubl-utils.h" | ||||
| #include "model.h" | ||||
| char* template_format_save(vector* vec_temp); | ||||
| char* save_format_key(config_u_g_p* _config, int index); | ||||
| char* save_str_users(config_u_g_p* _config, int index, char* start_split); | ||||
| char* save_format_str_value(config_u_g_p* config, int index); | ||||
| char* save_format_status_cmd(disk_status* config_disk_status, config_u_g_p* config); | ||||
| char* template_format_remove_save(config_all* _all_config, char* source_remove_cmd); | ||||
| void save_remove_array(config_all* _all_config); | ||||
| int save_check_save(config_all* _all_config); | ||||
| int wrapper_template_save(config_all* _all_config, char* source_set_cmd, char* source_remove_cmd); | ||||
| #endif | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								| @ -0,0 +1,128 @@ | ||||
| #include "vector.h" | ||||
| 
 | ||||
| int vectorTotal(vector *v) | ||||
| { | ||||
|     int totalCount = UNDEFINE; | ||||
|     if(v) | ||||
|     { | ||||
|         totalCount = v->vectorList.total; | ||||
|     } | ||||
|     return totalCount; | ||||
| } | ||||
| int vectorResize(vector *v, int capacity) | ||||
| { | ||||
|     int  status = UNDEFINE; | ||||
|     if(v) | ||||
|     { | ||||
|         void **items = realloc(v->vectorList.items, sizeof(void *) * capacity); | ||||
|         if (items) | ||||
|         { | ||||
|             v->vectorList.items = items; | ||||
|             v->vectorList.capacity = capacity; | ||||
|             status = SUCCESS; | ||||
|         } | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
| int vectorPushBack(vector *v, void *item) | ||||
| { | ||||
|     int  status = UNDEFINE; | ||||
|     if(v) | ||||
|     { | ||||
|         if (v->vectorList.capacity == v->vectorList.total) | ||||
|         { | ||||
|             status = vectorResize(v, v->vectorList.capacity * 2); | ||||
|             if(status != UNDEFINE) | ||||
|             { | ||||
|                 v->vectorList.items[v->vectorList.total++] = item; | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             v->vectorList.items[v->vectorList.total++] = item; | ||||
|             status = SUCCESS; | ||||
|         } | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
| int vectorSet(vector *v, int index, void *item) | ||||
| { | ||||
|     int  status = UNDEFINE; | ||||
|     if(v) | ||||
|     { | ||||
|         if ((index >= 0) && (index < v->vectorList.total)) | ||||
|         { | ||||
|             v->vectorList.items[index] = item; | ||||
|             status = SUCCESS; | ||||
|         } | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
| void *vectorGet(vector *v, int index) | ||||
| { | ||||
|     void *readData = NULL; | ||||
|     if(v) | ||||
|     { | ||||
|         if ((index >= 0) && (index < v->vectorList.total)) | ||||
|         { | ||||
|             readData = v->vectorList.items[index]; | ||||
|         } | ||||
|     } | ||||
|     return readData; | ||||
| } | ||||
| int vectorDelete(vector *v, int index) | ||||
| { | ||||
|     int  status = UNDEFINE; | ||||
|     int i = 0; | ||||
|     if(v) | ||||
|     { | ||||
|         if ((index < 0) || (index >= v->vectorList.total)) | ||||
|             return status; | ||||
|         v->vectorList.items[index] = NULL; | ||||
|         for (i = index; (i < v->vectorList.total - 1); ++i) | ||||
|         { | ||||
|             v->vectorList.items[i] = v->vectorList.items[i + 1]; | ||||
|             v->vectorList.items[i + 1] = NULL; | ||||
|         } | ||||
|         v->vectorList.total--; | ||||
|         if ((v->vectorList.total > 0) && ((v->vectorList.total) == (v->vectorList.capacity / 4))) | ||||
|         { | ||||
|             vectorResize(v, v->vectorList.capacity / 2); | ||||
|         } | ||||
|         status = SUCCESS; | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
| int vectorFree(vector *v) | ||||
| { | ||||
|     int  status = UNDEFINE; | ||||
|     if(v) | ||||
|     { | ||||
|         free(v->vectorList.items); | ||||
|         v->vectorList.items = NULL; | ||||
|         status = SUCCESS; | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
| void vectorCopy(vector* v_to_copy, vector* v_from_copy) { | ||||
|     for (int i = 0; i < v_from_copy->vectorList.total; i++) { | ||||
|         vectorPushBack(v_to_copy, vectorGet(v_from_copy, i));  | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void vector_init(vector *v) | ||||
| { | ||||
|     //init function pointers
 | ||||
|     v->pfVectorTotal = vectorTotal; | ||||
|     v->pfVectorResize = vectorResize; | ||||
|     v->pfVectorAdd = vectorPushBack; | ||||
|     v->pfVectorSet = vectorSet; | ||||
|     v->pfVectorGet = vectorGet; | ||||
|     v->pfVectorFree = vectorFree; | ||||
|     v->pfVectorDelete = vectorDelete; | ||||
|     v->pfVectorCopy = vectorCopy; | ||||
|     //initialize the capacity and allocate the memory
 | ||||
|     v->vectorList.capacity = VECTOR_INIT_CAPACITY; | ||||
|     v->vectorList.total = 0; | ||||
|     v->vectorList.items = malloc(sizeof(void *) * v->vectorList.capacity); | ||||
| } | ||||
| @ -0,0 +1,40 @@ | ||||
| #include <stdio.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| // https://aticleworld.com/implement-vector-in-c/
 | ||||
| 
 | ||||
| #define VECTOR_INIT_CAPACITY 7 | ||||
| #define UNDEFINE  -1 | ||||
| #define SUCCESS 0 | ||||
| //Store and track the stored data
 | ||||
| typedef struct sVectorList | ||||
| { | ||||
|     void **items; | ||||
|     int capacity; | ||||
|     int total; | ||||
| } sVectorList; | ||||
| //structure contain the function pointer
 | ||||
| typedef struct sVector vector; | ||||
| struct sVector | ||||
| { | ||||
|     sVectorList vectorList; | ||||
| //function pointers
 | ||||
|     int (*pfVectorTotal)(vector *); | ||||
|     int (*pfVectorResize)(vector *, int); | ||||
|     int (*pfVectorAdd)(vector *, void *); | ||||
|     int (*pfVectorSet)(vector *, int, void *); | ||||
|     void *(*pfVectorGet)(vector *, int); | ||||
|     int (*pfVectorDelete)(vector *, int); | ||||
|     int (*pfVectorFree)(vector *); | ||||
|     void (*pfVectorCopy)(vector *,vector *); | ||||
|      | ||||
| }; | ||||
| void vector_init(vector *v); | ||||
| int vectorFree(vector *v); | ||||
| int vectorDelete(vector *v, int index); | ||||
| void *vectorGet(vector *v, int index); | ||||
| int vectorSet(vector *v, int index, void *item); | ||||
| int vectorPushBack(vector *v, void *item); | ||||
| int vectorResize(vector *v, int capacity); | ||||
| int vectorTotal(vector *v); | ||||
| void vectorCopy(vector* v_to_copy, vector* v_from_copy); | ||||
| @ -1,79 +0,0 @@ | ||||
| #ifndef MY_TYPE_H | ||||
| #define MY_TYPE_H | ||||
| 
 | ||||
| #include "project_lib.h" | ||||
| #include <string> | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| typedef unsigned long max_num_T; | ||||
| 
 | ||||
| struct users_grups{ | ||||
|         string name; | ||||
|         bool state; | ||||
|         max_num_T size_data; | ||||
|         max_num_T soft_limit_size; | ||||
|         max_num_T severe_restriction_size; | ||||
|         max_num_T postponement_size_brat; | ||||
|         max_num_T hard_limit_activation_time_size; | ||||
|         max_num_T file; | ||||
|         max_num_T soft_file_limitation; | ||||
|         max_num_T hard_file_restriction; | ||||
|         max_num_T postponement_hard_file_restriction; | ||||
|         max_num_T hard_limit_activation_time; | ||||
|         }; | ||||
| struct Mount { | ||||
|         std::string device; | ||||
|         std::string destination; | ||||
|         std::string fstype; | ||||
|         std::string options; | ||||
|         std::string dump; | ||||
|         std::string pass; | ||||
| }; | ||||
| struct partition_cmd { | ||||
|         string device; | ||||
|         string cmd; | ||||
| }; | ||||
| struct struct_quotas { | ||||
|         string device; | ||||
|         string cmd; | ||||
|         string type_quotas; | ||||
|         string name; | ||||
| }; | ||||
| struct status_quotas { | ||||
|         bool user; | ||||
|         bool group; | ||||
|         bool project; | ||||
|         bool status; | ||||
| }; | ||||
| struct data_all_quotas { | ||||
|         string username; | ||||
|         string status; | ||||
|         string block_used; | ||||
|         string block_soft; | ||||
|         string block_hard;   | ||||
|         string block_grace; | ||||
|         string file_used; | ||||
|         string file_soft; | ||||
|         string file_hard; | ||||
|         string file_grace; | ||||
|         bool is_validate; | ||||
| }; | ||||
| struct tv_g_u_p { | ||||
|         string name; | ||||
|         string quotas; | ||||
|         string size; | ||||
|         string soft_limit_size; | ||||
|         string hard_limit_size; | ||||
|         string deferring_size; | ||||
|         string files; | ||||
|         string soft_limit_files; | ||||
|         string hard_limit_delay; | ||||
|         string deferring_files; | ||||
| }; | ||||
| 
 | ||||
| typedef struct users_grups USER_GRUPS; | ||||
| typedef map <string, string> map_str_str; | ||||
| typedef map <string, string>* map_s_s_ptr; | ||||
| typedef std::map<std::string, Mount> map_str_device; | ||||
| #endif | ||||
| @ -1,27 +0,0 @@ | ||||
| #ifndef PROJECT_LIB_H | ||||
| #define PROJECT_LIB_H | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <sstream> | ||||
| #include <string> | ||||
| #include <array> | ||||
| #include <vector> | ||||
| #include <linux/limits.h> | ||||
| #include <unistd.h> | ||||
| #include <sys/types.h> | ||||
| #include <iostream> | ||||
| #include <fstream> | ||||
| #include <filesystem> | ||||
| #include <pwd.h> | ||||
| #include <cstddef> | ||||
| #include <gtkmm.h> | ||||
| #include <gtkmm/stock.h> | ||||
| #include <gtkmm/window.h> | ||||
| #include <gtkmm/plug.h> | ||||
| #include <locale.h> | ||||
| #include <libintl.h> | ||||
| #include <glibmm/i18n.h> | ||||
| #include <map> | ||||
| #include "ubl-settings-diskquota-cm.h" | ||||
| 
 | ||||
| #endif | ||||
| @ -0,0 +1 @@ | ||||
| #cmakedefine WEBKIT_FOUND | ||||
| @ -1 +0,0 @@ | ||||
| #cmakedefine WEBKIT_FOUND | ||||
| @ -0,0 +1,101 @@ | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #include <libintl.h> | ||||
| #include <libintl.h> | ||||
| #define _(String) gettext(String) | ||||
| 
 | ||||
| 
 | ||||
| #define HELP_LABEL yon_char_unite(_("ubl-settings-diskquota version:")," ", version_application,"\n","\n",_("Usage:"), " ubl-settings-diskquota ",_("[OPTIONS]"),"\n",_("Options:"),"\n\t--help, -h\t\t\t",_("Show this help"),"\n\t--version, -V\t\t\t",_("Show package version"),"\n\t--lock-help\t\t\t",_("Lock this help menu"),"\n\t--lock-save\t\t\t",_("Lock configuration saving"),"\n\t--lock-save-local\t\t",_("Lock local configration saving"),"\n\t--lock-save-global\t\t",_("Lock global configration saving"),"\n\t--lock-load-global\t\t",_("Lock global configration loading"),"\n",NULL) | ||||
| 
 | ||||
| #define TITLE_LABEL _("Disk quotas") | ||||
| #define TITLE_INFO_LABEL _("Configuring disk quota settings for system groups and users") | ||||
| 
 | ||||
| #define SUCCESS_LABEL _("Operation succeeded") | ||||
| #define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked.") | ||||
| 
 | ||||
| #define ABOUT_LABEL _("About") | ||||
| #define DOCUMENTATION_LABEL _("Documentation") | ||||
| 
 | ||||
| #define SAVE_LOCAL_LABEL _("Save to local configuration") | ||||
| #define SAVE_GLOBAL_LABEL _("Save to global configuration") | ||||
| #define SAVE_CONFIGURATION_LABEL _("Save configuration") | ||||
| #define SAVE_LABEL _("Save") | ||||
| 
 | ||||
| #define LOAD_LOCAL_LABEL _("Load local configuration") | ||||
| #define LOAD_GLOBAL_LABEL _("Load global configuration") | ||||
| #define LOAD_LABEL _("Load") | ||||
| 
 | ||||
| #define CANCEL_LABEL _("Cancel") | ||||
| 
 | ||||
| #define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") | ||||
| #define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") | ||||
| #define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") | ||||
| #define OPEN_HELP_LABEL _("Open documentation") | ||||
| #define PROJECT_HOME_LABEL _("Project Home Page") | ||||
| #define NOTHING_CHOSEN_LABEL _("Nothing were chosen") | ||||
| 
 | ||||
| 
 | ||||
| #define GLOBAL_LOAD_SUCCESS_LABEL _("Global configuration loading succseeded.") | ||||
| #define LOCAL_LOAD_SUCCESS_LABEL _("Local configuration loading succseeded.") | ||||
| #define LOAD_FAILED_LABEL _("Config loading failed") | ||||
| 
 | ||||
| #define GLOBAL_LOCAL_SAVE_SUCCESS_LABEL _("Local and global configuration saving succseeded.") | ||||
| #define GLOBAL_SAVE_SUCCESS_LABEL _("Global configuration saving succseeded.") | ||||
| #define LOCAL_SAVE_SUCCESS_LABEL _("Local configuration saving succseeded.") | ||||
| #define MESS_NOTHING_SAVE _("Nothing to save!") | ||||
| 
 | ||||
| #define STR_KB _("Kb") | ||||
| #define STR_MB _("Mb") | ||||
| #define STR_GB _("Gb") | ||||
| #define STR_TB _("Tb") | ||||
| 
 | ||||
| 
 | ||||
| #define CMD_LOAD_GLOBAL "ubconfig --default --source global get security DISK_QUOTA[*]" | ||||
| #define CMD_LOAD_SYSTEM "ubconfig --default --source system get security DISK_QUOTA[*]" | ||||
| #define CMD_SAVE_GLOBAL "ubconfig --target global set security" | ||||
| #define CMD_SAVE_SYSTEM "ubconfig --target system set security" | ||||
| #define CMD_ALL_SAVE "ubconfig set security " | ||||
| #define CMD_ALL_REMOVE "ubconfig remove security " | ||||
| #define CMD_REMOVE_GLOBAL "ubconfig --target global --noexecute remove security " | ||||
| #define CMD_REMOVE_SYSTEM "ubconfig --target system remove security " | ||||
| 
 | ||||
| #define empty_str "-" | ||||
| #define WEEKS _("w ") | ||||
| #define DAYS _("d ") | ||||
| #define HOURS _("h ") | ||||
| #define MINUTES _("m ") | ||||
| 
 | ||||
| #define STR_ON _("On") | ||||
| #define STR_OFF _("Off") | ||||
| #define STR_NOT_SET _("Not set") | ||||
| #define STR_TITLE_ADD_QUOTAS _("Settings quotas - Addition") | ||||
| #define STR_TITLE_EDIT_QUOTAS _("Settings quotas - Editing") | ||||
| 
 | ||||
| #define SAVE_FAILED_LABEL | ||||
| 
 | ||||
| #define STR_TITLE_FILE_MANGER _("Please select folder") | ||||
| 
 | ||||
| #define STR_USER _("User") | ||||
| #define STR_GROUP _("Group") | ||||
| #define STR_PROJECT _("Project") | ||||
| #define STR_USERS _("Users") | ||||
| #define STR_GROUPS _("Groups") | ||||
| 
 | ||||
| #define STR_ERROR_MESS_NOT_DIR _("Is not a directory") | ||||
| #define STR_CHK_LABEL_WRITE_ALL_USERS _("Withdraw all users") | ||||
| #define STR_CHK_LABEL_WRITE_ALL_GROUPS _("Withdraw all groups") | ||||
| 
 | ||||
| #define STR_ERROR_ERROR_PROJECT_ID _("Project ID mandatory field") | ||||
| #define STR_ERROR_PATH_IS_DISK_FALSE_1 _("The path does not match the specified disk") | ||||
| #define STR_ERROR_PROJECT_NAME_VALUE_NULL _("Project name mandatory field") | ||||
| #define STR_ERROR_PROJECT_NAME_ENTER_VALUE _("Project name required field") | ||||
| #define STR_ERROR_LIST_USER_NULL _("The list of users is empty") | ||||
| #define STR_ERROR_NO_SELECTED_DISK _("To save, you need to select a disk") | ||||
| #define STR_ERROR_ENTRY_VALUE_VOLUME_OR_FILES _("The volume and files fields must have at least one value") | ||||
| #define STR_ERROR_PATH_IS_DISK_FALSE _("The selected directory is not located on the target device") | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -1,34 +0,0 @@ | ||||
| #include "load.h" | ||||
| 
 | ||||
| namespace Lib_Load{ | ||||
|     void Load::set_count_error(int count_error) { | ||||
|         process.set_count_error(count_error); | ||||
|     } | ||||
|     string Load::get_cmd_error() { | ||||
|         return process.get_cmd_error(); | ||||
|     } | ||||
|     map<string, string>& Load::get_load_data(std::map <string, string> &map_temp, string cmd) { | ||||
|         string response = ""; | ||||
|         string key = ""; | ||||
|         string value = ""; | ||||
|         response = process.call_all_sections(cmd); | ||||
|         vector<string> vec_str_key_value = Utils::split(response, '\n'); | ||||
|         for (const string ¶m: vec_str_key_value) { | ||||
|             if ((param.find("(null)") == std::string::npos) && (param.length() != 0 )) {  | ||||
|                 if (param.find("=") != std::string::npos) { | ||||
|                     size_t index = param.find("="); | ||||
|                     key = param.substr(0, index); | ||||
|                     value = param.substr(index + 1, param.length()); | ||||
|                     Utils::str_replace_all(value, " \"",""); | ||||
|                     Utils::str_replace_all(value, "\"",""); | ||||
|                     map_temp[key] = value; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return map_temp; | ||||
|     } | ||||
|     int Load::get_count_error() { | ||||
|         return process.get_count_error(); | ||||
|     } | ||||
|      | ||||
| } | ||||
| @ -1,20 +0,0 @@ | ||||
| #ifndef LOAD_H | ||||
| #define LOAD_H | ||||
| 
 | ||||
| #include "my_process.h" | ||||
| namespace Lib_Load{ | ||||
|     class Load { | ||||
|          | ||||
|     private: | ||||
|         string sections; | ||||
|         My_Process::My_Process_call process = My_Process::My_Process_call(); | ||||
|     public: | ||||
|         int get_count_error(); | ||||
|         void set_count_error(int count_error); | ||||
|         string get_cmd_error(); | ||||
|         map<string, string>& get_load_data(std::map <string, string> &map_temp, string str_flag_load); | ||||
|     }; | ||||
| 
 | ||||
|      | ||||
| } | ||||
| #endif | ||||
| @ -1,84 +0,0 @@ | ||||
| #include "my_process.h" | ||||
| #include "util.h" | ||||
| 
 | ||||
| namespace My_Process {  | ||||
| #define debug false | ||||
| struct Utils::Result<string> My_Process_call::call(string cmd) { | ||||
|     this->i_error_old = this->i_error; | ||||
|     struct Utils::Result<string> obj_result; | ||||
|     string response = Utils::call(cmd); | ||||
|     obj_result.response = response; | ||||
|     if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) { | ||||
|         if (response.find("=") != std::string::npos) { | ||||
|             if (response.find("\n") != std::string::npos) { | ||||
|                 response = response.substr(response.find("=")+1,response.length()); | ||||
|                 response = response.substr(0,response.find("\n")); | ||||
|                 obj_result.response = response; | ||||
|                 obj_result.error = 0; | ||||
|             } | ||||
|             else { | ||||
|                 obj_result.error = 1; | ||||
|                 this->i_error += 1; | ||||
|                 this->log_mess_error(cmd); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             obj_result.error = 2; | ||||
|             this->i_error += 1; | ||||
|             str_cmd_error = cmd; | ||||
|             this->log_mess_error(cmd); | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         obj_result.error = 3; | ||||
|         this->i_error += 1; | ||||
|         str_cmd_error = cmd; | ||||
|         this->log_mess_error(cmd); | ||||
|     } | ||||
|     return obj_result; | ||||
| } | ||||
| 
 | ||||
| int My_Process::get_count_error() { | ||||
|     return this->i_error; | ||||
| } | ||||
| 
 | ||||
| void My_Process::set_back_count_error() { | ||||
|     this->i_error = this->i_error_old; | ||||
| } | ||||
| 
 | ||||
| void My_Process_system::call(string cmd, string thread_str = "") { | ||||
|     string cmd_new = cmd + " " + thread_str; | ||||
|     int response_cmd = system(cmd_new.c_str()); | ||||
|     if (response_cmd != 0) { | ||||
|         this->i_error += 1; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void My_Process::set_count_error(int count_error) { | ||||
|     this->i_error = count_error; | ||||
|     this->str_cmd_error = ""; | ||||
| } | ||||
| 
 | ||||
| void My_Process::log_mess_error(string) { | ||||
| } | ||||
| 
 | ||||
| string My_Process::get_cmd_error() { | ||||
|     return this->str_cmd_error; | ||||
| } | ||||
| string My_Process_call::call_all_sections(string cmd) { | ||||
|     char buffer[PATH_MAX] = {0}; | ||||
|     std::string result = ""; | ||||
|     FILE* pipe = popen(cmd.c_str(), "r"); | ||||
|     if (!pipe) throw std::runtime_error("popen() failed!"); | ||||
|     try { | ||||
|         while (fgets(buffer, sizeof buffer, pipe) != NULL) { | ||||
|             result += buffer; | ||||
|         } | ||||
|     } catch (...) { | ||||
|         pclose(pipe); | ||||
|         throw; | ||||
|     } | ||||
|     pclose(pipe); | ||||
|     return result; | ||||
| } | ||||
| } | ||||
| @ -1,32 +0,0 @@ | ||||
| #ifndef MY_PROCESS_H | ||||
| #define MY_PROCESS_H | ||||
| 
 | ||||
| #include "util.h" | ||||
| namespace My_Process {  | ||||
| class My_Process { | ||||
|     public: | ||||
|     int i_error = 0; | ||||
|     int i_error_old = 0; | ||||
|     string str_cmd_error = ""; | ||||
|     int get_count_error(); | ||||
|     void set_count_error(int count_error); | ||||
|     void set_back_count_error(); | ||||
|     void log_mess_error(string); | ||||
|     string get_cmd_error(); | ||||
| }; | ||||
|      | ||||
| 
 | ||||
| class My_Process_call: public My_Process { | ||||
|     public:  | ||||
|         struct Utils::Result<string> call(string cmd); | ||||
|         string call_all_sections(string cmd); | ||||
|      | ||||
| }; | ||||
| 
 | ||||
| class My_Process_system: public My_Process { | ||||
|     public: | ||||
|         void call(string cmd, string thread_str); | ||||
| 
 | ||||
| }; | ||||
| } | ||||
| #endif | ||||
| @ -1,151 +0,0 @@ | ||||
| #include "save.h" | ||||
| 
 | ||||
| namespace Lib_save { | ||||
| 
 | ||||
| vector<string> Save::get_error() { | ||||
|     return this->vec_errors; | ||||
| } | ||||
| 
 | ||||
| bool Save::get_state_save() { | ||||
|     return this->flag_no_save; | ||||
| } | ||||
| 
 | ||||
| void Save::set_data_global(std::map <string, string> &map_global) { | ||||
|     this->map_global = &map_global; | ||||
| } | ||||
| 
 | ||||
| void Save::set_data_local(std::map <string, string> &map_local) { | ||||
|     this->map_local = &map_local; | ||||
| } | ||||
| 
 | ||||
| void Save::set_data_gui(std::map <string, string> &map_gui) { | ||||
|     this->map_gui = &map_gui; | ||||
| } | ||||
| 
 | ||||
| bool Save::check_save(string flag_save, string key_name) { | ||||
|     std::map <string, string>:: iterator iter_map_data; | ||||
|     std::map <string, string>:: iterator iter_map_data_old; | ||||
|     std::map <string, string> *map_data_old; | ||||
|     if (flag_save == "system") { | ||||
|         map_data_old = map_local; | ||||
|     } | ||||
|     else if (flag_save == "global") { | ||||
|         map_data_old = map_global; | ||||
|     } | ||||
|     iter_map_data = (*map_gui).find(key_name); | ||||
|     iter_map_data_old = (*map_data_old).find(key_name); | ||||
|     if ((*map_local).find(key_name) != (*map_local).end() && (*map_global).find(key_name) != (*map_global).end()) { | ||||
|         if ((*map_local)[key_name] != (*map_global)[key_name]) { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
|     if (iter_map_data_old == (*map_data_old).end() && iter_map_data != (*map_gui).end()) { | ||||
|         return true; | ||||
|     } | ||||
|     else if (iter_map_data->second != iter_map_data_old->second) { | ||||
|         return true; | ||||
|     } | ||||
|     else if (iter_map_data->second.length() == 0 && iter_map_data_old->second.length() == 0) { | ||||
|         return false; | ||||
|     } | ||||
|     else if (iter_map_data->second == iter_map_data_old->second) { | ||||
|         return false; | ||||
|     } | ||||
|     else { | ||||
|         return true; | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| int Save::get_count_error() { | ||||
|     return process.get_count_error(); | ||||
| } | ||||
| 
 | ||||
| string Save::get_cmd_error() { | ||||
|     return process.get_cmd_error(); | ||||
| } | ||||
| 
 | ||||
| void Save::set_count_error(int count_error) { | ||||
|     process.set_count_error(count_error); | ||||
| } | ||||
| 
 | ||||
| void Save::set_vec_params(vector<string>& vec_param_names) { | ||||
|     this->vec_param_names = &vec_param_names; | ||||
| } | ||||
| 
 | ||||
| void Save::save(string sections, string str_flag_save) { | ||||
|     string key = ""; | ||||
|     string value = ""; | ||||
|     string cmd = ""; | ||||
|     string str_error = ""; | ||||
|     this->flag_no_save = true; | ||||
|     for (const auto &key: *vec_param_names) { | ||||
|         if (map_gui->find(key) != map_gui->end()) { | ||||
|             value = (*map_gui)[key]; | ||||
|             if (this->check_save(str_flag_save, key)) { | ||||
|                 if (value.length() != 0) { | ||||
|                     cmd = "ubconfig --target  " + str_flag_save + " set " + sections + " " + | ||||
|                             key + "=\"" + value + "\""; | ||||
|                 } | ||||
|                 else if (value.length() == 0) { | ||||
|                     cmd = "ubconfig --target  " + str_flag_save + " remove " + sections + " " + key; | ||||
|                 } | ||||
|                 else { | ||||
|                     cmd = ""; | ||||
|                 } | ||||
|                 if (cmd.length() != 0) { | ||||
|                     process.call(cmd, ""); | ||||
|                     this->flag_no_save = false; | ||||
|                     str_error = process.get_cmd_error(); | ||||
|                     if (str_error.length() != 0) { | ||||
|                         this->vec_errors.push_back(str_error); | ||||
|                         str_error = ""; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|          | ||||
|     } | ||||
| } | ||||
| void Save::save_one_cmd(string cmd1, string cmd_remove, string str_flag_save) { | ||||
|     string key = ""; | ||||
|     string value = ""; | ||||
|     string cmd = ""; | ||||
|     this->flag_no_save = true; | ||||
|     cmd = cmd1; | ||||
|     string remove = cmd_remove; | ||||
|     for (const auto &key: *vec_param_names) { | ||||
|         if (map_gui->find(key) != map_gui->end()) { | ||||
|             value = (*map_gui)[key]; | ||||
|             if (this->check_save(str_flag_save, key)) { | ||||
|                 if (value.length() != 0) { | ||||
|                     cmd = cmd + key + "=\"" + value + "\" "; | ||||
|                 } | ||||
|                 else if (value.length() == 0) { | ||||
|                     remove = remove + key + " "; | ||||
|                 } | ||||
|                  | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     if (cmd.length() != cmd1.length()) { | ||||
|         this->template_save(cmd); | ||||
|     } | ||||
|     if (cmd_remove.length() != remove.length()) { | ||||
|         this->template_save(remove); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Save::template_save(string cmd) { | ||||
|     string str_error = ""; | ||||
|     process.call(cmd, ""); | ||||
|     this->flag_no_save = false; | ||||
|     str_error = process.get_cmd_error(); | ||||
|     if (str_error.length() != 0) { | ||||
|         this->vec_errors.push_back(str_error); | ||||
|         str_error = ""; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| } | ||||
| @ -1,33 +0,0 @@ | ||||
| #ifndef MY_SAVE_H | ||||
| #define MY_SAVE_H | ||||
| 
 | ||||
| #include "my_process.h" | ||||
| namespace Lib_save { | ||||
| 
 | ||||
| class Save { | ||||
| private: | ||||
|     std::map <string, string> *map_global; | ||||
|     std::map <string, string> *map_local; | ||||
|     std::map <string, string> *map_gui; | ||||
|     vector<string> vec_errors; | ||||
|     vector<string>* vec_param_names; | ||||
|     My_Process::My_Process_system process = My_Process::My_Process_system(); | ||||
|     bool flag_no_save; | ||||
|     void template_save(string cmd); | ||||
| public: | ||||
|     void set_data_global(std::map <string, string> &map_global); | ||||
|     void set_data_local(std::map <string, string> &map_local); | ||||
|     void set_data_gui(std::map <string, string> &map_gui); | ||||
|     bool check_save(string flag_save, string key_name); | ||||
|     bool get_state_save(); | ||||
|      | ||||
|     void save_one_cmd(string cmd1, string cmd_remove, string str_flag_save); | ||||
|     int get_count_error(); | ||||
|     string get_cmd_error(); | ||||
|     void set_count_error(int count_error); | ||||
|     void set_vec_params(vector<string>& vec_param_names); | ||||
|     void save(string sections, string str_flag_save) ; | ||||
|     vector<string> get_error(); | ||||
| }; | ||||
| } | ||||
| #endif | ||||
| @ -1,39 +0,0 @@ | ||||
| #include "ubconfig_quota.h" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| Ubconfig_quota::Ubconfig_quota(/* args */) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| Ubconfig_quota::~Ubconfig_quota() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::set_map_global(map_str_str* map_global_cfg) { | ||||
|     this->map_global_cfg = map_global_cfg; | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::set_map_local(map_str_str* map_system_cfg) { | ||||
|     this->map_system_cfg = map_system_cfg; | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::remove_key_to_vec(string key) { | ||||
|     cout << key << endl; | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::add_key_to_vec(string key) { | ||||
|     cout << key << endl; | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::set_vec_key(vector<string>* vec_param_names) { | ||||
|     this->vec_param_names = vec_param_names; | ||||
| } | ||||
| 
 | ||||
| void Ubconfig_quota::format_data() { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -1,58 +0,0 @@ | ||||
| #ifndef UBCONFIG_QUOTAS_H | ||||
| #define UBCONFIG_QUOTAS_H | ||||
| 
 | ||||
| #include "../../my_type.h" | ||||
| #include "../../project_lib.h" | ||||
| 
 | ||||
| class Ubconfig_quota | ||||
| { | ||||
| private: | ||||
|     map_str_str* map_gui_cfg = NULL; | ||||
|     map_str_str* map_global_cfg = NULL; | ||||
|     map_str_str* map_system_cfg = NULL; | ||||
|     vector<string>* vec_param_names = NULL; | ||||
|     struct Size { | ||||
|         int size_0; | ||||
|         int size_1; | ||||
|         int size_2; | ||||
|         int size_3; | ||||
|         int size_4; | ||||
|         int size_5; | ||||
|     }; | ||||
|     struct User { | ||||
|         bool active; | ||||
|         string device; | ||||
|         vector<string> users; | ||||
|         struct Size obj_size; | ||||
|     }; | ||||
|     struct Group { | ||||
|         bool active; | ||||
|         string device; | ||||
|         vector<string> groups; | ||||
|         struct Size obj_size; | ||||
|     }; | ||||
|     struct Prjquota { | ||||
|         bool active; | ||||
|         string device; | ||||
|         vector<string> prjquota_name; | ||||
|         struct Size obj_size; | ||||
|     }; | ||||
|     struct Quotas  { | ||||
|         struct User obj_user; | ||||
|         struct Group obj_group; | ||||
|         struct Prjquota obj_prjquota; | ||||
|     }; | ||||
| public: | ||||
|     Ubconfig_quota(/* args */); | ||||
|     ~Ubconfig_quota(); | ||||
|     void set_map_gui(map_str_str* map_gui_cfg); | ||||
|     void set_map_global(map_str_str* map_global_cfg); | ||||
|     void set_map_local(map_str_str* map_system_cfg); | ||||
|     void set_vec_key(vector<string>* vec_param_names); | ||||
|     void remove_key_to_vec(string key); | ||||
|     void add_key_to_vec(string key); | ||||
|     void format_data(); | ||||
|      | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| @ -1,34 +0,0 @@ | ||||
| #ifndef UTIL_H | ||||
| #define UTIL_H | ||||
| #include "../../project_lib.h" | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| namespace Utils { | ||||
| #define file_source_login_min_max "/etc/login.defs" | ||||
| template<typename Type> | ||||
| struct Result{ | ||||
|     Type response; | ||||
|     int error; | ||||
| }; | ||||
| 
 | ||||
| struct Passwd { | ||||
|     string user; | ||||
|     int uid; | ||||
| }; | ||||
| 
 | ||||
| string format_str_size(int num, int index); | ||||
| std::array<std::vector<std::string>, 5> read_csv(const std::string& filename); | ||||
| std::string call(std::string cmd); | ||||
| vector<int> find_all(string &str_ntp, string substr); | ||||
| void str_remove(std::string& source, std::string to_remove); | ||||
| void str_replace_all(string &str_base, string str_find, string str_replace); | ||||
| std::vector<std::string> split(std::string text, char delim); | ||||
| vector <string> pars_users(); | ||||
| int synopsis_show(string str_link); | ||||
| string file_read(string filename); | ||||
| unsigned short read_uid_min_max(string filename, string search); | ||||
| vector<string> pars_users(); | ||||
| vector<string> pars_group(); | ||||
| } | ||||
| #endif | ||||
| @ -1,133 +0,0 @@ | ||||
| #include "wrapper_load_save.h" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| Wrapper_load_save::Wrapper_load_save(/* args */) { | ||||
|     //obj_quotas_sys.set_map_gui(map_gui_cfg);
 | ||||
|     //obj_quotas_ubconfig.set_map_gui(map_gui_cfg);
 | ||||
| } | ||||
| 
 | ||||
| Wrapper_load_save::~Wrapper_load_save() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::set_map_gui(map_str_str* map_gui_cfg) { | ||||
|     this->map_gui_cfg = map_gui_cfg; | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::set_map_global(map_str_str* map_global_cfg) { | ||||
|     this->map_global_cfg = map_global_cfg; | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::set_map_local(map_str_str* map_system_cfg) { | ||||
|     this->map_system_cfg = map_system_cfg; | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::set_vec_key(vector<string> vec_param_names) { | ||||
|     this->vec_param_names = vec_param_names; | ||||
| } | ||||
| 
 | ||||
| int Wrapper_load_save::load_global_cfg() { | ||||
|     this->load_template(map_global_cfg, global_load); | ||||
|     *map_gui_cfg = *map_global_cfg; | ||||
|     return 1; | ||||
|      | ||||
| } | ||||
| 
 | ||||
| int Wrapper_load_save::load_system_cfg() { | ||||
|     this->load_template(map_system_cfg, system_load); | ||||
|     *map_gui_cfg = *map_system_cfg; | ||||
|     return 0; | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::load_template(map_str_str* map_temp, string cmd) { | ||||
|     if (cmd.find("system") != string::npos) { | ||||
|         this->init_dict("system"); | ||||
|     } | ||||
|     else { | ||||
|         this->init_dict("global"); | ||||
|     } | ||||
|     *map_temp = obj_load.get_load_data(*map_temp, cmd); | ||||
| } | ||||
| 
 | ||||
| int Wrapper_load_save::wrapper_save_global_cfg() { | ||||
|     this->set_data_cfg(); | ||||
|     if (this->save_template("boot", "global")) { | ||||
|         *map_global_cfg = *map_gui_cfg; | ||||
|         return 5; | ||||
|     } | ||||
|     else { | ||||
|         *map_global_cfg = *map_gui_cfg; | ||||
|         return 3; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| int Wrapper_load_save::wrapper_save_system_cfg() { | ||||
|     this->set_data_cfg(); | ||||
|     if (this->save_template("boot", "system")) { | ||||
|         *map_system_cfg = *map_gui_cfg; | ||||
|         return 5; | ||||
|     } | ||||
|     else { | ||||
|         *map_system_cfg = *map_gui_cfg; | ||||
|         return 2; | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| int Wrapper_load_save::wrapper_save_all_cfg() { | ||||
|     this->set_data_cfg(); | ||||
|     bool _flag_save_global = this->save_template("boot", "global");; | ||||
|     bool _flag_save_local = this->save_template("boot", "system"); | ||||
|     if (_flag_save_global && _flag_save_local) { | ||||
|         *map_global_cfg = *map_gui_cfg; | ||||
|         *map_system_cfg = *map_gui_cfg; | ||||
|         return 5; | ||||
|     } | ||||
|     else { | ||||
|         *map_global_cfg = *map_gui_cfg; | ||||
|         *map_system_cfg = *map_gui_cfg; | ||||
|         return 4; | ||||
|     } | ||||
|      | ||||
|      | ||||
| } | ||||
| 
 | ||||
| int Wrapper_load_save::get_error_load() { | ||||
|     return obj_load.get_count_error(); | ||||
| } | ||||
| int Wrapper_load_save::get_error_save() { | ||||
|     return obj_save.get_count_error(); | ||||
| } | ||||
| 
 | ||||
| bool Wrapper_load_save::save_template(string section, string flag_save) { | ||||
|     bool flag_no_save = true; | ||||
|     obj_save.set_data_local(*map_system_cfg); | ||||
|     obj_save.set_data_global(*map_global_cfg); | ||||
|     obj_save.set_data_gui(*map_gui_cfg); | ||||
|     obj_save.set_vec_params(vec_param_names); | ||||
|     obj_save.save(section, flag_save); | ||||
|     vector<string> obj_vec_error = obj_save.get_error(); | ||||
|     flag_no_save = obj_save.get_state_save(); | ||||
|     return flag_no_save; | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::init_dict(string flag_load) { | ||||
|     map_str_str map_gui_cfg_n; | ||||
|     map_gui_cfg_n[""] = ""; | ||||
| 
 | ||||
|     *map_gui_cfg = map_gui_cfg_n; | ||||
|     if (flag_load == "global") { | ||||
|         *map_global_cfg = *map_gui_cfg; | ||||
|     } | ||||
|     else if (flag_load == "system") { | ||||
|         *map_system_cfg = *map_gui_cfg; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void Wrapper_load_save::set_data_cfg() { | ||||
|     // TODO:
 | ||||
|     // Написать функцию
 | ||||
| } | ||||
| @ -1,55 +0,0 @@ | ||||
| #ifndef WRAPPER_LOAD_SAVE_H | ||||
| #define WRAPPER_LOAD_SAVE_H | ||||
| #include "../../my_type.h" | ||||
| #include "../../project_lib.h" | ||||
| #include "load.h" | ||||
| #include "save.h" | ||||
| #include "my_process.h" | ||||
| #include "util.h" | ||||
| #define global_load "ubconfig --default --source global get boot" | ||||
| #define system_load "ubconfig --default --source system get boot" | ||||
| #define global_save "ubconfig --target global --noexecute set boot " | ||||
| #define system_save "ubconfig --target system set boot " | ||||
| #define all_save "ubconfig set boot " | ||||
| #define all_remove "ubconfig set/remove boot " | ||||
| #define global_remove "ubconfig --target global --noexecute set/remove boot " | ||||
| #define system_remove "ubconfig --target system --noexecute set/remove boot " | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class Wrapper_load_save { | ||||
| private: | ||||
|     string str_cmd_error; | ||||
| private: | ||||
|     map_str_str* map_gui_cfg = NULL; | ||||
|     map_str_str* map_global_cfg = NULL; | ||||
|     map_str_str* map_system_cfg = NULL; | ||||
|     vector<string> vec_param_names; | ||||
|     My_Process::My_Process_system obj_process_system = My_Process::My_Process_system(); | ||||
|     My_Process::My_Process_call obj_process_call = My_Process::My_Process_call(); | ||||
|     Lib_save::Save obj_save = Lib_save::Save(); | ||||
|     Lib_Load::Load obj_load = Lib_Load::Load(); | ||||
| public: | ||||
|     Wrapper_load_save(/* args */); | ||||
|     ~Wrapper_load_save(); | ||||
|     int load_global_cfg(); | ||||
|     int load_system_cfg(); | ||||
|     int wrapper_save_system_cfg(); | ||||
|     int wrapper_save_global_cfg(); | ||||
|     int wrapper_save_all_cfg(); | ||||
|     int get_error_load(); | ||||
|     int get_error_save(); | ||||
|     void set_map_gui(map_str_str* map_gui_cfg); | ||||
|     void set_map_global(map_str_str* map_global_cfg); | ||||
|     void set_map_local(map_str_str* map_system_cfg); | ||||
|     void set_vec_key(vector<string> vec_param_names); | ||||
| private: | ||||
|     void load_template(map_str_str* map_temp, string cmd); | ||||
|     void init_dict(string flag_load); | ||||
|     void set_data_cfg(); | ||||
|     bool save_template(string section, string flag_save); | ||||
|      | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
| @ -1,620 +0,0 @@ | ||||
| #ifndef UBL_SETTINGS_DISKQUOTA_H | ||||
| #define UBL_SETTINGS_DISKQUOTA_H | ||||
| #include "ubl-settings-diskquota.h" | ||||
| 
 | ||||
| string version_application = "1.7"; | ||||
| bool flag_save = false; | ||||
| bool flag_save_local = false; | ||||
| bool flag_save_global = false; | ||||
| bool flag_load_global = false; | ||||
| bool flag_lock_help = false; | ||||
| 
 | ||||
| MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> builder, View_open_browser* obj_open_browser, int* socket_ext_id_I, int* socket_trd_id_I) { | ||||
|     this->builder = builder; | ||||
|     this->socket_ext_id_I = socket_ext_id_I; | ||||
|     this->socket_trd_id_I = socket_trd_id_I; | ||||
|     this->set_obj_browser(obj_open_browser); | ||||
|     // this->settings();
 | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_map_gui(map_str_str* map_gui_cfg) { | ||||
|     this->map_gui_cfg = map_gui_cfg; | ||||
|     obj_wrapper_load_save->set_map_gui(map_gui_cfg); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_map_global(map_str_str* map_global_cfg) { | ||||
|     this->map_global_cfg = map_global_cfg; | ||||
|     obj_wrapper_load_save->set_map_global(map_global_cfg); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_map_local(map_str_str* map_system_cfg) { | ||||
|     this->map_system_cfg = map_system_cfg; | ||||
|     obj_wrapper_load_save->set_map_local(map_system_cfg); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_obj_wrapper_load_save(Wrapper_load_save* obj_wrapper_load_save) { | ||||
|     this->obj_wrapper_load_save = obj_wrapper_load_save; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_obj_view_filters(View_filters* obj_view_filters) { | ||||
|     this->obj_view_filters = obj_view_filters; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_obj_view_add(View_add_user_group* obj_view_add) { | ||||
|     this->obj_view_add = obj_view_add; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_obj_view_edit(View_edit_user_group* obj_view_edit) { | ||||
|     this->obj_view_edit = obj_view_edit; | ||||
| } | ||||
| void MainWindow::set_obj_view_add_project(View_add_project* obj_view_add_project) { | ||||
|     this->obj_view_add_project = obj_view_add_project; | ||||
| } | ||||
| void MainWindow::set_obj_view_edit_project(View_edit_project* obj_view_edit_project) { | ||||
|     this->obj_view_edit_project = obj_view_edit_project; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::settings() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     Gtk::Widget *boxWidget; | ||||
|     builder->get_widget("boxColor", boxWidget); | ||||
|     HeadOverlay->add_overlay(*boxWidget); | ||||
|     ubl_make_plugs(boxSave, boxButton, (*socket_ext_id_I), (*socket_trd_id_I)); | ||||
|     this->add_CSS(); | ||||
|     this->flag_block_gui(); | ||||
|     this->init_tree_view(); | ||||
|     this->init_spin_all(); | ||||
|     if (geteuid() == 0) { | ||||
|         this->wrapper_load_system(); | ||||
|         this->wrapper_load_global(); | ||||
|         this->event(); | ||||
|     } | ||||
|     else { | ||||
|         boxFuncs->set_sensitive(false); | ||||
|         btnSave->set_sensitive(false); | ||||
|         btnLoad->set_sensitive(false); | ||||
|         imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); | ||||
|         info_status_app(info_box_error_css); | ||||
|         lblWarning->set_text(program_as_root); | ||||
|     } | ||||
|      | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void MainWindow::set_obj_browser(View_open_browser* obj_open_browser) { | ||||
|     this->obj_open_browser = obj_open_browser; | ||||
|     obj_open_browser->get_about()->set_version(version_application); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::init_spin_all() { | ||||
|     generalGroupsSizeWeeksSpi->set_range(0, 52); | ||||
|     generalGroupsSizeWeeksSpi->set_increments(1.0, 1.0); | ||||
|     generalGroupsSizeWeeksSpi->set_value(0); | ||||
|     generalGroupsFileWeeksSpin->set_range(0, 52); | ||||
|     generalGroupsFileWeeksSpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsFileWeeksSpin->set_value(0); | ||||
|     generalUsersSizWeeksSpin->set_range(0, 52); | ||||
|     generalUsersSizWeeksSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersSizWeeksSpin->set_value(0); | ||||
|     generalUsersFileWeeksSpin->set_range(0, 52); | ||||
|     generalUsersFileWeeksSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersFileWeeksSpin->set_value(0); | ||||
|     generalGroupsSizeDaySpin->set_range(0, 31); | ||||
|     generalGroupsSizeDaySpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsSizeDaySpin->set_value(0); | ||||
|     generalGroupsFilesDaySpin->set_range(0, 31); | ||||
|     generalGroupsFilesDaySpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsFilesDaySpin->set_value(0); | ||||
|     generalUsersSizeDaySpin->set_range(0, 31); | ||||
|     generalUsersSizeDaySpin->set_increments(1.0, 1.0); | ||||
|     generalUsersSizeDaySpin->set_value(0); | ||||
|     generalUsersFilesDaySpin->set_range(0, 31); | ||||
|     generalUsersFilesDaySpin->set_increments(1.0, 1.0); | ||||
|     generalUsersFilesDaySpin->set_value(0); | ||||
|     generalGroupsSizeHourSpin->set_range(0, 23); | ||||
|     generalGroupsSizeHourSpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsSizeHourSpin->set_value(0); | ||||
|     generalGroupsFilesHourSpin->set_range(0, 23); | ||||
|     generalGroupsFilesHourSpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsFilesHourSpin->set_value(0); | ||||
|     generalUsersSizeHourSpin->set_range(0, 23); | ||||
|     generalUsersSizeHourSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersSizeHourSpin->set_value(0); | ||||
|     generalUsersFilesHoursSpin->set_range(0, 23); | ||||
|     generalUsersFilesHoursSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersFilesHoursSpin->set_value(0);  | ||||
|     generalGroupsSizeMinuteSpin->set_range(0, 59); | ||||
|     generalGroupsSizeMinuteSpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsSizeMinuteSpin->set_value(0);   | ||||
|     generalGroupsFilesMinuteSpin->set_range(0, 59); | ||||
|     generalGroupsFilesMinuteSpin->set_increments(1.0, 1.0); | ||||
|     generalGroupsFilesMinuteSpin->set_value(0);  | ||||
|     generalUsersSizeMinuteSpin->set_range(0, 59); | ||||
|     generalUsersSizeMinuteSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersSizeMinuteSpin->set_value(0);   | ||||
|     generalUsersFilesMinutesSpin->set_range(0, 59); | ||||
|     generalUsersFilesMinutesSpin->set_increments(1.0, 1.0); | ||||
|     generalUsersFilesMinutesSpin->set_value(0);     | ||||
| } | ||||
| 
 | ||||
| void MainWindow::init_tree_view() { | ||||
|     this->view_add_columns(*usersQuotasTree); | ||||
|     this->view_add_columns(*groupsQuotasTree); | ||||
|     this->view_add_columns(*ProjectQuotasTree); | ||||
|     this->init_tree_view_general(); | ||||
| } | ||||
| void MainWindow::init_tree_view_general() { | ||||
|     GeneralQuotasTree->append_column_editable(str_status, m_columnsGeneral.status); | ||||
|     GeneralQuotasTree->append_column(str_quota, m_columnsGeneral.type_quotas); | ||||
|     GeneralQuotasTree->append_column(str_device_project, m_columnsGeneral.device); | ||||
|     GeneralQuotasTree->append_column(str_user, m_columnsGeneral.user); | ||||
|     GeneralQuotasTree->append_column(str_group, m_columnsGeneral.group); | ||||
|     GeneralQuotasTree->append_column(str_projects, m_columnsGeneral.projects); | ||||
|     GeneralQuotasTree->append_column(str_tw_soft_limit, m_columnsGeneral.soft_limit_size); | ||||
|     GeneralQuotasTree->append_column(str_tw_severe_limitation, m_columnsGeneral.hard_limit_size); | ||||
|     GeneralQuotasTree->append_column(str_tw_soft_limit_files, m_columnsGeneral.soft_limit_files); | ||||
|     GeneralQuotasTree->append_column(str_tw_severe_limitation_files, m_columnsGeneral.hard_limit_files); | ||||
|     GeneralQuotasTree->append_column(str_tw_general_deferring_size, m_columnsGeneral.deferring_size); | ||||
|     GeneralQuotasTree->append_column(str_tw_general_deferring_files, m_columnsGeneral.deferring_files); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::view_add_columns(Gtk::TreeView &treeView) { | ||||
|     treeView.append_column_editable(str_name, m_columns.name); | ||||
|     treeView.append_column_editable(str_quotas, m_columns.quotas); | ||||
|     treeView.append_column(str_size, m_columns.size); | ||||
|     treeView.append_column(str_tw_soft_limit, m_columns.soft_limit_size); | ||||
|     treeView.append_column(str_tw_severe_limitation, m_columns.hard_limit_size); | ||||
|     treeView.append_column(str_tw_deferring_size, m_columns.deferring_size); | ||||
|     treeView.append_column(str_files, m_columns.files); | ||||
|     treeView.append_column(str_tw_soft_limit_files, m_columns.soft_limit_files); | ||||
|     treeView.append_column(str_tw_severe_limitation_files, m_columns.hard_limit_delay); | ||||
|     treeView.append_column(str_tw_deferring_files, m_columns.deferring_files); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::lacalization() { | ||||
|     GroupsTabLabel->set_text(str_groups); | ||||
|     headerTopic->set_label(name_app); | ||||
|     UsersTabLabel->set_text(str_users); | ||||
|     generalGroupsFilesLabel->set_text(str_excess_files_delay); | ||||
|     generalUsersSizeLabel->set_text(str_excess_size_delay); | ||||
|     generalUsersFilesLabel->set_text(str_excess_files_delay); | ||||
|     lblLoad->set_text(str_load_local); | ||||
|     lblSave->set_text(str_save_local); | ||||
|     groupsDeviceLabel->set_label(str_device);  | ||||
|     usersDeviceLabel->set_label(str_device);  | ||||
|     headLabel->set_label(str_lb_head);    | ||||
|     btnLoadGlob->set_label(load_global); | ||||
|     btnLoadLocal->set_label(load_local); | ||||
|     btnAbout->set_label(str_about_1); | ||||
|     btnSynopsis->set_label(str_help); | ||||
|     btnSaveLocalGlob->set_label(save_all); | ||||
|     btnSaveGlob->set_label(save_global); | ||||
|     btnSaveLocal->set_label(save_local); | ||||
|     ProjectTabLabel->set_label(str_projects); | ||||
|     usersProjectLabel->set_text(str_device); | ||||
|     chbMangSystemFile->set_label(str_quotas_mode); | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void MainWindow::info_warning_error(int mess, int error_save, int error_load) { | ||||
|     if (error_save > 0 || error_load > 0) { | ||||
|         info_status_app(info_box_error_css); | ||||
|         imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); | ||||
|         string mess_error = ""; | ||||
|         if (mess == 0) { | ||||
|             mess_error = string(local_read_error) + str_cmd_error; | ||||
|             lblWarning->set_text(mess_error); | ||||
|         } | ||||
|         else if (mess == 1) { | ||||
|             mess_error = string(global_read_error) + str_cmd_error; | ||||
|             lblWarning->set_text(mess_error); | ||||
|         } | ||||
|         else if (mess == 2) { | ||||
|             mess_error = string(local_write_error) + str_cmd_error; | ||||
|             lblWarning->set_text(mess_error); | ||||
|         } | ||||
|         else if (mess == 3) { | ||||
|             mess_error = string(global_write_error) + str_cmd_error; | ||||
|             lblWarning->set_text(mess_error); | ||||
|         } | ||||
|         else if (mess == 4) { | ||||
|             mess_error = string(error_save_all) + str_cmd_error; | ||||
|             lblWarning->set_text(mess_error); | ||||
|         } | ||||
|         str_cmd_error = ""; | ||||
|     } | ||||
|     else { | ||||
|         info_status_app(info_box_ok_css); | ||||
|         imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); | ||||
|         if (mess == 0) { | ||||
|             lblWarning->set_text(local_load_ok); | ||||
|         } | ||||
|         else if (mess == 1) { | ||||
|             lblWarning->set_text(global_load_ok); | ||||
|         } | ||||
|         else if (mess == 2) { | ||||
|             lblWarning->set_text(local_ok_written); | ||||
|         } | ||||
|         else if (mess == 3) { | ||||
|             lblWarning->set_text(global_ok_written); | ||||
|         } | ||||
|         else if (mess == 4) { | ||||
|             lblWarning->set_text(successfully_save_all); | ||||
|         } | ||||
|         else if (mess == 5) { | ||||
|             lblWarning->set_text(nothing_save); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::filling_device_combo_box_template(Gtk::ComboBoxText *combo_box, map_str_str &map_device) { | ||||
|     if (map_device.size() != 0) { | ||||
|         for (const auto &device : map_device) { | ||||
|             combo_box->append(device.first.c_str()); | ||||
|         } | ||||
|         combo_box->set_active(0); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::flag_block_gui() { | ||||
|     if (flag_load_global == true) { | ||||
|         btnLoadGlob->set_sensitive(false); | ||||
|     } | ||||
|     if (flag_save_local == true && flag_save_global == true) { | ||||
|         btnSave->set_sensitive(false); | ||||
|     } | ||||
|     if (flag_save == true) { | ||||
|         btnSave->set_sensitive(false); | ||||
|     } | ||||
|     if (flag_save_local == true) { | ||||
|         btnSaveLocal->set_sensitive(false); | ||||
|         btnSaveLocalGlob->set_sensitive(false); | ||||
|     } | ||||
|     if (flag_save_global == true) { | ||||
|         btnSaveGlob->set_sensitive(false); | ||||
|         btnSaveLocalGlob->set_sensitive(false); | ||||
|     } | ||||
|     if (flag_lock_help == true) { | ||||
|         btnSynopsis->set_sensitive(false); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| void MainWindow::entry_combo_box_temp(Gtk::ComboBoxText *combo_box, Gtk::Label *label) { | ||||
|     string text = combo_box->get_active_text(); | ||||
|     if (map_device.find(text) != map_device.end()){ | ||||
|         label->set_text(map_device[text]); | ||||
|     } | ||||
| } | ||||
| */ | ||||
| 
 | ||||
| void MainWindow::add_CSS() { | ||||
|     Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create(); | ||||
|     cssProvider->load_from_path(path_css);    | ||||
|     Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create(); | ||||
|     Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen
 | ||||
|     styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application
 | ||||
|     HeadBackgroundImage->set(path_img_head_background); | ||||
|     Glib::RefPtr<Gtk::StyleContext> headLabel_css = headLabel->get_style_context(); | ||||
|     Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context(); | ||||
|     Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context(); | ||||
|     Glib::RefPtr<Gtk::StyleContext> headerBar_css = headerBar->get_style_context(); | ||||
|     if ((*socket_trd_id_I) == 0 && (*socket_ext_id_I) == 0){ | ||||
|         boxButton_css->add_class("bkim_no_plug"); | ||||
|         boxSave_css->add_class("bkim_no_plug"); | ||||
|     } | ||||
|     headLabel_css->add_class("textHead"); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::get_builder() { | ||||
|     builder->set_translation_domain(path_app); | ||||
|     builder->get_widget("headerTopic", headerTopic); | ||||
|     builder->get_widget("boxButton", boxButton); | ||||
|     builder->get_widget("boxSave", boxSave); | ||||
|     builder->get_widget("HeadOverlay", HeadOverlay); | ||||
|     builder->get_widget("headerBar", headerBar); | ||||
|     builder->get_widget("boxFuncs", boxFuncs); | ||||
|     builder->get_widget("btnLoad", btnLoad); | ||||
|     builder->get_widget("btnSave", btnSave); | ||||
|     builder->get_widget("HeadBackgroundImage", HeadBackgroundImage); | ||||
|     builder->get_widget("imgInfo", imgInfo); | ||||
|     builder->get_widget("lblWarning", lblWarning); | ||||
|     builder->get_widget("boxInfoError", boxInfoError); | ||||
|     builder->get_widget("imgInfo", imgInfo); | ||||
|     builder->get_widget("generalTabLabel", generalTabLabel); | ||||
|     builder->get_widget("GroupsTabLabel", GroupsTabLabel); | ||||
|     builder->get_widget("UsersTabLabel", UsersTabLabel); | ||||
|     builder->get_widget("generalGroupsFilesLabel", generalGroupsFilesLabel); | ||||
|     builder->get_widget("generalUsersSizeLabel", generalUsersSizeLabel); | ||||
|     builder->get_widget("generalUsersFilesLabel", generalUsersFilesLabel); | ||||
|     builder->get_widget("generalGroupsSizeWeeksLabel", generalGroupsSizeWeeksLabel); | ||||
|     builder->get_widget("generalGroupsFilesWeeksLabel", generalGroupsFilesWeeksLabel); | ||||
|     builder->get_widget("generalUsersSizeWeeksLabel", generalUsersSizeWeeksLabel); | ||||
|     builder->get_widget("generalUsersFilesWeeksLabel", generalUsersFilesWeeksLabel); | ||||
|     builder->get_widget("generalGroupsSizeDaysLabel", generalGroupsSizeDaysLabel); | ||||
|     builder->get_widget("generalGroupsFilesDaysLabel", generalGroupsFilesDaysLabel); | ||||
|     builder->get_widget("generalUsersSizeDaysLabel", generalUsersSizeDaysLabel); | ||||
|     builder->get_widget("generalUsersFilesDaysLabel", generalUsersFilesDaysLabel); | ||||
|     builder->get_widget("generalGroupsSizeHoursLabel", generalGroupsSizeHoursLabel); | ||||
|     builder->get_widget("generalGroupsFilesHoursLabel", generalGroupsFilesHoursLabel); | ||||
|     builder->get_widget("generalUsersSizeHoursLabel", generalUsersSizeHoursLabel); | ||||
|     builder->get_widget("generalUsersFilesHoursLabel", generalUsersFilesHoursLabel); | ||||
|     builder->get_widget("generalGroupsSizeMinutesLabel", generalGroupsSizeMinutesLabel); | ||||
|     builder->get_widget("generalGroupsFilesMinutesLabel", generalGroupsFilesMinutesLabel); | ||||
|     builder->get_widget("generalUsersSizeMinutesLabel", generalUsersSizeMinutesLabel); | ||||
|     builder->get_widget("generalUsersFilesMinutesLabel", generalUsersFilesMinutesLabel); | ||||
|     builder->get_widget("lblLoad", lblLoad); | ||||
|     builder->get_widget("lblSave", lblSave); | ||||
|     builder->get_widget("btnSettings", btnSettings); | ||||
|     builder->get_widget("groupsDeviceLabel", groupsDeviceLabel); | ||||
|     builder->get_widget("usersDeviceLabel", usersDeviceLabel); | ||||
|     builder->get_widget("headLabel", headLabel); | ||||
|     builder->get_widget("btnLoadGlob", btnLoadGlob); | ||||
|     builder->get_widget("btnLoadLocal", btnLoadLocal); | ||||
|     builder->get_widget("btnSynopsis", btnSynopsis); | ||||
|     builder->get_widget("btnAbout", btnAbout); | ||||
|     builder->get_widget("btnSaveLocalGlob", btnSaveLocalGlob); | ||||
|     builder->get_widget("btnSaveGlob", btnSaveGlob); | ||||
|     builder->get_widget("btnSaveLocal", btnSaveLocal); | ||||
|     builder->get_widget("GroupsTabLabel", GroupsTabLabel); | ||||
|     builder->get_widget("groupsQuotasTree", groupsQuotasTree); | ||||
|     builder->get_widget("usersQuotasTree", usersQuotasTree); | ||||
|     builder->get_widget("usersDeviceCombo", usersDeviceCombo); | ||||
|     builder->get_widget("GroupsTabLabel", GroupsTabLabel); | ||||
|     builder->get_widget("generalTabLabel", generalTabLabel); | ||||
|     builder->get_widget("groupsDeviceCombo", groupsDeviceCombo); | ||||
|     builder->get_widget("generalGroupsSizeWeeksSpi", generalGroupsSizeWeeksSpi); | ||||
|     builder->get_widget("generalGroupsFileWeeksSpin", generalGroupsFileWeeksSpin); | ||||
|     builder->get_widget("generalGroupsSizeDaySpin", generalGroupsSizeDaySpin); | ||||
|     builder->get_widget("generalGroupsFilesDaySpin", generalGroupsFilesDaySpin); | ||||
|     builder->get_widget("generalGroupsSizeHourSpin", generalGroupsSizeHourSpin); | ||||
|     builder->get_widget("generalGroupsFilesHourSpin", generalGroupsFilesHourSpin); | ||||
|     builder->get_widget("generalGroupsSizeMinuteSpin", generalGroupsSizeMinuteSpin); | ||||
|     builder->get_widget("generalGroupsFilesMinuteSpin", generalGroupsFilesMinuteSpin); | ||||
|     builder->get_widget("generalUsersSizWeeksSpin", generalUsersSizWeeksSpin); | ||||
|     builder->get_widget("generalUsersFileWeeksSpin", generalUsersFileWeeksSpin); | ||||
|     builder->get_widget("generalUsersSizeDaySpin", generalUsersSizeDaySpin); | ||||
|     builder->get_widget("generalUsersFilesDaySpin", generalUsersFilesDaySpin); | ||||
|     builder->get_widget("generalUsersSizeHourSpin", generalUsersSizeHourSpin); | ||||
|     builder->get_widget("generalUsersFilesHoursSpin", generalUsersFilesHoursSpin); | ||||
|     builder->get_widget("generalUsersSizeMinuteSpin", generalUsersSizeMinuteSpin); | ||||
|     builder->get_widget("generalUsersFilesMinutesSpin", generalUsersFilesMinutesSpin); | ||||
|     builder->get_widget("GeneralQuotasTree", GeneralQuotasTree); | ||||
|     builder->get_widget("ProjectQuotasTree", ProjectQuotasTree); | ||||
|     builder->get_widget("ProjectTabLabel", ProjectTabLabel); | ||||
|     builder->get_widget("usersProjectLabel", usersProjectLabel); | ||||
|     builder->get_widget("btnFilterProject", btnFilterProject); | ||||
|     builder->get_widget("btnFilterUsers", btnFilterUsers); | ||||
|     builder->get_widget("btnFilterGroups", btnFilterGroups); | ||||
|     builder->get_widget("chbMangSystemFile", chbMangSystemFile); | ||||
|     builder->get_widget("btnDelGroups", btnDelGroups); | ||||
|     builder->get_widget("btnDelProject", btnDelProject); | ||||
|     builder->get_widget("btnDelUsers", btnDelUsers); | ||||
|     builder->get_widget("btnAddGroups", btnAddGroups); | ||||
|     builder->get_widget("btnAddUsers", btnAddUsers); | ||||
|     builder->get_widget("btnAddProject", btnAddProject); | ||||
|     builder->get_widget("btnEditProject", btnEditProject); | ||||
|     builder->get_widget("btnEditUsers", btnEditUsers); | ||||
|     builder->get_widget("btnEditGroups", btnEditGroups); | ||||
|     builder->get_widget("usersProjectCombo", usersProjectCombo); | ||||
|     builder->get_widget("boxResize", boxResize); | ||||
|     builder->get_widget("boxGroupsWeeks", boxGroupsWeeks); | ||||
|     builder->get_widget("boxGroupsDays", boxGroupsDays); | ||||
|     builder->get_widget("boxGroupsHours", boxGroupsHours); | ||||
|     builder->get_widget("boxGroupsMinutes", boxGroupsMinutes); | ||||
|     builder->get_widget("boxUsersWeeks", boxUsersWeeks); | ||||
|     builder->get_widget("boxUsersDays", boxUsersDays); | ||||
|     builder->get_widget("boxUsersHours", boxUsersHours); | ||||
|     builder->get_widget("boxUsersMinutes", boxUsersMinutes); | ||||
|     builder->get_widget("boxProjectWeeks", boxProjectWeeks); | ||||
|     builder->get_widget("boxProjectDays", boxProjectDays); | ||||
|     builder->get_widget("boxProjectHours", boxProjectHours); | ||||
|     builder->get_widget("boxProjectMinutes", boxProjectMinutes); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::open_browser() { | ||||
|     obj_open_browser->open_help(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::wrapper_save_system() { | ||||
|     int id_mess = obj_wrapper_load_save->wrapper_save_system_cfg(); | ||||
|     int error_save = obj_wrapper_load_save->get_error_save(); | ||||
|     int error_load = obj_wrapper_load_save->get_error_load(); | ||||
|     this->info_warning_error(id_mess, error_save, error_load); | ||||
| } | ||||
| void MainWindow::wrapper_save_global() { | ||||
|     int id_mess = obj_wrapper_load_save->wrapper_save_global_cfg(); | ||||
|     int error_save = obj_wrapper_load_save->get_error_save(); | ||||
|     int error_load = obj_wrapper_load_save->get_error_load(); | ||||
|     this->info_warning_error(id_mess, error_save, error_load); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::wrapper_save_all() { | ||||
|     int id_mess = obj_wrapper_load_save->wrapper_save_all_cfg(); | ||||
|     int error_save = obj_wrapper_load_save->get_error_save(); | ||||
|     int error_load = obj_wrapper_load_save->get_error_load(); | ||||
|     this->info_warning_error(id_mess, error_save, error_load); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::wrapper_load_system() { | ||||
|     int id_mess = obj_wrapper_load_save->load_system_cfg(); | ||||
|     int error_save = obj_wrapper_load_save->get_error_save(); | ||||
|     int error_load = obj_wrapper_load_save->get_error_load(); | ||||
|     this->info_warning_error(id_mess, error_save, error_load); | ||||
|     this->init_work_tv_g_u_p(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::wrapper_load_global() { | ||||
|     int id_mess = obj_wrapper_load_save->load_global_cfg(); | ||||
|     int error_save = obj_wrapper_load_save->get_error_save(); | ||||
|     int error_load = obj_wrapper_load_save->get_error_load(); | ||||
|     this->info_warning_error(id_mess, error_save, error_load); | ||||
|     this->init_work_tv_g_u_p(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::event() { | ||||
|     boxResize->signal_check_resize().connect(sigc::mem_fun(*this, &MainWindow::resize_widget)); | ||||
|     btnFilterGroups->signal_clicked().connect([&]() {this->filters_show();}); | ||||
|     btnFilterUsers->signal_clicked().connect([&]() {this->filters_show();}); | ||||
|     btnFilterProject->signal_clicked().connect([&]() {this->filters_show();}); | ||||
|     btnSynopsis->signal_activate().connect([&]() {this->open_browser();}); | ||||
|     btnAbout->signal_activate().connect([&]() {obj_open_browser->get_about()->aboutWindows->show();}); | ||||
|     btnSaveLocalGlob->signal_activate().connect([&]() {this->wrapper_save_all();}); | ||||
|     btnSaveGlob->signal_activate().connect([&]() {this->wrapper_save_global();}); | ||||
|     btnSaveLocal->signal_activate().connect([&]() {this->wrapper_save_system();}); | ||||
|     btnLoadGlob->signal_activate().connect([&]() {this->wrapper_load_global();}); | ||||
|     btnLoadLocal->signal_activate().connect([&]() {this->wrapper_load_system();}); | ||||
|     btnEditGroups->signal_clicked().connect(sigc::bind<string> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::edit_quota_show), str_groups)); | ||||
|     btnEditUsers->signal_clicked().connect(sigc::bind<string> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::edit_quota_show), str_users)); | ||||
|     btnEditProject->signal_clicked().connect([&]() {this->edit_quota_project_show();}); | ||||
|     chbMangSystemFile->signal_toggled().connect([&]() {this->mode_switch_quota();}); | ||||
|     btnDelGroups->signal_clicked().connect(  | ||||
|         sigc::bind<Glib::RefPtr<Gtk::ListStore>*, const Gtk::TreeModel::iterator*, bool&> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::remove_template), &list_store_groups, &iter_groups, flag_validate_del_groups)); | ||||
|     btnDelUsers->signal_clicked().connect(  | ||||
|         sigc::bind<Glib::RefPtr<Gtk::ListStore>*, const Gtk::TreeModel::iterator*, bool&> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::remove_template), &list_store_users, &iter_users, flag_validate_del_users)); | ||||
|     btnDelProject->signal_clicked().connect(  | ||||
|         sigc::bind<Glib::RefPtr<Gtk::ListStore>*, const Gtk::TreeModel::iterator*, bool&> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::remove_template), &list_store_project, &iter_project, flag_validate_del_project)); | ||||
|     btnAddProject->signal_clicked().connect([&]() {this->obj_view_add_project->show();}); | ||||
|     btnAddUsers->signal_clicked().connect(  | ||||
|         sigc::bind<string,Gtk::TreeView*, Gtk::TreeModel::Row&, Glib::RefPtr<Gtk::ListStore>&,  struct tv_g_u_p> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::set_add_tv_g_u_p), str_users, usersQuotasTree, row, list_store_users, obj_tv_g_u_p)); | ||||
|     btnAddGroups->signal_clicked().connect(  | ||||
|         sigc::bind<string,Gtk::TreeView*, Gtk::TreeModel::Row&, Glib::RefPtr<Gtk::ListStore>&,  struct tv_g_u_p> (sigc::mem_fun( *this,  | ||||
|         &MainWindow::set_add_tv_g_u_p), str_groups, groupsQuotasTree, row, list_store_groups, obj_tv_g_u_p)); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::resize_widget() { | ||||
|     // boxGroupsWeeks = boxGroupsWeeks(Gtk::ORIENTATION_HORIZONTAL);
 | ||||
| } | ||||
| 
 | ||||
| void MainWindow::add_quota_show(string name) { | ||||
|     obj_view_add->set_label_type_quota(name); | ||||
|     obj_view_add->show(); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::edit_quota_show(string name) { | ||||
|     obj_view_edit->set_label_type_quota(name); | ||||
|     obj_view_edit->show(); | ||||
| } | ||||
| void MainWindow::edit_quota_project_show() { | ||||
|     obj_view_edit_project->show(); | ||||
| } | ||||
| void MainWindow::remove_template(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate_del) { | ||||
|     if (flag_validate_del && (*list_store)->iter_is_valid(*(iter))) { | ||||
|         Gtk::TreeModel::Row row = *(*iter); | ||||
|         if(row) { | ||||
|             // string name = row[m_columns.name] + "";
 | ||||
|             // TODO: : check
 | ||||
|             // string key = "GRUB_PASSWORD[" + name + "]";
 | ||||
|             // map_gui_cfg[key] = "";
 | ||||
|         } | ||||
|         (*list_store)->erase((*iter)); | ||||
|         flag_validate_del = false; | ||||
|         info_status_app(info_box_ok_css); | ||||
|         imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); | ||||
|         // lblWarning->set_text("");
 | ||||
|     } | ||||
|     flag_validate_del = false; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::set_add_tv_g_u_p(string name, Gtk::TreeView* tree_view, Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore>& list_store, struct tv_g_u_p obj_tv_g_u_p) { | ||||
|     if (this->check_space(tree_view)) { | ||||
|         row = *(list_store->append()); | ||||
|         row[m_columns.name] = obj_tv_g_u_p.name; | ||||
|         row[m_columns.quotas] = obj_tv_g_u_p.quotas; | ||||
|         row[m_columns.size] = obj_tv_g_u_p.size; | ||||
|         row[m_columns.soft_limit_size] = obj_tv_g_u_p.soft_limit_size;  | ||||
|         row[m_columns.hard_limit_size] = obj_tv_g_u_p.hard_limit_size;  | ||||
|         row[m_columns.deferring_size] = obj_tv_g_u_p.deferring_size;  | ||||
|         row[m_columns.files] = obj_tv_g_u_p.files;  | ||||
|         row[m_columns.soft_limit_files] = obj_tv_g_u_p.soft_limit_files;  | ||||
|         row[m_columns.hard_limit_delay] = obj_tv_g_u_p.hard_limit_delay;  | ||||
|         row[m_columns.deferring_files] = obj_tv_g_u_p.deferring_files; | ||||
|         this->add_quota_show(name); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::mode_switch_quota() { | ||||
|     // Todo: check
 | ||||
|     if (chbMangSystemFile->get_active()) { | ||||
|         mode_quota = "filesystem"; | ||||
|     } | ||||
|     else { | ||||
|         mode_quota = "ubconfig"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void MainWindow::filters_show() { | ||||
|     obj_view_filters->show(); | ||||
| } | ||||
| 
 | ||||
| bool MainWindow::check_space(Gtk::TreeView* tree_view) { | ||||
|     Glib::RefPtr<Gtk::TreeModel> tree_view_model = tree_view->get_model(); | ||||
|     Gtk::TreeModel::Children children = tree_view_model->children(); | ||||
|     string name = ""; | ||||
|     string quotas = ""; | ||||
|     for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) { | ||||
|         Gtk::TreeModel::Row row = *iter; | ||||
|         name = row[m_columns.name] + ""; | ||||
|         quotas = row[m_columns.quotas] + ""; | ||||
|         if (name.length() == 0 || quotas.length() == 0) { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|     return true; | ||||
| } | ||||
| 
 | ||||
| void MainWindow::info_status_app(string stule) { | ||||
|     Glib::RefPtr<Gtk::StyleContext> boxInfo = boxInfoError->get_style_context(); | ||||
|     boxInfo->remove_class(info_box_ok_css); | ||||
|     boxInfo->remove_class(info_box_error_css); | ||||
|     boxInfo->add_class(stule); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::init_work_tv_g_u_p() { | ||||
|     // Todo: remove
 | ||||
|     groupsQuotasTree->remove_all_columns(); | ||||
|     ProjectQuotasTree->remove_all_columns(); | ||||
|     usersQuotasTree->remove_all_columns(); | ||||
|     list_store_groups = Gtk::ListStore::create(m_columns); | ||||
|     list_store_project = Gtk::ListStore::create(m_columns); | ||||
|     list_store_users = Gtk::ListStore::create(m_columns); | ||||
|     groupsQuotasTree->set_model(list_store_groups); | ||||
|     ProjectQuotasTree->set_model(list_store_project); | ||||
|     usersQuotasTree->set_model(list_store_users); | ||||
|     Glib::RefPtr<Gtk::TreeModel> groupsQuotasTreeModel = groupsQuotasTree->get_model(); | ||||
|     groupsQuotasTreeModel->signal_row_changed().connect(sigc::bind<Gtk::TreeModel::iterator&, bool&>  | ||||
|     (sigc::mem_fun(*this, &MainWindow::remove_line_template), iter_groups, flag_validate_del_groups)); | ||||
|     Glib::RefPtr<Gtk::TreeModel> ProjectQuotasTreeModel = ProjectQuotasTree->get_model(); | ||||
|     ProjectQuotasTreeModel->signal_row_changed().connect(sigc::bind<Gtk::TreeModel::iterator&, bool&>  | ||||
|     (sigc::mem_fun(*this, &MainWindow::remove_line_template), iter_project, flag_validate_del_project)); | ||||
|     Glib::RefPtr<Gtk::TreeModel> usersQuotasTreeModel = usersQuotasTree->get_model(); | ||||
|     usersQuotasTreeModel->signal_row_changed().connect(sigc::bind<Gtk::TreeModel::iterator&, bool&>  | ||||
|     (sigc::mem_fun(*this, &MainWindow::remove_line_template),iter_users, flag_validate_del_users)); | ||||
|     this->view_add_columns(*groupsQuotasTree); | ||||
|     this->view_add_columns(*ProjectQuotasTree); | ||||
|     this->view_add_columns(*usersQuotasTree); | ||||
| } | ||||
| 
 | ||||
| void MainWindow::remove_line_template(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator& iter_del, bool& flag_del) { | ||||
|     iter_del = iter; | ||||
|     flag_del = true; | ||||
| } | ||||
| 
 | ||||
| void help() { | ||||
|     string version = string(str_version) + version_application + "\n"; | ||||
|     cout << version.c_str(); | ||||
|     cout << str_help_h; | ||||
| } | ||||
| 
 | ||||
| MainWindow::~MainWindow() {} | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| @ -1,273 +0,0 @@ | ||||
| #ifndef UBL_SETTINGS_QUOTAS_H | ||||
| #define UBL_SETTINGS_QUOTAS_H | ||||
| 
 | ||||
| #include <dlfcn.h> | ||||
| #include "view_open_browser.h" | ||||
| #include "../project_lib.h" | ||||
| #include "../my_type.h" | ||||
| #include "ubl-util-standard.c" | ||||
| #include "../var.h" | ||||
| #include "model/wrapper_load_save.h" | ||||
| #include "view_filters.h" | ||||
| #include "view_add_user_group.h" | ||||
| #include "view_edit_user_group.h" | ||||
| #include "view_add_project.h" | ||||
| #include "view_edit_project.h" | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| extern bool flag_save; | ||||
| extern bool flag_save_local; | ||||
| extern bool flag_save_global; | ||||
| extern bool flag_load_global; | ||||
| extern bool flag_lock_help; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| class MainWindow { | ||||
|     public: | ||||
|         class ModelColumns : public Gtk::TreeModel::ColumnRecord { | ||||
|             public: | ||||
|                 ModelColumns() {add(name), add(quotas); add(size), | ||||
|                 add(soft_limit_size), add(hard_limit_size); add(deferring_size), | ||||
|                 add(files); add(soft_limit_files), | ||||
|                 add(hard_limit_delay), add(deferring_files); } | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> name; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> quotas; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> soft_limit_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> hard_limit_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> deferring_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> files; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> soft_limit_files; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> hard_limit_delay; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> deferring_files; | ||||
|         }; | ||||
|         class ModelColumnsGeneral : public Gtk::TreeModel::ColumnRecord { | ||||
|             public: | ||||
|                 ModelColumnsGeneral() {add(status), add(type_quotas); add(device), | ||||
|                 add(user), add(group), add(projects); add(soft_limit_size), | ||||
|                 add(hard_limit_size); add(soft_limit_files), add(hard_limit_files), add(deferring_size), | ||||
|                 add(deferring_files); } | ||||
|                 Gtk::TreeModelColumn<bool> status; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> type_quotas; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> device; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> user; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> group; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> projects; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> soft_limit_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> hard_limit_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> soft_limit_files; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> hard_limit_files; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> deferring_size; | ||||
|                 Gtk::TreeModelColumn<Glib::ustring> deferring_files; | ||||
|         }; | ||||
|         ModelColumns m_columns; | ||||
|         ModelColumnsGeneral m_columnsGeneral; | ||||
|         Glib::RefPtr<Gtk::Builder> builder; | ||||
|         template<typename Type> | ||||
|         struct Result{ | ||||
|             Type response; | ||||
|             int error; | ||||
|         }; | ||||
|         Gtk::Label *headerTopic; | ||||
|         Gtk::Overlay *HeadOverlay; | ||||
|         Gtk::HeaderBar *headerBar; | ||||
|         Gtk::Widget *boxSave; | ||||
|         Gtk::Widget *boxButton; | ||||
|         Gtk::Box *boxFuncs; | ||||
|         Gtk::Box* boxResize; | ||||
|         Gtk::MenuButton *btnSave; | ||||
|         Gtk::MenuButton *btnLoad; | ||||
|         Gtk::MenuButton *btnSettings; | ||||
|         Gtk::Image *HeadBackgroundImage; | ||||
|         Gtk::Image *imgInfo; | ||||
|         Gtk::Box *boxInfoError; | ||||
|         Gtk::Label *lblWarning; | ||||
|         Gtk::Label *generalTabLabel; | ||||
|         Gtk::Label *UsersTabLabel; | ||||
|         Gtk::Label *GroupsTabLabel; | ||||
|         Gtk::Label *generalGroupsFilesLabel; | ||||
|         Gtk::Label *generalUsersSizeLabel; | ||||
|         Gtk::Label *generalUsersFilesLabel; | ||||
|         Gtk::Label *generalGroupsSizeWeeksLabel; | ||||
|         Gtk::Label *generalGroupsFilesWeeksLabel; | ||||
|         Gtk::Label *generalUsersSizeWeeksLabel; | ||||
|         Gtk::Label *generalUsersFilesWeeksLabel; | ||||
|         Gtk::Label *generalGroupsSizeDaysLabel; | ||||
|         Gtk::Label *generalGroupsFilesDaysLabel; | ||||
|         Gtk::Label *generalUsersSizeDaysLabel; | ||||
|         Gtk::Label *generalUsersFilesDaysLabel; | ||||
|         Gtk::Label *generalGroupsSizeHoursLabel; | ||||
|         Gtk::Label *generalGroupsFilesHoursLabel; | ||||
|         Gtk::Label *generalUsersSizeHoursLabel; | ||||
|         Gtk::Label *generalUsersFilesHoursLabel; | ||||
|         Gtk::Label *generalGroupsSizeMinutesLabel; | ||||
|         Gtk::Label *generalGroupsFilesMinutesLabel; | ||||
|         Gtk::Label *generalUsersSizeMinutesLabel; | ||||
|         Gtk::Label *generalUsersFilesMinutesLabel; | ||||
|         Gtk::Label *ProjectTabLabel; | ||||
|         Gtk::Label *usersProjectLabel; | ||||
|         Gtk::Label *lblLoad; | ||||
|         Gtk::Label *lblSave; | ||||
|         Gtk::MenuItem *btnLoadGlob; | ||||
|         Gtk::MenuItem *btnLoadLocal; | ||||
|         Gtk::MenuItem *btnSynopsis; | ||||
|         Gtk::MenuItem *btnAbout; | ||||
|         Gtk::MenuItem *btnSaveLocalGlob; | ||||
|         Gtk::MenuItem *btnSaveGlob; | ||||
|         Gtk::MenuItem *btnSaveLocal; | ||||
|         Gtk::Label *groupsDeviceLabel; | ||||
|         Gtk::Label *usersDeviceLabel; | ||||
|         Gtk::Label *headLabel; | ||||
|          | ||||
|         Gtk::TreeView *groupsQuotasTree;  | ||||
|         Gtk::TreeView *usersQuotasTree; | ||||
|         Gtk::TreeView *ProjectQuotasTree; | ||||
|         Gtk::TreeView *GeneralQuotasTree; | ||||
|         Gtk::Label *quotegroupGroupQuotasLabel; | ||||
|          | ||||
|          | ||||
|         Gtk::ComboBoxText *usersDeviceCombo; | ||||
|         Gtk::ComboBoxText *groupsDeviceCombo; | ||||
|         Gtk::ComboBoxText *generalDeviceCombo; | ||||
|         Gtk::ComboBoxText *usersProjectCombo; | ||||
|         Gtk::Label *lblFstypeGroups; | ||||
|         Gtk::SpinButton *generalGroupsSizeWeeksSpi; | ||||
|         Gtk::SpinButton *generalGroupsFileWeeksSpin; | ||||
|         Gtk::SpinButton *generalGroupsSizeDaySpin; | ||||
|         Gtk::SpinButton *generalGroupsFilesDaySpin; | ||||
|         Gtk::SpinButton *generalGroupsSizeHourSpin; | ||||
|         Gtk::SpinButton *generalGroupsFilesHourSpin; | ||||
|         Gtk::SpinButton *generalGroupsSizeMinuteSpin; | ||||
|         Gtk::SpinButton *generalGroupsFilesMinuteSpin; | ||||
|         Gtk::SpinButton *generalUsersSizWeeksSpin; | ||||
|         Gtk::SpinButton *generalUsersFileWeeksSpin; | ||||
|         Gtk::SpinButton *generalUsersSizeDaySpin; | ||||
|         Gtk::SpinButton *generalUsersFilesDaySpin; | ||||
|         Gtk::SpinButton *generalUsersSizeHourSpin; | ||||
|         Gtk::SpinButton *generalUsersFilesHoursSpin; | ||||
|         Gtk::SpinButton *generalUsersSizeMinuteSpin; | ||||
|         Gtk::SpinButton *generalUsersFilesMinutesSpin; | ||||
|          | ||||
|          | ||||
|         Gtk::Button *btnFilterGroups; | ||||
|         Gtk::Button *btnFilterUsers; | ||||
|         Gtk::Button *btnFilterProject; | ||||
|         Gtk::CheckMenuItem *chbMangSystemFile; | ||||
|         Gtk::Button* btnDelGroups; | ||||
|         Gtk::Button* btnDelProject; | ||||
|         Gtk::Button* btnDelUsers; | ||||
|         Gtk::Button* btnAddGroups; | ||||
|         Gtk::Button* btnAddUsers; | ||||
|         Gtk::Button* btnAddProject; | ||||
|         Gtk::Button* btnEditProject; | ||||
|         Gtk::Button* btnEditUsers; | ||||
|         Gtk::Button* btnEditGroups; | ||||
| 
 | ||||
|         Gtk::Box* boxGroupsWeeks; | ||||
|         Gtk::Box* boxGroupsDays; | ||||
|         Gtk::Box* boxGroupsHours; | ||||
|         Gtk::Box* boxGroupsMinutes; | ||||
|         Gtk::Box* boxUsersWeeks; | ||||
|         Gtk::Box* boxUsersDays; | ||||
|         Gtk::Box* boxUsersHours; | ||||
|         Gtk::Box* boxUsersMinutes; | ||||
|         Gtk::Box* boxProjectWeeks; | ||||
|         Gtk::Box* boxProjectDays; | ||||
|         Gtk::Box* boxProjectHours; | ||||
|         Gtk::Box* boxProjectMinutes; | ||||
| 
 | ||||
|     public: | ||||
|         map_str_str* map_gui_cfg = NULL; | ||||
|         map_str_str* map_global_cfg = NULL; | ||||
|         map_str_str* map_system_cfg = NULL; | ||||
|         Wrapper_load_save* obj_wrapper_load_save = NULL; | ||||
|         View_edit_user_group* obj_view_edit = NULL; | ||||
|         View_filters* obj_view_filters = NULL; | ||||
|         View_add_user_group* obj_view_add = NULL; | ||||
|         View_add_project* obj_view_add_project = NULL; | ||||
|         View_edit_project* obj_view_edit_project = NULL; | ||||
|         //Devices::Parted obj_device = Devices::Parted();
 | ||||
|         //Quotas_sys::Quotas_sys obj_quotas_sys = Quotas_sys::Quotas_sys();
 | ||||
|         //Quotas_ubconfig::Quotas_ubconfig obj_quotas_ubconfig = Quotas_ubconfig::Quotas_ubconfig();
 | ||||
|         vector<string> vec_param_names; | ||||
|         map_str_str map_device; | ||||
|         string str_cmd_error; | ||||
|         string save_user_or_group; | ||||
|         string sys_or_ubconfig; | ||||
|         string hw_or_sw = ""; | ||||
|         string mode_quota = "ubconfig"; | ||||
|         Glib::RefPtr<Gtk::ListStore> list_store_groups; | ||||
|         Glib::RefPtr<Gtk::ListStore> list_store_users; | ||||
|         Glib::RefPtr<Gtk::ListStore> list_store_project; | ||||
|         Gtk::TreeModel::iterator iter_groups; | ||||
|         Gtk::TreeModel::iterator iter_users; | ||||
|         Gtk::TreeModel::iterator iter_project; | ||||
|         bool flag_validate_del_groups = false; | ||||
|         bool flag_validate_del_users = false; | ||||
|         bool flag_validate_del_project = false; | ||||
|         Gtk::TreeModel::Row row; | ||||
|         int* socket_ext_id_I = NULL; | ||||
|         int* socket_trd_id_I = NULL; | ||||
|         View_open_browser* obj_open_browser; | ||||
|         const struct tv_g_u_p obj_tv_g_u_p {"", "", "", "", "", "", "", "", "",""}; | ||||
|     public: | ||||
|         // MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
 | ||||
|         MainWindow(Glib::RefPtr<Gtk::Builder> builder, View_open_browser* obj_open_browser, int* socket_ext_id_I, int* socket_trd_id_I); | ||||
|         ~MainWindow(); | ||||
|         void settings(); | ||||
|         void flag_block_gui(); | ||||
|         void lacalization(); | ||||
|         void add_CSS(); | ||||
|         void resize_widget(); | ||||
|         void get_builder(); | ||||
|         void event(); | ||||
|         void open_browser(); | ||||
|         void info_warning_error(int mess, int error_save, int error_load); | ||||
|         void init_work_tv_g_u_p(); | ||||
|         void remove_line_template(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator& iter_del, bool& flag_del); | ||||
|         void remove_template(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate_del); | ||||
|         void init_tree_view_general(); | ||||
|         void entry_combo_box_temp(Gtk::ComboBoxText *combo_box, Gtk::Label *label); | ||||
|         void info_status_app(string stule); | ||||
|         void filters_show(); | ||||
|         void set_obj_wrapper_load_save(Wrapper_load_save* obj_wrapper_load_save); | ||||
|         void init_tree_view(); | ||||
|         void del_columns(); | ||||
|         void set_obj_browser(View_open_browser* obj_open_browser); | ||||
|         void set_add_tv_g_u_p(string name, Gtk::TreeView* tree_view, Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore>& list_store, struct tv_g_u_p obj_tv_g_u_p); | ||||
|         void off_quota_system(Gtk::ComboBoxText* combo_box, string quota_type); | ||||
|         void mode_switch_quota(); | ||||
|         void save_quotegroupSaveButton(); | ||||
|         void filling_device_combo_box_template(Gtk::ComboBoxText *combo_box, map_str_str &map_device); | ||||
|         void wrapper_settings_quotas_temp(string save_user_or_group); | ||||
|         void off_quota_ubconfig(Gtk::ComboBoxText* combo_box, string quota_type); | ||||
|         void init_spin_all(); | ||||
|         void view_add_columns(Gtk::TreeView &treeView); | ||||
|         void format_cmd_quotas_system(struct struct_quotas& _struct_quota); | ||||
|         void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota); | ||||
|         struct partition_cmd wrapper_settings_quotas(); | ||||
|         void set_map_gui(map_str_str* map_gui_cfg); | ||||
|         void set_map_global(map_str_str* map_global_cfg); | ||||
|         void set_map_local(map_str_str* map_system_cfg); | ||||
|         void wrapper_load_system(); | ||||
|         void wrapper_load_global(); | ||||
|         void wrapper_save_all(); | ||||
|         void wrapper_save_system(); | ||||
|         void wrapper_save_global(); | ||||
|         void set_obj_view_filters(View_filters* obj_view_filters); | ||||
|         bool check_space(Gtk::TreeView* tree_view); | ||||
|         void set_obj_view_add(View_add_user_group* obj_view_edit); | ||||
|         void add_quota_show(string name); | ||||
|         void edit_quota_show(string name); | ||||
|         void set_obj_view_edit(View_edit_user_group* obj_view_edit); | ||||
|         void set_obj_view_add_project(View_add_project* obj_view_add_project); | ||||
|         void set_obj_view_edit_project(View_edit_project* obj_view_edit_project); | ||||
|         void edit_quota_project_show(); | ||||
| }; | ||||
| void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data); | ||||
| void help(); | ||||
| #endif | ||||
| @ -1,91 +0,0 @@ | ||||
| #include "ubl-util-standard.h" | ||||
| #ifndef __cplusplus | ||||
| #ifndef UBL_GET_STANDARD_UI | ||||
| #define UBL_GET_STANDARD_UI | ||||
| 
 | ||||
| 
 | ||||
| inline returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id){ | ||||
|     returnstruct *ret=(returnstruct*)malloc(sizeof(returnstruct*)); | ||||
|     if (left_plug_id>0&&LeftWidget){ | ||||
|         GtkWidget *plug=gtk_plug_new(left_plug_id); | ||||
|         GtkWidget *toplug=LeftWidget; | ||||
|         if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ | ||||
|             g_object_ref(G_OBJECT(toplug)); | ||||
|             GtkWidget *parent=gtk_widget_get_parent(toplug); | ||||
|             gtk_container_remove(GTK_CONTAINER(parent),toplug); | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         } else  | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         gtk_widget_show(GTK_WIDGET(plug)); | ||||
|         ret->plugLeft=plug; | ||||
|     } | ||||
|     if (right_plug_id>0&&RightWidget){ | ||||
|         GtkWidget *plug=gtk_plug_new(right_plug_id); | ||||
|         GtkWidget *toplug=RightWidget; | ||||
|         if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ | ||||
|             g_object_ref(G_OBJECT(toplug)); | ||||
|             GtkWidget *parent=gtk_widget_get_parent(toplug); | ||||
|             gtk_container_remove(GTK_CONTAINER(parent),toplug); | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         } else  | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         gtk_widget_show(GTK_WIDGET(plug)); | ||||
|         ret->plugRight=plug; | ||||
|     } | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| 
 | ||||
| inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){ | ||||
|     if (left_plug_id>0&&LeftWidget){ | ||||
|         GtkWidget *plug=gtk_plug_new(left_plug_id); | ||||
|         GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj()); | ||||
|         {GdkScreen *screen = gtk_widget_get_screen(plug); | ||||
|         gtk_widget_set_app_paintable(plug,TRUE); | ||||
|         GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); | ||||
|         gtk_widget_set_visual(plug, colormap);} | ||||
|         {GdkScreen *screen = gtk_widget_get_screen(toplug); | ||||
|         gtk_widget_set_app_paintable(toplug,TRUE); | ||||
|         GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); | ||||
|         gtk_widget_set_visual(toplug, colormap);} | ||||
|         if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ | ||||
|             g_object_ref(G_OBJECT(toplug)); | ||||
|             GtkWidget *parent=gtk_widget_get_parent(toplug); | ||||
|             gtk_container_remove(GTK_CONTAINER(parent),toplug); | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         } else  | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         gtk_widget_show(GTK_WIDGET(plug)); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); | ||||
|     } | ||||
|     if (right_plug_id>0&&RightWidget){ | ||||
|         GtkWidget *plug=gtk_plug_new(right_plug_id); | ||||
|         GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj()); | ||||
|         {GdkScreen *screen = gtk_widget_get_screen(plug); | ||||
|         gtk_widget_set_app_paintable(plug,TRUE); | ||||
|         GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); | ||||
|         gtk_widget_set_visual(plug, colormap);} | ||||
|         {GdkScreen *screen = gtk_widget_get_screen(toplug); | ||||
|         gtk_widget_set_app_paintable(toplug,TRUE); | ||||
|         GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); | ||||
|         gtk_widget_set_visual(toplug, colormap);} | ||||
|         if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ | ||||
|             g_object_ref(G_OBJECT(toplug)); | ||||
|             GtkWidget *parent=gtk_widget_get_parent(toplug); | ||||
|             gtk_container_remove(GTK_CONTAINER(parent),toplug); | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         } else  | ||||
|             gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); | ||||
|         gtk_widget_show(GTK_WIDGET(plug)); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); | ||||
|         gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); | ||||
|     } | ||||
| } | ||||
| #endif | ||||
| @ -1,20 +0,0 @@ | ||||
| #ifndef __cplusplus | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| 
 | ||||
| typedef struct { | ||||
|     GtkWidget *plugLeft; | ||||
|     GtkWidget *plugRight; | ||||
| 
 | ||||
| 
 | ||||
| } returnstruct; | ||||
| static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id); | ||||
| #else | ||||
| #include <gtkmm.h> | ||||
| #include <gtkmm/stock.h> | ||||
| #include <gtkmm/window.h> | ||||
| #include <gtkmm/plug.h> | ||||
| 
 | ||||
| 
 | ||||
| static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id); | ||||
| #endif | ||||
| @ -1,47 +0,0 @@ | ||||
| #include "view_about.h" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| View_about::View_about() { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->settings(); | ||||
| } | ||||
| 
 | ||||
| View_about::~View_about() { | ||||
| } | ||||
| 
 | ||||
| void View_about::lacalization() { | ||||
|     time_t now = time(0); | ||||
|     tm *ltm = localtime(&now); | ||||
|     unsigned int year = 1900 + ltm->tm_year; | ||||
|     string str_authors = string(copyright) + to_string(year);  | ||||
|     aboutWindows->set_copyright(str_authors); | ||||
|     aboutWindows->set_comments(str_setting_user); | ||||
|     aboutWindows->set_website(website); | ||||
|     aboutWindows->set_version(_(version_application.c_str())); | ||||
|     aboutWindows->set_website_label(project_Home_page); | ||||
|     headerAboutTopic->set_label(_(app_name)); | ||||
| } | ||||
| 
 | ||||
| void View_about::set_version(string version_application) { | ||||
|     version_application = version_application; | ||||
| } | ||||
| 
 | ||||
| void View_about::show() { | ||||
|     aboutWindows->show(); | ||||
| } | ||||
| void View_about::get_builder() { | ||||
|     builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog); | ||||
|     builder->get_widget("aboutWindows", aboutWindows); | ||||
|     builder->get_widget("headerAboutTopic", headerAboutTopic); | ||||
| } | ||||
| 
 | ||||
| void View_about::settings() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     btnBoxAboutDialog->set_visible(false); | ||||
| } | ||||
| 
 | ||||
| View_about* View_about::get_self() { | ||||
|     return this; | ||||
| } | ||||
| @ -1,29 +0,0 @@ | ||||
| #ifndef VIEW_ABOUT_H | ||||
| #define VIEW_ABOUT_H | ||||
| #include "../project_lib.h" | ||||
| #include "model/util.h" | ||||
| #include "../var.h" | ||||
| 
 | ||||
| class View_about | ||||
| { | ||||
| private: | ||||
|     string version_application; | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Label *headerAboutTopic; | ||||
|     Gtk::ButtonBox *btnBoxAboutDialog; | ||||
| public: | ||||
|     Gtk::AboutDialog *aboutWindows; | ||||
| public: | ||||
|     View_about(); | ||||
|     ~View_about(); | ||||
|     void lacalization(); | ||||
|     void event(); | ||||
|     View_about* get_self(); | ||||
|     void get_builder(); | ||||
|     void settings(); | ||||
|     void show(); | ||||
|     void set_path_glade(string str_path_glade); | ||||
|     void set_version(string version_application); | ||||
| }; | ||||
| #endif | ||||
| @ -1,139 +0,0 @@ | ||||
| #include "view_add_project.h" | ||||
| 
 | ||||
| View_add_project::View_add_project(/* args */) { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->setting(); | ||||
| } | ||||
| 
 | ||||
| View_add_project::~View_add_project() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void View_add_project::setting() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     check_limit(quotegroupSizeSoftLimitCheckProject | ||||
|         ,quotegroupSizeSoftLimitSpinProject | ||||
|         ,quotegroupSizeSoftLimitComboProject); | ||||
|     check_limit(quotegroupSizeHardLimitCheckProject | ||||
|         ,quotegroupSizeHardLimitSpin1 | ||||
|         ,quotegroupSizeHardLimitComboProject); | ||||
|     check_limit(quotegroupFilesSoftLimitCheckProject | ||||
|         ,quotegroupFilesSoftLimitSpinProject | ||||
|         ,quotegroupFilesSoftLimitlabelProject); | ||||
|     check_limit(quotegroupFilesHardLimitCheckProject | ||||
|         ,quotegroupFilesHardLimitSpinProject | ||||
|         ,quotegroupFilesHarLimitLabelProject); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::event() { | ||||
|     quotegroupSizeSoftLimitCheckProject->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeSoftLimitCheckProject | ||||
|             ,quotegroupSizeSoftLimitSpinProject | ||||
|             ,quotegroupSizeSoftLimitComboProject); | ||||
|     }); | ||||
|     quotegroupSizeHardLimitCheckProject->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeHardLimitCheckProject | ||||
|             ,quotegroupSizeHardLimitSpin1 | ||||
|             ,quotegroupSizeHardLimitComboProject); | ||||
|     }); | ||||
|     quotegroupFilesSoftLimitCheckProject->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesSoftLimitCheckProject | ||||
|             ,quotegroupFilesSoftLimitSpinProject | ||||
|             ,quotegroupFilesSoftLimitlabelProject); | ||||
|     }); | ||||
|     quotegroupFilesHardLimitCheckProject->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesHardLimitCheckProject | ||||
|             ,quotegroupFilesHardLimitSpinProject | ||||
|             ,quotegroupFilesHarLimitLabelProject); | ||||
|     }); | ||||
|     quotegroupCancelButtonAdd->signal_clicked().connect([&]() {this->close_wnd();}); | ||||
|     quotegroupSaveButtonAdd->signal_clicked().connect([&]() {this->save();}); | ||||
|     btnReviewProject->signal_clicked().connect([&]() {show_file_manager();}); | ||||
|     btnFilemangerOk->signal_clicked().connect([&]() {save_file_manager();}); | ||||
|     btnFilemangerExit->signal_clicked().connect([&]() {wndChooseFileWallpaper->hide();}); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::show_file_manager() { | ||||
|     wndChooseFileWallpaper->set_current_folder(open_dir_file_manager); | ||||
|     wndChooseFileWallpaper->show(); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::save_file_manager() { | ||||
|     entryCatalogProject->set_text(wndChooseFileWallpaper->get_filename()); | ||||
|     wndChooseFileWallpaper->hide(); | ||||
| } | ||||
| void View_add_project::close_wnd() { | ||||
|     wndQuotasAddProject->hide(); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::save() { | ||||
|     wndQuotasAddProject->hide(); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::show() { | ||||
|     wndQuotasAddProject->show(); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::get_builder() { | ||||
|     builder->get_widget("wndQuotasAddProject", wndQuotasAddProject); | ||||
|     builder->get_widget("quotegroupSizeFrameLabelProject", quotegroupSizeFrameLabelProject); | ||||
|     builder->get_widget("quotegroupFilesFrameLabelProject", quotegroupFilesFrameLabelProject); | ||||
|     builder->get_widget("quotegroupSizeCurrentlyLabelProject", quotegroupSizeCurrentlyLabelProject); | ||||
|     builder->get_widget("quotegroupFilesCurrentlyLabelProject", quotegroupFilesCurrentlyLabelProject); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitLabelProject", quotegroupSizeSoftLimitLabelProject); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitLabelProject", quotegroupFilesSoftLimitLabelProject); | ||||
|     builder->get_widget("quoteSizeHardLimitLabelProject", quoteSizeHardLimitLabelProject); | ||||
|     builder->get_widget("quoteFilesHardLimitLabelProject", quoteFilesHardLimitLabelProject); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitlabelProject", quotegroupFilesSoftLimitlabelProject); | ||||
|     builder->get_widget("quotegroupFilesHarLimitLabelProject", quotegroupFilesHarLimitLabelProject); | ||||
|     builder->get_widget("quotegroupCancelButtonAdd", quotegroupCancelButtonAdd); | ||||
|     builder->get_widget("quotegroupSaveButtonAdd", quotegroupSaveButtonAdd); | ||||
|     builder->get_widget("lblDeviceProject", lblDeviceProject); | ||||
|     builder->get_widget("lblStatusQuotaProject", lblStatusQuotaProject); | ||||
|     builder->get_widget("lblCatalogProject", lblCatalogProject); | ||||
|     builder->get_widget("lblProjectId", lblProjectId); | ||||
|     builder->get_widget("lblProjectName", lblProjectName); | ||||
|     builder->get_widget("btnReviewProject", btnReviewProject); | ||||
|     builder->get_widget("btnGenerateProject", btnGenerateProject); | ||||
|     builder->get_widget("chbAuto", chbAuto); | ||||
|     builder->get_widget("entryCatalogProject", entryCatalogProject); | ||||
|     builder->get_widget("entryProjectId", entryProjectId); | ||||
|     builder->get_widget("entryProjectName", entryProjectName); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitCheckProject", quotegroupSizeSoftLimitCheckProject); | ||||
|     builder->get_widget("quotegroupSizeHardLimitCheckProject", quotegroupSizeHardLimitCheckProject); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitCheckProject", quotegroupFilesSoftLimitCheckProject); | ||||
|     builder->get_widget("quotegroupFilesHardLimitCheckProject", quotegroupFilesHardLimitCheckProject); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitSpinProject", quotegroupSizeSoftLimitSpinProject); | ||||
|     builder->get_widget("quotegroupSizeHardLimitSpin1", quotegroupSizeHardLimitSpin1); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitSpinProject", quotegroupFilesSoftLimitSpinProject); | ||||
|     builder->get_widget("quotegroupFilesHardLimitSpinProject", quotegroupFilesHardLimitSpinProject); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitComboProject", quotegroupSizeSoftLimitComboProject); | ||||
|     builder->get_widget("quotegroupSizeHardLimitComboProject", quotegroupSizeHardLimitComboProject); | ||||
|     builder->get_widget("wndChooseFileWallpaper", wndChooseFileWallpaper); | ||||
|     builder->get_widget("btnFilemangerExit", btnFilemangerExit); | ||||
|     builder->get_widget("btnFilemangerOk", btnFilemangerOk); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::lacalization() { | ||||
|     this->fill_in_pow_memory(quotegroupSizeSoftLimitComboProject); | ||||
|     this->fill_in_pow_memory(quotegroupSizeHardLimitComboProject); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void View_add_project::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| void View_add_project::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| 
 | ||||
| void View_add_project::fill_in_pow_memory(Gtk::ComboBoxText *cb_text) { | ||||
|     cb_text->append(str_prefix_KB); | ||||
|     cb_text->append(str_prefix_MB); | ||||
|     cb_text->append(str_prefix_GB); | ||||
|     cb_text->append(str_prefix_TB); | ||||
| } | ||||
| @ -1,67 +0,0 @@ | ||||
| #ifndef VIEW_ADD_PROJECT_H | ||||
| #define VIEW_ADD_PROJECT_H | ||||
| #include "../project_lib.h" | ||||
| #include "../var.h" | ||||
| class View_add_project | ||||
| { | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Window* wndQuotasAddProject; | ||||
|     Gtk::Label* quotegroupSizeFrameLabelProject; | ||||
|     Gtk::Label* quotegroupFilesFrameLabelProject; | ||||
|     Gtk::Label* quotegroupSizeCurrentlyLabelProject; | ||||
|     Gtk::Label* quotegroupFilesCurrentlyLabelProject; | ||||
|     Gtk::Label* quotegroupSizeSoftLimitLabelProject; | ||||
|     Gtk::Label* quotegroupFilesSoftLimitLabelProject; | ||||
|     Gtk::Label* quoteSizeHardLimitLabelProject; | ||||
|     Gtk::Label* quoteFilesHardLimitLabelProject; | ||||
|     Gtk::Label* quotegroupFilesSoftLimitlabelProject; | ||||
|     Gtk::Label* quotegroupFilesHarLimitLabelProject; | ||||
|     Gtk::Label* lblDeviceProject; | ||||
|     Gtk::Label* lblStatusQuotaProject; | ||||
|     Gtk::Label* lblCatalogProject; | ||||
|     Gtk::Label* lblProjectId; | ||||
|     Gtk::Label* lblProjectName; | ||||
|     Gtk::Button* quotegroupCancelButtonAdd; | ||||
|     Gtk::Button* quotegroupSaveButtonAdd; | ||||
|     Gtk::Button* btnReviewProject; | ||||
|     Gtk::Button* btnGenerateProject; | ||||
|     Gtk::Entry* entryCatalogProject; | ||||
|     Gtk::Entry* entryProjectId; | ||||
|     Gtk::Entry* entryProjectName; | ||||
|     Gtk::CheckButton* chbAuto; | ||||
|     Gtk::CheckButton* quotegroupSizeSoftLimitCheckProject; | ||||
|     Gtk::CheckButton* quotegroupSizeHardLimitCheckProject; | ||||
|     Gtk::CheckButton* quotegroupFilesSoftLimitCheckProject; | ||||
|     Gtk::CheckButton* quotegroupFilesHardLimitCheckProject; | ||||
|     Gtk::SpinButton* quotegroupSizeSoftLimitSpinProject; | ||||
|     Gtk::SpinButton* quotegroupSizeHardLimitSpin1; | ||||
|     Gtk::SpinButton* quotegroupFilesSoftLimitSpinProject; | ||||
|     Gtk::SpinButton* quotegroupFilesHardLimitSpinProject; | ||||
|     Gtk::ComboBoxText* quotegroupSizeSoftLimitComboProject; | ||||
|     Gtk::ComboBoxText* quotegroupSizeHardLimitComboProject; | ||||
|     Gtk::FileChooserDialog* wndChooseFileWallpaper; | ||||
|     Gtk::Button* btnFilemangerOk; | ||||
|     Gtk::Button* btnFilemangerExit; | ||||
| 
 | ||||
| public: | ||||
|     View_add_project(/* args */); | ||||
|     ~View_add_project(); | ||||
|     void setting(); | ||||
|     void lacalization(); | ||||
|     void event(); | ||||
|     void show(); | ||||
|     void close_wnd(); | ||||
|     void save(); | ||||
|     void get_builder(); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box); | ||||
|     void fill_in_pow_memory(Gtk::ComboBoxText *cb_text); | ||||
|     void show_file_manager();  | ||||
|     void save_file_manager(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
| @ -1,118 +0,0 @@ | ||||
| #include "view_add_user_group.h" | ||||
| 
 | ||||
| 
 | ||||
| View_add_user_group::View_add_user_group(/* args */) { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->settings(); | ||||
| } | ||||
| 
 | ||||
| View_add_user_group::~View_add_user_group() { | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::settings() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     check_limit(quotegroupSizeSoftLimitCheck | ||||
|         ,quotegroupSizeSoftLimitSpin | ||||
|         ,quotegroupSizeSoftLimitCombo); | ||||
|     check_limit(quotegroupSizeHardLimitCheck | ||||
|         ,quotegroupSizeHardLimitSpin | ||||
|         ,quotegroupSizeHardLimitCombo); | ||||
|     check_limit(quotegroupFilesSoftLimitCheck | ||||
|         ,quotegroupFilesSoftLimitSpin | ||||
|         ,quotegroupFilesSoftLimitlabel); | ||||
|     check_limit(quotegroupFilesHardLimitCheck | ||||
|         ,quotegroupFilesHardLimitSpin | ||||
|         ,quotegroupFilesHarLimitLabel); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::event() { | ||||
|     quotegroupCancelButton->signal_clicked().connect([&]() {QuotasEditWindow->hide();}); | ||||
|     quotegroupSaveButton->signal_clicked().connect([&]() {}); | ||||
|     quotegroupSizeSoftLimitCheck->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeSoftLimitCheck | ||||
|         ,quotegroupSizeSoftLimitSpin | ||||
|         ,quotegroupSizeSoftLimitCombo); | ||||
|     }); | ||||
|     quotegroupSizeHardLimitCheck->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeHardLimitCheck | ||||
|         ,quotegroupSizeHardLimitSpin | ||||
|         ,quotegroupSizeHardLimitCombo); | ||||
|     }); | ||||
|     quotegroupFilesSoftLimitCheck->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesSoftLimitCheck | ||||
|         ,quotegroupFilesSoftLimitSpin | ||||
|         ,quotegroupFilesSoftLimitlabel); | ||||
|     }); | ||||
|     quotegroupFilesHardLimitCheck->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesHardLimitCheck | ||||
|         ,quotegroupFilesHardLimitSpin | ||||
|         ,quotegroupFilesHarLimitLabel); | ||||
|     }); | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::get_builder() { | ||||
|     builder->get_widget("lblSetDevice", lblSetDevice); | ||||
|     builder->get_widget("lblQuotasStatus", lblQuotasStatus); | ||||
|     builder->get_widget("lblSetUGP", lblSetUGP); | ||||
|     builder->get_widget("lblSetNameDevice", lblSetNameDevice); | ||||
|     builder->get_widget("lblSetQuotasStatus", lblSetQuotasStatus); | ||||
|     builder->get_widget("cmbSetNameUGP", cmbSetNameUGP); | ||||
|     builder->get_widget("quotegroupSizeFrameLabel", quotegroupSizeFrameLabel); | ||||
|     builder->get_widget("quotegroupFilesFrameLabel", quotegroupFilesFrameLabel); | ||||
|     builder->get_widget("quotegroupSizeCurrentlyLabel", quotegroupSizeCurrentlyLabel); | ||||
|     builder->get_widget("quotegroupFilesCurrentlyLabel", quotegroupFilesCurrentlyLabel); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitLabel", quotegroupSizeSoftLimitLabel); | ||||
|     builder->get_widget("quoteSizeHardLimitLabel", quoteSizeHardLimitLabel); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitLabel", quotegroupFilesSoftLimitLabel); | ||||
|     builder->get_widget("quoteFilesHardLimitLabel", quoteFilesHardLimitLabel); | ||||
|     builder->get_widget("quotegroupFilesHarLimitLabel", quotegroupFilesHarLimitLabel); | ||||
|     builder->get_widget("QuotasEditWindow", QuotasEditWindow); | ||||
|     builder->get_widget("lblHeadQuotasEditWindow", lblHeadQuotasEditWindow); | ||||
|     builder->get_widget("quotegroupCancelButton", quotegroupCancelButton); | ||||
|     builder->get_widget("quotegroupSaveButton", quotegroupSaveButton); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitSpin", quotegroupSizeSoftLimitSpin); | ||||
|     builder->get_widget("quotegroupSizeHardLimitSpin", quotegroupSizeHardLimitSpin); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitSpin", quotegroupFilesSoftLimitSpin); | ||||
|     builder->get_widget("quotegroupFilesHardLimitSpin", quotegroupFilesHardLimitSpin); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitlabel", quotegroupFilesSoftLimitlabel); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitCombo", quotegroupSizeSoftLimitCombo); | ||||
|     builder->get_widget("quotegroupSizeHardLimitCombo", quotegroupSizeHardLimitCombo); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitCheck", quotegroupSizeSoftLimitCheck); | ||||
|     builder->get_widget("quotegroupSizeHardLimitCheck", quotegroupSizeHardLimitCheck); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitCheck", quotegroupFilesSoftLimitCheck); | ||||
|     builder->get_widget("quotegroupFilesHardLimitCheck", quotegroupFilesHardLimitCheck); | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::show() { | ||||
|     QuotasEditWindow->show(); | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::lacalization() { | ||||
|     this->fill_in_pow_memory(quotegroupSizeSoftLimitCombo); | ||||
|     this->fill_in_pow_memory(quotegroupSizeHardLimitCombo); | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| void View_add_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::fill_in_pow_memory(Gtk::ComboBoxText *cb_text) { | ||||
|     cb_text->append(str_prefix_KB); | ||||
|     cb_text->append(str_prefix_MB); | ||||
|     cb_text->append(str_prefix_GB); | ||||
|     cb_text->append(str_prefix_TB); | ||||
| } | ||||
| 
 | ||||
| void View_add_user_group::set_label_type_quota(string name) { | ||||
|     lblSetUGP->set_text(name); | ||||
| } | ||||
| @ -1,63 +0,0 @@ | ||||
| #ifndef VIEW_SET_USER_GROUP_H | ||||
| #define VIEW_SET_USER_GROUP_H | ||||
| #include "../project_lib.h" | ||||
| #include "../var.h" | ||||
| 
 | ||||
| using namespace std; | ||||
| class View_add_user_group | ||||
| { | ||||
| private: | ||||
|     string str_path_glade; | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Label* lblSetDevice; | ||||
|     Gtk::Label* lblQuotasStatus; | ||||
|     Gtk::Label* lblSetUGP; | ||||
|     Gtk::Label* lblSetNameDevice; | ||||
|     Gtk::Label* lblSetQuotasStatus; | ||||
|     Gtk::ComboBoxText* cmbSetNameUGP; | ||||
|     Gtk::Label *quotegroupSizeFrameLabel; | ||||
|     Gtk::Label *quotegroupSizeCurrentlyLabel; | ||||
|     Gtk::Label *quoteSizeHardLimitLabel; | ||||
|     Gtk::Label *quotegroupFilesFrameLabel; | ||||
|     Gtk::Label *quotegroupFilesCurrentlyLabel; | ||||
|     Gtk::Label *quotegroupFilesSoftLimitLabel; | ||||
|     Gtk::Label *quoteFilesHardLimitLabel; | ||||
|     Gtk::Label *quotegroupFilesHarLimitLabel; | ||||
|     Gtk::Label *quotegroupSizeSoftLimitLabel; | ||||
|     Gtk::Window *QuotasEditWindow; | ||||
|     Gtk::Label *lblHeadQuotasEditWindow; | ||||
|     Gtk::Button *quotegroupCancelButton; | ||||
|     Gtk::Button *quotegroupSaveButton; | ||||
|     Gtk::SpinButton *quotegroupSizeSoftLimitSpin; | ||||
|     Gtk::SpinButton *quotegroupSizeHardLimitSpin; | ||||
|     Gtk::SpinButton *quotegroupFilesSoftLimitSpin; | ||||
|     Gtk::SpinButton *quotegroupFilesHardLimitSpin; | ||||
|     Gtk::Label *quotegroupFilesSoftLimitlabel; | ||||
|     Gtk::ComboBoxText *quotegroupSizeSoftLimitCombo; | ||||
|     Gtk::ComboBoxText *quotegroupSizeHardLimitCombo; | ||||
|     Gtk::CheckButton *quotegroupSizeSoftLimitCheck; | ||||
|     Gtk::CheckButton *quotegroupSizeHardLimitCheck; | ||||
|     Gtk::CheckButton *quotegroupFilesSoftLimitCheck; | ||||
|     Gtk::CheckButton *quotegroupFilesHardLimitCheck; | ||||
| public: | ||||
|     View_add_user_group(/* args */); | ||||
|     ~View_add_user_group(); | ||||
|     void lacalization(); | ||||
|     void event(); | ||||
|     void get_builder(); | ||||
|     void settings(); | ||||
|     void show(); | ||||
|     void set_path_glade(string str_path_glade); | ||||
|     void set_label_type_quota(string name); | ||||
| private: | ||||
|     void set_change_gui(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter,   bool& flag_validate, Gtk::ComboBoxText *combo_box); | ||||
|     void fill_in_pow_memory(Gtk::ComboBoxText *cb_text); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box); | ||||
|     void edit_tree_view_U(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); | ||||
|     void edit_tree_view_G(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); | ||||
|     void edit_tree_view_P(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| @ -1,124 +0,0 @@ | ||||
| #include "view_edit_project.h" | ||||
| 
 | ||||
| View_edit_project::View_edit_project(/* args */) { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->setting(); | ||||
| } | ||||
| 
 | ||||
| View_edit_project::~View_edit_project() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::setting() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     check_limit(quoteSizeSoftLimitCheckProjectEdit | ||||
|         ,quoteSizeSoftLimitSpinProjectEdit | ||||
|         ,quoteSizeSoftLimitComboProjectEdit); | ||||
|     check_limit(quoteSizeHardLimitCheckProjectEdit | ||||
|         ,quoteSizeHardLimitSpinEdit | ||||
|         ,quoteSizeHardLimitComboProjectEdit); | ||||
|     check_limit(quoteFilesSoftLimitCheckProjectEdit | ||||
|         ,quoteFilesSoftLimitSpinProjectEdit | ||||
|         ,quoteFilesProjectEdit); | ||||
|     check_limit(quoteFilesHardLimitCheckProjectEdit | ||||
|         ,quoteFilesHardLimitSpinProjectEdit | ||||
|         ,quoteFiles1ProjectEdit); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::event() { | ||||
|      | ||||
|     quoteCancelButtonEdit->signal_clicked().connect([&]() {this->close_wnd();}); | ||||
|     quoteSaveButtonEdit->signal_clicked().connect([&]() {this->save();}); | ||||
|     quoteSizeSoftLimitCheckProjectEdit->signal_toggled().connect([&]() { | ||||
|         check_limit(quoteSizeSoftLimitCheckProjectEdit | ||||
|         ,quoteSizeSoftLimitSpinProjectEdit | ||||
|         ,quoteSizeSoftLimitComboProjectEdit); | ||||
|     }); | ||||
|     quoteSizeHardLimitCheckProjectEdit->signal_toggled().connect([&]() { | ||||
|         check_limit(quoteSizeHardLimitCheckProjectEdit | ||||
|         ,quoteSizeHardLimitSpinEdit | ||||
|         ,quoteSizeHardLimitComboProjectEdit); | ||||
|     }); | ||||
|     quoteFilesSoftLimitCheckProjectEdit->signal_toggled().connect([&]() { | ||||
|         check_limit(quoteFilesSoftLimitCheckProjectEdit | ||||
|         ,quoteFilesSoftLimitSpinProjectEdit | ||||
|         ,quoteFilesProjectEdit); | ||||
|     }); | ||||
|     quoteFilesSoftLimitCheckProjectEdit->signal_toggled().connect([&]() { | ||||
|         check_limit(quoteFilesSoftLimitCheckProjectEdit | ||||
|         ,quoteFilesHardLimitSpinProjectEdit | ||||
|         ,quoteFiles1ProjectEdit); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::close_wnd() { | ||||
|     wndQuotasEditProject->hide(); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::save() { | ||||
|     wndQuotasEditProject->hide(); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::show() { | ||||
|     wndQuotasEditProject->show(); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::get_builder() { | ||||
|     builder->get_widget("lblDeviceProjectEdit", lblDeviceProjectEdit); | ||||
|     builder->get_widget("lblEditDeviceProjectValue", lblEditDeviceProjectValue); | ||||
|     builder->get_widget("lblStatusQuotaProjectEdit", lblStatusQuotaProjectEdit); | ||||
|     builder->get_widget("lblStatusQuotaProjectValueEdit", lblStatusQuotaProjectValueEdit); | ||||
|     builder->get_widget("lblCatalogProjectEdit", lblCatalogProjectEdit); | ||||
|     builder->get_widget("lblCatalogProjectEdit", lblCatalogProjectEdit); | ||||
|     builder->get_widget("lblProjectIdEdit", lblProjectIdEdit); | ||||
|     builder->get_widget("lblProjectIdValueEdit", lblProjectIdValueEdit); | ||||
|     builder->get_widget("lblProjectNameEdit", lblProjectNameEdit); | ||||
|     builder->get_widget("entryProjectNameEditValue", entryProjectNameEditValue); | ||||
|     builder->get_widget("quoteSizeFrameLabelProjectEdit", quoteSizeFrameLabelProjectEdit); | ||||
|     builder->get_widget("quoteSizeCurrentlyLabelProjectEdit", quoteSizeCurrentlyLabelProjectEdit); | ||||
|     builder->get_widget("quoteSizeSoftLimitLabelProjectEdit", quoteSizeSoftLimitLabelProjectEdit); | ||||
|     builder->get_widget("quoteSizeSoftLimitCheckProjectEdit", quoteSizeSoftLimitCheckProjectEdit); | ||||
|     builder->get_widget("quoteSizeSoftLimitSpinProjectEdit", quoteSizeSoftLimitSpinProjectEdit); | ||||
|     builder->get_widget("quoteSizeSoftLimitComboProjectEdit", quoteSizeSoftLimitComboProjectEdit); | ||||
|     builder->get_widget("quoteSizeHardLimitLabelProjectEdit", quoteSizeHardLimitLabelProjectEdit); | ||||
|     builder->get_widget("quoteSizeHardLimitCheckProjectEdit", quoteSizeHardLimitCheckProjectEdit); | ||||
|     builder->get_widget("quoteSizeHardLimitSpinEdit", quoteSizeHardLimitSpinEdit); | ||||
|     builder->get_widget("quoteSizeHardLimitComboProjectEdit", quoteSizeHardLimitComboProjectEdit); | ||||
|     builder->get_widget("quoteFilesFrameLabelProjectEdit", quoteFilesFrameLabelProjectEdit); | ||||
|     builder->get_widget("quoteFilesCurrentlyLabelProjectEdit", quoteFilesCurrentlyLabelProjectEdit); | ||||
|     builder->get_widget("quoteFilesSoftLimitLabelProjectEdit", quoteFilesSoftLimitLabelProjectEdit); | ||||
|     builder->get_widget("quoteFilesSoftLimitCheckProjectEdit", quoteFilesSoftLimitCheckProjectEdit); | ||||
|     builder->get_widget("quoteFilesSoftLimitSpinProjectEdit", quoteFilesSoftLimitSpinProjectEdit); | ||||
|     builder->get_widget("quoteFilesHardLimitCheckProjectEdit", quoteFilesHardLimitCheckProjectEdit); | ||||
|     builder->get_widget("quoteFilesHardLimitSpinProjectEdit", quoteFilesHardLimitSpinProjectEdit); | ||||
|     builder->get_widget("quoteCancelButtonEdit", quoteCancelButtonEdit); | ||||
|     builder->get_widget("quoteSaveButtonEdit", quoteSaveButtonEdit); | ||||
|     builder->get_widget("quoteFilesProjectEdit", quoteFilesProjectEdit); | ||||
|     builder->get_widget("quoteFiles1ProjectEdit", quoteFiles1ProjectEdit); | ||||
|     builder->get_widget("wndQuotasEditProject", wndQuotasEditProject); | ||||
|     builder->get_widget("quoteFilesHardLimitLabelProject1", quoteFilesHardLimitLabelProject1);  | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::lacalization() { | ||||
|     this->fill_in_pow_memory(quoteSizeSoftLimitComboProjectEdit); | ||||
|     this->fill_in_pow_memory(quoteSizeHardLimitComboProjectEdit); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void View_edit_project::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| void View_edit_project::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| 
 | ||||
| void View_edit_project::fill_in_pow_memory(Gtk::ComboBoxText *cb_text) { | ||||
|     cb_text->append(str_prefix_KB); | ||||
|     cb_text->append(str_prefix_MB); | ||||
|     cb_text->append(str_prefix_GB); | ||||
|     cb_text->append(str_prefix_TB); | ||||
| } | ||||
| @ -1,59 +0,0 @@ | ||||
| #ifndef VIEW_EDIT_PROJECT_H | ||||
| #define VIEW_EDIT_PROJECT_H | ||||
| #include "../project_lib.h" | ||||
| #include "../var.h" | ||||
| class View_edit_project | ||||
| { | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Window* wndQuotasEditProject; | ||||
|     Gtk::Label* lblDeviceProjectEdit; | ||||
|     Gtk::Label* lblEditDeviceProjectValue; | ||||
|     Gtk::Label* lblStatusQuotaProjectEdit; | ||||
|     Gtk::Label* lblStatusQuotaProjectValueEdit; | ||||
|     Gtk::Label* lblCatalogProjectEdit; | ||||
|     Gtk::Label* lblProjectIdEdit; | ||||
|     Gtk::Label* lblProjectIdValueEdit; | ||||
|     Gtk::Label* lblProjectNameEdit; | ||||
|     Gtk::Label* quoteSizeFrameLabelProjectEdit; | ||||
|     Gtk::Label* quoteFilesFrameLabelProjectEdit; | ||||
|     Gtk::Label* quoteSizeCurrentlyLabelProjectEdit; | ||||
|     Gtk::Label* quoteSizeSoftLimitLabelProjectEdit; | ||||
|     Gtk::Label* quoteSizeHardLimitLabelProjectEdit; | ||||
|     Gtk::Label* quoteFilesCurrentlyLabelProjectEdit; | ||||
|     Gtk::Label* quoteFilesSoftLimitLabelProjectEdit; | ||||
|     Gtk::Label* quoteFilesHardLimitLabelProject1; | ||||
|     Gtk::Label* quoteFilesProjectEdit; | ||||
|     Gtk::Label* quoteFiles1ProjectEdit; | ||||
|     Gtk::CheckButton* quoteSizeSoftLimitCheckProjectEdit; | ||||
|     Gtk::CheckButton* quoteSizeHardLimitCheckProjectEdit; | ||||
|     Gtk::CheckButton* quoteFilesSoftLimitCheckProjectEdit; | ||||
|     Gtk::CheckButton* quoteFilesHardLimitCheckProjectEdit; | ||||
|     Gtk::SpinButton* quoteSizeSoftLimitSpinProjectEdit; | ||||
|     Gtk::SpinButton* quoteSizeHardLimitSpinEdit; | ||||
|     Gtk::SpinButton* quoteFilesSoftLimitSpinProjectEdit; | ||||
|     Gtk::SpinButton* quoteFilesHardLimitSpinProjectEdit; | ||||
|     Gtk::ComboBoxText* quoteSizeSoftLimitComboProjectEdit; | ||||
|     Gtk::ComboBoxText* quoteSizeHardLimitComboProjectEdit; | ||||
|     Gtk::Button* quoteSaveButtonEdit; | ||||
|     Gtk::Button* quoteCancelButtonEdit; | ||||
|     Gtk::Entry* entryProjectNameEditValue; | ||||
| public: | ||||
|     View_edit_project(/* args */); | ||||
|     ~View_edit_project(); | ||||
|     void setting(); | ||||
|     void event(); | ||||
|     void show(); | ||||
|     void get_builder(); | ||||
|     void lacalization(); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box); | ||||
|     void fill_in_pow_memory(Gtk::ComboBoxText *cb_text); | ||||
|     void close_wnd(); | ||||
|     void save(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
| @ -1,115 +0,0 @@ | ||||
| #include "view_edit_user_group.h" | ||||
| 
 | ||||
| View_edit_user_group::View_edit_user_group(/* args */) { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->setting(); | ||||
| } | ||||
| 
 | ||||
| View_edit_user_group::~View_edit_user_group() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::setting() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     check_limit(quotegroupSizeSoftLimitCheckUser | ||||
|         ,quotegroupSizeSoftLimitSpinUser | ||||
|         ,quotegroupSizeSoftLimitComboUser); | ||||
|     check_limit(quotegroupSizeHardLimitCheckUser | ||||
|         ,quotegroupSizeHardLimitSpinUser | ||||
|         ,quotegroupSizeHardLimitComboUser); | ||||
|     check_limit(quotegroupFilesSoftLimitCheckUser | ||||
|         ,quotegroupFilesSoftLimitSpinUser | ||||
|         ,quotegroupFilesSoftLimitlabelUser); | ||||
|     check_limit(quotegroupFilesHardLimitCheckUser | ||||
|         ,quotegroupFilesHardLimitSpinUser | ||||
|         ,quotegroupFilesHarLimitLabelUser); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::event() { | ||||
|     btnCancelEditUser->signal_clicked().connect([&]() {wndQuotasEditUser->hide();}); | ||||
|     btnSaveEditUser->signal_clicked().connect([&]() {}); | ||||
|     quotegroupSizeSoftLimitCheckUser->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeSoftLimitCheckUser | ||||
|         ,quotegroupSizeSoftLimitSpinUser | ||||
|         ,quotegroupSizeSoftLimitComboUser); | ||||
|     }); | ||||
|     quotegroupSizeHardLimitCheckUser->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupSizeHardLimitCheckUser | ||||
|         ,quotegroupSizeHardLimitSpinUser | ||||
|         ,quotegroupSizeHardLimitComboUser); | ||||
|     }); | ||||
|     quotegroupFilesSoftLimitCheckUser->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesSoftLimitCheckUser | ||||
|         ,quotegroupFilesSoftLimitSpinUser | ||||
|         ,quotegroupFilesSoftLimitlabelUser); | ||||
|     }); | ||||
|     quotegroupFilesHardLimitCheckUser->signal_toggled().connect([&]() { | ||||
|         check_limit(quotegroupFilesHardLimitCheckUser | ||||
|         ,quotegroupFilesHardLimitSpinUser | ||||
|         ,quotegroupFilesHarLimitLabelUser); | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::get_builder() { | ||||
|     builder->get_widget("wndQuotasEditUser", wndQuotasEditUser); | ||||
|     builder->get_widget("btnCancelEditUser", btnCancelEditUser); | ||||
|     builder->get_widget("btnSaveEditUser", btnSaveEditUser); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitCheckUser", quotegroupSizeSoftLimitCheckUser); | ||||
|     builder->get_widget("quotegroupSizeHardLimitCheckUser", quotegroupSizeHardLimitCheckUser); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitCheckUser", quotegroupFilesSoftLimitCheckUser); | ||||
|     builder->get_widget("quotegroupFilesHardLimitCheckUser", quotegroupFilesHardLimitCheckUser); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitSpinUser", quotegroupSizeSoftLimitSpinUser); | ||||
|     builder->get_widget("quotegroupSizeHardLimitSpinUser", quotegroupSizeHardLimitSpinUser); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitSpinUser", quotegroupFilesSoftLimitSpinUser); | ||||
|     builder->get_widget("quotegroupFilesHardLimitSpinUser", quotegroupFilesHardLimitSpinUser); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitComboUser", quotegroupSizeSoftLimitComboUser); | ||||
|     builder->get_widget("quotegroupSizeHardLimitComboUser", quotegroupSizeHardLimitComboUser); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitlabelUser", quotegroupFilesSoftLimitlabelUser); | ||||
|     builder->get_widget("quotegroupFilesHarLimitLabelUser", quotegroupFilesHarLimitLabelUser); | ||||
|     builder->get_widget("quotegroupSizeSoftLimitLabelUser", quotegroupSizeSoftLimitLabelUser); | ||||
|     builder->get_widget("quotegroupFilesSoftLimitLabelUser", quotegroupFilesSoftLimitLabelUser); | ||||
|     builder->get_widget("quotegroupSizeCurrentlyLabelUser", quotegroupSizeCurrentlyLabelUser); | ||||
|     builder->get_widget("quotegroupFilesCurrentlyLabelUser", quotegroupFilesCurrentlyLabelUser); | ||||
|     builder->get_widget("quotegroupSizeFrameLabelUser", quotegroupSizeFrameLabelUser); | ||||
|     builder->get_widget("quotegroupFilesFrameLabelUser", quotegroupFilesFrameLabelUser); | ||||
|     builder->get_widget("lblSetDeviceUser", lblSetDeviceUser); | ||||
|     builder->get_widget("lblQuotasStatusUser", lblQuotasStatusUser); | ||||
|     builder->get_widget("lblSetUGPUser", lblSetUGPUser); | ||||
|     builder->get_widget("lblSetNameDeviceUser", lblSetNameDeviceUser); | ||||
|     builder->get_widget("lblSetQuotasStatusUser", lblSetQuotasStatusUser); | ||||
|     builder->get_widget("lblSetUGPUserValue", lblSetUGPUserValue); | ||||
|     builder->get_widget("lblHeadQuotasEditWindowUser", lblHeadQuotasEditWindowUser); | ||||
|     builder->get_widget("quoteSizeHardLimitLabel1", quoteSizeHardLimitLabel1); | ||||
|     builder->get_widget("quoteFilesHardLimitLabelUser", quoteFilesHardLimitLabelUser); | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::lacalization() { | ||||
|     this->fill_in_pow_memory(quotegroupSizeSoftLimitComboUser); | ||||
|     this->fill_in_pow_memory(quotegroupSizeHardLimitComboUser); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void View_edit_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| void View_edit_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box) { | ||||
|     spin->set_sensitive(check_button->get_active()); | ||||
|     combo_box->set_sensitive(check_button->get_active()); | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::fill_in_pow_memory(Gtk::ComboBoxText *cb_text) { | ||||
|     cb_text->append(str_prefix_KB); | ||||
|     cb_text->append(str_prefix_MB); | ||||
|     cb_text->append(str_prefix_GB); | ||||
|     cb_text->append(str_prefix_TB); | ||||
| } | ||||
| 
 | ||||
| void View_edit_user_group::set_label_type_quota(string name) { | ||||
|     lblSetUGPUser->set_text(name); | ||||
| } | ||||
| void View_edit_user_group::show() { | ||||
|     wndQuotasEditUser->show(); | ||||
| } | ||||
| @ -1,61 +0,0 @@ | ||||
| #ifndef VIEW_ADD_USER_GROUP_H | ||||
| #define VIEW_ADD_USER_GROUP_H | ||||
| #include "../project_lib.h" | ||||
| #include "../var.h" | ||||
| using namespace std; | ||||
| 
 | ||||
| class View_edit_user_group | ||||
| { | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
| private: | ||||
|     Gtk::Window* wndQuotasEditUser; | ||||
|     Gtk::Button* btnCancelEditUser; | ||||
|     Gtk::Button* btnSaveEditUser; | ||||
|     Gtk::CheckButton* quotegroupSizeSoftLimitCheckUser; | ||||
|     Gtk::CheckButton* quotegroupSizeHardLimitCheckUser; | ||||
|     Gtk::CheckButton* quotegroupFilesSoftLimitCheckUser; | ||||
|     Gtk::CheckButton* quotegroupFilesHardLimitCheckUser; | ||||
|     Gtk::SpinButton* quotegroupSizeSoftLimitSpinUser; | ||||
|     Gtk::SpinButton* quotegroupSizeHardLimitSpinUser; | ||||
|     Gtk::SpinButton* quotegroupFilesSoftLimitSpinUser; | ||||
|     Gtk::SpinButton* quotegroupFilesHardLimitSpinUser; | ||||
|     Gtk::ComboBoxText* quotegroupSizeSoftLimitComboUser; | ||||
|     Gtk::ComboBoxText* quotegroupSizeHardLimitComboUser; | ||||
|     Gtk::Label* quotegroupFilesSoftLimitlabelUser; | ||||
|     Gtk::Label* quotegroupFilesHarLimitLabelUser; | ||||
|     Gtk::Label* quotegroupSizeSoftLimitLabelUser; | ||||
|     Gtk::Label* quotegroupFilesSoftLimitLabelUser; | ||||
|     Gtk::Label* quotegroupSizeCurrentlyLabelUser; | ||||
|     Gtk::Label* quotegroupFilesCurrentlyLabelUser; | ||||
|     Gtk::Label* quotegroupSizeFrameLabelUser; | ||||
|     Gtk::Label* quotegroupFilesFrameLabelUser; | ||||
|     Gtk::Label* lblSetDeviceUser; | ||||
|     Gtk::Label* lblQuotasStatusUser; | ||||
|     Gtk::Label* lblSetUGPUser; | ||||
|     Gtk::Label* lblSetNameDeviceUser; | ||||
|     Gtk::Label* lblSetQuotasStatusUser; | ||||
|     Gtk::Label* lblSetUGPUserValue; | ||||
|     Gtk::Label* lblHeadQuotasEditWindowUser; | ||||
|     Gtk::Label* quoteSizeHardLimitLabel1; | ||||
|     Gtk::Label* quoteFilesHardLimitLabelUser; | ||||
| 
 | ||||
| 
 | ||||
| public: | ||||
|     View_edit_user_group(/* args */); | ||||
|     ~View_edit_user_group(); | ||||
|     void setting(); | ||||
|     void event(); | ||||
|     void show(); | ||||
|     void get_builder(); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box); | ||||
|     void check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box); | ||||
|     void fill_in_pow_memory(Gtk::ComboBoxText *cb_text); | ||||
|     void set_label_type_quota(string name); | ||||
|     void lacalization(); | ||||
| }; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #endif | ||||
| @ -1,123 +0,0 @@ | ||||
| #include "view_filters.h" | ||||
| 
 | ||||
| View_filters::View_filters(/* args */){ | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
|     this->settings(); | ||||
| } | ||||
| 
 | ||||
| View_filters::~View_filters() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void View_filters::settings() { | ||||
|     this->get_builder(); | ||||
|     this->lacalization(); | ||||
|     this->set_map_flag(chbFilterName); | ||||
|     this->set_map_flag(chbFilterQuotas); | ||||
|     this->set_map_flag(chbFilterSize); | ||||
|     this->set_map_flag(chbFilterSoftLimitSize); | ||||
|     this->set_map_flag(chbFilterHardLimitSize); | ||||
|     this->set_map_flag(chbFilterHardLimitSizeDelay); | ||||
|     this->set_map_flag(chbFilterFiles); | ||||
|     this->set_map_flag(chbFilterSoftLimitFile); | ||||
|     this->set_map_flag(chbFilterHardLimitFile); | ||||
|     this->set_map_flag(chbFilterHardLimitFileDelay); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_filters::get_builder() { | ||||
|     builder->get_widget("wndFilters", wndFilters); | ||||
|     builder->get_widget("chbFilterName", chbFilterName); | ||||
|     builder->get_widget("chbFilterQuotas", chbFilterQuotas); | ||||
|     builder->get_widget("chbFilterSize", chbFilterSize); | ||||
|     builder->get_widget("chbFilterSoftLimitSize", chbFilterSoftLimitSize); | ||||
|     builder->get_widget("chbFilterHardLimitSize", chbFilterHardLimitSize); | ||||
|     builder->get_widget("chbFilterHardLimitSizeDelay", chbFilterHardLimitSizeDelay); | ||||
|     builder->get_widget("chbFilterFiles", chbFilterFiles); | ||||
|     builder->get_widget("chbFilterSoftLimitFile", chbFilterSoftLimitFile); | ||||
|     builder->get_widget("chbFilterHardLimitFile", chbFilterHardLimitFile); | ||||
|     builder->get_widget("chbFilterHardLimitFileDelay", chbFilterHardLimitFileDelay); | ||||
|     builder->get_widget("lblFiltersHead", lblFiltersHead); | ||||
|     builder->get_widget("btnFiltersSave", btnFiltersSave); | ||||
|     builder->get_widget("btnFiltersCancel", btnFiltersCancel); | ||||
|     lblFiltersHead->set_label(str_filters); | ||||
| } | ||||
| 
 | ||||
| void View_filters::show() { | ||||
|     this->set_map_flag_false(); | ||||
|     wndFilters->show(); | ||||
| } | ||||
| 
 | ||||
| void View_filters::lacalization() { | ||||
|     /*
 | ||||
|     chbFilterName->set_label(str_name); | ||||
|     chbFilterQuotas->set_label(str_quotas); | ||||
|     chbFilterSize->set_label(str_size); | ||||
|     chbFilterSoftLimitSize->set_label(str_soft_limit_size); | ||||
|     chbFilterHardLimitSize->set_label(str_hard_limit_size); | ||||
|     chbFilterHardLimitSizeDelay->set_label(str_deferring_hard_limit_size); | ||||
|     chbFilterFiles->set_label(str_files); | ||||
|     chbFilterSoftLimitFile->set_label(str_soft_restriction_files); | ||||
|     chbFilterHardLimitFile->set_label(str_severe_limitation_files); | ||||
|     chbFilterHardLimitFileDelay->set_label(str_deferring_limit_files); | ||||
|     */ | ||||
| } | ||||
| 
 | ||||
| void View_filters::event() { | ||||
|     chbFilterName->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterName)); | ||||
|     chbFilterQuotas->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterQuotas)); | ||||
|     chbFilterSize->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterSize)); | ||||
|     chbFilterSoftLimitSize->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterSoftLimitSize)); | ||||
|     chbFilterHardLimitSize->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterHardLimitSize)); | ||||
|     chbFilterHardLimitSizeDelay->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterHardLimitSizeDelay)); | ||||
|     chbFilterFiles->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterFiles)); | ||||
|     chbFilterSoftLimitFile->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterSoftLimitFile)); | ||||
|     chbFilterHardLimitFile->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterHardLimitFile)); | ||||
|     chbFilterHardLimitFileDelay->signal_toggled().connect(  | ||||
|         sigc::bind<Gtk::CheckButton*> (sigc::mem_fun(*this,  | ||||
|         &View_filters::set_map_flag), chbFilterHardLimitFileDelay)); | ||||
|     btnFiltersSave->signal_clicked().connect(sigc::mem_fun(*this,  | ||||
|         &View_filters::btn_save)); | ||||
|     btnFiltersCancel->signal_clicked().connect(sigc::mem_fun(*this,  | ||||
|         &View_filters::btn_cancel)); | ||||
| } | ||||
| 
 | ||||
| void View_filters::set_map_flag(Gtk::CheckButton* check_button) { | ||||
|     map_filters_flag[check_button->get_label()] = check_button->get_active(); | ||||
| } | ||||
| 
 | ||||
| void View_filters::btn_save() { | ||||
|     wndFilters->hide(); | ||||
| } | ||||
| 
 | ||||
| void View_filters::btn_cancel() { | ||||
|     wndFilters->hide(); | ||||
| } | ||||
| 
 | ||||
| map<string, bool> View_filters::get_filters() { | ||||
|     return map_filters_flag; | ||||
| } | ||||
| 
 | ||||
| void View_filters::set_map_flag_false() { | ||||
|     for (auto& [key, value]: map_filters_flag) { | ||||
|         map_filters_flag[key] = false; | ||||
|     } | ||||
| } | ||||
| @ -1,46 +0,0 @@ | ||||
| #ifndef VIEW_FILTERS_H | ||||
| #define VIEW_FILTERS_H | ||||
| #include "../project_lib.h" | ||||
| #include "../var.h" | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| class View_filters | ||||
| { | ||||
| private: | ||||
|     map<string, bool> map_filters_flag; | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Window *wndFilters; | ||||
|     Gtk::CheckButton *chbFilterName; | ||||
|     Gtk::CheckButton *chbFilterQuotas; | ||||
|     Gtk::CheckButton *chbFilterSize; | ||||
|     Gtk::CheckButton *chbFilterSoftLimitSize; | ||||
|     Gtk::CheckButton *chbFilterHardLimitSize; | ||||
|     Gtk::CheckButton *chbFilterHardLimitSizeDelay; | ||||
|     Gtk::CheckButton *filtersHardSizeActivationFilterCheckbox; | ||||
|     Gtk::CheckButton *chbFilterFiles; | ||||
|     Gtk::CheckButton *chbFilterSoftLimitFile; | ||||
|     Gtk::CheckButton *chbFilterHardLimitFile; | ||||
|     Gtk::CheckButton *chbFilterHardLimitFileDelay; | ||||
|     Gtk::Label *lblFiltersHead; | ||||
|     Gtk::Button *btnFiltersSave; | ||||
|     Gtk::Button *btnFiltersCancel; | ||||
| public: | ||||
|     View_filters(/* args */); | ||||
|     ~View_filters(); | ||||
|     void lacalization(); | ||||
|     void event(); | ||||
|     void get_builder(); | ||||
|     void settings(); | ||||
|     void show(); | ||||
| private: | ||||
|     void set_map_flag(Gtk::CheckButton* check_button); | ||||
|     void btn_save(); | ||||
|     void btn_cancel(); | ||||
|     void set_map_flag_false(); | ||||
|     map<string, bool> get_filters(); | ||||
| }; | ||||
| #endif | ||||
| 
 | ||||
| 
 | ||||
| @ -1,121 +0,0 @@ | ||||
| #include "view_open_browser.h" | ||||
| 
 | ||||
| 
 | ||||
| View_open_browser* obj_open_browser; | ||||
| View_about* obj_about; | ||||
| 
 | ||||
| void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) { | ||||
|     if (self && user_data) {} | ||||
|     obj_open_browser->global_lick_doc = link; | ||||
|     obj_about->aboutWindows->hide(); | ||||
|     obj_open_browser->temp_help_show(); | ||||
| } | ||||
| 
 | ||||
| View_open_browser::View_open_browser(/* args */) { | ||||
|     builder = Gtk::Builder::create_from_file(path_glade); | ||||
| } | ||||
| 
 | ||||
| View_open_browser::~View_open_browser() { | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::settings() { | ||||
|     obj_open_browser = this; | ||||
|     this->get_builder(); | ||||
|     #ifdef WEBKIT_FOUND | ||||
|         my_web_kit =  WEBKIT_WEB_VIEW( webkit_web_view_new() ); | ||||
|         three = Glib::wrap(GTK_WIDGET(my_web_kit)); | ||||
|         wndWeb->add(*three); | ||||
|     #endif | ||||
|     this->lacalization(); | ||||
|     this->event(); | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::set_obj_about(View_about* obj_view_about) { | ||||
|     this->obj_view_about = obj_view_about; | ||||
|     obj_about = obj_view_about; | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::show() { | ||||
|     this->wndShowWeb->show(); | ||||
| } | ||||
| void View_open_browser::get_builder() { | ||||
|     #ifdef WEBKIT_FOUND | ||||
|             builder->get_widget("wndWeb", wndWeb); | ||||
|     #endif | ||||
|     builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb); | ||||
|     builder->get_widget("lblwebHeaderName", lblwebHeaderName); | ||||
|     builder->get_widget("lblhelpText", lblhelpText); | ||||
|     builder->get_widget("lblhelpHeader", lblhelpHeader); | ||||
|     builder->get_widget("chkAlwaysOpenHelp", chkAlwaysOpenHelp); | ||||
|     builder->get_widget("btnReadHelp", btnReadHelp); | ||||
|     builder->get_widget("btnCancelHelp", btnCancelHelp); | ||||
|     builder->get_widget("wndShowWeb", wndShowWeb); | ||||
|      | ||||
| } | ||||
| void View_open_browser::lacalization() { | ||||
|     lblwebHeaderName->set_label(name_app); | ||||
|     lblhelpText->set_text(redirected_documentation); | ||||
|     btnReadHelp->set_label(read_online); | ||||
|     btnCancelHelp->set_label(cancel); | ||||
|     chkAlwaysOpenHelp->set_label(always_redirect); | ||||
|     lblhelpHeader->set_text(read_documentation_web); | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::event() { | ||||
|     g_signal_connect(G_OBJECT(obj_view_about->aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), NULL); | ||||
|     btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();}); | ||||
|     chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;}); | ||||
|     btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &View_open_browser::open_browser)); | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::temp_help_show() { | ||||
|     if (flag_open_browser == true) { | ||||
|         this->open_browser(); | ||||
|     } | ||||
|     else { | ||||
|         wndShowWeb->show_all();  | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void View_open_browser::open_browser() { | ||||
|     #ifdef WEBKIT_FOUND | ||||
|         if (my_web_kit) { | ||||
|             gtk_widget_destroy(GTK_WIDGET(my_web_kit)); | ||||
|         } | ||||
|         my_web_kit =  WEBKIT_WEB_VIEW(webkit_web_view_new()); | ||||
|         three = Glib::wrap(GTK_WIDGET(my_web_kit)); | ||||
|         wndWeb->add(*three); | ||||
|         webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); | ||||
|         wndWeb->show_all(); | ||||
|         webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); | ||||
|         wndWeb->show_all(); | ||||
|         webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); | ||||
|         wndWeb->show_all(); | ||||
|     #else | ||||
|         this->template_open_browser(global_lick_doc); | ||||
|     #endif | ||||
|     this->wndShowWeb->hide(); | ||||
| } | ||||
| 
 | ||||
| int View_open_browser::template_open_browser(string str_link_doc) { | ||||
|     string cmd = cmd_xdg + string(_(str_link_doc.c_str())) + " &"; | ||||
|     string buf = ""; | ||||
|     if (geteuid() == 0) { | ||||
|         string response_user = getlogin(); | ||||
|         int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1; | ||||
|         auto size = static_cast<size_t>(size_s); | ||||
|         std::unique_ptr<char[]> buf(new char[ size ]); | ||||
|         std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str()); | ||||
|         cmd = string(buf.get(), buf.get() + size - 1); | ||||
|     } | ||||
|     return system(cmd.c_str()); | ||||
|       | ||||
| } | ||||
| void View_open_browser::open_help() { | ||||
|     global_lick_doc = const_link_doc; | ||||
|     temp_help_show(); | ||||
| } | ||||
| 
 | ||||
| View_about* View_open_browser::get_about() { | ||||
|     return obj_view_about; | ||||
| } | ||||
| @ -1,50 +0,0 @@ | ||||
| #ifndef VIEW_OPEN_BROWSER_H | ||||
| #define VIEW_OPEN_BROWSER_H | ||||
| 
 | ||||
| #include "../project_lib.h" | ||||
| #include "view_about.h" | ||||
| #ifdef WEBKIT_FOUND | ||||
| #include <webkit2/webkit2.h> | ||||
| #endif | ||||
| #include "../var.h" | ||||
| 
 | ||||
| class View_open_browser { | ||||
| private: | ||||
|     bool flag_open_browser = false; | ||||
|     View_about* obj_view_about; | ||||
| private: | ||||
|     Glib::RefPtr<Gtk::Builder> builder; | ||||
|     Gtk::Button *btnReadHelp; | ||||
|     Gtk::Button *btnCancelHelp; | ||||
|     Gtk::CheckButton *chkAlwaysOpenHelp; | ||||
|     Gtk::Label *lblwebHeaderName; | ||||
|     Gtk::Label *lblhelpText; | ||||
|     Gtk::Label *lblhelpHeader; | ||||
|     Gtk::Label *lblHeadeWndWeb; | ||||
| public: | ||||
|     string global_lick_doc; | ||||
|     Gtk::Window *wndShowWeb; | ||||
|     #ifdef WEBKIT_FOUND | ||||
|         Gtk::Window *wndWeb; | ||||
|         Gtk::Widget *three; | ||||
|         WebKitWebView *my_web_kit = NULL; | ||||
|     #endif | ||||
| public: | ||||
|     View_open_browser(/* args */); | ||||
|     ~View_open_browser(); | ||||
|     void lacalization(); | ||||
|     void event(); | ||||
|     void get_builder(); | ||||
|     void settings(); | ||||
|     void show(); | ||||
|     void open_help(); | ||||
|     void temp_help_show(); | ||||
|     void set_path_glade(string str_path_glade); | ||||
|     void set_obj_about(View_about* View_about); | ||||
|     View_about* get_about(); | ||||
| private: | ||||
|     int template_open_browser(string str_link_doc); | ||||
|     void open_browser(); | ||||
| }; | ||||
| void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data); | ||||
| #endif | ||||
| @ -0,0 +1,178 @@ | ||||
| #include "view_check_user_table.h" | ||||
| 
 | ||||
| char* glade_path = NULL; | ||||
| char* flag_u_g = NULL; | ||||
| char* table_u_g_set_add_edit; | ||||
| table_u_g* table_widgets; | ||||
| vector* _actors; | ||||
| 
 | ||||
| void table_u_g_get_actors(vector* actors) { | ||||
|     _actors = actors; | ||||
| } | ||||
| 
 | ||||
| table_u_g* get_widget_table_u_g() { | ||||
|     return table_widgets; | ||||
| } | ||||
| 
 | ||||
| void table_u_g_set_fill_user_group() { | ||||
|     int size = 0; | ||||
|     g_object_ref(table_widgets->liststoreUsersGroups); | ||||
|     gtk_list_store_clear(table_widgets->liststoreUsersGroups); | ||||
|     gboolean active1 = !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(table_widgets->chkActivUsersGroup)); | ||||
|     if (strcmp(flag_u_g, "grpquota")==0) { | ||||
|         gtk_button_set_label(GTK_BUTTON(table_widgets->chkActivUsersGroup), STR_CHK_LABEL_WRITE_ALL_GROUPS); | ||||
|         gtk_label_set_label(GTK_LABEL(table_widgets->lblHeadQuotaUsersGroups), STR_GROUPS); | ||||
|         char** array_groups = philos_list_group(&size,active1); | ||||
|         table_u_g_fill_tree_view(array_groups, size); | ||||
|         GtkTreeViewColumn* column = gtk_tree_view_get_column(GTK_TREE_VIEW(table_widgets->treeViewCheckUsersGroups), 1); | ||||
|         gtk_tree_view_column_set_title(column, STR_GROUPS); | ||||
|     } | ||||
|     else if (strcmp(flag_u_g, "usrquota") == 0) { | ||||
|         gtk_button_set_label(GTK_BUTTON(table_widgets->chkActivUsersGroup), STR_CHK_LABEL_WRITE_ALL_USERS); | ||||
|         gtk_label_set_label(GTK_LABEL(table_widgets->lblHeadQuotaUsersGroups), STR_USERS); | ||||
|         char** array_user = philos_list_user(&size, active1); | ||||
|         table_u_g_fill_tree_view(array_user, size); | ||||
|     } | ||||
|     set_actors(_actors); | ||||
| } | ||||
| 
 | ||||
| table_u_g *setup_table_u_g(){ | ||||
|     /* Widgets getting | Получение виджетов */ | ||||
|     table_widgets = malloc(sizeof(table_u_g)); | ||||
|     device_disk_parsed(); | ||||
|     GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); | ||||
|     table_widgets->Window = yon_gtk_builder_get_widget(builder,"tableUserGroupWindow"); | ||||
|     table_widgets->chkActivUsersGroup = yon_gtk_builder_get_widget(builder,"chkActivUsersGroup"); | ||||
|     table_widgets->btnCancel = yon_gtk_builder_get_widget(builder,"quotegroupCancelButton1"); | ||||
|     table_widgets->btnSave = yon_gtk_builder_get_widget(builder,"quotegroupSaveButton1"); | ||||
|     table_widgets->lblHeadQuotaUsersGroups = yon_gtk_builder_get_widget(builder,"lblHeadQuotaUsersGroups"); | ||||
|     table_widgets->treeViewCheckUsersGroups = yon_gtk_builder_get_widget(builder,"treeViewCheckUsersGroups"); | ||||
|     table_widgets->checkColUserGroup = GTK_CELL_RENDERER_TOGGLE(gtk_builder_get_object(builder,"checkColUserGroup")); | ||||
|     table_widgets->liststoreUsersGroups = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststoreUsersGroups")); | ||||
|     table_u_g_set_fill_user_group(); | ||||
|     table_u_g_event(); | ||||
|     g_signal_connect(G_OBJECT(table_widgets->chkActivUsersGroup), "toggled", G_CALLBACK(table_u_g_set_fill_user_group), NULL); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void table_u_g_set_glade_path(char* _glade_path) { | ||||
|     glade_path = _glade_path; | ||||
| } | ||||
| 
 | ||||
| void table_u_g_set_flag(char* _flag_u_g, char* _table_u_g_set_add_edit) { | ||||
|     flag_u_g = _flag_u_g; | ||||
|     table_u_g_set_add_edit = _table_u_g_set_add_edit; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void table_u_g_fill_tree_view(char** array, int size) { | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups); | ||||
|     g_object_ref(table_widgets->liststoreUsersGroups); | ||||
|     gtk_list_store_clear(table_widgets->liststoreUsersGroups); | ||||
|     for (int i=0; i<size; i++){ | ||||
|         GtkTreeIter iter; | ||||
|         gtk_list_store_append(table_widgets->liststoreUsersGroups,&iter); | ||||
|         gtk_list_store_set(table_widgets->liststoreUsersGroups,&iter, | ||||
|                                                             0,0, | ||||
|                                                             1,array[i], | ||||
|                                                             -1); | ||||
|     }  | ||||
|     gtk_tree_view_set_model(GTK_TREE_VIEW(table_widgets->treeViewCheckUsersGroups), model); | ||||
| } | ||||
| 
 | ||||
| void table_u_g_show(GtkWidget *self, char* glade_path) { | ||||
|     if (table_widgets != NULL) { | ||||
|         gtk_widget_show(table_widgets->Window); | ||||
|     } | ||||
|     else { | ||||
|         setup_table_u_g(glade_path); | ||||
|         gtk_widget_show(table_widgets->Window); | ||||
|     } | ||||
| } | ||||
| void chk_toggled_user_group ( | ||||
|   GtkCellRendererToggle* self, | ||||
|   gchar* path, | ||||
|   gpointer user_data | ||||
| ) { | ||||
|     GtkTreeIter iter; | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups); | ||||
|     gtk_tree_model_get_iter_from_string(model,&iter,path); | ||||
|     gboolean flag; | ||||
|     gtk_tree_model_get(model,&iter,0, &flag,-1); | ||||
|     gtk_list_store_set(table_widgets->liststoreUsersGroups,&iter, 0,!flag,-1); | ||||
|     gtk_tree_view_set_model(GTK_TREE_VIEW(table_widgets->treeViewCheckUsersGroups), model); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| vector* get_actors_table(vector* actors) { | ||||
|     model_free_vector_string(actors); | ||||
|     vectorFree(actors); | ||||
|     actors = malloc(sizeof(vector)); | ||||
|     vector_init(actors); | ||||
|     GtkTreeIter iter; | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups); | ||||
|     int valid = 1; | ||||
|     for(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter);valid==1;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter)){ | ||||
|         int is_active=0; | ||||
|         char* user_group; | ||||
|         gtk_tree_model_get(model,&iter,0,&is_active,-1); | ||||
|         gtk_tree_model_get(model,&iter,1,&user_group,-1); | ||||
|         if (is_active){ | ||||
|             actors->pfVectorAdd(actors, yon_char_new(user_group)); | ||||
|         } | ||||
|     } | ||||
|     return actors; | ||||
| } | ||||
| 
 | ||||
| void table_u_g_destroy(GtkWidget *self) { | ||||
|     table_widgets = NULL; | ||||
| } | ||||
| 
 | ||||
| void table_u_g_localization(table_u_g *widgets) { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void table_u_g_on_hide_subwindow(GtkWidget *self) { | ||||
|     gtk_widget_destroy(gtk_widget_get_toplevel(self)); | ||||
|     table_widgets = NULL; | ||||
| } | ||||
| 
 | ||||
| table_u_g *table_u_g_get_widget_filters() { | ||||
|     return table_widgets; | ||||
| } | ||||
| 
 | ||||
| void set_actors(vector* actors) { | ||||
|     GtkTreeIter iter; | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups); | ||||
|     int valid = 1; | ||||
|     for(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter);valid==1;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter)){ | ||||
|         char* user_group; | ||||
|         gtk_tree_model_get(model,&iter,1,&user_group,-1); | ||||
|         if (actors->vectorList.total> 0) { | ||||
|             for (int i = 0; i < actors->vectorList.total; i++) { | ||||
|                 char* str_actors = (char*)actors->pfVectorGet(actors, i); | ||||
|                 if (strcmp(str_actors, user_group)==0){ | ||||
|                     gtk_list_store_set(table_widgets->liststoreUsersGroups,&iter, 0,1,-1); | ||||
|                 }     | ||||
|             }       | ||||
|         } | ||||
|     } | ||||
|     gtk_tree_view_set_model(GTK_TREE_VIEW(table_widgets->treeViewCheckUsersGroups), model); | ||||
| } | ||||
| 
 | ||||
| void table_btn_block_save() { | ||||
|     GtkTreeIter iter; | ||||
|     GtkTreeModel *model = GTK_TREE_MODEL(table_widgets->liststoreUsersGroups); | ||||
|     int valid = 1; | ||||
|     int flag_activ = 0; | ||||
|     for(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter);valid==1;valid=gtk_tree_model_iter_next(GTK_TREE_MODEL(table_widgets->liststoreUsersGroups),&iter)){ | ||||
|         int is_active=0; | ||||
|         gtk_tree_model_get(model,&iter,0,&is_active,-1); | ||||
|         char* user_group; | ||||
|         if (is_active){ | ||||
|             flag_activ = 1; | ||||
|         } | ||||
|     } | ||||
|     gtk_widget_set_sensitive(table_widgets->btnSave,flag_activ); | ||||
| } | ||||
| @ -0,0 +1,47 @@ | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #include "model/ubl-utils.h" | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
| #include <libintl.h> | ||||
| #include <getopt.h> | ||||
| #include <libintl.h> | ||||
| #include "../compile/ubl-cmake.h" | ||||
| #include "model/model.h" | ||||
| #include "model/load.h" | ||||
| #include "ubl-strings.h" | ||||
| #include "model/my_device.h" | ||||
| 
 | ||||
| typedef struct { | ||||
|     GtkWidget* btnCancel; | ||||
|     GtkWidget* Window; | ||||
|     GtkWidget* btnSave; | ||||
|     GtkWidget* treeViewCheckUsersGroups; | ||||
|     GtkListStore* liststoreUsersGroups; | ||||
|     GtkCellRendererToggle* checkColUserGroup; | ||||
|     GtkWidget* chkActivUsersGroup; | ||||
|     GtkWidget* lblHeadQuotaUsersGroups; | ||||
| } table_u_g; | ||||
| 
 | ||||
| void table_u_g_table_u_g_event(table_u_g *widgets); | ||||
| void table_u_g_on_hide_subwindow(GtkWidget *self); | ||||
| table_u_g *table_u_g_get_widget_filters(); | ||||
| void table_u_g_destroy(GtkWidget *self); | ||||
| void table_u_g_event(); | ||||
| void table_u_g_fill_tree_view(char** array, int size); | ||||
| void table_u_g_set_flag(char* _flag_u_g, char* _table_u_g_set_add_edit); | ||||
| void table_u_g_set_glade_path(char* _glade_path); | ||||
| void table_u_g_show(GtkWidget *self, char* glade_path); | ||||
| void set_vector(vector* _vec_temp); | ||||
| vector* get_actors_table(vector* actors); | ||||
| void table_u_g_get_actors(vector* actors); | ||||
| void set_actors(vector* actors); | ||||
| table_u_g* get_widget_table_u_g(); | ||||
| void chk_toggled_user_group( | ||||
|   GtkCellRendererToggle* self, | ||||
|   gchar* path, | ||||
|   gpointer user_data | ||||
| ); | ||||
| void table_btn_block_save(); | ||||
| @ -0,0 +1,201 @@ | ||||
| #include "view_filters.h" | ||||
| char* flag_filters_u_g_p = NULL; | ||||
| filters_window *filters_widgets = NULL; | ||||
| GtkTreeView* _tree_view = NULL; | ||||
| const int len_user_group = 8; | ||||
| const int len_project = 10; | ||||
| gboolean flag_filters_user[8]; | ||||
| gboolean flag_filters_group[8]; | ||||
| gboolean flag_filters_project[10]; | ||||
| filters_window *filters_setup_window(char* glade_path){ | ||||
|     if (filters_widgets == NULL) { | ||||
|         filters_widgets = malloc(sizeof(filters_window)); | ||||
|         GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); | ||||
|         filters_widgets->Window = yon_gtk_builder_get_widget(builder,"wndFilters"); | ||||
|         filters_widgets->chbFilterName = yon_gtk_builder_get_widget(builder,"chbFilterName"); | ||||
|         filters_widgets->chbFilterSoftLimitFile = yon_gtk_builder_get_widget(builder,"chbFilterSoftLimitFile"); | ||||
|         filters_widgets->chbFilterFiles = yon_gtk_builder_get_widget(builder,"chbFilterFiles"); | ||||
|         filters_widgets->chbFilterHardLimitSizeDelay = yon_gtk_builder_get_widget(builder,"chbFilterHardLimitSizeDelay"); | ||||
|         filters_widgets->chbFilterHardLimitSize = yon_gtk_builder_get_widget(builder,"chbFilterHardLimitSize"); | ||||
|         filters_widgets->chbFilterSoftLimitSize = yon_gtk_builder_get_widget(builder,"chbFilterSoftLimitSize"); | ||||
|         filters_widgets->chbFilterQuotas = yon_gtk_builder_get_widget(builder,"chbFilterQuotas"); | ||||
|         filters_widgets->chbFilterSize = yon_gtk_builder_get_widget(builder,"chbFilterSize"); | ||||
|         filters_widgets->btnFiltersCancel = yon_gtk_builder_get_widget(builder,"btnFiltersCancel"); | ||||
|         filters_widgets->btnFiltersSave = yon_gtk_builder_get_widget(builder,"btnFiltersSave"); | ||||
|         filters_widgets->chbFilterHardLimitFile = yon_gtk_builder_get_widget(builder,"chbFilterHardLimitFile"); | ||||
|         filters_widgets->chbFilterHardLimitFileDelay = yon_gtk_builder_get_widget(builder,"chbFilterHardLimitFileDelay"); | ||||
|         filters_widgets->chbProjectName = yon_gtk_builder_get_widget(builder,"chbProjectName"); | ||||
|         filters_widgets->chbFilterDevice = yon_gtk_builder_get_widget(builder,"chbFilterDevice"); | ||||
|         filters_widgets->chkFilterID = yon_gtk_builder_get_widget(builder,"chkFilterID"); | ||||
|         filters_widgets->chbFilterCatalog = yon_gtk_builder_get_widget(builder,"chbFilterCatalog"); | ||||
|         if (strcmp(flag_filters_u_g_p, "prjquota")==0) { | ||||
|             gtk_widget_hide(filters_widgets->chbFilterName); | ||||
|         } | ||||
|         else { | ||||
|             gtk_widget_hide(filters_widgets->chbProjectName); | ||||
|             gtk_widget_hide(filters_widgets->chkFilterID); | ||||
|             gtk_widget_hide(filters_widgets->chbFilterCatalog); | ||||
|         } | ||||
|         filters_event(filters_widgets); | ||||
|     } | ||||
|     filters_set_flag(); | ||||
|     return filters_widgets; | ||||
| } | ||||
| 
 | ||||
| gboolean* filters_get_flag_user() { | ||||
|     flag_filters_user[0] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterName)); | ||||
|     flag_filters_user[1] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterDevice)); | ||||
|     flag_filters_user[2] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitSize)); | ||||
|     flag_filters_user[3] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSize)); | ||||
|     flag_filters_user[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitFile)); | ||||
|     flag_filters_user[5] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFile)); | ||||
|     flag_filters_user[6] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSizeDelay)); | ||||
|     flag_filters_user[7] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFileDelay)); | ||||
|     return flag_filters_user; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| gboolean* filters_get_flag_group() { | ||||
|     flag_filters_group[0] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterName)); | ||||
|     flag_filters_group[1] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterDevice)); | ||||
|     flag_filters_group[2] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitSize)); | ||||
|     flag_filters_group[3] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSize)); | ||||
|     flag_filters_group[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitFile)); | ||||
|     flag_filters_group[5] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFile)); | ||||
|     flag_filters_group[6] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSizeDelay)); | ||||
|     flag_filters_group[7] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFileDelay)); | ||||
|     return flag_filters_group; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| gboolean* filters_get_flag_project() { | ||||
|     flag_filters_project[0] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterDevice)); | ||||
|     flag_filters_project[1] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterCatalog)); | ||||
|     flag_filters_project[2] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chkFilterID)); | ||||
|     flag_filters_project[3] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbProjectName)); | ||||
|     flag_filters_project[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitSize)); | ||||
|     flag_filters_project[5] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSize)); | ||||
|     flag_filters_project[6] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitFile)); | ||||
|     flag_filters_project[7] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFile)); | ||||
|     flag_filters_project[8] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSizeDelay)); | ||||
|     flag_filters_project[9] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFileDelay)); | ||||
|     return flag_filters_project; | ||||
| } | ||||
| 
 | ||||
| void filters_set_name(char* _flag_filters_u_g_p) { | ||||
|     flag_filters_u_g_p = _flag_filters_u_g_p; | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void filters_get_tree_view(GtkWidget *tree_view) { | ||||
|     _tree_view = GTK_TREE_VIEW(tree_view); | ||||
| } | ||||
| 
 | ||||
| void filters_tree_view_update() { | ||||
|     int n_end = len_user_group; | ||||
|     gboolean* array_flags = NULL; | ||||
|     if (strcmp(flag_filters_u_g_p, "prjquota")==0) { | ||||
|         n_end = len_project; | ||||
|         array_flags = filters_get_flag_project(); | ||||
|     } | ||||
|     else { | ||||
|         n_end = len_user_group; | ||||
|         if (strcmp(flag_filters_u_g_p, "usrquota")==0) { | ||||
|             array_flags = filters_get_flag_user();   | ||||
|         } | ||||
|         else { | ||||
|             array_flags = filters_get_flag_group(); | ||||
|         } | ||||
|     } | ||||
|     for (int i = 0; i < n_end; i++) { | ||||
|         GtkTreeViewColumn* column = gtk_tree_view_get_column(_tree_view, i); | ||||
|         gtk_tree_view_column_set_visible(column, array_flags[i]); | ||||
|     } | ||||
| } | ||||
| void filters_save(GtkWidget *self) { | ||||
|     filters_tree_view_update(); | ||||
|     filters_on_hide_subwindow(self); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void filters_event(filters_window *widgets) { | ||||
|     g_signal_connect(G_OBJECT(widgets->btnFiltersSave), "clicked",G_CALLBACK(filters_save),widgets->Window); | ||||
|     g_signal_connect(G_OBJECT(widgets->btnFiltersCancel), "clicked",G_CALLBACK(filters_on_hide_subwindow),widgets->Window); | ||||
|     g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(filters_destroy), NULL); | ||||
| } | ||||
| 
 | ||||
| void filters_destroy(GtkWidget *self) { | ||||
|     filters_widgets = NULL; | ||||
| } | ||||
| 
 | ||||
| void filters_localization(filters_window *widgets) { | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| void filters_on_hide_subwindow(GtkWidget *self) { | ||||
|     gtk_widget_destroy(gtk_widget_get_toplevel(self)); | ||||
|     filters_widgets = NULL; | ||||
| } | ||||
| 
 | ||||
| filters_window *get_widget_filters() { | ||||
|     return filters_widgets; | ||||
| } | ||||
| 
 | ||||
| void filters_show(GtkWidget *self, char* glade_path) { | ||||
|     if (filters_widgets != NULL) { | ||||
|         gtk_widget_show(filters_widgets->Window); | ||||
|     } | ||||
|     else { | ||||
|         filters_setup_window(glade_path); | ||||
|         gtk_widget_show(filters_widgets->Window); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void filters_init_flag() { | ||||
|     for (int i=0; i<len_user_group;i++) { | ||||
|         flag_filters_user[i] = 1; | ||||
|         flag_filters_group[i] = 1; | ||||
|         flag_filters_project[i] = 1; | ||||
|     } | ||||
|     flag_filters_project[8] = 1; | ||||
|     flag_filters_project[9] = 1; | ||||
| } | ||||
| 
 | ||||
| void filters_set_flag() { | ||||
|     gboolean* array_flags = NULL; | ||||
|     if (strcmp(flag_filters_u_g_p, "prjquota")==0) { | ||||
|         array_flags = flag_filters_project; | ||||
|     } | ||||
|     else { | ||||
|         if (strcmp(flag_filters_u_g_p, "usrquota")==0) { | ||||
|             array_flags = flag_filters_user;   | ||||
|         } | ||||
|         else { | ||||
|             array_flags = flag_filters_group; | ||||
|         } | ||||
|     } | ||||
|     if (strcmp(flag_filters_u_g_p,"prjquota")) { | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterName),array_flags[0] ); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterDevice), array_flags[1]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitSize), array_flags[2]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSize), array_flags[3]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitFile), array_flags[4]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFile), array_flags[5]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSizeDelay), array_flags[6]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFileDelay), array_flags[7]); | ||||
|     } | ||||
|     else if (strcmp(flag_filters_u_g_p,"prjquota")==0) { | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterDevice),array_flags[0] ); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterCatalog), array_flags[1]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chkFilterID), array_flags[2]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbProjectName), array_flags[3]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitSize), array_flags[4]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSize), array_flags[5]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterSoftLimitFile), array_flags[6]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFile), array_flags[7]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitSizeDelay), array_flags[8]); | ||||
|         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterHardLimitFileDelay), array_flags[9]); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,52 @@ | ||||
| #ifndef VIEW_FILTERS_H | ||||
| #define VIEW_FILTERS_H | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #include "model/ubl-utils.h" | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
| #include <libintl.h> | ||||
| #include <getopt.h> | ||||
| #include <libintl.h> | ||||
| #include "../compile/ubl-cmake.h" | ||||
| #include "model/model.h" | ||||
| #include "model/load.h" | ||||
| 
 | ||||
| // Переменные
 | ||||
| typedef struct { | ||||
|     GtkWidget* Window; | ||||
|     GtkWidget* btnFiltersSave; | ||||
|     GtkWidget* btnFiltersCancel; | ||||
|     GtkWidget* chbFilterName; | ||||
|     GtkWidget* chbFilterQuotas; | ||||
|     GtkWidget* chbFilterSize; | ||||
|     GtkWidget* chbFilterSoftLimitSize; | ||||
|     GtkWidget* chbFilterHardLimitSize; | ||||
|     GtkWidget* chbFilterHardLimitSizeDelay; | ||||
|     GtkWidget* chbFilterFiles; | ||||
|     GtkWidget* chbFilterSoftLimitFile; | ||||
|     GtkWidget* chbFilterHardLimitFile; | ||||
|     GtkWidget* chbFilterHardLimitFileDelay; | ||||
|     GtkWidget* chbProjectName; | ||||
|     GtkWidget* chbFilterDevice; | ||||
|     GtkWidget* chkFilterID; | ||||
|     GtkWidget* chbFilterCatalog; | ||||
|     char* name; | ||||
| } filters_window; | ||||
| 
 | ||||
| // Функции
 | ||||
| filters_window *filters_setup_window(char* glade_path); | ||||
| void filters_event(filters_window *widgets); | ||||
| void filters_localization(filters_window *widgets); | ||||
| void filters_on_hide_subwindow(GtkWidget *self); | ||||
| filters_window *get_widget_filters(); | ||||
| void filters_show(GtkWidget *self, char* glade_path); | ||||
| void filters_destroy(GtkWidget *self); | ||||
| void filters_init_flag(); | ||||
| void filters_set_name(char* _flag_u_g_p); | ||||
| void filters_show(GtkWidget *self, char* glade_path); | ||||
| void filters_set_flag(); | ||||
| void filters_get_tree_view(GtkWidget *tree_view); | ||||
| #endif | ||||
| @ -0,0 +1,250 @@ | ||||
| #include "view_set_disk.h" | ||||
| 
 | ||||
| view_device_set_window *obj_view_device_widgets = NULL; | ||||
| char* view_device_glade_path = NULL; | ||||
| int view_device_index = 0; | ||||
| char* view_device_set_add_edit = NULL; | ||||
| vector* vec_device = NULL; | ||||
| config_all* view_device_all_config_temp = NULL; | ||||
| 
 | ||||
| void set_view_device_menu(char* _set_add_edit) { | ||||
|     view_device_set_add_edit = _set_add_edit; | ||||
| } | ||||
| void view_device_set_vector_device(vector* _vec_device) { | ||||
|     vec_device = _vec_device; | ||||
| } | ||||
| view_device_set_window* get_widget_view_device() { | ||||
|     return obj_view_device_widgets; | ||||
| } | ||||
| 
 | ||||
| void view_device_all_config(config_all* _all_config) { | ||||
|     view_device_all_config_temp = _all_config; | ||||
| } | ||||
| 
 | ||||
| void view_device_set_index(int _index) { | ||||
|     view_device_index = _index; | ||||
| } | ||||
| 
 | ||||
| view_device_set_window *view_device_setup_window_base(char* __glade_path) { | ||||
|     view_device_glade_path = __glade_path; | ||||
|     if (obj_view_device_widgets == NULL) { | ||||
|         obj_view_device_widgets = malloc(sizeof(view_device_set_window)); | ||||
|         GtkBuilder *builder = gtk_builder_new_from_resource(__glade_path); | ||||
|         obj_view_device_widgets->Window = yon_gtk_builder_get_widget(builder,"SetDeviceWindow"); | ||||
|         obj_view_device_widgets->btnSaveTempSave = yon_gtk_builder_get_widget(builder,"SetDeviceSaveButton"); | ||||
|         obj_view_device_widgets->btnTempCancel = yon_gtk_builder_get_widget(builder,"SetDeviceCancelButton"); | ||||
|         view_device_setup_window_custom(obj_view_device_widgets, builder); | ||||
|         view_device_event(obj_view_device_widgets); | ||||
|     } | ||||
|     return obj_view_device_widgets; | ||||
| } | ||||
| view_device_set_window *view_device_setup_window_custom(view_device_set_window* view_device_view_device_widgets, GtkBuilder *builder) { | ||||
|     obj_view_device_widgets->spinWeeksFile = yon_gtk_builder_get_widget(builder,"spinWeeksFile"); | ||||
|     obj_view_device_widgets->spinDaysFile = yon_gtk_builder_get_widget(builder,"spinDaysFile"); | ||||
|     obj_view_device_widgets->spinHoursFile = yon_gtk_builder_get_widget(builder,"spinHoursFile"); | ||||
|     obj_view_device_widgets->spinMinutesFile = yon_gtk_builder_get_widget(builder,"spinMinutesFile"); | ||||
| 
 | ||||
|     obj_view_device_widgets->spinWeeksSize = yon_gtk_builder_get_widget(builder,"spinWeeksSize"); | ||||
|     obj_view_device_widgets->spinDaysSize = yon_gtk_builder_get_widget(builder,"spinDaysSize"); | ||||
|     obj_view_device_widgets->spinHoursSize = yon_gtk_builder_get_widget(builder,"spinHoursSize"); | ||||
|     obj_view_device_widgets->spinMinutesSize = yon_gtk_builder_get_widget(builder,"spinMinutesSize"); | ||||
|     obj_view_device_widgets->lblNameDevice = yon_gtk_builder_get_widget(builder,"lblNameDevice"); | ||||
|     obj_view_device_widgets->cmbDeviceSetStatus = yon_gtk_builder_get_widget(builder,"cmbDeviceSetStatus"); | ||||
|     obj_view_device_widgets->DeviceCombo = yon_gtk_builder_get_widget(builder,"DeviceCombo"); | ||||
|     obj_view_device_widgets->lblHeadQuotasEditDeviceWindow = yon_gtk_builder_get_widget(builder,"lblHeadQuotasEditDeviceWindow"); | ||||
|     obj_view_device_widgets->boxBlockGuiAddEditDevice = yon_gtk_builder_get_widget(builder,"boxBlockGuiAddEditDevice"); | ||||
|     if (strcmp(view_device_set_add_edit, "add") == 0) { | ||||
|         gtk_label_set_label(GTK_LABEL(obj_view_device_widgets->lblHeadQuotasEditDeviceWindow), STR_TITLE_ADD_QUOTAS); | ||||
|         gtk_widget_hide(obj_view_device_widgets->lblNameDevice); | ||||
|         device_fill_disk(obj_view_device_widgets->DeviceCombo,vec_device); | ||||
|         gtk_combo_box_set_active(GTK_COMBO_BOX(obj_view_device_widgets->cmbDeviceSetStatus),-1); | ||||
|     } | ||||
|     else { | ||||
|         gtk_label_set_label(GTK_LABEL(obj_view_device_widgets->lblHeadQuotasEditDeviceWindow), STR_TITLE_EDIT_QUOTAS); | ||||
|         gtk_widget_hide(obj_view_device_widgets->DeviceCombo); | ||||
|     } | ||||
|     view_device_fill_gui(); | ||||
|     view_device_set_combo_box_device(); | ||||
| } | ||||
| 
 | ||||
| void view_device_show(GtkWidget *self, char* __glade_path) { | ||||
|     if (obj_view_device_widgets != NULL) { | ||||
|         gtk_widget_show(obj_view_device_widgets->Window); | ||||
|     } | ||||
|     else { | ||||
|         view_device_setup_window_base(__glade_path); | ||||
|         gtk_widget_show(obj_view_device_widgets->Window); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void view_device_save() { | ||||
|     view_device_get_gui_data(); | ||||
|     view_device_on_destroy_subwindow(obj_view_device_widgets->Window); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| void view_device_event(view_device_set_window* view_device_view_device_widgets) { | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->DeviceCombo), "changed", G_CALLBACK(view_device_set_combo_box_device), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->Window), "destroy", G_CALLBACK(view_device_destroy), obj_view_device_widgets->Window); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->btnTempCancel),"clicked",G_CALLBACK(view_device_on_destroy_subwindow), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinWeeksSize), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinDaysSize), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinHoursSize), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinMinutesSize), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinWeeksFile), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinDaysFile), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinHoursFile), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
|     g_signal_connect(G_OBJECT(obj_view_device_widgets->spinMinutesFile), "value-changed", G_CALLBACK(view_device_update_gui_spin_time), NULL); | ||||
| } | ||||
| 
 | ||||
| void view_device_set_combo_box_device() { | ||||
|     if (strcmp(view_device_set_add_edit, "add")==0) { | ||||
|         int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(obj_view_device_widgets->DeviceCombo)); | ||||
|         if (disk_id == -1) { | ||||
|             gtk_widget_set_sensitive(obj_view_device_widgets->boxBlockGuiAddEditDevice, 0); | ||||
|             gtk_widget_set_sensitive(obj_view_device_widgets->btnSaveTempSave, 0); | ||||
|         } | ||||
|         else { | ||||
|             gtk_widget_set_sensitive(obj_view_device_widgets->boxBlockGuiAddEditDevice, 1); | ||||
|             gtk_widget_set_sensitive(obj_view_device_widgets->btnSaveTempSave, 1); | ||||
|             int status_id = gtk_combo_box_get_active(GTK_COMBO_BOX(obj_view_device_widgets->cmbDeviceSetStatus)); | ||||
|             if (status_id == -1) { | ||||
|                 gtk_combo_box_set_active(GTK_COMBO_BOX(obj_view_device_widgets->cmbDeviceSetStatus), 0); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void view_device_on_destroy_subwindow(GtkWidget *self) { | ||||
|     if (self) { | ||||
|         gtk_widget_destroy(gtk_widget_get_toplevel(self)); | ||||
|         obj_view_device_widgets = NULL; | ||||
|          | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void view_device_destroy(GtkWidget *self) { | ||||
|     if (self) { | ||||
|         obj_view_device_widgets = NULL; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void view_device_update_gui_spin_time() { | ||||
|      | ||||
| } | ||||
| 
 | ||||
| void view_device_fill_gui() { | ||||
|     size_t second_file = 0; | ||||
|     size_t second_size = 0; | ||||
|     if (strcmp(view_device_set_add_edit, "edit") == 0) { | ||||
|         if (view_device_index != -1) { | ||||
|             disk_status* _config = (disk_status*)vec_device->pfVectorGet(vec_device, view_device_index); | ||||
|             second_size = _config->deferring_size; | ||||
|             second_file = _config->deferring_file; | ||||
|             gtk_combo_box_set_active(GTK_COMBO_BOX(obj_view_device_widgets->cmbDeviceSetStatus), _config->status); | ||||
|             gtk_label_set_label(GTK_LABEL(obj_view_device_widgets->lblNameDevice), _config->device); | ||||
|         } | ||||
|     } | ||||
|     view_device_set_time_spin(second_file, second_size); | ||||
| } | ||||
| void view_device_get_spin_time(size_t* second_file, size_t* second_size) { | ||||
|     int spin_week_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksSize)); | ||||
|     int spin_days_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysSize)); | ||||
|     int spin_hours_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursSize)); | ||||
|     int spin_minutes_size = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesSize)); | ||||
|     *second_size = spin_week_size*7*24*3600+spin_days_size*24*3600+spin_hours_size*3600+spin_minutes_size*60; | ||||
|     int spin_week_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksFile)); | ||||
|     int spin_days_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysFile)); | ||||
|     int spin_hours_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursFile)); | ||||
|     int spin_minutes_file = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesFile));  | ||||
|     *second_file = spin_week_file*7*24*3600+spin_days_file*24*3600+spin_hours_file*3600+spin_minutes_file*60; | ||||
|     view_device_set_time_spin(*second_file, *second_size); | ||||
| } | ||||
| 
 | ||||
| void view_device_get_gui_data() { | ||||
|     char* disk = NULL; | ||||
|     disk_status* _config = NULL; | ||||
|     int status_id = gtk_combo_box_get_active(GTK_COMBO_BOX(obj_view_device_widgets->cmbDeviceSetStatus)); | ||||
|     if (status_id != -1) { | ||||
|         size_t second_file = 0; | ||||
|         size_t second_size = 0; | ||||
|         view_device_get_spin_time(&second_file, &second_size); | ||||
|         if (view_device_index != -1) { | ||||
|             _config = (disk_status*)vec_device->pfVectorGet(vec_device, view_device_index); | ||||
|              | ||||
|         } | ||||
|         else { | ||||
|             _config = malloc(sizeof(disk_status)); | ||||
|             disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(obj_view_device_widgets->DeviceCombo)); | ||||
|             if (get_device_vec()->vectorList.total > 0) { | ||||
|                 for (int index = 0; index < get_device_vec()->vectorList.total; index++) | ||||
|                 {    | ||||
|                     device_config* obj_device_config = (device_config*)get_device_vec()->pfVectorGet(get_device_vec(), index); | ||||
|                     if (strstr(disk, obj_device_config->name_disk)) { | ||||
|                         _config->device = yon_char_new(obj_device_config->name_disk); | ||||
|                         _config->fs = yon_char_new(obj_device_config->file_system); | ||||
|                         _config->mount_point = yon_char_new(obj_device_config->mounted); | ||||
|                         _config->name = yon_char_new(obj_device_config->type_dick); | ||||
|                     } | ||||
|                      | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         _config->deferring_size = second_size; | ||||
|         _config->deferring_file = second_file; | ||||
|         if (strcmp(view_device_set_add_edit, "add") == 0) { | ||||
|             if (status_id == 0) { | ||||
|                 _config->status = 1; | ||||
|             } | ||||
|             else { | ||||
|                 _config->status = status_id; | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             if (status_id == 0) { | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, "deferring_size"); | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, "deferring_file"); | ||||
|                 yon_window_config_erase_custom_parameter(_config->device, _config->device); | ||||
|                 model_search_disk_remove(&view_device_all_config_temp->v_user, &view_device_all_config_temp->v_remove, _config->device); | ||||
|                 model_search_disk_remove(&view_device_all_config_temp->v_group, &view_device_all_config_temp->v_remove, _config->device); | ||||
|                 model_search_disk_remove_project(&view_device_all_config_temp->v_project,&view_device_all_config_temp->v_disk_status, &view_device_all_config_temp->v_remove, _config->device); | ||||
|                 _config->status = 1; | ||||
|             } | ||||
|             else { | ||||
|                 _config->status = status_id; | ||||
|             } | ||||
|         } | ||||
|         if (view_device_index == -1) { | ||||
|             vec_device->pfVectorAdd(vec_device, _config); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| void view_device_set_time_spin(size_t seconds_file, size_t seconds_size) { | ||||
|     me_time t_file = time_convert(seconds_file); | ||||
|     me_time t_size = time_convert(seconds_size); | ||||
|     if (seconds_file!=-1) { | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksFile), t_file.weeks); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysFile), t_file.days); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursFile), t_file.hours); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesFile), t_file.minutes); | ||||
|     } | ||||
|     else { | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksFile), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysFile), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursFile), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesFile), 0); | ||||
|     } | ||||
|     if (seconds_size!=-1) { | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksSize), t_size.weeks); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysSize), t_size.days); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursSize), t_size.hours); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesSize), t_size.minutes); | ||||
|     } | ||||
|     else { | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinWeeksSize), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinDaysSize), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinHoursSize), 0); | ||||
|         gtk_spin_button_set_value(GTK_SPIN_BUTTON(obj_view_device_widgets->spinMinutesSize), 0); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,58 @@ | ||||
| 
 | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #include "model/ubl-utils.h" | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
| #include <libintl.h> | ||||
| #include <getopt.h> | ||||
| #include <libintl.h> | ||||
| #include "../compile/ubl-cmake.h" | ||||
| #include "model/model.h" | ||||
| #include "model/load.h" | ||||
| #include "model/my_device.h" | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| typedef struct { | ||||
|     GtkWidget* Window; | ||||
|     GtkWidget* btnSaveTempSave; | ||||
|     GtkWidget* btnTempCancel; | ||||
| 
 | ||||
|     GtkWidget* spinWeeksFile; | ||||
|     GtkWidget* spinDaysFile; | ||||
|     GtkWidget* spinHoursFile; | ||||
|     GtkWidget* spinMinutesFile; | ||||
| 
 | ||||
|     GtkWidget* spinWeeksSize; | ||||
|     GtkWidget* spinDaysSize; | ||||
|     GtkWidget* spinHoursSize; | ||||
|     GtkWidget* spinMinutesSize; | ||||
|     GtkWidget* lblNameDevice; | ||||
|     GtkWidget* DeviceCombo; | ||||
|     GtkWidget* cmbDeviceSetStatus; | ||||
|     GtkWidget* lblHeadQuotasEditDeviceWindow; | ||||
|     GtkWidget* boxBlockGuiAddEditDevice; | ||||
|     char* name; | ||||
| } view_device_set_window; | ||||
| 
 | ||||
| view_device_set_window* get_widget_view_device(); | ||||
| void view_device_get_gui_data(); | ||||
| void view_device_all_config(config_all* _all_config); | ||||
| void view_device_get_vector_u_g_p(vector* _vec_u_g_p); | ||||
| void view_device_set_time_spin(size_t seconds_file, size_t seconds_size); | ||||
| void view_device_update_gui_spin_time(); | ||||
| void view_device_fill_gui(); | ||||
| void view_device_set_index(int _index); | ||||
| void set_view_device_menu(char* _set_add_edit); | ||||
| void view_device_set_combo_box_device(); | ||||
| void view_device_set_vector_device(vector* _vec_device); | ||||
| void set_view_device_menu(char* _set_add_edit); | ||||
| void view_device_show(GtkWidget *self, char* __glade_path); | ||||
| void view_device_event(view_device_set_window* view_device_view_device_widgets); | ||||
| void view_device_on_destroy_subwindow(GtkWidget *self); | ||||
| void view_device_destroy(GtkWidget *self); | ||||
| view_device_set_window *view_device_setup_window_base(char* __glade_path); | ||||
| view_device_set_window *view_device_setup_window_custom(view_device_set_window* view_device_view_device_widgets, GtkBuilder *builder); | ||||
| @ -0,0 +1,51 @@ | ||||
| #include <gtk/gtk.h> | ||||
| #include <gtk/gtkx.h> | ||||
| #include "model/ubl-utils.h" | ||||
| #include <locale.h> | ||||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| #include <stdlib.h> | ||||
| #include <libintl.h> | ||||
| #include <getopt.h> | ||||
| #include <libintl.h> | ||||
| #include "../compile/ubl-cmake.h" | ||||
| #include "model/model.h" | ||||
| #include "model/load.h" | ||||
| #include "view_check_user_table.h" | ||||
| 
 | ||||
| void temp_set_index(int _index); | ||||
| temp_set_window* get_widget_temp(); | ||||
| void set_disk(char* _disk); | ||||
| temp_set_window *temp_setup_window_base(char* _glade_path); | ||||
| void temp_on_destroy_subwindow(GtkWidget *self); | ||||
| void temp_destroy(GtkWidget *self); | ||||
| void temp_show(GtkWidget *self, char* _glade_path); | ||||
| void temp_init_windows(); | ||||
| void temp_event(temp_set_window* temp_widgets); | ||||
| void temp_localization(temp_set_window* temp_widgets); | ||||
| void btn_ok_file_manager(GtkWidget *self); | ||||
| void set_temp_menu(char* _flag_u_g_p, char* _set_add_edit); | ||||
| void destroy_file_manager(GtkWidget *self); | ||||
| void show_file_manger(temp_set_window* temp_widgets, GtkBuilder *builder); | ||||
| temp_set_window *temp_setup_window_custom(temp_set_window* temp_widgets, GtkBuilder *builder); | ||||
| void wrapper_show_file_manager(); | ||||
| void event_toggled_all(); | ||||
| void set_all_config(config_all* _all_config); | ||||
| void set_widget_config(GtkWidget* check, GtkWidget* spin, GtkWidget* combo, size_t* value, int* mem_size); | ||||
| void set_edit_gui_data_base(config_all* all_config, int index); | ||||
| config_u_g_p* get_temp_gui_data_base(config_u_g_p* _config); | ||||
| void get_add_gui_data_base(config_all* all_config); | ||||
| void get_edit_gui_data_base(config_all* all_config, int index); | ||||
| void set_widget(GtkWidget* check, GtkWidget* spin, GtkWidget* combo, int value_spin, int pow_mem_size); | ||||
| int generate_id(vector* _vec_temp, int max_id); | ||||
| void wrapper_generate_id(); | ||||
| int check_generate(vector* _vec_temp, int max_id); | ||||
| void check_generate_id(); | ||||
| void set_activ_project_id(); | ||||
| int wrapper_check_save(); | ||||
| void block_btn_save(); | ||||
| int table_check_save(); | ||||
| void temp_settings(); | ||||
| void show_warning_no_fill(char* text_mess); | ||||
| void update_max_size_spin(GtkWidget *self, int* flag); | ||||
| void temp_on_set_combo_box_device(); | ||||
| Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB | 
| @ -1,154 +1,108 @@ | ||||
| .textHead{ | ||||
|   text-shadow: 2px 2px @theme_bg_color; | ||||
|   color: @theme_text_color; | ||||
| } | ||||
| .boxInfoMessError{ | ||||
|   background-color: #ea9999; | ||||
| } | ||||
| .boxInfoMessOK{ | ||||
|   background-color: #f3f0ac; | ||||
| } | ||||
| .bannerbackground { | ||||
|   background-color: #404040; | ||||
| } | ||||
| .view_app { | ||||
|   background-color: @theme_bg_color; | ||||
| } | ||||
| .view_app.view.cell:selected { | ||||
|   background-color:@theme_selected_bg_color; | ||||
| 	color:@theme_selected_text_color; | ||||
| 	transition: 10ms ease-out; | ||||
|   border-radius: 3px; | ||||
| } | ||||
| #GnomeIcon{ | ||||
|   border-style:solid; | ||||
|   border-bottom-width: 1px; | ||||
|   border-image: linear-gradient(90deg, alpha(@theme_text_color,0.4) 55%, alpha(@theme_bg_color, 0) 100%); | ||||
|   border-image-slice: 1; | ||||
| } | ||||
| 
 | ||||
| #SepIcon{ | ||||
|   background-color: alpha(@theme_text_color, 0.6); | ||||
| } | ||||
| 
 | ||||
| #iconlabel { | ||||
|   font-size:14px; | ||||
|   font-weight: bold; | ||||
|    | ||||
| } | ||||
| .roundborder * { | ||||
|   border-width:0px; | ||||
|   border-radius:5px; | ||||
| .thin { | ||||
| 	margin:0px; | ||||
| 	padding:0px; | ||||
| } | ||||
| .noborder { | ||||
|   border: none; | ||||
| 	border:none; | ||||
| } | ||||
| .menu:hover {	 | ||||
|     border-color:alpha(@theme_text_color, 0.01); | ||||
| .nobackground { | ||||
| background:transparent; | ||||
| } | ||||
| .menu {	 | ||||
|     border-color:alpha(@theme_text_color, 0.01); | ||||
| .nobackground:active { | ||||
| background:transparent; | ||||
| } | ||||
| .menu:hover >* { | ||||
|   border-color:alpha(@theme_text_color, 0.01); | ||||
| } | ||||
| .menuitembottom{ | ||||
|   margin-top:0px; | ||||
|   margin-bottom:3px; | ||||
| } | ||||
| .menuitemmiddle{ | ||||
|   margin-top:0px; | ||||
|   margin-bottom:0px; | ||||
| .textHead{ | ||||
|     text-shadow: 2px 2px @theme_bg_color; | ||||
| 	color: @theme_text_color; | ||||
| } | ||||
| 
 | ||||
| .menuitemtop{ | ||||
|   margin-bottom:0px; | ||||
| } | ||||
| .menuitemtop *{ | ||||
|   margin:2px 2px 0 2px; | ||||
|   padding: 5px 10px 3px 5px; | ||||
| } | ||||
| .menuitemmiddle *{ | ||||
|   margin:0 2px 0 2px; | ||||
|   padding: 3px 10px 3px 5px; | ||||
| .inherited>* { | ||||
| 	border:none; | ||||
| 	background:inherit; | ||||
| } | ||||
| .menuitembottom *{ | ||||
|   margin:0 2px 2px 2px; | ||||
|   padding: 3px 10px 5px 5px; | ||||
| .workingbg { | ||||
| 	background:@theme_base_color; | ||||
| } | ||||
| .menuitemtop:hover { | ||||
|   background:@theme_bg_color; | ||||
|   border-color:inherit; | ||||
|   border-left-width:inherit; | ||||
|   border-right-width:inherit; | ||||
| } | ||||
| .menuitemmiddle:hover { | ||||
|   background:@theme_bg_color; | ||||
|   border-color:inherit; | ||||
|   border-left-width:inherit; | ||||
|   border-right-width:inherit; | ||||
| } | ||||
| .menuitembottom:hover { | ||||
|   background:@theme_bg_color; | ||||
|   border-color:inherit; | ||||
|   border-left-width:inherit; | ||||
|   border-right-width:inherit; | ||||
| .menuitembottom{ | ||||
| 	margin-top:0px; | ||||
| 	margin-bottom:3px; | ||||
| 	border-color:inherit; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
|   } | ||||
|   .menuitemmiddle{ | ||||
| 	margin-top:0px; | ||||
| 	margin-bottom:0px; | ||||
| 	border-color:inherit; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
|   } | ||||
|    | ||||
| } | ||||
| .menuitemtop:hover* { | ||||
|   margin:2px 2px 0 2px; | ||||
|   padding: 5px 10px 3px 5px; | ||||
|   background:@theme_selected_bg_color; | ||||
|   border-radius:2px; | ||||
| } | ||||
| .menuitemmiddle:hover* { | ||||
|   margin:0 2px 0 2px; | ||||
|   padding: 3px 10px 3px 5px; | ||||
|   background:@theme_selected_bg_color; | ||||
|   border-radius:2px; | ||||
| } | ||||
| .menuitembottom:hover* { | ||||
|   margin:0 2px 2px 2px; | ||||
|   padding: 3px 10px 5px 5px; | ||||
|   background:@theme_selected_bg_color; | ||||
|   border-radius:2px; | ||||
| } | ||||
| 
 | ||||
| .workingbg, #workingbg { | ||||
|   background-color:@theme_base_color; | ||||
| } | ||||
| .workingbg.view.cell:selected { | ||||
|   background-color:@theme_selected_bg_color; | ||||
| } | ||||
| .workingbg.view.cell:hover { | ||||
|   background-color:darker(@theme_selected_bg_color); | ||||
|   color:@theme_selected_text_color; | ||||
|   border-radius:3px; | ||||
| } | ||||
| .bkim { | ||||
|   transition: 200ms ease-out; | ||||
|       background-image: none; | ||||
| } | ||||
| .noborder{ | ||||
| border:none; | ||||
| } | ||||
| 
 | ||||
| .bkim{ | ||||
| opacity:0.99; | ||||
| border:none; | ||||
|   .menuitemtop{ | ||||
| 	margin-bottom:0px; | ||||
| 	border-color:inherit; | ||||
| 	border-top-width:inherit; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
|   } | ||||
|   .menuitemtop>*{ | ||||
| 	margin:2px 2px 0 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
| 	border:transparent; | ||||
|   } | ||||
|   .menuitemmiddle>*{ | ||||
| 	margin:0 2px 0 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
| 	border:transparent; | ||||
|   } | ||||
|   .menuitembottom>*{ | ||||
| 	margin:0 2px 2px 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
|   } | ||||
|   .menuitemtop:hover { | ||||
| 	background:@theme_bg_color; | ||||
| 	border-color:inherit; | ||||
| 	border-top-width:inherit; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
|   } | ||||
|   .menuitemmiddle:hover { | ||||
| 	background:@theme_bg_color; | ||||
| 	border-color:inherit; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
|   } | ||||
|   .menuitembottom:hover { | ||||
| 	background:@theme_bg_color; | ||||
| 	border-color:inherit; | ||||
| 	border-bottom-width:0px; | ||||
| 	border-left-width:inherit; | ||||
| 	border-right-width:inherit; | ||||
| 	 | ||||
|   } | ||||
|   .menuitemtop:hover>* { | ||||
| 	margin:2px 2px 0 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
| 	background:@theme_selected_bg_color; | ||||
| 	border-radius:2px; | ||||
|   } | ||||
|   .menuitemmiddle:hover>* { | ||||
| 	margin:0 2px 0px 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
| 	background:@theme_selected_bg_color; | ||||
| 	border-radius:2px; | ||||
|   } | ||||
|   .menuitembottom:hover>* { | ||||
| 	margin:0 2px 2px 2px; | ||||
| 	padding: 3px 10px 3px 5px; | ||||
| 	background:@theme_selected_bg_color; | ||||
| 	border-radius:2px; | ||||
|   } | ||||
|   .boxInfoMessError{ | ||||
|     background-color: #ea9999; | ||||
| } | ||||
| 
 | ||||
| .bkim_no_plug{ | ||||
| background-color: transparent; | ||||
| opacity:0.99; | ||||
| } | ||||
| .thin{ | ||||
|   margin:0px; | ||||
|   padding: 0px; | ||||
| } | ||||
| .nobg{ | ||||
|   background: none; | ||||
| } | ||||
| .addbg * { | ||||
|   background-color: @theme_bg_color; | ||||
| .boxInfoMessOK{ | ||||
|     background-color: #f3f0ac; | ||||
| } | ||||
| @ -1,15 +1,15 @@ | ||||
| [Desktop Entry] | ||||
| Encoding=UTF-8 | ||||
| Name=Setting user quotas | ||||
| Name[ru]=Настройка квот пользователей | ||||
| GenericName=Setting user quotas | ||||
| GenericName[ru]=Настройка квот пользователей | ||||
| Comment=Configuring disk quota settings for system groups and users | ||||
| Comment[ru]=Настройка параметров дисковых квот для системных групп и пользователей системы | ||||
| Name=ubl-settings-diskquota | ||||
| Name[ru]=Дисковые квоты | ||||
| GenericName=ubl-settings-diskquota | ||||
| GenericName[ru]=Дисковые квоты | ||||
| Comment=Configuring disk quota settings for groups and users of the system | ||||
| Comment[ru]=Настройка параметров дисковых квот для групп и пользователей системы | ||||
| Type=Application | ||||
| Exec=pkexec ubl-settings-diskquota | ||||
| Icon=com.ublinux.ubl-settings-diskquota | ||||
| Terminal=false | ||||
| X-XfcePluggable=true | ||||
| X-UBLPluggable=true | ||||
| Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; | ||||
| Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-Personal-Settings; | ||||
|  | ||||
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								
											
												
													File diff suppressed because it is too large
													Load Diff
												
											
										
									
								
					Loading…
					
					
				
		Reference in new issue
	
	