|
|
|
|
|
#include "ubl-settings-bootloader.h"
|
|
|
using namespace std;
|
|
|
|
|
|
string path_app = "/usr/bin/";
|
|
|
string path_glade= "/usr/share/ubl-settings-bootloader/ui/ubl-settings-bootloader.glade";
|
|
|
string path_css = "/usr/share/ubl-settings-bootloader/css/ubl-settings-bootloader.css";
|
|
|
string app_name = "ubl-settings-bootloader";
|
|
|
string path_resources = "/usr/share/ubl-settings-bootloader";
|
|
|
const string path_img_head_background = "/usr/share/ubl-settings-bootloader/images/logo-background.png";
|
|
|
int socket_ext_id_I = 0;
|
|
|
int socket_trd_id_I = 0;
|
|
|
string version_application = "1.0";
|
|
|
|
|
|
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
|
|
|
: Glib::OptionGroup{p_name, p_description, p_help} {
|
|
|
Glib::OptionEntry socketIDArg;
|
|
|
socketIDArg.set_long_name("socket-id");
|
|
|
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
|
|
|
socketIDArg.set_description("Settings manager socket");
|
|
|
|
|
|
Glib::OptionEntry socketExtId;
|
|
|
socketExtId.set_long_name("socket-ext-id");
|
|
|
socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
|
|
|
socketExtId.set_description("Settings manager secondary socket");
|
|
|
|
|
|
Glib::OptionEntry socketTrdId;
|
|
|
socketTrdId.set_long_name("socket-trd-id");
|
|
|
socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
|
|
|
socketTrdId.set_description("Settings manager secondary socket");
|
|
|
|
|
|
add_entry(socketIDArg, m_socketID);
|
|
|
add_entry(socketExtId, socket_ext_id_I);
|
|
|
add_entry(socketTrdId, socket_trd_id_I);
|
|
|
}
|
|
|
::Window CmdArgParser::GetSocketID() const{
|
|
|
return m_socketID;
|
|
|
}
|
|
|
|
|
|
SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> builder)
|
|
|
: Gtk::Plug{p_socketID} {
|
|
|
MainWindow* wnd = nullptr;
|
|
|
builder->get_widget_derived("window", wnd);
|
|
|
builder->get_widget("plugBox", plugBox);
|
|
|
plugBox->get_parent()->remove(*plugBox);
|
|
|
add(*plugBox);
|
|
|
show_all_children();
|
|
|
}
|
|
|
|
|
|
int MainWindow::check_root() {
|
|
|
if (geteuid() != 0) {
|
|
|
//lblMessageSudo->set_text(_("The program must be run with \nsuperuser privileges!"));
|
|
|
//mess_sudo->show();
|
|
|
return 1;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
|
|
|
: Gtk::ApplicationWindow(obj), builder{builder} {
|
|
|
this->builder = builder;
|
|
|
this->settings();
|
|
|
}
|
|
|
|
|
|
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
this->builder = builder;
|
|
|
this->settings();
|
|
|
}
|
|
|
|
|
|
void MainWindow::settings(){
|
|
|
map_cmd_error[""] = "";
|
|
|
this->get_builder();
|
|
|
this->localization();
|
|
|
this->add_CSS();
|
|
|
Gtk::Widget *boxWidget;
|
|
|
builder->get_widget("boxColor", boxWidget);
|
|
|
overHead->add_overlay(*boxWidget);
|
|
|
btnBoxAboutDialog->set_visible(false);
|
|
|
ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
|
|
|
if (this->check_root() == 0) {
|
|
|
this->fill_in_view();
|
|
|
this->download_local_cfg();
|
|
|
this->download_globl_cfg();
|
|
|
this->event();
|
|
|
|
|
|
}
|
|
|
else{
|
|
|
this->event();
|
|
|
boxWidgetAll->set_sensitive(false);
|
|
|
btnLoad->set_sensitive(false);
|
|
|
boxSave->set_sensitive(false);
|
|
|
imgInfo->set("/usr/share/icons/hicolor/scalable/status/ru.ublinux.ubl-settings-bootloader.warning.svg");
|
|
|
info_status_app("boxInfoMessError");
|
|
|
lblWarning->set_text(_("The program must be run as root"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void MainWindow::fill_in_view() {
|
|
|
list_store_kernel = Gtk::ListStore::create(m_columns);
|
|
|
list_store_IPT = Gtk::ListStore::create(m_columns);
|
|
|
list_store_OTT = Gtk::ListStore::create(m_columns);
|
|
|
treeViewKernel->set_model(list_store_kernel);
|
|
|
treeViewIPT->set_model(list_store_IPT);
|
|
|
treeViewOTT->set_model(list_store_OTT);
|
|
|
|
|
|
this->read_file_and_view("boot-options.csv", row_kernel, list_store_kernel);
|
|
|
this->read_file_and_view("input-options.csv", row_IPT, list_store_IPT);
|
|
|
this->read_file_and_view("output-options.csv", row_OTT, list_store_OTT);
|
|
|
this->view_add_colums(*treeViewKernel);
|
|
|
this->view_add_colums(*treeViewIPT);
|
|
|
this->view_add_colums(*treeViewOTT);
|
|
|
// auto iter = list_store_kernel->prepend();
|
|
|
// row_kernel[m_columns.cmd_set_true];
|
|
|
// cout << cmd << endl;
|
|
|
}
|
|
|
|
|
|
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
|
|
|
auto selection_IPT = treeViewIPT->get_selection();
|
|
|
auto selection_OTT = treeViewOTT->get_selection();
|
|
|
selection_IPT->unselect_all();
|
|
|
selection_OTT->unselect_all();
|
|
|
template_item_selected(map_cmd_selection_kernel, path, list_store_kernel);\
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_kernel,map_global_cmd_selection_kernel,map_local_cmd_selection_kernel);
|
|
|
entryKernel->set_text(str_flags);
|
|
|
}
|
|
|
|
|
|
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
|
|
|
auto selection_kernel = treeViewKernel->get_selection();
|
|
|
auto selection_IPT = treeViewIPT->get_selection();
|
|
|
selection_kernel->unselect_all();
|
|
|
selection_IPT->unselect_all();
|
|
|
template_item_selected(map_cmd_selection_OTT , path, list_store_OTT);
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_OTT, map_global_cmd_selection_OTT,map_local_cmd_selection_OTT);
|
|
|
entryOTT->set_text(str_flags);
|
|
|
|
|
|
|
|
|
}
|
|
|
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator&) {
|
|
|
auto selection_kernel = treeViewKernel->get_selection();
|
|
|
auto selection_OTT = treeViewOTT->get_selection();
|
|
|
selection_kernel->unselect_all();
|
|
|
selection_OTT->unselect_all();
|
|
|
template_item_selected(map_cmd_selection_IPT , path, list_store_IPT);
|
|
|
string str_flags = this->dynamic_update_entry(map_cmd_selection_IPT, map_global_cmd_selection_IPT,map_local_cmd_selection_IPT);
|
|
|
entryIPT->set_text(str_flags);
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::template_item_selected(std::map<string, string> &map_view, const Gtk::TreeModel::Path& path, Glib::RefPtr<Gtk::ListStore> &list_store) {
|
|
|
const auto iter = list_store->get_iter(path);
|
|
|
if(iter) {
|
|
|
const auto row = *iter;
|
|
|
Glib::ustring cmd;
|
|
|
bool check_btn = row[m_columns.check_button];
|
|
|
if (check_btn) {
|
|
|
cmd = row[m_columns.cmd_set_true];
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
cmd = row[m_columns.cmd_set_false];
|
|
|
|
|
|
}
|
|
|
Glib::ustring name = row[m_columns.name];
|
|
|
cout << cmd << " " << name << endl;
|
|
|
map_view[name] = cmd;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
string MainWindow::dynamic_update_entry(std::map<string, string> &map_view, std::map<string, string> &map_global_view, std::map<string, string> &map_local_view) {
|
|
|
string keys = "";
|
|
|
for(auto &it: map_view) {
|
|
|
string key = it.first;
|
|
|
if (flag_load == true && map_global_view.find(key) != map_global_view.end()) {
|
|
|
if (map_global_view[key] != map_view[key]){
|
|
|
keys += string(key) + ", ";
|
|
|
}
|
|
|
}
|
|
|
else if (flag_load == false && map_local_view.find(key) != map_local_view.end()) {
|
|
|
if (map_local_view[key] != map_view[key]){
|
|
|
keys += string(key) + ", ";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return keys;
|
|
|
}
|
|
|
|
|
|
|
|
|
void MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
|
std::array<std::vector<std::string>, 5> arr_view = read_csv(path_resources + "/" + file_name);
|
|
|
std::vector<std::string> vec_Option = arr_view[3];
|
|
|
std::vector<std::string> vec_Description = arr_view[4];
|
|
|
for (size_t index = 0; index < vec_Option.size(); index++) {
|
|
|
|
|
|
this->view_add_cell(row, list_store_m , arr_view, index);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void MainWindow::view_add_colums(Gtk::TreeView &treeView) {
|
|
|
treeView.append_column_editable(_("Active"), m_columns.check_button);
|
|
|
treeView.append_column(_("Option"), m_columns.name);
|
|
|
treeView.append_column(_("Description"), m_columns.description);
|
|
|
}
|
|
|
|
|
|
void MainWindow::view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m , std::array<std::vector<std::string>, 5> &arr_view , size_t index) {
|
|
|
row = *(list_store_m->append());
|
|
|
bool flag_chb = true;
|
|
|
row[m_columns.cmd_get] = arr_view[0][index];
|
|
|
row[m_columns.cmd_set_true] = arr_view[1][index];
|
|
|
row[m_columns.cmd_set_false] = arr_view[2][index];
|
|
|
row[m_columns.check_button] = flag_chb;
|
|
|
row[m_columns.name] = _(arr_view[3][index].c_str());
|
|
|
row[m_columns.description] = _(arr_view[4][index].c_str());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::get_monitor_size(){
|
|
|
GdkRectangle workarea;
|
|
|
gdk_monitor_get_workarea(
|
|
|
gdk_display_get_primary_monitor(gdk_display_get_default()),&workarea);
|
|
|
screen_width = workarea.width;
|
|
|
screen_hight = workarea.height;
|
|
|
}
|
|
|
|
|
|
void MainWindow::get_builder(){
|
|
|
builder->get_widget("chbLoadVariantSelectionTimer", chbLoadVariantSelectionTimer);
|
|
|
builder->get_widget("chbLastSelectionWillBecome", chbLastSelectionWillBecome);
|
|
|
|
|
|
|
|
|
builder->get_widget("lblInfoCommand", lblInfoCommand);
|
|
|
builder->get_widget("lblInfoCommand1", lblInfoCommand1);
|
|
|
builder->get_widget("lblInfoCommand2", lblInfoCommand2);
|
|
|
builder->get_widget("lblInfoDefaultDonw", lblInfoDefaultDonw);
|
|
|
builder->get_widget("lblInfoSeconds", lblInfoSeconds);
|
|
|
builder->get_widget("lblLoadMenu", lblLoadMenu);
|
|
|
builder->get_widget("lblInfoInputTerminal", lblInfoInputTerminal);
|
|
|
builder->get_widget("lblInfoOutputTerminal", lblInfoOutputTerminal);
|
|
|
builder->get_widget("lblInfoSeconds", lblInfoSeconds);
|
|
|
builder->get_widget("lblHeaderName", lblHeaderName);
|
|
|
builder->get_widget("lblInfoHead", lblInfoHead);
|
|
|
|
|
|
builder->get_widget("spbSecond", spbSecond);
|
|
|
builder->get_widget("entryKernel", entryKernel);
|
|
|
builder->get_widget("entryIPT", entryIPT);
|
|
|
builder->get_widget("entryOTT", entryOTT);
|
|
|
|
|
|
builder->get_widget("boxColor", boxColor);
|
|
|
builder->get_widget("boxWidgetAll", boxWidgetAll);
|
|
|
|
|
|
builder->get_widget("aboutWindows", aboutWindows);
|
|
|
builder->get_widget("btnSynopsis", btnSynopsis);
|
|
|
builder->get_widget("btnAbout", btnAbout);
|
|
|
builder->get_widget("btnLoadLocal", btnLoadLocal);
|
|
|
builder->get_widget("btnLoadGlob", btnLoadGlob);
|
|
|
builder->get_widget("btnSaveLocalGlob", btnSaveLocalGlob);
|
|
|
builder->get_widget("btnSaveLocal", btnSaveLocal);
|
|
|
builder->get_widget("btnSaveGlob", btnSaveGlob);
|
|
|
builder->get_widget("btnSettings", btnSettings);
|
|
|
builder->get_widget("btnLoad", btnLoad);
|
|
|
builder->get_widget("btnSave", btnSave);
|
|
|
builder->get_widget("boxButton", boxButton);
|
|
|
builder->get_widget("boxSave", boxSave);
|
|
|
builder->get_widget("boxInfoError", boxInfoError);
|
|
|
builder->get_widget("lblWarning", lblWarning);
|
|
|
builder->get_widget("imgInfo", imgInfo);
|
|
|
builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog);
|
|
|
builder->get_widget("treeViewKernel", treeViewKernel);
|
|
|
builder->get_widget("treeViewOTT", treeViewOTT);
|
|
|
builder->get_widget("treeViewIPT", treeViewIPT);
|
|
|
builder->get_widget("imgBG", imgBG);
|
|
|
builder->get_widget("overHead", overHead);
|
|
|
}
|
|
|
|
|
|
void MainWindow::localization(){
|
|
|
time_t now = time(0);
|
|
|
tm *ltm = localtime(&now);
|
|
|
unsigned int year = 1900+ ltm->tm_year;
|
|
|
string str_authors = string(_("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
|
|
|
aboutWindows->set_copyright(str_authors);
|
|
|
aboutWindows->set_comments(_("ubl-settings-bootloader"));
|
|
|
aboutWindows->set_website(_("https://wiki.ublinux.com"));
|
|
|
aboutWindows->set_version(_(version_application.c_str()));
|
|
|
aboutWindows->set_website_label(_("Project Home Page"));
|
|
|
lblInfoHead->set_text(_("Configuring system boot parameters"));
|
|
|
lblHeaderName->set_text(_("ubl-settings-bootloader"));
|
|
|
aboutWindows->set_comments(_("Setting bootloader"));
|
|
|
aboutWindows->set_website_label(_("Project Home Page"));
|
|
|
lblInfoCommand->set_text(_("Command line parameters:"));
|
|
|
lblInfoCommand1->set_text(_("Command line parameters:"));
|
|
|
lblInfoCommand2->set_text(_("Command line parameters:"));
|
|
|
lblInfoDefaultDonw->set_text(_("Default download"));
|
|
|
lblInfoSeconds->set_text(_("Seconds"));
|
|
|
lblLoadMenu->set_text(_("Download menu"));
|
|
|
lblInfoInputTerminal->set_text(_("Input terminal"));
|
|
|
lblInfoOutputTerminal->set_text(_("Output terminal"));
|
|
|
|
|
|
chbLoadVariantSelectionTimer->set_label(_("Load variant selection timer"));
|
|
|
chbLastSelectionWillBecome->set_label(_("The last selection will become the default boot choice"));
|
|
|
btnSynopsis->set_label(_("Help"));
|
|
|
btnAbout->set_label(_("About"));
|
|
|
btnSaveLocalGlob->set_label(_("Save to global and local configuration"));
|
|
|
btnSaveLocal->set_label(_("Save local configuration"));
|
|
|
btnSaveGlob->set_label(_("Save global configuration"));
|
|
|
btnLoadGlob->set_label(_("Load global configuration"));
|
|
|
btnLoadLocal->set_label(_("Load local configuration"));
|
|
|
btnSave->set_label(_("Save"));
|
|
|
btnLoad->set_label(_("Load"));
|
|
|
this->set_title(_("ubl-settings-bootloader"));
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MainWindow::event(){
|
|
|
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
|
|
|
btnAbout->signal_activate().connect([&]() {aboutWindows->show();});
|
|
|
btnLoadLocal->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_local_cfg));
|
|
|
btnLoadGlob->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::download_globl_cfg));
|
|
|
btnSaveLocalGlob->signal_activate().connect([&]() {save_global_local_cfg();});
|
|
|
btnSaveLocal->signal_activate().connect([&]() {save_local_cfg();});
|
|
|
btnSaveGlob->signal_activate().connect([&]() {save_global_cfg();});
|
|
|
//TreeView_TreeSelection = treeViewKernel->get_selection();
|
|
|
//TreeView_TreeSelection->signal_changed().connect(sigc::mem_fun(treeViewKernel, &MainWindow::item_selected) );
|
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewKernelModel = treeViewKernel->get_model();
|
|
|
treeViewKernelModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_kernel));
|
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewIPTModel = treeViewIPT->get_model();
|
|
|
treeViewIPTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_IPT));
|
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewOTTModel = treeViewOTT->get_model();
|
|
|
treeViewOTTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_OTT));
|
|
|
}
|
|
|
|
|
|
void MainWindow::save_global_local_cfg() {
|
|
|
if (flag_save_global == false) {
|
|
|
flag_save_all = true;
|
|
|
}
|
|
|
else if (flag_save_local == false) {
|
|
|
flag_save_all = true;
|
|
|
}
|
|
|
else{
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
}
|
|
|
|
|
|
info_warning_error(4);
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::save_global_cfg() {
|
|
|
if (flag_save_global == false) {
|
|
|
flag_save_global = true;
|
|
|
}
|
|
|
else{
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
}
|
|
|
info_warning_error(3);
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::save_local_cfg() {
|
|
|
if (flag_save_local == false) {
|
|
|
flag_save_local = true;
|
|
|
}
|
|
|
else{
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
lblWarning->set_text(gettext("Nothing to save!"));
|
|
|
}
|
|
|
|
|
|
info_warning_error(2);
|
|
|
|
|
|
}
|
|
|
|
|
|
void MainWindow::download_globl_cfg() {
|
|
|
entryKernel->set_text("");
|
|
|
entryOTT->set_text("");
|
|
|
entryIPT->set_text("");
|
|
|
|
|
|
flag_save_local = true;
|
|
|
flag_save_global = true;
|
|
|
flag_save_all = true;
|
|
|
flag_load = true;
|
|
|
info_warning_error(1);
|
|
|
}
|
|
|
|
|
|
void MainWindow::download_local_cfg() {
|
|
|
entryKernel->set_text("");
|
|
|
entryOTT->set_text("");
|
|
|
entryIPT->set_text("");
|
|
|
flag_load = false;
|
|
|
flag_save_local = true;
|
|
|
flag_save_global = true;
|
|
|
flag_save_all = true;
|
|
|
info_warning_error(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
void MainWindow::synopsis_show() {
|
|
|
string cmd = "xdg-open " + string(_("https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/")) + app_name;
|
|
|
wrapper_system(cmd, "&");
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void MainWindow::info_status_app(string stule) {
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxInfo = boxInfoError->get_style_context();
|
|
|
boxInfo->remove_class("boxInfoMessOK");
|
|
|
boxInfo->remove_class("boxInfoMessError");
|
|
|
boxInfo->add_class(stule);
|
|
|
}
|
|
|
|
|
|
void MainWindow::info_warning_error(int mess) {
|
|
|
if (index_error > 0) {
|
|
|
info_status_app("boxInfoMessError");
|
|
|
imgInfo->set("/usr/share/icons/hicolor/scalable/status/ru.ublinux.ubl-settings-bootloader.warning.svg");
|
|
|
index_error = 0;
|
|
|
string mess_error = "";
|
|
|
if (mess == 0) {
|
|
|
mess_error = string(_("Local configuration reading error")) + str_cmd_error;
|
|
|
lblWarning->set_text(mess_error);
|
|
|
}
|
|
|
else if (mess == 1) {
|
|
|
mess_error = string(_("Global configuration read error")) + str_cmd_error;
|
|
|
lblWarning->set_text(mess_error);
|
|
|
}
|
|
|
else if (mess == 2) {
|
|
|
mess_error = string(_("Local configuration write error")) + str_cmd_error;
|
|
|
lblWarning->set_text(mess_error);
|
|
|
}
|
|
|
else if (mess == 3) {
|
|
|
mess_error = string(_("Global configuration write error")) + str_cmd_error;
|
|
|
lblWarning->set_text(mess_error);
|
|
|
}
|
|
|
else if (mess == 4) {
|
|
|
mess_error = string(_("Error saved local and global configuration")) + str_cmd_error;
|
|
|
lblWarning->set_text(mess_error);
|
|
|
}
|
|
|
str_cmd_error = "";
|
|
|
}
|
|
|
else {
|
|
|
info_status_app("boxInfoMessOK");
|
|
|
imgInfo->set("/usr/share/icons/hicolor/scalable/status/ru.ublinux.ubl-settings-bootloader.checked.svg");
|
|
|
if (mess == 0) {
|
|
|
lblWarning->set_text(_("Local configuration downloaded successfully"));
|
|
|
}
|
|
|
else if (mess == 1) {
|
|
|
lblWarning->set_text(_("Global configuration downloaded successfully"));
|
|
|
}
|
|
|
else if (mess == 2) {
|
|
|
lblWarning->set_text(_("Local configuration successfully written"));
|
|
|
}
|
|
|
else if (mess == 3) {
|
|
|
lblWarning->set_text(_("Global configuration successfully written"));
|
|
|
}
|
|
|
else if (mess == 4) {
|
|
|
lblWarning->set_text(_("Successfully saved local and global configuration"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
struct MainWindow::Result<string> MainWindow::wrapper_call(string cmd) {
|
|
|
struct Result<string> obj_result;
|
|
|
string response = 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;
|
|
|
}
|
|
|
|
|
|
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(){
|
|
|
chbintelMax4->set_active(false);
|
|
|
}
|
|
|
|
|
|
void MainWindow::fn_event_intelMax4(){
|
|
|
chbintelMax1->set_active(false);
|
|
|
}
|
|
|
|
|
|
void MainWindow::add_CSS(){
|
|
|
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
|
|
|
cssProvider->load_from_path(path_css);
|
|
|
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
|
|
|
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen
|
|
|
styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application
|
|
|
Glib::RefPtr<Gtk::StyleContext> lblInfoHead_css = lblInfoHead->get_style_context();
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context();
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context();
|
|
|
imgBG->set(path_img_head_background);
|
|
|
if (socket_trd_id_I == 0 && socket_ext_id_I == 0){
|
|
|
boxButton_css->add_class("bkim_no_plug");
|
|
|
boxSave_css->add_class("bkim_no_plug");
|
|
|
}
|
|
|
lblInfoHead_css->add_class("textHead");
|
|
|
}
|
|
|
|
|
|
void help() {
|
|
|
string version = string(gettext("ubl-settings-datetime version: ")) + version_application + "\n";
|
|
|
cout << version.c_str();
|
|
|
string help;
|
|
|
help = "GTK settings bootloader for UBLinux\n\n"
|
|
|
"Usage: ubl-settings-bootloader [OPTIONS...]\n"
|
|
|
"Options:\n"
|
|
|
" -h, --help Show this help\n"
|
|
|
" -V, --version Show package version\n";
|
|
|
cout << gettext(help.c_str());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|