@ -1,13 +1,6 @@
# include "ubl-settings-diskquota.h"
# include "ubl-settings-diskquota.h"
using namespace std ;
using namespace std ;
const string path_app = " /usr/bin/ " ;
const string path_glade = " /usr/share/ubl-settings-diskquota/ui/ubl-settings-diskquota.glade " ;
const string app_name = " ubl-settings-diskquota " ;
const string path_locale = " /usr/share/locale/ " ;
const string path_css = " /usr/share/ubl-settings-diskquota/css/ubl-settings-diskquota.css " ;
const string path_img_head_background = " /usr/share/ubl-settings-diskquota/images/logo-background.png " ;
int socket_ext_id_I = 0 ;
int socket_ext_id_I = 0 ;
int socket_trd_id_I = 0 ;
int socket_trd_id_I = 0 ;
@ -58,14 +51,23 @@ void MainWindow::settings() {
boxFuncs - > set_sensitive ( false ) ;
boxFuncs - > set_sensitive ( false ) ;
btnSave - > set_sensitive ( false ) ;
btnSave - > set_sensitive ( false ) ;
btnLoad - > set_sensitive ( false ) ;
btnLoad - > set_sensitive ( false ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-diskquota.warning " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
info_status_app ( " boxInfoMessError " ) ;
info_status_app ( info_box_error_css ) ;
lblWarning - > set_text ( _( " The program must be run as root " ) ) ;
lblWarning - > set_text ( program_as_root ) ;
}
}
Gtk : : Widget * boxWidget ;
Gtk : : Widget * boxWidget ;
builder - > get_widget ( " boxColor " , boxWidget ) ;
builder - > get_widget ( " boxColor " , boxWidget ) ;
HeadOverlay - > add_overlay ( * boxWidget ) ;
HeadOverlay - > add_overlay ( * boxWidget ) ;
ubl_make_plugs ( boxSave , boxButton , socket_ext_id_I , socket_trd_id_I ) ;
ubl_make_plugs ( boxSave , boxButton , socket_ext_id_I , socket_trd_id_I ) ;
# ifdef WEBKIT_FOUND
void * handle = NULL ;
handle = dlopen ( " libwebkit2gtk-4.0.so " , RTLD_LAZY ) ;
if ( handle ) {
one = WEBKIT_WEB_VIEW ( webkit_web_view_new ( ) ) ;
three = Glib : : wrap ( GTK_WIDGET ( one ) ) ;
wndWeb - > add ( * three ) ;
}
# endif
}
}
void MainWindow : : init_spin_all ( ) {
void MainWindow : : init_spin_all ( ) {
@ -141,120 +143,120 @@ void MainWindow::init_tree_view() {
this - > init_tree_view_general ( ) ;
this - > init_tree_view_general ( ) ;
}
}
void MainWindow : : init_tree_view_general ( ) {
void MainWindow : : init_tree_view_general ( ) {
GeneralQuotasTree - > append_column_editable ( _( " Status " ) , m_columnsGeneral . status ) ;
GeneralQuotasTree - > append_column_editable ( str_status , m_columnsGeneral . status ) ;
GeneralQuotasTree - > append_column ( _( " Quota type " ) , m_columnsGeneral . type_quotas ) ;
GeneralQuotasTree - > append_column ( str_quota , m_columnsGeneral . type_quotas ) ;
GeneralQuotasTree - > append_column ( _( " Device \n Project " ) , m_columnsGeneral . device ) ;
GeneralQuotasTree - > append_column ( str_device_project , m_columnsGeneral . device ) ;
GeneralQuotasTree - > append_column ( _( " User " ) , m_columnsGeneral . user ) ;
GeneralQuotasTree - > append_column ( str_user , m_columnsGeneral . user ) ;
GeneralQuotasTree - > append_column ( _( " Group " ) , m_columnsGeneral . group ) ;
GeneralQuotasTree - > append_column ( str_group , m_columnsGeneral . group ) ;
GeneralQuotasTree - > append_column ( _( " Soft limit \n (size) " ) , m_columnsGeneral . soft_limit_size ) ;
GeneralQuotasTree - > append_column ( str_tw_soft_limit , m_columnsGeneral . soft_limit_size ) ;
GeneralQuotasTree - > append_column ( _( " Severe \n limitation \n (size) " ) , m_columnsGeneral . hard_limit_size ) ;
GeneralQuotasTree - > append_column ( str_tw_severe_limitation , m_columnsGeneral . hard_limit_size ) ;
GeneralQuotasTree - > append_column ( _( " Deferring \n a hard \n limit \n (size) " ) , m_columnsGeneral . hard_limit_size_delay ) ;
GeneralQuotasTree - > append_column ( str_tw_deferring_size , m_columnsGeneral . hard_limit_size_delay ) ;
GeneralQuotasTree - > append_column ( _( " Soft limit \n (files) " ) , m_columnsGeneral . soft_limit_files ) ;
GeneralQuotasTree - > append_column ( str_tw_soft_limit_files , m_columnsGeneral . soft_limit_files ) ;
GeneralQuotasTree - > append_column ( _( " Severe \n limitation \n (files) " ) , m_columnsGeneral . hard_limit_files ) ;
GeneralQuotasTree - > append_column ( str_tw_severe_limitation_files , m_columnsGeneral . hard_limit_files ) ;
GeneralQuotasTree - > append_column ( _( " Deferring \n a hard \n limit \n (files) " ) , m_columnsGeneral . hard_limit_delay ) ;
GeneralQuotasTree - > append_column ( str_tw_severe_limitation_files , m_columnsGeneral . hard_limit_delay ) ;
}
}
void MainWindow : : lacalization ( ) {
void MainWindow : : lacalization ( ) {
time_t now = time ( 0 ) ;
time_t now = time ( 0 ) ;
tm * ltm = localtime ( & now ) ;
tm * ltm = localtime ( & now ) ;
unsigned int year = 1900 + ltm - > tm_year ;
unsigned int year = 1900 + ltm - > tm_year ;
string str_authors = string ( _( " Copyright © UBSoft LLC, 2022 - " ) ) + to_string ( year ) ;
string str_authors = string ( copyright ) + to_string ( year ) ;
aboutWindows - > set_copyright ( str_authors ) ;
aboutWindows - > set_copyright ( str_authors ) ;
aboutWindows - > set_comments ( _( " Setting user quotas " ) ) ;
aboutWindows - > set_comments ( str_setting_user ) ;
aboutWindows - > set_website ( _( " https://wiki.ublinux.com " ) ) ;
aboutWindows - > set_website ( website ) ;
aboutWindows - > set_version ( gettext ( version_application . c_str ( ) ) ) ;
aboutWindows - > set_version ( _ ( version_application . c_str ( ) ) ) ;
aboutWindows - > set_website_label ( _( " Project Home Page " ) ) ;
aboutWindows - > set_website_label ( project_Home_page ) ;
generalTabLabel - > set_text ( _( " General settings " ) ) ;
generalTabLabel - > set_text ( str_general_settings ) ;
GroupsTabLabel - > set_text ( _( " Groups " ) ) ;
GroupsTabLabel - > set_text ( str_groups ) ;
headerAboutTopic - > set_label ( _ ( app_name .c_str ( ) )) ;
headerAboutTopic - > set_label ( _ ( app_name )) ;
headerTopic - > set_label ( _( " ubl-settings-diskquota " ) ) ;
headerTopic - > set_label ( name_app ) ;
UsersTabLabel - > set_text ( _( " Users " ) ) ;
UsersTabLabel - > set_text ( str_users ) ;
generalGroupsSizeLabel - > set_text ( _( " Excess size delay period " ) ) ;
generalGroupsSizeLabel - > set_text ( str_excess_size_delay ) ;
generalGroupsFilesLabel - > set_text ( _( " Excess files delay period " ) ) ;
generalGroupsFilesLabel - > set_text ( str_excess_files_delay ) ;
generalUsersSizeLabel - > set_text ( _( " Excess size delay period " ) ) ;
generalUsersSizeLabel - > set_text ( str_excess_size_delay ) ;
generalUsersFilesLabel - > set_text ( _( " Excess files delay period " ) ) ;
generalUsersFilesLabel - > set_text ( str_excess_files_delay ) ;
generalGroupsSizeWeeksLabel - > set_text ( _( " weeks" ) ) ;
generalGroupsSizeWeeksLabel - > set_text ( str _weeks) ;
generalGroupsFilesWeeksLabel - > set_text ( _( " weeks" ) ) ;
generalGroupsFilesWeeksLabel - > set_text ( str _weeks) ;
generalUsersSizeWeeksLabel - > set_text ( _( " weeks" ) ) ;
generalUsersSizeWeeksLabel - > set_text ( str _weeks) ;
generalUsersFilesWeeksLabel - > set_text ( _( " weeks" ) ) ;
generalUsersFilesWeeksLabel - > set_text ( str _weeks) ;
generalGroupsSizeDaysLabel - > set_text ( _( " days" ) ) ;
generalGroupsSizeDaysLabel - > set_text ( str _days) ;
generalGroupsFilesDaysLabel - > set_text ( _( " days" ) ) ;
generalGroupsFilesDaysLabel - > set_text ( str _days) ;
generalUsersSizeDaysLabel - > set_text ( _( " days" ) ) ;
generalUsersSizeDaysLabel - > set_text ( str _days) ;
generalUsersFilesDaysLabel - > set_text ( _( " days" ) ) ;
generalUsersFilesDaysLabel - > set_text ( str _days) ;
generalGroupsSizeHoursLabel - > set_text ( _( " hours" ) ) ;
generalGroupsSizeHoursLabel - > set_text ( str _hours) ;
generalGroupsFilesHoursLabel - > set_text ( _( " hours" ) ) ;
generalGroupsFilesHoursLabel - > set_text ( str _hours) ;
generalUsersSizeHoursLabel - > set_text ( _( " hours" ) ) ;
generalUsersSizeHoursLabel - > set_text ( str _hours) ;
generalUsersFilesHoursLabel - > set_text ( _( " hours" ) ) ;
generalUsersFilesHoursLabel - > set_text ( str _hours) ;
generalGroupsSizeMinutesLabel - > set_text ( _( " minutes" ) ) ;
generalGroupsSizeMinutesLabel - > set_text ( str _minutes) ;
generalGroupsFilesMinutesLabel - > set_text ( _( " minutes" ) ) ;
generalGroupsFilesMinutesLabel - > set_text ( str _minutes) ;
generalUsersSizeMinutesLabel - > set_text ( _( " minutes" ) ) ;
generalUsersSizeMinutesLabel - > set_text ( str _minutes) ;
generalUsersFilesMinutesLabel - > set_text ( _( " minutes" ) ) ;
generalUsersFilesMinutesLabel - > set_text ( str _minutes) ;
lblLoad - > set_text ( _( " Load " ) ) ;
lblLoad - > set_text ( str_load_local ) ;
lblSave - > set_text ( _( " Save " ) ) ;
lblSave - > set_text ( str_save_local ) ;
groupsDeviceLabel - > set_label ( _( " Device: " ) ) ;
groupsDeviceLabel - > set_label ( str_device ) ;
usersDeviceLabel - > set_label ( _( " Device: " ) ) ;
usersDeviceLabel - > set_label ( str_device ) ;
headLabel - > set_label ( _( " Configuration of disk quotas parameters for system groups and users " ) ) ;
headLabel - > set_label ( str_lb_head ) ;
filtersNameFilterCheckbox - > set_label ( _( " Name " ) ) ;
filtersNameFilterCheckbox - > set_label ( str_name ) ;
filtersQuotasFilterCheckbox - > set_label ( _( " Quotas " ) ) ;
filtersQuotasFilterCheckbox - > set_label ( str_quotas ) ;
filtersSizeFilterCheckbox - > set_label ( _( " Size " ) ) ;
filtersSizeFilterCheckbox - > set_label ( str_size ) ;
filtersSoftSizeFilterCheckbox - > set_label ( _( " Soft limit (size) " ) ) ;
filtersSoftSizeFilterCheckbox - > set_label ( str_soft_limit_size ) ;
filtersHardSizeFilterCheckbox - > set_label ( _( " Hard limit (size) " ) ) ;
filtersHardSizeFilterCheckbox - > set_label ( str_hard_limit_size ) ;
filtersHardSizeDelayFilterCheckbox - > set_label ( _( " Deferring a hard limit (size) " ) ) ;
filtersHardSizeDelayFilterCheckbox - > set_label ( str_deferring_hard_limit_size ) ;
filtersHardSizeActivationFilterCheckbox - > set_label ( _( " Hard limit activation time (size) " ) ) ;
filtersHardSizeActivationFilterCheckbox - > set_label ( str_hard_activation_size ) ;
filtersFilesFilterCheckbox - > set_label ( _( " Files " ) ) ;
filtersFilesFilterCheckbox - > set_label ( str_files ) ;
filtersSoftFilesFilterCheckbox - > set_label ( _( " Soft Restriction (files) " ) ) ;
filtersSoftFilesFilterCheckbox - > set_label ( str_soft_restriction_files ) ;
filtersHardFilesFilterCheckbox - > set_label ( _( " Severe limitation (files) " ) ) ;
filtersHardFilesFilterCheckbox - > set_label ( str_severe_limitation_files ) ;
filtersHardFilesDelayFilterCheckbox - > set_label ( _( " Deferring a hard limit (files) " ) ) ;
filtersHardFilesDelayFilterCheckbox - > set_label ( str_deferring_limit_files ) ;
filtersHardFilesActivationFilterCheckbox - > set_label ( _( " Hard limit (file) activation time " ) ) ;
filtersHardFilesActivationFilterCheckbox - > set_label ( str_hard_limit_time ) ;
quotegroupDeviceLabel - > set_text ( _( " Device: " ) ) ;
quotegroupDeviceLabel - > set_text ( str_device ) ;
quotegroupDiskQuotasLabel - > set_text ( _( " Disk quotas for this device: " ) ) ;
quotegroupDiskQuotasLabel - > set_text ( str_disk_quotas_device ) ;
quotegroupGroupQuotasLabel - > set_text ( _( " Group quotas for this device: " ) ) ;
quotegroupGroupQuotasLabel - > set_text ( str_group_quotas_device ) ;
quotegroupSizeFrameLabel - > set_text ( _( " Size " ) ) ;
quotegroupSizeFrameLabel - > set_text ( str_size ) ;
quotegroupFilesFrameLabel - > set_text ( _( " Files " ) ) ;
quotegroupFilesFrameLabel - > set_text ( str_files ) ;
quotegroupSizeCurrentlyLabel - > set_text ( _( " Currently using: " ) ) ;
quotegroupSizeCurrentlyLabel - > set_text ( str_currently_using ) ;
quotegroupSizeSoftLimitLabel - > set_text ( _( " Soft limit " ) ) ;
quotegroupSizeSoftLimitLabel - > set_text ( str_soft_limit ) ;
quoteSizeHardLimitLabel - > set_text ( _( " Hard limit " ) ) ;
quoteSizeHardLimitLabel - > set_text ( str_hard_limit ) ;
quoteFilesHardLimitLabel - > set_text ( _( " Hard limit " ) ) ;
quoteFilesHardLimitLabel - > set_text ( str_hard_limit ) ;
quotegroupFilesSoftLimitLabel - > set_text ( _( " Soft limit " ) ) ;
quotegroupFilesSoftLimitLabel - > set_text ( str_soft_limit ) ;
quotegroupFilesCurrentlyLabel - > set_text ( _( " Currently using: " ) ) ;
quotegroupFilesCurrentlyLabel - > set_text ( str_currently_using ) ;
quoteuserDiskQuotasLabel - > set_text ( _( " Disk quotas for this device: " ) ) ;
quoteuserDiskQuotasLabel - > set_text ( str_disk_quotas_device ) ;
quoteuserDeviceLabel - > set_text ( _( " Device: " ) ) ;
quoteuserDeviceLabel - > set_text ( str_device ) ;
quoteuserGroupQuotasLabel - > set_text ( _( " User quotas for this device: " ) ) ;
quoteuserGroupQuotasLabel - > set_text ( str_user_quotas_device ) ;
quoteuserSizeFrameLabel - > set_text ( _( " Size " ) ) ;
quoteuserSizeFrameLabel - > set_text ( str_size ) ;
quoteuserSizeCurrentlyLabel - > set_text ( _( " Currently using: " ) ) ;
quoteuserSizeCurrentlyLabel - > set_text ( str_currently_using ) ;
quoteuserSizeSoftLimitLabel - > set_text ( _( " Soft limit " ) ) ;
quoteuserSizeSoftLimitLabel - > set_text ( str_soft_limit ) ;
quoteuserSizeHardLimitLabel1 - > set_text ( _( " Hard limit " ) ) ;
quoteuserSizeHardLimitLabel1 - > set_text ( str_hard_limit ) ;
quoteuserFileSystemLabel - > set_text ( _( " File system: " ) ) ;
quoteuserFileSystemLabel - > set_text ( str_file_system ) ;
quoteuserFilesFrameLabel - > set_text ( _( " Files " ) ) ;
quoteuserFilesFrameLabel - > set_text ( str_files ) ;
quoteuserFilesCurrentlyLabel - > set_text ( _( " Currently using: " ) ) ;
quoteuserFilesCurrentlyLabel - > set_text ( str_currently_using_space ) ;
quoteuserFilesSoftLimitLabel - > set_text ( _( " Soft limit " ) ) ;
quoteuserFilesSoftLimitLabel - > set_text ( str_soft_limit ) ;
quoteFilesHardLimitLabel1 - > set_text ( _( " Hard limit " ) ) ;
quoteFilesHardLimitLabel1 - > set_text ( str_hard_limit ) ;
quoteuserFilesHarLimitLabel - > set_text ( _( " files" ) ) ;
quoteuserFilesHarLimitLabel - > set_text ( str _files) ;
quoteuserFilesSoftLimitlabel - > set_text ( _( " files" ) ) ;
quoteuserFilesSoftLimitlabel - > set_text ( str _files) ;
quotegroupFileSystemLabel - > set_text ( _( " File system: " ) ) ;
quotegroupFileSystemLabel - > set_text ( str_file_system ) ;
btnLoadGlob - > set_label ( _( " Load from global configuration " ) ) ;
btnLoadGlob - > set_label ( load_global ) ;
btnLoadLocal - > set_label ( _( " Load from local configuration " ) ) ;
btnLoadLocal - > set_label ( load_local ) ;
btnAbout - > set_label ( _( " About " ) ) ;
btnAbout - > set_label ( str_about_1 ) ;
btnSynopsis - > set_label ( _( " Help " ) ) ;
btnSynopsis - > set_label ( str_help ) ;
btnSaveLocalGlob - > set_label ( _( " Save to global and local configuration " ) ) ;
btnSaveLocalGlob - > set_label ( save_all ) ;
btnSaveGlob - > set_label ( _( " Save to global configuration " ) ) ;
btnSaveGlob - > set_label ( save_global ) ;
btnSaveLocal - > set_label ( _( " Save to local configuration " ) ) ;
btnSaveLocal - > set_label ( save_local ) ;
lblHeadFiltersWindow - > set_label ( _( " Filters " ) ) ;
lblHeadFiltersWindow - > set_label ( str_filters ) ;
ProjectTabLabel - > set_label ( _( " Projects " ) ) ;
ProjectTabLabel - > set_label ( str_projects ) ;
usersProjectLabel - > set_text ( _( " Device: " ) ) ;
usersProjectLabel - > set_text ( str_device ) ;
}
}
void MainWindow : : view_add_columns ( Gtk : : TreeView & treeView ) {
void MainWindow : : view_add_columns ( Gtk : : TreeView & treeView ) {
treeView . append_column ( _( " Name " ) , m_columns . name ) ;
treeView . append_column ( str_name , m_columns . name ) ;
treeView . append_column_editable ( _( " Quotas " ) , m_columns . quotas ) ;
treeView . append_column_editable ( str_quotas , m_columns . quotas ) ;
treeView . append_column ( _( " Size " ) , m_columns . size ) ;
treeView . append_column ( str_size , m_columns . size ) ;
treeView . append_column ( _( " Soft limit \n (size) " ) , m_columns . soft_limit_size ) ;
treeView . append_column ( str_tw_soft_limit , m_columns . soft_limit_size ) ;
treeView . append_column ( _( " Severe \n limitation \n (size) " ) , m_columns . hard_limit_size ) ;
treeView . append_column ( str_tw_severe_limitation , m_columns . hard_limit_size ) ;
treeView . append_column ( _( " Deferring \n a hard \n limit \n (size) " ) , m_columns . hard_limit_size_delay ) ;
treeView . append_column ( str_tw_deferring_size , m_columns . hard_limit_size_delay ) ;
treeView . append_column ( _( " Files " ) , m_columns . files ) ;
treeView . append_column ( str_files , m_columns . files ) ;
treeView . append_column ( _( " Soft limit \n (files) " ) , m_columns . soft_limit_files ) ;
treeView . append_column ( str_tw_soft_limit_files , m_columns . soft_limit_files ) ;
treeView . append_column ( _( " Severe \n limitation \n (files) " ) , m_columns . hard_limit_files ) ;
treeView . append_column ( str_tw_severe_limitation_files , m_columns . hard_limit_files ) ;
treeView . append_column ( _( " Deferring \n a hard \n limit \n (files) " ) , m_columns . hard_limit_delay ) ;
treeView . append_column ( str_tw_severe_limitation_files , m_columns . hard_limit_delay ) ;
}
}
void MainWindow : : filling_device_combo_box_template ( Gtk : : ComboBoxText * combo_box , map_str_str & map_device ) {
void MainWindow : : filling_device_combo_box_template ( Gtk : : ComboBoxText * combo_box , map_str_str & map_device ) {
@ -452,8 +454,13 @@ void MainWindow::get_builder() {
builder - > get_widget ( " btnFilterProject " , btnFilterProject ) ;
builder - > get_widget ( " btnFilterProject " , btnFilterProject ) ;
builder - > get_widget ( " btnFilterUsers " , btnFilterUsers ) ;
builder - > get_widget ( " btnFilterUsers " , btnFilterUsers ) ;
builder - > get_widget ( " btnFilterGroups " , btnFilterGroups ) ;
builder - > get_widget ( " btnFilterGroups " , btnFilterGroups ) ;
# ifdef WEBKIT_FOUND
void * handle = NULL ;
handle = dlopen ( " libwebkit2gtk-4.0.so " , RTLD_LAZY ) ;
if ( handle ) {
builder - > get_widget ( " wndWeb " , wndWeb ) ;
}
# endif
}
}
@ -580,8 +587,8 @@ void MainWindow::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *sp
void MainWindow : : info_status_app ( string stule ) {
void MainWindow : : info_status_app ( string stule ) {
Glib : : RefPtr < Gtk : : StyleContext > boxInfo = boxInfoError - > get_style_context ( ) ;
Glib : : RefPtr < Gtk : : StyleContext > boxInfo = boxInfoError - > get_style_context ( ) ;
boxInfo - > remove_class ( " boxInfoMessOK " ) ;
boxInfo - > remove_class ( info_box_ok_css ) ;
boxInfo - > remove_class ( " boxInfoMessError " ) ;
boxInfo - > remove_class ( info_box_error_css ) ;
boxInfo - > add_class ( stule ) ;
boxInfo - > add_class ( stule ) ;
}
}
@ -654,12 +661,43 @@ void MainWindow::wrapper_save_global_cfg() {
}
}
void MainWindow : : synopsis_show ( ) {
void MainWindow : : synopsis_show ( ) {
string cmd = " xdg-open " + string ( _ ( " https://wiki.ublinux.com/ru/Пр о г р а ммно е _о б е с пе че ние /Пр о г р а ммы_и_у тилиты/В с е / " ) ) + app_name ;
if ( flag_open_browser = = true ) {
this - > open_browser ( ) ;
}
else {
wndShowWeb - > show_all ( ) ;
}
}
void MainWindow : : open_browser ( ) {
# ifdef WEBKIT_FOUND
void * handle = NULL ;
handle = dlopen ( " libwebkit2gtk-4.0.so " , RTLD_LAZY ) ;
if ( handle ) {
webkit_web_view_load_uri ( one , link_doc ) ;
wndWeb - > show_all ( ) ;
}
else {
this - > template_open_browser ( ) ;
}
# else
this - > template_open_browser ( ) ;
# endif
}
void MainWindow : : template_open_browser ( ) {
string cmd = cmd_xdg + string ( _ ( link_doc ) ) + " & " ;
string buf = " " ;
if ( geteuid ( ) = = 0 ) {
if ( geteuid ( ) = = 0 ) {
string response_user = getlogin ( ) ;
string response_user = getlogin ( ) ;
cmd = " su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \" " ;
int size_s = std : : snprintf ( nullptr , 0 , cmd_execute , response_user . c_str ( ) , cmd . c_str ( ) ) + 1 ;
auto size = static_cast < size_t > ( size_s ) ;
std : : unique_ptr < char [ ] > buf ( new char [ size ] ) ;
std : : snprintf ( buf . get ( ) , size , cmd_execute , response_user . c_str ( ) , cmd . c_str ( ) ) ;
cmd = std : : string ( buf . get ( ) , buf . get ( ) + size - 1 ) ;
}
}
obj_process_system . call ( cmd , " & " ) ;
obj_process_system . call ( cmd , " ") ;
}
}
void MainWindow : : wrapper_save_system_cfg ( ) {
void MainWindow : : wrapper_save_system_cfg ( ) {
@ -683,27 +721,27 @@ void MainWindow::load_template(map_str_str* map_temp, string str_load) {
void MainWindow : : info_warning_error ( int mess ) {
void MainWindow : : info_warning_error ( int mess ) {
if ( obj_load . get_count_error ( ) > 0 | | obj_save . get_count_error ( ) > 0 ) {
if ( obj_load . get_count_error ( ) > 0 | | obj_save . get_count_error ( ) > 0 ) {
info_status_app ( " boxInfoMessError " ) ;
info_status_app ( info_box_error_css ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-diskquota.warning " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_warning , Gtk : : ICON_SIZE_MENU ) ;
string mess_error = " " ;
string mess_error = " " ;
if ( mess = = 0 ) {
if ( mess = = 0 ) {
mess_error = string ( _( " Local configuration reading error " ) ) + str_cmd_error ;
mess_error = string ( local_read_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
lblWarning - > set_text ( mess_error ) ;
}
}
else if ( mess = = 1 ) {
else if ( mess = = 1 ) {
mess_error = string ( _( " Global configuration read error " ) ) + str_cmd_error ;
mess_error = string ( global_read_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
lblWarning - > set_text ( mess_error ) ;
}
}
else if ( mess = = 2 ) {
else if ( mess = = 2 ) {
mess_error = string ( _( " Local configuration write error " ) ) + str_cmd_error ;
mess_error = string ( local_write_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
lblWarning - > set_text ( mess_error ) ;
}
}
else if ( mess = = 3 ) {
else if ( mess = = 3 ) {
mess_error = string ( _( " Global configuration write error " ) ) + str_cmd_error ;
mess_error = string ( global_write_error ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
lblWarning - > set_text ( mess_error ) ;
}
}
else if ( mess = = 4 ) {
else if ( mess = = 4 ) {
mess_error = string ( _( " Error saved local and global configuration " ) ) + str_cmd_error ;
mess_error = string ( error_save_all ) + str_cmd_error ;
lblWarning - > set_text ( mess_error ) ;
lblWarning - > set_text ( mess_error ) ;
}
}
str_cmd_error = " " ;
str_cmd_error = " " ;
@ -711,39 +749,43 @@ void MainWindow::info_warning_error(int mess) {
obj_save . set_count_error ( 0 ) ;
obj_save . set_count_error ( 0 ) ;
}
}
else {
else {
info_status_app ( " boxInfoMessOK " ) ;
info_status_app ( info_box_ok_css ) ;
imgInfo - > set_from_icon_name ( " com.ublinux.ubl-settings-diskquota.checked " , Gtk : : ICON_SIZE_MENU ) ;
imgInfo - > set_from_icon_name ( icon_checked , Gtk : : ICON_SIZE_MENU ) ;
if ( mess = = 0 ) {
if ( mess = = 0 ) {
lblWarning - > set_text ( _( " Local configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( local_load_ok ) ;
}
}
else if ( mess = = 1 ) {
else if ( mess = = 1 ) {
lblWarning - > set_text ( _( " Global configuration downloaded successfully " ) ) ;
lblWarning - > set_text ( global_load_ok ) ;
}
}
else if ( mess = = 2 ) {
else if ( mess = = 2 ) {
lblWarning - > set_text ( _( " Local configuration successfully written " ) ) ;
lblWarning - > set_text ( local_ok_written ) ;
}
}
else if ( mess = = 3 ) {
else if ( mess = = 3 ) {
lblWarning - > set_text ( _( " Global configuration successfully written " ) ) ;
lblWarning - > set_text ( global_ok_written ) ;
}
}
else if ( mess = = 4 ) {
else if ( mess = = 4 ) {
lblWarning - > set_text ( _( " Successfully saved local and global configuration " ) ) ;
lblWarning - > set_text ( successfully_save_all ) ;
}
}
else if ( mess = = 5 ) {
else if ( mess = = 5 ) {
lblWarning - > set_text ( _( " Nothing to save! " ) ) ;
lblWarning - > set_text ( nothing_save ) ;
}
}
}
}
}
}
MainWindow : : ~ MainWindow ( ) {
# ifdef WEBKIT_FOUND
void * handle = NULL ;
handle = dlopen ( " libwebkit2gtk-4.0.so " , RTLD_LAZY ) ;
if ( handle ) {
free ( one ) ;
}
# endif
}
void help ( ) {
void help ( ) {
string version = string ( _ ( " ubl-settings-diskquota version: " ) ) + version_application + " \n " ;
string version = string ( str_version ) + version_application + " \n " ;
cout < < version . c_str ( ) ;
cout < < version . c_str ( ) ;
string help ;
cout < < str_help_h ;
help = " GTK settings quotas. for UBLinux \n \n "
" Usage: ubl-settings-diskquota [OPTIONS...] \n "
" Options: \n "
" -h, --help Show this help \n "
" -V, --version Show package version \n " ;
cout < < gettext ( help . c_str ( ) ) ;
}
}