diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 081d48c..9c8d6a2 100644 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -76,60 +76,143 @@ void View_edit_add_table::settings() { void View_edit_add_table::event() { btnCancel->signal_clicked().connect([&]() {cancel();}); - btnSave->signal_clicked().connect([&]() {save();}); + 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("wndQuotasAddProject", wndQuotasAddProject); + builder->get_widget("wndAddEditData", wndAddEditData); builder->get_widget("btnCancel", btnCancel); - builder->get_widget("btnSave", btnSave); + builder->get_widget("btnSaveEditSave", btnSaveEditSave); builder->get_widget("chkAddEdit", chkAddEdit); builder->get_widget("entryCol1", entryCol1); builder->get_widget("entryCol2", entryCol2); - builder->get_widget("lblAddEditTitle", lblAddEditTitle); builder->get_widget("lblAddEditCheckBox", lblAddEditCheckBox); builder->get_widget("lblAddEditCol1", lblAddEditCol1); builder->get_widget("lblAddEditCol2", lblAddEditCol2); - builder->get_widget("lblAddEdittTableName", lblAddEdittTableName); + builder->get_widget("lblEditAddHead", lblEditAddHead); + } + void View_edit_add_table::cancel() { - wndQuotasAddProject->hide(); + wndAddEditData->hide(); flag_save = false; } void View_edit_add_table::save() { - wndQuotasAddProject->hide(); flag_save = true; + new_data.check = chkAddEdit->get_active(); + new_data.column1 = entryCol1->get_text(); + new_data.column2 = entryCol2->get_text(); + wndAddEditData->hide(); } -struct Data View_edit_add_table::get_data() { +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 Data View_edit_add_table::show() { +void View_edit_add_table::show() { flag_save = false; - wndQuotasAddProject->show(); + wndAddEditData->show(); } -void View_edit_add_table::set_data(bool check, string colmn1, string colmn2) { +void View_edit_add_table::set_data(bool check, string column1, string column2) { old_data.check = check; - old_data.colmn1 = colmn1; - old_data.colomn2 = colomn2; + 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_edit() { +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_add() { +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 const& builder) @@ -293,14 +376,14 @@ void MainWindow::fill_in_view() { void MainWindow::view_add_colums_user(Gtk::TreeView &treeView) { treeView.append_column_editable(str_administrator, m_columns_user.check_button); - treeView.append_column_editable(str_user, m_columns_user.name); - treeView.append_column_editable(str_password, m_columns_user.password); + 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_editable(str_option, m_columns_melody.title); - treeView.append_column_editable(str_melody_code, m_columns_melody.melody_code); + 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&) { @@ -727,6 +810,8 @@ 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();}); @@ -763,6 +848,54 @@ void MainWindow::event() { 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; @@ -866,7 +999,6 @@ void MainWindow::set_init_data_user(std::map &map_temp) { } } Glib::RefPtr treeViewUserModel = treeViewUser->get_model(); - treeViewUser->signal_cursor_changed().connect(sigc::mem_fun(*this, &MainWindow::check_space_user)); treeViewUserModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::select_line_user)); this->view_add_colums_user(*treeViewUser); } @@ -925,24 +1057,8 @@ void MainWindow::set_data_csv_melody() { } void MainWindow::wrapper_add_data_user() { - string name; - string password; - bool flag_no_add_user = false; - Glib::RefPtr 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; - name = row[m_columns_user.name] + ""; - password = row[m_columns_user.password] + ""; - if (name.length() == 0 || password.length() == 0) { - flag_no_add_user = true; - } - } - if (!flag_no_add_user) { - string name1 = ""; - string passwd = ""; - set_add_data_user(row_user, false, name1, passwd); - } + obj_view_edit_add_table.show_user_add(); + } void MainWindow::set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &name, string &password) { @@ -952,7 +1068,10 @@ void MainWindow::set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string & 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 &map_temp) { treeViewMelody->remove_all_columns(); list_store_melody = Gtk::ListStore::create(m_columns_melody); @@ -969,7 +1088,6 @@ void MainWindow::set_init_data_melody(std::map &map_temp) { this->set_add_data_melody(row_melody, flag, name, code); } Glib::RefPtr treeViewMelodyModel = treeViewMelody->get_model(); - treeViewMelody->signal_cursor_changed().connect(sigc::mem_fun(*this, &MainWindow::check_space_melody)); treeViewMelodyModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::select_line_melody)); this->view_add_colums_melody(*treeViewMelody); } @@ -981,24 +1099,13 @@ void MainWindow::set_add_data_melody(Gtk::TreeModel::Row &row, bool flag, string 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() { - string code_melodyes = ""; - string melody_title = ""; - bool flag_no_add_melody = false; - Glib::RefPtr 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] + ""; - melody_title = row[m_columns_melody.title] + ""; - if (code_melodyes.length() == 0 || melody_title.length() == 0) { - flag_no_add_melody = true; - } - } - if (flag_no_add_melody == false) { - string code = "", name = ""; - set_add_data_melody(row_melody, false, name, code); - } + obj_view_edit_add_table.show_melody_add(); } void MainWindow::remove_user() { @@ -1029,66 +1136,6 @@ void MainWindow::remove_melody() { flag_validate_del_melody = false; } -void MainWindow::check_space_user() { - bool flag_error = false; - string name = ""; - string password = ""; - size_t len_new_user = 0; - Glib::RefPtr 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; - name = row[m_columns_user.name] + ""; - password = row[m_columns_user.password] + ""; - len_new_user += 1; - if (name.length() == 0 || password.length() == 0) { - flag_error = true; - - } - } - if (flag_error == true) { - imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU); - info_status_app(info_box_error_css); - lblWarning->set_text(str_null_username); - } - else { - if ((len_old_user-1) != len_new_user) { - info_status_app(info_box_ok_css); - imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); - lblWarning->set_text(str_add_user); - } - } -} -void MainWindow::check_space_melody() { - string code_melodyes = ""; - string melody_title = ""; - size_t len_new_melody = 0; - bool flag_error = false; - Glib::RefPtr 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] + ""; - melody_title = row[m_columns_melody.title] + ""; - len_new_melody += 1; - if (code_melodyes.length() == 0 || melody_title.length() == 0) { - flag_error = true; - } - } - if (flag_error == true) { - 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); - } - else { - if ((len_old_melody-1) != len_new_melody) { - info_status_app(info_box_ok_css); - imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU); - lblWarning->set_text(str_add_melody); - } - } -} - void MainWindow::select_line_user(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter) { treeViewKernel->get_selection()->unselect_all(); treeViewOTT->get_selection()->unselect_all(); diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 3a0938f..3254043 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -61,6 +61,8 @@ void me_thread(string cmd); #define str_about_1 _("About") #define str_save _("Save") #define str_load _("Load") +#define str_edit _("Edit") +#define str_adding _("Adding") #define save_all _("Save configuration") #define save_local _("Save in local configuration") #define save_global _("Save in global configuration") @@ -161,41 +163,44 @@ void me_thread(string cmd); class View_edit_add_table { private: Glib::RefPtr builder; - Gtk::Window* wndQuotasAddProject; + Gtk::Window* wndAddEditData; Gtk::Button* btnCancel; - Gtk::Button* btnSave; + Gtk::Button* btnSaveEditSave; Gtk::CheckButton* chkAddEdit; Gtk::Entry* entryCol1; Gtk::Entry* entryCol2; - Gtk::Label* lblAddEditTitle; Gtk::Label* lblAddEditCheckBox; Gtk::Label* lblAddEditCol1; Gtk::Label* lblAddEditCol2; - Gtk::Label* lblAddEdittTableName; + Gtk::Label* lblEditAddHead; + bool flag_save = false; + string mode_show = ""; -private: - View_edit_add_table(); - ~View_edit_add_table(); - struct Data { +public: + struct struct_data { bool check; - string colomn1; - string colomn2; + string column1; + string column2; }; - struct Data old_data; - struct Data new_data; - string flag_save = false; + struct struct_data old_data; + struct struct_data new_data; public: + View_edit_add_table(); + //~View_edit_add_table(); void settings(); void event(); void localization(); void cancel(); void save(); - void set_data(bool check, string colmn1, string colmn2); - void get_data(); + void check_space_entry(); + void set_data(bool check, string column1, string column2); + struct struct_data get_data(); void show(); + void show_melody_edit(); + void show_melody_add(); + void show_user_edit(); + void show_user_add(); void get_builder(); - void show_edit(); - void show_add(); }; @@ -463,8 +468,12 @@ public: void wrapper_add_data_melody(); void check_resize_window(); void set_plug(Gtk::Widget *plug); - void check_space_user(); - void check_space_melody(); + void wrapper_edit_show_user(); + void wrapper_edit_show_melody(); + void wrapper_edit_melody(bool check, string column1, string column2); + void wrapper_edit_user(bool check, string column1, string column2); + void wrapper_set_add_data_melody(bool flag, string &name, string &code); + void wrapper_set_add_data_user(bool flag, string &name, string &password); }; class SettingsPlug : public Gtk::Plug diff --git a/ubl-settings-bootloader.css b/ubl-settings-bootloader.css index 34c1572..dcc568a 100644 --- a/ubl-settings-bootloader.css +++ b/ubl-settings-bootloader.css @@ -144,3 +144,10 @@ opacity:0.99; } +.thin{ + margin:0px; + padding: 0px; +} +.nobg{ + background: none; +} \ No newline at end of file diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 796e699..1b94d7f 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -153,12 +153,19 @@ True True - + True - False - gtk-goto-last + True + False + True + right + + + @@ -529,7 +536,7 @@ True False - open-menu-symbolic + image-loading-symbolic @@ -639,6 +646,9 @@ True True + + + @@ -814,6 +824,9 @@ True True + + + @@ -1011,6 +1024,9 @@ True True + + + @@ -1136,6 +1152,9 @@ True True + + + @@ -1261,6 +1280,9 @@ True True + + + @@ -1630,12 +1652,20 @@ True True - + True - False - start - 0 - gtk-goto-first + True + False + True + left + + + + @@ -1789,10 +1819,17 @@ True False - + True False + 5 + 5 + 5 + 5 + 5 + 5 label + 0 False @@ -1801,10 +1838,20 @@ - + True - False - label + True + False + 5 + 5 + 5 + 5 + 7 + 5 + True + + + False @@ -1812,9 +1859,6 @@ 1 - - - False @@ -1826,63 +1870,11 @@ True False + vertical True False - vertical - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - label - - - False - True - 0 - - - - - True - True - False - 5 - 5 - 5 - 5 - 7 - 5 - True - - - - - - False - True - 1 - - - - - True - True - 0 - - - - - True - False - vertical True @@ -1894,6 +1886,7 @@ 5 5 label + 0 False @@ -1913,23 +1906,22 @@ 5 - False + True True 1 - True + False True - 1 + 0 True False - vertical True @@ -1941,6 +1933,7 @@ 5 5 label + 0 False @@ -1960,16 +1953,16 @@ 5 - False + True True 1 - True + False True - 2 + 1 @@ -1983,9 +1976,17 @@ True False - end - 5 - True + + + True + False + + + False + True + 0 + + gtk-cancel @@ -2003,11 +2004,12 @@ False True - 0 + end + 1 - + gtk-save True True @@ -2023,6 +2025,7 @@ False True + end 1 @@ -2030,7 +2033,7 @@ False True - 2 + 3 @@ -2040,7 +2043,7 @@ True False - + True False ubl-settings-bootloader @@ -2058,6 +2061,14 @@ + + + + + + + + False start diff --git a/ubl-settings-bootloader.pot b/ubl-settings-bootloader.pot index e0c0e5b..7b40070 100644 --- a/ubl-settings-bootloader.pot +++ b/ubl-settings-bootloader.pot @@ -17,6 +17,12 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +msgid "Edit" +msgstr "" + +msgid "Adding" +msgstr "" + msgid "Selecting the loading mode option" msgstr "" diff --git a/ubl-settings-bootloader_ru.po b/ubl-settings-bootloader_ru.po index 1ea37f9..952e3ff 100644 --- a/ubl-settings-bootloader_ru.po +++ b/ubl-settings-bootloader_ru.po @@ -17,6 +17,12 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +msgid "Edit" +msgstr "Редактирование" + +msgid "Adding" +msgstr "Добавление" + msgid "Selecting the loading mode option" msgstr "Выбор варианта режима загрузки"