Application rework

pull/61/head
Ivan Yartsev 1 month ago
parent 5d913f07ec
commit 3eabfebabf

@ -12,7 +12,7 @@ DEPENDS = /bin/cmake
PREFIX ?= /usr/local
PKGNAME = $(MAKEFILE_DIR)
FILE_VER = source/${PKGNAME}.h
PKGIDENT = $(subst /,-,$(subst /usr,,${PREFIX}))
PKGIDENT=$(subst /,-,${PREFIX})
default_target: all
@ -94,7 +94,6 @@ uninstall:
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) "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy"
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
@ -117,18 +116,19 @@ install: check uninstall
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 -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-symbolic.svg"
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
@install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg"
@cp ./com.ublinux.${PKGNAME}.policy ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy
@sed -e 's+/usr/bin+${PREFIX}/bin+' -e 's+.run+${PKGIDENT}.run+g' ./compile/com.ublinux.${PKGNAME}${PKGIDENT}.policy -i
@install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}"
@install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy"
@sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
@install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg"
@install -Dm644 -t "${DESTDIR}/usr/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg"
@install -Dm644 -t "${DESTDIR}/usr/share/polkit-1/actions/" "${CMAKE_BUILD_DIR}/com.ublinux.${PKGNAME}${PKGIDENT}.policy"
@ldconfig -n /usr/local/lib
@if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
[ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/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; \
[ -d "${DESTDIR}/usr/share/applications" ] && touch "${DESTDIR}/usr/share/applications" &>/dev/null || true; \
fi
@echo "Install: OK"
@ -147,7 +147,7 @@ help:
echo "... init"; \
echo "... debug"; \
echo "... prepare"; \
echo "... build"; \
echo "... compile"; \
echo "... install"; \
echo "... uninstall"; \
echo "... clean"
echo "... clean"

@ -24,10 +24,6 @@ if(WEBKIT_LIBRARIES_FOUND)
add_definitions(${WEBKIT_CFLAGS_OTHER})
endif()
configure_file(ubl-cmake.in ubl-cmake.h)
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./)
set(GRESOURCE_C resources.c)
set(GRESOURCE_XML gresource.xml)
@ -63,27 +59,33 @@ add_custom_target(
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}
)
#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 \
add_definitions(-DVTE_INCLUDE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
-O2 -pipe -fno-plt -fexceptions \
-Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
-Wformat -Werror=format-security \
-fstack-clash-protection -fcf-protection")
string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND)
if(FORTIFY_FOUND EQUAL -1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2")
endif()
set(SOURCE_FILES
ubl-settings-resourcequota.c
ubl-settings-resourcequota.h
ubl-utils.c
ubl-utils.h
${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h
ubl-strings.h
)
set(LIBRARIES
${GTK_LIBRARIES}
${WEBKIT_LIBRARIES}
${VTE291_LIBRARIES}
pthread)
${UTILS_LIBRARIES}
${VTE291_LIBRARIES}
ublsettings
ublsettings-gtk3
ublsettingsui-gtk3)
add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C})

@ -1 +0,0 @@
#cmakedefine WEBKIT_FOUND

