diff --git a/Makefile b/Makefile index 838b50f..d440bec 100644 --- a/Makefile +++ b/Makefile @@ -105,7 +105,7 @@ uninstall: install: check uninstall @echo "Install ..." #################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################ -# @g++ source/ubl-cmake.h compile/resources.cc compile/ubl-cmake.h source/ubl-settings-diskquota.cc source/ubl-settings-diskquota.h source/ubl-strings.h source/view/model/ubl-utils.cc source/view/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 + @gcc source/ubl-cmake.h compile/resources.c compile/ubl-cmake.h 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 #################################################### УДАЛИТЬ ПЕРЕД КОММИТОМ ################################################################################ @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ diff --git a/com.ublinux.ubl-settings-diskquota.svg b/com.ublinux.ubl-settings-diskquota.svg index f636c26..708bd05 100644 --- a/com.ublinux.ubl-settings-diskquota.svg +++ b/com.ublinux.ubl-settings-diskquota.svg @@ -4,8 +4,8 @@ height="180" version="1.0" id="svg8" - sodipodi:docname="ublinux-ubconfig.svg" - inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + sodipodi:docname="ubl-settings-quotas.svg" + inkscape:version="1.1.2 (0a00cf5339, 2022-02-04, custom)" inkscape:export-filename="/media/Data/ShareMX/temp/archtoub_icons/ublinux-logo.png" inkscape:export-xdpi="136.53334" inkscape:export-ydpi="136.53334" @@ -16,6 +16,24 @@ xmlns:svg="http://www.w3.org/2000/svg"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + xlink:href="#linearGradient2580-3" /> + id="linearGradient2580-3" + x1="-183.25999" + x2="-133.33" + y1="-122.79" + y2="-134.57001" + gradientTransform="matrix(0.25137,0,0,0.25137,-7.3652,-24.336)" + gradientUnits="userSpaceOnUse"> + id="stop93" /> + id="stop95" /> + + + + + stdDeviation="0.43959997" + id="feGaussianBlur1137" /> + + xlink:href="#linearGradient2580-3" /> + + + + id="linearGradient6296" + x1="-183.25999" + x2="-133.33" + y1="-122.79" + y2="-134.57001" + gradientTransform="matrix(0.080474,0,0,0.080474,9.3119,27.811)" + gradientUnits="userSpaceOnUse" + xlink:href="#linearGradient2586" /> + + id="stop43" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id="stop11-9" /> + + + + + color-interpolation-filters="sRGB" + height="1.12" + width="1.12" + y="-0.060000001" + x="-0.060000001" + id="m-5"> + + + + + + + + + + + + + + id="feGaussianBlur903" + stdDeviation="0.14999813" /> + y2="36" + y1="20" + x2="23.5" + x1="23.5" + id="k-2" + gradientTransform="translate(-3.4889408e-4,-3.4889408e-4)" /> + id="b"> + id="stop2-7" /> + id="stop4-9" /> + xlink:href="#b" + gradientUnits="userSpaceOnUse" + y2="36" + y1="30" + x2="32" + x1="32" + id="j-9" + gradientTransform="translate(-3.4889408e-4,-3.4889408e-4)" /> + + stop-color="#0ef1c9" /> + stop-color="#0e95f1" /> + xlink:href="#a" /> + + id="stop7-2" /> + + + + + + + + id="stop734" /> + + + + + + id="stop725" /> + id="stop727" /> + + + id="filter4227" + x="-0.135" + y="-0.135" + width="1.27" + height="1.27"> + id="feFlood4217" /> + id="feComposite4219" /> + id="feGaussianBlur4221" /> + id="feOffset4223" /> + id="feComposite4225" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4927,31 +5741,163 @@ id="circle1671" /> - - + id="g912" + transform="matrix(2.0912263,0,0,2.0912263,23.080754,23.080758)" + style="filter:url(#filter4565)"> + + + + + + + + + + + + + + + + + + cx="32" + cy="32" + fill="url(#k)" + r="3" + id="circle71" + style="fill:url(#k)" /> + + + + + + + + + + + + + diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e8b8f28..7089e00 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -8,10 +8,10 @@ include_directories(${GTK_INCLUDE_DIRS}) link_directories(${GTK_LIBRARY_DIRS}) add_definitions(${GTK_CFLAGS_OTHER}) -pkg_check_modules(VTE291 REQUIRED vte-2.91) -include_directories(${VTE291_INCLUDE_DIRS}) -link_directories(${VTE291_LIBRARY_DIRS}) -add_definitions(${VTE291_CFLAGS_OTHER}) +#pkg_check_modules(VTE291 REQUIRED vte-2.91) +#include_directories(${VTE291_INCLUDE_DIRS}) +#link_directories(${VTE291_LIBRARY_DIRS}) +#add_definitions(${VTE291_CFLAGS_OTHER}) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) @@ -66,18 +66,15 @@ add_custom_target( set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \ - -fstack-clash-protection -fcf-protection -g") + -fstack-clash-protection -fcf-protection") set(SOURCE_FILES - view/model/ubl-utils.h - view/model/ubl-utils.cc - ubl-settings-diskquota.cc + ubl-settings-diskquota.c ubl-settings-diskquota.h ubl-strings.h - - - + model/ubl-utils.h + model/ubl-utils.c ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h ) diff --git a/source/controler.c b/source/controler.c new file mode 100644 index 0000000..30662ff --- /dev/null +++ b/source/controler.c @@ -0,0 +1,118 @@ +#include "controler.h" + +struct model_cfg_u_g_p* cfg_user = NULL; +struct model_cfg_u_g_p* cfg_group = NULL; +struct model_cfg_u_g_p* cfg_project = NULL; +struct model_cfg_general* cfg_general = NULL; +struct struct_gui* cfg_gui = NULL; + + +void load_system_cfg() { + cfg_gui->flag_load = 0; + template_load_cfg(CMD_LOAD_SYSTEM); + yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS, BACKGROUND_IMAGE_SUCCESS_TYPE); +} + +void load_global_cfg() { + cfg_gui->flag_load = 1; + template_load_cfg(CMD_LOAD_GLOBAL); + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE); +} + + + +int main(int argc, char *argv[]){ + local=setlocale(LC_ALL, ""); + textdomain (LocaleName); + config_init(); + 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;iHeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); + + yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); + if (getuid()!=0) + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + else + yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); + yon_window_config_setup(GTK_WINDOW(widgets->Window)); + yon_window_config_load(config_path); + 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); + gtk_main(); +} \ No newline at end of file diff --git a/source/controler.h b/source/controler.h new file mode 100644 index 0000000..3e50ac1 --- /dev/null +++ b/source/controler.h @@ -0,0 +1,7 @@ +#include "ubl-settings-diskquota.h" +#include "model.h" +#include "load.h" +#include "ubl-strings.h" + + +int main(int argc, char *argv[]); \ No newline at end of file diff --git a/source/model/load.c b/source/model/load.c new file mode 100644 index 0000000..efb064f --- /dev/null +++ b/source/model/load.c @@ -0,0 +1,25 @@ +#include "load.h" + + +void template_load_cfg(model_cfg_general* config, char* cmd) { + clear_array(); + int size = 0; + char** cfg = yon_config_load(cmd, &size); + philos_array_string_remove_char(&cfg, "\n", size); + 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); + if (yon_char_find_count(str_key, "CGROUP_QUOTA") != 0) { + if (str_key_value[0] == '\"') { + yon_char_divide(str_key_value, 0); + size_t length = strlen(str_key_value); + str_key_value = yon_char_divide(str_key_value, length-1); + } + str_split_value(str_key_value, config->size); + str_split_key(str_key, config->size); + config->size++; + } + } + + config->flag_set_data = 0; +} \ No newline at end of file diff --git a/source/model/load.h b/source/model/load.h new file mode 100644 index 0000000..7e157bd --- /dev/null +++ b/source/model/load.h @@ -0,0 +1,2 @@ +#include "ubl-utils.h" +#include "ubl-strings.h" \ No newline at end of file diff --git a/source/model/model.c b/source/model/model.c new file mode 100644 index 0000000..0caee63 --- /dev/null +++ b/source/model/model.c @@ -0,0 +1,156 @@ +#include "model.h" + + +void model_clear_cfg(model_cfg_u_g_p* config) { + philos_free_int_array(config->id, config->size); + philos_free_string_array(config->name, config->size); + philos_free_string_array(config->quota, config->size); + philos_free_string_array(config->quota, config->size); + philos_free_string_array(config->size_memory, config->size); + philos_free_int_array(config->soft_restriction_size, config->size); + philos_free_int_array(config->soft_restriction_file, config->size); + philos_free_int_array(config->severe_limitation_size, config->size); + philos_free_int_array(config->severe_limitation_file, config->size); + philos_free_int_array(config->deferring_size, config->size); + philos_free_int_array(config->deferring_file, config->size); + philos_free_int_array(config->size_memory_pow, config->size); + philos_free_int_array(config->soft_restriction_size_pow, config->size); + philos_free_int_array(config->soft_restriction_file_pow, config->size); + philos_free_int_array(config->severe_limitation_size_pow, config->size); + philos_free_int_array(config->severe_limitation_file_pow, config->size); + philos_free_int_array(config->deferring_size_pow, config->size); + philos_free_int_array(config->deferring_file_pow, config->size); + philos_free_string_array(config->device, config->size); + + config->size = 0; +} + +void model_null_cfg(model_cfg_u_g_p* config) { + if (config->size == 0) { + config->id = NULL; + config->name = NULL; + config->quota = NULL; + config->size_memory = NULL; + config->files = NULL; + config->soft_restriction_size = NULL; + config->soft_restriction_file = NULL; + config->severe_limitation_size = NULL; + config->severe_limitation_file = NULL; + config->deferring_size = NULL; + config->deferring_file = NULL; + config->size_memory_pow = NULL; + config->soft_restriction_size_pow = NULL; + config->soft_restriction_file_pow = NULL; + config->severe_limitation_size_pow = NULL; + config->severe_limitation_file_pow = NULL; + config->deferring_size_pow = NULL; + config->deferring_file_pow = NULL; + config->device = NULL; + } +} + +void model_clear_general(model_cfg_general* config) { + philos_free_int_array(config->flag_status, config->size); + + config->size = 0; +} + +void model_null_general(model_cfg_general* config) { + if (config->size == 0) { + config->flag_status = NULL; + } +} + +void model_tree_view_add(model_cfg_general* config) { + model_null_str_writing(config, config->size); +} + +void model_null_str_writing(model_cfg_general* config, int index) { + philos_set_size_memory_integer_char("-", config->name, index); + philos_set_size_memory_integer_char("-", config->quota, index); + philos_set_size_memory_integer_char("-", config->size_memory, index); + philos_set_size_memory_integer_char("-", config->files, index); + philos_set_size_memory_integer_char("-", config->device, index); + philos_set_pow_size_memory("-", config->soft_restriction_size, index, array_size_pow); + philos_set_pow_size_memory("-", config->soft_restriction_file, index, array_size_pow); + philos_set_pow_size_memory("-", config->severe_limitation_size, index, array_size_pow); + philos_set_pow_size_memory("-", config->severe_limitation_file, index, array_size_pow); + philos_set_pow_size_memory("-", config->deferring_size, index, array_size_pow); + philos_set_pow_size_memory("-", config->deferring_file, index, array_size_pow); + philos_set_pow_size_memory("-", config->size_memory_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->soft_restriction_size_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->soft_restriction_file_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->severe_limitation_size_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->severe_limitation_file_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->deferring_size_pow, index, array_size_pow); + philos_set_pow_size_memory("-", config->deferring_file_pow, index, array_size_pow); + +} + + +void model_array_size_memory() { + 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); +} + +void fill_tree_view_u_g_p(struct_gui* config_gui, model_cfg_general* config, int start, int flag_gui_add) { + GtkTreeModel *model = GTK_TREE_MODEL(config_gui->list); + if (flag_gui_add == 0) { + g_object_ref(config_gui->list); + gtk_list_store_clear(config_gui->list); + } + for (int index = start; index < config->size; index++) { + GtkTreeIter iter; + gtk_list_store_append(config_gui->list,&iter); + if (strcmp(config->type_arr, "project") != 0) { + gtk_list_store_set(config_gui->list,&iter, + 0,config->name[index], + 1,config->quota[index], + 2,config->files[index], + 3,philos_format_cfg_str_size_memory("", config->soft_restriction_size[index],config->soft_restriction_size_pow[index]), + 4,philos_format_cfg_str_size_memory("", config->soft_restriction_file[index],config->soft_restriction_file_pow[index]), + 5,philos_format_cfg_str_size_memory("", config->severe_limitation_size[index],config->severe_limitation_size_pow[index]), + 6,philos_format_cfg_str_size_memory("", config->severe_limitation_file[index], config->severe_limitation_file_pow[index]), + 7,philos_format_cfg_str_size_memory("", config->deferring_size[index], config->deferring_size_pow[index]), + 8,philos_format_cfg_str_size_memory("", config->deferring_file[index], config->deferring_file_pow[index]), + -1); + } + else { + gtk_list_store_set(config_gui->list,&iter, + 0,config->id[index] + 1,config->name[index], + 2,config->quota[index], + 3,config->files[index], + 4,philos_format_cfg_str_size_memory("", config->soft_restriction_size[index],config->soft_restriction_size_pow[index]), + 5,philos_format_cfg_str_size_memory("", config->soft_restriction_file[index],config->soft_restriction_file_pow[index]), + 6,philos_format_cfg_str_size_memory("", config->severe_limitation_size[index],config->severe_limitation_size_pow[index]), + 7,philos_format_cfg_str_size_memory("", config->severe_limitation_file[index], config->severe_limitation_file_pow[index]), + 8,philos_format_cfg_str_size_memory("", config->deferring_size[index], config->deferring_size_pow[index]), + 9,philos_format_cfg_str_size_memory("", config->deferring_file[index], config->deferring_file_pow[index]), + -1); + } + } + if (flag_gui_add != 0) { + gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model); + } +} +void fill_tree_view_u_g_p(struct_gui* config_gui, model_cfg_general* config, int start,int flag_gui_add) { + GtkTreeModel *model = GTK_TREE_MODEL(config_gui->list); + if (flag_gui_add == 0) { + g_object_ref(config_gui->list); + gtk_list_store_clear(config_gui->list); + } + for (int index = start; index < config->size; index++) { + GtkTreeIter iter; + gtk_list_store_append(config_gui->list,&iter); + if (strcmp(config->type_arr, "project") != 0) { + gtk_list_store_set(config_gui->list,&iter, -1); + } + } + if (flag_gui_add != 0) { + gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model); + } +} \ No newline at end of file diff --git a/source/model/model.h b/source/model/model.h new file mode 100644 index 0000000..8db5284 --- /dev/null +++ b/source/model/model.h @@ -0,0 +1,43 @@ +#include "ubl-utils.h" +#include "ubl-strings.h" +#include "model.h" + +static char** array_size_pow = NULL; + +struct model_cfg_u_g_p { + char* type_arr; + int* id; + char** name; + char** quota; + char** size_memory; + char** files; + + int* soft_restriction_size; + int* soft_restriction_file; + int* severe_limitation_size; + int* severe_limitation_file; + int* deferring_size; + int* deferring_file; + + int* size_memory_pow; + int* soft_restriction_size_pow; + int* soft_restriction_file_pow; + int* severe_limitation_size_pow; + int* severe_limitation_file_pow; + int* deferring_size_pow; + int* deferring_file_pow; + char** device; + size_t size; + int flag_set_data; + int flag_save; + int flag_load; +}; + + +struct model_cfg_general{ + int *flag_status; +} + +struct struct_gui { + int flag_load; +} \ No newline at end of file diff --git a/source/model/my_device.c b/source/model/my_device.c new file mode 100644 index 0000000..614a3ff --- /dev/null +++ b/source/model/my_device.c @@ -0,0 +1,50 @@ +#include "my_device.h" + +device_config obj_device_config; + +device_config* get_device_cfg() { + return &obj_device_config; +} + +void device_disk_parsed() { + char* cmd = "lsblk --fs --raw --output PATH,FSTYPE --exclude 7,11,253"; + int size = 0; + char** responce = yon_config_load(cmd, &size); + obj_device_config.size_disk = 0; + 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) { + char* name_disk = yon_char_divide_search(disk, " ", -1); + obj_device_config.name_disk = yon_char_parsed_append(obj_device_config.name_disk, &obj_device_config.size_disk, name_disk); + obj_device_config.size_disk--; + obj_device_config.file_system = yon_char_parsed_append(obj_device_config.file_system, &obj_device_config.size_disk, disk); + obj_device_config.size_disk--; + obj_device_config.mounted = yon_char_parsed_append(obj_device_config.mounted, &obj_device_config.size_disk, ""); + obj_device_config.size_disk--; + obj_device_config.type_dick = yon_char_parsed_append(obj_device_config.type_dick, &obj_device_config.size_disk, ""); + obj_device_config.size_disk--; + disk = yon_char_replace(disk," ", ""); + if (strlen(disk)!=0) { + char* description_disk = yon_char_unite(name_disk, + split_simvol, + disk, + NULL); + obj_device_config.description_disk = yon_char_parsed_append(obj_device_config.description_disk, &obj_device_config.size_disk, description_disk); + free(description_disk); + + } + free(name_disk); + } + free(disk); + } + philos_free_string_array(&responce, size); + +} +void device_fill_disk(GtkWidget* combo_box_text) { + for (int index = 0; index < obj_device_config.size_disk; index++) { + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo_box_text), obj_device_config.description_disk[index]); + } +} + + diff --git a/source/model/my_device.h b/source/model/my_device.h new file mode 100644 index 0000000..c2ef0e6 --- /dev/null +++ b/source/model/my_device.h @@ -0,0 +1,24 @@ +#ifndef MY_DEVICE_H +#define MY_DEVICE_H +#include "ubl-utils.h" +#include +#include +#include +#include "philos_utils.h" +typedef struct { + char** name_disk; + char** file_system; + char** mounted; + char** type_dick; + char** description_disk; + int size_disk; +} device_config; + +void device_disk_parsed(); +device_config* get_device_cfg(); +void device_fill_disk(GtkWidget* combo_box_text); +size_t get_mem_total(); +float get_size_pow_memory(size_t size_memory, int size); +size_t get_resurs_total(char* cmd); + +#endif \ No newline at end of file diff --git a/source/model/philos_utils.c b/source/model/philos_utils.c new file mode 100644 index 0000000..b32822e --- /dev/null +++ b/source/model/philos_utils.c @@ -0,0 +1,1138 @@ +#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,int index, 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 = philos_int_append(*array_size, &index, 0); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find, " ", STR_KB, NULL); + index--; + } + else if (strstr(str_find,"M") != NULL) { + *array_size = philos_int_append(*array_size, &index, 1); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_MB, NULL); + index--; + } + else if (strstr(str_find,"G") != NULL) { + *array_size = philos_int_append(*array_size, &index, 2); + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_GB, NULL); + index--; + } + else if (strstr(str_find,"T") != NULL) { + *array_size = philos_int_append(*array_size, &index, 3); + str_find = yon_char_divide(str_find, length-1); + + str_find = yon_char_unite(str_find," ", STR_TB, NULL); + index--; + } + else if (strstr(str_find,"%%") != NULL) { + *array_size = philos_int_append(*array_size, &index, -1); + str_find = yon_char_divide(str_find, length-1); + index--; + } + else if (strstr(str_find,"-") != NULL) { + *array_size = philos_int_append(*array_size, &index, -1); + index--; + } + +} +void philos_set_pow_size_memory_device(char* str_find, int** array_size,int index, 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)[index] = 0; + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find, " ", STR_KB, NULL); + index--; + } + else if (strstr(str_find,"M") != NULL) { + (*array_size)[index] = 1; + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_MB, NULL); + index--; + } + else if (strstr(str_find,"G") != NULL) { + (*array_size)[index] = 2; + str_find = yon_char_divide(str_find, length-1); + str_find = yon_char_unite(str_find," ", STR_GB, NULL); + index--; + } + else if (strstr(str_find,"T") != NULL) { + (*array_size)[index] = 3; + str_find = yon_char_divide(str_find, length-1); + + str_find = yon_char_unite(str_find," ", STR_TB, NULL); + index--; + } + else if (strstr(str_find,"%%") != NULL) { + (*array_size)[index] = -1; + str_find = yon_char_divide(str_find, length-1); + index--; + } + else if (strstr(str_find,"-") != NULL) { + (*array_size)[index] = -1; + index--; + } + +} +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_group(int* size) { + 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 ((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); + } + } + 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_user(int* size) { + 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; + } + str_users = yon_char_parsed_append(str_users, size, entry->pw_name); + } + 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 (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; + } + +} +int philos_check_activ_disk(temp_set_window *widgets, temp_config* _config) { + char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice)); + disk = yon_char_divide_search(disk," ", -1); + if (disk == NULL) { + return 0; + } + return 1; +} + +void philos_temp_generate_cmd(temp_set_window *widgets, temp_config* _config) { + char* str_cmd = ""; + char* split_simvol = g_malloc0(sizeof(char)*2); + int size_bite = 0; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkSoftRestrictionTemp))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spiSevereRestrictionTemp)); + str_cmd = yon_char_unite(str_cmd, + "MemoryHigh=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(widgets->cmSevereRestrictionTemp), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkSevereRestrictionTemp))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinSevereRestrictionTemp)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemoryMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(widgets->cmbSevereRestrictionTemp), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkPaddingFLTemp))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinPaddingFLTemp)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemorySwapMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(widgets->cmbPaddingFLTemp), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chkCPULimitTemp))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinCPULimitTemp)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "CPUQuota=", + yon_char_from_int(size_bite), + "%", NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice))!=-1) { + if (_config->size_disk!=0) { + str_cmd = philos_pard_array_add_cmd(str_cmd, _config, "IOReadBandwidthMax=", _config->i_o_limit_read, _config->i_o_limit_read_size, _config->disk_read, _config->size_disk); + + } + if (_config->size_disk!=0) { + str_cmd = philos_pard_array_add_cmd(str_cmd, _config, "IOWriteBandwidthMax=", _config->i_o_limit_write, _config->i_o_limit_write_size, _config->disk_write, _config->size_disk); + } + + } + gtk_entry_set_text(GTK_ENTRY(widgets->entryTempCmd), str_cmd); + free(split_simvol); +} +// flag_check_array = 0 READ +// flag_check_array = 1 WRITE +void philos_temp_del_disk(temp_set_window *widgets, temp_config* _config, int flag_check_array) { + char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice)); + disk = yon_char_divide_search(disk, " ", -1); + int bool_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead)); + int bool_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite)); + char** ptr_disk = NULL; + int size = 0; + + if (flag_check_array == 0) { + size = _config->size_disk; + if (philos_check_activ_disk(widgets, _config) == 0) { + return; + } + ptr_disk = _config->disk_read; + } + else if (flag_check_array == 1) { + size = _config->size_disk; + if (philos_check_activ_disk(widgets, _config) == 0) { + return; + } + ptr_disk = _config->disk_write; + } + int index_find = -1; + if (ptr_disk) { + for (int index = 0; index < size; index++) { + char* disk_cfg = ptr_disk[index]; + if (disk_cfg) { + if (strstr(disk_cfg, disk) != NULL) { + index_find = index; + break; + } + } + } + } + + if ((bool_read == 0 && bool_write == 0 && index_find != -1)) { + ptr_disk[index_find] = yon_char_new("-"); + _config->i_o_limit_read_size[index_find] = -3; + _config->i_o_limit_write_size[index_find] = -3; + _config->i_o_limit_read[index_find] = -3; + _config->i_o_limit_write[index_find] = -3; + } + if (flag_check_array == 0) { + if (ptr_disk) { + yon_char_parsed_copy(&_config->disk_read, &ptr_disk); + } + } + else if (flag_check_array == 1) { + if (ptr_disk) { + yon_char_parsed_copy(&_config->disk_write, &ptr_disk); + } + } +} + +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; +} + +// flag_check_array = 0 READ +// flag_check_array = 1 WRITE +void philos_update_device_to_entry(temp_set_window *widgets, temp_config* _config, int flag_check_array) { + int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice)); + char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice)); + disk = yon_char_divide_search(disk, " ", -1); + if (disk_id != -1) { + int index_find = -1; + if (flag_check_array == 0) { + if (_config->disk_read) { + for (int index = 0; index < _config->size_disk; index++) { + char* disk_cfg = _config->disk_read[index]; + if (disk_cfg) { + if (strstr(disk_cfg, disk)) { + index_find = index; + break; + } + } + } + } + } + else if (flag_check_array == 1) { + if (_config->disk_write) { + for (int index = 0; index < _config->size_disk; index++) { + char* disk_cfg = _config->disk_write[index]; + if (disk_cfg) { + if (strstr(disk_cfg, disk)) { + index_find = index; + break; + } + } + } + } + } + if (index_find != -1) { + if (flag_check_array==0) { + if (_config->i_o_limit_read[index_find]<0 || _config->i_o_limit_read_size[index_find]<0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0); + } + else { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), _config->i_o_limit_read[index_find]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 1); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), _config->i_o_limit_read_size[index_find]); + + } + } + else if (flag_check_array==1) { + if (_config->i_o_limit_write[index_find]<0 || _config->i_o_limit_write_size[index_find]<0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0); + } + else { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), _config->i_o_limit_write[index_find]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 1); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), _config->i_o_limit_write_size[index_find]); + } + } + else { + if (flag_check_array==0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0); + } + else if (flag_check_array==1) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0); + } + } + } + else { + if (flag_check_array==0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0); + } + else if (flag_check_array==1) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0); + } + } + } + else { + if (flag_check_array==0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempRead), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempRead), 0); + } + else if (flag_check_array==1) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite), 0); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widgets->spinTempWrite), 0); + gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cbtTempWrite), 0); + } + } +} +// flag_check_array = 0 READ +// flag_check_array = 1 WRITE +void philos_temp_add_disk(temp_set_window *widgets, temp_config* _config, int flag_check_array) { + char* disk = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtTempDevice)); + disk = yon_char_divide_search(disk, " ", -1); + int disk_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempDevice)); + int bool_read = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead)); + int bool_write = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite)); + char** ptr_disk = NULL; + int size = 0; + if (flag_check_array == 0) { + ptr_disk = _config->disk_read; + size = _config->size_disk; + } + else if (flag_check_array == 1) { + ptr_disk = _config->disk_write; + size = _config->size_disk; + } + if (disk_id >= 0 && size !=0) { + int index_find = -1; + if (ptr_disk){ + for (int index = 0; index < size; index++) { + char* disk_cfg = ptr_disk[index]; + if (disk_cfg) { + if (strstr(disk_cfg, disk) != NULL) { + index_find = index; + break; + } + } + } + } + + if (index_find == -1 || index_find>=0) { + if (index_find == -1) { + index_find = find_null_array(_config); + } + // Редактирование + if (flag_check_array == 0) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead))) { + ptr_disk[index_find] = yon_char_new(disk); + _config->i_o_limit_read_size[index_find] = (int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempRead)); + _config->i_o_limit_read[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempRead)); + } + else { + ptr_disk[index_find] = yon_char_new("-"); + _config->i_o_limit_read_size[index_find] = -3; + _config->i_o_limit_read[index_find] = -3; + } + } + if (flag_check_array == 1) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite))) { + ptr_disk[index_find] = yon_char_new(disk); + _config->i_o_limit_write_size[index_find] = (int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempWrite)); + _config->i_o_limit_write[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempWrite)); + } + else { + _config->i_o_limit_write_size[index_find] = -3; + _config->i_o_limit_write[index_find] = -3; + ptr_disk[index_find] = yon_char_new("-"); + } + } + } + } + else { + if (bool_read == 1 || bool_write == 1) { + int index_find = find_null_array(_config); + if (flag_check_array == 0) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempRead))) { + ptr_disk[index_find] = yon_char_new(disk); + _config->i_o_limit_read_size[index_find] = (int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempRead)); + _config->i_o_limit_read[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempRead)); + + } + } + if (flag_check_array == 1) { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->chbTempWrite))) { + ptr_disk[index_find] = yon_char_new(disk); + _config->i_o_limit_write_size[index_find] = (int)gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtTempWrite)); + _config->i_o_limit_write[index_find] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widgets->spinTempWrite)); + } + } + } + } + if (flag_check_array == 0) { + if (ptr_disk) { + yon_char_parsed_copy(&_config->disk_read, &ptr_disk); + + } + } + else if (flag_check_array == 1) { + if (ptr_disk) { + yon_char_parsed_copy(&_config->disk_write, &ptr_disk); + } + } +} +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)); + 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, (gdouble)(value*100)); + if ((value*100)0) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),1); + } + else if (active == 0) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), 0); + } + if (flag_cpu == 0) { + philos_set_spin_adjustment(check, spin, combo, resurs); + if (value_spin>resurs) { + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), resurs); + } + } + else { + philos_set_spin_adjustment(check, spin, NULL, resurs); + } + +} + +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; +} +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); +} +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; +} +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)); +} +/**[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; + } + } +} +void init_device_disk(temp_config* _config) { + for (int index = 0;index< (get_device_cfg()->size_disk*2);index++){ + _config->disk_read = yon_char_parsed_append(_config->disk_read,&_config->size_disk, "-"); + _config->size_disk--; + _config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size, &_config->size_disk, -3); + _config->size_disk--; + _config->i_o_limit_write = philos_int_append(_config->i_o_limit_write, &_config->size_disk, -3); + _config->size_disk--; + _config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size, &_config->size_disk, -3); + _config->size_disk--; + _config->disk_write = yon_char_parsed_append(_config->disk_write,&_config->size_disk, "-"); + _config->size_disk--; + _config->i_o_limit_read = philos_int_append(_config->i_o_limit_read, &_config->size_disk, -3); + } + _config->i_o_limit_write_size = philos_int_append(_config->i_o_limit_write_size, &_config->size_disk, -2); + _config->size_disk--; + _config->disk_write = yon_char_parsed_append(_config->disk_write, &_config->size_disk, NULL); + _config->size_disk--; + _config->disk_read = yon_char_parsed_append(_config->disk_read, &_config->size_disk, NULL); + _config->size_disk--; + _config->i_o_limit_write = philos_int_append(_config->i_o_limit_write, &_config->size_disk, -2); + _config->size_disk--; + _config->i_o_limit_read = philos_int_append(_config->i_o_limit_read, &_config->size_disk, -2); + _config->size_disk--; + _config->i_o_limit_read_size = philos_int_append(_config->i_o_limit_read_size, &_config->size_disk, -2); +} \ No newline at end of file diff --git a/source/model/philos_utils.h b/source/model/philos_utils.h new file mode 100644 index 0000000..8ec5af6 --- /dev/null +++ b/source/model/philos_utils.h @@ -0,0 +1,120 @@ +#ifndef PHILOS_UTILS_H +#define PHILOS_UTILS_H +#include "ubl-utils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "my_device.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* entryTempCmd; + GtkWidget* chbTempRead; + GtkWidget* spinTempRead; + GtkWidget* cbtTempRead; + + GtkWidget* chbTempWrite; + GtkWidget* spinTempWrite; + GtkWidget* cbtTempWrite; + + GtkWidget* chkSoftRestrictionTemp; + GtkWidget* spiSevereRestrictionTemp; + GtkWidget* cmSevereRestrictionTemp; + + GtkWidget* chkSevereRestrictionTemp; + GtkWidget* spinSevereRestrictionTemp; + GtkWidget* cmbSevereRestrictionTemp; + + GtkWidget* chkPaddingFLTemp; + GtkWidget* spinPaddingFLTemp; + GtkWidget* cmbPaddingFLTemp; + + GtkWidget* chkCPULimitTemp; + GtkWidget* spinCPULimitTemp; + GtkWidget* lblCPULimitTemp; + + GtkWidget* cbtTempDevice; + GtkWidget* cbxTempQuotaObj; + GtkWidget* cbxTempQuotaLevel2; + GtkWidget* boxBlockGui; +} temp_set_window; +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,int index, 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); +config_str philos_list_group(int* size); +unsigned short philos_read_uid_min_max(char* filename, char* search); +config_str philos_list_user(int* size); +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_set_pow_size_memory_device(char* str_find, int** array_size,int index, char** array_size_pow); +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, int flag_cpu, char* cmd); +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); +static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data); +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); +#endif \ No newline at end of file diff --git a/source/view/model/ubl-utils.cc b/source/model/ubl-utils.c similarity index 79% rename from source/view/model/ubl-utils.cc rename to source/model/ubl-utils.c index 6768f9e..0688bf4 100644 --- a/source/view/model/ubl-utils.cc +++ b/source/model/ubl-utils.c @@ -1,7 +1,4 @@ - #include "ubl-utils.h" -static dictionary* __yon__config__strings = NULL; -#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) // dictionary functions @@ -11,12 +8,9 @@ static dictionary* __yon__config__strings = NULL; * [RU] * Создаёт и возвращает пустой словарь. */ - - - dictionary *yon_dictionary_new() { - dictionary *dict = (dictionary *)malloc(sizeof(dictionary)); + dictionary *dict = malloc(sizeof(dictionary)); dict->data = NULL; dict->key = NULL; dict->next = NULL; @@ -26,7 +20,7 @@ dictionary *yon_dictionary_new() return dict; } -/**yon_dictionary_copy_deep(dictionary *dict) +/**yon_dictionary_copy(dictionary *dict) * [EN] * * [RU] @@ -35,7 +29,6 @@ dictionary *yon_dictionary_new() dictionary *yon_dictinoary_copy(dictionary *dict){ dictionary *dct = yon_dictionary_new_with_data(dict->key,dict->data); dct->data_type= dict->data_type; - return dct; } /**yon_dictionary_copy_deep(dictionary *dict) @@ -54,20 +47,44 @@ dictionary *yon_dictionary_copy_deep(dictionary *dict){ return newone->first; } -void yon_dictionary_set_data(dictionary *dict, void *data){ +/**int yon_dictionary_set_data(dictionary *dict, void *data) + * [EN] + * + * [RU] + * Установить элементу словаря [dict] значение [data] +*/ +int yon_dictionary_set_data(dictionary *dict, void *data){ dict->data=data; } -void yon_dictionary_set_key(dictionary *dict, char *key){ +/**int yon_dictionary_set_key(dictionary *dict, char *key) + * [EN] + * + * [RU] + * Изменяет ключ элемента словаря [dict] на [key] +*/ +int yon_dictionary_set_key(dictionary *dict, char *key){ dict->key=key; } -void yon_dictionary_set(dictionary *dict, char *key, void *data){ +/** int yon_dictionary_set(dictionary *dict, char *key, void *data) + * [EN] + * + * [RU] +* Устанавливает значение ключа элемента словаря [dict] на [key] и его данные на [data] +*/ +int yon_dictionary_set(dictionary *dict, char *key, void *data){ dict->key=key; dict->data=data; } -void yon_dictionary_empty(dictionary *dict){ +/**int yon_dictionary_empty(dictionary *dict) + * [EN] + * + * [RU] + * Очищает элемент словаря [dict] от данных +*/ +int yon_dictionary_empty(dictionary *dict){ dict->data=NULL; dict->data_type=DICTIONARY_OTHER_TYPE; } @@ -224,7 +241,6 @@ dictionary *yon_dictionary_swap(dictionary *dict, int aim) } } } - return dict; } /**yon_dictionary_make_first(dictionary *dict) @@ -426,7 +442,7 @@ char *yon_char_append(char *source, char *append) if (source && append) { int size = strlen(source) + strlen(append) + 1; - char *final = (char*)malloc(size); + char *final = malloc(size); memset(final, 0, size); if (strstr(source, "%%")) sprintf(final, source, append); @@ -445,7 +461,7 @@ char *yon_char_append(char *source, char *append) char *yon_char_new(char *chr) { if (chr){ - char *newchar = (char*)malloc(strlen(chr) + 1); + char *newchar = malloc(strlen(chr) + 1); memset(newchar, 0, strlen(chr) + 1); memcpy(newchar, chr, strlen(chr)); return newchar; @@ -453,8 +469,12 @@ char *yon_char_new(char *chr) return NULL; } -// char *yon_char_unite(char *source, ...) - +/**yon_char_unite(char *source, ...) + * [En] + * + * [RU] + * Объединяет строку [source] со всеми строками, написанными в [...] +*/ char *yon_char_unite(char *source, ...){ va_list arglist; char *new_char=NULL; @@ -477,7 +497,7 @@ char *yon_char_unite(char *source, ...){ char *yon_cut(char *source, int size, int startpos) { char *cut = NULL; - cut = (char*)malloc(size + 1); + cut = malloc(size + 1); memset(cut, 0, size + 1); memcpy(cut, source + startpos, size); return cut; @@ -491,10 +511,10 @@ char *yon_cut(char *source, int size, int startpos) */ char *yon_char_divide(char *source, int dividepos) { - char *cut = (char*)malloc(dividepos + 1); + char *cut = malloc(dividepos + 1); memset(cut, 0, dividepos + 1); memcpy(cut, source, dividepos); - char *left = (char*)malloc(strlen(source) - strlen(cut)); + char *left = malloc(strlen(source) - strlen(cut)); memset(left, 0, strlen(source) - strlen(cut)); memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); memset(source, 0, strlen(source)); @@ -502,11 +522,18 @@ char *yon_char_divide(char *source, int dividepos) return cut; } +/**yon_char_find_count(char *source, char *find) + * [EN] + * + * [RU] + * Считает количество символов [find] в строке [source] +*/ int yon_char_find_count(char *source, char *find){ char *working_string=yon_char_new(source); int i=0; int size=0; - config_str rtn = yon_char_parse(working_string,&size,(char*)"\n"); + int pos=0; + config_str rtn = yon_char_parse(working_string,&size,"\n"); for (int j=0;jd_name); -// if (strlen(de->d_name) > 9) -// { -// char *extension = strstr(path, "."); -// if (extension != NULL) -// { -// if (strcmp(extension, ".desktop") == 0) -// { -// apps tempapp; -// GKeyFile *gfile = g_key_file_new(); -// GError *err = NULL; -// g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); -// char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); -// if (err) -// { -// printf("%s\n", err->message); -// } -// if (strcmp(Type, "Application") == 0) -// tempapp.Type = 1; -// else if (strcmp(Type, "pyApplication") == 0) -// tempapp.Type = 2; -// else -// continue; -// tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); -// if (tempapp.Name == NULL) -// continue; -// tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); -// if (tempapp.Categories == NULL) -// continue; -// tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); -// if (tempapp.Exec == NULL) -// continue; -// tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); -// if (tempapp.Icon == NULL) -// continue; -// tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); -// if (!tempapp.Pluggable) -// tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); -// if (tempapp.Pluggable) -// tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); -// if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0){ -// if (size == 0) -// { -// applist = (apps *)malloc(size + 1 * sizeof(apps)); -// applist[0].Name = yon_char_new(tempapp.Name); -// applist[0].Categories = yon_char_new(tempapp.Categories); -// applist[0].Exec = yon_char_new(tempapp.Exec); -// applist[0].Icon = yon_char_new(tempapp.Icon); -// applist[0].Type = tempapp.Type; -// applist[0].Pluggable = tempapp.Pluggable; -// applist[0].DualPluggable = tempapp.DualPluggable; -// size++; -// } -// else -// { -// applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); -// applist[size].Name = yon_char_new(tempapp.Name); -// applist[size].Categories = yon_char_new(tempapp.Categories); -// applist[size].Exec = yon_char_new(tempapp.Exec); -// applist[size].Icon = yon_char_new(tempapp.Icon); -// applist[size].Pluggable = tempapp.Pluggable; -// applist[size].DualPluggable = tempapp.DualPluggable; -// applist[size].Type = tempapp.Type; -// size++; -// } -// } -// } -// } -// } -// } -// } -// *sizef = size; -// return applist; -// }; +apps *yon_apps_scan_and_parse_desktops(int *sizef) +{ + int size = 0; + struct apps *applist; + { + DIR *directory = opendir(DesktopPath); + struct dirent *de; + while ((de = readdir(directory))) + { + FILE *file; + char *path = yon_char_append(DesktopPath, de->d_name); + file = fopen(path, "r"); + if (strlen(de->d_name) > 9) + { + char *extension = strstr(path, "."); + if (extension != NULL) + { + if (strcmp(extension, ".desktop") == 0) + { + apps tempapp; + GKeyFile *gfile = g_key_file_new(); + GError *err = NULL; + g_key_file_load_from_file(gfile, path, G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", &err); + if (err) + { + printf("%s\n", err->message); + } + if (strcmp(Type, "Application") == 0) + tempapp.Type = 1; + else if (strcmp(Type, "pyApplication") == 0) + tempapp.Type = 2; + else + continue; + tempapp.Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); + if (tempapp.Name == NULL) + continue; + tempapp.Categories = g_key_file_get_string(gfile, "Desktop Entry", "Categories", NULL); + if (tempapp.Categories == NULL) + continue; + tempapp.Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); + if (tempapp.Exec == NULL) + continue; + tempapp.Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); + if (tempapp.Icon == NULL) + continue; + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "Pluggable", NULL); + if (!tempapp.Pluggable) + tempapp.Pluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-XfcePluggable", NULL); + if (tempapp.Pluggable) + tempapp.DualPluggable = g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBLPluggable", NULL); + if (g_key_file_get_boolean(gfile, "Desktop Entry", "X-UBL-SettingsManager-Hidden", NULL) == 0) + if (size == 0) + { + applist = (apps *)malloc(size + 1 * sizeof(apps)); + applist[0].Name = yon_char_new(tempapp.Name); + applist[0].Categories = yon_char_new(tempapp.Categories); + applist[0].Exec = yon_char_new(tempapp.Exec); + applist[0].Icon = yon_char_new(tempapp.Icon); + applist[0].Type = tempapp.Type; + applist[0].Pluggable = tempapp.Pluggable; + applist[0].DualPluggable = tempapp.DualPluggable; + size++; + } + else + { + applist = (apps *)realloc(applist, (size + 1) * sizeof(apps)); + applist[size].Name = yon_char_new(tempapp.Name); + applist[size].Categories = yon_char_new(tempapp.Categories); + applist[size].Exec = yon_char_new(tempapp.Exec); + applist[size].Icon = yon_char_new(tempapp.Icon); + applist[size].Pluggable = tempapp.Pluggable; + applist[size].DualPluggable = tempapp.DualPluggable; + applist[size].Type = tempapp.Type; + size++; + } + } + } + } + } + } + *sizef = size; + return applist; +}; void yon_apps_sort(apps *applist, int size) { @@ -885,21 +928,21 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size) * Выполняет команду [command]. * Полученные данные парсятся и регистрируются в конфиг. */ - int yon_config_load_register(char *command){ if (__yon__config__strings){ - __yon__config__strings = (dictionary *)yon_dictionary_free_all(__yon__config__strings,NULL); + __yon__config__strings = yon_dictionary_free_all(__yon__config__strings,NULL); } FILE *output = popen(command, "r"); - //char **output_strings = (char **)malloc(sizeof(char)); - // int i = 0; + char **output_strings = NULL; + output_strings = malloc(sizeof(char)); + int i = 0; char str[4096]; memset(str, 0, 4096); while (fgets(str, 4096, output)) { if (strcmp(str, "") != 0&& strcmp(str,"(null)\n")!=0) { - char *key = yon_char_divide_search(str,(char*)"=",-1); + char *key = yon_char_divide_search(str,"=",-1); yon_dictionary_add_or_create_if_exists_with_data(__yon__config__strings,key,str); __yon__config__strings->data_type=DICTIONARY_CHAR_TYPE; } @@ -958,7 +1001,7 @@ int yon_config_remove_element(char *key, char *deleted){ char *data = (char*)dict->data; char *found = strstr(data,deleted); int size=strlen(data)-strlen(found)+1; - char *new_data = (char*)malloc(size); + char *new_data = malloc(size); memset(new_data,0,size); if (strlen(found)!=strlen(deleted)){ memcpy(new_data,data,size-1); @@ -1033,7 +1076,7 @@ int yon_config_set(char *key, void *data){ */ int yon_config_clean(){ check_config{ - __yon__config__strings = (dictionary *)yon_dictionary_free_all(__yon__config__strings, NULL); + __yon__config__strings = yon_dictionary_free_all(__yon__config__strings, NULL); return 1; } else return 0; @@ -1062,7 +1105,7 @@ void yon_config_register(char *key, void *data){ config_str yon_config_load(char *command, int *str_len){ FILE *output = popen(command, "r"); char **output_strings = NULL; - output_strings = (char**)malloc(sizeof(char)); + output_strings = malloc(sizeof(char)); int i = 0; char str[4096]; memset(str, 0, 4096); @@ -1070,7 +1113,7 @@ config_str yon_config_load(char *command, int *str_len){ { if (strcmp(str, "") != 0) { - output_strings = (char**)realloc(output_strings, sizeof(char *) * (i + 1)); + output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); // printf("%s\n", str); output_strings[i] = NULL; output_strings[i] = yon_char_new(str); @@ -1094,54 +1137,41 @@ config_str yon_config_load(char *command, int *str_len){ * Выполняет команду [command], добавляя в конец все записи конфига в таком виде: * [ПАРАМЕТР1]="[значения1]" [ПАРАМЕТР2]="[значения2]" */ -int yon_config_save(char *command){ +int yon_config_save_registered(char *command){ check_config{ dictionary *dict = NULL; for_dictionaries(dict,__yon__config__strings){ - command = yon_char_unite(command, (char*)" ", yon_dictionary_get_data(dict,char*), NULL); + command = yon_char_unite(command, " ", yon_dictionary_get_data(dict,char*), NULL); } if (popen(command, "r")) return 1; else return 0; } else return 0; } -// /**yon_config_get_all(int *size) -// * [EN] -// * -// * [RU] -// * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL -// * [size] - указатель, в который выгружается длина массива -// */ -// config_str yon_config_get_all(int *size){ -// if (size) {} -// check_config{ -// *size = 1; -// config_str conf = NULL; -// dictionary *dict = NULL; -// for_dictionaries(dict,__yon__config__strings){ -// conf = yon_remalloc(conf,sizeof(char*)*(*size)); -// conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); -// size++; -// } -// conf = yon_remalloc(conf,sizeof(char*)*(*size+1)); -// conf[*size] = NULL; -// return conf; -// } else return NULL; -// } - -/**[EN] - * int yon_config_save(char *command) - * Saves config with [command] +/**yon_config_get_all(int *size) + * [EN] + * * [RU] - * Выполняет команду [command] + * Возвращает массив со всеми параметрами конфига, оканчивающаяся NULL + * [size] - указатель, в который выгружается длина массива */ -// int yon_config_save(char *command) -// { -// FILE *output = popen(command, "r"); -// return 1; -// } +config_str yon_config_get_all(int *size){ + check_config{ + *size = 1; + config_str conf = NULL; + dictionary *dict = NULL; + for_dictionaries(dict,__yon__config__strings){ + conf = yon_remalloc(conf,sizeof(char*)*(*size)); + conf[(*size)-1] = yon_char_unite(dict->key,"=",(char*)dict->data,NULL); + size++; + } + conf = yon_remalloc(conf,sizeof(char*)*(*size+1)); + conf[*size] = NULL; + return conf; + } else return NULL; +} -/**char *yon_config_get_parameter(config parameter" "s, int size, char *param) +/**char *yon_config_get_parameter(config parameters, int size, char *param) * [EN] * Gets parameter [param] from parameter list [parameters] of size [size]; * or NULL if nothing were found @@ -1152,19 +1182,19 @@ int yon_config_save(char *command){ char *yon_config_get_parameter(config_str parameters, int size, char *param) { if (param[0]==' ') - yon_char_divide_search(param,(char*)" ",-1); - param=yon_char_divide_search(yon_char_new(param),(char*)" ",-1); + yon_char_divide_search(param," ",-1); + param=yon_char_divide_search(yon_char_new(param)," ",-1); char *str = NULL; for (int j = 0; j < size; j++) { - char *name = yon_char_divide_search(yon_char_new(parameters[j]), (char*)"=", 1); + char *name = yon_char_divide_search(yon_char_new(parameters[j]), "=", 1); if (name) { if (strcmp(name, param) == 0) { - str = yon_char_divide_search(yon_char_new(parameters[j]), (char*)"\n", 1); - if (strcmp(str, "") != 0 && strcmp(str, (char*)"(null)") != 0) + str = yon_char_divide_search(yon_char_new(parameters[j]), "\n", 1); + if (strcmp(str, "") != 0 && strcmp(str, "(null)") != 0) return str; else return NULL; @@ -1184,13 +1214,13 @@ char *yon_config_get_parameter(config_str parameters, int size, char *param) * [RU] * Выполнить команду [command] в отдельном потоке; */ -void yon_launch_app_with_arguments(char *name, char *args) +int yon_launch_app_with_arguments(char *name, char *args) { - char *path = yon_char_unite((char*)"/usr/bin/", name, (char*)" ", args,NULL); + char *path = yon_char_unite("/usr/bin/", name, " ", args,NULL); pthread_t thread_id; char *command = NULL; command = path; - pthread_create(&thread_id, NULL, (void* (*)(void *))yon_launch, command); + pthread_create(&thread_id, NULL, (void *)yon_launch, command); }; /**yon_launch(char *command) @@ -1199,10 +1229,9 @@ void yon_launch_app_with_arguments(char *name, char *args) * [RU] * Выполнить команду [command] */ -void* yon_launch(void *command) +void yon_launch(char *command) { - if (system((char*)command)){} - return NULL; + system(command); } // Gtk functions @@ -1332,8 +1361,11 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end gtk_widget_show_all(terminal); } #endif + // Window config functions + #define check_window_config_setup if(__yon_window_config_target_window) + struct { int x; int y; @@ -1341,6 +1373,7 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end int height; int fullscreen; } __yon_main_window_config; + static GtkWindow *__yon_window_config_target_window = NULL; static GKeyFile *__yon_window_config_file = NULL; static char *__yon_window_config_path = NULL; @@ -1359,9 +1392,13 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); } - + /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) + * [EN] + * + * [RU] + * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. + */ void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ - if (self && event){} check_window_config_setup{ yon_get_is_fullscreen(); yon_window_config_save(); @@ -1378,26 +1415,36 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end } } + /**yon_window_config_setup(GtkWindow *window) + * [EN] + * + * [RU] + * Устанавливает указатель на окно для отслеживания его положения и размера + */ void yon_window_config_setup(GtkWindow *window){ __yon_window_config_target_window = window; g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); } - void* _yon_maximize(void *data){ - if (data){} + void _yon_maximize(void *data){ g_usleep(G_USEC_PER_SEC/10); if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); - return NULL; } + /**yon_window_config_load(char *path) + * [EN] + * + * [RU] + * Загружает конфиг окна и инициализирует отслеживание его параметров + */ int yon_window_config_load(char *path){ __yon_window_config_file = g_key_file_new(); __yon_window_config_path=yon_char_new(path); if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ struct stat st; int size; - config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,(char*)"/"); + config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,"/"); char *path = yon_char_unite(conf[0],"/",conf[1],"/",conf[2],"/",conf[3],"/",conf[4],"/",NULL); if (stat(path, &st) == -1) { mkdir(path, 0777); @@ -1417,16 +1464,53 @@ void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *end gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); pthread_t tid; - pthread_create(&tid,NULL,&_yon_maximize,NULL); + pthread_create(&tid,NULL,(void *)_yon_maximize,NULL); return 1; } void yon_window_config_apply(){ - // dictionary *dict=NULL; + dictionary *dict=NULL; gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); } +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitembottom"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-information-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname){ + GtkWidget *menu_item = gtk_menu_item_new(); + gtk_style_context_add_class(gtk_widget_get_style_context(menu_item),"menuitemtop"); + GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0); + GtkWidget *label = gtk_label_new(buttonname); + GtkWidget *image = gtk_image_new_from_icon_name("dialog-question-symbolic",GTK_ICON_SIZE_BUTTON); + gtk_label_set_xalign(GTK_LABEL(label),0.0); + gtk_box_pack_start(GTK_BOX(box),image,0,0,5); + gtk_box_pack_start(GTK_BOX(box),label,0,0,5); + gtk_container_add(GTK_CONTAINER(menu_item),box); + gtk_widget_show_all(menu_item); + return menu_item; +} + + +// other Gtk functions + +/**yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size) + * [EN] + * + * [RU] + * Добавляет в Комбобокс [combo] все строки из массива строк [parameters] размера [size] +*/ int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size){ if (combo&¶meters){ for (int i=0;i - #include - +#include #include #include #include @@ -16,8 +13,7 @@ #include #include - -#include "../../ubl-cmake.h" +#include "../ubl-cmake.h" #ifdef WEBKIT_FOUND #include #endif @@ -25,7 +21,7 @@ #define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) -//#define new(type) malloc(sizeof(type)) +#define new(type) malloc(sizeof(type)) #define new_arr(type,size) malloc(sizeof(type)*size) @@ -65,6 +61,8 @@ typedef struct apps typedef char** config_str; +static dictionary *__yon__config__strings = NULL; +#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE) #define config(key) yon_config_get_by_key(key) @@ -97,20 +95,6 @@ typedef char** config_str; dictionary *yon_dictionary_new(); -dictionary *yon_dictinoary_copy(dictionary *dict); - -dictionary *yon_dictionary_copy_deep(dictionary *dict); - -void yon_dictionary_set_data(dictionary *dict, void *data); - -void yon_dictionary_set_key(dictionary *dict, char *key); - -void yon_dictionary_set(dictionary *dict, char *key, void *data); - -void yon_dictionary_empty(dictionary *dict); - -void yon_dictionary_switch_to_last(dictionary **dict); - dictionary *yon_dictionary_append(dictionary *targetdict); dictionary *yon_dictionary_get_last(dictionary *dict); @@ -185,7 +169,7 @@ apps *yon_apps_get_by_name(apps *applist, char *name, int size); config_str yon_config_load(char *command, int *str_len); -int yon_config_save(char *command); +int yon_config_save_registered(char *command); char *yon_config_get_parameter(config_str parameters, int size, char *param); @@ -211,9 +195,9 @@ config_str yon_config_get_all(); // terminal-using functions -void yon_launch_app_with_arguments(char *name, char *args); +int yon_launch_app_with_arguments(char *name, char *args); -void* yon_launch(void *command); +void yon_launch(char *command); // Gtk functions @@ -223,19 +207,11 @@ void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, voi void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); +#endif +GtkWidget *yon_ubl_menu_item_about_new(char *buttonname); +GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname); -void __yon_window_config_on_resize(); - -void yon_get_is_fullscreen(); - - -void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event); -#endif -void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event); -void yon_window_config_save(); -void __yon_window_config_on_resize(); -void yon_get_is_fullscreen(); /**yon_gtk_builder_get_widget(builder, widget_name) * [EN] * Returns GtkWidget from GtkBuilder *[builder]. @@ -254,14 +230,8 @@ typedef struct void yon_window_config_setup(GtkWindow *window); -void* _yon_maximize(void *data); - -void yon_window_config_apply(); - int yon_window_config_load(char *path); -int yon_gtk_combo_box_text_fill(GtkWidget *combo, config_str parameters,int size); - int yon_gtk_combo_box_fill(GtkWidget *combo, char **parameters,int size); int yon_gtk_combo_box_text_find(GtkWidget *combo_box, char *text_to_find); @@ -318,9 +288,6 @@ int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); * или * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) */ - -void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); - void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); #ifdef __cplusplus @@ -372,4 +339,4 @@ void yon_ubl_browser_window_open(char *link, char *browser_window_name); void yon_ubl_browser_window_open(char *link, char *browser_window_name); #endif #endif -#endif +#endif \ No newline at end of file diff --git a/source/ubl-settings-diskquota.cc b/source/ubl-settings-diskquota.c similarity index 60% rename from source/ubl-settings-diskquota.cc rename to source/ubl-settings-diskquota.c index 76e5942..33f788f 100644 --- a/source/ubl-settings-diskquota.cc +++ b/source/ubl-settings-diskquota.c @@ -20,7 +20,7 @@ void on_close_subwindow(GtkWidget *self){ * [RU] * Открывает браузер с [link] ссылкой. */ -void yon_open_browser(GtkWidget *, char *link){ +void yon_open_browser(GtkWidget *self, char *link){ yon_ubl_browser_window_open(link,TITLE_LABEL); } @@ -33,7 +33,7 @@ void yon_open_browser(GtkWidget *, char *link){ void on_open_documentation_confirmation(GtkWidget *self, char *link){ if (main_config.always_open_documentation==0){ GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); - documentation_confirmation_window *widgets = (documentation_confirmation_window*)malloc(sizeof(documentation_confirmation_window)); + documentation_confirmation_window *widgets = malloc(sizeof(documentation_confirmation_window)); widgets->Window = yon_gtk_builder_get_widget(builder,"helpConfirmationWindow"); widgets->AcceptButton = yon_gtk_builder_get_widget(builder,"ReadHelpButton"); widgets->CloseButton = yon_gtk_builder_get_widget(builder,"CancelHelpButton"); @@ -72,7 +72,7 @@ void on_open_documentation_confirmation(GtkWidget *self, char *link){ * [uri] - ссылка, по которой совершается переход; * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; */ -void on_link(GtkWidget *self, char* uri, gpointer){ +void on_link(GtkWidget *self, char* uri, gpointer user_data){ gtk_widget_destroy(self); on_open_documentation_confirmation(self,uri); } @@ -130,7 +130,7 @@ void config_init(){ main_window *setup_window(){ /* Widgets getting | Получение виджетов */ - main_window *widgets = (main_window*)malloc(sizeof(main_window)); + main_window *widgets = malloc(sizeof(main_window)); GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); @@ -157,9 +157,13 @@ main_window *setup_window(){ widgets->LoadLocalMenuItem = yon_gtk_builder_get_widget(builder,"LoadLocalConfigurationMenuItem"); widgets->LeftBox = yon_gtk_builder_get_widget(builder,"HeaderLeftBox"); - widgets->DocumentationMenuItem = yon_gtk_builder_get_widget(builder,"DocumentationMenuItem"); - widgets->AboutMenuItem = yon_gtk_builder_get_widget(builder,"AboutMenuItem"); + widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL); // yon_gtk_builder_get_widget(builder,"DocumentationMenuItem"); + widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL); // yon_gtk_builder_get_widget(builder,"AboutMenuItem"); + GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2"); + gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem); + gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem); + if (main_config.lock_load_global == 1){ gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); } @@ -173,128 +177,12 @@ main_window *setup_window(){ } /* Signal connection | Присоединение сигналов */ - - event(widgets); - gtk_widget_show(widgets->Window); - return widgets; -} - -void event(main_window *widgets) { g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(gtk_main_quit), NULL); - g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),(char*)WIKI_LINK); + g_signal_connect(G_OBJECT(widgets->DocumentationMenuItem),"activate",G_CALLBACK(on_open_documentation_confirmation),WIKI_LINK); g_signal_connect(G_OBJECT(widgets->AboutMenuItem),"activate",G_CALLBACK(on_about),NULL); - //g_signal_connect(G_OBJECT(widgets->btnShowFilters),"clicked",G_CALLBACK(wrapper_filters_show), NULL); -} -/* -void main_visible_columns(main_window *widgets) { - gboolean *flags_filters = filters_get_flag(); - gtk_tree_view_column_set_visible(widgets->tvc0, flags_filters[0]); - gtk_tree_view_column_set_visible(widgets->tvc1, flags_filters[1]); - gtk_tree_view_column_set_visible(widgets->tvc2, flags_filters[2]); - gtk_tree_view_column_set_visible(widgets->tvc3, flags_filters[3]); - gtk_tree_view_column_set_visible(widgets->tvc4, flags_filters[4]); - gtk_tree_view_column_set_visible(widgets->tvc5, flags_filters[5]); - gtk_tree_view_column_set_visible(widgets->tvc6, flags_filters[6]); - gtk_tree_view_column_set_visible(widgets->tvc7, flags_filters[7]); - filters_on_hide_subwindow(self); -} -void wrapper_filters_show(GtkWidget *self) { - filters_show(self, glade_path); - g_signal_connect(G_OBJECT(get_widget_filters()->btnFiltersSave),"clicked",G_CALLBACK(main_visible_columns), NULL); -} -*/ -int main(int argc, char *argv[]){ - config_path = yon_char_unite((char*)"/home",yon_ubl_root_user_get(),(char*)"/.config/",LocaleName,(char*)"/",LocaleName,(char*)".conf",NULL); - local=setlocale(LC_ALL, ""); - textdomain (LocaleName); - config_init(); - int option_index=0; - int show_help=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;iHeadOverlay),GTK_WIDGET(widgets->HeadBox),GTK_WIDGET(widgets->HeadImage),(char*)banner_path); - - yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel); - if (getuid()!=0) - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - else - yon_ubl_status_box_render(TITLE_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); - yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id); - yon_window_config_setup(GTK_WINDOW(widgets->Window)); - yon_window_config_load((char*)config_path.c_str()); - 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); - gtk_main(); + gtk_widget_show(widgets->Window); + return widgets; } + diff --git a/source/ubl-settings-diskquota.h b/source/ubl-settings-diskquota.h index 4462d2d..915dc53 100644 --- a/source/ubl-settings-diskquota.h +++ b/source/ubl-settings-diskquota.h @@ -1,9 +1,6 @@ - - #include #include -#include -#include "view/model/ubl-utils.h" +#include "model/ubl-utils.h" #include #include #include @@ -11,10 +8,7 @@ #include #include #include -#include -#include #include "ubl-cmake.h" -using namespace std; #ifdef WEBKIT_FOUND #include #endif @@ -27,13 +21,12 @@ using namespace std; #define glade_path "/com/ublinux/ui/ubl-settings-diskquota.glade" #define banner_path "/com/ublinux/images/ubl-settings-diskquota-banner.png" #define CssPath "/com/ublinux/css/ubl-settings-diskquota.css" -static string config_path; - +#define config_path yon_char_unite("/home/",yon_ubl_root_user_get(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) #define LocalePath "/usr/share/locale" #define LocaleName "ubl-settings-diskquota" - -char const* version_application=""; +typedef char* string; +string version_application; char *local; @@ -55,6 +48,7 @@ typedef struct { } config; typedef struct { + //Standard GtkWidget *Window; GtkWidget *HatLabel; GtkWidget *PlugBox; @@ -82,6 +76,7 @@ typedef struct { GtkWidget *DocumentationMenuItem; GtkWidget *AboutMenuItem; + // Custom } main_window; @@ -97,7 +92,6 @@ typedef struct { GtkWidget *AcceptButton; } documentation_confirmation_window; - main_window *setup_window(); void on_about(); void yon_open_browser(GtkWidget *self, char *link); @@ -106,6 +100,6 @@ void on_link(GtkWidget *self, char* uri, gpointer user_data); void on_open_documentation_confirmation(GtkWidget *self, char *link); void yon_load_proceed(char *command); void event(main_window *widgets); -int main(int argc, char *argv[]); + void on_link(GtkWidget *self, char* uri, gpointer user_data); void config_init(); diff --git a/source/ubl-strings.h b/source/ubl-strings.h index 87d311e..cc9a345 100644 --- a/source/ubl-strings.h +++ b/source/ubl-strings.h @@ -1,8 +1,8 @@ #define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) -#define HELP_LABEL yon_char_unite(_("ubl-settings-diskquota version:")," ", version_application,"\n",_("TEMPLATE settings"),"\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 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 _("TEMPLATE Manager") -#define TITLE_INFO_LABEL _("System TEMPLATE settings management") +#define TITLE_LABEL _("") +#define TITLE_INFO_LABEL _("") #define SUCCESS_LABEL _("Operation succeeded") #define ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked") @@ -36,4 +36,20 @@ #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 SAVE_FAILED_LABEL \ No newline at end of file +#define SAVE_FAILED_LABEL + +#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 --default --target global set security" +#define CMD_SAVE_SYSTEM "ubconfig --default --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 CMD_GET_SLICE_SERVICE "systemd-cgls --no-page" \ No newline at end of file diff --git a/source/view/model/load.cc b/source/view/model/load.cc deleted file mode 100644 index 77873dc..0000000 --- a/source/view/model/load.cc +++ /dev/null @@ -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& Load::get_load_data(std::map &map_temp, string cmd) { - string response = ""; - string key = ""; - string value = ""; - response = process.call_all_sections(cmd); - vector 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(); - } - -} \ No newline at end of file diff --git a/source/view/model/load.h b/source/view/model/load.h deleted file mode 100644 index b4d4a38..0000000 --- a/source/view/model/load.h +++ /dev/null @@ -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& get_load_data(std::map &map_temp, string str_flag_load); - }; - - -} -#endif \ No newline at end of file diff --git a/source/view/model/my_process.cc b/source/view/model/my_process.cc deleted file mode 100644 index 658afd5..0000000 --- a/source/view/model/my_process.cc +++ /dev/null @@ -1,84 +0,0 @@ -#include "my_process.h" -#include "util.h" - -namespace My_Process { -#define debug false -struct Utils::Result My_Process_call::call(string cmd) { - this->i_error_old = this->i_error; - struct Utils::Result 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; -} -} \ No newline at end of file diff --git a/source/view/model/my_process.h b/source/view/model/my_process.h deleted file mode 100644 index 3cc6f81..0000000 --- a/source/view/model/my_process.h +++ /dev/null @@ -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 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 \ No newline at end of file diff --git a/source/view/model/save.cc b/source/view/model/save.cc deleted file mode 100644 index c824093..0000000 --- a/source/view/model/save.cc +++ /dev/null @@ -1,151 +0,0 @@ -#include "save.h" - -namespace Lib_save { - -vector Save::get_error() { - return this->vec_errors; -} - -bool Save::get_state_save() { - return this->flag_no_save; -} - -void Save::set_data_global(std::map &map_global) { - this->map_global = &map_global; -} - -void Save::set_data_local(std::map &map_local) { - this->map_local = &map_local; -} - -void Save::set_data_gui(std::map &map_gui) { - this->map_gui = &map_gui; -} - -bool Save::check_save(string flag_save, string key_name) { - std::map :: iterator iter_map_data; - std::map :: iterator iter_map_data_old; - std::map *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& 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 = ""; - } - -} - -} diff --git a/source/view/model/save.h b/source/view/model/save.h deleted file mode 100644 index d6c8c04..0000000 --- a/source/view/model/save.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef MY_SAVE_H -#define MY_SAVE_H - -#include "my_process.h" -namespace Lib_save { - -class Save { -private: - std::map *map_global; - std::map *map_local; - std::map *map_gui; - vector vec_errors; - vector* 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 &map_global); - void set_data_local(std::map &map_local); - void set_data_gui(std::map &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& vec_param_names); - void save(string sections, string str_flag_save) ; - vector get_error(); -}; -} -#endif \ No newline at end of file diff --git a/source/view/model/util.cc b/source/view/model/util.cc deleted file mode 100644 index c3cd4c6..0000000 --- a/source/view/model/util.cc +++ /dev/null @@ -1,252 +0,0 @@ -#include "util.h" -#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) -namespace Utils { - -string format_str_size(int num, int index) { - string value = ""; - value = to_string(num); - if (num == 0) { - return value; - } - if (index == 1) { - value += "M"; - } - else if (index == 2) { - value += "G"; - } - else if (index == 3) { - value += "T"; - } - return value; -} - -array, 5> read_csv(const string& filename) { - array, 5> array_vectors; - vector vec_option; - vector vec_opcision; - ifstream file(filename); - string line; - char delimiter = ','; - getline(file, line); - while (getline(file, line)) { - stringstream stream(line); - string option; - string opcision; - getline(stream, option, delimiter); - string line_local = stream.str(); - if (line_local.find("\"") != string::npos) { - string str_delimiter = "\""; - vector point = find_all(line_local, str_delimiter); - size_t len = point.size(); - if (len >= 2) { - int index_start = point[len-2]; - int index_end = point[len-1]; - opcision = line_local.substr(index_start, index_end); - index_end = opcision.find("\""); - if (opcision.find("\"") != string::npos) { - opcision.replace(index_end, opcision.length(), ""); - } - - } - else { - opcision = "error"; - } - - - } - else{ - getline(stream, opcision, delimiter); - } - - - vec_option.push_back(option); - vec_opcision.push_back(opcision); - } - - array_vectors[0] = vec_option; - array_vectors[1] = vec_opcision; - return array_vectors; -} - -string call(string cmd) { - FILE *fp; - int status; - char path[PATH_MAX] = {0}; - fp = popen(cmd.c_str(), "r"); - if (fp == NULL) { - exit(1); - } - while (fgets(path, PATH_MAX, fp) != NULL) { - break; - } - status = pclose(fp); - if (status == -1) { - exit(1); - } - return path; -} - -vector find_all(string &str_ntp, string substr) { - size_t index = 0; - vector sub_index; - while ((index = str_ntp.find(substr, index)) != std::string::npos) { - index += substr.length(); - sub_index.push_back(index); - } - return sub_index; -} - -void str_remove(std::string& source, std::string to_remove) { - string::size_type n = to_remove.length(); - for (string::size_type i = source.find(to_remove); - i != string::npos; - i = source.find(to_remove)) - source.erase(i, n); -} - -void str_replace_all(std::string& str_base, string str_find, string sReplacement) -{ - size_t pos = 0, fpos; - while ((fpos = str_base.find(str_find, pos)) != std::string::npos) - { - str_base.replace(fpos, str_find.size(), sReplacement); - pos = fpos + sReplacement.size(); - } -} -std::vector split(std::string text, char delim) { - std::string line; - std::vector vec; - std::stringstream ss(text); - while(std::getline(ss, line, delim)) { - vec.push_back(line); - } - return vec; -} - -int synopsis_show(string str_link) { - // gettext("https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/") - string cmd = "xdg-open " + str_link; - if (geteuid() == 0) { - string response_user = getlogin(); - cmd = "su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \""; - } - return system(cmd.c_str()); -} - -string file_read(string filename) { - string line; - string buffer; - std::ifstream in(filename); // окрываем файл для чтения - if (in.is_open()) - { - while (getline(in, line)) - { - buffer += line; - } - } - return buffer; -} - -unsigned short read_uid_min_max(string filename, string search) { - std::string line; - int uid = 0; - string remove_tab = "\t"; - string remove_space = " "; - std::ifstream in(filename); // окрываем файл для чтения - if (in.is_open()){ - while (getline(in, line)){ - try{ - if (line.find(search) != string::npos && (line.find("SYS_"+search) == string::npos)) { - Utils::str_remove(line, search); - Utils::str_remove(line, remove_space); - Utils::str_remove(line, remove_tab); - uid = atoi(line.c_str()); - } - } - catch (int x) { - if (search == "UID_MIN"){ - uid = 1000; - } - else{ - uid = 65534; - } - - } - - } - } - else{ - if (search == "UID_MIN") { - uid = 1000; - } - else{ - uid = 65534; - } - } - in.close(); - return uid; - -} - -vector pars_users() { - unsigned short uid_min = Utils::read_uid_min_max(file_source_login_min_max, "UID_MIN"); - unsigned short uid_max = Utils::read_uid_min_max(file_source_login_min_max, "UID_MAX"); - vector vec_user; - while (true) { - errno = 0; - passwd* entry = getpwent(); - if (!entry) { - if (errno) { - break; - } - break; - } - if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { - vec_user.push_back(entry->pw_name); - } - } - endpwent(); - return vec_user; -} - -vector list_groups() { - string str_uid_min = "UID_MIN"; - string str_uid_max = "UID_MAX"; - unsigned short uid_min = Utils::read_uid_min_max(file_source_login_min_max, "UID_MIN"); - unsigned short uid_max = Utils::read_uid_min_max(file_source_login_min_max, "UID_MAX"); - vector str_users; - while (1) { - errno = 0; - struct passwd* entry = getpwent(); - if (!entry) { - if (errno) { - return str_users; - } - break; - } - if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { - str_users.push_back(entry->pw_name); - } - } - endpwent(); - return str_users; -} - -vector pars_group() { - vector vec_group; - while (true) { - errno = 0; // so we can distinguish errors from no more entries - passwd* entry = getpwent(); - if (!entry) { - if (errno) { - std::cerr << "Error reading password database\n"; - break; - } - break; - } - vec_group.push_back(entry->pw_name); - } - endpwent(); - return vec_group; -} -} \ No newline at end of file diff --git a/source/view/model/util.h b/source/view/model/util.h deleted file mode 100644 index b93db49..0000000 --- a/source/view/model/util.h +++ /dev/null @@ -1,35 +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 -struct Result{ - Type response; - int error; -}; - -struct Passwd { - string user; - int uid; -}; - -string format_str_size(int num, int index); -std::array, 5> read_csv(const std::string& filename); -std::string call(std::string cmd); -vector 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 split(std::string text, char delim); -vector pars_users(); -int synopsis_show(string str_link); -string file_read(string filename); -unsigned short read_uid_min_max(string filename, string search); -vector pars_users(); -vector pars_group(); -vector list_groups(); -} -#endif \ No newline at end of file diff --git a/source/view/model/wrapper_load_save.cc b/source/view/model/wrapper_load_save.cc deleted file mode 100644 index 5988735..0000000 --- a/source/view/model/wrapper_load_save.cc +++ /dev/null @@ -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 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 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: - // Написать функцию -} \ No newline at end of file diff --git a/source/view/model/wrapper_load_save.h b/source/view/model/wrapper_load_save.h deleted file mode 100644 index 5562ff4..0000000 --- a/source/view/model/wrapper_load_save.h +++ /dev/null @@ -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 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 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 \ No newline at end of file diff --git a/source/view/view_add_project.cc b/source/view/view_add_project.cc deleted file mode 100644 index b0a08e1..0000000 --- a/source/view/view_add_project.cc +++ /dev/null @@ -1,141 +0,0 @@ -#include "view_add_project.h" -#include - -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(); - // ector vec_user = pars_users(); - -} - -void View_add_project::load_combo_box_UGP(vector vec_UGP) { - cmbSetNameUGP->remove_all(); - for (auto& iter: vec_UGP) { - cmbSetNameUGP->append(iter); - } -} - -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::lacalization() { - -} - -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::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()); -} - diff --git a/source/view/view_add_project.h b/source/view/view_add_project.h deleted file mode 100644 index ae8a079..0000000 --- a/source/view/view_add_project.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef VIEW_ADD_PROJECT_H -#define VIEW_ADD_PROJECT_H -#include "../project_lib.h" -#include "model/util.h" -#include "../var.h" -class View_add_project -{ -private: - Glib::RefPtr 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; - Gtk::ComboBoxText* cmbSetNameUGP; - -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 show_file_manager(); - void save_file_manager(); - void load_combo_box_UGP(vector vec_UGP); -}; - - - - -#endif \ No newline at end of file diff --git a/source/view/view_add_user_group.cc b/source/view/view_add_user_group.cc deleted file mode 100644 index c70f838..0000000 --- a/source/view/view_add_user_group.cc +++ /dev/null @@ -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); -} diff --git a/source/view/view_add_user_group.h b/source/view/view_add_user_group.h deleted file mode 100644 index 27a4b99..0000000 --- a/source/view/view_add_user_group.h +++ /dev/null @@ -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 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* 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* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); - void edit_tree_view_G(Glib::RefPtr* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); - void edit_tree_view_P(Glib::RefPtr* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate); -}; - -#endif \ No newline at end of file diff --git a/source/view/view_edit_project.cc b/source/view/view_edit_project.cc deleted file mode 100644 index 5d7d579..0000000 --- a/source/view/view_edit_project.cc +++ /dev/null @@ -1,116 +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() { - -} - - -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()); -} \ No newline at end of file diff --git a/source/view/view_edit_project.h b/source/view/view_edit_project.h deleted file mode 100644 index 239a999..0000000 --- a/source/view/view_edit_project.h +++ /dev/null @@ -1,58 +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 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 close_wnd(); - void save(); -}; - - - - -#endif \ No newline at end of file diff --git a/source/view/view_edit_user_group.cc b/source/view/view_edit_user_group.cc deleted file mode 100644 index 3ce3b1c..0000000 --- a/source/view/view_edit_user_group.cc +++ /dev/null @@ -1,107 +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() { - -} - - -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::set_label_type_quota(string name) { - lblSetUGPUser->set_text(name); -} -void View_edit_user_group::show() { - wndQuotasEditUser->show(); -} \ No newline at end of file diff --git a/source/view/view_edit_user_group.h b/source/view/view_edit_user_group.h deleted file mode 100644 index 3b9d82a..0000000 --- a/source/view/view_edit_user_group.h +++ /dev/null @@ -1,60 +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 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 set_label_type_quota(string name); - void lacalization(); -}; - - - - -#endif \ No newline at end of file diff --git a/source/view_add_p.c b/source/view_add_p.c new file mode 100644 index 0000000..e69de29 diff --git a/source/view_add_p.h b/source/view_add_p.h new file mode 100644 index 0000000..e69de29 diff --git a/source/view_add_u_g.c b/source/view_add_u_g.c new file mode 100644 index 0000000..e69de29 diff --git a/source/view_add_u_g.h b/source/view_add_u_g.h new file mode 100644 index 0000000..e69de29 diff --git a/source/view_edit_p.c b/source/view_edit_p.c new file mode 100644 index 0000000..e69de29 diff --git a/source/view_edit_p.h b/source/view_edit_p.h new file mode 100644 index 0000000..e69de29 diff --git a/source/view_edit_u_g.c b/source/view_edit_u_g.c new file mode 100644 index 0000000..e69de29 diff --git a/source/view_edit_u_g.h b/source/view_edit_u_g.h new file mode 100644 index 0000000..e69de29 diff --git a/source/view/view_filters.cc b/source/view_filters.c similarity index 100% rename from source/view/view_filters.cc rename to source/view_filters.c diff --git a/source/view/view_filters.h b/source/view_filters.h similarity index 100% rename from source/view/view_filters.h rename to source/view_filters.h diff --git a/ubl-settings-diskquota b/ubl-settings-diskquota new file mode 100755 index 0000000..c5075ae Binary files /dev/null and b/ubl-settings-diskquota differ diff --git a/ubl-settings-diskquota.glade b/ubl-settings-diskquota.glade index 2108af7..d240446 100644 --- a/ubl-settings-diskquota.glade +++ b/ubl-settings-diskquota.glade @@ -53,7 +53,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. vertical 2 - + False end @@ -63,13 +63,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 1 + + + True False - True True @@ -79,7 +81,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 5 5 2 - TEMPLATE Manager @@ -550,6 +551,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True + 7 0 @@ -566,6 +568,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 5 5 5 + + KB + MB + GB + TB + False @@ -627,6 +635,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True + 7 0 @@ -643,6 +652,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 5 5 5 + + KB + MB + GB + TB + False @@ -765,6 +780,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True + 7 0 @@ -838,6 +854,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True True + 7 0 @@ -1127,6 +1144,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. True False + 5 + 5 5 5 5 @@ -1295,12 +1314,10 @@ translated and supported by community. True False - True True False - TEMPLATE Manager @@ -1339,28 +1356,6 @@ translated and supported by community. False False False - - - True - False - Documentation - True - - - - - - True - False - About - - - True @@ -1679,7 +1674,7 @@ limitation - False + True True 0 @@ -1841,6 +1836,7 @@ limitation 5 5 5 + 4 False @@ -1888,6 +1884,7 @@ limitation 5 5 5 + 4 False @@ -1948,6 +1945,7 @@ limitation 5 5 5 + 4 False @@ -1995,6 +1993,7 @@ limitation 5 5 5 + 4 False @@ -2055,6 +2054,7 @@ limitation 5 5 5 + 4 False @@ -2102,6 +2102,7 @@ limitation 5 5 5 + 4 False @@ -2162,6 +2163,7 @@ limitation 5 5 5 + 4 False @@ -2209,6 +2211,7 @@ limitation 5 5 5 + 4 False @@ -2380,7 +2383,7 @@ limitation - False + True True 2 @@ -2714,6 +2717,7 @@ limitation 5 5 5 + 4 False @@ -2761,6 +2765,7 @@ limitation 5 5 5 + 4 False @@ -2821,6 +2826,7 @@ limitation 5 5 5 + 4 False @@ -2868,6 +2874,7 @@ limitation 5 5 5 + 4 False @@ -2928,6 +2935,7 @@ limitation 5 5 5 + 4 False @@ -2975,6 +2983,7 @@ limitation 5 5 5 + 4 False @@ -3035,6 +3044,7 @@ limitation 5 5 5 + 4 False @@ -3082,6 +3092,7 @@ limitation 5 5 5 + 4 False @@ -3253,7 +3264,7 @@ limitation - False + True True 2 @@ -3587,6 +3598,7 @@ limitation 5 5 5 + 4 False @@ -3634,6 +3646,7 @@ limitation 5 5 5 + 4 False @@ -3694,6 +3707,7 @@ limitation 5 5 5 + 4 False @@ -3741,6 +3755,7 @@ limitation 5 5 5 + 4 False @@ -3801,6 +3816,7 @@ limitation 5 5 5 + 4 False @@ -3848,6 +3864,7 @@ limitation 5 5 5 + 4 False @@ -3908,6 +3925,7 @@ limitation 5 5 5 + 4 False @@ -3955,6 +3973,7 @@ limitation 5 5 5 + 4 False @@ -4016,7 +4035,7 @@ limitation True True - ListProject + ListGroups 0 @@ -4135,7 +4154,7 @@ limitation - False + True True 2 @@ -4564,35 +4583,6 @@ limitation 1 10 - - False - Please select File - True - center - 500 - 400 - True - com.ublinux.ublexec - dialog - True - True - select-folder - - - False - - - False - - - False - False - 0 - - - - - False start @@ -4810,6 +4800,7 @@ limitation True True False + start True @@ -5112,6 +5103,7 @@ limitation Generate + True True True @@ -5279,6 +5271,7 @@ limitation True True + 7 0 @@ -5295,6 +5288,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -5356,6 +5355,7 @@ limitation True True + 7 0 @@ -5372,6 +5372,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -5498,6 +5504,7 @@ limitation True True + 7 0 @@ -5558,7 +5565,9 @@ limitation True True False + 5 5 + 5 5 5 5 @@ -5575,6 +5584,7 @@ limitation True True + 7 0 @@ -6066,6 +6076,7 @@ limitation True True + 7 0 @@ -6082,6 +6093,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -6143,6 +6160,7 @@ limitation True True + 7 0 @@ -6159,6 +6177,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -6285,6 +6309,7 @@ limitation True True + 7 0 @@ -6364,6 +6389,7 @@ limitation True True + 7 0 @@ -6776,6 +6802,7 @@ limitation True True + 7 0 @@ -6792,6 +6819,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -6853,6 +6886,7 @@ limitation True True + 7 0 @@ -6869,6 +6903,12 @@ limitation 5 5 5 + + KB + MB + GB + TB + False @@ -6995,6 +7035,7 @@ limitation True True + 7 0 @@ -7074,6 +7115,7 @@ limitation True True + 7 0 diff --git a/ubl-settings-diskquota_ru.po b/ubl-settings-diskquota_ru.po index cfdb42b..814ebd0 100644 --- a/ubl-settings-diskquota_ru.po +++ b/ubl-settings-diskquota_ru.po @@ -16,6 +16,125 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit" +#: source/ubl-strings.h:1 + +msgid "Version:" +msgstr "Версия:" + +#: source/ubl-strings.h:2 +msgid "ubl-settings-TEMPLATE version:" +msgstr "Версия ubl-settings-TEMPLATE: " + +#: source/ubl-strings.h:2 +msgid "TEMPLATE settings" +msgstr "Настройки TEMPLATE" + +#: source/ubl-strings.h:2 +msgid "Usage:" +msgstr "Использование:" + +#: source/ubl-strings.h:2 +msgid "[OPTIONS]" +msgstr "[АРГУМЕНТЫ]" + +#: source/ubl-strings.h:2 +msgid "Options:" +msgstr "Аргументы:" + +#: source/ubl-strings.h:2 +msgid "Show this help" +msgstr "Показать параметры справки" + +#: source/ubl-strings.h:2 +msgid "Show package version" +msgstr "Показать текущую версию" + +#: source/ubl-strings.h:2 +msgid "Lock this help menu" +msgstr "Блокировка вызова справки" + +#: source/ubl-strings.h:2 +#, fuzzy +msgid "Lock configuration saving" +msgstr "Блокировка сохранения локальной и глобальной конфигурации" + +#: source/ubl-strings.h:2 +msgid "Lock local configration saving" +msgstr "Блокировка сохранения локальной конфигурации" + +#: source/ubl-strings.h:2 +msgid "Lock global configration saving" +msgstr "Блокировка сохранения глобальной конфигурации" + +#: source/ubl-strings.h:2 +msgid "Lock global configration loading" +msgstr "Блокировка загрузки глобальной конфигурации" + +#: source/ubl-strings.h:4 +msgid "TEMPLATE Manager" +msgstr "Настройки TEMPLATE" + +#: source/ubl-strings.h:5 +msgid "System TEMPLATE settings management" +msgstr "Настройки TEMPLATE" + +#: source/ubl-strings.h:7 +msgid "Operation succeeded" +msgstr "Операция завершена" + +#: source/ubl-strings.h:8 +msgid "" +"Warning! Application was launched without root - root-dependent actions are " +"locked" +msgstr "Внимание! Приложение было запущено без прав суперпользователя - действия, требующие их наличия заблокированы" + +#: source/ubl-strings.h:11 +msgid "Documentation" +msgstr "Справка" + +#: source/ubl-strings.h:12 +msgid "Save to local configuration" +msgstr "Сохранить в локальную конфигурацию" + +#: source/ubl-strings.h:13 +msgid "Save to global configuration" +msgstr "Сохранить в глобальную конфигурацию" + +#: source/ubl-strings.h:14 +msgid "Save configuration" +msgstr "Сохранить конфигурацию" + +#: source/ubl-strings.h:24 +msgid "Always redirect to online documentation" +msgstr "Всегда перенаправлять" + +#: source/ubl-strings.h:25 +msgid "Open documentation" +msgstr "Прочитать справку" + +#: source/ubl-strings.h:27 +msgid "Nothing were chosen" +msgstr "Ничего не было выбрано" + +#: source/ubl-strings.h:30 +msgid "Global configuration loading succseeded." +msgstr "Успешно загружена глобальная конфигурация" + +#: source/ubl-strings.h:31 +msgid "Local configuration loading succseeded." +msgstr "Успешно загружена локальная конфигурация" + +#: source/ubl-strings.h:33 +msgid "Local and global configuration saving succseeded." +msgstr "Успешно записаны локальная и глобальная конфигурация" + +#: source/ubl-strings.h:34 +msgid "Global configuration saving succseeded." +msgstr "Успешно записана глобальная конфигурация" + +#: source/ubl-strings.h:35 +msgid "Local configuration saving succseeded." +msgstr "Успешно записана локальная конфигурация" msgid "Off" msgstr "Выключено"