Исправлено основное окно

pull/24/head
Igor Belitskiy 2 years ago
parent 43b7e61a56
commit 2fca6f8589

@ -8,13 +8,10 @@ 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
DEPENDS = /bin/cmake
PREFIX ?= /usr
PKGNAME = $(MAKEFILE_DIR)
#PKGNAME = ubl-settings-diskquota
LATEST_TAG=
default_target: all
.PHONY: all init depend debug prepare check build uninstall install clean help
@ -39,16 +36,15 @@ depend:
exit 1; \
fi; \
done; \
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B${CMAKE_BUILD_DIR} --check-build-system CMakeFiles/Makefile.cmake 1 || exit 1; \
echo "Check depends: OK"
# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
debug: init build
@echo "Debug ..."; \
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}"; \
@gcc source/ubl-settings-cmake.h compile/ubl-cmake.h source/ubl-settings-multiseat.c source/ubl-settings-multiseat.h source/ubl-settings-multiseat-strings.h source/ubl-utils.c source/ubl-utils.h -o ubl-settings-multiseat `pkg-config --cflags --libs gtk+-3.0 vte-2.91 webkit2gtk-4.0 webkit2gtk-web-extension-4.0` -g
fi; \
echo "${CMAKE_BUILD_DIR}/${PKGNAME}"; \
cp ${CMAKE_BUILD_DIR}/${PKGNAME} ./; \
echo "Debug: OK"
prepare:
@ -92,8 +88,8 @@ uninstall:
@$(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) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.checked.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.warning.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/com.ublinux.${PKGNAME}.checked.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/com.ublinux.${PKGNAME}.warning.svg"
@$(RM) "${DESTDIR}${PREFIX}/share/polkit-1/actions/com.ublinux.${PKGNAME}.policy"
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
@ -121,15 +117,16 @@ install: check uninstall
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 -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.${PKGNAME}.funnel.svg"
@install -dm755 "${DESTDIR}${PREFIX}/share/polkit-1/actions"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "com.ublinux.${PKGNAME}.policy"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "gdb.policy"
@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 -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.${PKGNAME}.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; \
@ -147,14 +144,6 @@ clean:
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)"; \
@ -164,5 +153,5 @@ help:
echo "... compile"; \
echo "... install"; \
echo "... uninstall"; \
echo "... clean"; \
echo "... up_ver"
echo "... clean"

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>UBLinux</vendor>
<vendor_url>https://ublinux.ru</vendor_url>
<action id="com.ublinux.gdb.run">
<description>Run ubl-settings-diskquota as root</description>
<description xml:lang="ru">Запуск утилиты ubl-settings-diskquota с правами root</description>
<message>Authentication is required to run ubl-settings-diskquota</message>
<message xml:lang="ru">Требуется авторизация для запуска утилиты ubl-settings-diskquota с правами root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gdb</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