@ -2,102 +2,27 @@
config main_config;
//signal emmit handlers - no header initialization
/**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_resource(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_resource(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 on_save_done(main_window *, config_str output, int size){
char *final_output = yon_char_parsed_to_string(output,size,"");
if (final_output){
printf("%s\n",final_output);
free(final_output);
}
yon_char_parsed_free(output,size);
textdomain(template_ui_LocaleName);
switch (main_config.save_config){
case 0:
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
case 1:
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
case 2:
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
break;
}
textdomain(LocaleName);
}
//functions
@ -117,7 +42,7 @@ char *get_size_mod(GtkComboBox *combo){
return size_modifier;
}
void on_device_limits_update(GtkWidget *self, quota_window *window){
void on_device_limits_update(GtkWidget *, quota_window *window){
if (window->devices->data){
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck)))
yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo)));
@ -130,19 +55,27 @@ void on_device_limits_update(GtkWidget *self, quota_window *window){
void on_quota_configuration_update(GtkWidget *self, quota_window *window){
char *output_line = NULL;
char *size_modifier=NULL;
on_device_limits_update(self,window);
char *soft_limit = yon_char_unite("MemoryHigh=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo)),NULL);
char *hard_limit = yon_char_unite("MemoryMax=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin))),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo)),NULL);
char *paging_limit = yon_char_unite("MemorySwapMax=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin))),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo)),NULL);
char *cpu_limit = yon_char_unite("CPUQuota=",yon_char_from_long((long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin))),"%",NULL);
long sft = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->SoftRestrictionSpin));
long hrd = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->HardRestrictionSpin));
long pgl = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->PagingLimitSpin));
long cpu = (long)gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->CpuLimitSpin));
char *soft_limit = "";
char *hard_limit = "";
char *paging_limit = "";
char *cpu_limit = "";
if (sft) soft_limit = yon_char_unite("MemoryHigh=",yon_char_from_long(sft),get_size_mod(GTK_COMBO_BOX(window->SoftRestrictionCombo)),NULL);
if (hrd) hard_limit = yon_char_unite("MemoryMax=",yon_char_from_long(hrd),get_size_mod(GTK_COMBO_BOX(window->HardRestrictionCombo)),NULL);
if (pgl) paging_limit = yon_char_unite("MemorySwapMax=",yon_char_from_long(pgl),get_size_mod(GTK_COMBO_BOX(window->PagingLimitCombo)),NULL);
if (cpu) cpu_limit = yon_char_unite("CPUQuota=",yon_char_from_long(cpu),"%",NULL);
char *read_limit = "";
char *read_devices = "";
dictionary *dict;
for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->read)
read_devices = yon_char_unite(read_devices,"IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,",",NULL);
if (!strstr(yon_dictionary_get_data(dict,device_limits*)->read," 0 "))
read_devices = yon_char_unite(read_devices,"IOReadBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->read,",",NULL);
}
if (read_devices[strlen(read_devices)-1]==',') read_devices[strlen(read_devices)-1]='\0';
read_limit = yon_char_unite(read_limit,read_devices,NULL);
@ -152,7 +85,8 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){
char *write_devices = "";
for_dictionaries(dict,window->devices){
if (dict->data&&yon_dictionary_get_data(dict,device_limits*)->write)
write_devices = yon_char_unite(write_devices,"IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,",",NULL);
if (!strstr(yon_dictionary_get_data(dict,device_limits*)->write," 0 "))
write_devices = yon_char_unite(write_devices,"IOWriteBandwidthMax=",yon_char_divide_search(yon_char_new(dict->key)," ",-1)," ",yon_dictionary_get_data(dict,device_limits*)->write,",",NULL);
}
if (write_devices[strlen(write_devices)-1]==',') write_devices[strlen(write_devices)-1]='\0';
write_limit = yon_char_unite(write_limit,write_devices,NULL);
@ -167,7 +101,7 @@ void on_quota_configuration_update(GtkWidget *self, quota_window *window){
gtk_entry_set_text(GTK_ENTRY(window->ManualInputEntry),output_line);
}
void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window){
void on_limit_manual_input(GtkWidget *self, double *, quota_window *window){
on_quota_configuration_update(self, window);
}
@ -281,78 +215,86 @@ void on_target_check_chosen(GtkWidget *self, quota_window *window){
void yon_get_devices(quota_window *window){
int size=0;
config_str devices_parsed = yon_config_load(get_devices_command,&size);
yon_char_parsed_remove_newline_symbols(devices_parsed,&size);
for (int i=0; i<size;i++){
yon_char_remove_last_symbol(devices_parsed[i],'\n');
yon_dictionary_add_or_create_if_exists_with_data(window->devices,devices_parsed[i],NULL);
}
}
void on_device_current_changed(GtkWidget *self, quota_window *window){
void on_device_current_changed(GtkWidget *, quota_window *window){
char *chosen = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo));
if (!window->devices->data){
printf("%s\n",gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo)));
yon_dictionary_get(&window->devices,chosen);
if (!window->devices->data)
if (!window->devices->data){
window->devices->data = g_malloc0(sizeof(device_limits));
((device_limits*)window->devices->data)->write=NULL;
((device_limits*)window->devices->data)->read=NULL;
}
((device_limits*)window->devices->data)->write=NULL;
((device_limits*)window->devices->data)->read=NULL;
} else {
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck)))
yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo)));
else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck)))
yon_dictionary_get_data(window->devices,device_limits*)->write=yon_char_append(yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin))),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitWriteCombo)));
else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL;
long read_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin));
long write_lim = gtk_spin_button_get_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin));
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck))){
if (read_lim) yon_dictionary_get_data(window->devices,device_limits*)->read=yon_char_append(yon_char_from_long(read_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitReadCombo)));
} else yon_dictionary_get_data(window->devices,device_limits*)->read = NULL;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck))){
if (write_lim) yon_dictionary_get_data(window->devices,device_limits*)->write=yon_char_append(yon_char_from_long(write_lim),get_size_mod(GTK_COMBO_BOX(window->DeviceLimitWriteCombo)));
} else yon_dictionary_get_data(window->devices,device_limits*)->write = NULL;
yon_dictionary_get(&window->devices,chosen);
if (!window->devices->data)
if (!window->devices->data){
window->devices->data = g_malloc0(sizeof(device_limits));
((device_limits*)window->devices->data)->write=NULL;
((device_limits*)window->devices->data)->read=NULL;
char *read = yon_dictionary_get_data(window->devices,device_limits*)->read;
char *write = yon_dictionary_get_data(window->devices,device_limits*)->write;
if (read) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
switch (read[strlen(read)-1]){
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1);
break;
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2);
break;
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3);
break;
}
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
}
((device_limits*)window->devices->data)->write=NULL;
((device_limits*)window->devices->data)->read=NULL;
char *read = yon_dictionary_get_data(window->devices,device_limits*)->read;
char *write = yon_dictionary_get_data(window->devices,device_limits*)->write;
if (read) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),atoi(read));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
switch (read[strlen(read)-1]){
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),1);
break;
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),2);
break;
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),3);
break;
}
if (write) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
switch (write[strlen(write)-1]){
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1);
break;
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2);
break;
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3);
break;
}
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),0);
}
if (write) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),atoi(write));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
switch (write[strlen(write)-1]){
case 'K': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
break;
case 'M': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),1);
break;
case 'G': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),2);
break;
case 'T': gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),3);
break;
}
} else {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),0);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),0);
gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),0);
}
}
}
void on_quotas_save(GtkWidget *self, dictionary *windows){
quota_window *window = yon_dictionary_get_data(windows->first,quota_window*);
main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*);
// main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*);
GtkTreeIter iter;
if (!strcmp(gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)),"")){
yon_ubl_status_box_render(OPERATION_FAILED_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
const char *string = gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry));
const char *type = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->TargetTypeCombo));
const char *target = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(window->TargetCombo));
@ -381,8 +323,8 @@ void on_quotas_save(GtkWidget *self, dictionary *windows){
write_limit = yon_char_unite(write_limit,write_devices,NULL);
gtk_list_store_append(main_config.list,&iter);
gtk_list_store_set(main_config.list,&iter,0,type,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1);
yon_config_register(CGROUP_QUOTA((char*)target),yon_char_new((char*)string));
on_close_subwindow(self);
yon_config_register(CGROUP_QUOTA((char*)target),CGROUP_QUOTA_comd((char*)target),yon_char_new((char*)string));
on_subwindow_close(self);
yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
@ -401,12 +343,12 @@ int yon_get_size_request_from_letter(char size){
}
}
void yon_load_proceed(char *command){
void yon_interface_update(main_window *){
gtk_list_store_clear(main_config.list);
if (yon_config_load_register(command)){
config_str rtn = yon_config_get_all();
int parameters_size;
config_str rtn = yon_config_get_all(&parameters_size);
char *quota = NULL;
for (int i=0;rtn[i];i++){
for (int i=0;i<parameters_size;i++){
quota=yon_char_new(rtn[i]);
char *name = yon_char_divide_search(quota,"=",-1);
if (quota[0]=='\"') yon_char_divide(quota,0);
@ -461,48 +403,94 @@ void yon_load_proceed(char *command){
gtk_list_store_append(main_config.list,&iter);
gtk_list_store_set(main_config.list,&iter,0,type,1,name,2,high,3,max,4,swap,5,cpu,6,read,7,write,8,quota,-1);
}
}
}
void on_config_load_global(){
yon_load_proceed(load_global_command);
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
void on_config_global_local_save(GtkWidget *, main_window *){
main_config.save_config=3;
yon_save_proceed(NULL,YON_CONFIG_BOTH,config_get_global_command,NULL);
}
void on_config_load_local(){
yon_load_proceed(load_local_command);
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
void on_config_local_save(GtkWidget *, main_window *){
main_config.save_config=1;
yon_save_proceed("system",YON_CONFIG_LOCAL,config_get_local_command,NULL);
}
void yon_save_proceed(char *path, char *section){
yon_config_save_registered(path,section);
void on_config_global_save(GtkWidget *, main_window *){
main_config.save_config=0;
yon_save_proceed("global",YON_CONFIG_GLOBAL,config_get_global_command,NULL);
}
void on_config_save(){
yon_save_proceed(NULL,"security");
yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
void on_config_custom_save(GtkWidget *, main_window *){
main_config.save_config=1;
template_saving_window *window = yon_save_proceed(NULL,YON_CONFIG_CUSTOM,yon_config_get_custom_command("system"),NULL);
if (window){};
}
void on_config_save_global(){
yon_save_proceed("global","security");
yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
void on_config_local_load(GtkWidget *,main_window *widgets){
yon_load_proceed(YON_CONFIG_LOCAL);
yon_interface_update(widgets);
main_config.load_mode=1;
}
void on_config_global_load(GtkWidget *,main_window *widgets){
yon_load_proceed(YON_CONFIG_GLOBAL);
yon_interface_update(widgets);
main_config.load_mode=0;
}
void on_config_save_local(){
yon_save_proceed("system","security");
yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
void on_config_custom_load(GtkWidget *,main_window *widgets){
yon_load_proceed(YON_CONFIG_CUSTOM);
textdomain(template_ui_LocaleName);
yon_ubl_status_box_render(GLOBAL_LOAD_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
textdomain(LocaleName);
main_config.load_mode=3;
yon_interface_update(widgets);
}
void yon_load_proceed(YON_CONFIG_TYPE type){
yon_config_clean();
if (!yon_char_is_empty(config_get_default_command))
yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL);
if (type==YON_CONFIG_GLOBAL){
yon_config_load_config(type,config_get_global_command,NULL);
} else if (type==YON_CONFIG_LOCAL){
yon_config_load_config(type,config_get_local_command,NULL);
} else if (type==YON_CONFIG_CUSTOM){
char *path="";
textdomain(template_ui_LocaleName);
GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL);
textdomain(LocaleName);
gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services");
gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL);
GtkFileFilter *filter = gtk_file_filter_new();
gtk_file_filter_add_pattern(filter,"*.ini");
gtk_file_filter_set_name(filter, "*.ini");
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
gtk_widget_show(dialog);
int response = gtk_dialog_run(GTK_DIALOG(dialog));
if (response == GTK_RESPONSE_ACCEPT){
char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
if (!yon_char_is_empty(file)){
path=file;
}
gtk_widget_destroy(dialog);
} else {
gtk_widget_destroy(dialog);
}
char *command = yon_config_get_custom_command(path);
yon_config_load_config(type,command,NULL);
}
}
void on_apply_filters(GtkWidget *self, dictionary *dict){
GList *columns = yon_dictionary_get_data(dict->first,GList*);
GList *checks = yon_dictionary_get_data(dict->first->next,GList*);
if (g_list_length(columns)==g_list_length(checks)){
for (int i=0;i<g_list_length(columns);i++){
for (guint i=0;i<g_list_length(columns);i++){
if (gtk_toggle_button_get_active((GtkToggleButton*)g_list_nth_data(checks,i)))
gtk_tree_view_column_set_visible((GtkTreeViewColumn*)g_list_nth_data(columns,i),1);
else {
@ -512,7 +500,7 @@ void on_apply_filters(GtkWidget *self, dictionary *dict){
} else {
printf("Error! Unequal quantity of filters and tree columns!");
}
on_close_subwindow(self);
on_subwindow_close(self);
}
void on_quota_manual_input(GtkWidget *self, quota_window *window){
@ -633,34 +621,13 @@ void on_quota_manual_input(GtkWidget *self, quota_window *window){
} else return;
}
}
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitCombo),0);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitCombo),G_CALLBACK(on_device_current_changed),window);
// if (window->devices->data){
// if (((device_limits*)window->devices->data)->read&&strcmp(((device_limits*)window->devices->data)->read,"")!=0){
// char *rd = ((device_limits*)window->devices->data)->read;
// g_signal_handlers_block_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitReadCheck),1);
// g_signal_handlers_unblock_by_func(G_OBJECT(window->DeviceLimitReadCheck),G_CALLBACK(on_quota_configuration_update),window);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitReadCombo),yon_get_size_request_from_letter(rd[strlen(rd)-1]));
// rd[strlen(rd)-1]='\0';
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitReadSpin),strtol(((device_limits*)window->devices->data)->read,NULL,10));
// }
// else ((device_limits*)window->devices->data)->read=NULL;
// if (((device_limits*)window->devices->data)->write&&strcmp(((device_limits*)window->devices->data)->write,"")!=0){
// gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(window->DeviceLimitWriteCheck),1);
// gtk_combo_box_set_active(GTK_COMBO_BOX(window->DeviceLimitWriteCombo),yon_get_size_request_from_letter(((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]));
// ((device_limits*)window->devices->data)->write[strlen(((device_limits*)window->devices->data)->write)-1]='\0';
// gtk_spin_button_set_value(GTK_SPIN_BUTTON(window->DeviceLimitWriteSpin),strtol(((device_limits*)window->devices->data)->write,NULL,10));
// } else ((device_limits*)window->devices->data)->write=NULL;
// }
}
void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *event, quota_window *window){
void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *, quota_window *window){
on_quota_manual_input(self,window);
}
void on_filters_opened(GtkWidget *self, main_window *widgets) {
void on_filters_opened(GtkWidget *, main_window *widgets) {
GtkBuilder *builder = gtk_builder_new_from_resource(glade_filters_path);
filters_window *window = g_malloc0(sizeof(filters_window));
@ -680,7 +647,7 @@ void on_filters_opened(GtkWidget *self, main_window *widgets) {
GList *columns = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree));
GList *checks = gtk_container_get_children(GTK_CONTAINER(gtk_widget_get_parent(window->QuotaTypeCheck)));
if (g_list_length(columns)==g_list_length(checks)){
for (int i=0;i<g_list_length(columns);i++){
for (guint i=0;i<g_list_length(columns);i++){
if (gtk_tree_view_column_get_visible((GtkTreeViewColumn*)g_list_nth_data(columns,i)))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON((GtkToggleButton*)g_list_nth_data(checks,i)),1);
}
@ -692,14 +659,14 @@ void on_filters_opened(GtkWidget *self, main_window *widgets) {
yon_dictionary_add_or_create_if_exists_with_data(dict,"columns",columns);
yon_dictionary_add_or_create_if_exists_with_data(dict,"checks",checks);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->AcceptButton),"clicked",G_CALLBACK(on_apply_filters),dict);
gtk_window_set_title(GTK_WINDOW(window->Window),TITLE_LABEL);
gtk_widget_show(window->Window);
}
void on_add_open(GtkWidget *self, main_window *widgets){
void on_add_open(GtkWidget *, main_window *widgets){
GtkBuilder *builder = gtk_builder_new_from_resource(glade_quota_path);
quota_window *window = g_malloc0(sizeof(quota_window));
@ -755,7 +722,7 @@ void on_add_open(GtkWidget *self, main_window *widgets){
dictionary *windows = NULL;
yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window);
yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_save),windows);
g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window);
@ -822,8 +789,8 @@ void on_add_open(GtkWidget *self, main_window *widgets){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->DeviceLimitCombo),dict->key);
}
main_config.users = yon_ubl_get_all_users(&main_config.users_size);
main_config.processes = yon_ubl_get_all_processes(&main_config.processes_size);
main_config.slices = yon_ubl_get_all_slices(&main_config.slices_size);
main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size);
main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size);
for (int i=0; i<main_config.users_size;i++){
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(window->TargetCombo),main_config.users[i]);
}
@ -835,11 +802,12 @@ void on_information_chosen_changed(GtkWidget *self, main_window *widgets){
if (chosen){
char *command = yon_char_unite(get_information_command, (char*)chosen," --no-pager",NULL);
main_config.last_info = yon_char_new((char*)chosen);
yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL);
vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1);
yon_terminal_integrated_start(widgets->InformationTerminal, command);
}
}
void on_information(GtkWidget *self, main_window *widgets){
void on_information(GtkWidget *, main_window *widgets){
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
@ -857,19 +825,21 @@ void on_information(GtkWidget *self, main_window *widgets){
g_signal_handlers_unblock_by_func(G_OBJECT(widgets->TargetCombo),on_information_chosen_changed,widgets);
char *command = yon_char_unite(get_information_command, (char*)name," --no-pager",NULL);
main_config.last_info = yon_char_new((char*)name);
yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL);
vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1);
yon_terminal_integrated_start(widgets->InformationTerminal, command);
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->MainNotebook),3);
yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
}
void on_information_update(GtkWidget *self, main_window *widgets){
void on_information_update(GtkWidget *, main_window *widgets){
char *command = yon_char_unite(get_information_command, main_config.last_info," --no-pager",NULL);
yon_terminal_integrated_start(widgets->InformationTerminal, command, NULL, NULL);
vte_terminal_reset(VTE_TERMINAL(widgets->InformationTerminal),1,1);
yon_terminal_integrated_start(widgets->InformationTerminal, command);
}
void on_remove(GtkWidget *self, main_window *widgets){
void on_remove(GtkWidget *, main_window *widgets){
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
@ -888,6 +858,10 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
quota_window *window = yon_dictionary_get_data(windows->first,quota_window*);
main_window *widgets = yon_dictionary_get_data(windows->first->next,main_window*);
GtkTreeIter iter;
if (!strcmp(gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry)),"")){
yon_ubl_status_box_render(OPERATION_FAILED_EMPTY_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
return;
}
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
const char *string = gtk_entry_get_text(GTK_ENTRY(window->ManualInputEntry));
const char *target = gtk_label_get_text(GTK_LABEL(window->TargetLabel));
@ -916,13 +890,13 @@ void on_quotas_edit(GtkWidget *self, dictionary *windows){
write_limit = yon_char_unite(write_limit,write_devices,NULL);
gtk_list_store_set(main_config.list,&iter,1,target,2,soft,3,hard,4,paging,5,cpu,6,read_limit,7,write_limit,8,string,-1);
yon_config_set(CGROUP_QUOTA(target),(void*)yon_char_new((char*)string));
on_close_subwindow(self);
on_subwindow_close(self);
yon_ubl_status_box_render(SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE);
}
else yon_ubl_status_box_render(NOTHING_CHOSEN_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
}
void on_edit_open(GtkWidget *self, main_window *widgets){
void on_edit_open(GtkWidget *, main_window *widgets){
GtkTreeModel *model = GTK_TREE_MODEL(main_config.list);
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(gtk_tree_view_get_selection(GTK_TREE_VIEW(widgets->MainTree)),&model,&iter)){
@ -1008,7 +982,7 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
dictionary *windows = NULL;
yon_dictionary_add_or_create_if_exists_with_data(windows,"window",window);
yon_dictionary_add_or_create_if_exists_with_data(windows,"widgets",widgets);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_close_subwindow),NULL);
g_signal_connect(G_OBJECT(window->CancelButton),"clicked",G_CALLBACK(on_subwindow_close),NULL);
g_signal_connect(G_OBJECT(window->SaveButton),"clicked",G_CALLBACK(on_quotas_edit),windows);
g_signal_connect(G_OBJECT(window->TargetTypeCombo),"changed",G_CALLBACK(on_quota_target_type_changed),window);
@ -1181,13 +1155,13 @@ void on_edit_open(GtkWidget *self, main_window *widgets){
}
}
void on_dispatcher_update(GtkWidget *self,main_window *widgets){
void on_dispatcher_update(GtkWidget *,main_window *widgets){
int interval = gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->DispatcherUpdateSpin));
if (interval>0) {
char* str_second = yon_char_from_int(interval);
char *command = yon_char_unite(get_dispatcher_command," -d ",str_second,NULL);
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->DispatcherUpdateCheck))) command = yon_char_append(command," -n 1");
yon_terminal_integrated_start(widgets->DispatcherTerminal, command, NULL, NULL);
yon_terminal_integrated_start_shell(widgets->DispatcherTerminal, command,NULL,NULL);
free(str_second);
GValue *val = g_malloc0(sizeof(GValue));
g_object_get_property(G_OBJECT(widgets->DispatcherUpdateSpin),"has-focus",val);
@ -1197,16 +1171,16 @@ void on_dispatcher_update(GtkWidget *self,main_window *widgets){
}
}
void on_processes_update(GtkWidget *self,main_window *widgets){
void on_processes_update(GtkWidget *,main_window *widgets){
int show_all = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowAllCheck));
int show_core = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->ShowCoreCheck));
char *command = get_processes_tree_command;
if (show_all) yon_char_append(command, " -k");
if (show_core) yon_char_append(command, " -l");
yon_terminal_integrated_start(widgets->ProcessesTerminal, command, NULL, NULL);
yon_terminal_integrated_start_shell(widgets->ProcessesTerminal, command,NULL,NULL);
}
void on_tab_changed(GtkWidget *self, GtkWidget *page, int page_num, main_window *widgets){
void on_tab_changed(GtkWidget *, GtkWidget *, int , main_window *){
}
@ -1236,51 +1210,22 @@ void on_info_target_type_switched(GtkWidget *self, main_window *widgets){
// standard functions
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.avaliable_ram=0;
}
main_window *setup_window(){
/* Widgets getting | Получение виджетов */
main_window *widgets = malloc(sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
widgets->Window = yon_gtk_builder_get_widget(builder,"MainWindow");
widgets->HatLabel = yon_gtk_builder_get_widget(builder,"headerTopic");
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");
// void config_init(){
// main_config.avaliable_ram=0;
// }
/**yon_main_window_complete(main_window *widgets)
* [EN]
*
* [RU]
* Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом.
*/
void yon_main_window_complete(main_window *widgets){
widgets = yon_remalloc(widgets,sizeof(main_window));
GtkBuilder *builder = gtk_builder_new_from_resource(glade_path);
gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0);
// Custom widgets configuration
{
widgets->FiltersButton = yon_gtk_builder_get_widget(builder,"FiltersButton");
widgets->InformationButton = yon_gtk_builder_get_widget(builder,"InformationButton");
@ -1307,28 +1252,7 @@ main_window *setup_window(){
widgets->InformationTerminal = yon_gtk_builder_get_widget(builder,"InformationTerminal");
main_config.list = GTK_LIST_STORE(gtk_builder_get_object(builder,"liststore"));
widgets->DocumentationMenuItem = yon_ubl_menu_item_documentation_new(DOCUMENTATION_LABEL);
widgets->AboutMenuItem = yon_ubl_menu_item_about_new(ABOUT_LABEL);
gtk_window_set_title(GTK_WINDOW(widgets->Window),TITLE_LABEL);
GtkWidget *menu = yon_gtk_builder_get_widget(builder,"menu2");
gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->DocumentationMenuItem);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),widgets->AboutMenuItem);
if (main_config.lock_load_global == 1){
gtk_widget_set_sensitive(widgets->LoadGlobalMenuItem,0);
}
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);
}
/* Widget registration for config monitoring | Регистрация виджетов для мониторинга конфига */
// yon_window_config_add_custom_parameter(widgets->HeadInfoLabel,"head-text","label",YON_TYPE_STRING);
@ -1353,131 +1277,62 @@ main_window *setup_window(){
g_signal_connect(G_OBJECT(widgets->ProcessesUpdateButton),"clicked",G_CALLBACK(on_processes_update),widgets);
g_signal_connect(G_OBJECT(widgets->InformationUpdateButton),"clicked",G_CALLBACK(on_information_update),widgets);
g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_save),NULL);
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_save_global),NULL);
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_save_local),NULL);
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_load_global),NULL);
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_load_local),NULL);
g_signal_connect(G_OBJECT(widgets->SaveMenuItem),"activate",G_CALLBACK(on_config_global_local_save),widgets);
g_signal_connect(G_OBJECT(widgets->SaveGlobalMenuItem),"activate",G_CALLBACK(on_config_global_save),widgets);
g_signal_connect(G_OBJECT(widgets->SaveLocalMenuItem),"activate",G_CALLBACK(on_config_local_save),widgets);
g_signal_connect(G_OBJECT(widgets->SaveCustomMenuItem),"activate",G_CALLBACK(on_config_custom_save),widgets);
g_signal_connect(G_OBJECT(widgets->LoadGlobalMenuItem),"activate",G_CALLBACK(on_config_global_load),widgets);
g_signal_connect(G_OBJECT(widgets->LoadLocalMenuItem),"activate",G_CALLBACK(on_config_local_load),widgets);
g_signal_connect(G_OBJECT(widgets->LoadCustomMenuItem),"activate",G_CALLBACK(on_config_custom_load),widgets);
on_dispatcher_update(NULL,widgets);
on_processes_update(NULL,widgets);
yon_window_config_add_listener(widgets->DispatcherUpdateCheck,"DispatcherAutoupdate","active",YON_TYPE_BOOLEAN);
yon_window_config_add_listener(widgets->ShowAllCheck,"ProcessShowAll","active",YON_TYPE_BOOLEAN);
yon_window_config_add_listener(widgets->ShowCoreCheck,"ProcessShowCore","active",YON_TYPE_BOOLEAN);
yon_window_config_add_listener(widgets->DispatcherUpdateSpin,"DispatcherUpdateDelay","value",YON_TYPE_DOUBLE);
yon_gtk_tree_view_minimal_fixed_size_set_full(GTK_TREE_VIEW(widgets->MainTree));
GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree));
for (int i=0;i<g_list_length(list);i++){
for (guint i=0;i<g_list_length(list);i++){
yon_window_config_add_listener((GtkWidget*)g_list_nth_data(list,i),yon_char_append("column",yon_char_from_int(i)),"fixed-width",YON_TYPE_INT);
}
main_config.users = yon_ubl_get_all_users(&main_config.users_size);
main_config.processes = yon_ubl_get_all_processes(&main_config.processes_size);
main_config.slices = yon_ubl_get_all_slices(&main_config.slices_size);
main_config.processes = yon_config_load(get_processes_command,&main_config.processes_size);
main_config.slices = yon_config_load(get_slices_command,&main_config.slices_size);
on_info_target_type_switched(widgets->TargetTypeCombo,widgets);
gtk_widget_show(widgets->Window);
return widgets;
}
yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size);
yon_save_window_set_postsave_function(on_save_done,widgets);
}
int main(int argc, char *argv[]){
local=setlocale(LC_ALL, "");
setlocale(LC_ALL, "");
textdomain (LocaleName);
config_init();
int option_index=0;
int show_help=0;
int debug_mode=0;
{
struct option long_options[] = {
{"help", 0, 0, 'h'},
{"version", 0, 0, 'V'},
{"lock-help", 0,0, 1},
{"lock-save", 0,0, 2},
{"lock-save-local", 0,0, 3},
{"lock-save-global", 0,0, 4},
{"lock-load-global", 0,0, 5},
{"socket-id", 1, 0, 's'},
{"socket-ext-id", 1,0, 'e'},
{"socket-trd-id", 1,0, 't'},
{"debug", 0,0, 'd'},
{"clean-config", 0,0, 'c'},
{ NULL, 0, NULL, 0 }
};
for (int i=0;i<argc;i++){
int argument=getopt_long(argc,argv,"hVvs:e:t:dc",long_options,&option_index);
switch(argument){
case 'h':
show_help=1;
break;
case 'v':
case 'V':
printf("%s\n",VERSION_LABEL);
exit(0);
break;
case 's':
if(optarg)
main_config.socket_id=atoi(optarg);
break;
case 'e':
if(optarg)
main_config.save_socket_id=atoi(optarg);
break;
case 't':
if(optarg)
main_config.load_socket_id=atoi(optarg);
break;
case 'c': rmdir(yon_char_unite(yon_ubl_user_get_home_directory(),"/",LocaleName,"/",LocaleName,".conf",NULL));
break;
case 1:
main_config.lock_help=1;
break;
case 2:
main_config.lock_save_local=1;
main_config.lock_save_global=1;
break;
case 3:
main_config.lock_save_local=1;
break;
case 4:
main_config.lock_save_global=1;
break;
case 5:
main_config.lock_load_global=1;
break;
}
}
if (show_help==1&&main_config.lock_help!=1){
printf("%s\n",HELP_LABEL);
exit(0);
}
}
if (getuid()!=0){
main_config.lock_load_global=1;
main_config.lock_save_global=1;
main_config.lock_save_local=1;
}
gtk_init(&argc,&argv);
yon_ubl_connect_config((_template_config*)&main_config);
yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK);
config_str unfound = NULL;
int size=0;
yon_ubl_setup_arguments(argc,argv,&unfound,&size,NULL);
gtk_init(&argc,&argv);
template_main_window *widgets = yon_ubl_window_setup();
main_window *widgets = setup_window();
yon_ubl_header_setup_resource(widgets->HeadOverlay,widgets->HeadBox,widgets->HeadImage,banner_path);
yon_ubl_status_box_setup(widgets->StatusIcon,widgets->StatusBox,widgets->StatusLabel);
yon_ubl_setup_sockets(widgets->PlugBox,widgets->LeftBox,widgets->RightBox,main_config.socket_id,main_config.load_socket_id,main_config.save_socket_id);
yon_window_config_setup(GTK_WINDOW(widgets->Window));
yon_window_config_load(config_path);
on_config_load_local();
GList *list = gtk_tree_view_get_columns(GTK_TREE_VIEW(widgets->MainTree));
for (int i = 0; i < g_list_length(list); i++){
yon_gtk_column_minimal_fixed_size_set((GtkTreeViewColumn*)g_list_nth_data(list,i));
}
g_list_free(list);
//turn off if custom presented
// yon_ubl_settings_window_set_standard_callbacks(widgets,config_get_global_command,config_get_local_command,yon_config_get_custom_command("./"),config_get_default_command,config_get_global_only_parameters,config_get_local_only_parameters);
if (getuid()!=0)
yon_main_window_complete((main_window*)widgets);
char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL);
yon_window_config_load(path);
main_config.launch_arguments=yon_char_parsed_copy(argv,argc);
main_config.launch_size=argc;
if (getuid()!=0){
textdomain(template_ui_LocaleName);
yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE);
else
yon_ubl_status_box_render(LOCAL_LOAD_SUCCESS,BACKGROUND_IMAGE_SUCCESS_TYPE);
GtkCssProvider *css=gtk_css_provider_new();
gtk_css_provider_load_from_resource(css,CssPath);
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
GTK_STYLE_PROVIDER(css),
-1);
textdomain(LocaleName);
}
gtk_main();
return 0;
}

