diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 39fe799..670aa0b 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -31,6 +31,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissin -fstack-clash-protection -fcf-protection") set(SOURCE_FILES + menu_os.h + menu_os.cc ubl-settings-bootloader-cm.h ubl-settings-bootloader.h ubl-settings-bootloader.cc diff --git a/source/menu_os.cc b/source/menu_os.cc index 560d332..baa940e 100644 --- a/source/menu_os.cc +++ b/source/menu_os.cc @@ -1,26 +1,87 @@ #include "menu_os.h" -menu_os::menu_os(/* args */) +Menu_os::Menu_os(/* args */) { } -menu_os::~menu_os() +Menu_os::~Menu_os() { } -void menu_os::init() { - this->m_box(Gtk::ORIENTATION_VERTICAL); +void Menu_os::set_builder(Glib::RefPtr const& builder) { + this->builder = builder; + builder->get_widget("popoverMenuOS", popoverMenuOS); + builder->get_widget("revealerL1", revealerL1); + builder->get_widget("revealerL2", revealerL2); + builder->get_widget("boxALLL3", boxALLL3); +} + +void Menu_os::set_map(std::map > &map_list_os) { + this->map_list_os = map_list_os; +} + +void Menu_os::init() { + Gtk::Box *box_L1 = new Gtk::Box(); + vector vec_stuct_all_reviler; for (auto& [key, value]: map_list_os) { - Gtk::Button *button = new Gtk::button(); - Gtk::Revealer *revealer = new Gtk::Revealer(); - std::map map_buttons_level_2; + size_t len_data = value.size(); + struct map_reviler_L1 obj_map_reviler_L1; + struct map_reviler_L3 obj_map_reviler_L3; + vector vec_buttons; + vector vec_labels; + vector vec_names; + Gtk::Revealer* revealerL3; + Gtk::Box *box_L3 = new Gtk::Box(); + builder->get_widget("boxL1", obj_map_reviler_L1.boxL1); + builder->get_widget("lblRevL1", obj_map_reviler_L1.lblRevL1); + builder->get_widget("btnToL2AndLv3", obj_map_reviler_L1.btnToL2AndLv3); + builder->get_widget("revealerL3", revealerL3); + box_L1->pack_start(*obj_map_reviler_L1.btnToL2AndLv3, Gtk::PACK_SHRINK); + obj_map_reviler_L1.lblRevL1->set_text(key); + this->event_template(obj_map_reviler_L1.btnToL2AndLv3, obj_map_reviler_L1.lblRevL1, name_level_1); + // Todo : open level 3 + for (string& str_level_2: value) { + Gtk::Button* btn1; + Gtk::Label* lbl1; + builder->get_widget("btnToL3", btn1); + builder->get_widget("lblToL3", lbl1); + this->event_template(btn1, lbl1, name_level_3); + box_L3->pack_start(*btn1, Gtk::PACK_SHRINK); + lbl1->set_text(str_level_2); + vec_buttons.push_back(btn1); + vec_labels.push_back(lbl1); + vec_names.push_back(str_level_2); + } + boxALLL3->pack_start(*box_L3, Gtk::PACK_SHRINK); + revealerL3->set_reveal_child(true); + obj_map_reviler_L3.revealerL3 = revealerL3; + obj_map_reviler_L3.vec_buttons = vec_buttons; + obj_map_reviler_L3.vec_labels = vec_labels; + obj_map_reviler_L3.len_data = len_data; + obj_map_reviler_L3.box_L3 = box_L3; + obj_stuct_all_reviler.obj_map_reviler_L1 = obj_map_reviler_L1; + obj_stuct_all_reviler.obj_map_reviler_L3 = obj_map_reviler_L3; + vec_stuct_all_reviler.push_back(obj_stuct_all_reviler); + GtkWidget* rev_widget = GTK_WIDGET(revealerL1->gobj()); + gtk_container_add(GTK_CONTAINER(rev_widget), GTK_WIDGET(box_L1->gobj())); - map_buttons_level_1[key] = struct_menu_os_button{button, revealer} - } + + +} +void Menu_os::show() { + popoverMenuOS->show_all(); +} +void Menu_os::event() { + btnToLev1->signal_clicked().connect(sigc::mem_fun(*this, &Menu_os::to_l1)); +} + +void Menu_os::event_template(Gtk::Button* button, Gtk::Label* label, string& name_level) { + button->signal_clicked().connect([&]() {name_level = label->get_label();}); +} +void Menu_os::to_l1() { + revealerL1->set_reveal_child(true); + revealerL2->set_reveal_child(false); } -void menu_os::crete_menu_level_2(string key, std::map &map_buttons_level_2) { - map_buttons_level_2[key] = -} \ No newline at end of file diff --git a/source/menu_os.h b/source/menu_os.h index 4b5d1c5..7b06bbc 100644 --- a/source/menu_os.h +++ b/source/menu_os.h @@ -1,27 +1,51 @@ +#ifndef Menu_os_H +#define Menu_os_H #include +#include +#include +using namespace std; -class menu_os +class Menu_os { private: - struct struct_menu_os_button_v_2{ - Gtk::Button* button; + struct map_reviler_L1 { + Gtk::Box *boxL1; + Gtk::Label *lblRevL1; + Gtk::Button *btnToL2AndLv3; }; - - struct struct_menu_os_button{ - Gtk::Button* button; - Gtk::Revealer* revealer; - std::map map_buttons_level_2; + struct map_reviler_L3 { + Gtk::Revealer *revealerL3; + Gtk::Box *box_L3; + vector vec_buttons; + vector vec_labels; + vector vec_names; + size_t len_data; }; - std::map map_buttons_level_1; - std::map map_list_os; - Gtk::Box m_box; - Gtk::Revealer* level_1; + struct stuct_all_reviler { + struct map_reviler_L1 obj_map_reviler_L1; + struct map_reviler_L3 obj_map_reviler_L3; + }; + struct stuct_all_reviler obj_stuct_all_reviler; + vector vec_map_reviler_L1; + Glib::RefPtr builder; + std::map > map_list_os; + Gtk::Box *boxALLL3; + Gtk::Popover *popoverMenuOS; + Gtk::Revealer *revealerL1; + Gtk::Revealer *revealerL2; + Gtk::Button *btnToLev1; + string name_level_1 = ""; + string name_level_3 = ""; public: - menu_os(/* args */); - void set_popover(Gtk::Popover *popover); - void set_map(std::map map_list_os); - void crete_menu_level_2(string key, std::map &map_buttons_level_2); + Menu_os(/* args */); + void set_builder(Glib::RefPtr const& builder); + void set_map(std::map > &map_list_os); void init(); - ~menu_os(); + void show(); + void event_template(Gtk::Button* button, Gtk::Label* label, string& name_level); + void event(); + void to_l1(); + ~Menu_os(); }; +#endif diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc index 27a320e..66ec037 100755 --- a/source/ubl-settings-bootloader.cc +++ b/source/ubl-settings-bootloader.cc @@ -99,6 +99,10 @@ void MainWindow::settings(){ this->str_last_launched_os = this->pars_last_launched_os(); vector os_control_list; this->pars_os(os_control_list); + std::map> map_list_os = format_os_list(os_control_list); + obj_menu_os.set_builder(builder); + obj_menu_os.set_map(map_list_os); + obj_menu_os.show(); this->write_list_entry_os(os_control_list); this->download_local_cfg(); this->download_globl_cfg(); @@ -116,6 +120,38 @@ void MainWindow::settings(){ this->event(); } +map> MainWindow::format_os_list(vector &os_control_list) { + std::map> map_list_os; + set 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 vec_os; + vec_os.push_back(" "); + map_list_os[name_os] = vec_os; + } + } + set::iterator it = set_key.begin(); + for (int index = 1; it != set_key.end(); index++, it++) { + bool flag = false; + string name_os_buff = ""; + vector 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 = name_os; + } + } + if (flag) { + map_list_os[name_os_buff] = vec_os_values; + } + } + return map_list_os; +} + vector MainWindow::pars_os(vector &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'); diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index 35e984d..1524710 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -18,6 +18,7 @@ #include "load.h" #include #include "ubl-settings-bootloader-cm.h" +#include "menu_os.h" #ifdef WEBKIT_FOUND #include #endif @@ -225,6 +226,7 @@ class MainWindow : public Gtk::ApplicationWindow { Gtk::Label *lblDownloadMode; Lib_save::Save obj_save = Lib_save::Save(); Lib_Load::Load obj_load = Lib_Load::Load(); + Menu_os obj_menu_os = Menu_os(); vector vec_param_names; My_Process::My_Process_system obj_process_system = My_Process::My_Process_system(); My_Process::My_Process_call obj_process_call = My_Process::My_Process_call(); @@ -270,6 +272,7 @@ class MainWindow : public Gtk::ApplicationWindow { void fn_event_intelMax4(); void synopsis_show(); void set_data_cfg(); + std::map> format_os_list(vector &os_control_list); void set_active_boot_second(); void get_download_mode(std::map &map_temp); void view_add_cell(Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m , std::array, 5> &arr_view, size_t index); diff --git a/source/util.cc b/source/util.cc index 3fefeb4..b1ae35a 100644 --- a/source/util.cc +++ b/source/util.cc @@ -103,5 +103,6 @@ std::vector split(std::string text, char delim) { vec.push_back(line); } return vec; -} +} + } \ No newline at end of file diff --git a/source/util.h b/source/util.h index 23c75f7..12e6667 100644 --- a/source/util.h +++ b/source/util.h @@ -22,6 +22,7 @@ #include #include #include +#include using namespace std; diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 20b9f6e..08cf155 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -7,160 +7,7 @@ True - - False - - - True - True - True - - - - - True - True - True - - - True - False - - - True - False - label - - - False - True - 0 - - - - - True - True - False - True - right - - - - - - False - True - 1 - - - - - - - False - - - True - False - - - True - False - none - - - True - False - label - - - - - True - True - 0 - - - - - True - False - vertical - - - True - False - none - - - True - False - label111 - - - - - False - True - 0 - - - - - True - False - none - - - True - False - label2222 - - - - - False - True - 1 - - - - - True - False - none - - - True - False - label333 - - - - - False - True - 2 - - - - - False - True - 1 - - - - - - - False - - - - False False @@ -278,6 +125,52 @@ specified priority + + True + False + + + True + False + **** + + + True + True + 0 + + + + + True + True + True + + + True + False + gtk-missing-image + + + + + False + True + 1 + + + + + True + True + True + + + True + False + + + True False @@ -373,6 +266,159 @@ specified priority + + False + Внимание! + center + dialog + + + True + False + vertical + + + True + False + 5 + 5 + 5 + 5 + + + True + False + 5 + 5 + 5 + 5 + 6 + 6 + 50 + gtk-dialog-warning + + + True + True + 0 + + + + + 160 + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Warning! + + + True + True + 1 + + + + + False + True + 1 + + + + + OK + True + True + True + 5 + 5 + 5 + 5 + 3 + 3 + + + False + True + 1 + + + + + + + False + + + True + False + + + True + False + none + + + + + + True + True + 0 + + + + + True + False + none + True + + + True + False + vertical + + + True + True + True + + + True + False + gtk-missing-image + + + + + False + True + 0 + + + + + + + + + + False + True + 1 + + + + + 750 550 @@ -606,8 +652,19 @@ specified priority True False True + 5 + 5 + 5 + 5 + 6 + 6 + popoverMenuOS - + + True + False + open-menu-symbolic + @@ -1375,91 +1432,12 @@ specified priority - + + True False - Внимание! - center - dialog + none - - True - False - vertical - - - True - False - 5 - 5 - 5 - 5 - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 50 - gtk-dialog-warning - - - True - True - 0 - - - - - 160 - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Warning! - - - True - True - 1 - - - - - False - True - 1 - - - - - OK - True - True - True - 5 - 5 - 5 - 5 - 3 - 3 - - - False - True - 1 - - - +