#include "view_edit_user_group.h"

View_edit_user_group::View_edit_user_group(/* args */) {
    builder = Gtk::Builder::create_from_file(path_glade);
    this->setting();
}

View_edit_user_group::~View_edit_user_group()
{
}

void View_edit_user_group::setting() {
    this->get_builder();
    this->lacalization();
    check_limit(quotegroupSizeSoftLimitCheckUser
        ,quotegroupSizeSoftLimitSpinUser
        ,quotegroupSizeSoftLimitComboUser);
    check_limit(quotegroupSizeHardLimitCheckUser
        ,quotegroupSizeHardLimitSpinUser
        ,quotegroupSizeHardLimitComboUser);
    check_limit(quotegroupFilesSoftLimitCheckUser
        ,quotegroupFilesSoftLimitSpinUser
        ,quotegroupFilesSoftLimitlabelUser);
    check_limit(quotegroupFilesHardLimitCheckUser
        ,quotegroupFilesHardLimitSpinUser
        ,quotegroupFilesHarLimitLabelUser);
    this->event();
}

void View_edit_user_group::event() {
    btnCancelEditUser->signal_clicked().connect([&]() {wndQuotasEditUser->hide();});
    btnSaveEditUser->signal_clicked().connect([&]() {});
    quotegroupSizeSoftLimitCheckUser->signal_toggled().connect([&]() {
        check_limit(quotegroupSizeSoftLimitCheckUser
        ,quotegroupSizeSoftLimitSpinUser
        ,quotegroupSizeSoftLimitComboUser);
    });
    quotegroupSizeHardLimitCheckUser->signal_toggled().connect([&]() {
        check_limit(quotegroupSizeHardLimitCheckUser
        ,quotegroupSizeHardLimitSpinUser
        ,quotegroupSizeHardLimitComboUser);
    });
    quotegroupFilesSoftLimitCheckUser->signal_toggled().connect([&]() {
        check_limit(quotegroupFilesSoftLimitCheckUser
        ,quotegroupFilesSoftLimitSpinUser
        ,quotegroupFilesSoftLimitlabelUser);
    });
    quotegroupFilesHardLimitCheckUser->signal_toggled().connect([&]() {
        check_limit(quotegroupFilesHardLimitCheckUser
        ,quotegroupFilesHardLimitSpinUser
        ,quotegroupFilesHarLimitLabelUser);
    });
}

void View_edit_user_group::get_builder() {
    builder->get_widget("wndQuotasEditUser", wndQuotasEditUser);
    builder->get_widget("btnCancelEditUser", btnCancelEditUser);
    builder->get_widget("btnSaveEditUser", btnSaveEditUser);
    builder->get_widget("quotegroupSizeSoftLimitCheckUser", quotegroupSizeSoftLimitCheckUser);
    builder->get_widget("quotegroupSizeHardLimitCheckUser", quotegroupSizeHardLimitCheckUser);
    builder->get_widget("quotegroupFilesSoftLimitCheckUser", quotegroupFilesSoftLimitCheckUser);
    builder->get_widget("quotegroupFilesHardLimitCheckUser", quotegroupFilesHardLimitCheckUser);
    builder->get_widget("quotegroupSizeSoftLimitSpinUser", quotegroupSizeSoftLimitSpinUser);
    builder->get_widget("quotegroupSizeHardLimitSpinUser", quotegroupSizeHardLimitSpinUser);
    builder->get_widget("quotegroupFilesSoftLimitSpinUser", quotegroupFilesSoftLimitSpinUser);
    builder->get_widget("quotegroupFilesHardLimitSpinUser", quotegroupFilesHardLimitSpinUser);
    builder->get_widget("quotegroupSizeSoftLimitComboUser", quotegroupSizeSoftLimitComboUser);
    builder->get_widget("quotegroupSizeHardLimitComboUser", quotegroupSizeHardLimitComboUser);
    builder->get_widget("quotegroupFilesSoftLimitlabelUser", quotegroupFilesSoftLimitlabelUser);
    builder->get_widget("quotegroupFilesHarLimitLabelUser", quotegroupFilesHarLimitLabelUser);
    builder->get_widget("quotegroupSizeSoftLimitLabelUser", quotegroupSizeSoftLimitLabelUser);
    builder->get_widget("quotegroupFilesSoftLimitLabelUser", quotegroupFilesSoftLimitLabelUser);
    builder->get_widget("quotegroupSizeCurrentlyLabelUser", quotegroupSizeCurrentlyLabelUser);
    builder->get_widget("quotegroupFilesCurrentlyLabelUser", quotegroupFilesCurrentlyLabelUser);
    builder->get_widget("quotegroupSizeFrameLabelUser", quotegroupSizeFrameLabelUser);
    builder->get_widget("quotegroupFilesFrameLabelUser", quotegroupFilesFrameLabelUser);
    builder->get_widget("lblSetDeviceUser", lblSetDeviceUser);
    builder->get_widget("lblQuotasStatusUser", lblQuotasStatusUser);
    builder->get_widget("lblSetUGPUser", lblSetUGPUser);
    builder->get_widget("lblSetNameDeviceUser", lblSetNameDeviceUser);
    builder->get_widget("lblSetQuotasStatusUser", lblSetQuotasStatusUser);
    builder->get_widget("lblSetUGPUserValue", lblSetUGPUserValue);
    builder->get_widget("lblHeadQuotasEditWindowUser", lblHeadQuotasEditWindowUser);
    builder->get_widget("quoteSizeHardLimitLabel1", quoteSizeHardLimitLabel1);
    builder->get_widget("quoteFilesHardLimitLabelUser", quoteFilesHardLimitLabelUser);
}

void View_edit_user_group::lacalization() {

}


void View_edit_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::ComboBoxText *combo_box) {
    spin->set_sensitive(check_button->get_active());
    combo_box->set_sensitive(check_button->get_active());
}
void View_edit_user_group::check_limit(Gtk::CheckButton *check_button, Gtk::SpinButton *spin, Gtk::Label *combo_box) {
    spin->set_sensitive(check_button->get_active());
    combo_box->set_sensitive(check_button->get_active());
}

void View_edit_user_group::set_label_type_quota(string name) {
    lblSetUGPUser->set_text(name);
}
void View_edit_user_group::show() {
    wndQuotasEditUser->show();
}