|
|
|
|
@ -41,6 +41,7 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::settings(){
|
|
|
|
|
map_cmd_error[""] = "";
|
|
|
|
|
this->get_builder();
|
|
|
|
|
this->localization();
|
|
|
|
|
this->event();
|
|
|
|
|
@ -106,8 +107,12 @@ void MainWindow::get_builder(){
|
|
|
|
|
builder->get_widget("boxKernel", boxKernel);
|
|
|
|
|
builder->get_widget("boxKernel1", boxKernel1);
|
|
|
|
|
builder->get_widget("boxKernel2", boxKernel2);
|
|
|
|
|
builder->get_widget("aboutWindows", aboutWindows);
|
|
|
|
|
builder->get_widget("boxColor", boxColor);
|
|
|
|
|
builder->get_widget("aboutWindows", aboutWindows);
|
|
|
|
|
|
|
|
|
|
builder->get_widget("btnSynopsis", btnSynopsis);
|
|
|
|
|
builder->get_widget("btnAbout", btnAbout);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -116,6 +121,15 @@ void MainWindow::get_builder(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::localization(){
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
unsigned int year = 1900+ ltm->tm_year;
|
|
|
|
|
string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
|
|
|
|
|
aboutWindows->set_copyright(str_authors);
|
|
|
|
|
aboutWindows->set_comments(gettext("Date and Time"));
|
|
|
|
|
aboutWindows->set_website(gettext("https://wiki.ublinux.com"));
|
|
|
|
|
aboutWindows->set_version(gettext(version_application.c_str()));
|
|
|
|
|
aboutWindows->set_website_label(gettext("Project Home Page"));
|
|
|
|
|
lblInfoHead->set_text(gettext("Configuring system boot parameters"));
|
|
|
|
|
lblHeaderName->set_text(gettext("UBConfig - Loading"));
|
|
|
|
|
aboutWindows->set_comments(gettext("Setting bootloader"));
|
|
|
|
|
@ -154,6 +168,8 @@ void MainWindow::localization(){
|
|
|
|
|
chbconsoleOT->set_label(gettext("console (PC BIOS & console EFI)"));
|
|
|
|
|
chbGfxterm->set_label(gettext("gfxterm (Output in graphical mode)"));
|
|
|
|
|
chbVgaText->set_label(gettext("chbVgaText"));
|
|
|
|
|
btnSynopsis->set_label(gettext("Help"));
|
|
|
|
|
btnAbout->set_label(gettext("About"));
|
|
|
|
|
|
|
|
|
|
//set_label(gettext("Command line parameters:"));
|
|
|
|
|
}
|
|
|
|
|
@ -164,6 +180,91 @@ void MainWindow::event(){
|
|
|
|
|
chbintelMax1->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax1));
|
|
|
|
|
chbintelMax4->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax4));
|
|
|
|
|
signal_configure_event().connect(sigc::mem_fun(*this, &MainWindow::gui_set_orientation), false);
|
|
|
|
|
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
|
|
|
|
|
btnAbout->signal_activate().connect([&]() {aboutWindows->show();});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::synopsis_show() {
|
|
|
|
|
wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home", "&");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::wrapper_system(string cmd, string thread_str = "") {
|
|
|
|
|
string cmd_new = cmd + " " + thread_str;
|
|
|
|
|
int response_cmd = system(cmd_new.c_str());
|
|
|
|
|
if (response_cmd != 0) {
|
|
|
|
|
index_error += 1;
|
|
|
|
|
//this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
|
|
struct Result<string> obj_result;
|
|
|
|
|
string response = this->call(cmd);
|
|
|
|
|
if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) {
|
|
|
|
|
if (response.find("=") != std::string::npos) {
|
|
|
|
|
if (response.find("\n") != std::string::npos) {
|
|
|
|
|
response = response.substr(response.find("=")+1,response.length());
|
|
|
|
|
response = response.substr(0,response.find("\n"));
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 0;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 1;
|
|
|
|
|
index_error += 1;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 2;
|
|
|
|
|
index_error += 1;
|
|
|
|
|
str_cmd_error = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
obj_result.response = response;
|
|
|
|
|
obj_result.error = 3;
|
|
|
|
|
index_error += 1;
|
|
|
|
|
str_cmd_error = cmd;
|
|
|
|
|
this->log_mess_error(cmd);
|
|
|
|
|
}
|
|
|
|
|
return obj_result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string MainWindow::call(string cmd) {
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int status;
|
|
|
|
|
char path[PATH_MAX] = {0};
|
|
|
|
|
fp = popen(cmd.c_str(), "r");
|
|
|
|
|
if (fp == NULL) {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
while (fgets(path, PATH_MAX, fp) != NULL) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
status = pclose(fp);
|
|
|
|
|
if (status == -1) {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::log_mess_error(string &cmd){
|
|
|
|
|
string key = "";
|
|
|
|
|
if (map_cmd_error.find(cmd) != map_cmd_error.end()){
|
|
|
|
|
str_cmd_error = map_cmd_error[cmd];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
for ( const auto &map_iter: map_cmd_error ) {
|
|
|
|
|
key = map_iter.first;
|
|
|
|
|
if (cmd.find(key) != std::string::npos){
|
|
|
|
|
str_cmd_error = map_iter.second;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::fn_event_intelMax1(){
|
|
|
|
|
|