You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-diskquota/source/view/ubl-settings-diskquota.h

344 lines
16 KiB

#ifndef UBL_SETTINGS_QUOTAS_H
#define UBL_SETTINGS_QUOTAS_H
#include <dlfcn.h>
#include "../project_lib.h"
#include "../my_type.h"
#include "ubl-util-standard.c"
#ifdef WEBKIT_FOUND
#include <webkit2/webkit2.h>
#endif
#define name_app _("ubl-settings-diskquota")
#define configuring_system_boot _("Configuring system boot parameters")
#define system_boot _("System boot")
#define str_about _("About ubl-settings-diskquota")
#define command_line_parameters _("Command line parameters:")
#define load_default _("Load default:")
#define seconds _("seconds")
#define download_menu _("Download menu")
#define terminal_for_input _("Terminal for input")
#define terminal_for_output _("Terminal for output")
#define boot_selection_menu_timer _("Boot selection menu timer")
#define str_help _("Help")
#define str_about_1 _("About")
#define str_save_local _("Save")
#define str_load_local _("Load")
#define save_all _("Save in global and local configuration")
#define save_local _("Save in local configuration")
#define save_global _("Save in global configuration")
#define load_global _("Load global configuration")
#define load_local _("Load local configuration")
#define read_online _("Read online")
#define cancel _("Cancel")
#define always_redirect _("Always redirect")
#define boot_screen_display_mode _("Boot screen display mode:")
#define no_loading_animation _("No loading animation, full log")
#define boot_menu_user_name _("Boot menu user name:")
#define boot_menu_user_password _("Boot menu user password:")
#define last_successful_upload _("Last successful upload")
#define read_documentation_web _("Would you like to read documentation in the Web?")
#define redirected_documentation _("You will be redirected to documentation site, where user help pages are ""translated and supported by community.")
#define local_read_error _("Local configuration reading error")
#define global_read_error _("Global configuration read error")
#define local_write_error _("Local configuration write error")
#define global_write_error _("Global configuration write error")
#define error_save_all _("Error saved local and global configuration")
#define local_load_ok _("Local configuration downloaded successfully")
#define global_load_ok _("Global configuration downloaded successfully")
#define local_ok_written _("Local configuration successfully written")
#define global_ok_written _("Global configuration successfully written")
#define successfully_save_all _("Successfully saved local and global configuration")
#define nothing_save _("Nothing to save!")
#define program_as_root _("The program must be run as root")
#define str_weeks _("weeks")
#define str_days _("days")
#define str_hours _("hours")
#define str_minutes _("minutes")
#define str_device _("Device:")
#define str_users _("Users")
#define str_groups _("Groups")
#define str_files _("files")
#define str_hard_limit _("Hard limit")
#define str_file_system _("File system:")
#define str_name _("Name")
#define str_size _("Size")
#define str_quotas_mode _("Direct control of the file system")
#define str_lb_head _("Configuration of disk quotas parameters for system groups and users")
#define str_soft_limit _("Soft limit")
#define str_currently_using _("Currently using:")
#define str_currently_using_space _("Currently using: ")
#define str_filters _("Filters")
#define str_quotas _("Quotas")
#define str_help_h _("GTK settings disk quota for UBLinux\n" \
"\n" \
"Usage: ubl-settings-diskquota [OPTIONS...]\n" \
"Options:\n" \
" -h, --help\t Show this help\n" \
" -V, --version\t Show package version\n" \
" --lock-help Lock utility help\n" \
" --lock-save Lock saving local and global configuration\n" \
" --lock-save-local Lock save global configuration\n" \
" --lock-save-global Lock load global configuration\n" \
" --lock-load-global Lock load global configuration\n")
#define str_version _("ubl-settings-diskquota version: ")
#define str_user _("User")
#define str_group _("Group")
#define str_projects _("Projects")
#define str_user_1 _("User:")
#define str_group_1 _("Group:")
#define str_project_1 _("Projects:")
#define str_device_project _("Device\nProject")
#define str_quota _("Quota type")
#define str_status _("Status")
#define str_excess_size_delay _("Excess size delay period")
#define str_excess_files_delay _("Excess files delay period")
#define str_disk_quotas_device _("Disk quotas for this device:")
#define str_user_quotas_device _("User quotas for this device: ")
#define str_soft_limit_size _("Soft limit (size)")
#define str_tw_soft_limit _("Soft limit\n(size)")
#define str_hard_limit_size _("Hard limit (size)")
#define str_deferring_hard_limit_size _("Deferring a hard limit (size)")
#define str_hard_activation_size _("Hard limit activation time (size)")
#define str_hard_limit_time _("Hard limit (file) activation time")
#define str_group_quotas_device _("Group quotas for this device:")
#define str_general_settings _("General settings")
#define str_tw_severe_limitation _("Severe\nlimitation\n(size)")
#define str_tw_general_deferring_size _("Deferring\n(size)")
#define str_tw_general_deferring_files _("Deferring\n(files)")
#define str_tw_deferring_size _("Deferring\na hard\nlimit\n(files)")
#define str_tw_deferring_files _("Deferring\na hard\nlimit\n(files)")
#define str_tw_soft_limit_files _("Soft limit\n(files)")
#define str_tw_severe_limitation_files _("Severe\nlimitation\n(files)")
#define str_soft_restriction_files _("Soft Restriction (files)")
#define str_severe_limitation_files _("Severe limitation (files)")
#define str_deferring_limit_files _("Deferring a hard limit (files)")
#define info_box_ok_css "boxInfoMessOK"
#define info_box_error_css "boxInfoMessError"
#define icon_checked "com.ublinux.ubl-settings-diskquota.checked"
#define icon_warning "com.ublinux.ubl-settings-diskquota.warning"
#define path_app "/usr/bin/"
#define path_glade "/usr/share/ubl-settings-diskquota/ui/ubl-settings-diskquota.glade"
#define path_css "/usr/share/ubl-settings-diskquota/css/ubl-settings-diskquota.css"
#define app_name "ubl-settings-diskquota"
#define path_resources "/usr/share/ubl-settings-diskquota"
#define path_img_head_background "/usr/share/ubl-settings-diskquota/images/logo-background.png"
#define no_recognized _("Argument not recognized\n")
using namespace std;
extern string version_application;
extern bool flag_save;
extern bool flag_save_local;
extern bool flag_save_global;
extern bool flag_load_global;
extern bool flag_lock_help;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
class MainWindow : public Gtk::ApplicationWindow {
public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
ModelColumns() {add(name), add(quotas); add(size),
add(soft_limit_size), add(hard_limit_size); add(deferring_size),
add(files); add(soft_limit_files),
add(hard_limit_delay), add(deferring_files); }
Gtk::TreeModelColumn<Glib::ustring> name;
Gtk::TreeModelColumn<Glib::ustring> quotas;
Gtk::TreeModelColumn<Glib::ustring> size;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size;
Gtk::TreeModelColumn<Glib::ustring> deferring_size;
Gtk::TreeModelColumn<Glib::ustring> files;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_delay;
Gtk::TreeModelColumn<Glib::ustring> deferring_files;
};
class ModelColumnsGeneral : public Gtk::TreeModel::ColumnRecord {
public:
ModelColumnsGeneral() {add(status), add(type_quotas); add(device),
add(user), add(group), add(projects); add(soft_limit_size),
add(hard_limit_size); add(soft_limit_files), add(hard_limit_files), add(deferring_size),
add(deferring_files); }
Gtk::TreeModelColumn<bool> status;
Gtk::TreeModelColumn<Glib::ustring> type_quotas;
Gtk::TreeModelColumn<Glib::ustring> device;
Gtk::TreeModelColumn<Glib::ustring> user;
Gtk::TreeModelColumn<Glib::ustring> group;
Gtk::TreeModelColumn<Glib::ustring> projects;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_size;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_size;
Gtk::TreeModelColumn<Glib::ustring> soft_limit_files;
Gtk::TreeModelColumn<Glib::ustring> hard_limit_files;
Gtk::TreeModelColumn<Glib::ustring> deferring_size;
Gtk::TreeModelColumn<Glib::ustring> deferring_files;
};
ModelColumns m_columns;
ModelColumnsGeneral m_columnsGeneral;
Glib::RefPtr<Gtk::Builder> builder;
template<typename Type>
struct Result{
Type response;
int error;
};
Gtk::Label *headerTopic;
Gtk::Overlay *HeadOverlay;
Gtk::HeaderBar *headerBar;
Gtk::Box *boxSave;
Gtk::Box *boxButton;
Gtk::Box *boxFuncs;
Gtk::MenuButton *btnSave;
Gtk::MenuButton *btnLoad;
Gtk::MenuButton *btnSettings;
Gtk::Image *HeadBackgroundImage;
Gtk::Image *imgInfo;
Gtk::Box *boxInfoError;
Gtk::Label *lblWarning;
Gtk::Label *generalTabLabel;
Gtk::Label *UsersTabLabel;
Gtk::Label *GroupsTabLabel;
Gtk::Label *generalGroupsFilesLabel;
Gtk::Label *generalUsersSizeLabel;
Gtk::Label *generalUsersFilesLabel;
Gtk::Label *generalGroupsSizeWeeksLabel;
Gtk::Label *generalGroupsFilesWeeksLabel;
Gtk::Label *generalUsersSizeWeeksLabel;
Gtk::Label *generalUsersFilesWeeksLabel;
Gtk::Label *generalGroupsSizeDaysLabel;
Gtk::Label *generalGroupsFilesDaysLabel;
Gtk::Label *generalUsersSizeDaysLabel;
Gtk::Label *generalUsersFilesDaysLabel;
Gtk::Label *generalGroupsSizeHoursLabel;
Gtk::Label *generalGroupsFilesHoursLabel;
Gtk::Label *generalUsersSizeHoursLabel;
Gtk::Label *generalUsersFilesHoursLabel;
Gtk::Label *generalGroupsSizeMinutesLabel;
Gtk::Label *generalGroupsFilesMinutesLabel;
Gtk::Label *generalUsersSizeMinutesLabel;
Gtk::Label *generalUsersFilesMinutesLabel;
Gtk::Label *ProjectTabLabel;
Gtk::Label *usersProjectLabel;
Gtk::Label *lblLoad;
Gtk::Label *lblSave;
Gtk::MenuItem *btnLoadGlob;
Gtk::MenuItem *btnLoadLocal;
Gtk::MenuItem *btnSynopsis;
Gtk::MenuItem *btnAbout;
Gtk::MenuItem *btnSaveLocalGlob;
Gtk::MenuItem *btnSaveGlob;
Gtk::MenuItem *btnSaveLocal;
Gtk::Label *groupsDeviceLabel;
Gtk::Label *usersDeviceLabel;
Gtk::Label *headLabel;
Gtk::TreeView *groupsQuotasTree;
Gtk::TreeView *usersQuotasTree;
Gtk::TreeView *ProjectQuotasTree;
Gtk::TreeView *GeneralQuotasTree;
Gtk::Label *quotegroupGroupQuotasLabel;
Gtk::ComboBoxText *usersDeviceCombo;
Gtk::ComboBoxText *groupsDeviceCombo;
Gtk::ComboBoxText *generalDeviceCombo;
Gtk::ComboBoxText *usersProjectCombo;
Gtk::Label *lblFstypeGroups;
Gtk::SpinButton *generalGroupsSizeWeeksSpi;
Gtk::SpinButton *generalGroupsFileWeeksSpin;
Gtk::SpinButton *generalGroupsSizeDaySpin;
Gtk::SpinButton *generalGroupsFilesDaySpin;
Gtk::SpinButton *generalGroupsSizeHourSpin;
Gtk::SpinButton *generalGroupsFilesHourSpin;
Gtk::SpinButton *generalGroupsSizeMinuteSpin;
Gtk::SpinButton *generalGroupsFilesMinuteSpin;
Gtk::SpinButton *generalUsersSizWeeksSpin;
Gtk::SpinButton *generalUsersFileWeeksSpin;
Gtk::SpinButton *generalUsersSizeDaySpin;
Gtk::SpinButton *generalUsersFilesDaySpin;
Gtk::SpinButton *generalUsersSizeHourSpin;
Gtk::SpinButton *generalUsersFilesHoursSpin;
Gtk::SpinButton *generalUsersSizeMinuteSpin;
Gtk::SpinButton *generalUsersFilesMinutesSpin;
Gtk::Button *btnFilterGroups;
Gtk::Button *btnFilterUsers;
Gtk::Button *btnFilterProject;
Gtk::CheckMenuItem *chbMangSystemFile;
Gtk::Button* btnDelGroups;
Gtk::Button* btnDelProject;
Gtk::Button* btnDelUsers;
Gtk::Button* btnAddGroups;
Gtk::Button* btnAddUsers;
Gtk::Button* btnAddProject;
Gtk::Button* btnEditProject;
Gtk::Button* btnEditUsers;
Gtk::Button* btnEditGroups;
public:
map_str_str map_gui_cfg;
map_str_str map_global_cfg;
map_str_str map_system_cfg;
//Devices::Parted obj_device = Devices::Parted();
//Quotas_sys::Quotas_sys obj_quotas_sys = Quotas_sys::Quotas_sys();
//Quotas_ubconfig::Quotas_ubconfig obj_quotas_ubconfig = Quotas_ubconfig::Quotas_ubconfig();
vector<string> vec_param_names;
map_str_str map_device;
string str_cmd_error;
string save_user_or_group;
string sys_or_ubconfig;
string hw_or_sw = "";
string mode_quota = "ubconfig";
Glib::RefPtr<Gtk::ListStore> list_store_groups;
Glib::RefPtr<Gtk::ListStore> list_store_users;
Glib::RefPtr<Gtk::ListStore> list_store_project;
Gtk::TreeModel::iterator iter_groups;
Gtk::TreeModel::iterator iter_users;
Gtk::TreeModel::iterator iter_project;
bool flag_validate_del_groups = false;
bool flag_validate_del_users = false;
bool flag_validate_del_project = false;
Gtk::TreeModel::Row row;
const struct tv_g_u_p obj_tv_g_u_p {"", "", "", "", "", "", "", "", "",""};
public:
MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder);
MainWindow(Glib::RefPtr<Gtk::Builder> const& builder);
~MainWindow();
void settings();
void flag_block_gui();
void lacalization();
void add_CSS();
void get_builder();
void event();
void info_warning_error(int mess, int error_save, int error_load);
void init_work_tv_g_u_p();
void remove_line_template(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter, Gtk::TreeModel::iterator& iter_del, bool& flag_del);
void remove_template(Glib::RefPtr<Gtk::ListStore>* list_store, const Gtk::TreeModel::iterator* iter, bool& flag_validate_del);
void init_tree_view_general();
void entry_combo_box_temp(Gtk::ComboBoxText *combo_box, Gtk::Label *label);
void info_status_app(string stule);
void filters_show();
void init_tree_view();
void del_columns();
void set_add_tv_g_u_p(Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store, struct tv_g_u_p obj_tv_g_u_p);
void off_quota_system(Gtk::ComboBoxText* combo_box, string quota_type);
void mode_switch_quota();
void save_quotegroupSaveButton();
void filling_device_combo_box_template(Gtk::ComboBoxText *combo_box, map_str_str &map_device);
void wrapper_settings_quotas_temp(string save_user_or_group);
void off_quota_ubconfig(Gtk::ComboBoxText* combo_box, string quota_type);
void init_spin_all();
void view_add_columns(Gtk::TreeView &treeView);
void format_cmd_quotas_system(struct struct_quotas& _struct_quota);
void format_cmd_quotas_ubconfig(struct struct_quotas& _struct_quota);
struct partition_cmd wrapper_settings_quotas();
};
void help();
#endif