@ -34,7 +34,9 @@ void wrapper_add_user_show() {
}
void wrapper_edit_user_show() {
int index = wrapper_select_tree_view(&cfg_custom_gui.user);
printf("%d\n", index);
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
set_disk(activ_text);
set_temp_menu("usrquota", "edit");
temp_set_index(index);
set_all_config(all_config);
@ -58,6 +60,9 @@ void wrapper_add_group_show() {
}
void wrapper_edit_group_show() {
int index = wrapper_select_tree_view(&cfg_custom_gui.group);
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
set_disk(activ_text);
set_temp_menu("grpquota", "edit");
temp_set_index(index);
set_all_config(all_config);
@ -111,9 +116,13 @@ void unlock_spin_time(hotebook* widgets,void (*f)()) {
}
void entry_user_disk(GtkWidget *self,int* flag_update) {
block_spin_time(&cfg_custom_gui.user, wrapper_get_spin_time_gui_user);
if (flag_update) {
all_config->flag_set_data = 1;
all_config->flag_save = 3;
temp_on_destroy_subwindow(self);
}
get_status_disk(&cfg_custom_gui.user);
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.user.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.user,"usrquota", 0);
@ -121,11 +130,18 @@ void entry_user_disk(GtkWidget *self,int* flag_update) {
g_object_ref(cfg_custom_gui.user.liststore);
gtk_list_store_clear(cfg_custom_gui.user.liststore);
}
unlock_spin_time(&cfg_custom_gui.user, wrapper_get_spin_time_gui_user);
}
void entry_groups_disk(GtkWidget *self,int* flag_update) {
block_spin_time(&cfg_custom_gui.group, wrapper_get_spin_time_gui_group);
if (flag_update) {
all_config->flag_set_data = 1;
all_config->flag_save = 3;
temp_on_destroy_subwindow(self);
}
get_status_disk(&cfg_custom_gui.group);
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(cfg_custom_gui.group.comboBox));
activ_text= yon_char_divide_search(activ_text, " ", -1);
int find = fill_tree_view_user_group(all_config, activ_text, &cfg_custom_gui.group,"grpquota", 0);
@ -133,9 +149,13 @@ void entry_groups_disk(GtkWidget *self,int* flag_update) {
g_object_ref(cfg_custom_gui.group.liststore);
gtk_list_store_clear(cfg_custom_gui.group.liststore);
}
unlock_spin_time(&cfg_custom_gui.group, wrapper_get_spin_time_gui_group);
}
void entry_project_disk(GtkWidget *self,int* flag_update) {
void entry_project_disk(GtkWidget *self,int* flag_update) {
block_spin_time(&cfg_custom_gui.project, wrapper_get_spin_time_gui_project);
if (flag_update) {
all_config->flag_set_data = 1;
all_config->flag_save = 3;
temp_on_destroy_subwindow(self);
}
int find = fill_tree_view_project(all_config, &cfg_custom_gui.project,"prjquota", 0);
@ -143,6 +163,7 @@ void entry_project_disk(GtkWidget *self,int* flag_update) {
g_object_ref(cfg_custom_gui.project.liststore);
gtk_list_store_clear(cfg_custom_gui.project.liststore);
}
unlock_spin_time(&cfg_custom_gui.project, wrapper_get_spin_time_gui_project);
}
void tree_view_select_user(GtkWidget* self) {
@ -218,10 +239,12 @@ void template_remove(vector* vec_temp, hotebook* widgets) {
int index = wrapper_select_tree_view(widgets);
if (index!=-1) {
config_u_g_p* _config = (config_u_g_p*)vec_temp->pfVectorGet(vec_temp, index);
char* load_key = yon_char_new(_config->loaded_keys);
all_config->v_remove.pfVectorAdd(&all_config->v_remove, load_key);
model_clear_cfg(_config);
vec_temp->pfVectorDelete(vec_temp, index);
}
all_config->flag_save = 1;
}
}
void user_remove() {
@ -231,7 +254,7 @@ void user_remove() {
if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
gtk_list_store_remove(cfg_custom_gui.user.liststore, &iter);
}
template_remove(&all_config->v_user , &cfg_custom_gui.user);
template_remove(&all_config->v_user, &cfg_custom_gui.user);
}
void group_remove() {
@ -255,9 +278,7 @@ void project_remove() {
}
int wrapper_select_tree_view(hotebook* widgets) {
block_spin_time(widgets, wrapper_get_spin_time_gui_user);
block_spin_time(widgets, wrapper_get_spin_time_gui_group);
block_spin_time(widgets, wrapper_get_spin_time_gui_project);
int index = 0;
GtkTreeIter iter;
GtkTreeModel *model = GTK_TREE_MODEL(widgets->liststore);
@ -270,9 +291,6 @@ int wrapper_select_tree_view(hotebook* widgets) {
else {
//index_selected = -1;
}
unlock_spin_time(widgets, wrapper_get_spin_time_gui_user);
unlock_spin_time(widgets, wrapper_get_spin_time_gui_group);
unlock_spin_time(widgets, wrapper_get_spin_time_gui_project);
return index;
}
@ -377,6 +395,59 @@ void control_event(main_window* _config_main_gui, custom_window* _config_custom_
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinDaysFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinHoursFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->project.spinMinutesFile), "value-changed", G_CALLBACK(wrapper_get_spin_time_gui_project), NULL);
g_signal_connect(G_OBJECT(_config_custom_gui->user.cmbSetStatusDisk), "changed", G_CALLBACK(template_set_status_disk), &_config_custom_gui->user);
g_signal_connect(G_OBJECT(_config_custom_gui->group.cmbSetStatusDisk), "changed", G_CALLBACK(template_set_status_disk), &_config_custom_gui->group);
}
void template_set_status_disk(GtkWidget* self,hotebook* widgets) {
int menu_id_disk = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->comboBox));
int menu_id = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk));
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->comboBox));
activ_text = yon_char_divide_search(activ_text, " ", -1);
vector* v_disk_status = &all_config->v_disk_status;
int flag = 0;
if (v_disk_status->vectorList.total> 0 && menu_id_disk >= 0 && menu_id >= 0) {
for (int i = 0; i < v_disk_status->pfVectorTotal(v_disk_status); i++) {
disk_status* _config = (disk_status*)v_disk_status->pfVectorGet(v_disk_status, i);
if (strstr(_config->device, activ_text) && strstr(_config->device,widgets->name)) {
flag = 1;
_config->status = menu_id;
all_config->flag_set_data = 1;
}
}
}
if (flag == 0) {
disk_status* disk_cfg = malloc(sizeof(disk_status));
disk_cfg->device = yon_char_unite("DISK_QUOTA[",widgets->name,":",activ_text, "]",NULL);
disk_cfg->status = menu_id;
v_disk_status->pfVectorAdd(v_disk_status, disk_cfg);
all_config->flag_set_data = 1;
}
}
void get_status_disk(hotebook* widgets) {
int menu_id_disk = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->comboBox));
vector* v_disk_status = &all_config->v_disk_status;
if (v_disk_status->vectorList.total> 0 && menu_id_disk>=0) {
char* activ_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->comboBox));
activ_text = yon_char_divide_search(activ_text, " ", -1);
int status = 0;
for (int i = 0; i < v_disk_status->pfVectorTotal(v_disk_status); i++) {
disk_status* _config = (disk_status*)v_disk_status->pfVectorGet(v_disk_status, i);
if (strstr(_config->device, activ_text) && strstr(_config->device,widgets->name)) {
status = 1;
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), _config->status);
}
if (!status) {
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), -1);
}
}
}
else {
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->cmbSetStatusDisk), -1);
}
}
/*

@ -31,4 +31,5 @@ void get_spin_time_gui(vector* vec_u_g_p, hotebook* widgets);
void tree_view_select(GtkWidget* self, vector* vec_temp, hotebook* widgets);
void block_spin_time(hotebook* widgets,void (*f)());
void unlock_spin_time(hotebook* widgets,void (*f)());
void template_set_status_disk(GtkWidget* self, hotebook* widgets);
void get_status_disk(hotebook* widgets);

@ -24,16 +24,16 @@ void model_null_str_writing(config_u_g_p* _config) {
_config->files = yon_char_new(empty_str);
_config->loaded_keys = yon_char_new(empty_str);
_config->type_arr = yon_char_new(empty_str);
_config->id = -3;
_config->soft_restriction_size = -3;
_config->soft_restriction_file = -3;
_config->severe_limitation_size = -3;
_config->severe_limitation_file = -3;
_config->id = 0;
_config->soft_restriction_size = 0;
_config->soft_restriction_file = 0;
_config->severe_limitation_size = 0;
_config->severe_limitation_file = 0;
_config->deferring_size = 0;
_config->deferring_file = 0;
_config->size_memory_pow = -3;
_config->soft_restriction_size_pow = -3;
_config->severe_limitation_size_pow = -3;
_config->size_memory_pow = 0;
_config->soft_restriction_size_pow = 0;
_config->severe_limitation_size_pow = 0;
vector_init(&_config->actors);
}

@ -263,6 +263,9 @@ char* philos_format_cfg_str_size_memory(char* str_key, int value, int pow_size_m
return yon_char_new("-");
}
char* str_value = yon_char_from_int(value);
if (value == 0) {
return str_value;
}
if (pow_size_memory==0) {
return yon_char_unite(str_key, str_value, "K" ,NULL);
}
@ -717,7 +720,8 @@ void yon_int_array_append(int **source, int append){
* [RU]
*/
int philos_config_save(char *command)
{
{
puts(command);
FILE *output = popen(command, "r");
return 1;
}

@ -76,6 +76,7 @@ typedef struct {
} temp_set_window;
typedef struct {
char* name;
GtkListStore *liststore;
GtkWidget* tree_view;
GtkWidget* btnAdd;
@ -93,7 +94,7 @@ typedef struct {
GtkWidget* spinDaysFile;
GtkWidget* spinHoursFile;
GtkWidget* spinMinutesFile;
GtkWidget* cmbSetStatusDisk;
GtkWidget* lblSetNameDevice;
} hotebook;
typedef struct {

@ -200,6 +200,10 @@ custom_window *setup_window_custom(custom_window* custom_widgets, GtkBuilder *bu
custom_widgets->group.comboBox = yon_gtk_builder_get_widget(builder,"groupsDeviceCombo");
device_fill_disk(custom_widgets->user.comboBox);
device_fill_disk(custom_widgets->group.comboBox);
custom_widgets->user.name = yon_char_new("usrquota");
custom_widgets->group.name = yon_char_new("grpquota");
custom_widgets->project.name = yon_char_new("grpquota");
custom_widgets->user.btnAdd = yon_gtk_builder_get_widget(builder,"btnAddUsers");
custom_widgets->user.btnEdit = yon_gtk_builder_get_widget(builder,"btnEditUsers");
custom_widgets->user.btnDel = yon_gtk_builder_get_widget(builder,"btnDelUsers");
@ -255,6 +259,9 @@ custom_window *setup_window_custom(custom_window* custom_widgets, GtkBuilder *bu
custom_widgets->user.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalUsersFilesMinutesSpin");
custom_widgets->group.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalGroupsFilesMinuteSpin");
custom_widgets->project.spinMinutesFile = yon_gtk_builder_get_widget(builder,"generalProjectFilesMinutesSpin");
custom_widgets->user.cmbSetStatusDisk = yon_gtk_builder_get_widget(builder,"cmbUserSetStatus");
custom_widgets->group.cmbSetStatusDisk = yon_gtk_builder_get_widget(builder,"cmbGroupSetStatus");
return custom_widgets;
}

@ -127,4 +127,5 @@ void config_init(config_settings_gui* main_config);
int wrapper_select_tree_view(hotebook* widgets);
int tree_view_edit(config_all* _all_config, vector* vec_temp, hotebook* widgets);
void set_time_spin(hotebook* widgets, size_t seconds_file, size_t seconds_size);
void template_set_status_disk(GtkWidget* self,hotebook* widgets);
#endif

@ -379,6 +379,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-start">5</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">True</property>
@ -415,7 +416,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</packing>
</child>
<child>
<object class="GtkLabel" id="lblSetQuotasStatus1">
<object class="GtkLabel" id="lblSetQuotasStatus">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
@ -2271,7 +2272,7 @@ limitation
</packing>
</child>
<child>
<object class="GtkComboBoxText">
<object class="GtkComboBoxText" id="cmbUserSetStatus">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
@ -3190,7 +3191,7 @@ limitation
</packing>
</child>
<child>
<object class="GtkComboBoxText">
<object class="GtkComboBoxText" id="cmbGroupSetStatus">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
@ -4069,25 +4070,6 @@ limitation
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBoxText">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<items>
<item translatable="yes">Off</item>
<item translatable="yes">Not set</item>
</items>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="boxGeneralUsersEnableCheck1">
<property name="visible">True</property>

Loading…
Cancel
Save