Исправлены баги с ComboBoxText

pull/11/head
Igor Belitskiy 3 years ago
parent 532d354afb
commit 52915a3500

@ -1,4 +1,4 @@
Get,Set=1,Set=0,Option,Description Option,Description
quiet,Downloading without text messages quiet,Downloading without text messages
splash,Show welcome window splash,Show welcome window
noplymouth,Disable Plymouth noplymouth,Disable Plymouth

Can't render this file because it has a wrong number of fields in line 2.

@ -1,4 +1,4 @@
Get,Set=1,Set=0,Option,Description Option,Description
console,PC BIOS & EFI console console,PC BIOS & EFI console
serial,Serial terminal serial,Serial terminal
ofconsole,Open Firmware Console ofconsole,Open Firmware Console

1 Get,Set=1,Set=0,Option,Description Option Description
2 console,PC BIOS & EFI console console PC BIOS & EFI console
3 serial,Serial terminal serial Serial terminal
4 ofconsole,Open Firmware Console ofconsole Open Firmware Console

@ -1,4 +1,4 @@
Get,Set=1,Set=0,Option,Description Option,Description
console,PC BIOS & EFI console console,PC BIOS & EFI console
serial,Serial terminal serial,Serial terminal
ofconsole,Open Firmware Console ofconsole,Open Firmware Console

1 Get,Set=1,Set=0,Option,Description Option Description
2 console,PC BIOS & EFI console console PC BIOS & EFI console
3 serial,Serial terminal serial Serial terminal
4 ofconsole,Open Firmware Console ofconsole Open Firmware Console