@ -1,6 +1,8 @@
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include "ubl-utils.h"
#include "libublsettings.h"
#include "libublsettings-gtk3.h"
#include "libublsettingsui-gtk3.h"
#include <locale.h>
#include <stdio.h>
#include <unistd.h>
@ -9,7 +11,6 @@
#include <getopt.h>
#include <libintl.h>
#include <vte/vte.h>
#include "ubl-cmake.h"
#include "sys/sysinfo.h"
#ifdef WEBKIT_FOUND
@ -30,41 +31,45 @@
#define LocalePath "/usr/share/locale"
#define LocaleName "ubl-settings-resourcequota"
#define load_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]"
#define load_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]"
#define save_global_command "ubconfig --default --target global set security"
#define save_local_command "ubconfig --default --target system set security"
#define save_command "ubconfig set security "
#define remove_command "ubconfig remove security "
#define remove_global_command "ubconfig --target global --noexecute remove security "
#define remove_local_command "ubconfig --target system remove security "
// #define load_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]"
// #define load_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]"
// #define save_global_command "ubconfig --default --target global set security"
// #define save_local_command "ubconfig --default --target system set security"
// #define save_command "ubconfig set security "
// #define remove_command "ubconfig remove security "
// #define remove_global_command "ubconfig --target global --noexecute remove security "
// #define remove_local_command "ubconfig --target system remove security "
#define get_devices_command "findmnt -lo source,target,fstype,label,size -t ext4 |grep -vE \"zram|\\]|\\[|SOURCE\""
#define get_processes_tree_command "clear; systemd-cgls --no-page"
#define get_dispatcher_command "clear; systemd-cgtop"
#define get_information_command "systemctl status "
#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\""
#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\""
#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get security CGROUP_QUOTA[*]",NULL)
#define config_get_local_command "ubconfig --default --source system get security CGROUP_QUOTA[*]"
#define config_get_global_command "ubconfig --default --source global get security CGROUP_QUOTA[*]"
#define config_get_default_command ""
#define config_get_global_only_parameters ""
#define config_get_local_only_parameters ""
#define CGROUP_QUOTA(name) yon_char_unite("CGROUP_QUOTA[",name,"]",NULL)
#define CGROUP_QUOTA_comd(name) yon_char_unite("ubconfig -- source global get security CGROUP_QUOTA[",target,"]",NULL)
#define CGROUP_QUOTA_parameter "CGROUP_QUOTA"
#define CGROUP_QUOTA_command "ubconfig -- source global get security CGROUP_QUOTA"
typedef char *string;
string version_application;
char *local;
__attribute__((unused)) static \
string version_application;
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;
template_config_fields
int save_config;
config_str launch_arguments;
int launch_size;
GtkListStore *list;
long avaliable_ram;
long avaliable_swap;
@ -81,34 +86,7 @@ typedef struct {
} config;
typedef struct {
//Standard
GtkWidget *Window;
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;
template_window_fields
// Custom
GtkWidget *FiltersButton;
GtkWidget *InformationButton;
@ -202,4 +180,43 @@ typedef struct {
char *write;
} device_limits;
main_window *setup_window();
main_window *setup_window();
void on_save_done(main_window *, config_str output, int size);
char *get_size_mod(GtkComboBox *combo);
void yon_main_window_complete(main_window *widgets);
void config_init();
void on_info_target_type_switched(GtkWidget *self, main_window *widgets);
void on_tab_changed(GtkWidget *self, GtkWidget *page, int page_num, main_window *widgets);
void on_processes_update(GtkWidget *self,main_window *widgets);
void on_dispatcher_update(GtkWidget *self,main_window *widgets);
void on_edit_open(GtkWidget *self, main_window *widgets);
void on_quotas_edit(GtkWidget *self, dictionary *windows);
void on_remove(GtkWidget *self, main_window *widgets);
void on_information_update(GtkWidget *self, main_window *widgets);
void on_information(GtkWidget *self, main_window *widgets);
void on_information_chosen_changed(GtkWidget *self, main_window *widgets);
void on_add_open(GtkWidget *self, main_window *widgets);
void on_filters_opened(GtkWidget *self, main_window *widgets);
void on_quota_manual_input_focus (GtkWidget *self, GdkEventFocus *event, quota_window *window);
void on_quota_manual_input(GtkWidget *self, quota_window *window);
void on_apply_filters(GtkWidget *self, dictionary *dict);
void yon_load_proceed(YON_CONFIG_TYPE type);
void on_config_custom_load(GtkWidget *,main_window *widgets);
void on_config_global_load(GtkWidget *,main_window *widgets);
void on_config_local_load(GtkWidget *,main_window *widgets);
void on_config_custom_save(GtkWidget *, main_window *);
void on_config_global_save(GtkWidget *, main_window *);
void on_config_local_save(GtkWidget *, main_window *);
void on_config_global_local_save(GtkWidget *, main_window *);
void yon_interface_update(main_window *);
int yon_get_size_request_from_letter(char size);
void on_quotas_save(GtkWidget *self, dictionary *windows);
void on_device_current_changed(GtkWidget *self, quota_window *window);
void yon_get_devices(quota_window *window);
void on_target_check_chosen(GtkWidget *self, quota_window *window);
void on_quota_target_type_changed(GtkWidget *self, quota_window *window);
void on_check_maximum_cpu(GtkWidget *self, GtkWidget *pair);
void on_check_maximum(GtkWidget *self, GtkWidget *pair);
void on_limit_manual_input(GtkWidget *self, double *new_value, quota_window *window);
void on_quota_configuration_update(GtkWidget *self, quota_window *window);
void on_device_limits_update(GtkWidget *, quota_window *window);

@ -1,28 +1,28 @@
#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"),"\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 ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked")
// #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"),"\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 ROOT_WARNING_LABEL _("Warning! Application was launched without root - root-dependent actions are locked")
#define TITLE_LABEL _("CPU and RAM quotas")
#define TITLE_INFO_LABEL _("Configuring CPU and RAM quota settings for groups and users of the system")
#define SUCCESS_LABEL _("Operation succeeded")
#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 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 homepage")
// #define SUCCESS_LABEL _("Operation succeeded")
// #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 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 homepage")
#define NOTHING_CHOSEN_LABEL _("Nothing were chosen")
#define STR_USER _("User")
@ -64,7 +64,7 @@
#define WRITE_LIMIT_TAB_LABEL _("I/O\nlimit\n(write)")
#define QUOTA_OBJECT_LABEL _("Quota target")
#define SOFT_LIMIT_LABEL _("Soft RAM limit, n(volume)")
#define SOFT_LIMIT_LABEL _("Soft RAM limit, (volume)")
#define HARD_LIMIT_LABEL _("Hard RAM limit, (volume)")
#define SWAP_LIMIT_LABEL _("Swap file limit (volume)")
#define CPU_LIMIT_LABEL _("CPU limit (%)")
@ -100,4 +100,6 @@
#define READ_LABEL _("Read")
#define WRITE_LABEL _("Write")
#define APPLY_CHANGES_LABEL _("Apply changes of operations limit")
#define MANUAL_INPUT_LABEL _("Manual input (for advanced users)")
#define MANUAL_INPUT_LABEL _("Manual input (for advanced users)")
#define OPERATION_FAILED_EMPTY_LABEL _("Current quota has no parameters")

File diff suppressed because it is too large Load Diff

@ -1,368 +0,0 @@
#ifndef UBL_UTILS
#define UBL_UTILS
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <pthread.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <pwd.h>
#include <locale.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <pwd.h>
#include <vte/vte.h>
#include "ubl-cmake.h"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#define DesktopPath "/usr/share/applications/"
#define try bool __HadError=false;
#define catch(x) ExitJmp:if(__HadError)
#define throw(x) {__HadError=true;goto ExitJmp;}
static char** array_size_pow;
#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 get_home_dir_command yon_char_unite("getent passwd \"",yon_ubl_root_user_get(),"\" | cut -d: -f6",NULL)
#define get_processes_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.service\""
#define get_slices_command "systemd-cgls --no-pager |grep -oE \"[-0-9A-Za-z.:]{1,}.slice\""
typedef enum
{
#ifdef __GTK_H__
DICTIONARY_GTK_WIDGETS_TYPE,
#endif
DICTIONARY_OTHER_TYPE=0,
DICTIONARY_CHAR_TYPE,
DICTIONARY_INT_TYPE,
DICTIONARY_BOOL_TYPE,
} DICT_TYPE;
typedef struct dictionary
{
char *key;
void *data;
struct dictionary *next;
struct dictionary *prev;
struct dictionary *first;
DICT_TYPE data_type;
int flag1;
} dictionary;
typedef struct apps
{
char *Name;
int Type;
char *Categories;
char *Exec;
char *Icon;
int Pluggable;
int DualPluggable;
} apps;
typedef char** config_str;
static dictionary *__yon__config__strings = NULL;
#define check_config if(__yon__config__strings&&__yon__config__strings->data_type==DICTIONARY_CHAR_TYPE)
#define config(key) yon_config_get_by_key(key)
#define for_config dictionary temp = NULL; for_dictionary(temp,__yon__config__strings)
#define yon_remalloc(pointer, size) (!pointer) ? malloc(size) : realloc(pointer, size)
// 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)
/**yon_dictionary_add_or_create_if_exists_with_data(dict,key,data)
* [EN]
*
* [RU]
* Добавляет элемент словаря в конец словаря [dict] c ключом [key] и данными [data].
* Если словарь не существует, создаёт его
*/
#define yon_dictionary_add_or_create_if_exists_with_data(dict,key,data) {if (!dict) dict=yon_dictionary_new_with_data(key,data); \
else dict=yon_dictionary_append_with_data(dict,key,data);}
dictionary *yon_dictionary_new();
dictionary *yon_dictionary_append(dictionary *targetdict);
dictionary *yon_dictionary_get_last(dictionary *dict);
dictionary *yon_dictionary_swap(dictionary *dict, int aim);
void yon_dictionary_make_first(dictionary *dict);
void yon_dictionary_make_nth(dictionary *dict, int nth);
dictionary *yon_dictionary_new_with_data(char *key, void *data);
dictionary *yon_dictionary_append_with_data(dictionary *dict, char *key, void *data);
dictionary *yon_dictionary_connect(dictionary *old, dictionary *toconnect);
dictionary *yon_dictionary_get(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
int yon_char_find_last(char *source, char find);
char *yon_char_append(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_from_long(long int_to_convert);
char *yon_char_replace(char *source, char *find, char*replace);
char **yon_char_parse(char *parameters, int *size, char *divider);
char **yon_char_parsed_rip(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 (int *size, ...);
void yon_char_parsed_copy(config_str *source, config_str *to_copy);
config_str yon_char_parsed_append(config_str parsed, int *size, char *string);
int yon_char_parsed_remove_newline_symbols(config_str parsed, int *size);
int yon_ubl_check_root();
char *yon_ubl_root_user_get();
char *yon_ubl_user_get_home_directory();
config_str yon_ubl_get_all_users(int *user_size);
config_str yon_ubl_get_all_processes(int *processes_size);
config_str yon_ubl_get_all_slices(int *slices_size);
// parsing functions
config_str philos_list_user(int* size);
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_registered(char *path, char *section);
char *yon_config_get_parameter(config_str parameters, int size, char *param);
int yon_config_load_register(char *command);
int yon_config_remove_by_key(char *key);
int yon_config_remove_by_data(void *data);
int yon_config_remove_element(char *key, char *deleted);
void *yon_config_get_by_key(char *key);
char *yon_config_get_key_by_data(char *data);
int yon_config_set(char *key, void *data);
int yon_config_clean();
void yon_config_register(char *key, void *data);
config_str yon_config_get_all();
// terminal-using functions
int yon_launch_app_with_arguments(char *name, char *args);
void yon_launch(char *command);
// Gtk functions
#ifdef __GTK_H__
#ifdef VTE_TERMINAL
void yon_terminal_integrated_launch(GtkWidget *place_to_show, char* command, void *endwork_function, void* endwork_function_argument);
void yon_terminal_integrated_start(GtkWidget *terminal, char* command, void *endwork_function, void* endwork_function_argument);
#endif
enum YON_TYPE{
YON_TYPE_STRING,
YON_TYPE_STRING_LIST,
YON_TYPE_INT,
YON_TYPE_DOUBLE,
YON_TYPE_BOOLEAN,
YON_TYPE_OTHER
};
GtkWidget *yon_ubl_menu_item_about_new(char *buttonname);
GtkWidget *yon_ubl_menu_item_documentation_new(char *buttonname);
/**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;
void yon_window_config_setup(GtkWindow *window);
int yon_window_config_load(char *path);
config_str yon_window_config_get_section(char *section, gsize *size);
void yon_window_config_add_listener(GtkWidget *widget, char *param_name, char *widget_property, enum YON_TYPE val_type);
void yon_window_config_add_custom_parameter(char *param_name, char *section, void *tracked_value, enum YON_TYPE val_type);
void yon_window_config_erase_custom_parameter(char *param_name, char *section);
int yon_window_config_get_parameter(char *section, char *config_parameter, void *return_value, enum YON_TYPE type);
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);
void yon_gtk_column_minimal_fixed_size_set(GtkTreeViewColumn *column);
int yon_gtk_icon_view_hide_empty(dictionary *icon_view_segment);
int yon_dictionary_gtk_pack_start_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...);
int yon_dictionary_gtk_pack_end_multiple_widgets(GtkBox *destination, gboolean expand, gboolean fill, int padding, ...);
void yon_gtk_widget_set_sensitive_from_toggle_button(GtkToggleButton *toggle, GtkWidget *target);
void yon_gtk_widget_set_sensitive_from_toggle_button_inversed(GtkToggleButton *toggle, GtkWidget *target);
void yon_gtk_widget_set_sensitive_from_combo_box(GtkComboBox *toggle, GtkWidget *target);
void yon_gtk_widget_set_sensitive_from_combo_box_inversed(GtkComboBox *toggle, GtkWidget *target);
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);
/**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)
#define yon_ubl_header_setup_resource(overlay, head, image, imag_path) _yon_ubl_header_setup_resource(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_header_setup_resource(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

File diff suppressed because it is too large Load Diff

@ -284,7 +284,7 @@ msgid "Quota target"
msgstr ""
#: source/ubl-strings.h:67
msgid "Soft RAM limit, n(volume)"
msgid "Soft RAM limit, (volume)"
msgstr ""
#: source/ubl-strings.h:68

@ -115,7 +115,7 @@ msgstr "Сохранить"
#: source/ubl-strings.h:14
msgid "Load local configuration"
msgstr "Загрузить локальную конфигуруцию"
msgstr "Загрузить локальную конфигурацию"
#: source/ubl-strings.h:15
msgid "Load global configuration"
@ -309,7 +309,7 @@ msgstr "Объект квотирования"
#: source/ubl-strings.h:67
#, fuzzy
msgid "Soft RAM limit, n(volume)"
msgid "Soft RAM limit, (volume)"
msgstr "Мягкий лимит ОЗУ, (объём)"
#: source/ubl-strings.h:68

Loading…
Cancel
Save