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.
1557 lines
60 KiB
1557 lines
60 KiB
|
|
#include "ubl-settings-bootloader.h"
|
|
using namespace std;
|
|
|
|
int socket_ext_id_I = 0;
|
|
int socket_trd_id_I = 0;
|
|
bool flag_save = false;
|
|
bool flag_save_local = false;
|
|
bool flag_save_global = false;
|
|
bool flag_load_global = false;
|
|
bool flag_lock_help = false;
|
|
string version_application = "2.2";
|
|
|
|
MainWindow* obj_main;
|
|
void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) {
|
|
if (self && user_data) {}
|
|
obj_main->global_lick_doc = link;
|
|
obj_main->aboutWindows->hide();
|
|
obj_main->temp_help_show();
|
|
}
|
|
|
|
CmdArgParser::CmdArgParser(const string& p_name, const string& p_description, const 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);
|
|
wnd->settings();
|
|
wnd->set_plug(plugBox);
|
|
wnd->event();
|
|
plugBox->get_parent()->remove(*plugBox);
|
|
add(*plugBox);
|
|
show_all_children();
|
|
}
|
|
|
|
int MainWindow::check_root() {
|
|
if (geteuid() != 0) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// =================================================================
|
|
View_edit_add_table::View_edit_add_table() {
|
|
builder = Gtk::Builder::create_from_file(path_glade);
|
|
this->settings();
|
|
}
|
|
|
|
void View_edit_add_table::settings() {
|
|
this->get_builder();
|
|
this->localization();
|
|
this->event();
|
|
|
|
}
|
|
|
|
void View_edit_add_table::event() {
|
|
btnCancel->signal_clicked().connect([&]() {cancel();});
|
|
btnSaveEditSave->signal_clicked().connect([&]() {save();});
|
|
wndAddEditData->signal_hide().connect([&]() {this->get_data();});
|
|
entryCol1->signal_changed().connect([&]() {this->check_space_entry();});
|
|
entryCol2->signal_changed().connect([&]() {this->check_space_entry();});
|
|
}
|
|
|
|
void View_edit_add_table::check_space_entry() {
|
|
if (entryCol1->get_text().length() == 0 || entryCol2->get_text().length() == 0) {
|
|
btnSaveEditSave->set_sensitive(false);
|
|
}
|
|
else {
|
|
btnSaveEditSave->set_sensitive(true);
|
|
}
|
|
}
|
|
|
|
void View_edit_add_table::localization() {
|
|
|
|
}
|
|
void View_edit_add_table::get_builder() {
|
|
builder->get_widget("wndAddEditData", wndAddEditData);
|
|
builder->get_widget("btnCancel", btnCancel);
|
|
builder->get_widget("btnSaveEditSave", btnSaveEditSave);
|
|
builder->get_widget("chkAddEdit", chkAddEdit);
|
|
builder->get_widget("entryCol1", entryCol1);
|
|
builder->get_widget("entryCol2", entryCol2);
|
|
builder->get_widget("lblAddEditCheckBox", lblAddEditCheckBox);
|
|
builder->get_widget("lblAddEditCol1", lblAddEditCol1);
|
|
builder->get_widget("lblAddEditCol2", lblAddEditCol2);
|
|
builder->get_widget("lblEditAddHead", lblEditAddHead);
|
|
|
|
}
|
|
|
|
|
|
void View_edit_add_table::cancel() {
|
|
wndAddEditData->hide();
|
|
flag_save = false;
|
|
}
|
|
|
|
void View_edit_add_table::save() {
|
|
flag_save = true;
|
|
new_data.check = chkAddEdit->get_active();
|
|
new_data.column1 = entryCol1->get_text();
|
|
new_data.column2 = entryCol2->get_text();
|
|
wndAddEditData->hide();
|
|
}
|
|
struct View_edit_add_table::struct_data View_edit_add_table::get_data() {
|
|
if (flag_save == true) {
|
|
if (mode_show == "ue" && new_data.column1.length() != 0 && new_data.column2.length() != 0) {
|
|
obj_main->wrapper_edit_user(new_data.check, new_data.column1, new_data.column2);
|
|
}
|
|
else if (mode_show == "me" && new_data.column1.length() != 0 && new_data.column2.length() != 0) {
|
|
obj_main->wrapper_edit_melody(new_data.check, new_data.column1, new_data.column2);
|
|
}
|
|
else if (mode_show == "ua" && new_data.column1.length() != 0 && new_data.column2.length() != 0) {
|
|
obj_main->wrapper_set_add_data_user(new_data.check, new_data.column1, new_data.column2);
|
|
}
|
|
else if (mode_show == "ma" && new_data.column1.length() != 0 && new_data.column2.length() != 0) {
|
|
obj_main->wrapper_set_add_data_melody(new_data.check, new_data.column1, new_data.column2);
|
|
}
|
|
return new_data;
|
|
}
|
|
if (mode_show == "ue" && old_data.column1.length() != 0 && old_data.column2.length() != 0) {
|
|
obj_main->wrapper_edit_user(old_data.check, old_data.column1, old_data.column2);
|
|
}
|
|
else if (mode_show == "me" && old_data.column1.length() != 0 && old_data.column2.length() != 0) {
|
|
obj_main->wrapper_edit_melody(old_data.check, old_data.column1, old_data.column2);
|
|
}
|
|
else if (mode_show == "ua" && old_data.column1.length() != 0 && old_data.column2.length() != 0){
|
|
obj_main->wrapper_set_add_data_user(old_data.check, old_data.column1, old_data.column2);
|
|
}
|
|
else if (mode_show == "ma" && old_data.column1.length() != 0 && old_data.column2.length() != 0) {
|
|
obj_main->wrapper_set_add_data_melody(old_data.check, old_data.column1, old_data.column2);
|
|
}
|
|
return old_data;
|
|
}
|
|
void View_edit_add_table::show() {
|
|
flag_save = false;
|
|
wndAddEditData->show();
|
|
}
|
|
|
|
void View_edit_add_table::set_data(bool check, string column1, string column2) {
|
|
old_data.check = check;
|
|
old_data.column1 = column1;
|
|
old_data.column2 = column2;
|
|
chkAddEdit->set_active(check);
|
|
entryCol1->set_text(column1);
|
|
entryCol2->set_text(column2);
|
|
}
|
|
|
|
void View_edit_add_table::show_melody_edit() {
|
|
lblAddEditCheckBox->set_text(string(str_active) + ":");
|
|
lblAddEditCol1->set_text(string(str_option) + ":");
|
|
lblAddEditCol2->set_text(string(str_melody_code) + ":");
|
|
string title = string(str_ringtone_at_startup) + " - " + string(str_edit);
|
|
lblEditAddHead->set_text(title);
|
|
mode_show = "me";
|
|
this->show();
|
|
}
|
|
|
|
void View_edit_add_table::show_melody_add() {
|
|
btnSaveEditSave->set_sensitive(false);
|
|
chkAddEdit->set_active(false);
|
|
entryCol1->set_text("");
|
|
entryCol2->set_text("");
|
|
lblAddEditCheckBox->set_text(string(str_active) + ":");
|
|
lblAddEditCol1->set_text(string(str_option) + ":");
|
|
lblAddEditCol2->set_text(string(str_melody_code) + ":");
|
|
string title = string(str_ringtone_at_startup) + " - " + string(str_adding);
|
|
lblEditAddHead->set_text(title);
|
|
mode_show = "ma";
|
|
btnSaveEditSave->set_sensitive(false);
|
|
this->show();
|
|
}
|
|
void View_edit_add_table::show_user_edit() {
|
|
lblAddEditCheckBox->set_text(string(str_administrator) + ":");
|
|
lblAddEditCol1->set_text(string(str_user) + ":");
|
|
lblAddEditCol2->set_text(string(str_password) + ":");
|
|
string title = string(str_title_Boot_Menu_Users) + " - " + string(str_edit);
|
|
lblEditAddHead->set_text(title);
|
|
mode_show = "ue";
|
|
this->show();
|
|
}
|
|
|
|
void View_edit_add_table::show_user_add() {
|
|
btnSaveEditSave->set_sensitive(false);
|
|
chkAddEdit->set_active(false);
|
|
entryCol1->set_text("");
|
|
entryCol2->set_text("");
|
|
lblAddEditCheckBox->set_text(string(str_administrator) + ":");
|
|
lblAddEditCol1->set_text(string(str_user) + ":");
|
|
lblAddEditCol2->set_text(string(str_password) + ":");
|
|
string title = string(str_title_Boot_Menu_Users) + " - " + string(str_adding);
|
|
lblEditAddHead->set_text(title);
|
|
btnSaveEditSave->set_sensitive(false);
|
|
this->show();
|
|
mode_show = "ua";
|
|
}
|
|
// =================================================================
|
|
|
|
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
|
|
: Gtk::ApplicationWindow(obj), builder{builder} {
|
|
this->builder = builder;
|
|
}
|
|
|
|
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
this->builder = builder;
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::settings() {
|
|
obj_main = this;
|
|
map_cmd_error[""] = "";
|
|
vec_param_names.push_back("GRUB_TIMEOUT");
|
|
vec_param_names.push_back("GRUB_CMDLINE_LINUX");
|
|
vec_param_names.push_back("GRUB_TERMINAL_INPUT");
|
|
vec_param_names.push_back("GRUB_TERMINAL_OUTPUT");
|
|
vec_param_names.push_back("GRUB_BOOT_SILENT");
|
|
vec_param_names.push_back("GRUB_PASSWORD");
|
|
vec_param_names.push_back("GRUB_DEFAULT");
|
|
vec_param_names.push_back("GRUB_PLAY");
|
|
vec_param_names.push_back("GRUB_SUPERUSERS");
|
|
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);
|
|
|
|
#ifdef WEBKIT_FOUND
|
|
one = WEBKIT_WEB_VIEW(webkit_web_view_new());
|
|
three = Glib::wrap(GTK_WIDGET(one));
|
|
wndWeb->add(*three);
|
|
#endif
|
|
this->flag_block_gui();
|
|
if (this->check_root() == 0) {
|
|
spbSecond->set_range(1, 60);
|
|
spbSecond->set_increments(1.0, 1.0);
|
|
spbSecond->set_value(1);
|
|
this->fill_in_view();
|
|
this->set_active_boot_second();
|
|
this->str_last_launched_os = this->pars_last_launched_os();
|
|
vector<string> os_control_list;
|
|
this->pars_os(os_control_list);
|
|
this->download_local_cfg();
|
|
this->download_globl_cfg();
|
|
vector<tuple<string, vector<string>>> vec_list_os = format_os_list(os_control_list);
|
|
obj_menu_os.set_builder(builder, path_glade);
|
|
obj_menu_os.set_map(vec_list_os);
|
|
obj_menu_os.set_entry(entrListOS);
|
|
// obj_menu_os.set_last_launched_os(map_global_cmd_selection["GRUB_DEFAULT"]);
|
|
obj_menu_os.set_last_launched_os(this->str_last_launched_os);
|
|
obj_menu_os.init();
|
|
obj_menu_os.event();
|
|
}
|
|
else{
|
|
boxWidgetAll->set_sensitive(false);
|
|
btnLoad->set_sensitive(false);
|
|
btnSave->set_sensitive(false);
|
|
imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
|
|
info_status_app(info_box_error_css);
|
|
lblWarning->set_text(program_as_root);
|
|
this->set_active_boot_second();
|
|
this->fill_in_view();
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_plug(Gtk::Widget *plug) {
|
|
this->plug = plug;
|
|
}
|
|
|
|
vector<tuple<string, vector<string>>> MainWindow::format_os_list(vector<string> &os_control_list) {
|
|
vector<tuple<string, vector<string>>> vec_list_os;
|
|
set<string> set_key;
|
|
for (string& name_os : os_control_list) {
|
|
if (name_os.find(">") != string::npos) {
|
|
set_key.insert(name_os.substr(0,name_os.find(">")+1));
|
|
}
|
|
else {
|
|
vector<string> vec_os;
|
|
tuple<string, vector<string>> t1(name_os, vec_os);
|
|
vec_list_os.push_back(t1);
|
|
}
|
|
}
|
|
set<string>::iterator it = set_key.begin();
|
|
for (int index = 1; it != set_key.end(); index++, it++) {
|
|
bool flag = false;
|
|
string name_os_buff = "";
|
|
vector<string> vec_os_values;
|
|
for (string& name_os : os_control_list) {
|
|
if (name_os.find(*it) != string::npos) {
|
|
flag = true;
|
|
vec_os_values.push_back(name_os.substr(name_os.find(">")+1, name_os.length() - 1));
|
|
name_os_buff = *it;
|
|
}
|
|
}
|
|
if (flag) {
|
|
tuple<string, vector<string>> t1(name_os_buff, vec_os_values);
|
|
vec_list_os.push_back(t1);
|
|
}
|
|
}
|
|
return vec_list_os;
|
|
}
|
|
|
|
vector<string> MainWindow::pars_os(vector<string> &os_control_list) {
|
|
string str_list_os = obj_process_call.call_all_sections(cmd_pars_list_os);
|
|
os_control_list = Utils::split(str_list_os, '\n');
|
|
return os_control_list;
|
|
}
|
|
string MainWindow::pars_last_launched_os() {
|
|
string str_list_os = obj_process_call.call_all_sections(cmd_last_launched_os);
|
|
Utils::str_replace_all(str_list_os, "\n" , "");
|
|
return str_list_os;
|
|
}
|
|
|
|
void MainWindow::flag_block_gui() {
|
|
if (flag_load_global == true) {
|
|
btnLoadGlob->set_sensitive(false);
|
|
}
|
|
if (flag_save_local == true && flag_save_global == true) {
|
|
btnSave->set_sensitive(false);
|
|
}
|
|
if (flag_save == true) {
|
|
btnSave->set_sensitive(false);
|
|
}
|
|
if (flag_save_local == true) {
|
|
btnSaveLocal->set_sensitive(false);
|
|
btnSaveLocalGlob->set_sensitive(false);
|
|
}
|
|
if (flag_save_global == true) {
|
|
btnSaveGlob->set_sensitive(false);
|
|
btnSaveLocalGlob->set_sensitive(false);
|
|
}
|
|
if (flag_lock_help == true) {
|
|
btnHelp->set_sensitive(false);
|
|
}
|
|
}
|
|
|
|
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);
|
|
vec_Option_kernel = this->read_file_and_view(kernel_csv, row_kernel, list_store_kernel);
|
|
vec_Option_IPT = this->read_file_and_view(IPT_csv, row_IPT, list_store_IPT);
|
|
vec_Option_OTT = this->read_file_and_view(OTT_csv, row_OTT, list_store_OTT);
|
|
size_kernel = vec_Option_kernel.size();
|
|
size_IPT = vec_Option_IPT.size();
|
|
size_OTT = vec_Option_OTT.size();
|
|
this->view_add_colums(*treeViewKernel);
|
|
this->view_add_colums(*treeViewIPT);
|
|
this->view_add_colums(*treeViewOTT);
|
|
}
|
|
|
|
void MainWindow::view_add_colums_user(Gtk::TreeView &treeView) {
|
|
treeView.append_column_editable(str_administrator, m_columns_user.check_button);
|
|
treeView.append_column(str_user, m_columns_user.name);
|
|
treeView.append_column(str_password, m_columns_user.password);
|
|
}
|
|
|
|
void MainWindow::view_add_colums_melody(Gtk::TreeView &treeView) {
|
|
treeView.append_column_editable(str_active, m_columns_melody.check_button);
|
|
treeView.append_column(str_option, m_columns_melody.title);
|
|
treeView.append_column(str_melody_code, m_columns_melody.melody_code);
|
|
}
|
|
|
|
void MainWindow::item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
|
|
treeViewIPT->get_selection()->unselect_all();
|
|
treeViewOTT->get_selection()->unselect_all();
|
|
treeViewUser->get_selection()->unselect_all();
|
|
treeViewMelody->get_selection()->unselect_all();
|
|
if (flag_blocked_tree_view == false) {
|
|
if (this->intel_idle_cstate_check(size_kernel, list_store_kernel, "GRUB_CMDLINE_LINUX") == false) {
|
|
string str_flags = template_item_selected(size_kernel, list_store_kernel, "GRUB_CMDLINE_LINUX");
|
|
map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
|
|
// Utils::str_replace_all(str_flags, " ", ", ");
|
|
entryKernel->set_text(str_flags);
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
|
|
treeViewIPT->get_selection()->unselect_all();
|
|
treeViewKernel->get_selection()->unselect_all();
|
|
treeViewUser->get_selection()->unselect_all();
|
|
treeViewMelody->get_selection()->unselect_all();
|
|
if (flag_blocked_tree_view == false) {
|
|
if (this->intel_idle_cstate_check(size_OTT, list_store_OTT, "GRUB_TERMINAL_OUTPUT") == false) {
|
|
string str_flags = template_item_selected(size_OTT, list_store_OTT, "GRUB_TERMINAL_OUTPUT");
|
|
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
|
|
// Utils::str_replace_all(str_flags, " ", ", ");
|
|
entryOTT->set_text(str_flags);
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
|
|
treeViewKernel->get_selection()->unselect_all();
|
|
treeViewOTT->get_selection()->unselect_all();
|
|
treeViewUser->get_selection()->unselect_all();
|
|
treeViewMelody->get_selection()->unselect_all();
|
|
if (flag_blocked_tree_view == false) {
|
|
if (this->intel_idle_cstate_check(size_IPT, list_store_IPT, "GRUB_TERMINAL_INPUT") == false) {
|
|
string str_flags = template_item_selected(size_IPT, list_store_IPT, "GRUB_TERMINAL_INPUT");
|
|
map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
|
|
// Utils::str_replace_all(str_flags, " ", ", ");
|
|
entryIPT->set_text(str_flags);
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::get_download_mode(std::map <string, string> &map_temp) {
|
|
std::map <string, string>:: iterator iter_map_data;
|
|
iter_map_data = map_temp.find("GRUB_BOOT_SILENT");
|
|
if (iter_map_data != map_temp.end()) {
|
|
string value = iter_map_data->second;
|
|
if (value.length() != 0) {
|
|
Utils::str_replace_all(value, "\"","");
|
|
if (value == "splash") {
|
|
cmbDownloadMode->set_active(0);
|
|
}
|
|
else if (value == "splash quiet ub.silent") {
|
|
cmbDownloadMode->set_active(1);
|
|
}
|
|
else if (value == "quiet ub.silent") {
|
|
cmbDownloadMode->set_active(2);
|
|
}
|
|
else if (value == "plymouth.enable=0") {
|
|
cmbDownloadMode->set_active(3);
|
|
}
|
|
else{
|
|
cmbDownloadMode->set_active(-1);
|
|
}
|
|
}
|
|
else {
|
|
cmbDownloadMode->set_active(-1);
|
|
}
|
|
}
|
|
else {
|
|
cmbDownloadMode->set_active(-1);
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_download_mode() {
|
|
int index = cmbDownloadMode->get_active_row_number();
|
|
string key = "";
|
|
if (index == 0) {
|
|
key = "splash";
|
|
}
|
|
else if (index == 1) {
|
|
key = "splash quiet ub.silent";
|
|
}
|
|
else if (index == 2) {
|
|
key = "quiet ub.silent";
|
|
}
|
|
else if (index == 3) {
|
|
key = "plymouth.enable=0";
|
|
}
|
|
else{
|
|
return;
|
|
}
|
|
map_cmd_selection["GRUB_BOOT_SILENT"] = key;
|
|
}
|
|
|
|
bool MainWindow::intel_idle_cstate_check(int size, Glib::RefPtr<Gtk::ListStore> &list_store, string key) {
|
|
string cmds_old = map_cmd_selection[key];
|
|
string cmds = "";
|
|
string param = "";
|
|
int index_1 = -1;
|
|
int index_4 = -1;
|
|
bool active = false;
|
|
for (int index = 0; index < size; index++) {
|
|
Gtk::TreeModel::Row row = list_store->children()[index];
|
|
if(row) {
|
|
param = row[m_columns.name] + "";
|
|
active = row[m_columns.check_button];
|
|
if (param == "intel_idle.max_cstate=1" && active == true) {
|
|
index_1 = index;
|
|
}
|
|
else if (param == "intel_idle.max_cstate=4" && active == true) {
|
|
index_4 = index;
|
|
}
|
|
}
|
|
}
|
|
if (index_1 != -1 && index_4 != -1) {
|
|
if (cmds_old.find("intel_idle.max_cstate=1") == string::npos) {
|
|
Gtk::TreeModel::Row row = list_store->children()[index_4];
|
|
row[m_columns.check_button] = false;
|
|
return true;
|
|
}
|
|
else if (cmds_old.find("intel_idle.max_cstate=4") == string::npos) {
|
|
Gtk::TreeModel::Row row = list_store->children()[index_1];
|
|
row[m_columns.check_button] = false;
|
|
return true;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
string MainWindow::template_item_selected(int size, Glib::RefPtr<Gtk::ListStore> &list_store, string key) {
|
|
string cmds_old = map_cmd_selection[key];
|
|
string cmds = "";
|
|
string param = "";
|
|
vector<string> vec_param = Utils::split(cmds_old, ' ');
|
|
for (int index = 0; index < size; index++) {
|
|
Gtk::TreeModel::Row row = list_store->children()[index];
|
|
if(row) {
|
|
param = row[m_columns.name] + "";
|
|
if (row[m_columns.check_button] == true) {
|
|
cmds += param + " ";
|
|
}
|
|
for (size_t i = 0; i < vec_param.size(); i++) {
|
|
if (param == vec_param[i]) {
|
|
vec_param.erase(vec_param.begin() + i);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (size_t i = 0; i < vec_param.size(); i++) {
|
|
cmds += vec_param[i] + " ";
|
|
}
|
|
if (cmds.length() > 1) {
|
|
if (cmds[cmds.length()-1] == ' ') {
|
|
cmds = cmds.substr(0, cmds.length() - 1);
|
|
}
|
|
}
|
|
return cmds;
|
|
}
|
|
|
|
|
|
vector<string> MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m) {
|
|
std::array<std::vector<string>, 5> arr_view = Utils::read_csv(string(path_resources) + "/" + file_name);
|
|
std::vector<string> vec_Option = arr_view[0];
|
|
for (size_t index = 0; index < vec_Option.size(); index++) {
|
|
|
|
this->view_add_cell(row, list_store_m , arr_view, index);
|
|
}
|
|
return vec_Option;
|
|
}
|
|
|
|
void MainWindow::view_add_colums(Gtk::TreeView &treeView) {
|
|
treeView.append_column_editable(str_active, m_columns.check_button);
|
|
treeView.append_column(str_option, m_columns.name);
|
|
treeView.append_column(str_description, m_columns.description);
|
|
}
|
|
|
|
void MainWindow::view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr<Gtk::ListStore> list_store_m , std::array<std::vector<string>, 5> &arr_view , size_t index) {
|
|
row = *(list_store_m->append());
|
|
bool flag_chb = false;
|
|
string name = arr_view[0][index];
|
|
row[m_columns.check_button] = flag_chb;
|
|
row[m_columns.name] = _(name.c_str());
|
|
row[m_columns.description] = _(arr_view[1][index].c_str());
|
|
}
|
|
|
|
void MainWindow::get_builder() {
|
|
builder->get_widget("lblHeaderAboutTopic", lblHeaderAboutTopic);
|
|
builder->get_widget("chbLoadVariantSelectionTimer", chbLoadVariantSelectionTimer);
|
|
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("btnHelp", btnHelp);
|
|
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);
|
|
builder->get_widget("lblDownloadMode", lblDownloadMode);
|
|
builder->get_widget("cmbDownloadMode", cmbDownloadMode);
|
|
#ifdef WEBKIT_FOUND
|
|
builder->get_widget("wndWeb", wndWeb);
|
|
#endif
|
|
builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb);
|
|
builder->get_widget("lblwebHeaderName", lblwebHeaderName);
|
|
builder->get_widget("lblhelpText", lblhelpText);
|
|
builder->get_widget("lblhelpHeader", lblhelpHeader);
|
|
builder->get_widget("chkAlwaysOpenHelp", chkAlwaysOpenHelp);
|
|
builder->get_widget("btnReadHelp", btnReadHelp);
|
|
builder->get_widget("btnCancelHelp", btnCancelHelp);
|
|
builder->get_widget("wndShowWeb", wndShowWeb);
|
|
builder->get_widget("btnOpenMenuOS", btnOpenMenuOS);
|
|
builder->get_widget("entrListOS", entrListOS);
|
|
builder->get_widget("treeViewUser", treeViewUser);
|
|
builder->get_widget("treeViewMelody", treeViewMelody);
|
|
builder->get_widget("lblBootMenuUsers", lblBootMenuUsers);
|
|
builder->get_widget("lblRingtoneStartup", lblRingtoneStartup);
|
|
builder->get_widget("btnAddUser", btnAddUser);
|
|
builder->get_widget("btnRemoveUser", btnRemoveUser);
|
|
builder->get_widget("btnAddMusic", btnAddMusic);
|
|
builder->get_widget("btnRemoveMusic", btnRemoveMusic);
|
|
builder->get_widget("btnEditMusic", btnEditMusic);
|
|
builder->get_widget("btnEditUser", btnEditUser);
|
|
|
|
|
|
}
|
|
|
|
void MainWindow::localization() {
|
|
time_t now = time(0);
|
|
tm *ltm = localtime(&now);
|
|
unsigned int year = 1900+ ltm->tm_year;
|
|
string str_authors = string(copyright) + to_string(year);
|
|
aboutWindows->set_program_name(app_name);
|
|
aboutWindows->set_copyright(str_authors);
|
|
aboutWindows->set_comments(name_app);
|
|
aboutWindows->set_website(web_url);
|
|
aboutWindows->set_version(_(version_application.c_str()));
|
|
aboutWindows->set_website_label(project_Home_page);
|
|
lblInfoHead->set_text(name_app);
|
|
lblHeaderName->set_text(name_app);
|
|
lblHeaderAboutTopic->set_label(str_about);
|
|
lblBootMenuUsers->set_text(str_title_Boot_Menu_Users);
|
|
lblRingtoneStartup->set_text(str_title_Ringtone_Startup);
|
|
lblInfoCommand->set_text(command_line_parameters);
|
|
lblInfoCommand1->set_text(command_line_parameters);
|
|
lblInfoCommand2->set_text(command_line_parameters);
|
|
lblInfoDefaultDonw->set_text(load_default);
|
|
lblInfoSeconds->set_text(seconds);
|
|
lblLoadMenu->set_text(download_menu);
|
|
lblInfoInputTerminal->set_text(terminal_for_input);
|
|
lblInfoOutputTerminal->set_text(terminal_for_output);
|
|
chbLoadVariantSelectionTimer->set_label(boot_selection_menu_timer);
|
|
btnHelp->set_label(str_help);
|
|
btnAbout->set_label(str_about_1);
|
|
lblHeadeWndWeb->set_text(name_app);
|
|
btnSaveLocalGlob->set_label(save_all);
|
|
btnSaveLocal->set_label(save_local);
|
|
btnSaveGlob->set_label(save_global);
|
|
btnLoadGlob->set_label(load_global);
|
|
btnLoadLocal->set_label(load_local);
|
|
btnSave->set_label(str_save);
|
|
btnLoad->set_label(str_load);
|
|
this->set_title(name_app);
|
|
cmbDownloadMode->append(loading_animation_with);
|
|
cmbDownloadMode->append(loading_animation_without);
|
|
cmbDownloadMode->append(no_loading_animation);
|
|
cmbDownloadMode->append(lack_loading_animation);
|
|
lblDownloadMode->set_text(boot_screen_display_mode);
|
|
lblhelpHeader->set_text(read_documentation_web);
|
|
lblhelpText->set_text(_(redirected_documentation));
|
|
btnReadHelp->set_label(read_online);
|
|
btnCancelHelp->set_label(str_cancel);
|
|
chkAlwaysOpenHelp->set_label(always_redirect);
|
|
lblwebHeaderName->set_label(name_app);
|
|
btnRemoveMusic->set_tooltip_text(str_tooltip_del_melody);
|
|
btnAddMusic->set_tooltip_text(str_tooltip_add_melody);
|
|
btnRemoveUser->set_tooltip_text(str_tooltip_del_user);
|
|
btnAddUser->set_tooltip_text(str_tooltip_add_user);
|
|
btnOpenMenuOS->set_tooltip_text(str_tooltip_boot_menu);
|
|
}
|
|
|
|
vector<string> MainWindow::get_setting_entry_all(string key, std::map <string, string>* map_temp) {
|
|
vector<string> vec_params;
|
|
std::map <string, string>:: iterator iter_map_data;
|
|
iter_map_data = (*map_temp).find(key);
|
|
if (iter_map_data != (*map_temp).end()) {
|
|
string value = iter_map_data->second;
|
|
if (value.length() != 0) {
|
|
Utils::str_replace_all(value, "\"", "");
|
|
vec_params = Utils::split(value, ' ');
|
|
Utils::str_replace_all(value, " ", ", ");
|
|
Utils::str_remove(value, ",");
|
|
(*map_temp)[key] = value;
|
|
}
|
|
}
|
|
return vec_params;
|
|
}
|
|
|
|
void MainWindow::focus_out_txt_kernel() {
|
|
this->set_entry_to_tree_view(list_store_kernel, *entryKernel, vec_Option_kernel, size_kernel, "GRUB_CMDLINE_LINUX");
|
|
this->set_row_all(map_cmd_selection, list_store_kernel, vec_Option_kernel, size_kernel, "GRUB_CMDLINE_LINUX");
|
|
flag_blocked_tree_view = false;
|
|
}
|
|
|
|
void MainWindow::focus_out_txt_IPT() {
|
|
this->set_entry_to_tree_view(list_store_IPT, *entryIPT, vec_Option_IPT, size_IPT, "GRUB_TERMINAL_INPUT");
|
|
this->set_row_all(map_cmd_selection, list_store_IPT, vec_Option_IPT, size_IPT, "GRUB_TERMINAL_INPUT");
|
|
flag_blocked_tree_view = false;
|
|
}
|
|
|
|
void MainWindow::focus_out_txt_OTT() {
|
|
this->set_entry_to_tree_view(list_store_OTT, *entryOTT, vec_Option_OTT, size_OTT, "GRUB_TERMINAL_OUTPUT");
|
|
this->set_row_all(map_cmd_selection, list_store_OTT, vec_Option_OTT, size_OTT, "GRUB_TERMINAL_OUTPUT");
|
|
flag_blocked_tree_view = false;
|
|
}
|
|
|
|
bool MainWindow::focus_in_txt_entry(GdkEventFocus*) {
|
|
treeViewKernel->get_selection()->unselect_all();
|
|
treeViewIPT->get_selection()->unselect_all();
|
|
treeViewOTT->get_selection()->unselect_all();
|
|
treeViewUser->get_selection()->unselect_all();
|
|
treeViewMelody->get_selection()->unselect_all();
|
|
return true;
|
|
}
|
|
|
|
void MainWindow::set_entry_to_tree_view(Glib::RefPtr<Gtk::ListStore> &list_store, Gtk::Entry &entry, std::vector<std::string> &vec_Option, int size, string key) {
|
|
flag_blocked_tree_view = true;
|
|
vector<string> vec_params;
|
|
std::string text = entry.get_text();
|
|
// Utils::str_replace_all(text, " ", "");
|
|
vec_params = Utils::split(text, ' ');
|
|
for (auto &name: vec_Option) {
|
|
this->set_row(list_store, size, name, false);
|
|
}
|
|
for (auto &name: vec_params) {
|
|
this->set_row(list_store, size, name, true);
|
|
}
|
|
// Utils::str_replace_all(text, ",", " ");
|
|
if (text.length() > 0) {
|
|
if (text[0] == ' ') {
|
|
text = text.substr(1, text.length() - 1);
|
|
}
|
|
}
|
|
map_cmd_selection[key] = text;
|
|
}
|
|
|
|
void MainWindow::get_menu_boot(std::map <string, string> &map_temp) {
|
|
std::map <string, string>:: iterator iter_map_data;
|
|
iter_map_data = map_temp.find("GRUB_TIMEOUT");
|
|
if (iter_map_data != map_temp.end()) {
|
|
if (iter_map_data->second.length() > 0) {
|
|
spbSecond->set_value(atoi(iter_map_data->second.c_str()));
|
|
chbLoadVariantSelectionTimer->set_active(true);
|
|
spbSecond->set_sensitive(true);
|
|
lblInfoSeconds->set_sensitive(true);
|
|
}
|
|
else {
|
|
spbSecond->set_value(1);
|
|
chbLoadVariantSelectionTimer->set_active(false);
|
|
spbSecond->set_sensitive(false);
|
|
lblInfoSeconds->set_sensitive(true);
|
|
}
|
|
}
|
|
else {
|
|
spbSecond->set_value(1);
|
|
chbLoadVariantSelectionTimer->set_active(false);
|
|
spbSecond->set_sensitive(false);
|
|
lblInfoSeconds->set_sensitive(true);
|
|
}
|
|
}
|
|
|
|
void MainWindow::cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove) {
|
|
string cmds = entry.get_text();
|
|
Utils::str_remove(cmds, ",");
|
|
if (cmds.length() != 0) {
|
|
cmd_settings += "\"" + cmds + "\"";
|
|
Utils::str_replace_all(cmd_settings, " \"", "\"");
|
|
obj_process_system.call(cmd_settings, "");
|
|
}
|
|
else {
|
|
obj_process_system.call(cmd_remove, "");
|
|
}
|
|
}
|
|
|
|
void MainWindow::event() {
|
|
g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), NULL);
|
|
btnRemoveUser->signal_clicked().connect([&]() {remove_user();});
|
|
btnRemoveMusic->signal_clicked().connect([&]() {remove_melody();});
|
|
btnEditUser->signal_clicked().connect([&]() {wrapper_edit_show_user();});
|
|
btnEditMusic->signal_clicked().connect([&]() {wrapper_edit_show_melody();});
|
|
btnAddUser->signal_clicked().connect([&]() {wrapper_add_data_user();});
|
|
btnAddMusic->signal_clicked().connect([&]() {wrapper_add_data_melody();});
|
|
btnOpenMenuOS->signal_clicked().connect([&]() {obj_menu_os.show();});
|
|
btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();});
|
|
chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;});
|
|
btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_browser));
|
|
btnHelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help));
|
|
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([&]() {wrapper_save_all_cfg();});
|
|
btnSaveLocal->signal_activate().connect([&]() {wrapper_save_local_cfg();});
|
|
btnSaveGlob->signal_activate().connect([&]() {wrapper_save_global_cfg();});
|
|
entryKernel->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel));
|
|
entryIPT->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT));
|
|
entryOTT->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT));
|
|
if (this->check_root() == 0) {
|
|
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));
|
|
entryKernel->signal_focus_in_event().connect(sigc::mem_fun(*this, &MainWindow::focus_in_txt_entry));
|
|
entryIPT->signal_focus_in_event().connect(sigc::mem_fun(*this, &MainWindow::focus_in_txt_entry));
|
|
entryOTT->signal_focus_in_event().connect(sigc::mem_fun(*this, &MainWindow::focus_in_txt_entry));
|
|
}
|
|
this->signal_delete_event().connect(sigc::mem_fun(*this, &MainWindow::gui_exit));
|
|
chbLoadVariantSelectionTimer->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::set_active_boot_second));
|
|
if (plug == NULL) {
|
|
this->signal_check_resize().connect(sigc::mem_fun(*this, &MainWindow::check_resize_window));
|
|
}
|
|
else {
|
|
plug->get_parent()->signal_check_resize().connect(sigc::mem_fun(*this, &MainWindow::check_resize_window));
|
|
}
|
|
}
|
|
void MainWindow::wrapper_edit_user(bool check, string column1, string column2) {
|
|
if (flag_validate_del_user && list_store_user->iter_is_valid(iter_user_del)) {
|
|
Gtk::TreeModel::Row row = *iter_user_del;
|
|
if(row) {
|
|
row[m_columns_user.check_button] = check;
|
|
row[m_columns_user.name] = column1;
|
|
row[m_columns_user.password] = column2;
|
|
}
|
|
}
|
|
}
|
|
void MainWindow::wrapper_edit_melody(bool check, string column1, string column2) {
|
|
if (flag_validate_del_melody && list_store_melody->iter_is_valid(iter_melody_del)) {
|
|
Gtk::TreeModel::Row row = *iter_melody_del;
|
|
if(row) {
|
|
row[m_columns_user.check_button] = check;
|
|
row[m_columns_user.name] = column1;
|
|
row[m_columns_user.password] = column2;
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::wrapper_edit_show_user() {
|
|
if (flag_validate_del_user && list_store_user->iter_is_valid(iter_user_del)) {
|
|
Gtk::TreeModel::Row row = *iter_user_del;
|
|
if(row) {
|
|
bool flag_activ = row[m_columns_user.check_button];
|
|
string name = row[m_columns_user.name] + "";
|
|
string password = row[m_columns_user.password] + "";
|
|
obj_view_edit_add_table.set_data(flag_activ, name, password);
|
|
obj_view_edit_add_table.show_user_edit();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
void MainWindow::wrapper_edit_show_melody() {
|
|
if (flag_validate_del_melody && list_store_melody->iter_is_valid(iter_melody_del)) {
|
|
Gtk::TreeModel::Row row = *iter_melody_del;
|
|
if(row) {
|
|
bool flag_activ = row[m_columns_melody.check_button];
|
|
string title = row[m_columns_melody.title] + "";
|
|
string melody_code = row[m_columns_melody.melody_code] + "";
|
|
obj_view_edit_add_table.set_data(flag_activ, title, melody_code);
|
|
obj_view_edit_add_table.show_melody_edit();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::check_resize_window() {
|
|
int height = 0;
|
|
int width = 0;
|
|
if (plug == NULL) {
|
|
height = this->get_window()->get_height();
|
|
width = this->get_window()->get_width();
|
|
}
|
|
else {
|
|
height = plug->get_window()->get_height();
|
|
width = plug->get_window()->get_width();
|
|
// lblInfoHead->set_text(to_string(height));
|
|
}
|
|
if (height != old_height) {
|
|
if (minimal_height >= height) {
|
|
cmbDownloadMode->remove_all();
|
|
cmbDownloadMode->append(loading_animation_with);
|
|
cmbDownloadMode->append(loading_animation_without);
|
|
cmbDownloadMode->append(no_loading_animation_800_600);
|
|
cmbDownloadMode->append(lack_loading_animation_800_600);
|
|
}
|
|
else {
|
|
cmbDownloadMode->remove_all();
|
|
cmbDownloadMode->append(loading_animation_with);
|
|
cmbDownloadMode->append(loading_animation_without);
|
|
cmbDownloadMode->append(no_loading_animation);
|
|
cmbDownloadMode->append(lack_loading_animation);
|
|
}
|
|
}
|
|
old_height = height;
|
|
old_width = width;
|
|
|
|
}
|
|
|
|
void MainWindow::set_tree_view_user() {
|
|
string key = "";
|
|
string users_root = "";
|
|
string password = "";
|
|
bool flag_available = false;
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewUser_model = treeViewUser->get_model();
|
|
Gtk::TreeModel::Children children = treeViewUser_model->children();
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
Gtk::TreeModel::Row row = *iter;
|
|
if(row) {
|
|
string superuser_name = row[m_columns_user.name] + "";
|
|
if (row[m_columns_user.check_button] && superuser_name.length() != 0) {
|
|
key = "GRUB_PASSWORD[" + superuser_name + "]";
|
|
password = row[m_columns_user.password] + "";
|
|
if (password != "************") {
|
|
map_cmd_selection[key] = password;
|
|
flag_available = false;
|
|
for (size_t index = 0; index < vec_param_names.size(); index++) {
|
|
if (vec_param_names[index] == map_cmd_selection[key]) {
|
|
flag_available = true;
|
|
}
|
|
}
|
|
if (flag_available == false) {
|
|
vec_param_names.push_back(key);
|
|
}
|
|
|
|
}
|
|
else {
|
|
// map_cmd_selection[key] = "";
|
|
}
|
|
if (row[m_columns_user.check_button]) {
|
|
if (users_root.length() != 0) {
|
|
users_root = users_root + "," + superuser_name;
|
|
}
|
|
else {
|
|
users_root = users_root + row[m_columns_user.name];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (users_root.length() != 0) {
|
|
map_cmd_selection["GRUB_SUPERUSERS"] = users_root;
|
|
}
|
|
else {
|
|
map_cmd_selection["GRUB_SUPERUSERS"] = "";
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_init_data_user(std::map<string, string> &map_temp) {
|
|
treeViewUser->remove_all_columns();
|
|
list_store_user = Gtk::ListStore::create(m_columns_user);
|
|
treeViewUser->set_model(list_store_user);
|
|
vector<string> vec_users;
|
|
string buf_key = "";
|
|
string password = "";
|
|
for (auto& [key, value]: map_temp) {
|
|
if (key.find("GRUB_PASSWORD[") != string::npos) {
|
|
buf_key = key;
|
|
vec_param_names.push_back(buf_key);
|
|
Utils::str_remove(buf_key,"GRUB_PASSWORD[");
|
|
Utils::str_remove(buf_key,"]");
|
|
if (value.length() != 0) {
|
|
password = "************";
|
|
this->set_add_data_user(row_user, false, buf_key, password);
|
|
}
|
|
}
|
|
}
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewUserModel = treeViewUser->get_model();
|
|
treeViewUserModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::select_line_user));
|
|
this->view_add_colums_user(*treeViewUser);
|
|
}
|
|
|
|
void MainWindow::set_init_data_superuser(std::map<string, string> &map_temp) {
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewUser_model = treeViewUser->get_model();
|
|
string names_superusers = map_temp["GRUB_SUPERUSERS"];
|
|
vector<string> vec_superusers = Utils::split(names_superusers, ',');
|
|
Gtk::TreeModel::Children children = treeViewUser_model->children();
|
|
for (string& str_superuser: vec_superusers) {
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
Gtk::TreeModel::Row row = *iter;
|
|
if (row[m_columns_user.name] == str_superuser) {
|
|
row[m_columns_user.check_button] = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_data_csv_melody() {
|
|
string path_name = "";
|
|
path_name = path_name + path_resources + "/" + melody_csv;
|
|
string line;
|
|
string all_melody = "Option;Tone code\n";
|
|
string all_melody_old = "Option;Tone code\n";
|
|
string code_melodyes = "";
|
|
ifstream in(path_name);
|
|
if (in.is_open()) {
|
|
while (getline(in, line)) {
|
|
all_melody_old += line + "\n";
|
|
}
|
|
}
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewMelody_model = treeViewMelody->get_model();
|
|
Gtk::TreeModel::Children children = treeViewMelody_model->children();
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
Gtk::TreeModel::Row row = *iter;
|
|
code_melodyes = row[m_columns_melody.melody_code] + "";
|
|
if (code_melodyes.length() != 0 && (row[m_columns_melody.title] + "").length() != 0) {
|
|
all_melody += row[m_columns_melody.title] + ";" + code_melodyes + "\n";
|
|
if (row[m_columns_melody.check_button]) {
|
|
map_cmd_selection["GRUB_PLAY"] = code_melodyes + "";
|
|
}
|
|
else {
|
|
map_cmd_selection["GRUB_PLAY"] = "";
|
|
}
|
|
}
|
|
else {
|
|
imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
|
|
info_status_app(info_box_error_css);
|
|
lblWarning->set_text(str_null_melody_name);
|
|
}
|
|
}
|
|
if (all_melody_old != all_melody) {
|
|
Utils::write_file(path_name, all_melody);
|
|
}
|
|
}
|
|
|
|
void MainWindow::wrapper_add_data_user() {
|
|
obj_view_edit_add_table.show_user_add();
|
|
|
|
}
|
|
|
|
void MainWindow::set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &name, string &password) {
|
|
row = *(list_store_user->append());
|
|
row[m_columns_user.check_button] = flag;
|
|
row[m_columns_user.name] = name;
|
|
row[m_columns_user.password] = password;
|
|
len_old_user += 1;
|
|
}
|
|
void MainWindow::wrapper_set_add_data_user(bool flag, string &name, string &password) {
|
|
Gtk::TreeModel::Row row;
|
|
this->set_add_data_user(row, flag, name, password);
|
|
}
|
|
void MainWindow::set_init_data_melody(std::map<string, string> &map_temp) {
|
|
treeViewMelody->remove_all_columns();
|
|
list_store_melody = Gtk::ListStore::create(m_columns_melody);
|
|
treeViewMelody->set_model(list_store_melody);
|
|
string path_name = "";
|
|
path_name = path_name + path_resources + "/" + melody_csv;
|
|
vector<tuple<string, string>> vec_melody = Utils::read_csv_melody(path_name);
|
|
bool flag = false;
|
|
string cgf_code_melody = map_temp["GRUB_PLAY"];
|
|
for (tuple<string, string>& tuple_melody: vec_melody) {
|
|
string name = get<0>(tuple_melody);
|
|
string code = get<1>(tuple_melody);
|
|
flag = (cgf_code_melody == code);
|
|
this->set_add_data_melody(row_melody, flag, name, code);
|
|
}
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewMelodyModel = treeViewMelody->get_model();
|
|
treeViewMelodyModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::select_line_melody));
|
|
this->view_add_colums_melody(*treeViewMelody);
|
|
}
|
|
|
|
void MainWindow::set_add_data_melody(Gtk::TreeModel::Row &row, bool flag, string &name, string &code) {
|
|
row = *(list_store_melody->append());
|
|
row[m_columns_melody.check_button] = flag;
|
|
row[m_columns_melody.title] = name;
|
|
row[m_columns_melody.melody_code] = code;
|
|
len_old_melody += 1;
|
|
}
|
|
void MainWindow::wrapper_set_add_data_melody(bool flag, string &name, string &code) {
|
|
Gtk::TreeModel::Row row;
|
|
this->set_add_data_melody(row,flag, name, code);
|
|
}
|
|
|
|
void MainWindow::wrapper_add_data_melody() {
|
|
obj_view_edit_add_table.show_melody_add();
|
|
}
|
|
|
|
void MainWindow::remove_user() {
|
|
if (flag_validate_del_user && list_store_user->iter_is_valid(iter_user_del)) {
|
|
Gtk::TreeModel::Row row = *iter_user_del;
|
|
if(row) {
|
|
string name = row[m_columns_user.name] + "";
|
|
string key = "GRUB_PASSWORD[" + name + "]";
|
|
map_cmd_selection[key] = "";
|
|
}
|
|
list_store_user->erase(iter_user_del);
|
|
flag_validate_del_user = false;
|
|
info_status_app(info_box_ok_css);
|
|
imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
|
|
lblWarning->set_text(str_del_user);
|
|
}
|
|
flag_validate_del_user = false;
|
|
}
|
|
|
|
void MainWindow::remove_melody() {
|
|
if (flag_validate_del_melody && list_store_melody->iter_is_valid(iter_melody_del)) {
|
|
list_store_melody->erase(iter_melody_del);
|
|
flag_validate_del_melody = false;
|
|
info_status_app(info_box_ok_css);
|
|
imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
|
|
lblWarning->set_text(str_del_melody);
|
|
}
|
|
flag_validate_del_melody = false;
|
|
}
|
|
|
|
void MainWindow::select_line_user(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter) {
|
|
treeViewKernel->get_selection()->unselect_all();
|
|
treeViewOTT->get_selection()->unselect_all();
|
|
treeViewIPT->get_selection()->unselect_all();
|
|
treeViewMelody->get_selection()->unselect_all();
|
|
iter_user_del = iter;
|
|
size_t len_new_user = 0;
|
|
flag_validate_del_user = true;
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewUser_model = treeViewUser->get_model();
|
|
Gtk::TreeModel::Children children = treeViewUser_model->children();
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
len_new_user += 1;
|
|
}
|
|
len_old_user = len_new_user;
|
|
}
|
|
|
|
void MainWindow::select_line_melody(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter) {
|
|
treeViewKernel->get_selection()->unselect_all();
|
|
treeViewOTT->get_selection()->unselect_all();
|
|
treeViewIPT->get_selection()->unselect_all();
|
|
treeViewUser->get_selection()->unselect_all();
|
|
iter_melody_del = iter;
|
|
size_t len_new_melody = 0;
|
|
flag_validate_del_melody = true;
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewMelody_model = treeViewMelody->get_model();
|
|
Gtk::TreeModel::Children children = treeViewMelody_model->children();
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
len_new_melody += 1;
|
|
}
|
|
this->validate_melody();
|
|
len_old_melody = len_new_melody;
|
|
}
|
|
|
|
void MainWindow::validate_melody() {
|
|
Glib::RefPtr<Gtk::TreeModel> treeViewMelody_model = treeViewMelody->get_model();
|
|
Gtk::TreeModel::Children children = treeViewMelody_model->children();
|
|
int count = 0;
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
Gtk::TreeModel::Row row = *iter;
|
|
if (row[m_columns_melody.check_button]) {
|
|
count+=1;
|
|
}
|
|
}
|
|
if (count>1) {
|
|
for(Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); ++iter) {
|
|
Gtk::TreeModel::Row row = *iter;
|
|
if (row[m_columns_melody.check_button]) {
|
|
count-=1;
|
|
row[m_columns_melody.check_button] = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool MainWindow::focus_tree_view(GdkEventFocus*) {
|
|
treeViewKernel->set_can_focus(false);
|
|
treeViewIPT->set_can_focus(false);
|
|
treeViewOTT->set_can_focus(false);
|
|
treeViewKernel->collapse_all();
|
|
treeViewIPT->collapse_all();
|
|
treeViewOTT->collapse_all();
|
|
return true;
|
|
}
|
|
|
|
bool MainWindow::gui_exit(GdkEventAny*) {
|
|
exit(1);
|
|
return true;
|
|
}
|
|
|
|
void MainWindow::get_default_load(std::map <string, string> &map_temp) {
|
|
std::map <string, string>:: iterator iter_map_data;
|
|
iter_map_data = map_temp.find("GRUB_DEFAULT");
|
|
if (iter_map_data != map_temp.end()) {
|
|
string value = iter_map_data->second;
|
|
if (value.length() != 0) {
|
|
entrListOS->set_text(value);
|
|
}
|
|
else {
|
|
entrListOS->set_text("");
|
|
}
|
|
}
|
|
else {
|
|
entrListOS->set_text("");
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_active_boot_second() {
|
|
spbSecond->set_sensitive(chbLoadVariantSelectionTimer->get_active());
|
|
lblInfoSeconds->set_sensitive(chbLoadVariantSelectionTimer->get_active());
|
|
if (chbLoadVariantSelectionTimer->get_active()) {
|
|
int second = spbSecond->get_value();
|
|
map_cmd_selection["GRUB_TIMEOUT"] = to_string(second);
|
|
}
|
|
else {
|
|
spbSecond->set_value(1);
|
|
map_cmd_selection["GRUB_TIMEOUT"] = "";
|
|
}
|
|
}
|
|
|
|
void MainWindow::wrapper_save_all_cfg() {
|
|
this->set_data_cfg();
|
|
bool _flag_save_all = true;
|
|
if (flag_save_global == false || flag_save_local == false) {
|
|
_flag_save_all = this->save_template(all_save, all_remove, "all");
|
|
}
|
|
if (_flag_save_all) {
|
|
this->info_warning_error(5);
|
|
}
|
|
else {
|
|
info_warning_error(4);
|
|
}
|
|
map_global_cmd_selection = map_cmd_selection;
|
|
map_local_cmd_selection = map_cmd_selection;
|
|
|
|
}
|
|
|
|
void MainWindow::wrapper_save_global_cfg() {
|
|
this->set_data_cfg();
|
|
if (this->save_template(global_save, global_remove , "global")) {
|
|
this->info_warning_error(5);
|
|
}
|
|
else {
|
|
info_warning_error(3);
|
|
}
|
|
map_global_cmd_selection = map_cmd_selection;
|
|
|
|
}
|
|
|
|
bool MainWindow::save_template(string cmd, string cmd_remove, string flag_save) {
|
|
bool flag_no_save = true;
|
|
obj_save.set_data_local(map_local_cmd_selection);
|
|
obj_save.set_data_global(map_global_cmd_selection);
|
|
obj_save.set_data_gui(map_cmd_selection);
|
|
obj_save.set_vec_params(vec_param_names);
|
|
obj_save.save_one_cmd(cmd, cmd_remove ,flag_save);
|
|
vector<string> obj_vec_error = obj_save.get_error();
|
|
flag_no_save = obj_save.get_state_save();
|
|
return flag_no_save;
|
|
}
|
|
|
|
void MainWindow::wrapper_save_local_cfg() {
|
|
this->set_data_cfg();
|
|
if (this->save_template(system_save, system_remove , "system")) {
|
|
this->info_warning_error(5);
|
|
}
|
|
else {
|
|
info_warning_error(2);
|
|
}
|
|
map_local_cmd_selection = map_cmd_selection;
|
|
}
|
|
|
|
void MainWindow::set_data_cfg() {
|
|
string str_flags = entryKernel->get_text();
|
|
// Utils::str_remove(str_flags, ",");
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
|
|
str_flags = entryIPT->get_text();
|
|
// Utils::str_remove(str_flags, ",");
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
|
|
str_flags = entryOTT->get_text();
|
|
// Utils::str_remove(str_flags, ",");
|
|
Utils::str_replace_all(str_flags, " \"", "\"");
|
|
map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
|
|
if (chbLoadVariantSelectionTimer->get_active()) {
|
|
int second = spbSecond->get_value();
|
|
map_cmd_selection["GRUB_TIMEOUT"] = to_string(second);
|
|
}
|
|
else {
|
|
map_cmd_selection["GRUB_TIMEOUT"] = "";
|
|
}
|
|
string name_os = entrListOS->get_text();
|
|
if (name_os.length() != 0) {
|
|
map_cmd_selection["GRUB_DEFAULT"] = name_os;
|
|
}
|
|
else {
|
|
map_cmd_selection["GRUB_DEFAULT"] = "";
|
|
}
|
|
this->set_download_mode();
|
|
this->set_tree_view_user();
|
|
this->set_data_csv_melody();
|
|
}
|
|
|
|
void MainWindow::download_globl_cfg() {
|
|
str_flag_load = "global";
|
|
this->load_template(&map_global_cmd_selection, global_load);
|
|
info_warning_error(1);
|
|
map_cmd_selection = map_global_cmd_selection;
|
|
}
|
|
|
|
void MainWindow::download_local_cfg() {
|
|
str_flag_load = "system";
|
|
this->load_template(&map_local_cmd_selection, system_load);
|
|
info_warning_error(0);
|
|
map_cmd_selection = map_local_cmd_selection;
|
|
}
|
|
|
|
void MainWindow::load_template(std::map<string, string>* map_temp, string cmd) {
|
|
if (cmd.find("system") != string::npos) {
|
|
this->init_dict("system");
|
|
}
|
|
else {
|
|
this->init_dict("global");
|
|
}
|
|
entryKernel->set_text("");
|
|
entryOTT->set_text("");
|
|
entryIPT->set_text("");
|
|
*map_temp = obj_load.get_load_data(*map_temp, cmd);
|
|
this->get_menu_boot(*map_temp);
|
|
this->get_setting_entry_all("GRUB_CMDLINE_LINUX", map_temp);
|
|
this->get_setting_entry_all("GRUB_TERMINAL_INPUT", map_temp);
|
|
this->get_setting_entry_all("GRUB_TERMINAL_OUTPUT", map_temp);
|
|
this->set_row_all(*map_temp, list_store_kernel, vec_Option_kernel, size_kernel, "GRUB_CMDLINE_LINUX");
|
|
this->set_row_all(*map_temp, list_store_IPT, vec_Option_IPT, size_IPT, "GRUB_TERMINAL_INPUT");
|
|
this->set_row_all(*map_temp, list_store_OTT, vec_Option_OTT, size_OTT, "GRUB_TERMINAL_OUTPUT");
|
|
this->get_download_mode(*map_temp);
|
|
this->get_default_load(*map_temp);
|
|
this->set_entry(entryKernel, *map_temp, "GRUB_CMDLINE_LINUX");
|
|
this->set_entry(entryIPT, *map_temp, "GRUB_TERMINAL_INPUT");
|
|
this->set_entry(entryOTT, *map_temp, "GRUB_TERMINAL_OUTPUT");
|
|
string str_last_launched_os_ubconfig = (*map_temp)["GRUB_DEFAULT"];
|
|
this->set_init_data_user(*map_temp);
|
|
this->set_init_data_melody(*map_temp);
|
|
this->set_init_data_superuser(*map_temp);
|
|
if (str_last_launched_os_ubconfig.length() != 0) {
|
|
entrListOS->set_text(str_last_launched_os_ubconfig);
|
|
}
|
|
else {
|
|
entrListOS->set_text(str_last_launched_os);
|
|
}
|
|
|
|
}
|
|
|
|
void MainWindow::set_entry(Gtk::Entry* entry, std::map<string, string> &map_temp, string key) {
|
|
if (map_temp.find(key) != map_temp.end()) {
|
|
string value = map_temp[key];
|
|
Utils::str_replace_all(value, "\"", "");
|
|
// Utils::str_replace_all(value, " ", ", ");
|
|
entry->set_text(value);
|
|
}
|
|
else {
|
|
entry->set_text("");
|
|
}
|
|
}
|
|
|
|
void MainWindow::init_dict(string flag_load) {
|
|
std::map<string, string> map_cmd_selection_n;
|
|
map_cmd_selection_n["GRUB_TIMEOUT"] = "";
|
|
map_cmd_selection_n["GRUB_CMDLINE_LINUX"] = "";
|
|
map_cmd_selection_n["GRUB_TERMINAL_INPUT"] = "";
|
|
map_cmd_selection_n["GRUB_TERMINAL_OUTPUT"] = "";
|
|
map_cmd_selection_n["GRUB_BOOT_SILENT"] = "";
|
|
map_cmd_selection_n["GRUB_PASSWORD"] = "";
|
|
map_cmd_selection_n["GRUB_DEFAULT"] = "";
|
|
map_cmd_selection_n["GRUB_PLAY"] = "";
|
|
map_cmd_selection_n["GRUB_SUPERUSERS"] = "";
|
|
map_cmd_selection = map_cmd_selection_n;
|
|
if (flag_load == "global") {
|
|
map_global_cmd_selection = map_cmd_selection_n;
|
|
}
|
|
else if (flag_load == "system") {
|
|
map_local_cmd_selection = map_cmd_selection_n;
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_row_all(std::map <string, string> &map_cmd, Glib::RefPtr<Gtk::ListStore> &list_store, vector<string> &list_params, size_t size,string key) {
|
|
for (auto &name: list_params) {
|
|
this->set_row(list_store, size, name, false);
|
|
}
|
|
string value = map_cmd[key];
|
|
Utils::str_replace_all(value, "\"", "");
|
|
vector<string> vec_params = Utils::split(value, ' ');
|
|
for (auto &name: vec_params) {
|
|
this->set_row(list_store, size, name, true);
|
|
}
|
|
}
|
|
|
|
void MainWindow::set_row(Glib::RefPtr<Gtk::ListStore> &list_store, int size, string name, bool flag_chbox) {
|
|
for (int index = 0; index < size; index++) {
|
|
Gtk::TreeModel::Row row = list_store->children()[index];
|
|
if(row) {
|
|
if (row[m_columns.name] == name) {
|
|
row[m_columns.check_button] = flag_chbox;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void MainWindow::temp_help_show() {
|
|
if (flag_open_browser == true) {
|
|
this->open_browser();
|
|
}
|
|
else {
|
|
wndShowWeb->show_all();
|
|
}
|
|
}
|
|
|
|
void MainWindow::open_help() {
|
|
global_lick_doc = const_link_doc;
|
|
temp_help_show();
|
|
}
|
|
|
|
void MainWindow::open_browser() {
|
|
#ifdef WEBKIT_FOUND
|
|
webkit_web_view_load_uri(one, _(global_lick_doc.c_str()));
|
|
wndWeb->show_all();
|
|
#else
|
|
this->template_open_browser(global_lick_doc);
|
|
#endif
|
|
wndShowWeb->hide();
|
|
}
|
|
|
|
void MainWindow::template_open_browser(string link_doc) {
|
|
string cmd = cmd_xdg + string(_(link_doc.c_str())) + " &";
|
|
string buf = "";
|
|
if (geteuid() == 0) {
|
|
string response_user = getlogin();
|
|
int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1;
|
|
auto size = static_cast<size_t>(size_s);
|
|
std::unique_ptr<char[]> buf(new char[ size ]);
|
|
std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str());
|
|
cmd = string(buf.get(), buf.get() + size - 1);
|
|
}
|
|
index_error = system(cmd.c_str());
|
|
}
|
|
void MainWindow::info_status_app(string stule) {
|
|
boxInfo->remove_class(info_box_ok_css);
|
|
boxInfo->remove_class(info_box_error_css);
|
|
boxInfo->add_class(stule);
|
|
}
|
|
|
|
void MainWindow::info_warning_error(int mess) {
|
|
if (obj_load.get_count_error() > 0 || obj_save.get_count_error() > 0) {
|
|
info_status_app(info_box_error_css);
|
|
imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
|
|
string mess_error = "";
|
|
if (mess == 0) {
|
|
mess_error = string(local_read_error) + str_cmd_error;
|
|
lblWarning->set_text(mess_error);
|
|
}
|
|
else if (mess == 1) {
|
|
mess_error = string(global_read_error) + str_cmd_error;
|
|
lblWarning->set_text(mess_error);
|
|
}
|
|
else if (mess == 2) {
|
|
mess_error = string(local_write_error) + str_cmd_error;
|
|
lblWarning->set_text(mess_error);
|
|
}
|
|
else if (mess == 3) {
|
|
mess_error = string(global_write_error) + str_cmd_error;
|
|
lblWarning->set_text(mess_error);
|
|
}
|
|
else if (mess == 4) {
|
|
mess_error = string(error_save_all) + str_cmd_error;
|
|
lblWarning->set_text(mess_error);
|
|
}
|
|
str_cmd_error = "";
|
|
obj_load.set_count_error(0);
|
|
obj_save.set_count_error(0);
|
|
}
|
|
else {
|
|
info_status_app(info_box_ok_css);
|
|
imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
|
|
if (mess == 0) {
|
|
lblWarning->set_text(local_load_ok);
|
|
}
|
|
else if (mess == 1) {
|
|
lblWarning->set_text(global_load_ok);
|
|
}
|
|
else if (mess == 2) {
|
|
lblWarning->set_text(local_ok_written);
|
|
}
|
|
else if (mess == 3) {
|
|
lblWarning->set_text(global_ok_written);
|
|
}
|
|
else if (mess == 4) {
|
|
lblWarning->set_text(successfully_save_all);
|
|
}
|
|
else if (mess == 5) {
|
|
lblWarning->set_text(nothing_save);
|
|
}
|
|
}
|
|
}
|
|
MainWindow::~MainWindow() {
|
|
#ifdef WEBKIT_FOUND
|
|
free(one);
|
|
#endif
|
|
}
|
|
|
|
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> boxButton_css = boxButton->get_style_context();
|
|
Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context();
|
|
boxInfo = boxInfoError->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");
|
|
}
|
|
}
|
|
|
|
void help() {
|
|
string version = string(str_version) + version_application + "\n";
|
|
cout << version;
|
|
string help;
|
|
cout << str_help_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|