#include "view_edit_project.h"

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

View_edit_project::~View_edit_project()
{
}

void View_edit_project::setting() {
    this->get_builder();
    this->lacalization();
    check_limit(quoteSizeSoftLimitCheckProjectEdit
        ,quoteSizeSoftLimitSpinProjectEdit
        ,quoteSizeSoftLimitComboProjectEdit);
    check_limit(quoteSizeHardLimitCheckProjectEdit
        ,quoteSizeHardLimitSpinEdit
        ,quoteSizeHardLimitComboProjectEdit);
    check_limit(quoteFilesSoftLimitCheckProjectEdit
        ,quoteFilesSoftLimitSpinProjectEdit
        ,quoteFilesProjectEdit);
    check_limit(quoteFilesHardLimitCheckProjectEdit
        ,quoteFilesHardLimitSpinProjectEdit
        ,quoteFiles1ProjectEdit);
    this->event();
}

void View_edit_project::event() {
    
    quoteCancelButtonEdit->signal_clicked().connect([&]() {this->close_wnd();});
    quoteSaveButtonEdit->signal_clicked().connect([&]() {this->save();});
    quoteSizeSoftLimitCheckProjectEdit->signal_toggled().connect([&]() {
        check_limit(quoteSizeSoftLimitCheckProjectEdit
        ,quoteSizeSoftLimitSpinProjectEdit
        ,quoteSizeSoftLimitComboProjectEdit);
    });
    quoteSizeHardLimitCheckProjectEdit->signal_toggled().connect([&]() {
        check_limit(quoteSizeHardLimitCheckProjectEdit
        ,quoteSizeHardLimitSpinEdit
        ,quoteSizeHardLimitComboProjectEdit);
    });
    quoteFilesSoftLimitCheckProjectEdit->signal_toggled().connect([&]() {
        check_limit(quoteFilesSoftLimitCheckProjectEdit
        ,quoteFilesSoftLimitSpinProjectEdit
        ,quoteFilesProjectEdit);
    });
    quoteFilesSoftLimitCheckProjectEdit->signal_toggled().connect([&]() {
        check_limit(quoteFilesSoftLimitCheckProjectEdit
        ,quoteFilesHardLimitSpinProjectEdit
        ,quoteFiles1ProjectEdit);
    });
}

void View_edit_project::close_wnd() {
    wndQuotasEditProject->hide();
}

void View_edit_project::save() {
    wndQuotasEditProject->hide();
}

void View_edit_project::show() {
    wndQuotasEditProject->show();
}

void View_edit_project::get_builder() {
    builder->get_widget("lblDeviceProjectEdit", lblDeviceProjectEdit);
    builder->get_widget("lblEditDeviceProjectValue", lblEditDeviceProjectValue);
    builder->get_widget("lblStatusQuotaProjectEdit", lblStatusQuotaProjectEdit);
    builder->get_widget("lblStatusQuotaProjectValueEdit", lblStatusQuotaProjectValueEdit);
    builder->get_widget("lblCatalogProjectEdit", lblCatalogProjectEdit);
    builder->get_widget("lblCatalogProjectEdit", lblCatalogProjectEdit);
    builder->get_widget("lblProjectIdEdit", lblProjectIdEdit);
    builder->get_widget("lblProjectIdValueEdit", lblProjectIdValueEdit);
    builder->get_widget("lblProjectNameEdit", lblProjectNameEdit);
    builder->get_widget("entryProjectNameEditValue", entryProjectNameEditValue);
    builder->get_widget("quoteSizeFrameLabelProjectEdit", quoteSizeFrameLabelProjectEdit);
    builder->get_widget("quoteSizeCurrentlyLabelProjectEdit", quoteSizeCurrentlyLabelProjectEdit);
    builder->get_widget("quoteSizeSoftLimitLabelProjectEdit", quoteSizeSoftLimitLabelProjectEdit);
    builder->get_widget("quoteSizeSoftLimitCheckProjectEdit", quoteSizeSoftLimitCheckProjectEdit);
    builder->get_widget("quoteSizeSoftLimitSpinProjectEdit", quoteSizeSoftLimitSpinProjectEdit);
    builder->get_widget("quoteSizeSoftLimitComboProjectEdit", quoteSizeSoftLimitComboProjectEdit);
    builder->get_widget("quoteSizeHardLimitLabelProjectEdit", quoteSizeHardLimitLabelProjectEdit);
    builder->get_widget("quoteSizeHardLimitCheckProjectEdit", quoteSizeHardLimitCheckProjectEdit);
    builder->get_widget("quoteSizeHardLimitSpinEdit", quoteSizeHardLimitSpinEdit);
    builder->get_widget("quoteSizeHardLimitComboProjectEdit", quoteSizeHardLimitComboProjectEdit);
    builder->get_widget("quoteFilesFrameLabelProjectEdit", quoteFilesFrameLabelProjectEdit);
    builder->get_widget("quoteFilesCurrentlyLabelProjectEdit", quoteFilesCurrentlyLabelProjectEdit);
    builder->get_widget("quoteFilesSoftLimitLabelProjectEdit", quoteFilesSoftLimitLabelProjectEdit);
    builder->get_widget("quoteFilesSoftLimitCheckProjectEdit", quoteFilesSoftLimitCheckProjectEdit);
    builder->get_widget("quoteFilesSoftLimitSpinProjectEdit", quoteFilesSoftLimitSpinProjectEdit);
    builder->get_widget("quoteFilesHardLimitCheckProjectEdit", quoteFilesHardLimitCheckProjectEdit);
    builder->get_widget("quoteFilesHardLimitSpinProjectEdit", quoteFilesHardLimitSpinProjectEdit);
    builder->get_widget("quoteCancelButtonEdit", quoteCancelButtonEdit);
    builder->get_widget("quoteSaveButtonEdit", quoteSaveButtonEdit);
    builder->get_widget("quoteFilesProjectEdit", quoteFilesProjectEdit);
    builder->get_widget("quoteFiles1ProjectEdit", quoteFiles1ProjectEdit);
    builder->get_widget("wndQuotasEditProject", wndQuotasEditProject);
    builder->get_widget("quoteFilesHardLimitLabelProject1", quoteFilesHardLimitLabelProject1); 
}

void View_edit_project::lacalization() {

}


void View_edit_project::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_project::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());
}