diff --git a/.gitignore b/.gitignore index e367c25..6cbad38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,12 @@ -ubl-settings-bootloader.glade~ -test.cpp -.vscode +.vscode/ ubl-settings-bootloader -ubl-settings-bootloader_ru.po~ +*~ +build/ +compile/ +*# terminal-commands/ -compile/ \ No newline at end of file +source/ubl-cmake.h +vgcore* +.BUILD.md +.updatebuild.sh +.install.sh \ No newline at end of file diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 97e6b70..6974d60 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -3,20 +3,15 @@ project(ubl-settings-bootloader) find_package(PkgConfig REQUIRED) -pkg_check_modules(GTK3 REQUIRED gtk+-3.0) -include_directories(${GTK3_INCLUDE_DIRS}) -link_directories(${GTK3_LIBRARY_DIRS}) -add_definitions(${GTK3_CFLAGS_OTHER}) +pkg_check_modules(GTK REQUIRED gtk+-3.0) +include_directories(${GTK_INCLUDE_DIRS}) +link_directories(${GTK_LIBRARY_DIRS}) +add_definitions(${GTK_CFLAGS_OTHER}) -pkg_check_modules(GTKMM30 REQUIRED gtkmm-3.0) -include_directories(${GTKMM30_INCLUDE_DIRS}) -link_directories(${GTKMM30_LIBRARY_DIRS}) -add_definitions(${GTKMM30_CFLAGS_OTHER}) - -#pkg_check_modules(VTE291 REQUIRED vte-2.91) -#include_directories(${VTE291_INCLUDE_DIRS}) -#link_directories(${VTE291_LIBRARY_DIRS}) -#add_definitions(${VTE291_CFLAGS_OTHER}) +pkg_check_modules(VTE291 REQUIRED vte-2.91) +include_directories(${VTE291_INCLUDE_DIRS}) +link_directories(${VTE291_LIBRARY_DIRS}) +add_definitions(${VTE291_CFLAGS_OTHER}) find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0) @@ -29,10 +24,6 @@ if(WEBKIT_LIBRARIES_FOUND) add_definitions(${WEBKIT_CFLAGS_OTHER}) endif() -configure_file(ubl-cmake.in ubl-cmake.h) - -file(COPY ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h DESTINATION ./) - set(GRESOURCE_C resources.c) set(GRESOURCE_XML gresource.xml) @@ -66,41 +57,34 @@ add_custom_target( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C} ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ +add_definitions(-DVTE_INCLUDE) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \ -O2 -pipe -fno-plt -fexceptions \ -Wformat -Werror=format-security \ -fstack-clash-protection -fcf-protection") - string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) +string(FIND "${CMAKE_CXX_FLAGS}" "-D_FORTIFY_SOURCE" FORTIFY_FOUND) + +if(FORTIFY_FOUND EQUAL -1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") +endif() - if(FORTIFY_FOUND EQUAL -1) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-D_FORTIFY_SOURCE=2") - endif() - set(SOURCE_FILES - menu_os.h - menu_os.cc + ubl-settings-bootloader.c ubl-settings-bootloader.h - ubl-settings-bootloader.cc - save.h - save.cc - load.h - load.cc - my_process.h - my_process.cc - util.h - util.cc - ubl-util-standard.h - ubl-util-standard.c - main.cc - ${CMAKE_CURRENT_BINARY_DIR}/ubl-cmake.h) + ubl-strings.h + ) set(LIBRARIES ${GTK_LIBRARIES} - ${GTKMM30_LIBRARIES} ${WEBKIT_LIBRARIES} -# ${VTE291_LIBRARIES} - pthread) + ${UTILS_LIBRARIES} + ${VTE291_LIBRARIES} + pthread + ublsettings + ublsettings-gtk3 + ublsettingsui-gtk3) add_executable(${PROJECT_NAME} ${SOURCE_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${GRESOURCE_C}) @@ -111,5 +95,4 @@ set_source_files_properties( PROPERTIES GENERATED TRUE ) install(TARGETS ${PROJECT_NAME} DESTINATION bin) -add_dependencies(${PROJECT_NAME} dummy-resource) - +add_dependencies(${PROJECT_NAME} dummy-resource) \ No newline at end of file diff --git a/source/load.cc b/source/load.cc deleted file mode 100644 index 77873dc..0000000 --- a/source/load.cc +++ /dev/null @@ -1,34 +0,0 @@ -#include "load.h" - -namespace Lib_Load{ - void Load::set_count_error(int count_error) { - process.set_count_error(count_error); - } - string Load::get_cmd_error() { - return process.get_cmd_error(); - } - map& Load::get_load_data(std::map &map_temp, string cmd) { - string response = ""; - string key = ""; - string value = ""; - response = process.call_all_sections(cmd); - vector vec_str_key_value = Utils::split(response, '\n'); - for (const string ¶m: vec_str_key_value) { - if ((param.find("(null)") == std::string::npos) && (param.length() != 0 )) { - if (param.find("=") != std::string::npos) { - size_t index = param.find("="); - key = param.substr(0, index); - value = param.substr(index + 1, param.length()); - Utils::str_replace_all(value, " \"",""); - Utils::str_replace_all(value, "\"",""); - map_temp[key] = value; - } - } - } - return map_temp; - } - int Load::get_count_error() { - return process.get_count_error(); - } - -} \ No newline at end of file diff --git a/source/load.h b/source/load.h deleted file mode 100644 index b4d4a38..0000000 --- a/source/load.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LOAD_H -#define LOAD_H - -#include "my_process.h" -namespace Lib_Load{ - class Load { - - private: - string sections; - My_Process::My_Process_call process = My_Process::My_Process_call(); - public: - int get_count_error(); - void set_count_error(int count_error); - string get_cmd_error(); - map& get_load_data(std::map &map_temp, string str_flag_load); - }; - - -} -#endif \ No newline at end of file diff --git a/source/main.cc b/source/main.cc deleted file mode 100644 index 7ebc421..0000000 --- a/source/main.cc +++ /dev/null @@ -1,100 +0,0 @@ -#include "ubl-settings-bootloader.h" - - -void pars_flag(int index_start, int argc, char* argv[]); - -int main(int argc, char** argv) { - string str_argv= ""; - string str_cmd_argv = ""; - for (int i=1; i 1){ - str_argv = argv[1]; - } - bindtextdomain("ubl-settings-bootloader", "/usr/share/locale/"); - bind_textdomain_codeset("ubl-settings-bootloader", "UTF-8"); - textdomain("ubl-settings-bootloader"); - if (str_argv.find("--socket-id") != std::string::npos) { - auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); - auto builder = Gtk::Builder::create_from_resource(path_glade); - Glib::init(); - setlocale(LC_ALL, ""); - Glib::OptionContext context; - - CmdArgParser parser{ - "Socket ID", - "Command line argument for socket ID communication.", - "No help available, sorry" - }; - - context.set_main_group(parser); - context.parse(argc, argv); - - ::Window socketID = parser.GetSocketID(); - - // Handle plug: - SettingsPlug plug{socketID, builder}; - plug.show(); - - app->run(plug); - return 0; - } - else if (str_argv.find("-") != std::string::npos || argc == 1) { - int len_argv = 1; - auto app = Gtk::Application::create(len_argv, argv, "org.gtkmm.example.plug"); - auto builder = Gtk::Builder::create_from_resource(path_glade); - pars_flag(1, argc, argv); - MainWindow* wnd = nullptr; - builder->get_widget_derived("window", wnd); - GObject *window_obj = G_OBJECT(wnd->gobj()); - Utils::yon_window_config_setup(GTK_WINDOW(window_obj)); - Utils::yon_window_config_load(ui_config_path); - wnd->settings(); - wnd->event(); - wnd->set_menu_os_to_button(); - auto r = app->run(*wnd); - delete wnd; - return r; - } - -} -void pars_flag(int index_start, int argc, char* argv[]) { - string str_argv = ""; - for (int i = index_start; istr_last_launched_os = str_last_launched_os; -} - -void Menu_os::set_builder(Glib::RefPtr& builder, string path_glade) { - this->builder = builder; - this->path_glade = path_glade; - builder->get_widget("revealerL1", revealerL1); - builder->get_widget("revealerL2", revealerL2); - builder->get_widget("boxALLL3", boxALLL3); - builder->get_widget("boxLevel1", boxLevel1); - builder->get_widget("btnToLev1", btnToLev1); - revealerL1->set_reveal_child(true); -} - -void Menu_os::set_btnOpenMenuOS(Gtk::Button *btnOpenMenuOS) { - this->btnOpenMenuOS = btnOpenMenuOS; -} - -void Menu_os::set_map(vector>> &vec_list_os) { - this->vec_list_os = vec_list_os; -} - -void Menu_os::init() { - revealerL1->set_reveal_child(true); - revealerL2->set_reveal_child(true); - size_t index_l1 = 0; - string key = ""; - - for (tuple> tuple_os: vec_list_os) { - key = get<0>(tuple_os); - vector vec_value = get<1>(tuple_os); - map_menu_level_1[key] = new struct_menu_level1; - Glib::RefPtr builder_level_1 = Gtk::Builder::create_from_resource(path_glade); - builder_level_1->get_widget("lblRevL1", map_menu_level_1[key]->lblRevL1); - builder_level_1->get_widget("btnToL2AndLv3", map_menu_level_1[key]->btnToL2AndLv3); - builder_level_1->get_widget("boxMenuLevel1", map_menu_level_1[key]->boxMenuLevel1); - map_menu_level_1[key]->btnToL2AndLv3_css = map_menu_level_1[key]->btnToL2AndLv3->get_style_context(); - map_menu_level_1[key]->btnToL2AndLv3_css->add_class("noborder"); - map_menu_level_1[key]->builder = builder_level_1; - boxLevel1->pack_start(*(map_menu_level_1[key]->boxMenuLevel1)); - map_menu_level_1[key]->name = key; - this->html_last_launched_os(key, map_menu_level_1[key]->lblRevL1); - map_menu_level_1[key]->btnToL2AndLv3->signal_clicked().connect( - sigc::bind (sigc::mem_fun( *this, - &Menu_os::event_template), map_menu_level_1[key]->lblRevL1, - name_level_1, map_menu_level_1[key]->name)); - if (vec_value.size()!= 0) { - builder_level_1->get_widget("revealerL3", map_menu_level_1[key]->revealer); - builder_level_1->get_widget("boxLevel3", map_menu_level_1[key]->boxLevel3); - boxALLL3->pack_start(*(map_menu_level_1[key]->revealer)); - } - else { - map_menu_level_1[key]->revealer = NULL; - map_menu_level_1[key]->boxLevel3 = NULL; - } - size_t index_l3 = 0; - if (vec_value.size() == 0) { - builder_level_1->get_widget("btnToL2AndLv3Image", map_menu_level_1[key]->btnToL2AndLv3Image); - map_menu_level_1[key]->btnToL2AndLv3Image->hide(); - } - else { - builder_level_1->get_widget("btnToL2AndLv3Image", map_menu_level_1[key]->btnToL2AndLv3Image); - } - for (string& str_level_3: vec_value) { - auto builder_level_3 = Gtk::Builder::create_from_resource(path_glade); - map_menu_level_1[key]->vec_menu_level_3.push_back(new struct_menu_level_3); - builder_level_3->get_widget("btnToL3", - map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3); - builder_level_3->get_widget("lblToL3", - map_menu_level_1[key]->vec_menu_level_3[index_l3]->lblToL3); - map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3_css = - map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3->get_style_context(); - map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3_css->add_class("noborder"); - this->html_last_launched_os(str_level_3, map_menu_level_1[key]->vec_menu_level_3[index_l3]->lblToL3); - map_menu_level_1[key]->boxLevel3->pack_start( - *(map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3)); - map_menu_level_1[key]->vec_menu_level_3[index_l3]->btnToL3->signal_clicked().connect( - sigc::bind (sigc::mem_fun(*this, - &Menu_os::event_template), map_menu_level_1[key]->vec_menu_level_3[index_l3]->lblToL3, - name_level_3, map_menu_level_1[key]->name)); - map_menu_level_1[key]->vec_menu_level_3[index_l3]->builder_level_3 = builder_level_3; - index_l3 += 1; - - } - index_l1 += 1; - } -} -void Menu_os::close_revealer() { - for (auto& [key, values]: map_menu_level_1) { - if (values->revealer != NULL) { - values->revealer->set_reveal_child(false); - } - } -} - -void Menu_os::set_main_revealer(Gtk::Revealer *revealer) { - this->main_revealer = revealer; -} - -void Menu_os::show() { - revealerL1->set_reveal_child(true); - revealerL2->set_reveal_child(false); - this->close_revealer(); - main_revealer->set_reveal_child(true); -} -void Menu_os::event() { - btnToLev1->signal_clicked().connect(sigc::mem_fun(*this, &Menu_os::to_l1)); -} -void Menu_os::set_entry(Gtk::Entry *entry) { - this->entry = entry; -} -void Menu_os::event_template(Gtk::Label* label, string& name_level, string& key) { - name_level = label->get_label(); - key_global = key; - Utils::str_remove(name_level_1, ""); - Utils::str_remove(name_level_1, ""); - Utils::str_remove(name_level_3, ""); - Utils::str_remove(name_level_3, ""); - Gtk::Revealer *revealer = map_menu_level_1[key]->revealer; - if (&name_level == &name_level_1 && map_menu_level_1[key]->vec_menu_level_3.size() != 0) { - revealerL1->set_reveal_child(false); - revealerL2->set_reveal_child(true); - this->close_revealer(); - revealer->set_reveal_child(true); - name_level_3 = ""; - } - else if (map_menu_level_1[key]->vec_menu_level_3.size() == 0) { - entry->set_text(name_level_1); - name_level_3 = ""; - main_revealer->set_reveal_child(false); - } - else { - main_revealer->set_reveal_child(false); - entry->set_text(name_level_1 + name_level_3); - } -} -void Menu_os::to_l1() { - revealerL1->set_reveal_child(true); - revealerL2->set_reveal_child(false); - map_menu_level_1[key_global]->revealer->set_reveal_child(false); - key_global = ""; -} - -void Menu_os::html_last_launched_os(string name_os, Gtk::Label *label) { - string margin_name_os = ""; - size_t index_find = this->str_last_launched_os.find(">"); - size_t len_last_launched_os = this->str_last_launched_os.length(); - if (index_find != string::npos) { - string level_1 = this->str_last_launched_os.substr(0, index_find + 1); - string level_3 = this->str_last_launched_os.substr(index_find + 1, len_last_launched_os - 1); - if (name_os == level_1) { - margin_name_os = "" + name_os + ""; - label->set_markup(margin_name_os); - } - else if (name_os == level_3) { - margin_name_os = "" + name_os + ""; - label->set_markup(margin_name_os); - } - else { - label->set_text(name_os); - } - } - else { - if (this->str_last_launched_os == name_os) { - margin_name_os = "" + name_os + ""; - label->set_markup(margin_name_os); - } - else { - label->set_text(name_os); - } - } -} - diff --git a/source/menu_os.h b/source/menu_os.h deleted file mode 100644 index 29e3508..0000000 --- a/source/menu_os.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef Menu_os_H -#define Menu_os_H -#include -#include -#include -#include -#include "util.h" -using namespace std; - -class Menu_os -{ -private: - Glib::RefPtr builder; - vector>> vec_list_os; - - Gtk::Revealer *revealerL1; - Gtk::Revealer *revealerL2; - Gtk::Button *btnToLev1; - Gtk::Revealer *main_revealer; - string str_last_launched_os = ""; - private: - string name_level_1 = ""; - string name_level_3 = ""; - string key_global = ""; - Gtk::Entry *entry; - string path_glade = ""; - Gtk::Box *boxALLL3; - Gtk::Box *boxLevel1; - Gtk::Button *btnOpenMenuOS; - struct struct_menu_level_3 { - Gtk::Button *btnToL3; - Gtk::Label *lblToL3; - Glib::RefPtr builder_level_3; - Glib::RefPtr btnToL3_css; - }; - struct struct_menu_level1 { - Gtk::Label *lblRevL1; - Gtk::Button *btnToL2AndLv3; - Gtk::MenuButton* btnToL2AndLv3Image; - Gtk::Revealer *revealer; - Gtk::Box *boxLevel3; - Gtk::Box *boxMenuLevel1; - string name; - Glib::RefPtr builder; - vector vec_menu_level_3; - Glib::RefPtr btnToL2AndLv3_css; - }; - - std::map map_menu_level_1; - - -public: - Menu_os(/* args */); - void set_builder(Glib::RefPtr& builder, string path_glade); - void set_map(vector>> &vec_list_os); - void init(); - void show(); - void close_revealer(); - void settings(); - void html_last_launched_os(string name_os, Gtk::Label *label); - void set_last_launched_os(string str_last_launched_os); - void set_entry(Gtk::Entry *entry); - void event_template(Gtk::Label* label, string& name_level, string& key); - void event(); - void set_main_revealer(Gtk::Revealer *revealer); - void set_btnOpenMenuOS(Gtk::Button *btnOpenMenuOS); - void to_l1(); - ~Menu_os(); -}; -#endif - diff --git a/source/my_process.cc b/source/my_process.cc deleted file mode 100644 index 658afd5..0000000 --- a/source/my_process.cc +++ /dev/null @@ -1,84 +0,0 @@ -#include "my_process.h" -#include "util.h" - -namespace My_Process { -#define debug false -struct Utils::Result My_Process_call::call(string cmd) { - this->i_error_old = this->i_error; - struct Utils::Result obj_result; - string response = Utils::call(cmd); - obj_result.response = response; - if ((response.find("(null)") == std::string::npos) && (response.length() != 0 )) { - if (response.find("=") != std::string::npos) { - if (response.find("\n") != std::string::npos) { - response = response.substr(response.find("=")+1,response.length()); - response = response.substr(0,response.find("\n")); - obj_result.response = response; - obj_result.error = 0; - } - else { - obj_result.error = 1; - this->i_error += 1; - this->log_mess_error(cmd); - } - } - else { - obj_result.error = 2; - this->i_error += 1; - str_cmd_error = cmd; - this->log_mess_error(cmd); - } - } - else { - obj_result.error = 3; - this->i_error += 1; - str_cmd_error = cmd; - this->log_mess_error(cmd); - } - return obj_result; -} - -int My_Process::get_count_error() { - return this->i_error; -} - -void My_Process::set_back_count_error() { - this->i_error = this->i_error_old; -} - -void My_Process_system::call(string cmd, string thread_str = "") { - string cmd_new = cmd + " " + thread_str; - int response_cmd = system(cmd_new.c_str()); - if (response_cmd != 0) { - this->i_error += 1; - } -} - -void My_Process::set_count_error(int count_error) { - this->i_error = count_error; - this->str_cmd_error = ""; -} - -void My_Process::log_mess_error(string) { -} - -string My_Process::get_cmd_error() { - return this->str_cmd_error; -} -string My_Process_call::call_all_sections(string cmd) { - char buffer[PATH_MAX] = {0}; - std::string result = ""; - FILE* pipe = popen(cmd.c_str(), "r"); - if (!pipe) throw std::runtime_error("popen() failed!"); - try { - while (fgets(buffer, sizeof buffer, pipe) != NULL) { - result += buffer; - } - } catch (...) { - pclose(pipe); - throw; - } - pclose(pipe); - return result; -} -} \ No newline at end of file diff --git a/source/my_process.h b/source/my_process.h deleted file mode 100644 index f780860..0000000 --- a/source/my_process.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef SAVE_H -#define SAVE_H - -#include "util.h" -namespace My_Process{ -class My_Process { - public: - int i_error = 0; - int i_error_old = 0; - string str_cmd_error = ""; - int get_count_error(); - void set_count_error(int count_error); - void set_back_count_error(); - void log_mess_error(string); - string get_cmd_error(); -}; - - -class My_Process_call: public My_Process { - public: - struct Utils::Result call(string cmd); - string call_all_sections(string cmd); - -}; - -class My_Process_system: public My_Process { - public: - void call(string cmd, string thread_str); - -}; -} -#endif \ No newline at end of file diff --git a/source/save.cc b/source/save.cc deleted file mode 100644 index 040d72a..0000000 --- a/source/save.cc +++ /dev/null @@ -1,165 +0,0 @@ -#include "save.h" - -namespace Lib_save { - -vector Save::get_error() { - return this->vec_errors; -} - -bool Save::get_state_save() { - return this->flag_no_save; -} - -void Save::set_data_global(std::map &map_global) { - this->map_global = &map_global; -} - -void Save::set_data_local(std::map &map_local) { - this->map_local = &map_local; -} - -void Save::set_data_gui(std::map &map_gui) { - this->map_gui = &map_gui; -} - -bool Save::check_save(string flag_save, string key_name) { - std::map :: iterator iter_map_data; - std::map :: iterator iter_map_data_old; - std::map *map_data_old=NULL; - if (flag_save == "system") { - map_data_old = map_local; - } - else if (flag_save == "global") { - map_data_old = map_global; - } - iter_map_data = (*map_gui).find(key_name); - iter_map_data_old = (*map_data_old).find(key_name); - if ((*map_local).find(key_name) != (*map_local).end() && (*map_global).find(key_name) != (*map_global).end()) { - if ((*map_local)[key_name] != (*map_global)[key_name]) { - return true; - } - } - if (iter_map_data_old == (*map_data_old).end() && iter_map_data != (*map_gui).end()) { - return true; - } - else if (iter_map_data->second != iter_map_data_old->second) { - return true; - } - else if (iter_map_data->second.length() == 0 && iter_map_data_old->second.length() == 0) { - return false; - } - else if (iter_map_data->second == iter_map_data_old->second) { - return false; - } - else { - return true; - } - return true; -} - -bool Save::wrapper_check_save(string flag_save, string key_name) { - if (flag_save == "all") { - bool bool_flag_save = this->check_save("system", key_name); - if (bool_flag_save) { - return true; - } - return this->check_save("global", key_name); - } - else { - return this->check_save(flag_save, key_name); - } - -} - -int Save::get_count_error() { - return process.get_count_error(); -} - -string Save::get_cmd_error() { - return process.get_cmd_error(); -} - -void Save::set_count_error(int count_error) { - process.set_count_error(count_error); -} - -void Save::set_vec_params(vector& vec_param_names) { - this->vec_param_names = &vec_param_names; -} - -void Save::save(string sections, string str_flag_save) { - string key = ""; - string value = ""; - string cmd = ""; - string str_error = ""; - this->flag_no_save = true; - for (const auto &key: *vec_param_names) { - if (map_gui->find(key) != map_gui->end()) { - value = (*map_gui)[key]; - if (this->wrapper_check_save(str_flag_save, key)) { - if (value.length() != 0) { - cmd = "ubconfig --target " + str_flag_save + " set " + sections + " " + - key + "=\"" + value + "\""; - } - else if (value.length() == 0) { - cmd = "ubconfig --target " + str_flag_save + " remove " + sections + " " + key; - } - else { - cmd = ""; - } - if (cmd.length() != 0) { - process.call(cmd, ""); - this->flag_no_save = false; - str_error = process.get_cmd_error(); - if (str_error.length() != 0) { - this->vec_errors.push_back(str_error); - str_error = ""; - } - } - } - } - - } -} -void Save::save_one_cmd(string cmd1, string cmd_remove, string str_flag_save) { - string key = ""; - string value = ""; - string cmd = ""; - this->flag_no_save = true; - cmd = cmd1; - string remove = cmd_remove; - for (const auto &key: *vec_param_names) { - if (map_gui->find(key) != map_gui->end()) { - value = (*map_gui)[key]; - if (this->wrapper_check_save(str_flag_save, key)) { - if (value.length() != 0) { - cmd = cmd + key + "=\"" + value + "\" "; - } - else if (value.length() == 0) { - remove = remove + key + " "; - } - - } - } - } - if (cmd.length() != cmd1.length()) { - this->template_save(cmd); - } - if (cmd_remove.length() != remove.length()) { - this->template_save(remove); - } -} - -void Save::template_save(string cmd) { - string str_error = ""; - process.call(cmd, ""); - this->flag_no_save = false; - str_error = process.get_cmd_error(); - if (str_error.length() != 0) { - this->vec_errors.push_back(str_error); - str_error = ""; - } - -} - -} diff --git a/source/save.h b/source/save.h deleted file mode 100644 index b268b31..0000000 --- a/source/save.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef MY_PROCESS_H -#define MY_PROCESS_H - -#include "my_process.h" -namespace Lib_save { - -class Save { -private: - std::map *map_global; - std::map *map_local; - std::map *map_gui; - vector vec_errors; - vector* vec_param_names; - My_Process::My_Process_system process = My_Process::My_Process_system(); - bool flag_no_save; - void template_save(string cmd); -public: - void set_data_global(std::map &map_global); - void set_data_local(std::map &map_local); - void set_data_gui(std::map &map_gui); - bool check_save(string flag_save, string key_name); - bool get_state_save(); - bool wrapper_check_save(string flag_save, string key_name); - void save_one_cmd(string cmd1, string cmd_remove, string str_flag_save); - int get_count_error(); - string get_cmd_error(); - void set_count_error(int count_error); - void set_vec_params(vector& vec_param_names); - void save(string sections, string str_flag_save) ; - vector get_error(); -}; -} -#endif \ No newline at end of file diff --git a/source/ubl-cmake.in b/source/ubl-cmake.in deleted file mode 100644 index 17ba454..0000000 --- a/source/ubl-cmake.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND \ No newline at end of file diff --git a/source/ubl-settings-bootloader.c b/source/ubl-settings-bootloader.c new file mode 100644 index 0000000..fdfefcc --- /dev/null +++ b/source/ubl-settings-bootloader.c @@ -0,0 +1,166 @@ +#include "ubl-settings-bootloader.h" + +config main_config; + +//functions + +void on_save_done(main_window *, config_str output, int size){ + char *final_output = yon_char_parsed_to_string(output,size,""); + if (final_output){ + printf("%s\n",final_output); + free(final_output); + } + yon_char_parsed_free(output,size); + textdomain(template_ui_LocaleName); + switch (main_config.save_config){ + case 0: + yon_ubl_status_box_render(GLOBAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 1: + yon_ubl_status_box_render(LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + case 2: + yon_ubl_status_box_render(GLOBAL_LOCAL_SAVE_SUCCESS_LABEL,BACKGROUND_IMAGE_SUCCESS_TYPE); + break; + } + textdomain(LocaleName); + +} + +void yon_load_proceed(YON_CONFIG_TYPE type){ + yon_config_clean(); + if (!yon_char_is_empty(config_get_default_command)) + yon_config_load_config(YON_CONFIG_DEFAULT,config_get_default_command,NULL); + if (type==YON_CONFIG_GLOBAL){ + yon_config_load_config(type,config_get_global_command,NULL); + } else if (type==YON_CONFIG_LOCAL){ + yon_config_load_config(type,config_get_local_command,NULL); + } else if (type==YON_CONFIG_CUSTOM){ + char *path=""; + textdomain(template_ui_LocaleName); + GtkWidget *dialog = gtk_file_chooser_dialog_new(template_app_information.app_title,NULL,GTK_FILE_CHOOSER_ACTION_SAVE,CANCEL_LABEL,GTK_RESPONSE_CANCEL,OPEN_LABEL,GTK_RESPONSE_ACCEPT,NULL); + textdomain(LocaleName); + gtk_window_set_icon_name(GTK_WINDOW(dialog),"com.ublinux.ubl-settings-services"); + gtk_window_set_title(GTK_WINDOW(dialog),TITLE_LABEL); + GtkFileFilter *filter = gtk_file_filter_new(); + gtk_file_filter_add_pattern(filter,"*.ini"); + gtk_file_filter_set_name(filter, "*.ini"); + gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter); + gtk_widget_show(dialog); + int response = gtk_dialog_run(GTK_DIALOG(dialog)); + if (response == GTK_RESPONSE_ACCEPT){ + char *file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (!yon_char_is_empty(file)){ + path=file; + } + gtk_widget_destroy(dialog); + } else { + gtk_widget_destroy(dialog); + } + char *command = yon_config_get_custom_command(path); + yon_config_load_config(type,command,NULL); + } +} + +void yon_interface_update(main_window *){ + +} +// standard functions + +/**config_init() + * [EN] + * + * [RU] + * Функция инициализации всех параметров конфигурации +*/ +void config_init(){ + main_config.always_open_documentation=0; + main_config.socket_id=-1; + main_config.save_socket_id=-1; + main_config.load_socket_id=-1; + main_config.lock_help=0; + main_config.lock_help=0; + main_config.lock_load_global=0; + main_config.lock_save_global=0; + main_config.lock_save_local=0; + main_config.load_mode=1; +} + +/**yon_main_window_complete(main_window *widgets) + * [EN] + * + * [RU] + * Функция настройки основного окна приложения. [widgets] - структура со стандартным интерфейсом. +*/ +void yon_main_window_complete(main_window *widgets){ + widgets = yon_remalloc(widgets,sizeof(main_window)); + GtkBuilder *builder = gtk_builder_new_from_resource(glade_path); + gtk_box_pack_start(GTK_BOX(widgets->InterfaceBox),yon_gtk_builder_get_widget(builder,"BoxMain"),1,1,0); + // Custom widgets configuration + { + widgets->BootRingtoneAddButton = yon_gtk_builder_get_widget(builder,"BootRingtoneAddButton"); + widgets->BootRingtoneEditButton = yon_gtk_builder_get_widget(builder,"BootRingtoneEditButton"); + widgets->BootRingtoneRemoveButton = yon_gtk_builder_get_widget(builder,"BootRingtoneRemoveButton"); + widgets->BootRingtoneTree = yon_gtk_builder_get_widget(builder,"BootRingtoneTree"); + widgets->BootUsersAddButton = yon_gtk_builder_get_widget(builder,"BootUsersAddButton"); + widgets->BootUsersEditButton = yon_gtk_builder_get_widget(builder,"BootUsersEditButton"); + widgets->BootUsersRemoveButton = yon_gtk_builder_get_widget(builder,"BootUsersRemoveButton"); + widgets->BootUsersTree = yon_gtk_builder_get_widget(builder,"BootUsersTree"); + widgets->BoxMain = yon_gtk_builder_get_widget(builder,"BoxMain"); + widgets->boxWidgetAll = yon_gtk_builder_get_widget(builder,"boxWidgetAll"); + widgets->btnAbout = yon_gtk_builder_get_widget(builder,"btnAbout"); + widgets->btnHelp = yon_gtk_builder_get_widget(builder,"btnHelp"); + widgets->btnLoadGlob = yon_gtk_builder_get_widget(builder,"btnLoadGlob"); + widgets->btnLoadLocal = yon_gtk_builder_get_widget(builder,"btnLoadLocal"); + widgets->btnOpenMenuOS1 = yon_gtk_builder_get_widget(builder,"btnOpenMenuOS1"); + widgets->btnSaveGlob = yon_gtk_builder_get_widget(builder,"btnSaveGlob"); + widgets->btnSaveLocal = yon_gtk_builder_get_widget(builder,"btnSaveLocal"); + widgets->btnSaveLocalGlob = yon_gtk_builder_get_widget(builder,"btnSaveLocalGlob"); + widgets->chbLoadVariantSelectionTimer = yon_gtk_builder_get_widget(builder,"chbLoadVariantSelectionTimer"); + widgets->cmbDownloadMode = yon_gtk_builder_get_widget(builder,"cmbDownloadMode"); + widgets->CommandLineParametersEntry = yon_gtk_builder_get_widget(builder,"CommandLineParametersEntry"); + widgets->entrListOS = yon_gtk_builder_get_widget(builder,"entrListOS"); + widgets->InputTerminalEntry = yon_gtk_builder_get_widget(builder,"InputTerminalEntry"); + widgets->InputTerminalTree = yon_gtk_builder_get_widget(builder,"InputTerminalTree"); + widgets->KernelParametersTree = yon_gtk_builder_get_widget(builder,"KernelParametersTree"); + widgets->lblInfoDefaultDonw = yon_gtk_builder_get_widget(builder,"lblInfoDefaultDonw"); + widgets->lblInfoSeconds = yon_gtk_builder_get_widget(builder,"lblInfoSeconds"); + widgets->list_os = yon_gtk_builder_get_widget(builder,"list_os"); + widgets->menu = yon_gtk_builder_get_widget(builder,"menu"); + widgets->menu1 = yon_gtk_builder_get_widget(builder,"menu1"); + widgets->menu2 = yon_gtk_builder_get_widget(builder,"menu2"); + widgets->OutputTerminalEntry = yon_gtk_builder_get_widget(builder,"OutputTerminalEntry"); + widgets->OutputTerminalTree = yon_gtk_builder_get_widget(builder,"OutputTerminalTree"); + widgets->overMenuOS = yon_gtk_builder_get_widget(builder,"overMenuOS"); + widgets->spbSecond = yon_gtk_builder_get_widget(builder,"spbSecond"); + + } + yon_root_button_setup((template_main_window*)widgets,main_config.launch_arguments,main_config.launch_size); + yon_save_window_set_postsave_function(on_save_done,widgets); +} + +int main(int argc, char *argv[]){ + local=setlocale(LC_ALL, ""); + textdomain (LocaleName); + config_init(); + + yon_ubl_connect_config((_template_config*)&main_config); + yon_ubl_window_init(TITLE_LABEL,TITLE_INFO_LABEL,LocaleName,CssPath,LocaleName,version_application,WIKI_LINK); + config_str unfound = NULL; + int size=0; + yon_ubl_setup_arguments(argc,argv,&unfound,&size,NULL); + gtk_init(&argc,&argv); + template_main_window *widgets = yon_ubl_window_setup(); + yon_main_window_complete((main_window*)widgets); + char *path = yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL); + yon_window_config_load(path); + main_config.launch_arguments=yon_char_parsed_copy(argv,argc); + main_config.launch_size=argc; + if (getuid()!=0){ + textdomain(template_ui_LocaleName); + yon_ubl_status_box_render(ROOT_WARNING_LABEL,BACKGROUND_IMAGE_FAIL_TYPE); + textdomain(LocaleName); + } + gtk_main(); + return 0; +} diff --git a/source/ubl-settings-bootloader.cc b/source/ubl-settings-bootloader.cc deleted file mode 100644 index 8c08211..0000000 --- a/source/ubl-settings-bootloader.cc +++ /dev/null @@ -1,1573 +0,0 @@ - -#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; - -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 builder) - : Gtk::Plug{p_socketID} { - MainWindow* wnd = nullptr; - builder->get_widget_derived("window", wnd); - GObject *window_obj = G_OBJECT(wnd->gobj()); - Utils::yon_window_config_setup(GTK_WINDOW(window_obj)); - Utils::yon_window_config_load(ui_config_path); - builder->get_widget("plugBox", plugBox); - wnd->settings(); - wnd->set_plug(plugBox); - wnd->event(); - plugBox->get_parent()->remove(*plugBox); - add(*plugBox); - wnd->set_menu_os_to_button(); - 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_resource(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() { - gtk_entry_set_input_purpose(GTK_ENTRY(entryCol2->gobj()) ,GTK_INPUT_PURPOSE_FREE_FORM); - 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() { - gtk_entry_set_input_purpose(GTK_ENTRY(entryCol2->gobj()),GTK_INPUT_PURPOSE_FREE_FORM); - 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() { - gtk_entry_set_input_purpose(GTK_ENTRY(entryCol2->gobj()),GTK_INPUT_PURPOSE_PASSWORD); - entryCol2->set_visibility(0); - 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() { - gtk_entry_set_input_purpose(GTK_ENTRY(entryCol2->gobj()),GTK_INPUT_PURPOSE_PASSWORD); - btnSaveEditSave->set_sensitive(false); - chkAddEdit->set_active(false); - entryCol1->set_text(""); - entryCol2->set_text(""); - entryCol2->set_visibility(0); - 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) - : Gtk::ApplicationWindow(obj), builder{builder} { - this->builder = builder; -} - -MainWindow::MainWindow(Glib::RefPtr 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); - overMenuOS->add_overlay(*revilerMenuOS); - btnBoxAboutDialog->set_visible(false); - ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I); - 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 os_control_list; - this->pars_os(os_control_list); - this->download_local_cfg(); - vector>> vec_list_os = format_os_list(os_control_list); - obj_menu_os.set_main_revealer(revilerMenuOS); - 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(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_menu_os_to_button() { - obj_menu_os.set_btnOpenMenuOS(btnOpenMenuOS1); -} - -void MainWindow::set_plug(Gtk::Widget *plug) { - this->plug = plug; -} - -vector>> MainWindow::format_os_list(vector &os_control_list) { - vector>> vec_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; - tuple> t1(name_os, vec_os); - vec_list_os.push_back(t1); - } - } - 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 = *it; - } - } - if (flag) { - tuple> t1(name_os_buff, vec_os_values); - vec_list_os.push_back(t1); - } - } - return vec_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'); - os_control_list.insert(os_control_list.begin(),LAST_MODE_LABEL); - 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; - 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; - 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; - entryIPT->set_text(str_flags); - } - } -} - -void MainWindow::get_download_mode(std::map &map_temp) { - std::map :: 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 &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 &list_store, string key) { - string cmds_old = map_cmd_selection[key]; - string cmds = ""; - string param = ""; - vector 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 MainWindow::read_file_and_view(string file_name ,Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m) { - std::array, 5> arr_view = Utils::read_csv(string(path_resources) + "/" + file_name); - std::vector 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 list_store_m , std::array, 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("btnOpenMenuOS1", btnOpenMenuOS1); - 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); - builder->get_widget("revilerMenuOS", revilerMenuOS); - builder->get_widget("overMenuOS", overMenuOS); - - -} - -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); - 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); - 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); - btnOpenMenuOS1->set_tooltip_text(str_tooltip_boot_menu); -} - -vector MainWindow::get_setting_entry_all(string key, std::map * map_temp) { - vector vec_params; - std::map :: 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 &list_store, Gtk::Entry &entry, std::vector &vec_Option, int size, string key) { - flag_blocked_tree_view = true; - vector vec_params; - std::string text = entry.get_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); - } - 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 &map_temp) { - std::map :: 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();}); - btnOpenMenuOS1->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 treeViewKernelModel = treeViewKernel->get_model(); - treeViewKernelModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_kernel)); - Glib::RefPtr treeViewIPTModel = treeViewIPT->get_model(); - treeViewIPTModel->signal_row_changed().connect(sigc::mem_fun(*this, &MainWindow::item_selected_IPT)); - Glib::RefPtr 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) { - iter_user_del = this->treeViewUser->get_selection()->get_selected(); - 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; - obj_view_edit_add_table.old_data.column1=""; - obj_view_edit_add_table.old_data.column2=""; - } - } -} -void MainWindow::wrapper_edit_melody(bool check, string column1, string column2) { - iter_melody_del = this->treeViewMelody->get_selection()->get_selected(); - 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; - obj_view_edit_add_table.old_data.column1=""; - obj_view_edit_add_table.old_data.column2=""; - } - } -} - -void MainWindow::wrapper_edit_show_user() { - iter_user_del = this->treeViewUser->get_selection()->get_selected(); - 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() { - iter_melody_del = this->treeViewMelody->get_selection()->get_selected(); - 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(); - } - 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); - this->get_download_mode(map_cmd_selection); - } - else { - cmbDownloadMode->remove_all(); - cmbDownloadMode->append(loading_animation_with); - cmbDownloadMode->append(loading_animation_without); - cmbDownloadMode->append(no_loading_animation); - cmbDownloadMode->append(lack_loading_animation); - this->get_download_mode(map_cmd_selection); - } - } - 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 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 { - } - 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 &map_temp) { - treeViewUser->remove_all_columns(); - list_store_user = Gtk::ListStore::create(m_columns_user); - treeViewUser->set_model(list_store_user); - vector 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 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 &map_temp) { - Glib::RefPtr treeViewUser_model = treeViewUser->get_model(); - string names_superusers = map_temp["GRUB_SUPERUSERS"]; - vector 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 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 &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> vec_melody = Utils::read_csv_melody(path_name); - bool flag = false; - string cgf_code_melody = map_temp["GRUB_PLAY"]; - for (tuple& 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 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() { - iter_user_del = this->treeViewUser->get_selection()->get_selected(); - 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 = true; - 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 = true; -} - -void MainWindow::remove_melody() { - iter_melody_del = this->treeViewMelody->get_selection()->get_selected(); - 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 = true; - 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 = true; -} - -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 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 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 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 &map_temp) { - std::map :: 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 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_replace_all(str_flags, " \"", "\""); - map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags; - str_flags = entryIPT->get_text(); - Utils::str_replace_all(str_flags, " \"", "\""); - map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags; - str_flags = entryOTT->get_text(); - 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 (strstr(name_os.c_str(),LAST_MODE_LABEL)){ - map_cmd_selection["GRUB_DEFAULT"] = ""; - } else 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* 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 &map_temp, string key) { - if (map_temp.find(key) != map_temp.end()) { - string value = map_temp[key]; - Utils::str_replace_all(value, "\"", ""); - entry->set_text(value); - } - else { - entry->set_text(""); - } -} - -void MainWindow::init_dict(string flag_load) { - std::map 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 &map_cmd, Glib::RefPtr &list_store, vector &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 vec_params = Utils::split(value, ' '); - for (auto &name: vec_params) { - this->set_row(list_store, size, name, true); - } -} - -void MainWindow::set_row(Glib::RefPtr &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 - if (my_web_kit) { - gtk_widget_destroy(GTK_WIDGET(my_web_kit)); - } - my_web_kit = WEBKIT_WEB_VIEW(webkit_web_view_new()); - three = Glib::wrap(GTK_WIDGET(my_web_kit)); - wndWeb->add(*three); - webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); - wndWeb->show_all(); - webkit_web_view_load_uri(my_web_kit, _(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_s); - std::unique_ptr 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() { -} - -void MainWindow::add_CSS() { - Glib::RefPtr cssProvider = Gtk::CssProvider::create(); - cssProvider->load_from_resource(path_css); - Glib::RefPtr styleContext = Gtk::StyleContext::create(); - Glib::RefPtr 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 boxButton_css = boxButton->get_style_context(); - Glib::RefPtr boxSave_css = boxSave->get_style_context(); - boxInfo = boxInfoError->get_style_context(); - imgBG->set_from_resource(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; - -} - - - - - - diff --git a/source/ubl-settings-bootloader.h b/source/ubl-settings-bootloader.h index fdc91af..15f3b4e 100644 --- a/source/ubl-settings-bootloader.h +++ b/source/ubl-settings-bootloader.h @@ -1,497 +1,111 @@ - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include +#include +#include +#include #include -#include -#include -#include "ubl-util-standard.c" -#include "util.h" -#include "save.h" -#include "load.h" -#include -#include "../compile/ubl-cmake.h" -#include "menu_os.h" -#ifdef WEBKIT_FOUND -#include -#endif - -#include "my_process.h" -using namespace std; - -extern int socket_ext_id_I; -extern int socket_trd_id_I; -extern string version_application; -extern bool flag_save; -extern bool flag_save_local; -extern bool flag_save_global; -extern bool flag_load_global; -extern bool flag_lock_help; -void me_thread(string cmd); - -#define minimal_width 640 -#define minimal_height 500 -#define str_tooltip_add_user _("Add user") -#define str_tooltip_del_user _("Delete user") -#define str_tooltip_add_melody _("Add melody") -#define str_tooltip_del_melody _("Delete melody") -#define str_tooltip_boot_menu _("Selecting the loading mode option") -#define copyright _("Copyright © UBSoft LLC, 2022 - ") -#define name_app _("System boot") -#define website _("https://wiki.ublinux.com") -#define project_Home_page _("Project homepage") -#define configuring_system_boot _("Configuring system boot parameters") -#define system_boot _("System boot setup") -#define str_about _("About System boot") -#define command_line_parameters _("Command line parameters:") -#define load_default _("Load default:") -#define seconds _("seconds") -#define download_menu _("Download menu") -#define terminal_for_input _("Terminal for input") -#define terminal_for_output _("Terminal for output") -#define boot_selection_menu_timer _("Boot selection menu timer:") -#define str_help _("Help") -#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") -#define load_global _("Load global configuration") -#define load_local _("Load local configuration") -#define read_online _("Read online") -#define str_cancel _("Cancel") -#define always_redirect _("Always redirect") -#define boot_screen_display_mode _("Boot screen display mode:") -#define no_loading_animation_800_600 _("No loading animation,\nfull log") -#define no_loading_animation _("No loading animation, full log") -#define boot_menu_user_name _("Boot menu user name:") -#define boot_menu_user_password _("Boot menu user password:") -#define last_successful_upload _("Last successful upload") -#define read_documentation_web _("Would you like to read documentation in the Web?") -#define redirected_documentation _("You will be redirected to documentation website where documentation is\n""translated and supported by community.") -#define user_name_configuration_editing_code _("User name to enter boot configuration editing mode") -#define user_password_configuration_edit_mode _("User password to enter boot configuration edit mode") -#define loading_animation_with _("Loading animation with log") -#define loading_animation_without _("Loading animation without log") -#define lack_loading_animation_800_600 _("Lack of loading animation with the\noutput of the abbreviated log") -#define lack_loading_animation _("Lack of loading animation with the output of the abbreviated log") -#define web_url _("https://wiki.ublinux.com") -#define enter_password _("Enter your password") -#define enter_login _("Enter login") -#define str_version _("ubl-settings-bootloader version: ") -#define local_read_error _("Local configuration reading error") -#define global_read_error _("Global configuration read error") -#define local_write_error _("Local configuration write error") -#define global_write_error _("Global configuration write error") -#define error_save_all _("Error saved local and global configuration") -#define local_load_ok _("Local configuration downloaded successfully") -#define global_load_ok _("Global configuration downloaded successfully") -#define local_ok_written _("Local configuration successfully written") -#define global_ok_written _("Global configuration successfully written") -#define successfully_save_all _("Successfully saved local and global configuration") -#define nothing_save _("Nothing to save!") -#define program_as_root _("The program must be run as root") -#define str_active _("Active") -#define str_option _("Option") -#define str_title _("Title") -#define str_user _("User") -#define str_password _("Password") -#define str_administrator _("Administrator") -#define str_select _("Select") -#define str_melody_code _("Melody code") -#define str_ringtone_at_startup _("Ringtone at startup") -#define str_description _("Description") -#define str_title_Boot_Menu_Users _("Boot Menu Users") -#define str_title_Ringtone_Startup _("Ringtone at startup") -#define str_null_melody_name _("Enter the name and code of the tune in the \"Ringtone at startup\" field") -#define str_null_username _("Enter name and password in the \"Boot Menu Users\" field") -#define str_help_h _("GTK settings bootloader for UBLinux\n" \ - "\n" \ - "Usage: ubl-settings-bootloader [OPTIONS...]\n" \ - "Options:\n" \ - " -h, --help\t Show this help\n" \ - " -V, --version\t Show package version\n" \ - " --lock-help Lock utility help\n" \ - " --lock-save Lock saving local and global configuration\n" \ - " --lock-save-local Lock save global configuration\n" \ - " --lock-save-global Lock load global configuration\n" \ - " --lock-load-global Lock load global configuration\n") -#define no_recognized _("Argument not recognized\n") - -#define global_load "ubconfig --default --source global get boot" -#define system_load "ubconfig --default --source system get boot" -#define all_save "ubconfig set boot " -#define all_remove "ubconfig remove boot " -#define global_save "ubconfig --target global --noexecute set boot " -#define system_save "ubconfig --target system set boot " -#define global_remove "ubconfig --target global --noexecute remove boot " -#define system_remove "ubconfig --target system remove boot " -#define const_link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-bootloader" -#define cmd_xdg "xdg-open " -#define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" -#define icon_checked "com.ublinux.ubl-settings-bootloader.checked" -#define icon_warning "com.ublinux.ubl-settings-bootloader.warning" -#define kernel_csv "grub-cmdline-linux.csv" -#define melody_csv "grub-play.csv" -#define IPT_csv "grub-terminal-input.csv" -#define OTT_csv "grub-terminal-output.csv" -#define path_app "/usr/bin/" -#define path_glade "/com/ublinux/ui/ubl-settings-bootloader.glade" -#define path_css "/com/ublinux/css/ubl-settings-bootloader.css" -#define app_name "ubl-settings-bootloader" -#define path_resources "/usr/share/ubl-settings-bootloader" -#define path_img_head_background "/com/ublinux/images/ubl-settings-bootloader-banner.png" -#define ui_config_path Utils::yon_char_unite(Utils::yon_ubl_user_get_home_directory(),"/.config/",app_name,"/",app_name,".conf",NULL) - -#define cmd_pars_list_os "/usr/lib/ublinux/scripts/grub-functions exec_get_all_menuentry" -#define cmd_last_launched_os "/usr/lib/ublinux/scripts/grub-functions exec_get_last_menuentry" -#define info_box_ok_css "boxInfoMessOK" -#define info_box_error_css "boxInfoMessError" -#define str_add_user _("User added") -#define str_add_melody _("Melody added") -#define str_del_user _("User deleted") -#define str_del_melody _("Melody deleted") -#define LAST_MODE_LABEL _("Last succeeded load mode") - -class View_edit_add_table { -private: - Glib::RefPtr builder; - Gtk::Window* wndAddEditData; - Gtk::Button* btnCancel; - Gtk::Button* btnSaveEditSave; - Gtk::CheckButton* chkAddEdit; - Gtk::Entry* entryCol1; - Gtk::Entry* entryCol2; - Gtk::Label* lblAddEditCheckBox; - Gtk::Label* lblAddEditCol1; - Gtk::Label* lblAddEditCol2; - Gtk::Label* lblEditAddHead; - bool flag_save = false; - string mode_show = ""; - -public: - struct struct_data { - bool check; - string column1; - string column2; - }; - 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 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(); -}; - - -class CmdArgParser : public Glib::OptionGroup -{ -public: - CmdArgParser(const std::string &p_name, const std::string &p_description, const std::string &p_help); - ::Window GetSocketID() const; - -private: - int m_socketID = 0; -}; - -class MainWindow : public Gtk::ApplicationWindow -{ -public: - class ModelColumns : public Gtk::TreeModel::ColumnRecord - { - public: - ModelColumns() - { - add(check_button), add(name); - add(description); - } - // Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn description; - }; - class ModelColumnsUser : public Gtk::TreeModel::ColumnRecord - { - public: - ModelColumnsUser() - { - add(check_button), add(name); - add(password); - } - // Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn name; - Gtk::TreeModelColumn password; - }; - class ModelColumnsMelody : public Gtk::TreeModel::ColumnRecord - { - public: - ModelColumnsMelody() - { - add(check_button), add(title); - add(melody_code); - } - // Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn check_button; - Gtk::TreeModelColumn title; - Gtk::TreeModelColumn melody_code; - }; - - ModelColumns m_columns; - ModelColumnsUser m_columns_user; - ModelColumnsMelody m_columns_melody; - Glib::RefPtr builder; - Gtk::Widget *plug = NULL; - Gtk::SpinButton *spbSecond; - Gtk::Label *lblBootMenuUsers; - Gtk::Label *lblRingtoneStartup; - Gtk::Label *lblInfoSeconds; - Gtk::Label *lblInfoDefaultDonw; - Gtk::Label *lblInfoCommand; - Gtk::Label *lblInfoCommand1; - Gtk::Label *lblHeaderAboutTopic; - Gtk::Label *lblInfoCommand2; - Gtk::Label *lblLoadMenu; - Gtk::Label *lblInfoInputTerminal; - Gtk::Label *lblInfoOutputTerminal; - Gtk::Label *lblHeaderName; - Gtk::Label *lblInfoHead; - Gtk::Button *btnAddUser; - Gtk::Button *btnRemoveUser; - Gtk::Button *btnAddMusic; - Gtk::Button *btnRemoveMusic; - Gtk::Button *btnEditUser; - Gtk::Button *btnEditMusic; - Gtk::CheckButton *chbVgaText; - Gtk::CheckButton *chbLoadVariantSelectionTimer; - Gtk::Entry *entryKernel; - Gtk::Entry *entryIPT; - Gtk::Entry *entryOTT; - Gtk::Box *boxColor; - Gtk::AboutDialog *aboutWindows; - Gtk::MenuItem *btnAbout; - Gtk::MenuItem *btnHelp; - Gtk::MenuItem *btnSaveLocalGlob; - Gtk::MenuItem *btnSaveLocal; - Gtk::MenuItem *btnSaveGlob; - Gtk::MenuItem *btnLoadGlob; - Gtk::MenuItem *btnLoadLocal; - Gtk::Button *btnLoad; - Gtk::Button *btnSave; - Gtk::Button *btnSettings; - Gtk::Widget *boxButton; - Gtk::Widget *boxSave; - Gtk::Box *boxInfoError; - Gtk::Box *boxWidgetAll; - Gtk::Label *lblWarning; - Gtk::Image *imgInfo; - Gtk::ButtonBox *btnBoxAboutDialog; - Gtk::TreeView *treeViewKernel; - Gtk::TreeView *treeViewIPT; - Gtk::TreeView *treeViewOTT; - Gtk::TreeView *treeViewUser; - Gtk::TreeView *treeViewMelody; - Gtk::Image *imgBG; - Gtk::Overlay *overHead; - Gtk::ComboBoxText *cmbDownloadMode; - Gtk::CheckButton *chbPasswordProtecc; - Gtk::Label *lblHeadeWndWeb; - - Gtk::Label *lblwebHeaderName; - Gtk::Label *lblhelpText; - Gtk::Label *lblhelpHeader; - Gtk::CheckButton *chkAlwaysOpenHelp; - Gtk::Button *btnReadHelp; - Gtk::Button *btnCancelHelp; - Gtk::Window *wndShowWeb; - Gtk::Button *btnOpenMenuOS1; - Gtk::Entry *entrListOS; - Gtk::Overlay *overMenuOS; - Gtk::Revealer* revilerMenuOS; - - std::vector vec_Option_kernel; - std::vector vec_Option_IPT; - std::vector vec_Option_OTT; - - Glib::RefPtr list_store_kernel; - Glib::RefPtr list_store_IPT; - Glib::RefPtr list_store_OTT; - Glib::RefPtr list_store_user; - Glib::RefPtr list_store_melody; +#include +#include +#include +#include +#include #ifdef WEBKIT_FOUND - Gtk::Window *wndWeb; - Gtk::Widget *three; - WebKitWebView *my_web_kit = NULL; -#endif - Gtk::TreeModel::Row row_kernel; - Gtk::TreeModel::Row row_IPT; - Gtk::TreeModel::Row row_OTT; - Gtk::TreeModel::Row row_user; - Gtk::TreeModel::Row row_melody; - std::map map_cmd_selection; - std::map map_global_cmd_selection; - std::map map_local_cmd_selection; - Gtk::TreeModel::iterator iter_user_del; - Gtk::TreeModel::iterator iter_melody_del; - bool flag_validate_del_user = false; - bool flag_validate_del_melody = false; - - 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(); - View_edit_add_table obj_view_edit_add_table = View_edit_add_table(); - bool flag_load = false; - bool flag_save_all = false; - bool flag_blocked_tree_view = false; - bool flag_save_block = false; - bool flag_open_browser = false; - string str_last_launched_os = ""; - int index_error = 0; - string str_flag_load = ""; - size_t size_kernel = 0; - size_t size_IPT = 0; - size_t size_OTT = 0; - size_t len_old_melody = 0; - size_t len_old_user = 0; - int old_height = 0; - int old_width = 0; - Glib::RefPtr boxInfo; - string str_cmd_error = ""; - template - struct Result { - Type response; - int error; - }; -public: - std::map map_cmd_error; - string global_lick_doc = ""; - MainWindow(BaseObjectType *obj, Glib::RefPtr const &builder); - MainWindow(Glib::RefPtr const &builder); - ~MainWindow(); - void open_browser(); - void select_line_user(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter); - void set_entry_to_tree_view(Glib::RefPtr &list_store, Gtk::Entry &entry, std::vector &vec_Option, int size, string key); - void get_menu_boot(std::map &map_temp); - void set_row_all(std::map &map_cmd, Glib::RefPtr &list_store, vector &list_params, size_t size, string key); - void set_row(Glib::RefPtr &list_store, int size, std::string name, bool flag_chbox); - void get_builder(); - bool gui_exit(GdkEventAny *); - void init_dict(string flag_load); - void add_CSS(); - void show_pass(); - void localization(); - void event(); - void remove_user(); - void remove_melody(); - void settings(); - void open_help(); - void validate_melody(); - void select_line_melody(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter); - void view_add_colums_user(Gtk::TreeView &treeView); - void view_add_colums_melody(Gtk::TreeView &treeView); - void set_bat_save(Gtk::Button *btnSave); - string pars_last_launched_os(); - vector pars_os(vector &os_control_list); - void fn_event_intelMax1(); - void fn_event_intelMax4(); - void temp_help_show(); - void set_data_cfg(); - void set_data_csv_melody(); - vector>> 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); - void wrapper_system(string cmd, string thread_str); - struct Result wrapper_call(string cmd); - void log_mess_error(string &cmd); - void wrapper_save_all_cfg(); - void wrapper_save_local_cfg(); - void wrapper_save_global_cfg(); - bool save_template(string cmd, string cmd_remove, string flag_save); - void view_add_colums(Gtk::TreeView &treeView); - vector read_file_and_view(string file_name, Gtk::TreeModel::Row &row, Glib::RefPtr list_store_m); - void download_local_cfg(); - void set_tree_view_user(); - void template_open_browser(string link_doc); - void download_globl_cfg(); - void flag_block_gui(); - void info_status_app(string stule); - bool check_save(string flag_save, string key_name); - void info_warning_error(int mess); - int check_root(); - void focus_out_txt_kernel(); - void focus_out_txt_IPT(); - void focus_out_txt_OTT(); - bool focus_in_txt_entry(GdkEventFocus*); - void fill_in_view(); - bool focus_tree_view(GdkEventFocus *); - bool check_flag_save(string flag_save); - void set_download_mode(); - void get_default_load(std::map &map_temp); - void set_entry(Gtk::Entry *entry, std::map &map_temp, string key); - void load_template(std::map *map_temp, string cmd); - vector get_setting_entry_all(string key, std::map *map_temp); - void cmd_entry_all(Gtk::Entry &entry, string cmd_settings, string cmd_remove); - void item_selected_kernel(const Gtk::TreeModel::Path &, const Gtk::TreeModel::iterator &); - void item_selected_OTT(const Gtk::TreeModel::Path &, const Gtk::TreeModel::iterator &); - void item_selected_IPT(const Gtk::TreeModel::Path &, const Gtk::TreeModel::iterator &); - string template_item_selected(int size, Glib::RefPtr &list_store, string key); - void set_add_data_melody(Gtk::TreeModel::Row &row, bool flag, string &name, string &code); - void set_init_data_melody(std::map &map_temp); - void set_add_data_user(Gtk::TreeModel::Row &row, bool flag, string &name, string &password); - void set_init_data_user(std::map &map_temp); - void set_init_data_superuser(std::map &map_temp); - bool intel_idle_cstate_check(int size, Glib::RefPtr &list_store, string key); - void wrapper_add_data_user(); - void wrapper_add_data_melody(); - void check_resize_window(); - void set_plug(Gtk::Widget *plug); - 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); - void set_menu_os_to_button(); -}; - -class SettingsPlug : public Gtk::Plug -{ -public: - Gtk::Window *window; - SettingsPlug(::Window p_socketID, Glib::RefPtr builder); - -private: - Gtk::Widget *plugBox; - Gtk::Widget *parent; -}; - -void help(); -void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data); + #include +#endif +#include "ubl-strings.h" + +#define WIKI_LINK "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/ubl-settings-bootloader" + +#define _(String) gettext(String) + +#define glade_path "/com/ublinux/ui/ubl-settings-bootloader.glade" +#define banner_path "/com/ublinux/images/ubl-settings-bootloader-banner.png" +#define CssPath "/com/ublinux/css/ubl-settings-bootloader.css" +#define config_path yon_char_unite(yon_ubl_user_get_home_directory(),"/.config/",LocaleName,"/",LocaleName,".conf",NULL) +#define icon_path "com.ublinux.ubl-settings-bootloader" + +#define LocaleName "ubl-settings-bootloader" + +#define yon_config_get_custom_command(target) yon_char_unite("ubconfig --source ",target," get system PARAMETERS",NULL) +#define config_get_local_command "ubconfig --source system get system PARAMETERS" +#define config_get_global_command "ubconfig --source global get system PARAMETERS" +#define config_get_default_command "" + +#define config_get_global_only_parameters "" +#define config_get_local_only_parameters "" + +typedef char* string; +string version_application; + +char *local; + +typedef struct { + template_config_fields + int save_config; + config_str launch_arguments; + int launch_size; +} config; + +typedef struct { + template_window_fields + GtkWidget *BootRingtoneAddButton; + GtkWidget *BootRingtoneEditButton; + GtkWidget *BootRingtoneRemoveButton; + GtkWidget *BootRingtoneTree; + GtkWidget *BootUsersAddButton; + GtkWidget *BootUsersEditButton; + GtkWidget *BootUsersRemoveButton; + GtkWidget *BootUsersTree; + GtkWidget *BoxMain; + GtkWidget *boxWidgetAll; + GtkWidget *btnAbout; + GtkWidget *btnHelp; + GtkWidget *btnLoadGlob; + GtkWidget *btnLoadLocal; + GtkWidget *btnOpenMenuOS1; + GtkWidget *btnSaveGlob; + GtkWidget *btnSaveLocal; + GtkWidget *btnSaveLocalGlob; + GtkWidget *chbLoadVariantSelectionTimer; + GtkWidget *cmbDownloadMode; + GtkWidget *CommandLineParametersEntry; + GtkWidget *entrListOS; + GtkWidget *InputTerminalEntry; + GtkWidget *InputTerminalTree; + GtkWidget *KernelParametersTree; + GtkWidget *lblInfoDefaultDonw; + GtkWidget *lblInfoSeconds; + GtkWidget *list_os; + GtkWidget *menu; + GtkWidget *menu1; + GtkWidget *menu2; + GtkWidget *OutputTerminalEntry; + GtkWidget *OutputTerminalTree; + GtkWidget *overMenuOS; + GtkWidget *spbSecond; + +} main_window; + + +typedef struct { + GtkWidget *Window; + GtkWidget *HeaderLabel; + + GtkWidget *AlwaysOpenCheck; + + GtkWidget *CloseButton; + GtkWidget *AcceptButton; +} documentation_confirmation_window; + +void on_save_done(main_window *, config_str output, int size); + +void yon_load_proceed(YON_CONFIG_TYPE type); + +void yon_interface_update(main_window *); + +void on_save_done(main_window *widgets, config_str output, int size); + +void config_init(); + +void yon_main_window_complete(main_window *widgets); \ No newline at end of file diff --git a/source/ubl-settings-bootloader.h.in b/source/ubl-settings-bootloader.h.in deleted file mode 100644 index 17ba454..0000000 --- a/source/ubl-settings-bootloader.h.in +++ /dev/null @@ -1 +0,0 @@ -#cmakedefine WEBKIT_FOUND \ No newline at end of file diff --git a/source/ubl-strings.h b/source/ubl-strings.h new file mode 100644 index 0000000..7a70169 --- /dev/null +++ b/source/ubl-strings.h @@ -0,0 +1,3 @@ + +#define TITLE_LABEL _("ubl-settings-bootloader") +#define TITLE_INFO_LABEL _("TEMPLATE configuration") diff --git a/source/ubl-util-standard.c b/source/ubl-util-standard.c deleted file mode 100644 index 3b753b1..0000000 --- a/source/ubl-util-standard.c +++ /dev/null @@ -1,91 +0,0 @@ -#include "ubl-util-standard.h" -#ifndef __cplusplus -#ifndef UBL_GET_STANDARD_UI -#define UBL_GET_STANDARD_UI - - -inline returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id){ - returnstruct *ret=(returnstruct*)malloc(sizeof(returnstruct*)); - if (left_plug_id>0&&LeftWidget){ - GtkWidget *plug=gtk_plug_new(left_plug_id); - GtkWidget *toplug=LeftWidget; - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - ret->plugLeft=plug; - } - if (right_plug_id>0&&RightWidget){ - GtkWidget *plug=gtk_plug_new(right_plug_id); - GtkWidget *toplug=RightWidget; - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - ret->plugRight=plug; - } - return ret; -} - -#endif - -#else - - -inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){ - if (left_plug_id>0&&LeftWidget){ - GtkWidget *plug=gtk_plug_new(left_plug_id); - GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj()); - {GdkScreen *screen = gtk_widget_get_screen(plug); - gtk_widget_set_app_paintable(plug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(plug, colormap);} - {GdkScreen *screen = gtk_widget_get_screen(toplug); - gtk_widget_set_app_paintable(toplug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(toplug, colormap);} - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); - } - if (right_plug_id>0&&RightWidget){ - GtkWidget *plug=gtk_plug_new(right_plug_id); - GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj()); - {GdkScreen *screen = gtk_widget_get_screen(plug); - gtk_widget_set_app_paintable(plug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(plug, colormap);} - {GdkScreen *screen = gtk_widget_get_screen(toplug); - gtk_widget_set_app_paintable(toplug,TRUE); - GdkVisual *colormap = gdk_screen_get_rgba_visual(screen); - gtk_widget_set_visual(toplug, colormap);} - if (gtk_widget_get_parent(GTK_WIDGET(toplug))){ - g_object_ref(G_OBJECT(toplug)); - GtkWidget *parent=gtk_widget_get_parent(toplug); - gtk_container_remove(GTK_CONTAINER(parent),toplug); - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - } else - gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug)); - gtk_widget_show(GTK_WIDGET(plug)); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(toplug),"bkim"); - gtk_style_context_add_class(gtk_widget_get_style_context(plug),"primary-toolbar"); - } -} -#endif \ No newline at end of file diff --git a/source/ubl-util-standard.h b/source/ubl-util-standard.h deleted file mode 100644 index 3209625..0000000 --- a/source/ubl-util-standard.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __cplusplus -#include -#include - -typedef struct { - GtkWidget *plugLeft; - GtkWidget *plugRight; - - -} returnstruct; -static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id); -#else -#include -#include -#include -#include - - -static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id); -#endif \ No newline at end of file diff --git a/source/util.cc b/source/util.cc deleted file mode 100644 index d47e8ff..0000000 --- a/source/util.cc +++ /dev/null @@ -1,467 +0,0 @@ -#include "util.h" - -namespace Utils { - -array, 5> read_csv(const string& filename) { - array, 5> array_vectors; - vector vec_option; - vector vec_opcision; - ifstream file(filename); - string line; - char delimiter = '|'; - getline(file, line); - while (getline(file, line)) { - stringstream stream(line); - string option; - string opcision; - getline(stream, option, delimiter); - string line_local = stream.str(); - if (line_local.find("\"") != string::npos) { - string str_delimiter = "\""; - vector point = find_all(line_local, str_delimiter); - size_t len = point.size(); - if (len >= 2) { - int index_start = point[len-2]; - int index_end = point[len-1]; - opcision = line_local.substr(index_start, index_end); - index_end = opcision.find("\""); - if (opcision.find("\"") != string::npos) { - opcision.replace(index_end, opcision.length(), ""); - } - - } - else { - opcision = "error"; - } - - - } - else{ - getline(stream, opcision, delimiter); - } - - - vec_option.push_back(option); - vec_opcision.push_back(opcision); - } - - array_vectors[0] = vec_option; - array_vectors[1] = vec_opcision; - return array_vectors; -} - -void write_file(string path_name, string data) { - ofstream fout(path_name, ios_base::out | ios_base::trunc); - if (fout.is_open()) { - fout << data; - fout.close(); - } -} - -vector> read_csv_melody(const string& filename) { - vector> vec_music; - ifstream file(filename); - string line; - char delimiter = '|'; - getline(file, line); - while (getline(file, line)) { - stringstream stream(line); - string name; - string code; - getline(stream, name, delimiter); - getline(stream, code, delimiter); - tuple tuple_music(name, code); - vec_music.push_back(tuple_music); - } - return vec_music; -} - -string call(string cmd) { - FILE *fp; - int status; - char path[PATH_MAX] = {0}; - fp = popen(cmd.c_str(), "r"); - if (fp == NULL) { - exit(1); - } - while (fgets(path, PATH_MAX, fp) != NULL) { - break; - } - status = pclose(fp); - if (status == -1) { - exit(1); - } - return path; -} - -vector find_all(string &str_ntp, string substr) { - size_t index = 0; - vector sub_index; - while ((index = str_ntp.find(substr, index)) != std::string::npos) { - index += substr.length(); - sub_index.push_back(index); - } - return sub_index; -} - -void str_remove(std::string& source, std::string to_remove) { - string::size_type n = to_remove.length(); - for (string::size_type i = source.find(to_remove); - i != string::npos; - i = source.find(to_remove)) - source.erase(i, n); -} - -void str_replace_all(std::string& str_base, string str_find, string sReplacement) -{ - size_t pos = 0, fpos; - while ((fpos = str_base.find(str_find, pos)) != std::string::npos) - { - str_base.replace(fpos, str_find.size(), sReplacement); - pos = fpos + sReplacement.size(); - } -} -std::vector split(std::string text, char delim) { - std::string line; - std::vector vec; - std::stringstream ss(text); - while(std::getline(ss, line, delim)) { - vec.push_back(line); - } - return vec; -} - - -char *yon_char_new(char *chr) -{ - if (chr){ - char *newchar = (char*)malloc(strlen(chr) + 1); - memset(newchar, 0, strlen(chr) + 1); - memcpy(newchar, chr, strlen(chr)); - return newchar; - } else - return NULL; -} - -char *yon_char_append(char *source, char *append) -{ - if (source && append) - { - int size = strlen(source) + strlen(append) + 1; - char *final = (char*)malloc(size); - memset(final, 0, size); - // if (strstr(source, "%%")) - // sprintf(final, source, append); - // else - sprintf(final, "%s%s", source, append); - return final; - } - else - return NULL; -} - -char *yon_char_unite(char *source, ...){ - va_list arglist; - char *new_char=NULL; - char *unite_char=NULL; - new_char=yon_char_new(source); - va_start(arglist,source); - unite_char = va_arg(arglist,char*); - while(unite_char){ - new_char = yon_char_append(new_char,unite_char); - unite_char = va_arg(arglist,char*); - } - va_end(arglist); - return new_char; -} - -char *yon_char_divide(char *source, int dividepos) -{ - if (source&&(int)strlen(source)>=dividepos){ - char *cut = (char*)malloc(dividepos + 1); - memset(cut, 0, dividepos + 1); - memcpy(cut, source, dividepos); - char *left = (char*)malloc(strlen(source) - strlen(cut)); - memset(left, 0, strlen(source) - strlen(cut)); - memcpy(left, source + dividepos + 1, (strlen(source) - dividepos)); - memset(source, 0, strlen(source)); - memcpy(source, left, strlen(left)); - return cut; - } - return NULL; -} - -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider) -{ - if (delete_divider){}; - if (source&÷pos){ - char *cut = strstr(source, dividepos); - if (cut) - { - int leng = strlen(source) - strlen(cut); - cut = yon_char_divide(source, leng); - return cut; - } - } - return source; -} - -char **yon_char_parse(char *parameters, int *size, char *divider){ - *size=0; - if (parameters){ - char **string=NULL; - char *paramline=yon_char_new(parameters); - char *param = strstr(paramline,divider); - for (;param;param=strstr(paramline,divider)){ - string = (!string) ? (char **)malloc(sizeof(char*)*((*size)+1)) : (char **)realloc(string, sizeof(char*)*((*size)+1)); - string[(*size)]=yon_char_divide(paramline,strlen(paramline)-strlen(param)); - *size=(*size)+1; - } - string = (!string) ? (char **)malloc(sizeof(char*)*((*size)+1)) : (char **)realloc(string, sizeof(char*)*((*size)+1)); - string[(*size)]=paramline; - (*size)+=1; - return string; - } - return NULL; -} - - #define check_window_config_setup if(__yon_window_config_target_window) - - typedef struct { - char *parameter_name; - enum YON_TYPE containing_type; - GtkWidget *track_widget; - char *property_name; - } __yon_listener_parameter; - - typedef struct { - char *parameter_name; - char *section; - enum YON_TYPE containing_type; - void *property; - } __yon_custom_parameter; - - struct { - int x; - int y; - int width; - int height; - int fullscreen; - dictionary *custom_listeners; - dictionary *custom_parameters; - dictionary *deleted_parameters; - } __yon_main_window_config; - - static GtkWindow *__yon_window_config_target_window = NULL; - static GKeyFile *__yon_window_config_file = NULL; - static char *__yon_window_config_path = NULL; - - void yon_window_config_save(); - void yon_window_config_save(){ - if (__yon_window_config_path){ - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosX",__yon_main_window_config.x); - g_key_file_set_integer(__yon_window_config_file,"window","WindowPosY",__yon_main_window_config.y); - g_key_file_set_integer(__yon_window_config_file,"window","WindowWidth",__yon_main_window_config.width); - g_key_file_set_integer(__yon_window_config_file,"window","WindowHeight",__yon_main_window_config.height); - g_key_file_set_integer(__yon_window_config_file,"window","fullscreen",__yon_main_window_config.fullscreen); - dictionary *dict=NULL; - if (__yon_main_window_config.deleted_parameters) - for_dictionaries(dict,__yon_main_window_config.deleted_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - g_key_file_remove_key(__yon_window_config_file,param->section,param->parameter_name,NULL); - } - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = (GValue*)g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - switch(param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,"window",param->parameter_name, g_value_get_string(val)); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,"window",param->parameter_name, g_value_get_int(val)); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,"window",param->parameter_name, g_value_get_boolean(val)); - break; - case YON_TYPE_STRING_LIST:break; - case YON_TYPE_OTHER:printf("\033[0;31mCannot save %s property with %s key\033[0m\n",param->property_name,param->parameter_name);break; - } - } - if (__yon_main_window_config.custom_parameters) - for_dictionaries(dict,__yon_main_window_config.custom_parameters){ - __yon_custom_parameter *param = yon_dictionary_get_data(dict,__yon_custom_parameter*); - switch (param->containing_type){ - case YON_TYPE_STRING: - g_key_file_set_string(__yon_window_config_file,param->section,param->parameter_name, (char*)param->property); - break; - case YON_TYPE_INT: - g_key_file_set_integer(__yon_window_config_file,param->section,param->parameter_name, *(int*)param->property); - break; - case YON_TYPE_BOOLEAN: - g_key_file_set_boolean(__yon_window_config_file,param->section,param->parameter_name, *(gboolean*)param->property); - break; - case YON_TYPE_STRING_LIST:break; - default: - break; - } - } - - g_key_file_save_to_file(__yon_window_config_file,__yon_window_config_path,NULL); - } - } - - void yon_get_is_fullscreen(); - void yon_get_is_fullscreen(){ - gtk_window_is_maximized(__yon_window_config_target_window); - __yon_main_window_config.fullscreen = gtk_window_is_maximized(__yon_window_config_target_window); - if (!__yon_main_window_config.fullscreen) gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - - /**yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event) - * [EN] - * - * [RU] - * Сохраняет настройки основного окна. Вызывается когда основное окно уничтожается. - */ - void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event); - void yon_on_configured_window_destroy(GtkWidget* self,GdkEvent* event){ - if (self&&event){}; - check_window_config_setup{ - yon_get_is_fullscreen(); - yon_window_config_save(); - } - exit(0); - } - - void __yon_window_config_on_resize(); - void __yon_window_config_on_resize(){ - int max=0; - max=gtk_window_is_maximized(__yon_window_config_target_window); - if(max==0){ - gtk_window_get_size(__yon_window_config_target_window,&__yon_main_window_config.width,&__yon_main_window_config.height); - gtk_window_get_position(__yon_window_config_target_window,&__yon_main_window_config.x,&__yon_main_window_config.y); - } - } - - void yon_window_config_setup(GtkWindow *window){ - __yon_window_config_target_window = window; - g_signal_connect(G_OBJECT(window),"delete-event",G_CALLBACK(yon_on_configured_window_destroy),NULL); - g_signal_connect(G_OBJECT(window),"check-resize"/*"configure-event"*/,G_CALLBACK(__yon_window_config_on_resize),NULL); - } - - void *_yon_maximize(void *data); - void *_yon_maximize(void *data){ - if (data){}; - g_usleep(G_USEC_PER_SEC/10); - if(__yon_main_window_config.fullscreen ==1) gtk_window_maximize(__yon_window_config_target_window); - return NULL; - } - - int yon_window_config_load(char *path){ - if(__yon_window_config_target_window){ - if (!access(path,0)){ - __yon_window_config_file = g_key_file_new(); - __yon_window_config_path=yon_char_new(path); - if (!g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL)){ - struct stat st; - int size; - config_str conf = yon_char_parse(yon_char_new(__yon_window_config_path),&size,(char*)"/"); - char *path = yon_char_unite(conf[0],(char*)"/",conf[1],(char*)"/",conf[2],(char*)"/",conf[3],(char*)"/",conf[4],(char*)"/",NULL); - if (stat(path, &st) == -1) { - mkdir(path, 0777); - } - FILE *fp; - fp=fopen(__yon_window_config_path,"w"); - chmod(__yon_window_config_path,0777); - fclose(fp); - g_key_file_load_from_file(__yon_window_config_file,__yon_window_config_path,G_KEY_FILE_NONE,NULL); - } - __yon_main_window_config.x = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosX",NULL); - __yon_main_window_config.y = g_key_file_get_integer(__yon_window_config_file,"window","WindowPosY",NULL); - __yon_main_window_config.width = g_key_file_get_integer(__yon_window_config_file,"window","WindowWidth",NULL); - __yon_main_window_config.height = g_key_file_get_integer(__yon_window_config_file,"window","WindowHeight",NULL); - __yon_main_window_config.fullscreen = g_key_file_get_integer(__yon_window_config_file,"window","fullscreen",NULL); - dictionary *dict=NULL; - if (__yon_main_window_config.custom_listeners) - for_dictionaries(dict,__yon_main_window_config.custom_listeners){ - __yon_listener_parameter *param = yon_dictionary_get_data(dict,__yon_listener_parameter*); - GValue *val = (GValue*)g_malloc0(sizeof(GValue)); - g_object_get_property(G_OBJECT(param->track_widget),param->property_name,val); - gboolean res=0; - switch(param->containing_type){ - case YON_TYPE_STRING: - g_value_set_string(val,g_key_file_get_string(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_INT: - g_value_set_int(val,g_key_file_get_integer(__yon_window_config_file,"window",param->parameter_name, NULL)); - break; - case YON_TYPE_BOOLEAN: - res = g_key_file_get_boolean(__yon_window_config_file,"window",param->parameter_name, NULL); - g_value_set_boolean(val,res); - break; - case YON_TYPE_STRING_LIST:break; - case YON_TYPE_OTHER:break; - } - g_object_set_property(G_OBJECT(param->track_widget),param->property_name,val); - } - if (__yon_main_window_config.width==0) __yon_main_window_config.width=800; - if (__yon_main_window_config.height==0) __yon_main_window_config.height=600; - gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - pthread_t tid; - pthread_create(&tid, NULL, (&_yon_maximize), NULL); - - return 1; - } - } - return 0; - } - -void yon_window_config_apply(); - void yon_window_config_apply(){ - gtk_window_move(__yon_window_config_target_window,__yon_main_window_config.x,__yon_main_window_config.y); - gtk_window_resize(__yon_window_config_target_window,__yon_main_window_config.width,__yon_main_window_config.height); - } - - config_str yon_window_config_get_section(char *section, gsize *size){ - config_str key = g_key_file_get_keys(__yon_window_config_file,section,size,NULL); - return key; - } - -char *yon_ubl_user_get_home_directory(){ - FILE *path = popen(get_home_dir_command,"r"); - char *ret = (char*)malloc(4096); - memset(ret,0,4096); - if (fgets(ret,4096,path)){ - ret=yon_char_divide_search(ret,(char*)"\n",-1); - return ret; - } else return NULL; -} - - -char *yon_ubl_root_user_get(){ - char *user=NULL; - if (yon_ubl_check_root()){ - user=getenv("SUDO_USER"); - if (user&&strcmp(user,"")!=0){ - return user; - }else { - FILE *file = popen("getent passwd $PKEXEC_UID | cut -d: -f1","r"); - user=(char*)malloc(4096); - memset(user,0,4096); - if (fgets(user,4096,file)){ - user=yon_char_divide_search(user,(char*)"\n",-1); - if (user) return user; - } else return NULL; - } - } - return getlogin(); -} - -int yon_ubl_check_root(){ - if (getuid()==0) return 1; - else return 0; -} -} \ No newline at end of file diff --git a/source/util.h b/source/util.h deleted file mode 100644 index 8c614aa..0000000 --- a/source/util.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef UTIL_H -#define UTIL_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -namespace Utils { - - -#define get_home_dir_command yon_char_unite((char*)"getent passwd \"",yon_ubl_root_user_get(),(char*)"\" | cut -d: -f6",NULL) - -template -struct Result{ - Type response; - int error; -}; - -struct Passwd { - string user; - int uid; -}; - -std::array, 5> read_csv(const std::string& filename); -std::string call(std::string cmd); -vector find_all(string &str_ntp, string substr); -void str_remove(std::string& source, std::string to_remove); -void str_replace_all(string &str_base, string str_find, string str_replace); -std::vector split(std::string text, char delim); -vector> read_csv_melody(const string& filename); -void write_file(string path_name, string data); - -#define for_dictionaries(element, stack) for (element = stack->first; element != NULL; element = element->next) -#define yon_dictionary_get_data(dictionary, type) ((type)dictionary->data) - -typedef enum -{ - DICTIONARY_GTK_WIDGETS_TYPE, - DICTIONARY_OTHER_TYPE=0, - DICTIONARY_CHAR_TYPE, - DICTIONARY_INT_TYPE, - DICTIONARY_BOOL_TYPE, - -} DICT_TYPE; - -typedef struct dictionary -{ - char *key; - void *data; - struct dictionary *next; - struct dictionary *prev; - struct dictionary *first; - DICT_TYPE data_type; -} dictionary; - -typedef char** config_str; - -char *yon_char_divide(char *source, int dividepos); - -char *yon_char_divide_search(char *source, char *dividepos, int delete_divider); - -char *yon_char_new(char *chr); - -char *yon_char_append(char *source, char *append); - -char *yon_char_unite(char *source, ...); - -char **yon_char_parse(char *parameters, int *size, char *divider); - -/**YON_TYPE - * [EN] - * - * [RU] - * Типы, поддерживаемые функциями сохранения/загрузки конфигурации утилиты -*/ -enum YON_TYPE{ - YON_TYPE_STRING, - YON_TYPE_STRING_LIST, - YON_TYPE_INT, - YON_TYPE_BOOLEAN, - YON_TYPE_OTHER}; - -/**yon_window_config_setup(GtkWindow *window) - * [EN] - * - * [RU] - * Устанавливает указатель на окно для отслеживания его положения и размера -*/ -void yon_window_config_setup(GtkWindow *window); - -/**yon_window_config_load(char *path) - * [EN] - * - * [RU] - * Загружает конфиг окна и инициализирует отслеживание его параметров -*/ -int yon_window_config_load(char *path); - -/**yon_window_config_get_section(char *section, gsize *size) - * [EN] - * - * [RU] - * Возвращает все параметры раздела [section] конфига утилиты и записывает в [size] количество считанных параметров. -*/ -config_str yon_window_config_get_section(char *section, gsize *size); - - -char *yon_ubl_user_get_home_directory(); - -char *yon_ubl_root_user_get(); - - -int yon_ubl_check_root(); -} -#endif \ No newline at end of file diff --git a/ubl-settings-bootloader.css b/ubl-settings-bootloader.css index 7ee9ef8..1ca94fe 100644 --- a/ubl-settings-bootloader.css +++ b/ubl-settings-bootloader.css @@ -1,166 +1,139 @@ -.textHead{ - text-shadow: 2px 2px @theme_bg_color; - color: @theme_text_color; -} -.boxInfoMessError{ - background-color: #ea9999; -} -.boxInfoMessOK{ - background-color: #f3f0ac; -} -.bannerbackground { - background-color: #404040; +.thin { + margin:0px; + padding:0px; } -.view_app { - background-color: @theme_bg_color; +.noborder { + border:none; } -.view_app.view.cell:selected { - background-color:@theme_selected_bg_color; - color:@theme_selected_text_color; - transition: 10ms ease-out; - border-radius: 3px; +.nobackground { +background:transparent; } -#GnomeIcon{ - border-style:solid; - border-bottom-width: 1px; - border-image: linear-gradient(90deg, alpha(@theme_text_color,0.4) 55%, alpha(@theme_bg_color, 0) 100%); - border-image-slice: 1; +.nobackground:active { +background:transparent; } - -#SepIcon{ - background-color: alpha(@theme_text_color, 0.6); +.textHead{ + text-shadow: 2px 2px @theme_bg_color; + color: @theme_text_color; } -#iconlabel { - font-size:14px; - font-weight: bold; - +.inherited>* { + border:none; + background:inherit; } -.roundborder * { - border-width:0px; - border-radius:5px; -} -.noborder { - border: none; -} -.menu:hover { - border-color:alpha(@theme_text_color, 0.01); -} -.menu { - border-color:alpha(@theme_text_color, 0.01); -} -.menu:hover >* { - border-color:alpha(@theme_text_color, 0.01); +.workingbg { + background:@theme_base_color; } .menuitembottom{ - margin-top:0px; - margin-bottom:3px; -} -.menuitemmiddle{ - margin-top:0px; - margin-bottom:0px; -} + margin-top:0px; + margin-bottom:3px; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; + } + .menuitemmiddle{ + margin-top:0px; + margin-bottom:0px; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; + } -.menuitemtop{ - margin-bottom:0px; -} -.menuitemtop *{ - margin:2px 2px 0 2px; - padding: 5px 10px 3px 5px; -} -.menuitemmiddle *{ - margin:0 2px 0 2px; - padding: 3px 10px 3px 5px; -} -.menuitembottom *{ - margin:0 2px 2px 2px; - padding: 3px 10px 5px 5px; -} -.menuitemtop:hover { - background:@theme_bg_color; - border-color:inherit; - border-left-width:inherit; - border-right-width:inherit; -} -.menuitemmiddle:hover { - background:@theme_bg_color; - border-color:inherit; - border-left-width:inherit; - border-right-width:inherit; -} -.menuitembottom:hover { - background:@theme_bg_color; - border-color:inherit; - border-left-width:inherit; - border-right-width:inherit; - -} -.menuitemtop:hover* { - margin:2px 2px 0 2px; - padding: 5px 10px 3px 5px; - background:@theme_selected_bg_color; - border-radius:2px; -} -.menuitemmiddle:hover* { - margin:0 2px 0 2px; - padding: 3px 10px 3px 5px; - background:@theme_selected_bg_color; - border-radius:2px; -} -.menuitembottom:hover* { - margin:0 2px 2px 2px; - padding: 3px 10px 5px 5px; - background:@theme_selected_bg_color; - border-radius:2px; + .menuitemtop{ + margin-bottom:0px; + border-color:inherit; + border-top-width:inherit; + border-left-width:inherit; + border-right-width:inherit; + } + .menuitemtop >*{ + margin:4px 2px 0 2px; + padding: 3px 10px 3px 5px; + border:transparent; + } + .menuitemmiddle >*{ + margin:0 2px 0 2px; + padding: 3px 10px 3px 5px; + border:transparent; + } + .menuitembottom >*{ + margin:0 2px 2px 2px; + padding: 3px 10px 3px 5px; + } + .menuitemtop:hover { + background:@theme_bg_color; + border-color:inherit; + border-top-width:inherit; + border-left-width:inherit; + border-right-width:inherit; + } + .menuitemmiddle:hover { + background:@theme_bg_color; + border-color:inherit; + border-left-width:inherit; + border-right-width:inherit; + } + .menuitembottom:hover { + background:@theme_bg_color; + border-color:inherit; + border-bottom-width:0px; + border-left-width:inherit; + border-right-width:inherit; + + } + .menuitemtop:hover>* { + margin:4px 2px 0 2px; + padding: 3px 10px 3px 5px; + background:@theme_selected_bg_color; + border-radius:2px; + } + .menuitemmiddle:hover>* { + margin:0 2px 0 2px; + padding: 3px 10px 3px 5px; + background:@theme_selected_bg_color; + border-radius:2px; + } + .menuitembottom:hover>* { + margin:0 2px 2px 2px; + padding: 3px 10px 3px 5px; + background:@theme_selected_bg_color; + border-radius:2px; + } + .boxInfoMessError{ + background-color: #ea9999; } -.workingbg, #workingbg { - background-color:@theme_base_color; -} -.workingbg.view.cell:selected { - background-color:@theme_selected_bg_color; -} -.workingbg.view.cell:hover { - background-color:darker(@theme_selected_bg_color); - color:@theme_selected_text_color; - border-radius:3px; -} -.bkim { - transition: 200ms ease-out; - background-image: none; +.boxInfoMessOK{ + background-color: #f3f0ac; } -.noborder{ -border:none; +.errorBox { + border-width: 2px; + border-color: #ea9999; + border-style:solid; } -.bkim{ -opacity:0.99; -border:none; +.chosenOutline{ + transition: 0ms; + border-width: 1px; + border-color: #f3f0ac; + border-style:solid; } -.bkim_no_plug{ -background-color: transparent; -opacity:0.99; -} -.thin{ - margin:0px; - padding: 0px; -} -.nobg{ - background: none; -} -.addbg * { - background-color: @theme_bg_color; +.separatorTop{ + border-color: darker (@theme_bg_color); + border-top-width:1px; + border-style:solid; } -.addbg_revealer * { - background-color: @theme_base_color; +.separatorBottom{ + border-color: darker (@theme_bg_color); + border-bottom-width:1px; + border-style:solid; } -.offset_revealer{ - border-width: 1px; - border-style: solid; - border-color: @theme_text_color; + +.marginright image{ + margin-right: 2px; } -.bultar { - border:none; -} \ No newline at end of file + +treeview row:nth-child(odd) { background-color: #000000; } + +treeview row:nth-child(even) { background-color: #ffffff; } \ No newline at end of file diff --git a/ubl-settings-bootloader.glade b/ubl-settings-bootloader.glade index 4ce5f58..4be8712 100644 --- a/ubl-settings-bootloader.glade +++ b/ubl-settings-bootloader.glade @@ -1,528 +1,74 @@ - + - - False - False - True - center - com.ublinux.ubl-settings-bootloader - dialog - True - ubl-settings-bootloader - 1.0 - Copyright © 2022 - 2023, UBSoft LLC - ubl-settings-bootloader - https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ - Project Home Page - Это приложение распространяется без каких-либо гарантий. -Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. - UBGroup - UBGroup - UBGroup - UBGroup - com.ublinux.ubl-settings-bootloader - True - gpl-2-0 - - - True - False - vertical - 2 - - - False - end - - - False - False - 1 - - - - - - - - - - True - False - True - - - True - False - 5 - 5 - 5 - 5 - 2 - System boot - - - - - - - - - + True False + vertical - - 90 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - 69 - com.ublinux.ubl-settings-bootloader - - - False - True - 0 - - - - + True - False + True + never - + True False + 5 + 5 + 5 True False vertical - - 255 - True - False - end - System boot - 0 - - - - - - - - True - True - 0 - - - - - 255 - True - False - start - Configuring system boot parameters - 0 - - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - True - 0 - - - - - True - True - 1 - - - - - True - False - - - 1 - 1 - True - True - True - - - True - False - - - 1 - 1 - True - False - **** - True - 0.009999999776482582 - - - True - True - 0 - - - - - True - True - False - True - right - - - - - - - False - True - 1 - - - - - - - True - True - 1 - - - - - 1 - 1 - True - True - True - - - 1 - 1 - True - False - True - 0 - - - - - True - False - - - True - False - False - False - 4 - - - True - False - Load global configuration - - - - - - True - False - Load local configuration - - - - - - True - False - False - False - 4 - - - True - False - Help - - - - - - True - False - About - - - - - - True - False - False - False - 4 - - - True - False - Save to global and local configuration - - - - - - True - False - Save global configuration - - - - - - True - False - Save local configuration - - - - - - 800 - 600 - False - com.ublinux.ubl-settings-bootloader - - - True - False - vertical - - - True - False - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 25 - 1 - - - False - True - 0 - - - - - True - False - start - 5 - 5 - 5 - 5 - 5 - 5 - - - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - - - 81 - True - False - start - - - -1 - - - - - False - True - 1 - - - - - True - True - never - - - True - False - 5 - 5 - 5 - - + True False vertical + 5 - + True False - vertical - 5 + 0.019999999552965164 + in - + True False - 0.019999999552965164 - in + 5 + 5 + 5 - + True False - 5 - 5 - 5 - + True False + 5 + vertical + 5 True False - 5 - vertical 5 - + + Boot selection menu timer: True - False - 5 - - - Boot selection menu timer - True - True - False - True - - - - False - True - 0 - - - - - True - True - - - False - True - 1 - - - - - True - False - Seconds - - - False - True - 2 - - + True + False + True + False @@ -531,55 +77,9 @@ - + True - False - 5 - - - True - False - start - Default load - start - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 2 - - - - - True - True - True - - - True - False - image-loading-symbolic - - - - - False - True - 3 - - + True False @@ -588,87 +88,156 @@ - + True False - 5 - - - True - False - start - Load screen display mode: - start - 0 - - - False - True - 0 - - + Seconds + + + False + True + 2 + + + + + False + True + 0 + + + + + True + False + 5 + + + True + False + start + Default OS: + start + 0 + + + False + True + 0 + + + + + True + True + + + True + True + 2 + + + + + True + True + True - + True False + image-loading-symbolic - - True - True - 1 - False True - 2 + 3 + + + False + True + 1 + + + + + True + False + 5 + + + True + False + start + Load screen display mode: + start + 0 + + + False + True + 0 + + + + + True + False + + + True + True + 1 + + + + + False + True + 2 + + + + + True + False + 0.019999999552965164 + in - + True False - 0.019999999552965164 - in + 5 + 5 + 5 - + True False - 5 - 5 - 5 + 5 True False - 5 + vertical - + True False - vertical + 0 + in - - True - False - 0 - in - - + True True - - - - - - - True - True - 0 - + + + @@ -677,397 +246,331 @@ 0 + + + True + True + 0 + + + + + True + False + vertical + 5 - + True - False - vertical - 5 + True + True - - True - True - True - - + True False value-increase-symbolic - - - - False - True - 0 - + + + + False + True + 0 + + + + + True + True + True - - True - True - True - - + True False document-edit-symbolic - - - - False - True - 1 - + + + + False + True + 1 + + + + + True + True + True - - True - True - True - - + True False user-trash-symbolic - - - - False - True - 2 - + False True - 1 + 2 + + False + True + 1 + - - - True - False - start - Boot Menu Users - start - - - - True - True - 5 - + + + True + False + start + Boot Menu Users + start + + + + + True + True + 5 + + + + + True + False + 0.019999999552965164 + in - + True False - 0.019999999552965164 - in + 5 + 5 + 5 - + True False - 5 - 5 - 5 + 5 + + + True + False + 0 + in + + + True + True + + + + + + + + True + True + 0 + + True False + vertical 5 - + True - False - 0 - in + True + True - + True - True + False + value-increase-symbolic - - - + - True + False True 0 - + True - False - vertical - 5 - - - True - True - True - - - True - False - value-increase-symbolic - - - - - - False - True - 0 - - + True + True - - True - True - True - - + True False document-edit-symbolic - - - - - False - True - 1 - + + + + False + True + 1 + + + + + True + True + True - - True - True - True - - + True False user-trash-symbolic - - - - - False - True - 2 - + False True - 1 + 2 + + False + True + 1 + - - - True - False - start - Ringtone at startup - start - - - - True - True - 5 - + + + + True + False + start + Startup ringtone + start + - -1 + True + True + 5 + + -1 + - - - True - False - Download menu - - - - False - True - 0 - + + + True + False + Boot menu + + + + + False + True + 0 + + + + + True + False + 0.019999999552965164 + in - + True False - 0.019999999552965164 - in + 5 + 5 + 5 - + True False - 5 - 5 - 5 + vertical + 5 - + + 141 True - False - vertical - 5 + True + in - - 141 + True True - in - - - True - True - - - - - True - True - 0 - - - - - True - False - 5 - - - True - False - Command line parameters: - - - False - True - 0 - - - - - True - True - center - 5 - 5 - - - True - True - 1 - - - - False - True - 10 - + + True + True + 0 + - - - - - True - False - start - Parameters passed to the kernel - start - - - - - False - True - 1 - - - - - True - False - 0.019999999552965164 - in - - - True - False - 5 - 5 - 5 True False - vertical 5 - + True False - 0 - in - - - True - True - - - - - + Command line parameters: False @@ -1076,98 +579,96 @@ - + True - False - 5 - - - True - False - center - Command line parameters: - - - False - True - 0 - - - - - True - True - center - 5 - 5 - - - True - True - 1 - - + True + center - False + True True - 7 + 1 + + False + True + 10 + - - - True - False - start - Terminal for input - start - - - - False - True - 2 - + + + True + False + start + Parameters passed to the kernel + start + + + + + False + True + 1 + + + + + True + False + 0.019999999552965164 + in - + True False - 0.019999999552965164 - in + 5 + 5 + 5 - + True False - 5 - 5 - 5 + vertical + 5 + + + True + False + 0 + in + + + True + True + + + + + + + + False + True + 0 + + True False - vertical 5 - + True False - 0 - in - - - True - True - - - - - + center + Command line parameters: False @@ -1176,958 +677,253 @@ - + True - False - 5 - - - True - False - center - Command line parameters: - - - False - True - 0 - - - - - True - True - center - 5 - 5 - - - True - True - 1 - - + True + center - False + True True - 7 + 1 + + False + True + 7 + - - - True - False - start - Terminal for output - start - - - - - False - True - 3 - - - - - False - True - 5 - - - - - - - - - True - True - 2 - - - - - - - True - False - True - - - True - False - 5 - 5 - System boot - - - - - - - - True - False - 5 - 5 - 32 - com.ublinux.ubl-settings-bootloader - - - - - True - False - - - True - False - - - True - True - False - True - True - menu2 - none - - - True - False - - - True - False - Save - - - False - True - 0 - - - + + True False - pan-down-symbolic + start + Input terminal + start - - False - True - 1 - - - - - False - True - 0 - - - - - True - True - True - False - True - True - menu1 - none - - - - - - - False - True - 1 - - - - - - False - True - 0 - - - - - end - 1 - - - - - True - False - - - True - True - False - True - True - menu - none - - - True - False - - - True - False - Load - - - False - True - 0 - - - - - True - False - pan-down-symbolic - False True - 1 + 2 - - - - - False - True - 0 - - - - - - 2 - - - - - - - False - Внимание! - False - True - center - com.ublinux.ubl-settings-bootloader - dialog - - - True - False - vertical - - - True - False - 5 - 5 - 5 - 5 - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 50 - dialog-information-symbolic - - - True - True - 0 - - - - - 160 - True - False - start - center - 5 - 5 - 5 - 5 - 5 - 5 - Warning! - - - True - True - 1 - - - - - False - True - 1 - - - - - OK - True - True - True - 5 - 5 - 5 - 5 - 3 - 3 - - - False - True - 1 - - - - - - - True - False - none - - - True - False - vertical - - - - - - - - True - False - end - start - 5 - 5 - 10 - 10 - slide-right - - - True - False - 0 - in - - - True - False - - - True - False - - - 0 - 0 - True - False - none - - - True - False - vertical - - - - - - - - True - True - 0 - - - - - 0 - 0 - True - False - none - True - + True False - vertical + 0.019999999552965164 + in - - 1 - 1 + True - True - True + False + 5 + 5 + 5 - + True - True - False - True - 0 - left + False + vertical + 5 + + + True + False + 0 + in + + + True + True + + + + + + + + False + True + 0 + + - + + True + False + 5 + + + True + False + center + Command line parameters: + + + False + True + 0 + + + + + True + True + center + + + True + True + 1 + + + + + False + True + 7 + - - - False - True - 0 - - - + + True False - vertical - - - + start + Output terminal + start - - False - True - 1 - + + False + True + 3 + False True - 1 + 5 - - - - + + True + True + 2 + - - + + True + False + + + True False - True - True - com.ublinux.ubl-settings-bootloader + False + False + 4 - + True False - 5 - 5 - 5 - 5 - vertical - 5 - - - True - False - 5 - - - True - False - label - 0 - - - False - True - 0 - - - - - True - True - False - True - - - - - - False - True - 1 - - - - - False - True - 0 - - - - - True - False - vertical - 5 - - - True - False - 5 - - - True - False - label - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 5 - - - True - False - label - 0 - - - False - True - 0 - - - - - True - True - - - True - True - 1 - - - - - False - True - 1 - - - - - True - True - 1 - - - - - True - False - 5 - - - True - False - - - False - True - 0 - - - - - gtk-cancel - True - True - True - True - - - False - True - end - 1 - - - - - gtk-save - True - True - True - True - - - False - True - end - 1 - - - - - False - True - 3 - - + Load global configuration + - - + + True False - True - - - True - False - System boot - - - - - True - False - 32 - com.ublinux.ubl-settings-bootloader - 5 - - + Load local configuration + - + + True False - False - True - 450 - com.ublinux.ubl-settings-bootloader + False + False + 4 - + True False - vertical - - - True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 5 - - - False - True - 0 - - - - - True - False - vertical - - - True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - - - - - False - True - 0 - - - - - True - False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is translated and supported by community. - True - 0 - - - - True - True - 1 - - - - - Always redirect to online documentation - True - True - False - end - 10 - True - - - - False - True - 2 - - - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 30 - True - - - Cancel - True - True - True - - - - True - True - 0 - - - - - Read Online - True - True - True - - - - True - True - 1 - - - - - False - True - 1 - - + Help + - - + + True False - True - - - True - False - System boot - - - - - - - - True - False - 32 - dialog-question-symbolic - - + About + - - 800 - 600 + + True False - True - True - com.ublinux.ubl-settings-bootloader + False + False + 4 + + + True + False + Save to global and local configuration + + + - + + True + False + Save global configuration + + - - + + True False - True - - - True - False - System boot - - - - - True - False - 32 - com.ublinux.ubl-settings-bootloader - 5 - - + Save local configuration +