@ -81,12 +81,11 @@ void MainWindow::settings(){
spbSecond->set_range(1, 60); spbSecond->set_range(1, 60);
spbSecond->set_increments(1.0, 1.0); spbSecond->set_increments(1.0, 1.0);
this->fill_in_view(); this->fill_in_view();
this->download_local_cfg();
this->download_globl_cfg();
entrySecurityLogin->set_sensitive(false);
this->set_active_boot_second();
this->change_password_protecc(); this->change_password_protecc();
this->change_security_login(); this->change_security_login();
this->set_active_boot_second();
this->download_local_cfg();
this->download_globl_cfg();
this->event(); this->event();
} }
@ -237,14 +236,14 @@ void MainWindow::set_security_login(string cmd="") {
} }
else if (index == 1) { else if (index == 1) {
key = string(getlogin()); key = entrySecurityLogin->get_text();
} }
else { else if (index == -1) {
return; return;
} }
if (cmd.length() != 0) { if (cmd.length() != 0) {
entrySecurityLogin->set_text(key); entrySecurityLogin->set_text(key);
cmd = cmd + key; cmd = cmd + "\"" + key + "\"";
wrapper_system(cmd, ""); wrapper_system(cmd, "");
} }
map_cmd_selection["GRUB_USER"] = key; map_cmd_selection["GRUB_USER"] = key;
@ -252,20 +251,27 @@ void MainWindow::set_security_login(string cmd="") {
void MainWindow::get_security_login(string cmd, std::map <string, string> &map_temp) { void MainWindow::get_security_login(string cmd, std::map <string, string> &map_temp) {
struct Result<string> res_response = this->wrapper_call(cmd); struct Result<string> res_response = this->wrapper_call(cmd);
// TODO:
// Убрать в будущем
string default_login = "superadmin";
if (res_response.error == 0) { if (res_response.error == 0) {
str_replace_all(res_response.response, " ","");
str_replace_all(res_response.response, "\"",""); str_replace_all(res_response.response, "\"","");
entrySecurityLogin->set_text(res_response.response); entrySecurityLogin->set_text(res_response.response);
if (res_response.response == getlogin()) { if (res_response.response != default_login) {
chbSecurityLogin->set_active(1); chbSecurityLogin->set_active(1);
map_temp["GRUB_USER"] = getlogin(); entrySecurityLogin->set_sensitive(true);
map_temp["GRUB_USER"] = res_response.response;
} }
else if (res_response.response.length() != 0) { else if (res_response.response == default_login) {
chbSecurityLogin->set_active(0); chbSecurityLogin->set_active(0);
map_temp["GRUB_USER"] = res_response.response; map_temp["GRUB_USER"] = default_login;
} }
else{ else {
chbSecurityLogin->set_active(-1); chbSecurityLogin->set_active(-1);
map_temp["GRUB_USER"] = ""; map_temp["GRUB_USER"] = "";
} }
} }
else if (res_response.error == 3) { else if (res_response.error == 3) {
@ -278,30 +284,30 @@ void MainWindow::get_security_login(string cmd, std::map <string, string> &map_t
} }
} }
void MainWindow::set_password_protec(string cmd = "", string cmd_remove= "") { void MainWindow::set_password_protec(string cmd = "", string cmd_remove = "") {
// TODO: // TODO:
// Не работает // Не работает
int index = chbSecurityLogin->get_active_row_number(); int index = chbPasswordProtecc->get_active_row_number();
string key = ""; string key = "";
if (index == 0){ if (index == 0){
key = ""; key = "";
} }
else if (index == 1) { else if (index == 1) {
key = entryPasswordProtecc->get_text(); key = entryPasswordProtecc->get_text();
} }
else if (index == 2) { else if (index == 2) {
key = "remove"; key = "remove";
if (cmd.length() != 0 && cmd_remove.length() != 0) { if (cmd_remove.length() != 0) {
wrapper_system(cmd_remove, ""); wrapper_system(cmd_remove, "");
} }
cmd = ""; cmd = "";
} }
else { else if (index == -1){
return; return;
} }
if (cmd.length() != 0 && cmd_remove.length() != 0) { if (cmd.length() != 0 && cmd_remove.length() != 0) {
entrySecurityLogin->set_text(key); entryPasswordProtecc->set_text(key);
cmd = cmd + key; cmd = cmd + key;
wrapper_system(cmd, ""); wrapper_system(cmd, "");
} }
@ -309,36 +315,35 @@ void MainWindow::set_password_protec(string cmd = "", string cmd_remove= "") {
} }
void MainWindow::get_password_protec(string cmd, std::map <string, string> &map_temp) { void MainWindow::get_password_protec(string cmd, std::map <string, string> &map_temp) {
// TODO:
// Не работает
struct Result<string> res_response = this->wrapper_call(cmd); struct Result<string> res_response = this->wrapper_call(cmd);
cout << res_response.response << " " << res_response.error << endl;
if (res_response.error == 0) { if (res_response.error == 0) {
str_replace_all(res_response.response, "\"",""); str_replace_all(res_response.response, "\"","");
entrySecurityLogin->set_text(res_response.response); entryPasswordProtecc->set_text(res_response.response);
// TODO:
// Не работает
if (res_response.response == getlogin()) { if (res_response.response == getlogin()) {
chbSecurityLogin->set_active(0); chbPasswordProtecc->set_active(0);
map_temp["GRUB_PASSWORD"] = ""; map_temp["GRUB_PASSWORD"] = "";
} }
else if (res_response.response.length() != 0) { else if (res_response.response.length() != 0) {
chbSecurityLogin->set_active(1); chbPasswordProtecc->set_active(1);
map_temp["GRUB_PASSWORD"] = "";
}
else if (res_response.response.length() != 0) {
chbSecurityLogin->set_active(2);
map_temp["GRUB_PASSWORD"] = ""; map_temp["GRUB_PASSWORD"] = "";
entryPasswordProtecc->set_sensitive(true);
} }
else{ else{
map_temp["GRUB_PASSWORD"] = ""; map_temp["GRUB_PASSWORD"] = "";
chbSecurityLogin->set_active(-1); chbPasswordProtecc->set_active(-1);
} }
} }
else if (res_response.error == 3) { else if (res_response.error == 3 && res_response.response.find("null") != string::npos) {
chbPasswordProtecc->set_active(2);
map_temp["GRUB_PASSWORD"] = ""; map_temp["GRUB_PASSWORD"] = "";
chbSecurityLogin->set_active(-1); entryPasswordProtecc->set_text("");
} }
else { else {
map_temp["GRUB_PASSWORD"] = ""; map_temp["GRUB_PASSWORD"] = "";
chbSecurityLogin->set_active(-1); chbPasswordProtecc->set_active(-1);
} }
} }
@ -530,8 +535,17 @@ vector<string> MainWindow::get_setting_entry_all(string cmd, Gtk::Entry &entry_t
} }
bool MainWindow::focus_out_txt_password(GdkEventFocus*) { bool MainWindow::focus_out_txt_password(GdkEventFocus*) {
info_status_app("boxInfoMessError"); if (entryPasswordProtecc->get_text().length() == 0) {
lblWarning->set_text(gettext("Enter your password")); info_status_app("boxInfoMessError");
lblWarning->set_text(gettext("Enter your password"));
}
return true;
}
bool MainWindow::focus_out_txt_login(GdkEventFocus*) {
if (entrySecurityLogin->get_text().length() == 0) {
info_status_app("boxInfoMessError");
lblWarning->set_text(gettext("Enter login"));
}
return true; return true;
} }
@ -580,9 +594,8 @@ void MainWindow::get_menu_boot(string cmd, std::map <string, string> &map_temp)
void MainWindow::set_menu_boot(string cmd="") { void MainWindow::set_menu_boot(string cmd="") {
int value = spbSecond->get_value(); int value = spbSecond->get_value();
std::string seconds = to_string(value);
cmd += seconds;
if (cmd.length() != 0) { if (cmd.length() != 0) {
cmd += to_string(value);
this->wrapper_system(cmd, ""); this->wrapper_system(cmd, "");
} }
map_cmd_selection["GRUB_TIMEOUT"] = to_string(value); map_cmd_selection["GRUB_TIMEOUT"] = to_string(value);
@ -608,6 +621,7 @@ void MainWindow::event(){
entryKernel->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel)); entryKernel->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel));
entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT)); entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT));
entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT)); entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT));
entrySecurityLogin->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_login));
entryPasswordProtecc->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_password)); entryPasswordProtecc->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_password));
chbPasswordProtecc->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_password_protecc)); chbPasswordProtecc->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_password_protecc));
chbSecurityLogin->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_security_login)); chbSecurityLogin->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::change_security_login));
@ -627,22 +641,28 @@ void MainWindow::event(){
void MainWindow::change_security_login() { void MainWindow::change_security_login() {
int index = chbSecurityLogin->get_active_row_number(); int index = chbSecurityLogin->get_active_row_number();
if (index == 0 || index == -1) { if (index == 0) {
entrySecurityLogin->set_sensitive(false); entrySecurityLogin->set_sensitive(false);
// TODO: // TODO:
// Добавить заполнение логина по умолчанию // Добавить заполнение логина по умолчанию
entrySecurityLogin->set_text(""); string default_login = "superadmin";
entrySecurityLogin->set_text(default_login);
} }
else if (index == 1) { else if (index == 1) {
entrySecurityLogin->set_sensitive(true); entrySecurityLogin->set_sensitive(true);
entrySecurityLogin->set_text(""); entrySecurityLogin->set_text("");
} }
else {
entrySecurityLogin->set_sensitive(false);
entrySecurityLogin->set_text("");
}
} }
void MainWindow::change_password_protecc() { void MainWindow::change_password_protecc() {
int index = chbPasswordProtecc->get_active_row_number(); int index = chbPasswordProtecc->get_active_row_number();
if (index == 0 || index == 2 || index == -1) { if (index == 0 || index == 2 || index == -1) {
entryPasswordProtecc->set_sensitive(false); entryPasswordProtecc->set_sensitive(false);
entryPasswordProtecc->set_text("");
} }
else if (index == 1) { else if (index == 1) {
entryPasswordProtecc->set_sensitive(true); entryPasswordProtecc->set_sensitive(true);
@ -657,8 +677,7 @@ void MainWindow::set_active_boot_second() {
void MainWindow::wrapper_save_all_cfg() { void MainWindow::wrapper_save_all_cfg() {
if (this->save_global_cfg() && this->save_local_cfg()) { if (this->save_global_cfg() && this->save_local_cfg()) {
info_status_app("boxInfoMessOK"); this->info_warning_error(5);
lblWarning->set_text(gettext("Nothing to save!"));
} }
else { else {
info_warning_error(4); info_warning_error(4);
@ -668,8 +687,7 @@ void MainWindow::wrapper_save_all_cfg() {
void MainWindow::wrapper_save_global_cfg() { void MainWindow::wrapper_save_global_cfg() {
if (this->save_global_cfg()) { if (this->save_global_cfg()) {
info_status_app("boxInfoMessOK"); this->info_warning_error(5);
lblWarning->set_text(gettext("Nothing to save!"));
} }
else { else {
info_warning_error(3); info_warning_error(3);
@ -714,7 +732,7 @@ bool MainWindow::save_global_cfg() {
} }
if (this->check_save(flag_save, "GRUB_PASSWORD")) { if (this->check_save(flag_save, "GRUB_PASSWORD")) {
string cmd_password = "ubconfig --target global set boot GRUB_PASSWORD="; string cmd_password = "ubconfig --target global set boot GRUB_PASSWORD=";
string cmd_password_remove = "ubconfig --target global remove boot GRUB_PASSWORD="; string cmd_password_remove = "ubconfig --target global remove boot GRUB_PASSWORD";
this->set_password_protec(cmd_password, cmd_password_remove); this->set_password_protec(cmd_password, cmd_password_remove);
flag_no_save = false; flag_no_save = false;
} }
@ -726,8 +744,7 @@ bool MainWindow::save_global_cfg() {
void MainWindow::wrapper_save_local_cfg() { void MainWindow::wrapper_save_local_cfg() {
if (this->save_local_cfg()){ if (this->save_local_cfg()){
info_status_app("boxInfoMessOK"); this->info_warning_error(5);
lblWarning->set_text(gettext("Nothing to save!"));
} }
else { else {
info_warning_error(2); info_warning_error(2);
@ -772,7 +789,7 @@ bool MainWindow::save_local_cfg() {
} }
if (this->check_save(flag_save, "GRUB_PASSWORD")) { if (this->check_save(flag_save, "GRUB_PASSWORD")) {
string cmd_password = "ubconfig --target system set boot GRUB_PASSWORD="; string cmd_password = "ubconfig --target system set boot GRUB_PASSWORD=";
string cmd_password_remove = "ubconfig --target system remove boot GRUB_PASSWORD="; string cmd_password_remove = "ubconfig --target system remove boot GRUB_PASSWORD";
this->set_password_protec(cmd_password, cmd_password_remove); this->set_password_protec(cmd_password, cmd_password_remove);
flag_no_save = false; flag_no_save = false;
} }
@ -853,6 +870,8 @@ void MainWindow::download_local_cfg() {
} }
bool MainWindow::check_save(string flag_save, string key_name="") { bool MainWindow::check_save(string flag_save, string key_name="") {
if (flag_save.empty() && key_name.empty()) {}
/*
std::map <string, string>:: iterator iter_map_data; std::map <string, string>:: iterator iter_map_data;
std::map <string, string>:: iterator iter_map_data_old; std::map <string, string>:: iterator iter_map_data_old;
std::map <string, string> map_config_data_old; std::map <string, string> map_config_data_old;
@ -890,6 +909,7 @@ bool MainWindow::check_save(string flag_save, string key_name="") {
return true; return true;
} }
cout << 7 << endl; cout << 7 << endl;
*/
return true; return true;
} }
@ -935,7 +955,7 @@ void MainWindow::wrapper_system(string cmd, string thread_str = "") {
} }
void MainWindow::info_status_app(string stule) { void MainWindow::info_status_app(string stule) {
Glib::RefPtr<Gtk::StyleContext> boxInfo = boxInfoError->get_style_context();
boxInfo->remove_class("boxInfoMessOK"); boxInfo->remove_class("boxInfoMessOK");
boxInfo->remove_class("boxInfoMessError"); boxInfo->remove_class("boxInfoMessError");
boxInfo->add_class(stule); boxInfo->add_class(stule);
@ -987,6 +1007,9 @@ void MainWindow::info_warning_error(int mess) {
else if (mess == 4) { else if (mess == 4) {
lblWarning->set_text(gettext("Successfully saved local and global configuration")); lblWarning->set_text(gettext("Successfully saved local and global configuration"));
} }
else if (mess == 5) {
lblWarning->set_text(gettext("Nothing to save!"));
}
} }
} }
@ -1061,6 +1084,7 @@ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::StyleContext> lblInfoHead_css = lblInfoHead->get_style_context(); Glib::RefPtr<Gtk::StyleContext> lblInfoHead_css = lblInfoHead->get_style_context();
Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context(); Glib::RefPtr<Gtk::StyleContext> boxButton_css = boxButton->get_style_context();
Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context(); Glib::RefPtr<Gtk::StyleContext> boxSave_css = boxSave->get_style_context();
boxInfo = boxInfoError->get_style_context();
imgBG->set(path_img_head_background); imgBG->set(path_img_head_background);
if (socket_trd_id_I == 0 && socket_ext_id_I == 0){ if (socket_trd_id_I == 0 && socket_ext_id_I == 0){
boxButton_css->add_class("bkim_no_plug"); boxButton_css->add_class("bkim_no_plug");

@ -125,6 +125,7 @@ class MainWindow : public Gtk::ApplicationWindow {
size_t size_IPT = 0; size_t size_IPT = 0;
size_t size_OTT = 0; size_t size_OTT = 0;
int index_error = 0; int index_error = 0;
Glib::RefPtr<Gtk::StyleContext> boxInfo;
string str_cmd_error = ""; string str_cmd_error = "";
template<typename Type> template<typename Type>
struct Result{ struct Result{
@ -176,6 +177,7 @@ class MainWindow : public Gtk::ApplicationWindow {
bool check_flag_save(string flag_save); bool check_flag_save(string flag_save);
void set_download_mode(string cmd); void set_download_mode(string cmd);
void change_password_protecc(); void change_password_protecc();
bool focus_out_txt_login(GdkEventFocus*);
void change_security_login(); void change_security_login();
bool focus_out_txt_password(GdkEventFocus*); bool focus_out_txt_password(GdkEventFocus*);
void get_password_protec(string cmd, std::map <string, string> &map_temp); void get_password_protec(string cmd, std::map <string, string> &map_temp);

@ -385,6 +385,7 @@ specified priority</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
<property name="label" translatable="yes">Default download</property> <property name="label" translatable="yes">Default download</property>
<property name="ellipsize">start</property> <property name="ellipsize">start</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -454,6 +455,7 @@ specified priority</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
<property name="label" translatable="yes">Download mode</property> <property name="label" translatable="yes">Download mode</property>
<property name="ellipsize">start</property> <property name="ellipsize">start</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -502,6 +504,7 @@ specified priority</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
<property name="label" translatable="yes">Security login:</property> <property name="label" translatable="yes">Security login:</property>
<property name="ellipsize">start</property> <property name="ellipsize">start</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -567,6 +570,7 @@ specified priority</property>
<property name="margin-bottom">6</property> <property name="margin-bottom">6</property>
<property name="label" translatable="yes">Password protection:</property> <property name="label" translatable="yes">Password protection:</property>
<property name="ellipsize">start</property> <property name="ellipsize">start</property>
<property name="xalign">0</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -1212,6 +1216,15 @@ specified priority</property>
<widget name="lblPasswordProtec"/> <widget name="lblPasswordProtec"/>
</widgets> </widgets>
</object> </object>
<object class="GtkSizeGroup">
<property name="mode">both</property>
<property name="ignore-hidden">True</property>
<widgets>
<widget name="chbLastSelectionWillBecome"/>
<widget name="entrySecurityLogin"/>
<widget name="entryPasswordProtecc"/>
</widgets>
</object>
<object class="GtkWindow" id="mess_sudo"> <object class="GtkWindow" id="mess_sudo">
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="title" translatable="yes">Внимание!</property> <property name="title" translatable="yes">Внимание!</property>

@ -16,6 +16,9 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
msgid "Enter login"
msgstr "Введите логин"
msgid "Enter your password" msgid "Enter your password"
msgstr "Введите пароль" msgstr "Введите пароль"

Loading…
Cancel
Save