diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..caa5726 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.vscode/ +ubl-settings-resourcequota.glade~ +ubl-settings-resourcequota_ru.po~ +source/ubl-cmake.h +ubl-settings-resourcequota \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6b214de --- /dev/null +++ b/Makefile @@ -0,0 +1,161 @@ +#!/usr/bin/make -f + +#SHELL := /bin/bash +MAKEFILE_FILEPATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MAKEFILE_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_FILEPATH)))) +MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH)) + +CMAKE_COMMAND = cmake +CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source +CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile +#CMAKE_SOURCE_DIR = ./source +#CMAKE_BUILD_DIR = ./compile +FILE_VERSION = VERSION.md +DEPENDS = /bin/cmake +PREFIX ?= /usr +PKGNAME = $(MAKEFILE_DIR) +#PKGNAME = ubl-settings-manager + +default_target: all + +.PHONY: all init depend debug prepare check build uninstall install clean up_ver help + +all: init build + +init: + @echo "Initialize ..."; \ + sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-resourcequota.h; \ + echo "-- Build path: ${CMAKE_BUILD_DIR}" + +depend: + @echo "Check depends ..." + @for FILE_DEPEND in $(DEPENDS); do \ + if [ ! -f $${FILE_DEPEND} ]; then \ + echo "ERROR: Depend '$${FILE_DEPEND}' not found !"; \ + exit 1; \ + fi; \ + done; \ + echo "Check depends: OK" +# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 + +debug: + @echo "Debug ..." + if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ + $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ + fi; \ + echo "Debug: OK" + +prepare: + @echo "Prepare ..."; \ + if [ ! -d ${CMAKE_BUILD_DIR} ]; then \ + $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \ + fi; \ + echo "Prepare: OK" + +check: + @echo "Check ..."; \ + if [ -f ${CMAKE_BUILD_DIR}/${PKGNAME} ]; then \ + echo "Check: OK"; \ + else \ + echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not found !"; \ + exit 1; \ + fi + +build: depend prepare + @echo "Build ..."; \ + make --directory=${CMAKE_BUILD_DIR}; \ + echo "Build: OK" + +uninstall: + @echo "Uninstall ..." + @for FILE_PO in $(wildcard *.po); do \ + LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ + FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ + PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + $(RM) "$${PATH_FILE_MO}"; \ + done + @for SIZE in 16x16 32x32 48x48 scalable; do \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \ + done + @for FILE_SVG in $(wildcard *.svg); do \ + for SIZE in 16x16 32x32 48x48 scalable; do \ + $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \ + done; \ + done + @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}" + @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop" + @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg" + @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/${PKGNAME}-banner.png" + @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}" + @if [ -z ${DESTDIR} ]; then \ + [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ + update-desktop-database --quiet &>/dev/null || true; \ + [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + fi + @echo "Uninstall: OK" + +install: check uninstall + @cc source/my_device.c source/my_device.h source/filters.c source/filters.h source/ubl-cmake.h source/view_edit.h source/view_edit.c source/view_add.h source/view_add.c source/ubl-utils.h source/ubl-utils.c source/ubl-strings.h source/ubl-settings-resourcequota.h source/ubl-settings-resourcequota.c -o ubl-settings-resourcequota `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g + @echo "Install ..." + @for FILE_PO in $(wildcard *.po); do \ + LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ + install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \ + FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ + PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + echo "$${FILE_PO}"; \ + msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ + done + @for SIZE in 16 32 48; do \ + install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ + rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \ + done + @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" + @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" + @install -dm755 "${DESTDIR}/etc/xdg" + @install -dm755 "${DESTDIR}${PREFIX}/share/applications" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" + @install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images} + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css" + @install -dm755 -d "${DESTDIR}${PREFIX}/share/${PKGNAME}/images" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "${PKGNAME}-banner.png" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg" + @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.ubl-settings-resourcequota.funnel.svg" + @if [ -z ${DESTDIR} ]; then \ + [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \ + update-desktop-database --quiet &>/dev/null || true; \ + [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \ + fi + @echo "Install: OK" + +clean: + @echo "Clean ..." + @$(RM) -rd ${CMAKE_BUILD_DIR} + @if [ -d ${CMAKE_BUILD_DIR} ]; then \ + echo "Clean: error, compile directory exist ${CMAKE_BUILD_DIR}"; \ + else \ + echo "Clean: OK"; \ + fi + +up_ver: + @CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \ + MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \ + MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \ + VER="$${MAJOR}.$$(($${MINOR}+1))"; \ + sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \ + echo "Updated version to VERSION.md: $${CURRENT} to $${VER}" + +help: + @echo "The following are some of the valid targets for this Makefile:"; \ + echo "... all (the default if no target is provided)"; \ + echo "... init"; \ + echo "... debug"; \ + echo "... prepare"; \ + echo "... compile"; \ + echo "... install"; \ + echo "... uninstall"; \ + echo "... clean"; \ + echo "... up_ver" diff --git a/README.md b/README.md index fcf7c41..516bb46 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,49 @@ # ubl-settings-resourcequota +# Настройки квот +[RU] Утилита для настройки квот процессора и ОЗУ +Utility for setting the disk quotas + +![alt text](screenshot/screenshot.png) + +# Build +In order to build ubl-settings-resourcequota you will need: + +- CMake +- C compiler +- GTK+ 3 & dependencies + +Once you have all the necessary dependencies, you can use: +```sh +$ make +``` + +# Installation +After a successful build, just use: +```sh +$ sudo make install clean +``` + +# Uninstallation +After a successful build, just use: +```sh +$ sudo make uninstall +``` +# Usage +```sh +$ ubl-settings-resourcequota --help +GTK settings resource quota for UBLinux + +Usage: ubl-settings-resourcequota [OPTIONS...] +Options: + -h, --help Show this help + -V, --version Show package version + --lock-help Lock utility help + --lock-save Lock saving local and global configuration + --lock-save-local Lock save global configuration + --lock-save-global Lock load global configuration + --lock-load-global Lock load global configuration + +$ ubl-settings-resourcequota --version +ubl-settings-resourcequota version: x.xx +``` diff --git a/VERSION.md b/VERSION.md new file mode 100644 index 0000000..12ebd01 --- /dev/null +++ b/VERSION.md @@ -0,0 +1 @@ +VERSION 1.0 diff --git a/com.ublinux.ubl-settings-resourcequota.checked.svg b/com.ublinux.ubl-settings-resourcequota.checked.svg new file mode 100644 index 0000000..e3cab42 --- /dev/null +++ b/com.ublinux.ubl-settings-resourcequota.checked.svg @@ -0,0 +1,327 @@ + + + + + + + + + + + + + + + + diff --git a/com.ublinux.ubl-settings-resourcequota.funnel.svg b/com.ublinux.ubl-settings-resourcequota.funnel.svg new file mode 100644 index 0000000..4aec04a --- /dev/null +++ b/com.ublinux.ubl-settings-resourcequota.funnel.svg @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/com.ublinux.ubl-settings-resourcequota.policy b/com.ublinux.ubl-settings-resourcequota.policy new file mode 100644 index 0000000..7ddcc9b --- /dev/null +++ b/com.ublinux.ubl-settings-resourcequota.policy @@ -0,0 +1,24 @@ + + + + + UBLinux + https://ublinux.ru + + + Run "ubl-settings-resourcequota" as root + Запуск утилиты ubl-settings-resourcequota с правами root + Authentication is required to run ubl-settings-resourcequota + Требуется авторизация для запуска утилиты ubl-settings-resourcequota с правами root + + auth_admin + auth_admin + auth_admin + + /usr/bin/ubl-settings-resourcequota + true + + + diff --git a/com.ublinux.ubl-settings-resourcequota.svg b/com.ublinux.ubl-settings-resourcequota.svg new file mode 100644 index 0000000..fd135ba --- /dev/null +++ b/com.ublinux.ubl-settings-resourcequota.svg @@ -0,0 +1,6175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.ublinux.ubl-settings-resourcequota.warning.svg b/com.ublinux.ubl-settings-resourcequota.warning.svg new file mode 100644 index 0000000..9a90dba --- /dev/null +++ b/com.ublinux.ubl-settings-resourcequota.warning.svg @@ -0,0 +1,55 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/screenshot/screenshot.png b/screenshot/screenshot.png new file mode 100644 index 0000000..e2b4d59 Binary files /dev/null and b/screenshot/screenshot.png differ diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt new file mode 100644 index 0000000..b61aca0 --- /dev/null +++ b/source/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 3.23) +project(ubl-settings-resourcequota) + +find_package(PkgConfig REQUIRED) + +pkg_check_modules(GTK3 REQUIRED gtk+-3.0) +include_directories(${GTK3_INCLUDE_DIRS}) +link_directories(${GTK3_LIBRARY_DIRS}) +add_definitions(${GTK3_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) + +option(WEBKIT_FOUND "No" OFF) +if(WEBKIT_LIBRARIES_FOUND) + option(WEBKIT_FOUND "Yes" ON) + PKG_CHECK_MODULES(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0) + include_directories(${WEBKIT_INCLUDE_DIRS}) + link_directories(${WEBKIT_LIBRARY_DIRS}) + add_definitions(${WEBKIT_CFLAGS_OTHER}) +endif() + +configure_file(ubl-cmake.h.in ubl-cmake.h) + +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -lm") +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") + +set(SOURCE_FILES + ubl-settings-resourcequota.c + ubl-settings-resourcequota.h + my_device.c + my_device.h + filters.c + filters.h + view_add.c + view_add.h + view_edit.c + view_edit.h + ubl-strings.h + ubl-utils.h + ubl-utils.c + ubl-cmake.h) + +set(LIBRARIES + ${GTK3_LIBRARIES} + ${WEBKIT_LIBRARIES} + ${VTE291_LIBRARIES} + pthread) + +add_executable(${PROJECT_NAME} ${SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} PUBLIC ${LIBRARIES}) +target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_BINARY_DIR}) +install(TARGETS ${PROJECT_NAME} DESTINATION bin) \ No newline at end of file diff --git a/source/filters.c b/source/filters.c new file mode 100644 index 0000000..c5f816e --- /dev/null +++ b/source/filters.c @@ -0,0 +1,90 @@ +#include "filters.h" + +filters_window *filters_widgets = NULL; +gboolean flag_filters[8]; +filters_window *filters_setup_window(char* glade_path){ + if (filters_widgets == NULL) { + filters_widgets = malloc(sizeof(filters_window)); + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + filters_widgets->Window = yon_gtk_builder_get_widget(builder,"wndFilters"); + filters_widgets->chbFilterTypeQouota = yon_gtk_builder_get_widget(builder,"chbFilterTypeQouota"); + filters_widgets->chbQuotaVolume = yon_gtk_builder_get_widget(builder,"chbQuotaVolume"); + filters_widgets->chbSoftLimit = yon_gtk_builder_get_widget(builder,"chbSoftLimit"); + filters_widgets->chbHardLimit = yon_gtk_builder_get_widget(builder,"chbHardLimit"); + filters_widgets->chbSwapFileLimit = yon_gtk_builder_get_widget(builder,"chbSwapFileLimit"); + filters_widgets->chbIOLimitWrite = yon_gtk_builder_get_widget(builder,"chbIOLimitWrite"); + filters_widgets->chbCPULimit = yon_gtk_builder_get_widget(builder,"chbCPULimit"); + filters_widgets->chbIOLimitRead = yon_gtk_builder_get_widget(builder,"chbIOLimitRead"); + filters_widgets->btnFiltersCancel = yon_gtk_builder_get_widget(builder,"btnFiltersCancel"); + filters_widgets->btnFiltersSave = yon_gtk_builder_get_widget(builder,"btnFiltersSave"); + filters_event(filters_widgets); + } + filters_set_flag(); + return filters_widgets; +} + +void filters_event(filters_window *widgets) { + g_signal_connect(G_OBJECT(widgets->btnFiltersCancel), "clicked",G_CALLBACK(filters_on_hide_subwindow),NULL); + g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(filters_destroy), NULL); +} + +void filters_destroy(GtkWidget *self) { + filters_widgets = NULL; +} + +void filters_localization(filters_window *widgets) { + +} + +void filters_on_hide_subwindow(GtkWidget *self) { + gtk_widget_destroy(gtk_widget_get_toplevel(self)); + filters_widgets = NULL; +} + +filters_window *get_widget_filters() { + return filters_widgets; +} + +void filters_show(GtkWidget *self, char* glade_path) { + if (filters_widgets != NULL) { + gtk_widget_show_all(filters_widgets->Window); + } + else { + filters_setup_window(glade_path); + gtk_widget_show_all(filters_widgets->Window); + } +} + +gboolean* filters_get_flag() { + flag_filters[0] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterTypeQouota)); + flag_filters[1] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbQuotaVolume)); + flag_filters[2] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbSoftLimit)); + flag_filters[3] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbHardLimit)); + flag_filters[4] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbSwapFileLimit)); + flag_filters[5] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbCPULimit)); + flag_filters[6] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbIOLimitWrite)); + flag_filters[7] = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(filters_widgets->chbIOLimitRead)); + return flag_filters; +} + +void filters_init_flag() { + flag_filters[0] = 1; + flag_filters[1] = 1; + flag_filters[2] = 1; + flag_filters[3] = 1; + flag_filters[4] = 1; + flag_filters[5] = 1; + flag_filters[6] = 1; + flag_filters[7] = 1; +} + +void filters_set_flag() { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbFilterTypeQouota),flag_filters[0] ); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbQuotaVolume), flag_filters[1]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbSoftLimit), flag_filters[2]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbHardLimit), flag_filters[3]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbSwapFileLimit), flag_filters[4]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbCPULimit), flag_filters[5]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbIOLimitWrite), flag_filters[6]); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(filters_widgets->chbIOLimitRead), flag_filters[7]); +} \ No newline at end of file diff --git a/source/filters.h b/source/filters.h new file mode 100644 index 0000000..96025df --- /dev/null +++ b/source/filters.h @@ -0,0 +1,42 @@ +#ifndef FILTERS_H +#define FILTERS_H +#include +#include +#include "ubl-utils.h" +#include "ubl-strings.h" +#include +#include +#include +#include +#include +#include +#include + + +// Переменные +typedef struct { + GtkWidget* Window; + GtkWidget* btnFiltersSave; + GtkWidget* btnFiltersCancel; + GtkWidget* chbFilterTypeQouota; + GtkWidget* chbCPULimit; + GtkWidget* chbIOLimitRead; + GtkWidget* chbIOLimitWrite; + GtkWidget* chbSwapFileLimit; + GtkWidget* chbHardLimit; + GtkWidget* chbSoftLimit; + GtkWidget* chbQuotaVolume; +} filters_window; + +// Функции +filters_window *filters_setup_window(char* glade_path); +void filters_event(filters_window *widgets); +void filters_localization(filters_window *widgets); +void filters_on_hide_subwindow(GtkWidget *self); +filters_window *get_widget_filters(); +void filters_show(GtkWidget *self, char* glade_path); +void filters_destroy(GtkWidget *self); +int* filters_get_flag(); +void filters_init_flag(); +void filters_set_flag(); +#endif \ No newline at end of file diff --git a/source/my_device.c b/source/my_device.c new file mode 100644 index 0000000..995306d --- /dev/null +++ b/source/my_device.c @@ -0,0 +1,58 @@ +#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); + char* disk = NULL; + obj_device_config.size_disk = 0; + char* split_simvol = " "; + for (int index = 1; index < size; index++ ) { + 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--; + 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); + } + else { + obj_device_config.name_disk = yon_char_parsed_append(obj_device_config.name_disk, &obj_device_config.size_disk, 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, ""); + 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--; + char* description_disk = yon_char_unite(disk, + split_simvol, + 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); + } + } + +} +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]); + } +} \ No newline at end of file diff --git a/source/my_device.h b/source/my_device.h new file mode 100644 index 0000000..4b695a0 --- /dev/null +++ b/source/my_device.h @@ -0,0 +1,20 @@ +#ifndef MY_DEVICE_H +#define MY_DEVICE_H +#include "ubl-utils.h" +#include +#include +#include +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); + +#endif \ No newline at end of file diff --git a/source/ubl-cmake.h.in b/source/ubl-cmake.h.in new file mode 100644 index 0000000..17ba454 --- /dev/null +++ b/source/ubl-cmake.h.in @@ -0,0 +1 @@ +#cmakedefine WEBKIT_FOUND \ No newline at end of file diff --git a/source/ubl-settings-resourcequota.c b/source/ubl-settings-resourcequota.c new file mode 100644 index 0000000..613dbc6 --- /dev/null +++ b/source/ubl-settings-resourcequota.c @@ -0,0 +1,846 @@ +#include "ubl-settings-resourcequota.h" + +config main_config; +main_window *widgets; +/**on_close_subwindow(GtkWidget *self) + * [EN] + * Closes window in which [self] is contained. + * [RU] + * Закрывает окно, в котором расположен виджет [self]. +*/ +void on_close_subwindow(GtkWidget *self){ + gtk_widget_destroy(gtk_widget_get_toplevel(self)); +} + +/**yon_open_browser(GtkWidget *self, char *link) + * [EN] + * Opens browser with [link] link. + * [RU] + * Открывает браузер с [link] ссылкой. +*/ +void yon_open_browser(GtkWidget *self, char *link){ + yon_ubl_browser_window_open(link,TITLE_LABEL); +} + +/**on_open_documentation_confirmation(GtkWidget *self, char *link) + * [EN] + * Opens confirmation window for [link] link. + * [RU] + * Открывает окно подтверждение перехода по ссылке [link]. +*/ +void on_open_documentation_confirmation(GtkWidget *self, char *link){ + if (main_config.always_open_documentation==0){ + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + 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"); + widgets->HatText = yon_gtk_builder_get_widget(builder,"webHeaderNameLabel"); + widgets->HeaderText = yon_gtk_builder_get_widget(builder,"helpHeader"); + widgets->InfoText = yon_gtk_builder_get_widget(builder,"helpText"); + widgets->AlwaysOpenCheck = yon_gtk_builder_get_widget(builder,"AlwaysOpenDocumentationCheckbox"); + gtk_label_set_text(GTK_LABEL(widgets->HatText),TITLE_LABEL); + gtk_label_set_text(GTK_LABEL(widgets->HeaderText),HELP_TITLE_LABEL); + gtk_label_set_text(GTK_LABEL(widgets->InfoText),HELP_INFO_LABEL); + gtk_button_set_label(GTK_BUTTON(widgets->AcceptButton),OPEN_HELP_LABEL); + gtk_button_set_label(GTK_BUTTON(widgets->AlwaysOpenCheck),HELP_ALWAYS_OPEN_LABEL); + gtk_button_set_label(GTK_BUTTON(widgets->CloseButton),CANCEL_LABEL); + gtk_widget_show_all(widgets->Window); + g_signal_connect(G_OBJECT(widgets->CloseButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(yon_open_browser),yon_char_new(link)); + g_signal_connect(G_OBJECT(widgets->AcceptButton),"clicked",G_CALLBACK(on_close_subwindow),NULL); + + + } else { + yon_open_browser(self,link); + } +} + +/**on_link(GtkWidget *self, char* uri, gpointer user_data) + * [EN] + * Signal for hadnling AboutDialog links. + * Connect to "activate-link" signal. + * [self] is AboutDialog window; + * [uri] is activated link; + * [user_data] is pointer for user data, hasn't used in standard handler; + * [RU] + * Функция для обработки сигнала нажатия на ссылку окна AboutDialog. + * Присоединять к сигналу "activate-link". + * [self] - окно AboutDialog; + * [uri] - ссылка, по которой совершается переход; + * [user_data] - указатель на любые другие данные, не используется в стандартном обработчике; +*/ +void on_link(GtkWidget *self, char* uri, gpointer user_data){ + gtk_widget_destroy(self); + on_open_documentation_confirmation(self,uri); +} + +/**on_about() + * [EN] + * Function for setting up and showing AboutDialog. + * Connect it to "activate" signal of Documentation MenuItem. + * [RU] + * Функиця для настройки и показа окна AboutDialog. + * Присоединять к сигналу "activate" кнопки справки типа MenuItem. +*/ +void on_about(){ + GtkBuilder *builder=gtk_builder_new_from_file(glade_path); + GtkWidget *window=yon_gtk_builder_get_widget(builder,"AboutWindow"); + GtkWidget *title=yon_gtk_builder_get_widget(builder,"headerAboutTopic"); + GtkWidget *hideButtonBox=yon_gtk_builder_get_widget(builder,"buttonBoxHide"); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window),version_application); + gtk_about_dialog_set_website_label(GTK_ABOUT_DIALOG(window),PROJECT_HOME_LABEL); + // gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window),TITLE_LABEL); + gtk_label_set_text(GTK_LABEL(title),TITLE_LABEL); + g_signal_connect(G_OBJECT(window),"activate-link",G_CALLBACK(on_link),NULL); + gtk_widget_set_visible(hideButtonBox,0); + gtk_widget_destroy(hideButtonBox); + gtk_widget_show(window); +} + +void config_init(){ + main_config.always_open_documentation=0; + main_config.win_height=0; + main_config.win_width=0; + main_config.win_pos_x=0; + main_config.win_pos_y=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; + main_config.size_tree_view = 0; +} + +main_window *setup_window(){ + /* Widgets getting | Получение виджетов */ + widgets = malloc(sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow"); + + widgets->btnDelQuotas = yon_gtk_builder_get_widget(builder,"btnDelQuotas"); + widgets->treeViewMain = yon_gtk_builder_get_widget(builder,"treeViewMain"); + widgets->tvc0 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc0")); + widgets->tvc1 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc1")); + widgets->tvc2 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc2")); + widgets->tvc3 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc3")); + widgets->tvc4 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc4")); + widgets->tvc5 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc5")); + widgets->tvc6 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc6")); + widgets->tvc7 = GTK_TREE_VIEW_COLUMN(gtk_builder_get_object(builder,"tvc7")); + + widgets->btnMainShowAllEmpty = yon_gtk_builder_get_widget(builder,"btnMainShowAllEmpty"); + widgets->btnMainShowCoreStream = yon_gtk_builder_get_widget(builder,"btnMainShowCoreStream"); + + main_config.list = GTK_LIST_STORE(gtk_builder_get_object(builder, "liststore")); + widgets->vteInformation = yon_gtk_builder_get_widget(builder,"vteInformation"); + widgets->vteDispatcher = yon_gtk_builder_get_widget(builder,"vteDispatcher"); + widgets->vteProcesses = yon_gtk_builder_get_widget(builder,"vteProcesses"); + widgets->cbtMainInfo = yon_gtk_builder_get_widget(builder,"cbtMainInfo"); + widgets->cbtMainInfoLevel2 = yon_gtk_builder_get_widget(builder,"cbtMainInfoLevel2"); + widgets->spinUpdateDispatcher = yon_gtk_builder_get_widget(builder,"spinUpdateDispatcher"); + widgets->btnUpdateDispatcher = yon_gtk_builder_get_widget(builder,"btnUpdateDispatcher"); + widgets->btnSaveCfg = yon_gtk_builder_get_widget(builder,"btnSaveCfg"); + widgets->notebookMain = yon_gtk_builder_get_widget(builder,"notebookMain"); + + widgets->btnEdit = yon_gtk_builder_get_widget(builder,"btnEdit"); + widgets->btnAdd = yon_gtk_builder_get_widget(builder,"btnAdd"); + widgets->btnInfo = yon_gtk_builder_get_widget(builder,"btnInfo"); + widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic"); + widgets->PlugBox = yon_gtk_builder_get_widget(builder,"plugBox"); + + widgets->HeadOverlay = yon_gtk_builder_get_widget(builder,"HeadOverlay"); + widgets->HeadImage = yon_gtk_builder_get_widget(builder,"HeadBackgroundImage"); + widgets->HeadBox = yon_gtk_builder_get_widget(builder,"HeaderBox"); + widgets->HeadTitleLabel = yon_gtk_builder_get_widget(builder,"HeaderTitleLabel"); + widgets->HeadInfoLabel = yon_gtk_builder_get_widget(builder,"HeaderInfoLabel"); + + widgets->StatusBox = yon_gtk_builder_get_widget(builder,"mainStatusBox"); + widgets->StatusIcon = yon_gtk_builder_get_widget(builder,"mainStatusIcon"); + widgets->StatusLabel = yon_gtk_builder_get_widget(builder,"mainStatusLabel"); + + widgets->SaveLabel = yon_gtk_builder_get_widget(builder,"headerSaveConfigLabel"); + widgets->SaveMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalLocalConfigurationMenuItem"); + widgets->SaveGlobalMenuItem = yon_gtk_builder_get_widget(builder,"SaveGlobalConfigurationMenuItem"); + widgets->SaveLocalMenuItem = yon_gtk_builder_get_widget(builder,"SaveLocalConfigurationMenuItem"); + widgets->RightBox = yon_gtk_builder_get_widget(builder,"HeaderRightBox"); + + widgets->LoadLabel = yon_gtk_builder_get_widget(builder,"headerLoadConfigLabel"); + widgets->LoadGlobalMenuItem = yon_gtk_builder_get_widget(builder,"LoadGlobalConfigurationMenuItem"); + 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->btnShowFilters = yon_gtk_builder_get_widget(builder,"btnShowFilters"); + if (main_config.lock_load_global == 1){ + gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0); + } + if (main_config.lock_save_global == 1){ + gtk_widget_set_sensitive(widgets->SaveGlobalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + if (main_config.lock_save_local == 1){ + gtk_widget_set_sensitive(widgets->SaveLocalMenuItem,0); + gtk_widget_set_sensitive(widgets->SaveMenuItem,0); + } + if (main_config.lock_save_global == 1 && main_config.lock_save_local == 1) { + gtk_widget_set_sensitive(widgets->btnSaveCfg,0); + } + + + gtk_widget_show_all(widgets->Window); + return widgets; +} + +void main_update_dispatcher() { + int second = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->spinUpdateDispatcher)); + char* str_second = yon_char_from_int(second); + char *cmd = yon_char_get_augumented("systemd-cgtop -d ", str_second); + yon_terminal_integrated_launch(widgets->vteDispatcher, cmd, NULL, NULL); + free(str_second); + free(cmd); +} + +void main_update_processes() { + char* cmd = NULL; + gboolean active_all_empty = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->btnMainShowAllEmpty)); + gboolean active_core_stream = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->btnMainShowCoreStream)); + if (active_core_stream == 1) { + cmd = "systemd-cgls --no-page -l"; + } + else if (active_all_empty == 1) { + cmd = "systemd-cgls --no-page -k"; + } + else if (active_all_empty == 1 && active_core_stream == 1) { + cmd = "systemd-cgls --no-page -l -k"; + } + else { + cmd = "systemd-cgls --no-page"; + } + yon_terminal_integrated_launch(widgets->vteProcesses, cmd, NULL, NULL); +} + +void main_update_information() { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtMainInfo)); + char* cmd = NULL; + config_str fill_cmb_2 = NULL; + int size = 0; + if (menu_id == 0) { + fill_cmb_2 = philos_list_user(&size); + + } + else if (menu_id == 1) { + + } + else if (menu_id == 2) { + + } + else if (menu_id == 3) { + + } + if (menu_id >= 0) { + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(widgets->cbtMainInfoLevel2)); + philos_fill_combo_box_text(widgets->cbtMainInfoLevel2, fill_cmb_2, size); + // yon_terminal_integrated_launch(widgets->vteProcesses, cmd, NULL, NULL); + } +} + +void load_system_cfg() { + template_cfg(CMD_LOAD_SYSTEM); +} + +void load_global_cfg() { + template_cfg(CMD_LOAD_GLOBAL); +} + +void template_cfg(char* cmd) { + int size = 0; + int index_quotas = 0; + char** cfg = yon_config_load(cmd, &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-2); + } + str_split_key(str_key, index_quotas); + str_split_value(str_key_value, index); + index_quotas++; + } + } + if (index_quotas != 0) { + fill_tree_view(0, size); + } + + +} +void str_split_key(char* value, int index) { + yon_char_divide_search(value, "[", -1); + value = yon_char_divide_search(value, "]", -1); + if (strstr(value, ".") != NULL) { + if (strstr(value, ".slice") != NULL) { + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value); + index--; + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 4); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_PROCESS); + index--; + } + else if (strstr(value, ".service") != NULL) { + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value); + index--; + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 3); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_SLICE); + index--; + } + else { + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value); + index--; + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, -1); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, "-"); + index--; + } + + } + else { + int user_size = 0; + char** arr_users = philos_list_user(&user_size); + for (int user_index = 0; user_index < user_size; user_index++) { + // Пользователь + if (strcmp(arr_users[user_index], value) != 0) { + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 0); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_USER); + index--; + } + // Группа + else { + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &index, 1); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &index, value); + index--; + main_config.quota_volume = yon_char_parsed_append(main_config.type_quota, &index, STR_GROUP); + index--; + } + } + } + +} +void str_split_value(char* values, int index) { + char* new_value = yon_char_new(values); + int size = 0; + char* key = NULL; + char* value = NULL; + char** arr_values = philos_str_split(new_value, &size, ","); + if (arr_values == NULL) { + return; + } + char* value_i = NULL; + for (int index_1 = 0; index_1 < size; index_1++) { + value = arr_values[index_1]; + key = yon_char_divide_search(value, "=", -1); + if (yon_char_find_count(key, "MemoryHigh") != 0) { + set_pow_size(value, main_config.soft_raw_limit_size, main_config.soft_raw_limit, index); + } + else { + set_pow_size("-", main_config.soft_raw_limit_size, main_config.soft_raw_limit, index); + } + if (yon_char_find_count(key, "MemoryMax") != 0) { + set_pow_size(value, main_config.hard_raw_limit_size, main_config.hard_raw_limit, index); + } + else { + set_pow_size("-", main_config.hard_raw_limit_size, main_config.hard_raw_limit, index); + } + if (yon_char_find_count(key, "MemorySwapMax") != 0) { + set_pow_size(value, main_config.swap_size, main_config.swap, index); + } + else { + set_pow_size("-", main_config.swap_size, main_config.swap, index); + } + if (yon_char_find_count(key, "CPUQuota") != 0) { + set_pow_size(value, main_config.cpu_limit_size, main_config.cpu_limit, index); + } + else { + set_pow_size("-", main_config.cpu_limit_size, main_config.cpu_limit, index); + } + if (yon_char_find_count(key, "IOReadBandwidthMax") != 0) { + set_pow_size(value, main_config.i_o_limit_read_size, main_config.i_o_limit_read, index); + } + else { + set_pow_size("-", main_config.i_o_limit_read_size, main_config.i_o_limit_read, index); + } + if (yon_char_find_count(key, "IOWriteBandwidthMax") != 0) { + set_pow_size(value, main_config.i_o_limit_write_size, main_config.i_o_limit_write, index); + } + else { + set_pow_size("-", main_config.i_o_limit_write_size, main_config.i_o_limit_write, index); + } + } +} + +void set_pow_size(char* str_find, int* array_size, char** array_data , int index) { + if (strstr(str_find,"K") != NULL) { + array_size = philos_int_append(array_size, &index, 0); + index--; + } + else if (strstr(str_find,"M") != NULL) { + array_size = philos_int_append(array_size, &index, 1); + index--; + } + else if (strstr(str_find,"G") != NULL) { + array_size = philos_int_append(array_size, &index, 2); + index--; + } + else if (strstr(str_find,"T") != NULL) { + array_size = philos_int_append(array_size, &index, 3); + index--; + } + else if (strstr(str_find,"\%") != NULL) { + array_size = philos_int_append(array_size, &index, -1); + index--; + } + else if (strstr(str_find,"\"") != NULL) { + + } + else if (strstr(str_find,"-") != NULL) { + array_size = philos_int_append(array_size, &index, -1); + index--; + } + if (strstr(str_find,"-") == NULL) { + 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); + } + size_t length = strlen(str_find); + str_find = yon_char_divide(str_find, length-2); + array_data = yon_char_parsed_append(array_data, &index, str_find); + } + else { + array_data = yon_char_parsed_append(array_data, &index, "-"); + } +} + + +void main_cbx_2_event() { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cbtMainInfo)); + char* cmd_text_param = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->cbtMainInfo)); + if (menu_id == 0) { + + } + else if (menu_id == 1) { + + } + else if (menu_id == 2) { + + } + else if (menu_id == 3) { + + } + if (menu_id >= 0) { + + } + //char *cmd = yon_char_get_augumented("systemd-cgtop -d ", str_second); + //yon_terminal_integrated_launch(widgets->vteDispatcher, cmd, NULL, NULL); + +} + +void tree_view_select(GtkWidget *self, main_window *widgets) { + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); + if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + gtk_widget_set_sensitive(widgets->btnAdd,1); + gtk_widget_set_sensitive(widgets->btnDelQuotas,1); + gtk_widget_set_sensitive(widgets->btnEdit,1); + gtk_widget_set_sensitive(widgets->btnInfo,1); + } + else { + gtk_widget_set_sensitive(widgets->btnAdd,1); + gtk_widget_set_sensitive(widgets->btnDelQuotas,0); + gtk_widget_set_sensitive(widgets->btnEdit,0); + gtk_widget_set_sensitive(widgets->btnInfo,0); + } + +} + +void tree_view_add(int index) { + main_config.type_quota = yon_char_parsed_append(main_config.type_quota, &main_config.size_tree_view, add_get_quota_object()); + main_config.size_tree_view--; + main_config.quota_volume = yon_char_parsed_append(main_config.quota_volume, &main_config.size_tree_view, add_get_select_device_to_level_2()); + main_config.size_tree_view--; + main_config.soft_raw_limit = yon_char_parsed_append(main_config.soft_raw_limit, &main_config.size_tree_view, add_get_soft()); + main_config.size_tree_view--; + main_config.hard_raw_limit = yon_char_parsed_append(main_config.hard_raw_limit, &main_config.size_tree_view, add_get_hard()); + main_config.size_tree_view--; + main_config.swap = yon_char_parsed_append(main_config.swap, &main_config.size_tree_view, add_get_limit_swap()); + main_config.size_tree_view--; + main_config.cpu_limit = yon_char_parsed_append(main_config.cpu_limit, &main_config.size_tree_view, add_get_limit_cpu()); + main_config.size_tree_view--; + main_config.i_o_limit_read = yon_char_parsed_append(main_config.i_o_limit_read, &main_config.size_tree_view, add_get_read_device()); + main_config.size_tree_view--; + main_config.i_o_limit_write = yon_char_parsed_append(main_config.i_o_limit_write, &main_config.size_tree_view, add_get_write_device()); + main_config.size_tree_view--; + + main_config.type_quota_size = philos_int_append(main_config.type_quota_size, &main_config.size_tree_view, add_get_quota_object_size()); + main_config.size_tree_view--; + main_config.quota_volume_size = philos_int_append(main_config.quota_volume_size, &main_config.size_tree_view, -1); + main_config.size_tree_view--; + main_config.soft_raw_limit_size = philos_int_append(main_config.soft_raw_limit_size, &main_config.size_tree_view, add_get_soft_size()); + main_config.size_tree_view--; + main_config.hard_raw_limit_size = philos_int_append(main_config.hard_raw_limit_size, &main_config.size_tree_view, add_get_hard_size()); + main_config.size_tree_view--; + main_config.swap_size = philos_int_append(main_config.swap_size, &main_config.size_tree_view, add_get_limit_swap_size()); + main_config.size_tree_view--; + main_config.cpu_limit_size = philos_int_append(main_config.cpu_limit_size, &main_config.size_tree_view, add_get_limit_cpu_size()); + main_config.size_tree_view--; + main_config.i_o_limit_read_size = philos_int_append(main_config.i_o_limit_read_size, &main_config.size_tree_view, add_get_read_device_size()); + main_config.size_tree_view--; + main_config.i_o_limit_write_size = philos_int_append(main_config.i_o_limit_write_size, &main_config.size_tree_view, add_get_write_device_size()); + fill_tree_view(main_config.size_tree_view-1, main_config.size_tree_view); +} + +void fill_tree_view(int start, int size) { + for (int index = start; index < size; index++) { + GtkTreeIter iter; + gtk_list_store_append(main_config.list,&iter); + gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index], + 1,main_config.quota_volume[index], + 2,main_config.soft_raw_limit[index], + 3,main_config.hard_raw_limit[index], + 4,main_config.swap[index], + 5,main_config.cpu_limit[index], + 6,main_config.i_o_limit_read[index], + 7,main_config.i_o_limit_write[index],-1); + } +} + +int tree_view_edit() { + int index = 0; + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); + + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); + if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); + index = atoi(str_iter); + main_config.soft_raw_limit[index] = edit_get_soft(); + main_config.hard_raw_limit[index] = edit_get_hard(); + main_config.swap[index] = edit_get_limit_swap(); + main_config.cpu_limit[index] = edit_get_limit_cpu(); + main_config.i_o_limit_read[index] = edit_get_read_device(); + main_config.i_o_limit_write[index] = edit_get_write_device(); + + main_config.soft_raw_limit_size[index] = edit_get_soft_size(); + main_config.hard_raw_limit_size[index] = edit_get_hard_size(); + main_config.swap_size[index] = edit_get_limit_swap_size(); + main_config.cpu_limit_size[index] = edit_get_limit_cpu_size(); + main_config.i_o_limit_read_size[index] = edit_get_read_device_size(); + main_config.i_o_limit_write_size[index] = edit_get_write_device_size(); + gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index], + 1,main_config.quota_volume[index], + 2,main_config.soft_raw_limit[index], + 3,main_config.hard_raw_limit[index], + 4,main_config.swap[index], + 5,main_config.cpu_limit[index], + 6,main_config.i_o_limit_read[index], + 7,main_config.i_o_limit_write[index],-1); + return 1; + } + else { + return 0; + } + +} + +void main_visible_columns(GtkWidget *self) { + 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 info_show(GtkWidget *self) { + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); + if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); + int index = atoi(str_iter); + char* t_quota = main_config.type_quota[index]; + if (yon_char_find_count(t_quota, "-") == 0) { + // TODO: add code + } + } + gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->notebookMain), 3); +} + +void event_all(main_window *widgets) { + +} + +void main_event(main_window *widgets) { + /* Signal connection | Присоединение сигналов */ + 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),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); + g_signal_connect(G_OBJECT(widgets->btnAdd),"clicked",G_CALLBACK(wrapper_add_show), glade_path); + g_signal_connect(G_OBJECT(widgets->btnEdit),"clicked",G_CALLBACK(wrapper_edit_show), glade_path); + g_signal_connect(G_OBJECT(widgets->btnInfo),"clicked",G_CALLBACK(info_show), glade_path); + g_signal_connect(G_OBJECT(widgets->btnUpdateDispatcher),"clicked",G_CALLBACK(main_update_dispatcher), NULL); + g_signal_connect(G_OBJECT(widgets->btnMainShowAllEmpty), "toggled", G_CALLBACK(main_update_processes), NULL); + g_signal_connect(G_OBJECT(widgets->btnMainShowCoreStream), "toggled", G_CALLBACK(main_update_processes), NULL); + g_signal_connect(G_OBJECT(widgets->cbtMainInfo),"changed",G_CALLBACK(main_update_information), NULL); + g_signal_connect(G_OBJECT(widgets->cbtMainInfoLevel2),"changed",G_CALLBACK(main_cbx_2_event), NULL); + g_signal_connect(G_OBJECT(widgets->btnDelQuotas), "clicked", G_CALLBACK(tree_view_del_line), widgets); + g_signal_connect(G_OBJECT(widgets->treeViewMain), "cursor-changed", G_CALLBACK(tree_view_select), widgets); + g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem), "activate", G_CALLBACK(load_global_cfg), widgets); + g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem), "activate", G_CALLBACK(load_system_cfg), widgets); +/* + g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(),NULL); + g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(),NULL); + g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(),NULL); + + g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(),NULL); + g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(),NULL); +*/ +} +void wrapper_add_show(GtkWidget *self) { + add_show(NULL, glade_path); + g_signal_connect(G_OBJECT(get_widget_add()->btnSaveAddSave), "clicked", G_CALLBACK(main_add_btn_save), NULL); +} +void main_add_btn_save() { + tree_view_add(main_config.size_tree_view); + add_on_destroy_subwindow(get_widget_add()->Window); +} + +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); +} + +void wrapper_edit_show() { + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); + if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); + int index = atoi(str_iter); + edit_show(NULL, glade_path); + edit_set_hard(main_config.hard_raw_limit[index], main_config.hard_raw_limit_size[index]); + edit_set_limit_cpu(main_config.cpu_limit[index], main_config.cpu_limit_size[index]); + edit_set_soft(main_config.soft_raw_limit[index], main_config.soft_raw_limit_size[index]); + edit_set_write_device(main_config.i_o_limit_write[index], main_config.i_o_limit_write_size[index]); + edit_set_read_device(main_config.i_o_limit_read[index], main_config.i_o_limit_read_size[index]); + edit_set_limit_swap(main_config.swap[index], main_config.swap_size[index]); + // edit_set_select_device(main_config.cpu_limit[index]); + g_signal_connect(G_OBJECT(get_widget_edit()->btnSaveEditSave), "clicked", G_CALLBACK(main_edit_btn_save), NULL); + } +} + +void main_edit_btn_save() { + if (tree_view_edit(main_config.size_tree_view)) { + add_on_destroy_subwindow(get_widget_edit()->Window); + } + else { + + } + +} + +void tree_view_del_line() { + int index = 0; + GtkTreeIter iter; + GtkTreeModel *model = GTK_TREE_MODEL(main_config.list); + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->treeViewMain)); + if(gtk_tree_selection_get_selected(selection, &model, &iter)) { + char* str_iter = gtk_tree_model_get_string_from_iter(model, &iter); + index = atoi(str_iter); + main_config.type_quota = yon_char_parsed_shrink(main_config.type_quota, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.quota_volume = yon_char_parsed_shrink(main_config.quota_volume, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.soft_raw_limit = yon_char_parsed_shrink(main_config.soft_raw_limit, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.hard_raw_limit = yon_char_parsed_shrink(main_config.hard_raw_limit, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.swap = yon_char_parsed_shrink(main_config.swap, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.cpu_limit = yon_char_parsed_shrink(main_config.cpu_limit, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.i_o_limit_read = yon_char_parsed_shrink(main_config.i_o_limit_read, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.i_o_limit_write = yon_char_parsed_shrink(main_config.i_o_limit_write, &main_config.size_tree_view,index); + main_config.size_tree_view++; + + main_config.type_quota_size = remove_element_int_array(main_config.type_quota_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.quota_volume_size = remove_element_int_array(main_config.quota_volume_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.soft_raw_limit_size = remove_element_int_array(main_config.soft_raw_limit_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.hard_raw_limit_size = remove_element_int_array(main_config.hard_raw_limit_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.swap_size = remove_element_int_array(main_config.swap_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.cpu_limit_size = remove_element_int_array(main_config.cpu_limit_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.i_o_limit_read_size = remove_element_int_array(main_config.i_o_limit_read_size, &main_config.size_tree_view,index); + main_config.size_tree_view++; + main_config.i_o_limit_write_size = remove_element_int_array(main_config.i_o_limit_write_size, &main_config.size_tree_view,index); + g_object_ref(main_config.list); + gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), NULL); + gtk_list_store_clear(main_config.list); + main_fill_tree_view_after_remove(); + gtk_tree_view_set_model(GTK_TREE_VIEW(widgets->treeViewMain), model); + } + else { + + } +} + +void main_fill_tree_view_after_remove() { + for (int index= 0; index < main_config.size_tree_view; index++) { + GtkTreeIter iter; + gtk_list_store_append(main_config.list,&iter); + gtk_list_store_set(main_config.list,&iter,0,main_config.type_quota[index], + 1,main_config.quota_volume[index], + 2,main_config.soft_raw_limit[index], + 3,main_config.hard_raw_limit[index], + 4,main_config.swap[index], + 5,main_config.cpu_limit[index], + 6,main_config.i_o_limit_read[index], + 7,main_config.i_o_limit_write[index],-1); + } +} + +void main_localization(main_window *widgets) { + /* Localisation | Локализация */ + gtk_label_set_text(GTK_LABEL(widgets->HatLabel),TITLE_LABEL); + gtk_label_set_text(GTK_LABEL(widgets->SaveLabel),SAVE_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->SaveMenuItem),SAVE_CONFIGURATION_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->SaveGlobalMenuItem),SAVE_GLOBAL_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->SaveLocalMenuItem),SAVE_LOCAL_LABEL); + + gtk_label_set_text(GTK_LABEL(widgets->LoadLabel),LOAD_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->LoadGlobalMenuItem),LOAD_GLOBAL_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->LoadLocalMenuItem),LOAD_LOCAL_LABEL); + + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->DocumentationMenuItem),DOCUMENTATION_LABEL); + gtk_menu_item_set_label(GTK_MENU_ITEM(widgets->AboutMenuItem),ABOUT_LABEL); +} + +int main(int argc, char *argv[]){ + 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'}, + { NULL, 0, NULL, 0 } + }; + + for (int i=0;iHeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path); + + if (yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel)) + yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,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); + + GtkCssProvider *css=gtk_css_provider_new(); + gtk_css_provider_load_from_path(css,CssPath,NULL); + gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), + GTK_STYLE_PROVIDER(css), + -1); + gtk_main(); +} + diff --git a/source/ubl-settings-resourcequota.h b/source/ubl-settings-resourcequota.h new file mode 100755 index 0000000..57a56b5 --- /dev/null +++ b/source/ubl-settings-resourcequota.h @@ -0,0 +1,186 @@ +#include +#include +#include "ubl-utils.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "ubl-cmake.h" +#include "view_add.h" +#include "filters.h" +#include "view_edit.h" +#include "my_device.h" + + + +#ifdef WEBKIT_FOUND + #include +#endif +#include "ubl-strings.h" + +#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-resourcequota" + +#define _(String) gettext(String) + +#define glade_path "/usr/share/ubl-settings-resourcequota/ui/ubl-settings-resourcequota.glade" +#define banner_path "/usr/share/ubl-settings-resourcequota/images/ubl-settings-resourcequota-banner.png" +#define CssPath "/usr/share/ubl-settings-resourcequota/css/ubl-settings-resourcequota.css" + +#define LocalePath "/usr/share/locale" +#define LocaleName "ubl-settings-resourcequota" +#define CMD_LOAD_GLOBAL "ubconfig --default --source global get security" +#define CMD_LOAD_SYSTEM "ubconfig --default --source system get security" +typedef char* string; +string version_application = "1.0"; + +static char *local; + +typedef struct { + int always_open_documentation; + int win_pos_x; + int win_pos_y; + int win_width; + int win_height; + + int socket_id; + int load_socket_id; + int save_socket_id; + + int lock_help; + int lock_save_local; + int lock_save_global; + int lock_load_global; + + GtkListStore *list; + config_str load_system_value; + config_str load_global_value; + config_str cfg_gui_value; + + config_str load_system_key; + config_str load_global_key; + config_str cfg_gui_key; + + render_data status_render; + config_str type_quota; + config_str quota_volume; + config_str soft_raw_limit; + config_str hard_raw_limit; + config_str swap; + config_str cpu_limit; + config_str i_o_limit_read; + config_str i_o_limit_write; + + int* type_quota_size; + int* quota_volume_size; + int* soft_raw_limit_size; + int* hard_raw_limit_size; + int* swap_size; + int* cpu_limit_size; + int* i_o_limit_read_size; + int* i_o_limit_write_size; + int size_tree_view; +} config; + +typedef struct { + GtkWidget *Window; + + GtkTreeViewColumn *tvc0; + GtkTreeViewColumn *tvc1; + GtkTreeViewColumn *tvc2; + GtkTreeViewColumn *tvc3; + GtkTreeViewColumn *tvc4; + GtkTreeViewColumn *tvc5; + GtkTreeViewColumn *tvc6; + GtkTreeViewColumn *tvc7; + + GtkWidget *btnDelQuotas; + GtkWidget *cbtMainInfoLevel2; + GtkWidget *cbtMainInfo; + GtkWidget *vteProcesses; + GtkWidget *vteInformation; + GtkWidget *btnMainShowCoreStream; + GtkWidget *btnMainShowAllEmpty; + GtkWidget *vteDispatcher; + GtkWidget *spinUpdateDispatcher; + GtkWidget *btnUpdateDispatcher; + GtkWidget *treeViewMain; + GtkWidget *btnSaveCfg; + GtkWidget *btnShowFilters; + GtkWidget *notebookMain; + GtkWidget *btnEdit; + GtkWidget *btnInfo; + GtkWidget *btnAdd; + GtkWidget *HatLabel; + GtkWidget *PlugBox; + + GtkWidget *HeadOverlay; + GtkWidget *HeadImage; + GtkWidget *HeadBox; + GtkWidget *HeadTitleLabel; + GtkWidget *HeadInfoLabel; + + GtkWidget *StatusBox; + GtkWidget *StatusIcon; + GtkWidget *StatusLabel; + + GtkWidget *SaveLabel; + GtkWidget *SaveMenuItem; + GtkWidget *SaveGlobalMenuItem; + GtkWidget *SaveLocalMenuItem; + GtkWidget *RightBox; + + GtkWidget *LoadLabel; + GtkWidget *LoadGlobalMenuItem; + GtkWidget *LoadLocalMenuItem; + GtkWidget *LeftBox; + + GtkWidget *DocumentationMenuItem; + GtkWidget *AboutMenuItem; +} main_window; + + +typedef struct { + GtkWidget *Window; + + GtkWidget *HatText; + GtkWidget *HeaderText; + GtkWidget *InfoText; + GtkWidget *AlwaysOpenCheck; + + GtkWidget *CloseButton; + GtkWidget *AcceptButton; + +} documentation_confirmation_window; + +main_window *setup_window(); +void main_update_processes(); +void config_init(); +void event_all(main_window *widgets); +void main_event(main_window *widgets); +void info_show(GtkWidget *self); +void main_localization(main_window *widgets); +void main_visible_columns(); +void wrapper_filters_show(GtkWidget *self); +void main_update_dispatcher(); +void main_update_information(); +void main_fill_combo_box_text(GtkWidget *cbt, config_str list_data, int size); +void main_cbx_2_event(); +void tree_view_select(GtkWidget *self, main_window *widgets); +void tree_view_add(int index); +int tree_view_edit(); +void main_add_btn_save(); +void wrapper_add_show(GtkWidget *self); +void main_edit_btn_save(); +void tree_view_del_line(); +void main_fill_tree_view_after_remove(); +void load_system_cfg(); +void load_global_cfg(); +void template_cfg(char* cmd); +void str_split_value(char* values, int index); +void set_pow_size(char* str_find, int* array_size, char** array_data, int index); +void str_split_key(char* value, int index); +void fill_tree_view(int start, int size); \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h new file mode 100644 index 0000000..2d732c4 --- /dev/null +++ b/source/ubl-strings.h @@ -0,0 +1,39 @@ +#define VERSION_LABEL yon_char_unite(_("Version:")," ",version_application,"\n",NULL) +#define HELP_LABEL yon_char_unite(_("ubl-settings-resourcequota version:")," ", version_application,"\n",_("CPU and RAM quotas settings"),"\n",_("Usage:"), " ubl-settings-resourcequota ",_("[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 _("CPU and RAM quotas") +#define TITLE_INFO_LABEL _("System resource quota settings management") + +#define ABOUT_LABEL _("About") +#define DOCUMENTATION_LABEL _("Documentation") +#define SAVE_LOCAL_LABEL _("Save to local configuration") +#define SAVE_GLOBAL_LABEL _("Save to global configuration") +#define SAVE_CONFIGURATION_LABEL _("Save configuration") +#define SAVE_LABEL _("Save") +#define LOAD_LOCAL_LABEL _("Load local configuration") +#define LOAD_GLOBAL_LABEL _("Load global configuration") +#define LOAD_LABEL _("Load") + +#define CANCEL_LABEL _("Cancel") + +#define HELP_TITLE_LABEL _("Would you like to read documentation in the Web?") +#define HELP_INFO_LABEL _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") +#define HELP_ALWAYS_OPEN_LABEL _("Always redirect to online documentation") +#define OPEN_HELP_LABEL _("Open documentation") +#define PROJECT_HOME_LABEL _("Project Home Page") +#define NOTHING_CHOSEN_LABEL _("Nothing were chosen") + +#define STR_USER _("User") +#define STR_GROUP _("Group") +#define STR_PROCESS _("Process") +#define STR_SLICE _("Slice") + +#define GLOBAL_LOAD_SUCCESS _("Global configuration loading succseeded.") +#define LOCAL_LOAD_SUCCESS _("Local configuration loading succseeded.") + +#define GLOBAL_LOCAL_SAVE_SUCCESS _("Local and global configuration saving succseeded.") +#define GLOBAL_SAVE_SUCCESS _("Global configuration saving succseeded.") +#define LOCAL_SAVE_SUCCESS _("Local configuration saving succseeded.") +#define STR_DEL_TABLE _("Quota deleted") +#define STR_NO_SELECT_TABLE _("Quota deleted") +#define STR_QUOTAS_ADD _("Quota deleted") \ No newline at end of file diff --git a/source/ubl-utils.c b/source/ubl-utils.c new file mode 100644 index 0000000..dd61852 --- /dev/null +++ b/source/ubl-utils.c @@ -0,0 +1,1289 @@ +#include "ubl-utils.h" + +// dictionary functions + +/**[EN] + * yon_dictionary_create_empty(): + * Creates and returns empty dictionary + */ +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_dictionary_switch_to_last(dictionary **dict) +{ + if ((*dict)->next != NULL) + for ((*dict) = (*dict)->first; (*dict)->next != NULL; (*dict) = (*dict)->next) + { + } +} + +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; +} + +dictionary *yon_dictionary_get_last(dictionary *dict) +{ + dictionary *dct = NULL; + for (dct = dict->first; dct->next != NULL; dct = dct->next) + { + } + return dct; +} + +dictionary *yon_dictionary_switch_places(dictionary *dict, int aim) +{ + if (aim < 0) + { + if (dict->prev) + { + if (dict->prev->prev) + { + dictionary *next = dict->next, *prev = dict->prev, *preprev = prev->prev; + if (next) + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + preprev->next = dict; + dict->prev = preprev; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; + } + return prev; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (next) + { + yon_dictionary_make_first(dict); + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = next; + next->prev = prev; + } + else + { + dict->prev = NULL; + dict->next = prev; + prev->prev = dict; + prev->next = NULL; + } + return prev; + } + } + } + else if (aim > 0) + { + if (dict->next) + { + if (dict->next->next) + { + dictionary *next = dict->next, *prev = dict->prev, *afnext = next->next; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; + } + else + { + yon_dictionary_make_first(next); + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = afnext; + afnext->prev = dict; + } + return next; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + if (prev) + { + prev->next = next; + next->prev = prev; + next->next = dict; + dict->prev = next; + dict->next = NULL; + } + else + { + next->prev = NULL; + next->next = dict; + dict->prev = next; + dict->next = NULL; + } + } + } + } +} + +void yon_dictionary_make_first(dictionary *dict) +{ + for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) + { + dct->first = dict; + } +} + +void yon_dictionary_make_nth(dictionary *dict, int nth) +{ + dictionary *dct = dict->first; + for (int i = 0; i < nth; i++) + { + if (dct == NULL) + return; + else + dct = dct->next; + } + yon_dictionary_rip(dict); + dictionary *prev = dct->prev; + prev->next = dict; + dict->prev = prev; + dict->next = dct; + dct->prev = dict; +} + +dictionary *yon_dictionary_create_with_data(char *key, void *data) +{ + dictionary *dct = yon_dictionary_create_empty(); + dct->key = yon_char_new(key); + dct->data = data; + dct->data_type = DICTIONARY_OTHER_TYPE; + return dct; +} + +/** void *yon_dictionary_free_all(dictionary *dictionary,void *data_manipulation) + * [EN] + * Frees whole [dictionary] and activates [data_manipulation] function if not NULL with [dictionary]->data argument for each dictionary. + * [RU] + * Освобождает память для всех элементов словаря [dictionary] и активирует функцию [data_manipulation], если она была передана, с аргументом [dictionary]->data на каждый элемент словаря. +*/ +void *yon_dictionary_free_all(dictionary *dictionary_to_free,void (*data_manipulation)(void*)){ + dictionary *dict=NULL; + for_dictionaries(dict,dictionary_to_free){ + if(data_manipulation) + data_manipulation(dict->data); + if(dict->prev) + free(dict->prev); + } + free(dict); + 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; +} + +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect) +{ + dictionary *dict = yon_dictionary_get_last(old); + dict->next = toconnect; + toconnect->prev = dict; + toconnect->first = dict->first; + return toconnect; +} + +dictionary *yon_dictionary_find(dictionary **dict, char *key) +{ + dictionary *dct = *dict; + for (dictionary *pointer = dct->first; pointer != NULL; pointer = pointer->next) + { + if (strcmp(pointer->key, key) == 0) + { + *dict = pointer; + return pointer; + } + } + return NULL; +} + +dictionary *yon_dictionary_rip(dictionary *dict) +{ + if (!dict->next&&!dict->prev) return NULL; + else if (!dict->next) + { + dictionary *prev = dict->prev; + if (prev) + { + prev->next = NULL; + return prev; + } + else + return dict; + } + else if (!dict->prev) + { + dictionary *next = dict->next; + if (next) + { + yon_dictionary_make_first(next); + next->prev = NULL; + return next; + } + else + return dict; + } + else + { + dictionary *next = dict->next, *prev = dict->prev; + next->prev = prev; + prev->next = next; + return next; + } +} + +dictionary *yon_dictionary_get_nth(dictionary *dict, int place) +{ + if (dict){ + dict = dict->first; + int i = 0; + for (i = 0; i < place; i++) + if (dict->next) + dict = dict->next; + else + break; + if (i == place) + return dict; + else + return NULL; + } else return NULL; +} + +// char functions + +/**[EN] + * + * creates new char string by combining two char strings. + */ +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; +} + +/**[EN] + * + * creates new char string by copying another char. + */ +char *yon_char_new(char *chr) +{ + if (chr){ + char *newchar = malloc(strlen(chr) + 1); + memset(newchar, 0, strlen(chr) + 1); + memcpy(newchar, chr, strlen(chr)); + return newchar; + } else + return NULL; +} + +// char *yon_char_unite(char *source, ...) + +char *yon_char_unite(char *source, ...){ + va_list arglist; + char *new_char=NULL; + char *unite_char=NULL; + new_char=yon_char_new(source); + va_start(arglist,source); + unite_char = va_arg(arglist,char*); + while(unite_char){ + new_char = yon_char_get_augumented(new_char,unite_char); + unite_char = va_arg(arglist,char*); + } + va_end(arglist); + return new_char; +} + +/**[EN] + * + * cuts source string by size length from startpos position. + */ +char *yon_cut(char *source, int size, int startpos) +{ + char *cut = NULL; + cut = malloc(size + 1); + memset(cut, 0, size + 1); + memcpy(cut, source + startpos, size); + return cut; +} +/**[EN] + * + * divides source string in dividepos position, + * returning left part of divided string and + * inserting right part to source string. + */ +char *yon_char_divide(char *source, int dividepos) +{ + char *cut = malloc(dividepos + 1); + memset(cut, 0, dividepos + 1); + memcpy(cut, source, dividepos); + 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)); + memcpy(source, left, strlen(left)); + return cut; +} + +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; // so we can distinguish errors from no more entries + 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; +} + +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 " "; + } +} + +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; // so we can distinguish errors from no more entries + 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; + +} + +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; +} + +int yon_char_find_count(char *source, char *find){ + char *working_string=yon_char_new(source); + int i=0; + int size=0; + int pos=0; + config_str rtn = yon_char_parse(working_string,&size,"\n"); + for (int j=0;j 10; i++) + { + convert_check = convert_check / 10; + } + char *ch = malloc(i * sizeof(char) + 1); + sprintf(ch, "%d", int_to_convert); + return ch; +} + +char *yon_char_replace(char *source, char *find, char*replace){ + char *final=NULL; + char *temp=NULL; + if(!strstr(replace,find)){ + while ((final=strstr(source,find))){ + temp=malloc(strlen(source)-strlen(final)); + memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); + memcpy(temp,source,strlen(source)-strlen(final)); + temp=yon_char_get_augumented(temp,replace); + source=yon_char_get_augumented(temp,final+1); + } + return source; + } +} +void philos_split_size_memory(char* str_value, int* size, char* pow_memory) { + // pow_memory = yon_char_new(str_value); + (*size) = atoi(yon_char_divide_search(pow_memory, " ", -1)); +} +/**[EN] + * char **yon_char_parse(char *parameters, int *size, char *divider) + * Parses string [parameters], divided by [divider], + * then returns parsed string array and sets [size] to + * size of returned array +*/ +char **yon_char_parse(char *parameters, int *size, char *divider){ + char **string=NULL; + int i=1; + string=malloc(sizeof(char*)); + char *paramline=yon_char_new(parameters); + char *param; + while ((param=yon_char_divide_search(paramline,divider,1))){ + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(param); + i++; + if (strcmp(param,paramline)==0) break; + } + string=realloc(string,sizeof(char*)*i); + string[i-1]=yon_char_new(paramline); + i++; + // printf("%d\n",i); + *size=i-1; + return string; + + + +} + +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; +} + +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; +} + +/**[EN] + * + * Checks if [parameters] string array of length [size] + * has [param] element; +*/ +int yon_char_parsed_check_exist(char **parameters, int size, char *param){ + + for (int i=0;id_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) +{ + apps tmp; + if (size > 2) + { + for (int i = 1; i < size; i++) + { + for (int j = 1; j < size; j++) + { + if (strcmp(applist[j].Name, applist[j - 1].Name) < 0) + { + tmp = applist[j]; + applist[j] = applist[j - 1]; + applist[j - 1] = tmp; + }; + } + }; + } +}; + +apps *yon_apps_get_by_name(apps *applist, char *name, int size) +{ + for (int i = 0; i < size; i++) + { + if (strcmp(applist[i].Name, name) == 0) + return &applist[i]; + } + return NULL; +}; + +config_str yon_config_load(char *command, int *str_len) +{ + FILE *output = popen(command, "r"); + char **output_strings = NULL; + output_strings = malloc(sizeof(char)); + int i = 0; + char str[1000]; + memset(str, 0, 1000); + while (fgets(str, 1000, output)) + { + if (strcmp(str, "") != 0) + { + output_strings = realloc(output_strings, sizeof(char *) * (i + 1)); + // printf("%s\n", str); + output_strings[i] = NULL; + output_strings[i] = yon_char_new(str); + memset(str, 0, 1000); + i++; + } + } + if (i>0){ + *str_len = i; + return output_strings; + } else{ + *str_len=-1; + return NULL; + } +} + +/**[EN] + * int yon_config_save(char *command) + * Saves config with [command] + * [RU] +*/ +int yon_config_save(char *command) +{ + FILE *output = popen(command, "r"); + return 1; +} + +/**[EN] + * char *yon_config_get_parameter(config parameters, int size, char *param) + * Gets parameter from parameter list; + * + * [RU] +*/ +char *yon_config_get_parameter(config_str parameters, int size, char *param) +{ + if (param[0]==' ') + 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]), "=", 1); + if (name) + { + if (strcmp(name, param) == 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; + } + } + } + return NULL; +} + +/**[EN] + * Parses, modifies and connects string to use it as one of arguments, + * sended to ubconfig. + * + * [RU] + */ +char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider){ + char *final=""; + int done=0; + char *cur=yon_char_new(parameter_string); + yon_char_divide_search(cur,"=",1); + char *cur_param=NULL; + while (cur_param=yon_char_divide_search(cur,",",1)){ + if (done==0){ + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur_param,", "))); + done=1; + } else { + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur_param,", "))); + } + } + if (cur&&strcmp(cur,"")!=0) + if (done==0) + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"="), yon_char_get_augumented(cur,", "))); + else + final=yon_char_get_augumented(final,yon_char_get_augumented(yon_char_get_augumented(config_parameter,"+="), yon_char_get_augumented(cur,", "))); + return final; +} + +// terminal-using functions + +int yon_launch_app(char *name) +{ + char *path = name; + thread_output *thread = malloc(sizeof(thread_output)); + thread->command = path; + thread->exitcode = malloc(sizeof(int)); + pthread_t thread_id; + pthread_create(&thread_id, NULL, (void *)yon_launch, thread); + return *thread->exitcode; +}; + +int yon_launch_app_with_arguments(char *name, char *args) +{ + char *path = yon_char_get_augumented("/usr/bin/", name); + path = yon_char_get_augumented(path, " "); + path = yon_char_get_augumented(path, args); + pthread_t thread_id; + thread_output *thread = malloc(sizeof(thread_output)); + thread->command = path; + thread->exitcode = malloc(sizeof(int)); + pthread_create(&thread_id, NULL, (void *)yon_launch, thread); + return *thread->exitcode; +}; + +int yon_launch(thread_output *thread) +{ + int a = 0; + a = system(thread->command); + *thread->exitcode = a; + return *thread->exitcode; +} + +int* philos_int_append(int* array, int* size, int value) { + if (array == NULL) { + array = (int*) malloc((*size+1) * sizeof(int)); + } + else { + array = (int*) realloc(array, ((*size)+1)*sizeof(int)); + } + array[(*size)] = value; + (*size)++; + return array; + +} + +int* remove_element_int_array(int* array, int* size, int index) { + int* temp = malloc(((*size) - 1) * sizeof(int)); + if (index != 0) + memcpy(temp, array, index * sizeof(int)); + + if (index != ((*size) - 1)) + memcpy(temp+index, array+index+1, ((*size) - index - 1) * sizeof(int)); + + free (array); + return temp; +} +// Gtk functions + + +#ifdef __GTK_H__ + + +static render_data render; + +#ifdef VTE_TERMINAL + +static void child_ready(VteTerminal *terminal, GPid pid, GError *error, gpointer user_data) +{ + if (!terminal) return; + if (pid == -1) printf("Error\n\n\n"); + else vte_terminal_feed_child(VTE_TERMINAL(terminal),(char*)user_data,strlen((char*)user_data)); +} + +/** + * void yon_terminal_integrated_launch(GtkWidget *place_to_show, void *endwork_function, void* endwork_function_argument) + * [EN] + * launches terminal with specific [command], + * terminal is shown in [place_to_show] container, + * after terminal done its work [endwork_function] is called with [endwork_function_argument] argument. + * [RU] + * Запускает терминал с командой [command], + * терминал добавляется в контейнер [place_to_show] виджета, + * после завершения работы терминала вызывается функция [endwork_function] с аргументом [endwork_function_argument]. +*/ +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,"\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), 100); + 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); + } + +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]); + } +} +#endif + +int yon_gtk_combo_box_fill(GtkWidget *combo, config_str parameters,int size){ + if (combo&¶meters){ + for (int i=0;ifirst; dct != NULL; dct = dct->next) + { + gtk_box_pack_start(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); + } + return 1; + }else return 0; +} + +int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding) +{ + for (dictionary *dct = dict->first; dct != NULL; dct = dct->next) + { + gtk_box_pack_end(GTK_BOX(destination), (GtkWidget *)dct->data, expand, fill, padding); + } + return 1; +} + +void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path) +{ + gtk_overlay_add_overlay(GTK_OVERLAY(Overlay), Head); + gtk_image_set_from_file(GTK_IMAGE(Image), image_path); +} + +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label) +{ + if(icon&&box&&label){ + render.icon=icon; + render.box=box; + render.label=label; + return 1; + } else return 0; +} + +/** + * +*/ +void _yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type) +{ + render_data data = render; + GtkIconTheme *ictheme = gtk_icon_theme_get_default(); + GError *err = NULL; + if (err) + { + printf("%s\n", err->message); + g_error_free(err); + } + if (type == BACKGROUND_IMAGE_SUCCESS_TYPE||! type) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); + gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); + gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.checked", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); + } + else if (type == BACKGROUND_IMAGE_FAIL_TYPE) + { + gtk_style_context_remove_class(gtk_widget_get_style_context(data.box), "boxInfoMessOK"); + gtk_style_context_add_class(gtk_widget_get_style_context(data.box), "boxInfoMessError"); + gtk_image_set_from_pixbuf(GTK_IMAGE(data.icon), gtk_icon_theme_load_icon_for_scale(ictheme, "com.ublinux.ubl-settings-video.warning", 25, 1, GTK_ICON_LOOKUP_FORCE_SIZE, &err)); + } + if (text) + gtk_label_set_text(GTK_LABEL(data.label), text); +} + + +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type){ + _yon_ubl_status_box_render(text,type); +} + +/**yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id) + * [EN] + * Set up plugs for using with GtkSockets insine ubl-settings-manager. + * [main_window] is container widget, which holds main application functionality. + * [left_window] is container widget, which holds widgets, have to be shown at left part of ubl-settings-manager header. + * [right_window] is container widget, which holds widgets, have to be shown at right part of ubl-settings-manager header. + * [socket_main_id] is id of socket for [main_window]. + * [socket_left_id] is id of socket for [left_window]. + * [socket_right_id] is id of socket for [right_window]. + * [RU] + * Настраивает плаги для работы с сокетами в утилите ubl-settings-manager. + * [main_window] - контейнер основного интерфейса приложения. + * [left_window] - контейнер для виджетов которые должны отображаться в левой части шапки ubl-settings-manager. + * [right_window] - контейнер для виджетов которые должны отображаться в правой части шапки ubl-settings-manager. + * [socket_main_id] - id сокета для [main_window]. + * [socket_left_id] - id сокета для [left_window]. + * [socket_right_id] - id сокета для [right_window]. +*/ +void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id){ + if (main_window&&socket_main_id>-1){ + gtk_widget_hide(gtk_widget_get_toplevel(main_window)); + GtkWidget *plug_main=gtk_plug_new(socket_main_id); + GtkWidget *plug_left=NULL; + GtkWidget *plug_right=NULL; + GtkWidget *box=NULL; + g_signal_connect(G_OBJECT(plug_main), "destroy", G_CALLBACK(gtk_main_quit),NULL); + if (socket_left_id>-1&&left_window){ + plug_left=gtk_plug_new(socket_left_id); + g_object_ref(left_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); + gtk_container_add(GTK_CONTAINER(plug_left),left_window); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"primary-toolbar"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"button"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"opacited"); + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"color"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_left),"noborder"); + gtk_widget_show(plug_left); + } + else if (left_window){ + if (box==NULL){ + box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); + gtk_box_reorder_child(GTK_BOX(main_window),box,0); + gtk_widget_show(box); + } + gtk_style_context_add_class(gtk_widget_get_style_context(left_window),"inherited"); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(left_window)),left_window); + gtk_box_pack_end(GTK_BOX(box),left_window,0,0,5); + } + if (socket_right_id>-1&&right_window){ + plug_right=gtk_plug_new(socket_right_id); + g_object_ref(right_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); + gtk_container_add(GTK_CONTAINER(plug_right),right_window); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"primary-toolbar"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"button"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"opacited"); + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"color"); + gtk_style_context_add_class(gtk_widget_get_style_context(plug_right),"noborder"); + gtk_widget_show(plug_right); + } + else if (right_window){ + if (box==NULL){ + box=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,5); + gtk_box_pack_start(GTK_BOX(main_window),box,0,0,5); + gtk_box_reorder_child(GTK_BOX(main_window),box,0); + gtk_widget_show(box); + } + gtk_style_context_add_class(gtk_widget_get_style_context(right_window),"inherited"); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(right_window)),right_window); + gtk_box_pack_start(GTK_BOX(box),right_window,0,0,5); + } + g_object_ref(main_window); + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(main_window)),main_window); + gtk_container_add(GTK_CONTAINER(plug_main),main_window); + gtk_widget_show(plug_main); + } +} + +#ifdef WEBKIT_FOUND + +/**yon_ubl_browser_window_open(char *link, char *browser_window_name) + * [EN] + * Launches integrated browser window, named [browser_window_name] at header with [link]. + * [RU] + * Открывает встроенный браузер с именем [browser_window_name] и показываемой страницей по ссылке [link] +*/ +void yon_ubl_browser_window_open(char *link, char *browser_window_name){ + GtkWidget *browser=gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget *web_place=gtk_box_new(GTK_ORIENTATION_VERTICAL,0); + GtkWidget *header=gtk_header_bar_new(); + GtkWidget *header_label=gtk_label_new(browser_window_name); + GtkWidget *WebView=webkit_web_view_new(); + gtk_container_add(GTK_CONTAINER(browser),web_place); + gtk_window_set_titlebar(GTK_WINDOW(browser),header); + gtk_window_set_title(GTK_WINDOW(browser),browser_window_name); + gtk_widget_set_size_request(browser,800,600); + gtk_header_bar_set_custom_title(GTK_HEADER_BAR(header),header_label); + gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(header),1); + webkit_web_view_load_uri(WEBKIT_WEB_VIEW(WebView),link); + gtk_box_pack_start(GTK_BOX(web_place),WebView,1,1,0); + gtk_widget_show_all(browser); +} +#else + +/**yon_ubl_browser_window_open(char *link, char *browser_window_name) + * [EN] + * Launches browser with [link]. + * [browser_window_name] is't used. It's needed for compatibility with webkit version of that function. + * [RU] + * Открывает браузер со страницей по ссылке [link] + * [browser_window_name] не используется. Нужна для совместимости с webkit версией этой функции. +*/ +void yon_ubl_browser_window_open(char *link, char *browser_window_name){ + char *user=getenv("SUDO_USER"); + if (!user) + user=getlogin(); + char *command=yon_char_unite("sudo -u ",user," xdg-open ", link,NULL); + yon_launch_app(command); +} +#endif + +#endif \ No newline at end of file diff --git a/source/ubl-utils.h b/source/ubl-utils.h new file mode 100644 index 0000000..acd60c5 --- /dev/null +++ b/source/ubl-utils.h @@ -0,0 +1,326 @@ +#ifndef UBL_UTILS +#define UBL_UTILS +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ubl-cmake.h" +#ifdef WEBKIT_FOUND + #include +#endif +#define DesktopPath "/usr/share/applications/" + +#define for_dictionaries(obj, obj1) for (obj = obj1->first; obj != NULL; obj = obj->next) + +#define new(type) malloc(sizeof(type)) +#define new_arr(type,size) malloc(sizeof(type)*size) + +#define yon_ubl_set_config_save_data_pointer(command) config_commands.config_save_data = command + +#define yon_ubl_load_global_config(command, size_pointer) yon_config_load(command, size_pointer) +#define yon_ubl_load_local_config(command, size_pointer) yon_config_load(command, size_pointer) +#define yon_ubl_save_global_config(command) yon_config_save(command) +#define yon_ubl_save_local_config(command) yon_config_save(command) + +#define try bool __HadError=false; +#define catch(x) ExitJmp:if(__HadError) +#define throw(x) {__HadError=true;goto ExitJmp;} +#define file_source_login_min_max "/etc/login.defs" + +typedef enum +{ + #ifdef __GTK_H__ + DICTIONARY_GTK_WIDGETS_TYPE, + #endif + DICTIONARY_OTHER_TYPE + +} DICT_TYPE; + +typedef struct +{ + char *command; + int *exitcode; +} thread_output; + + +typedef struct dictionary +{ + char *key; + void *data; + struct dictionary *next; + struct dictionary *prev; + struct dictionary *first; + DICT_TYPE data_type; +} dictionary; + +typedef struct apps +{ + char *Name; + int Type; + char *Categories; + char *Exec; + char *Icon; + int Pluggable; + int DualPluggable; +} apps; + +typedef char** config_str; +// dictionary functions + +/**yon_dictionary_get_data(dictionary, type) + * [EN] + * Gets data from dictionary. + * [dictionary] is dictionary, from which data should be extracted; + * [type] is type of data, [dictionary] contains. + * [RU] + * Возвращает данные из словаря. + * [dictionary] - словарь из которого достаются данные. + * [type] - тип данных, хранящихся в словаре [dictionary]. +*/ +#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) +#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_create_with_data(key,data); \ + else dict=yon_dictionary_create_with_data_connected(dict,key,data);} + +dictionary *yon_dictionary_create_empty(); + +dictionary *yon_dictionary_create_conneced(dictionary *targetdict); + +dictionary *yon_dictionary_get_last(dictionary *dict); + +dictionary *yon_dictionary_switch_places(dictionary *dict, int aim); + +void yon_dictionary_make_first(dictionary *dict); + +void yon_dictionary_make_nth(dictionary *dict, int nth); + +dictionary *yon_dictionary_create_with_data(char *key, void *data); + +dictionary *yon_dictionary_create_with_data_connected(dictionary *dict, char *key, void *data); + +dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect); + +dictionary *yon_dictionary_find(dictionary **dict, char *key); + +dictionary *yon_dictionary_rip(dictionary *dict); + +dictionary *yon_dictionary_get_nth(dictionary *dict, int place); + +void *yon_dictionary_free_all(dictionary *dictionary,void (data_manipulation)(void*)); + +// char functions +char* philos_str_remove(char *str, const char *sub); +char *yon_char_get_augumented(char *source, char *append); + +char *yon_char_new(char *chr); + +char *yon_char_unite(char *source, ...); + +char *yon_cut(char *source, int size, int startpos); + +char *yon_char_divide(char *source, int dividepos); + +char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); + +char *yon_char_from_int(int int_to_convert); + +char *yon_char_replace(char *source, char *find, char*replace); + +void philos_split_size_memory(char* str_value, int* size, char* pow_memory); + +char **yon_char_parse(char *parameters, int *size, char *divider); + +char** philos_str_split(char *parameters, int *size, char *divider); + +char **yon_char_parsed_shrink(char **char_string, int *size, int item_to_delete); + +int yon_char_parsed_check_exist(char **parameters, int size, char *param); + +int yon_char_find_count(char *source, char *find); + +int yon_char_parsed_includes_char_parsed (config_str source, config_str to_check, int source_size, int check_size); + +config_str yon_char_parsed_new (config_str old, int *old_size, ...); +config_str yon_char_parsed_append(config_str parsed, int *size, char *string); +// parsing functions + +config_str philos_list_user(int* size); + +char* philos_str_size_pow_byte(GtkWidget *combo_box_text); + +config_str philos_list_group(int* size); + +unsigned short philos_read_uid_min_max(char* filename, char* search); + +apps *yon_apps_scan_and_parse_desktops(int *sizef); + +void yon_apps_sort(apps *applist, int size); + +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); + +char *yon_config_get_parameter(config_str parameters, int size, char *param); + +char *yon_config_make_save_parameter_with_multiple_arguments(char *parameter_string, char *config_parameter, char *divider); + +// terminal-using functions + +int yon_launch_app(char *name); + +int yon_launch_app_with_arguments(char *name, char *args); + +int yon_launch(thread_output *thread); + +int* philos_int_append(int* array, int* size, int value); + +int* remove_element_int_array(int* array, int* size, int index); +// Gtk functions + +#ifdef __GTK_H__ +#ifdef VTE_TERMINAL + +/** + * +*/ +void yon_terminal_integrated_launch(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument); +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); +#endif + +/**yon_gtk_builder_get_widget(builder, widget_name) + * [EN] + * Returns GtkWidget from GtkBuilder *[builder]. + * [builder] is GtkBuilder*; + * [widget_name] is id of widget; +*/ +#define yon_gtk_builder_get_widget(builder, widget_name) GTK_WIDGET(gtk_builder_get_object(builder, widget_name)) + +typedef struct +{ + GtkWidget *Icon; + GtkWidget *Label; + GtkWidget *IconView; + GtkListStore *List; +} expander_icon_view; + +// GtkWidget *yon_gtk_app_chooser_apps_create(); + +// dictionary *yon_gtk_app_chooser_create(); + +// expander_icon_view yon_gtk_icon_view_expander_create(GtkWidget *pack, ...); + +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); + +int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment); + +int yon_dictionary_gtk_pack_start_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); +int yon_dictionary_gtk_pack_end_multiple_widgets(dictionary *dict, GtkWidget *destination, gboolean expand, gboolean fill, int padding); + + + +typedef enum +{ + BACKGROUND_IMAGE_SUCCESS_TYPE, + BACKGROUND_IMAGE_FAIL_TYPE +} BACKGROUND_IMAGE_TYPE; + +typedef struct { + BACKGROUND_IMAGE_TYPE type; + GtkWidget *icon; + GtkWidget *box; + GtkWidget *label; + char* text_to_render; +} render_data; + + +/**yon_ubl_status_box_setup(render,icon,box,label) + * [EN] + * Sets up [render] structure of type render_data. + * [icon] is GtkImage widget of status box for showing status icons; + * [box] is GtkBox widget of status box for showing status color; + * [label] is GtkLabel widget of status box for showing status text; + * [RU] + * Настраивает структуру [render] типа render_data. + * [icon] - виджет типа GtkIcon в котором будут отображаться статусные иконки; + * [box] - виджет типа GtkBox в котором будет отображаться цвет статуса; + * [label] - виджет типа GtkLabel в котором будет отображаться текст статусного сообщения; +*/ +int yon_ubl_status_box_setup(GtkWidget *icon, GtkWidget *box, GtkWidget *label); + +/**yon_ubl_status_box_render(render,text,type) + * [EN] + * Renders message in status box; + * [render] is render_data structure of status box; + * [text] is text to be shown in status box; + * [type] if type of message. Can be BACKGROUND_IMAGE_FAIL_TYPE or BACKGROUND_IMAGE_SUCCESS_TYPE + * [RU] + * Отображает сообщение в статусном окне. + * [render] - структура типа render_data для нужного статусного окна; + * [text] - текст, отображаемый в статусном окне; + * [type] - тип сообщения. Может быть: + * BACKGROUND_IMAGE_FAIL_TYPE (красный фон,иконка - восклицательный знак) + * или + * BACKGROUND_IMAGE_SUCCESS_TYPE (Жёлтный фон, иконка - галка) +*/ +void yon_ubl_status_box_render(char *text, BACKGROUND_IMAGE_TYPE type); + +#ifdef __cplusplus + +/**yon_ubl_header_setup(overlay, head, image, imag_path) + * [EN] + * Sets up header of app. + * [overlay] is overlay for app header; + * [head] is box of header, which connects to [overlay] + * [image] is header background image; + * [imag_path] is path of image, shown in [image] + * [RU] + * Настраивает заголовок приложения. + * [overlay] - оверлей заголовка приложения; + * [head] - шапка заголовка, присоединяемая к [overlay] + * [image] - виджет картинки для заднего фона; + * [imag_path] - путь до картинки, загружаемой в [image] +*/ +#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay.gobj()), GTK_WIDGET(head.gobj()), GTK_WIDGET(image.gobj()), (char *)imag_path) +#else + +/**yon_ubl_header_setup(overlay, head, image, imag_path) + * [EN] + * Sets up header of app. + * [overlay] is overlay for app header; + * [head] is box of header, which connects to [overlay] + * [image] is header background image; + * [imag_path] is path of image, shown in [image] + * [RU] + * Настраивает заголовок приложения. + * [overlay] - оверлей заголовка приложения; + * [head] - шапка заголовка, присоединяемая к [overlay] + * [image] - виджет картинки для заднего фона; + * [imag_path] - путь до картинки, загружаемой в [image] +*/ +#define yon_ubl_header_setup(overlay, head, image, imag_path) _yon_ubl_header_setup(GTK_WIDGET(overlay), GTK_WIDGET(head), GTK_WIDGET(image), (char *)imag_path) +#endif + +void _yon_ubl_header_setup(GtkWidget *Overlay, GtkWidget *Head, GtkWidget *Image, char *image_path); + +void yon_ubl_setup_sockets(GtkWidget *main_window, GtkWidget *left_window, GtkWidget *right_window, int socket_main_id, int socket_left_id, int socket_right_id); +#ifdef WEBKIT_FOUND + +void yon_ubl_browser_window_open(char *link, char *browser_window_name); +#else +void yon_ubl_browser_window_open(char *link, char *browser_window_name); +#endif +#endif +#endif \ No newline at end of file diff --git a/source/view_add.c b/source/view_add.c new file mode 100644 index 0000000..c478654 --- /dev/null +++ b/source/view_add.c @@ -0,0 +1,298 @@ +#include "view_add.h" + +add_window *add_widgets = NULL; + + +add_window *add_setup_window(char* glade_path) { + if (add_widgets == NULL) { + add_widgets = malloc(sizeof(add_window)); + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + add_widgets->Window = yon_gtk_builder_get_widget(builder,"wndQuotasAdding"); + add_widgets->btnSaveAddSave = yon_gtk_builder_get_widget(builder,"btnSaveAddSave"); + add_widgets->btnAddCancel = yon_gtk_builder_get_widget(builder,"btnAddCancel"); + + add_widgets->entryAddCmd = yon_gtk_builder_get_widget(builder,"entryAddCmd"); + add_widgets->cbxAddQuotaObj = yon_gtk_builder_get_widget(builder,"cbxAddQuotaObj"); + add_widgets->cbxAddQuotaLevel2 = yon_gtk_builder_get_widget(builder,"cbxAddQuotaLevel2"); + add_widgets->cbtAddDevice = yon_gtk_builder_get_widget(builder,"cbtAddDevice"); + add_widgets->lblCPULimitAdd = yon_gtk_builder_get_widget(builder,"lblCPULimitAdd"); + add_widgets->spinCPULimitAdd = yon_gtk_builder_get_widget(builder,"spinCPULimitAdd"); + add_widgets->chkCPULimitAdd = yon_gtk_builder_get_widget(builder,"chkCPULimitAdd"); + + add_widgets->chkPaddingFLAdd = yon_gtk_builder_get_widget(builder,"chkPaddingFLAdd"); + add_widgets->spinPaddingFLAdd = yon_gtk_builder_get_widget(builder,"spinPaddingFLAdd"); + add_widgets->cmbPaddingFLAdd = yon_gtk_builder_get_widget(builder,"cmbPaddingFLAdd"); + + add_widgets->chkSevereRestrictionAdd = yon_gtk_builder_get_widget(builder,"chkSevereRestrictionAdd"); + add_widgets->spinSevereRestrictionAdd = yon_gtk_builder_get_widget(builder,"spinSevereRestrictionAdd"); + add_widgets->cmbSevereRestrictionAdd = yon_gtk_builder_get_widget(builder,"cmbSevereRestrictionAdd"); + + add_widgets->chkSoftRestrictionAdd = yon_gtk_builder_get_widget(builder,"chkSoftRestrictionAdd"); + add_widgets->spiSevereRestrictionAdd = yon_gtk_builder_get_widget(builder,"spiSevereRestrictionAdd"); + add_widgets->cmSevereRestrictionAdd = yon_gtk_builder_get_widget(builder,"cmSevereRestrictionAdd"); + + add_widgets->chbAddRead = yon_gtk_builder_get_widget(builder,"chbAddRead"); + add_widgets->spinAddRead = yon_gtk_builder_get_widget(builder,"spinAddRead"); + add_widgets->cbtAddRead = yon_gtk_builder_get_widget(builder,"cbtAddRead"); + + add_widgets->spinAddWrite = yon_gtk_builder_get_widget(builder,"spinAddWrite"); + add_widgets->chbAddWrite = yon_gtk_builder_get_widget(builder,"chbAddWrite"); + add_widgets->cbtAddWrite = yon_gtk_builder_get_widget(builder,"cbtAddWrite"); + + device_fill_disk(add_widgets->cbtAddDevice); + add_event(add_widgets); + add_init_windows(); + add_localization(add_widgets); + } + + return add_widgets; +} + +void add_init_windows() { + add_set_active_widgets(add_widgets->chkSoftRestrictionAdd, add_widgets->spiSevereRestrictionAdd, add_widgets->cmSevereRestrictionAdd); + add_set_active_widgets(add_widgets->chkSevereRestrictionAdd, add_widgets->spinSevereRestrictionAdd, add_widgets->cmbSevereRestrictionAdd); + add_set_active_widgets(add_widgets->chkPaddingFLAdd, add_widgets->spinPaddingFLAdd, add_widgets->cmbPaddingFLAdd); + add_set_active_widgets(add_widgets->chkCPULimitAdd, add_widgets->spinCPULimitAdd, add_widgets->lblCPULimitAdd); + add_set_active_widgets(add_widgets->chbAddWrite, add_widgets->spinAddWrite, add_widgets->cbtAddWrite); + add_set_active_widgets(add_widgets->chbAddRead, add_widgets->spinAddRead, add_widgets->cbtAddRead); + add_generate_cmd(); +} + +void add_event(add_window *widgets) { + g_signal_connect(G_OBJECT(widgets->btnAddCancel),"clicked",G_CALLBACK(add_on_destroy_subwindow),NULL); + g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(add_destroy), NULL); + g_signal_connect(G_OBJECT(widgets->chkSoftRestrictionAdd), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkSevereRestrictionAdd), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkPaddingFLAdd), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkCPULimitAdd), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chbAddRead), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chbAddWrite), "toggled", G_CALLBACK(add_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->cbxAddQuotaObj),"changed",G_CALLBACK(add_update_combo_box), NULL); + + g_signal_connect(G_OBJECT(widgets->spiSevereRestrictionAdd),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinSevereRestrictionAdd),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinPaddingFLAdd),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinCPULimitAdd),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinAddRead),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinAddWrite),"value-changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmSevereRestrictionAdd),"changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmbSevereRestrictionAdd),"changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmbPaddingFLAdd),"changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtAddRead),"changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtAddWrite),"changed",G_CALLBACK(add_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtAddDevice),"changed",G_CALLBACK(add_generate_cmd), NULL); + +} + +void add_destroy(GtkWidget *self) { + add_widgets = NULL; +} + +void add_set_active_widgets(GtkWidget *self, GtkWidget *entry, GtkWidget *label) { + gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + gtk_widget_set_sensitive(entry, active); + gtk_widget_set_sensitive(label, active); +} + +void add_localization(add_window *widgets) { + +} + +void add_on_destroy_subwindow(GtkWidget *self) { + gtk_widget_destroy(gtk_widget_get_toplevel(self)); + add_widgets = NULL; + +} + +add_window *get_widget_add() { + return add_widgets; +} + +void add_show(GtkWidget *self, char* glade_path) { + if (add_widgets != NULL) { + add_update_combo_box(); + gtk_widget_show_all(add_widgets->Window); + + } + else { + add_setup_window(glade_path); + add_update_combo_box(); + gtk_widget_show_all(add_widgets->Window); + } +} + +char* add_get_select_device_to_level_2() { + char* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(add_widgets->cbxAddQuotaLevel2)); + if (text != NULL) { + return text; + } + else { + char* str = (char*)malloc(sizeof(char*)*2); + str[0] = '-'; + str[1] = '\0'; + return str; + } +} + +char* add_get_select_device() { + char* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(add_widgets->cbtAddDevice)); + if (text != NULL) { + return text; + } + else { + char* str = (char*)malloc(sizeof(char*)*2); + str[0] = '-'; + str[1] = '\0'; + return str; + } +} +int add_get_read_device_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbtAddRead)); +} +int add_get_write_device_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbtAddWrite)); +} +int add_get_soft_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cmSevereRestrictionAdd)); +} +int add_get_hard_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cmbSevereRestrictionAdd)); +} +int add_get_limit_cpu_size() { + return -1; +} +int add_get_limit_swap_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cmbPaddingFLAdd)); +} +int add_get_quota_object_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbxAddQuotaObj)); +} +char* add_get_read_device() { + return philos_get_size_bite(add_widgets->chbAddRead, add_widgets->spinAddRead, + add_widgets->cbtAddRead); +} +char* add_get_write_device() { + return philos_get_size_bite(add_widgets->chbAddWrite, add_widgets->spinAddWrite, + add_widgets->cbtAddWrite); +} +char* add_get_soft() { + return philos_get_size_bite(add_widgets->chkSoftRestrictionAdd, add_widgets->spiSevereRestrictionAdd, + add_widgets->cmSevereRestrictionAdd); +} +char* add_get_hard() { + return philos_get_size_bite(add_widgets->chkSevereRestrictionAdd, add_widgets->spinSevereRestrictionAdd, + add_widgets->cmbSevereRestrictionAdd); +} +char* add_get_limit_cpu() { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chkCPULimitAdd))) { + int size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinCPULimitAdd)); + return yon_char_from_int(size_bite); + } + else { + char* str = (char*)malloc(sizeof(char*)*2); + str[0] = '-'; + str[1] = '\0'; + return str; + } +} +char* add_get_limit_swap() { + return philos_get_size_bite(add_widgets->chkPaddingFLAdd, add_widgets->spinPaddingFLAdd, + add_widgets->cmbPaddingFLAdd); +} +char* add_get_quota_object() { + return gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(add_widgets->cbxAddQuotaObj)); +} +void add_update_combo_box() { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbxAddQuotaObj)); + char* cmd = NULL; + config_str fill_cmb_2 = NULL; + int size = 0; + if (menu_id == 0) { + fill_cmb_2 = philos_list_user(&size); + + } + else if (menu_id == 1) { + + } + else if (menu_id == 2) { + + } + else if (menu_id == 3) { + + } + if (menu_id >= 0) { + gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(add_widgets->cbxAddQuotaLevel2)); + philos_fill_combo_box_text(add_widgets->cbxAddQuotaLevel2, fill_cmb_2, size); + // yon_terminal_integrated_launch(widgets->vteProcesses, cmd, NULL, NULL); + } +} +void add_generate_cmd() { + char* str_cmd = ""; + char* split_simvol = g_malloc0(sizeof(char)*2); + int size_bite = 0; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chkSoftRestrictionAdd))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spiSevereRestrictionAdd)); + str_cmd = yon_char_unite(str_cmd, + "MemoryHigh=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(add_widgets->cmSevereRestrictionAdd), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chkSevereRestrictionAdd))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinSevereRestrictionAdd)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemoryMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(add_widgets->cmbSevereRestrictionAdd), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chkPaddingFLAdd))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinPaddingFLAdd)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemorySwapMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(add_widgets->cmbPaddingFLAdd), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chkCPULimitAdd))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinCPULimitAdd)); + 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_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chbAddRead))) { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbtAddDevice)); + if (menu_id != -1) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinAddRead)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "IOReadBandwidthMax=\"", + get_device_cfg()->name_disk[menu_id], + " ", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(add_widgets->cbtAddRead),"\"", NULL); + } + split_simvol[0] = ','; + split_simvol[1] = '\0'; + + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_widgets->chbAddWrite))) { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(add_widgets->cbtAddDevice)); + if (menu_id != -1) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(add_widgets->spinAddWrite)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "IOWriteBandwidthMax=\"", + get_device_cfg()->name_disk[menu_id], + " ", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(add_widgets->cbtAddWrite),"\"", NULL); + } + } + gtk_entry_set_text(GTK_ENTRY(add_widgets->entryAddCmd), str_cmd); + free(split_simvol); +} diff --git a/source/view_add.h b/source/view_add.h new file mode 100644 index 0000000..261d998 --- /dev/null +++ b/source/view_add.h @@ -0,0 +1,81 @@ +#ifndef VIEW_ADD_H +#define VIEW_ADD_H +#include +#include +#include "ubl-utils.h" +#include "ubl-strings.h" +#include +#include +#include +#include +#include +#include +#include +#include "my_device.h" + +// Переменные +typedef struct { + GtkWidget* Window; + GtkWidget* btnSaveAddSave; + GtkWidget* btnAddCancel; + + GtkWidget* entryAddCmd; + GtkWidget* chbAddRead; + GtkWidget* spinAddRead; + GtkWidget* cbtAddRead; + + GtkWidget* chbAddWrite; + GtkWidget* spinAddWrite; + GtkWidget* cbtAddWrite; + + GtkWidget* chkSoftRestrictionAdd; + GtkWidget* spiSevereRestrictionAdd; + GtkWidget* cmSevereRestrictionAdd; + + GtkWidget* chkSevereRestrictionAdd; + GtkWidget* spinSevereRestrictionAdd; + GtkWidget* cmbSevereRestrictionAdd; + + GtkWidget* chkPaddingFLAdd; + GtkWidget* spinPaddingFLAdd; + GtkWidget* cmbPaddingFLAdd; + + GtkWidget* chkCPULimitAdd; + GtkWidget* spinCPULimitAdd; + GtkWidget* lblCPULimitAdd; + + GtkWidget* cbtAddDevice; + GtkWidget* cbxAddQuotaObj; + GtkWidget* cbxAddQuotaLevel2; +} add_window; +// Функции +add_window *add_setup_window(char* glade_path); +void add_event(add_window *widgets); +void add_localization(add_window *widgets); +void add_on_destroy_subwindow(GtkWidget *self); +add_window *get_widget_add(); +void add_show(GtkWidget *self, char* glade_path); +void add_destroy(GtkWidget *self); +void add_set_active_widgets(GtkWidget *self, GtkWidget *entry, GtkWidget *label); +void add_init_windows(); +void add_update_combo_box(); +char* add_get_select_device(); +char* add_get_read_device(); +char* add_get_write_device(); +char* add_get_soft(); +char* add_get_hard(); +char* add_get_limit_cpu(); +char* add_get_limit_swap(); +char* add_get_quota_object(); + +int add_get_read_device_size(); +int add_get_write_device_size(); +int add_get_soft_size(); +int add_get_hard_size(); +int add_get_limit_cpu_size(); +int add_get_limit_swap_size(); +int add_get_quota_object_size(); + +char* add_get_select_device_to_level_2(); +void add_generate_cmd(); +#endif \ No newline at end of file diff --git a/source/view_edit.c b/source/view_edit.c new file mode 100644 index 0000000..7127154 --- /dev/null +++ b/source/view_edit.c @@ -0,0 +1,298 @@ +#include "view_edit.h" + +edit_window *edit_widgets = NULL; + +edit_window *edit_setup_window(char* glade_path){ + if (edit_widgets == NULL) { + edit_widgets = malloc(sizeof(edit_window)); + GtkBuilder *builder = gtk_builder_new_from_file(glade_path); + edit_widgets->Window = yon_gtk_builder_get_widget(builder,"wndQuotasEdit"); + edit_widgets->btnEditCancel = yon_gtk_builder_get_widget(builder,"btnEditCancel"); + edit_widgets->btnSaveEditSave = yon_gtk_builder_get_widget(builder,"btnSaveEditSave"); + + edit_widgets->cbtEditDevice = yon_gtk_builder_get_widget(builder,"cbtEditDevice"); + edit_widgets->lblCPULimitEdit = yon_gtk_builder_get_widget(builder,"lblCPULimitEdit"); + edit_widgets->spinCPULimitEdit = yon_gtk_builder_get_widget(builder,"spinCPULimitEdit"); + edit_widgets->chkCPULimitEdit = yon_gtk_builder_get_widget(builder,"chkCPULimitEdit"); + + edit_widgets->chkPaddingFLEdit = yon_gtk_builder_get_widget(builder,"chkPaddingFLEdit"); + edit_widgets->spinPaddingFLEdit = yon_gtk_builder_get_widget(builder,"spinPaddingFLEdit"); + edit_widgets->cmbPaddingFLEdit = yon_gtk_builder_get_widget(builder,"cmbPaddingFLEdit"); + + edit_widgets->chkSevereRestrictionEdit = yon_gtk_builder_get_widget(builder,"chkSevereRestrictionEdit"); + edit_widgets->spinSevereRestrictionEdit = yon_gtk_builder_get_widget(builder,"spinSevereRestrictionEdit"); + edit_widgets->cmbSevereRestrictionEdit = yon_gtk_builder_get_widget(builder,"cmbSevereRestrictionEdit"); + + edit_widgets->chkSoftRestrictionEdit = yon_gtk_builder_get_widget(builder,"chkSoftRestrictionEdit"); + edit_widgets->spiSevereRestrictionEdit = yon_gtk_builder_get_widget(builder,"spiSevereRestrictionEdit"); + edit_widgets->cmSevereRestrictionEdit = yon_gtk_builder_get_widget(builder,"cmSevereRestrictionEdit"); + + edit_widgets->chbEditRead = yon_gtk_builder_get_widget(builder,"chbEditRead"); + edit_widgets->spinEditRead = yon_gtk_builder_get_widget(builder,"spinEditRead"); + edit_widgets->cbtEditRead = yon_gtk_builder_get_widget(builder,"cbtEditRead"); + + edit_widgets->spinEditWrite = yon_gtk_builder_get_widget(builder,"spinEditWrite"); + edit_widgets->chbEditWrite = yon_gtk_builder_get_widget(builder,"chbEditWrite"); + edit_widgets->cbtEditWrite = yon_gtk_builder_get_widget(builder,"cbtEditWrite"); + edit_widgets->entryEditCmd = yon_gtk_builder_get_widget(builder,"entryEditCmd"); + device_fill_disk(edit_widgets->cbtEditDevice); + edit_event(edit_widgets); + edit_localization(edit_widgets); + } + return edit_widgets; +} + +void edit_event(edit_window *widgets) { + g_signal_connect(G_OBJECT(widgets->btnEditCancel),"clicked",G_CALLBACK(edit_on_hide_subwindow),NULL); + g_signal_connect(G_OBJECT(widgets->Window), "destroy", G_CALLBACK(edit_destroy), NULL); + g_signal_connect(G_OBJECT(widgets->chkSoftRestrictionEdit), "toggled", G_CALLBACK(edit_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkSevereRestrictionEdit), "toggled", G_CALLBACK(edit_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkPaddingFLEdit), "toggled", G_CALLBACK(edit_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chkCPULimitEdit), "toggled", G_CALLBACK(edit_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chbEditRead), "toggled", G_CALLBACK(edit_init_windows), NULL); + g_signal_connect(G_OBJECT(widgets->chbEditWrite), "toggled", G_CALLBACK(edit_init_windows), NULL); + + g_signal_connect(G_OBJECT(widgets->spiSevereRestrictionEdit),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinSevereRestrictionEdit),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinPaddingFLEdit),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinCPULimitEdit),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinEditRead),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->spinEditWrite),"value-changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmSevereRestrictionEdit),"changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmbSevereRestrictionEdit),"changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cmbPaddingFLEdit),"changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtEditRead),"changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtEditWrite),"changed",G_CALLBACK(edit_generate_cmd), NULL); + g_signal_connect(G_OBJECT(widgets->cbtEditDevice),"changed",G_CALLBACK(edit_generate_cmd), NULL); +} + +void edit_destroy(GtkWidget *self) { + edit_widgets = NULL; +} + +void edit_localization(edit_window *widgets) { + +} + +void edit_on_hide_subwindow(GtkWidget *self) { + gtk_widget_destroy(gtk_widget_get_toplevel(self)); + edit_widgets = NULL; +} + +edit_window *get_widget_edit() { + return edit_widgets; +} + +void edit_show(GtkWidget *self, char* glade_path) { + if (edit_widgets != NULL) { + gtk_widget_show_all(edit_widgets->Window); + } + else { + edit_setup_window(glade_path); + gtk_widget_show_all(edit_widgets->Window); + } + +} + +void edit_init_windows() { + edit_generate_cmd(); + edit_set_active_widgets(edit_widgets->chkSoftRestrictionEdit, edit_widgets->spiSevereRestrictionEdit, edit_widgets->cmSevereRestrictionEdit); + edit_set_active_widgets(edit_widgets->chkSevereRestrictionEdit, edit_widgets->spinSevereRestrictionEdit, edit_widgets->cmbSevereRestrictionEdit); + edit_set_active_widgets(edit_widgets->chkPaddingFLEdit, edit_widgets->spinPaddingFLEdit, edit_widgets->cmbPaddingFLEdit); + edit_set_active_widgets(edit_widgets->chkCPULimitEdit, edit_widgets->spinCPULimitEdit, edit_widgets->lblCPULimitEdit); + edit_set_active_widgets(edit_widgets->chbEditWrite, edit_widgets->spinEditWrite, edit_widgets->cbtEditWrite); + edit_set_active_widgets(edit_widgets->chbEditRead, edit_widgets->spinEditRead, edit_widgets->cbtEditRead); +} + +void edit_set_active_widgets(GtkWidget *self, GtkWidget *entry, GtkWidget *label) { + gboolean active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(self)); + gtk_widget_set_sensitive(entry, active); + gtk_widget_set_sensitive(label, active); +} + +char* edit_get_select_device() { + char* text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(edit_widgets->cbtEditDevice)); + if (text != NULL) { + return text; + } + else { + char* str = (char*)malloc(sizeof(char*)*2); + str[0] = '-'; + str[1] = '\0'; + return str; + } +} +int edit_get_read_device_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cbtEditRead)); +} +int edit_get_write_device_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cbtEditWrite)); +} +int edit_get_soft_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cmSevereRestrictionEdit)); +} +int edit_get_hard_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cmbSevereRestrictionEdit)); +} +int edit_get_limit_cpu_size() { + return -1; +} +int edit_get_limit_swap_size() { + return gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cmbPaddingFLEdit)); +} + +char* edit_get_read_device() { + return philos_get_size_bite(edit_widgets->chbEditRead, edit_widgets->spinEditRead, + edit_widgets->cbtEditRead); +} +char* edit_get_write_device() { + return philos_get_size_bite(edit_widgets->chbEditWrite, edit_widgets->spinEditWrite, + edit_widgets->cbtEditWrite); +} +char* edit_get_soft() { + return philos_get_size_bite(edit_widgets->chkSoftRestrictionEdit, edit_widgets->spiSevereRestrictionEdit, + edit_widgets->cmSevereRestrictionEdit); +} +char* edit_get_hard() { + return philos_get_size_bite(edit_widgets->chkSevereRestrictionEdit, edit_widgets->spinSevereRestrictionEdit, + edit_widgets->cmbSevereRestrictionEdit); +} +char* edit_get_limit_cpu() { + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chkCPULimitEdit))) { + int size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinCPULimitEdit)); + return yon_char_from_int(size_bite); + } + else { + char* str = (char*)malloc(sizeof(char*)*2); + str[0] = '-'; + str[1] = '\0'; + return str; + } +} +char* edit_get_limit_swap() { + return philos_get_size_bite(edit_widgets->chkPaddingFLEdit, edit_widgets->spinPaddingFLEdit, + edit_widgets->cmbPaddingFLEdit); +} + +// ================================================================= +void edit_set_select_device(char* str_value, int pow_mem) { + puts(str_value); +} +void edit_set_read_device(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chbEditRead, + edit_widgets->spinEditRead, + edit_widgets->cbtEditRead); +} +void edit_set_write_device(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chbEditWrite, + edit_widgets->spinEditWrite, + edit_widgets->cbtEditWrite); +} +void edit_set_soft(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chkSoftRestrictionEdit, + edit_widgets->spiSevereRestrictionEdit, + edit_widgets->cmSevereRestrictionEdit); +} +void edit_set_hard(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chkSevereRestrictionEdit, + edit_widgets->spinSevereRestrictionEdit, + edit_widgets->cmbSevereRestrictionEdit); +} +void edit_set_limit_cpu(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chkCPULimitEdit, + edit_widgets->spinCPULimitEdit, + edit_widgets->lblCPULimitEdit); +} +void edit_set_limit_swap(char* str_value, int pow_mem) { + edit_temp_set(str_value,pow_mem, edit_widgets->chkPaddingFLEdit, + edit_widgets->spinPaddingFLEdit, + edit_widgets->cmbPaddingFLEdit); +} +void edit_temp_set(char* str_value, int pow_mem, GtkWidget* cheek, GtkWidget* spin, GtkWidget* combo_box_text) { + char* search = "-"; + char* mem_size_pow = yon_char_new(str_value); + if (yon_char_find_count(mem_size_pow, search) == 0) { + int value = atoi(yon_char_divide_search(mem_size_pow, " ", -1)); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), value); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cheek), 1); + if (combo_box_text != NULL) { + // Todo: add code + gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box_text), pow_mem); + + } + } + else { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cheek), 0); + } +} +void edit_generate_cmd() { + char* str_cmd = ""; + char* split_simvol = g_malloc0(sizeof(char)*2); + int size_bite = 0; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chkSoftRestrictionEdit))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spiSevereRestrictionEdit)); + str_cmd = yon_char_unite(str_cmd, + "MemoryHigh=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(edit_widgets->cmSevereRestrictionEdit), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chkSevereRestrictionEdit))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinSevereRestrictionEdit)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemoryMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(edit_widgets->cmbSevereRestrictionEdit), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chkPaddingFLEdit))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinPaddingFLEdit)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "MemorySwapMax=", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(edit_widgets->cmbPaddingFLEdit), NULL); + split_simvol[0] = ','; + split_simvol[1] = '\0'; + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chkCPULimitEdit))) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinCPULimitEdit)); + 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_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chbEditRead))) { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cbtEditDevice)); + if (menu_id != -1) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinEditRead)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "IOReadBandwidthMax=\"", + get_device_cfg()->name_disk[menu_id], + " ", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(edit_widgets->cbtEditRead),"\"", NULL); + } + split_simvol[0] = ','; + split_simvol[1] = '\0'; + + } + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_widgets->chbEditWrite))) { + int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(edit_widgets->cbtEditDevice)); + if (menu_id != -1) { + size_bite = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(edit_widgets->spinEditWrite)); + str_cmd = yon_char_unite(str_cmd, split_simvol, + "IOWriteBandwidthMax=\"", + get_device_cfg()->name_disk[menu_id], + " ", + yon_char_from_int(size_bite), + philos_str_size_pow_byte(edit_widgets->cbtEditWrite),"\"", NULL); + } + } + gtk_entry_set_text(GTK_ENTRY(edit_widgets->entryEditCmd), str_cmd); + free(split_simvol); +} + diff --git a/source/view_edit.h b/source/view_edit.h new file mode 100644 index 0000000..32fd5f9 --- /dev/null +++ b/source/view_edit.h @@ -0,0 +1,83 @@ +#ifndef VIEW_EDIT_H +#define VIEW_EDIT_H +#include +#include +#include "ubl-utils.h" +#include "ubl-strings.h" +#include +#include +#include +#include +#include +#include +#include +#include "my_device.h" + +// Переменные +typedef struct { + GtkWidget* Window; + GtkWidget* btnSaveEditSave; + GtkWidget* btnEditCancel; + + GtkWidget* entryEditCmd; + GtkWidget* chbEditRead; + GtkWidget* spinEditRead; + GtkWidget* cbtEditRead; + + GtkWidget* chbEditWrite; + GtkWidget* spinEditWrite; + GtkWidget* cbtEditWrite; + + GtkWidget* chkSoftRestrictionEdit; + GtkWidget* spiSevereRestrictionEdit; + GtkWidget* cmSevereRestrictionEdit; + + GtkWidget* chkSevereRestrictionEdit; + GtkWidget* spinSevereRestrictionEdit; + GtkWidget* cmbSevereRestrictionEdit; + + GtkWidget* chkPaddingFLEdit; + GtkWidget* spinPaddingFLEdit; + GtkWidget* cmbPaddingFLEdit; + + GtkWidget* chkCPULimitEdit; + GtkWidget* spinCPULimitEdit; + GtkWidget* lblCPULimitEdit; + GtkWidget* cbtEditDevice; +} edit_window; + +// Функции +edit_window *edit_setup_window(char* glade_path); +void edit_event(edit_window *widgets); +void edit_localization(edit_window *widgets); +void edit_on_hide_subwindow(GtkWidget *self); +edit_window *get_widget_edit(); +void edit_show(GtkWidget *self, char* glade_path); +void edit_destroy(GtkWidget *self); +void edit_init_windows(); +void edit_set_active_widgets(GtkWidget *self, GtkWidget *entry, GtkWidget *label); +char* edit_get_select_device(); +char* edit_get_read_device(); +char* edit_get_write_device(); +char* edit_get_soft(); +char* edit_get_hard(); +char* edit_get_limit_cpu(); +char* edit_get_limit_swap(); +void edit_generate_cmd(); +void wrapper_edit_show(); +void edit_set_select_device(char* str_value, int pow_mem); +void edit_set_read_device(char* str_value, int pow_mem); +void edit_set_write_device(char* str_value, int pow_mem); +void edit_set_soft(char* str_value, int pow_mem); +void edit_set_hard(char* str_value, int pow_mem); +void edit_set_limit_cpu(char* str_value, int pow_mem); +void edit_set_limit_swap(char* str_value, int pow_mem); +void edit_temp_set(char* str_value, int pow_mem, GtkWidget* cheek, GtkWidget* spin, GtkWidget* combo_box_text); + +int edit_get_read_device_size(); +int edit_get_write_device_size(); +int edit_get_soft_size(); +int edit_get_hard_size(); +int edit_get_limit_cpu_size(); +int edit_get_limit_swap_size(); +#endif \ No newline at end of file diff --git a/ubl-settings-resourcequota-banner.png b/ubl-settings-resourcequota-banner.png new file mode 100644 index 0000000..8eb67cb Binary files /dev/null and b/ubl-settings-resourcequota-banner.png differ diff --git a/ubl-settings-resourcequota.css b/ubl-settings-resourcequota.css new file mode 100644 index 0000000..34e17f4 --- /dev/null +++ b/ubl-settings-resourcequota.css @@ -0,0 +1,156 @@ +.textHead{ + text-shadow: 2px 2px @theme_bg_color; + color: @theme_text_color; +} +.boxInfoMessError{ + background-color: #ea9999; +} +.boxInfoMessOK{ + background-color: #f3f0ac; +} +.bannerbackground { + background-color: #404040; +} +.view_app { + background-color: @theme_bg_color; +} +.view_app.view.cell:selected { + background-color:@theme_selected_bg_color; + color:@theme_selected_text_color; + transition: 10ms ease-out; + border-radius: 3px; +} +#GnomeIcon{ + border-style:solid; + border-bottom-width: 1px; + border-image: linear-gradient(90deg, alpha(@theme_text_color,0.4) 55%, alpha(@theme_bg_color, 0) 100%); + border-image-slice: 1; +} + +#SepIcon{ + background-color: alpha(@theme_text_color, 0.6); +} + +#iconlabel { + font-size:14px; + font-weight: bold; + +} +.roundborder * { + border-width:0px; + border-radius:5px; +} +.noborder { + border: none; +} +.menu:hover { + border-color:alpha(@theme_text_color, 0.01); +} +.menu { + border-color:alpha(@theme_text_color, 0.01); +} +.menu:hover >* { + border-color:alpha(@theme_text_color, 0.01); +} +.menuitembottom{ + margin-top:0px; + margin-bottom:3px; +} +.menuitemmiddle{ + margin-top:0px; + margin-bottom:0px; +} + +.menuitemtop{ + margin-bottom:0px; +} +.menuitemtop *{ + margin:2px 2px 0 2px; + padding: 5px 10px 3px 5px; +} +.menuitemmiddle *{ + margin:0 2px 0 2px; + padding: 3px 10px 3px 5px; +} +.menuitembottom *{ + margin:0 2px 2px 2px; + padding: 3px 10px 5px 5px; +} +.menuitemtop:hover { + background:@theme_bg_color; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; +} +.menuitemmiddle:hover { + background:@theme_bg_color; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; +} +.menuitembottom:hover { + background:@theme_bg_color; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; + +} +.menuitemtop:hover* { + margin:2px 2px 0 2px; + padding: 5px 10px 3px 5px; + background:@theme_selected_bg_color; + border-radius:2px; +} +.menuitemmiddle:hover* { + margin:0 2px 0 2px; + padding: 3px 10px 3px 5px; + background:@theme_selected_bg_color; + border-radius:2px; +} +.menuitembottom:hover* { + margin:0 2px 2px 2px; + padding: 3px 10px 5px 5px; + background:@theme_selected_bg_color; + border-radius:2px; +} + +.workingbg, #workingbg { + background-color:@theme_base_color; +} +.workingbg.view.cell:selected { + background-color:@theme_selected_bg_color; +} +.workingbg.view.cell:hover { + background-color:darker(@theme_selected_bg_color); + color:@theme_selected_text_color; + border-radius:3px; +} +.bkim { + transition: 200ms ease-out; + background-image: none; +} +.noborder{ +border:none; +} + +.bkim{ +opacity:0.99; +border:none; +} + +.bkim_no_plug{ +background-color: transparent; +opacity:0.99; +} + + +.thin{ + margin:0px; + padding: 0px; +} +.nobg{ + background: none; +} +.addbg * { + background-color: @theme_bg_color; +} \ No newline at end of file diff --git a/ubl-settings-resourcequota.desktop b/ubl-settings-resourcequota.desktop new file mode 100644 index 0000000..9d7483e --- /dev/null +++ b/ubl-settings-resourcequota.desktop @@ -0,0 +1,15 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=CPU and RAM quotas +Name[ru]=Квоты процессора и ОЗУ +GenericName=CPU and RAM quotas +GenericName[ru]=Квоты процессора и ОЗУ +Comment=Configuring CPU and RAM quota settings for groups and users of the system +Comment[ru]=Настройка параметров квот процессорного времени и ОЗУ для групп и пользователей системы +Type=Application +Exec=ubl-settings-resourcequota +Icon=com.ublinux.ubl-settings-resourcequota +Terminal=false +X-XfcePluggable=true +X-UBLPluggable=true +Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; diff --git a/ubl-settings-resourcequota.glade b/ubl-settings-resourcequota.glade new file mode 100644 index 0000000..c9045b9 --- /dev/null +++ b/ubl-settings-resourcequota.glade @@ -0,0 +1,4118 @@ + + + + + + + False + False + True + center + com.ublinux.ubl-settings-resourcequota + dialog + True + ubl-settings-resourcequota + 1.0 + Copyright © 2022 - 2023, UBSoft LLC + CPU and RAM quotas + https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-resourcequota + Project Home Page + Это приложение распространяется без каких-либо гарантий. +Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. + UBGroup + UBGroup + com.ublinux.ubl-settings-resourcequota + True + gpl-2-0 + + + True + False + vertical + 2 + + + False + end + + + False + False + 1 + + + + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + ubl-settings-resourcequota + + + + + + + + + + True + False + + + 90 + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 69 + com.ublinux.ubl-settings-resourcequota + + + False + True + 0 + + + + + True + False + + + True + False + + + True + False + vertical + + + 255 + True + False + end + CPU and RAM quotas + 0 + + + + + + + + True + True + 0 + + + + + 255 + True + False + start + Configuring CPU and RAM quota settings for groups and users of the system + True + 0 + + + + + + + + True + True + 1 + + + + + False + True + 0 + + + + + True + True + 0 + + + + + True + True + 1 + + + + + 1 + 1000 + 1 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + 1023 + 1 + 10 + + + 100 + 1 + 10 + + + 1023 + 1 + 10 + + + 1023 + 1 + 10 + + + 100 + 1 + 10 + + + 100 + 1 + 10 + + + False + start + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Quota object + + + False + True + 0 + + + + + 100 + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + User + Group + Process + Slice + + + + True + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Soft Restriction + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment4 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Severe Restriction + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment6 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + RAM limit + + + + + False + True + 0 + + + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment7 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Paging file limit + + + + + True + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment5 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + % + + + False + True + 2 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + CPU limit + + + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Device: + 0 + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Read + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 4 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment8 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Write + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment9 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Input/Output limit of block devices + + + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + + + + + True + False + Manual input (for advanced users) + + + + + False + True + 3 + + + + + False + True + 1 + + + + + True + False + + + True + False + + + False + True + 0 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + gtk-stop + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Cancel + + + False + True + 1 + + + + + + + False + True + end + 1 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + gtk-save + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Save + + + False + True + 1 + + + + + + + False + True + end + 1 + + + + + False + True + 2 + + + + + + + True + False + True + + + True + False + Settings quotas - Adding + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-resourcequota + 5 + + + + + + + False + start + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Quota object + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Soft Restriction + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment4 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Severe Restriction + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment6 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + RAM limit + + + + + False + True + 0 + + + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment7 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Paging file limit + + + + + True + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment5 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + % + + + False + True + 2 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + CPU limit + + + + + True + True + 1 + + + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + False + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Device: + 0 + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Read + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 4 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment9 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 0 + + + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Write + 0 + + + False + True + 0 + + + + + True + False + + + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment8 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + Kb + Mb + Gb + Tb + + + + False + True + 2 + + + + + False + True + 1 + + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Input/Output limit of block devices + + + + + False + True + 2 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0.019999999552965164 + in + + + True + False + 12 + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + + + + + True + False + Manual input (for advanced users) + + + + + False + True + 3 + + + + + False + True + 1 + + + + + True + False + + + True + False + + + False + True + 0 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + gtk-stop + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Cancel + + + False + True + 1 + + + + + + + False + True + end + 1 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + gtk-save + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Save + + + False + True + 1 + + + + + + + False + True + end + 1 + + + + + False + True + 2 + + + + + + + True + False + True + + + True + False + Settings quotas - Editing + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-resourcequota + 5 + + + + + + + True + False + dialog-information-symbolic + + + True + False + dialog-question-symbolic + + + True + False + False + + + imagemenuitem + True + False + image2 + False + + + + + + imagemenuitem + True + False + image1 + False + + + + + + True + False + process-stop-symbolic + + + True + False + emblem-ok-symbolic + + + False + False + 450 + dialog-question-symbolic + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + 10 + + + True + False + + + True + False + start + 20 + 20 + dialog-question-symbolic + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + start + 10 + 5 + Would you like to read documentation in the Web? + True + 0 + + + + + + + False + True + 0 + + + + + True + False + start + start + 10 + 10 + You will be redirected to documentation website where documentation is +translated and supported by community. + True + 0 + + + + False + True + 1 + + + + + Always redirect to online documentation + True + True + False + end + True + + + + False + True + end + 2 + + + + + + True + True + 1 + + + + + + True + True + 0 + + + + + True + False + 30 + True + + + Cancel + True + True + True + image8 + + + + True + True + 0 + + + + + Read Online + True + True + True + image9 + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + True + False + True + + + True + False + UBLinux Settings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + False + False + + + True + False + + + + + + True + False + + + + + + True + False + False + + + True + False + + + + + + True + False + + + + + + True + False + True + + + + + + 640 + 500 + False + 700 + 500 + com.ublinux.ubl-settings-resourcequota + center + + + True + False + vertical + + + True + False + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 25 + + + False + True + 0 + + + + + True + False + start + 5 + 5 + 5 + 5 + 6 + 6 + + + + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + vertical + + + 81 + True + False + + + True + False + start + + + -1 + + + + + False + True + 0 + + + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + True + vertical + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + True + vertical + + + True + True + + + True + False + vertical + + + True + True + in + + + True + False + + + True + True + liststore + 0 + + + + + + Type quota + True + + + + 0 + + + + + + + Quota +object + True + + + + 1 + + + + + + + Soft RAM limit, +(volume) + True + + + + 2 + + + + + + + Hard RAM limit, +(volume) + True + + + + 3 + + + + + + + Swap file +limit +(volume) + True + + + + 4 + + + + + + + CPU limit +(%) + True + + + + 5 + + + + + + + I/O +limit +(read) + True + + + + 6 + + + + + + + I/O +limit +(write) + True + + + + 7 + + + + + + + + + + + True + True + 0 + + + + + True + False + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + com.ublinux.ubl-settings-resourcequota.funnel + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Filters + + + False + True + 1 + + + + + + + False + True + 0 + + + + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + tab-new-symbolic + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Add + + + False + True + 1 + + + + + + + False + True + end + 2 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + error-correct-symbolic + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Edit + + + False + True + 1 + + + + + + + False + True + end + 3 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + software-remove-symbolic + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Remove + + + False + True + 1 + + + + + + + False + True + end + 4 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + + + True + False + dialog-information-symbolic + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + Information + + + False + True + 1 + + + + + + + False + True + end + 5 + + + + + False + True + 2 + + + + + + + True + False + List quotas + + + False + + + + + True + False + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + Update every + + + False + True + 0 + + + + + True + True + 5 + 5 + 5 + 5 + 5 + 5 + adjustment1 + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + seconds + + + False + True + 2 + + + + + True + True + True + 5 + 5 + 5 + 5 + 5 + 5 + + + True + False + reload + + + + + True + True + 3 + + + + + False + True + 0 + + + + + True + False + + + True + False + True + natural + adjustment3 + natural + UTF-8 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment3 + + + False + True + 1 + + + + + True + True + 1 + + + + + 1 + + + + + True + False + Dispatcher + + + 1 + False + + + + + True + False + vertical + + + True + False + + + All groups including empty + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + False + True + 0 + + + + + Core streams + True + True + False + 5 + 5 + 5 + 5 + 5 + 5 + True + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + + + True + False + True + natural + adjustment2 + natural + UTF-8 + 1024 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment2 + + + False + True + 1 + + + + + True + True + 1 + + + + + 2 + + + + + True + False + Processes + + + 2 + False + + + + + True + False + vertical + + + True + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + View properties for + + + False + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 0 + 0 + + User + Group + Process + Slice + + + + True + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + + + True + True + 2 + + + + + False + True + 0 + + + + + True + False + + + True + False + True + natural + adjustment3 + natural + UTF-8 + True + False + + + True + True + 0 + + + + + True + False + vertical + adjustment3 + + + False + True + 1 + + + + + True + True + 1 + + + + + 3 + + + + + True + False + Information + + + 3 + False + + + + + True + True + 0 + + + + + False + True + 0 + + + + + False + True + 2 + + + + + True + True + 0 + + + + + + + True + False + True + + + True + False + 5 + 5 + 5 + 5 + 2 + ubl-settings-resourcequota + + + + + + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 32 + com.ublinux.ubl-settings-resourcequota + + + + + True + False + + + True + True + False + True + menuSave + + + True + False + + + True + False + Save + + + False + True + 0 + + + + + True + False + pan-down-symbolic + + + False + True + 1 + + + + + + + False + True + 0 + + + + + True + True + True + False + True + True + menuAbout + none + + + + + + + False + True + 1 + + + + + end + 1 + + + + + True + False + + + True + True + False + True + menuLoad + + + True + False + + + True + False + Load + + + False + True + 0 + + + + + True + False + pan-down-symbolic + + + False + True + 1 + + + + + + + False + True + 0 + + + + + 2 + + + + + + + + vertical + + + + + + + + False + start + False + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + vertical + + + Type quota + True + True + False + start + True + + + False + True + 2 + + + + + Quota volume + True + True + False + start + True + + + False + True + 3 + + + + + Soft RAM limit, (volume) + True + True + False + start + True + + + False + True + 4 + + + + + True + False + end + 5 + 5 + True + + + gtk-cancel + True + True + True + center + True + + + False + True + 0 + + + + + gtk-save + True + True + True + center + True + + + False + True + 1 + + + + + False + True + end + 5 + + + + + Hard RAM limit, (volume) + True + True + False + start + True + + + False + True + 6 + + + + + Swap file limit (volume) + True + True + False + start + True + + + False + True + 7 + + + + + CPU limit (%) + True + True + False + start + True + + + False + True + 8 + + + + + I/O limit (write) + True + True + False + start + True + + + False + True + 8 + + + + + I/O limit (read) + True + True + False + start + True + + + False + True + 9 + + + + + + + True + False + True + + + True + False + Filters + + + + + + + + True + False + 32 + com.ublinux.ubl-settings-resourcequota + 5 + + + + + + diff --git a/ubl-settings-resourcequota.pot b/ubl-settings-resourcequota.pot new file mode 100644 index 0000000..d6d9317 --- /dev/null +++ b/ubl-settings-resourcequota.pot @@ -0,0 +1,240 @@ +# Language translations for ubl-settings-diskquota package. +# Copyright (C) 2022, UBTech LLC +# This file is distributed under the same license as the ubl-settings-diskquota package. +# UBLinux Team , 2022 +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-04-10 16:09+0000\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +msgid "User" +msgstr "" + +msgid "Group" +msgstr "" + +msgid "Process" +msgstr "" + +msgid "Slice" +msgstr "" + +msgid "Documentation" +msgstr "" + +msgid "Save to local configuration" +msgstr "" + +#: source/ubl-strings.h:10 +msgid "Save to global configuration" +msgstr "" + +#: source/ubl-strings.h:11 +msgid "Save configuration" +msgstr "" + +msgid "Kb" +msgstr "" + +msgid "Mb" +msgstr "" + +msgid "Gb" +msgstr "" + +msgid "Tb" +msgstr "" + +msgid "Type quota" +msgstr "" + +msgid "Quota volume" +msgstr "" + +msgid "Soft RAM limit, (volume)" +msgstr "" + +msgid "Hard RAM limit, (volume)" +msgstr "" + +msgid "Swap file limit (volume)" +msgstr "" + +msgid "CPU limit (%)" +msgstr "" + +msgid "I/O limit (read)" +msgstr "" + +msgid "I/O limit (write)" +msgstr "" + +msgid "Filters" +msgstr "" + +msgid "List quotas" +msgstr "" + +msgid "Dispatcher" +msgstr "" + +msgid "Processes" +msgstr "" + +msgid "Information" +msgstr "" + +msgid "seconds" +msgstr "" + +msgid "Update every" +msgstr "" + +msgid "Core streams" +msgstr "" + +msgid "All groups including empty" +msgstr "" + +msgid "View properties for" +msgstr "" + +msgid "Setting resource quotas" +msgstr "" + +msgid "CPU and RAM quotas" +msgstr "" + +msgid "Information" +msgstr "" + +msgid "Delete" +msgstr "" + +msgid "Edit" +msgstr "" + +msgid "Add" +msgstr "" + +msgid "Error saved local and global configuration" +msgstr "" + +msgid "" +"GTK settings disk quota for UBLinux\n" +"\n" +"Usage: ubl-settings-diskquota [OPTIONS...]\n" +"Options:\n" +" -h, --help\t Show this help\n" +" -V, --version\t Show package version\n" +" --lock-help Lock utility help\n" +" --lock-save Lock saving local and global configuration\n" +" --lock-save-local Lock save global configuration\n" +" --lock-save-global Lock load global configuration\n" +" --lock-load-global Lock load global configuration\n" +msgstr "" + +msgid "Global configuration read error" +msgstr "" + +msgid "Global configuration write error" +msgstr "" + +msgid "Nothing to save!" +msgstr "" + +msgid "Project Home Page" +msgstr "" + +msgid "Save" +msgstr "" + +msgid "Save in global and local configuration" +msgstr "" + +msgid "Save in global configuration" +msgstr "" + +msgid "Save in local configuration" +msgstr "" + +msgid "Global configuration downloaded successfully" +msgstr "" + +msgid "Load" +msgstr "" + +msgid "Load global configuration" +msgstr "" + +msgid "Load local configuration" +msgstr "" + +msgid "Local configuration downloaded successfully" +msgstr "" + +msgid "Local configuration reading error" +msgstr "" + +msgid "Local configuration successfully written" +msgstr "" + +msgid "Local configuration write error" +msgstr "" + +msgid "Help" +msgstr "" + +msgid "About" +msgstr "" + +msgid "Settings quotas - Editing" +msgstr "" + +msgid "Quota object" +msgstr "" + +msgid "RAM limit" +msgstr "" + +msgid "Soft Restriction" +msgstr "" + +msgid "Severe Restriction" +msgstr "" + +msgid "Paging file limit" +msgstr "" + +msgid "CPU limit" +msgstr "" + +msgid "Input/Output limit of block devices" +msgstr "" + +msgid "Device:" +msgstr "" + +msgid "Read" +msgstr "" + +msgid "Write" +msgstr "" + +msgid "Manual input (for advanced users)" +msgstr "" + +msgid "Settings quotas - Adding" +msgstr "" + + diff --git a/ubl-settings-resourcequota_ru.po b/ubl-settings-resourcequota_ru.po new file mode 100644 index 0000000..8f1180f --- /dev/null +++ b/ubl-settings-resourcequota_ru.po @@ -0,0 +1,372 @@ +# Russian translations for ubl-settings-diskquota package. +# Copyright (C) 2022, UBTech LLC +# This file is distributed under the same license as the ubl-settings-diskquota package. +# UBLinux Team , 2022 +# +#, fuzzy +msgid "test" +msgstr "" +"Project-Id-Version: ubl-settings-bootloader 1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-04-10 16:09+0000\n" +"PO-Revision-Date: 2023-01-01 00:00+0600\n" +"Last-Translator: UBLinux Team \n" +"Language-Team: Russian - UBLinux Team \n" +"Language: Russian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit" +#: source/ubl-strings.h:9 +#: source/ubl-strings.h:8 +#: source/ubl-strings.h:1 + +msgid "Quota deleted" +msgstr "Квота удалена" + +msgid "User" +msgstr "Пользователь" + +msgid "Group" +msgstr "Группа" + +msgid "Process" +msgstr "Процесс" + +msgid "Slice" +msgstr "Слайс" + +msgid "Version:" +msgstr "Версия:" + +#: source/ubl-strings.h:2 +msgid "CPU and RAM quotas settings" +msgstr "Настройки квот процессора и ОЗУ" + +#: 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 "Блокировка загрузки глобальной конфигурации" + +msgid "Read Online" +msgstr "Читать онлайн" + +msgid "Always redirect to online documentation" +msgstr "Всегда перенаправлять" + +msgid "Would you like to read documentation in the Web?" +msgstr "Вы хотите прочитать справку в Сети?" + +msgid "" +"You will be redirected to documentation website where documentation is\n" +"translated and supported by community." +msgstr "" +"Вы будете перенаправлены на сайт с документацией где страницы помощи\n" +"переводятся и поддерживаются сообществом." + +msgid "Documentation" +msgstr "Справка" + +msgid "Save to local configuration" +msgstr "Сохранить в локальную конфигурацию" + +#: source/ubl-strings.h:10 +msgid "Save to global configuration" +msgstr "Сохранить в глобальную конфигурацию" + +#: source/ubl-strings.h:11 +msgid "Save configuration" +msgstr "Сохранить конфигурацию" + +msgid "Kb" +msgstr "Кб" + +msgid "Mb" +msgstr "Мб" + +msgid "Gb" +msgstr "Гб" + +msgid "Tb" +msgstr "Тб" + +msgid "Type quota" +msgstr "Тип квоты" + +msgid "Quota volume" +msgstr "Объем квотирования" + +msgid "Soft RAM limit, (volume)" +msgstr "Мягкий лимит ОЗУ, (объём)" + +msgid "Hard RAM limit, (volume)" +msgstr "Жёсткий лимит ОЗУ, (объём)" + +msgid "Swap file limit (volume)" +msgstr "Лимит файлов подкачки (объём)" + +msgid "CPU limit (%)" +msgstr "Лимит ЦПУ (%)" + +msgid "I/O limit (read)" +msgstr "Лимит I/O (чтение)" + +msgid "I/O limit (write)" +msgstr "Лимит I/O (запись)" + +msgid "Filters" +msgstr "Фильтры" + +msgid "Quota\nvolume" +msgstr "Объем\nквотирования" + +msgid "Soft RAM limit,\n(volume)" +msgstr "Мягкий лимит ОЗУ,\n(объём)" + +msgid "Hard RAM limit,\n(volume)" +msgstr "Жёсткий лимит ОЗУ,\n(объём)" + +msgid "Swap file\nlimit\n(volume)" +msgstr "Лимит файлов\nподкачки\n(объём)" + +msgid "CPU limit\n(%)" +msgstr "Лимит ЦПУ\n(%)" + +msgid "I/O\nlimit\n(read)" +msgstr "Лимит\nI/O\n(чтение)" + +msgid "I/O\nlimit\n(write)" +msgstr "Лимит\nI/O\n(запись)" + +msgid "List quotas" +msgstr "Список квот" + +msgid "Dispatcher" +msgstr "Диспетчер" + +msgid "Processes" +msgstr "Процессы" + +msgid "Information" +msgstr "Информация" + +msgid "seconds" +msgstr "сек." + +msgid "Update every" +msgstr "Обновлять каждые" + +msgid "Core streams" +msgstr "Потоки ядра" + +msgid "All groups including empty" +msgstr "Все группы включая пустые" + +msgid "View properties for" +msgstr "Посмотреть свойства для" + +msgid "Setting resource quotas" +msgstr "Установка ресурсов квот" + +msgid "CPU and RAM quotas" +msgstr "Квоты процессора и ОЗУ" + +msgid "Delete" +msgstr "Удалить" + +msgid "Edit" +msgstr "Редактировать" + +msgid "Add" +msgstr "Добавить" + +msgid "Error saved local and global configuration" +msgstr "Сохранить глобальную и локальную конфигурацию" + +msgid "" +"GTK settings disk quota for UBLinux\n" +"\n" +"Usage: ubl-settings-diskquota [OPTIONS...]\n" +"Options:\n" +" -h, --help\t Show this help\n" +" -V, --version\t Show package version\n" +" --lock-help Lock utility help\n" +" --lock-save Lock saving local and global configuration\n" +" --lock-save-local Lock save global configuration\n" +" --lock-save-global Lock load global configuration\n" +" --lock-load-global Lock load global configuration\n" +msgstr "" +"GTK утилита настройки дисковых для UBLinux\n" +"\n" +"Использование: ubl-settings-diskquota [Параметры приложения...]\n" +"Параметры приложения:\n" +" -h, --help\t Показать параметры справки\n" +" -V, --version\t Показать версию пакета\n" +" --lock-help Блокировка вызова справки\n" +" --lock-save Блокировка сохранения локальной и глобальной " +"конфигурации\n" +" --lock-save-local Блокировка сохранения локальной конфигурации\n" +" --lock-save-global Блокировка сохранения глобальной конфигурации\n" +" --lock-load-global Блокировка загрузки глобальной конфигурации\n" + +msgid "Global configuration read error" +msgstr "Сохранить глобальную конфигурацию" + +msgid "Global configuration write error" +msgstr "Сохранить глобальную конфигурацию" + +msgid "Nothing to save!" +msgstr "Нечего сохранять!" + +msgid "Project Home Page" +msgstr "Главная страница проекта" + +msgid "Save" +msgstr "Сохранить" + +msgid "Save in global and local configuration" +msgstr "Сохранить в глобальную и локальную конфигурацию" + +msgid "Save in global configuration" +msgstr "Сохранить в глобальную конфигурацию" + +msgid "Save in local configuration" +msgstr "Сохранить в локальную конфигурацию" + +msgid "Global configuration downloaded successfully" +msgstr "Успешно загружена глобальная конфигурация" + +msgid "Load" +msgstr "Загрузить" + +msgid "Load global configuration" +msgstr "Загрузить глобальную конфигурацию" + +msgid "Load local configuration" +msgstr "Загрузить локальную конфигурацию" + +msgid "Local configuration downloaded successfully" +msgstr "Успешно загружена локальная конфигурация" + +msgid "Local configuration reading error" +msgstr "Загрузить локальную конфигурацию" + +msgid "Local configuration successfully written" +msgstr "Успешно записана локальная конфигурация" + +msgid "Local configuration write error" +msgstr "Загрузить локальную конфигурацию" + +msgid "Help" +msgstr "Справка" + +msgid "About" +msgstr "О программе" + +msgid "Settings quotas - Editing" +msgstr "Квоты настроек - Редактирование" + +msgid "Quota object" +msgstr "Объект квоты" + +msgid "Quota\nobject" +msgstr "Объект\nквоты" + +msgid "RAM limit" +msgstr "Лимит ОЗУ" + +msgid "Soft Restriction" +msgstr "Мягкое ограничение" + +msgid "Severe Restriction" +msgstr "Жесткое ограничение" + +msgid "Paging file limit" +msgstr "Лимит файлов подкачки" + +msgid "CPU limit" +msgstr "Лимит ЦПУ" + +msgid "Input/Output limit of block devices" +msgstr "Лимит операций Ввода/Вывода блочных устройств" + +msgid "Device:" +msgstr "Устройство:" + +msgid "Read" +msgstr "Чтение" + +msgid "Write" +msgstr "Запись" + +msgid "Manual input (for advanced users)" +msgstr "Ручной ввод (для опытных пользователей)" + +msgid "Settings quotas - Adding" +msgstr "Квоты настроек - Добавление" +#: source/ubl-strings.h:24 +msgid "Nothing were chosen" +msgstr "Ничего не было выбрано" + +msgid "Cancel" +msgstr "Отмена" + +#: source/ubl-strings.h:27 +msgid "Global configuration loading succseeded." +msgstr "Успешно загружена глобальная конфигурация" + +#: source/ubl-strings.h:28 +msgid "Local configuration loading succseeded." +msgstr "Успешно загружена локальная конфигурация" + +#: source/ubl-strings.h:30 +msgid "Local and global configuration saving succseeded." +msgstr "Успешно записаны локальная и глобальная конфигурация" + +#: source/ubl-strings.h:31 +msgid "Global configuration saving succseeded." +msgstr "Успешно записана глобальная конфигурация" + +#: source/ubl-strings.h:32 +msgid "Local configuration saving succseeded." +msgstr "Успешно записана локальная конфигурация" + +msgid "Configuring CPU and RAM quota settings for groups and users of the system" +msgstr "Настройка параметров квот процессорного времени и ОЗУ для групп и пользователей системы" + +