diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..86196dd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+ubl-settings-bootloader.glade~
+test.cpp
+.vscode
+ubl-settings-bootloader
+ubl-settings-bootloader_ru.po~
\ No newline at end of file
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..76288d0
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,162 @@
+#!/usr/bin/make -f
+
+#SHELL := /bin/bash
+MAKEFILE_FILEPATH := $(abspath $(lastword $(MAKEFILE_LIST)))
+MAKEFILE_DIR := $(notdir $(patsubst %/,%,$(dir $(MAKEFILE_FILEPATH))))
+MAKEFILE_PATH := $(dir $(MAKEFILE_FILEPATH))
+
+CMAKE_COMMAND = cmake
+CMAKE_SOURCE_DIR = $(MAKEFILE_PATH)source
+CMAKE_BUILD_DIR = $(MAKEFILE_PATH)compile
+#CMAKE_SOURCE_DIR = ./source
+#CMAKE_BUILD_DIR = ./compile
+FILE_VERSION = VERSION.md
+DEPENDS = /bin/cmake
+PREFIX ?= /usr
+PKGNAME = $(MAKEFILE_DIR)
+#PKGNAME = ubl-settings-bootloader
+
+default_target: all
+
+.PHONY: all init depend debug prepare check build uninstall install clean up_ver help
+
+all: init build
+
+init:
+ @echo "Initialize ..."; \
+ sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2)\";/" -i source/ubl-settings-bootloader.cc; \
+ echo "-- Build path: ${CMAKE_BUILD_DIR}"
+
+depend:
+ @echo "Check depends ..."
+ @for FILE_DEPEND in $(DEPENDS); do \
+ if [ ! -f $${FILE_DEPEND} ]; then \
+ echo "ERROR: Depend '$${FILE_DEPEND}' not found !"; \
+ exit 1; \
+ fi; \
+ done; \
+ echo "Check depends: OK"
+# $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
+
+debug:
+ @echo "Debug ..."
+ if [ ! -d ${CMAKE_BUILD_DIR} ]; then \
+ $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \
+ fi; \
+ echo "Debug: OK"
+
+prepare:
+ @echo "Prepare ..."; \
+ if [ ! -d ${CMAKE_BUILD_DIR} ]; then \
+ $(CMAKE_COMMAND) -S${CMAKE_SOURCE_DIR} -B${CMAKE_BUILD_DIR} -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="${PREFIX}"; \
+ fi; \
+ echo "Prepare: OK"
+
+check:
+ @echo "Check ..."; \
+ if [ -f ${CMAKE_BUILD_DIR}/${PKGNAME} ]; then \
+ echo "Check: OK"; \
+ else \
+ echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not found !"; \
+ exit 1; \
+ fi
+
+build: depend prepare
+ @echo "Build ..."; \
+ make --directory=${CMAKE_BUILD_DIR}; \
+ echo "Build: OK"
+
+uninstall:
+ @echo "Uninstall ..."
+ @for FILE_PO in $(wildcard *.po); do \
+ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \
+ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \
+ PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \
+ $(RM) "$${PATH_FILE_MO}"; \
+ done
+ @for SIZE in 16x16 32x32 48x48 scalable; do \
+ $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.svg"; \
+ $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \
+ done
+ @for FILE_SVG in $(wildcard *.svg); do \
+ for SIZE in 16x16 32x32 48x48 scalable; do \
+ $(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \
+ done; \
+ done
+ @$(RM) "${DESTDIR}${PREFIX}/bin/${PKGNAME}"
+ @$(RM) "${DESTDIR}${PREFIX}/share/applications/${PKGNAME}.desktop"
+ @$(RM) "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/logo-background.png"
+ @$(RM) "${DESTDIR}${PREFIX}/share/polkit-1/actions/com.ublinux.pkexec.${PKGNAME}.exec.policy"
+ @$(RM) "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/com.ublinux.${PKGNAME}.svg"
+ @$(RM) -rd "${DESTDIR}${PREFIX}/share/${PKGNAME}"
+ @if [ -z ${DESTDIR} ]; then \
+ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
+ update-desktop-database --quiet &>/dev/null || true; \
+ [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
+ fi
+ @echo "Uninstall: OK"
+
+install: check uninstall
+ @echo "Install ..."
+ @for FILE_PO in $(wildcard *.po); do \
+ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \
+ install -dm755 "${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES"; \
+ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \
+ PATH_FILE_MO="${DESTDIR}${PREFIX}/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \
+ echo "$${FILE_PO}"; \
+ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \
+ done
+ @for SIZE in 16 32 48; do \
+ install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \
+ rsvg-convert -w $${SIZE} -h $${SIZE} -f png --keep-image-data "com.ublinux.${PKGNAME}.svg" -o "${DESTDIR}${PREFIX}/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/com.ublinux.${PKGNAME}.png"; \
+ done
+ @install -dm755 "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg"
+ @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}"
+ @install -dm755 "${DESTDIR}${PREFIX}/share/applications"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
+ @install -dm755 "${DESTDIR}${PREFIX}/share/polkit-1/actions"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/polkit-1/actions/" "com.ublinux.pkexec.${PKGNAME}.exec.policy"
+ @install -dm755 "${DESTDIR}${PREFIX}/share/${PKGNAME}"/{ui,css,images}
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/ui/" "${PKGNAME}.glade"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/css/" "${PKGNAME}.css"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/${PKGNAME}/images/" "logo-background.png"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.checked.svg"
+ @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/status/" "com.ublinux.${PKGNAME}.warning.svg"
+ @install -Dm644 -t /usr/share/${PKGNAME}/ cmdline-linux.csv
+ @install -Dm644 -t /usr/share/${PKGNAME}/ grub-terminal-input.csv
+ @install -Dm644 -t /usr/share/${PKGNAME}/ grub-terminal-output.csv
+ @if [ -z ${DESTDIR} ]; then \
+ [ -d "${DESTDIR}${PREFIX}/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}${PREFIX}/share/icons/hicolor/" &>/dev/null || true; \
+ update-desktop-database --quiet &>/dev/null || true; \
+ [ -d "${DESTDIR}${PREFIX}/share/applications" ] && touch "${DESTDIR}${PREFIX}/share/applications" &>/dev/null || true; \
+ fi
+ @echo "Install: OK"
+
+clean:
+ @echo "Clean ..."
+ @$(RM) -rd ${CMAKE_BUILD_DIR}
+ @if [ -d ${CMAKE_BUILD_DIR} ]; then \
+ echo "Clean: error, compile directory exist ${CMAKE_BUILD_DIR}"; \
+ else \
+ echo "Clean: OK"; \
+ fi
+
+up_ver:
+ @CURRENT=$$(grep 'VERSION' ${FILE_VERSION} | cut -d" " -f2); \
+ MAJOR=$$(cut -d. -f1 <<< $${CURRENT}); \
+ MINOR=$$(cut -d. -f2 <<< $${CURRENT}); \
+ VER="$${MAJOR}.$$(($${MINOR}+1))"; \
+ sed "s/VERSION *[[:digit:]]*.*/VERSION $${VER}/" -i ${FILE_VERSION}; \
+ echo "Updated version to VERSION.md: $${CURRENT} to $${VER}"
+
+help:
+ @echo "The following are some of the valid targets for this Makefile:"
+ @echo "... all (the default if no target is provided)"
+ @echo "... init"
+ @echo "... debug"
+ @echo "... prepare"
+ @echo "... compile"
+ @echo "... install"
+ @echo "... uninstall"
+ @echo "... clean"
diff --git a/README.md b/README.md
index f8c2bcf..85c8e4b 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,44 @@
# ubl-settings-bootloader
+# Настройка загрузчика
+[RU] Утилита для настройки загрузчика
+Utility for setting the bootloader
+
+
+
+# Build
+In order to build ubl-settings-bootloader you will need:
+
+- CMake
+- C compiler
+- GTK+ 3 & dependencies
+
+Once you have all the necessary dependencies, you can use:
+```sh
+$ make
+```
+
+# Installation
+After a successful build, just use:
+```sh
+$ sudo make install clean
+```
+
+# Uninstallation
+After a successful build, just use:
+```sh
+$ sudo make uninstall
+```
+# Usage
+```sh
+$ ubl-settings-bootloader --help
+GTK settings bootloader for UBLinux
+
+Usage: ubl-settings-bootloader [OPTIONS...]
+Options:
+ -h, --help Show this help
+ -V, --version Show package version
+
+$ ubl-settings-bootloader --version
+ubl-settings-bootloader version: x.xx
+```
\ No newline at end of file
diff --git a/VERSION.md b/VERSION.md
new file mode 100644
index 0000000..12ebd01
--- /dev/null
+++ b/VERSION.md
@@ -0,0 +1 @@
+VERSION 1.0
diff --git a/cmdline-linux.csv b/cmdline-linux.csv
new file mode 100644
index 0000000..1aba2df
--- /dev/null
+++ b/cmdline-linux.csv
@@ -0,0 +1,14 @@
+Option,Description
+quiet,Downloading without text messages
+splash,Show welcome window
+noplymouth,Disable Plymouth
+acpi=off,Disable ACPI
+noapic,Disable APIC
+nolapic,Disable local APIC
+single,Single User Mode
+nomodeset,Disable kernel selection and loading of video drivers
+915.enable_dc=0,Disable GPU power management
+ahci.mobile_lpm_policy=1,"Maximum performance, power management"
+snd-intel-dspcfg.dsp_driver=1,Forced selection of an Intel sound device driver
+intel_idle.max_cstate=1,Prevents the processor from going into a deep sleep state
+intel_idle.max_cstate=4,Eliminates flickering laptop display on Ultra Voltage processors
diff --git a/com.ublinux.pkexec.ubl-settings-bootloader.exec.policy b/com.ublinux.pkexec.ubl-settings-bootloader.exec.policy
new file mode 100644
index 0000000..50b1000
--- /dev/null
+++ b/com.ublinux.pkexec.ubl-settings-bootloader.exec.policy
@@ -0,0 +1,24 @@
+
+
+
+
+ UBLinux
+ https://ublinux.ru
+
+
+ Run "ubl-settings-bootloader" as root
+ Запуск утилиты "ubl-settings-bootloader" с правами root
+ Authentication is required to run "ubl-settings-bootloader"
+ Требуется авторизация для запуска утилиты "ubl-settings-bootloader" с правами root
+
+ auth_admin
+ auth_admin
+ auth_admin
+
+ /usr/bin/ubl-settings-bootloader
+ true
+
+
+
diff --git a/com.ublinux.ubl-settings-bootloader.checked.svg b/com.ublinux.ubl-settings-bootloader.checked.svg
new file mode 100644
index 0000000..e3cab42
--- /dev/null
+++ b/com.ublinux.ubl-settings-bootloader.checked.svg
@@ -0,0 +1,327 @@
+
+
diff --git a/com.ublinux.ubl-settings-bootloader.svg b/com.ublinux.ubl-settings-bootloader.svg
new file mode 100644
index 0000000..ceee7ff
--- /dev/null
+++ b/com.ublinux.ubl-settings-bootloader.svg
@@ -0,0 +1,3363 @@
+
+
diff --git a/com.ublinux.ubl-settings-bootloader.warning.svg b/com.ublinux.ubl-settings-bootloader.warning.svg
new file mode 100644
index 0000000..9a90dba
--- /dev/null
+++ b/com.ublinux.ubl-settings-bootloader.warning.svg
@@ -0,0 +1,55 @@
+
+
diff --git a/grub-terminal-input.csv b/grub-terminal-input.csv
new file mode 100644
index 0000000..4bd7f47
--- /dev/null
+++ b/grub-terminal-input.csv
@@ -0,0 +1,6 @@
+Option,Description
+console,PC BIOS & EFI console
+serial,Serial terminal
+ofconsole,Open Firmware Console
+at_keyboard,PC AT Keyboard (Coreboot)
+usb_keyboard,USB Keyboard (HID Boot protocol)
diff --git a/grub-terminal-output.csv b/grub-terminal-output.csv
new file mode 100644
index 0000000..30453d6
--- /dev/null
+++ b/grub-terminal-output.csv
@@ -0,0 +1,6 @@
+Option,Description
+console,PC BIOS & EFI console
+serial,Serial terminal
+ofconsole,Open Firmware Console
+gfxterm,Output in graphical mode
+vga_text,VGA text output (Coreboot)
diff --git a/logo-background.png b/logo-background.png
new file mode 100644
index 0000000..8eb67cb
Binary files /dev/null and b/logo-background.png differ
diff --git a/screenshot/screenshot.png b/screenshot/screenshot.png
new file mode 100644
index 0000000..9f7ddbf
Binary files /dev/null and b/screenshot/screenshot.png differ
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
new file mode 100644
index 0000000..39fe799
--- /dev/null
+++ b/source/CMakeLists.txt
@@ -0,0 +1,59 @@
+cmake_minimum_required(VERSION 3.7)
+project(ubl-settings-bootloader)
+
+find_package(PkgConfig REQUIRED)
+
+pkg_check_modules(GTK REQUIRED gtkmm-3.0)
+include_directories(${GTK_INCLUDE_DIRS})
+link_directories(${GTK_LIBRARY_DIRS})
+add_definitions(${GTK_CFLAGS_OTHER})
+
+find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
+
+option(WEBKIT_FOUND "No" OFF)
+
+find_library(WEBKIT_LIBRARIES_FOUND webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
+if(WEBKIT_LIBRARIES_FOUND)
+ option(WEBKIT_FOUND "Yes" ON)
+ PKG_CHECK_MODULES(WEBKIT REQUIRED webkit2gtk-4.0 webkit2gtk-web-extension-4.0)
+ include_directories(${WEBKIT_INCLUDE_DIRS})
+ link_directories(${WEBKIT_LIBRARY_DIRS})
+ add_definitions(${WEBKIT_CFLAGS_OTHER})
+endif()
+configure_file(ubl-settings-bootloader.h.in ubl-settings-bootloader-cm.h)
+
+
+
+#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always -std=c++2a -g")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Werror -Wmissing-declarations -fdiagnostics-color=always \
+ -O2 -pipe -fno-plt -fexceptions \
+ -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
+ -fstack-clash-protection -fcf-protection")
+
+set(SOURCE_FILES
+ ubl-settings-bootloader-cm.h
+ 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)
+
+set(LIBRARIES
+ ${GTK_LIBRARIES}
+ pthread)
+
+add_executable(ubl-settings-bootloader ${SOURCE_FILES})
+target_link_libraries(ubl-settings-bootloader PUBLIC ${WEBKIT_LIBRARIES} ${LIBRARIES})
+target_include_directories(ubl-settings-bootloader PUBLIC
+ "${PROJECT_BINARY_DIR}"
+ ${WEBKIT_INCLUDE_DIRS}
+ )
+install(TARGETS ubl-settings-bootloader DESTINATION bin)
\ No newline at end of file
diff --git a/source/load.cc b/source/load.cc
new file mode 100644
index 0000000..77873dc
--- /dev/null
+++ b/source/load.cc
@@ -0,0 +1,34 @@
+#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
new file mode 100644
index 0000000..b4d4a38
--- /dev/null
+++ b/source/load.h
@@ -0,0 +1,20 @@
+#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
new file mode 100644
index 0000000..edab5c2
--- /dev/null
+++ b/source/main.cc
@@ -0,0 +1,94 @@
+#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_file(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_file(path_glade);
+ pars_flag(1, argc, argv);
+ MainWindow* wnd = nullptr;
+ builder->get_widget_derived("window", wnd);
+ 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; i 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
new file mode 100644
index 0000000..f780860
--- /dev/null
+++ b/source/my_process.h
@@ -0,0 +1,32 @@
+#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
new file mode 100644
index 0000000..c824093
--- /dev/null
+++ b/source/save.cc
@@ -0,0 +1,151 @@
+#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;
+ 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;
+}
+
+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->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->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
new file mode 100644
index 0000000..40b13a1
--- /dev/null
+++ b/source/save.h
@@ -0,0 +1,33 @@
+#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();
+
+ 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-settings-bootloader.cc b/source/ubl-settings-bootloader.cc
new file mode 100755
index 0000000..66ee893
--- /dev/null
+++ b/source/ubl-settings-bootloader.cc
@@ -0,0 +1,1058 @@
+
+#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 = "1.0";
+
+CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::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);
+ builder->get_widget("plugBox", plugBox);
+ plugBox->get_parent()->remove(*plugBox);
+ add(*plugBox);
+ show_all_children();
+}
+
+int MainWindow::check_root() {
+ if (geteuid() != 0) {
+ return 1;
+ }
+ return 0;
+}
+
+MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder)
+ : Gtk::ApplicationWindow(obj), builder{builder} {
+ this->builder = builder;
+ this->settings();
+}
+
+MainWindow::MainWindow(Glib::RefPtr const& builder) {
+ this->builder = builder;
+ this->settings();
+}
+
+void MainWindow::settings(){
+ 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_USER");
+ vec_param_names.push_back("GRUB_PASSWORD");
+ vec_param_names.push_back("GRUB_DEFAULT");
+ this->get_builder();
+ this->localization();
+ this->add_CSS();
+ Gtk::Widget *boxWidget;
+ builder->get_widget("boxColor", boxWidget);
+ overHead->add_overlay(*boxWidget);
+ btnBoxAboutDialog->set_visible(false);
+ ubl_make_plugs(boxSave,boxButton, socket_ext_id_I, socket_trd_id_I);
+ #ifdef WEBKIT_FOUND
+ one = WEBKIT_WEB_VIEW( webkit_web_view_new() );
+ three = Glib::wrap(GTK_WIDGET(one));
+ wndWeb->add(*three);
+ #endif
+ this->flag_block_gui();
+ if (this->check_root() == 0) {
+ spbSecond->set_range(1, 60);
+ spbSecond->set_increments(1.0, 1.0);
+ spbSecond->set_value(1);
+ this->fill_in_view();
+ this->change_password_protecc();
+ this->change_security_login();
+ 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->write_list_entry_os(os_control_list);
+ this->download_local_cfg();
+ this->download_globl_cfg();
+ }
+ 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();
+ }
+ this->event();
+}
+
+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');
+ 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::write_list_entry_os(vector &os_control_list) {
+ for (string &name_os: os_control_list) {
+ cmbDefaultDonw->append(name_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) {
+ btnSynopsis->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::item_selected_kernel(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
+ auto selection_IPT = treeViewIPT->get_selection();
+ auto selection_OTT = treeViewOTT->get_selection();
+ selection_IPT->unselect_all();
+ selection_OTT->unselect_all();
+ if (flag_blocked_tree_view == false) {
+ string str_flags = template_item_selected(size_kernel, list_store_kernel);
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ Utils::str_replace_all(str_flags, "\"", "");
+ map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
+ Utils::str_replace_all(str_flags, " ", ", ");
+ entryKernel->set_text(str_flags);
+ }
+}
+
+void MainWindow::item_selected_OTT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
+ auto selection_kernel = treeViewKernel->get_selection();
+ auto selection_IPT = treeViewIPT->get_selection();
+ selection_kernel->unselect_all();
+ selection_IPT->unselect_all();
+ if (flag_blocked_tree_view == false) {
+ string str_flags = template_item_selected(size_OTT, list_store_OTT);
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ Utils::str_replace_all(str_flags, "\"", "");
+ map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
+ Utils::str_replace_all(str_flags, " ", ", ");
+ entryOTT->set_text(str_flags);
+ }
+}
+void MainWindow::item_selected_IPT(const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&) {
+ auto selection_kernel = treeViewKernel->get_selection();
+ auto selection_OTT = treeViewOTT->get_selection();
+ selection_kernel->unselect_all();
+ selection_OTT->unselect_all();
+ if (flag_blocked_tree_view == false) {
+ string str_flags = template_item_selected(size_IPT, list_store_IPT);
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ Utils::str_replace_all(str_flags, "\"", "");
+ map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
+ Utils::str_replace_all(str_flags, " ", ", ");
+ entryIPT->set_text(str_flags);
+ }
+}
+
+void MainWindow::get_download_mode(std::map &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;
+}
+
+void MainWindow::set_security_login() {
+ bool index = chbSecurityLogin->get_active();
+ string key = "";
+ if (index == false) {
+ key = "";
+ }
+ else if (index == true) {
+ key = entrySecurityLogin->get_text();
+ }
+ map_cmd_selection["GRUB_USER"] = key;
+}
+
+void MainWindow::get_security_login(std::map &map_temp) {
+ // Todo;
+ std::map :: iterator iter_map_data;
+ iter_map_data = map_temp.find("GRUB_USER");
+ if (iter_map_data != map_temp.end()) {
+ string value = iter_map_data->second;
+ if (value.length() != 0) {
+ Utils::str_replace_all(value, " ","");
+ Utils::str_replace_all(value, "\"","");
+ chbSecurityLogin->set_active(1);
+ entrySecurityLogin->set_sensitive(true);
+ entrySecurityLogin->set_text(value);
+ }
+ else {
+ chbSecurityLogin->set_active(0);
+ entrySecurityLogin->set_text("");
+ entrySecurityLogin->set_sensitive(false);
+ }
+ }
+ else {
+ chbSecurityLogin->set_active(0);
+ entrySecurityLogin->set_text("");
+ entrySecurityLogin->set_sensitive(false);
+ }
+}
+
+void MainWindow::set_password_protec() {
+ bool index = chbPasswordProtecc->get_active();
+ string key = "";
+ if (index == false){
+ key = "";
+ }
+ else if (index == true) {
+ key = entryPasswordProtecc->get_text();
+ }
+ if (key != "************") {
+ map_cmd_selection["GRUB_PASSWORD"] = key;
+ }
+}
+
+void MainWindow::get_password_protec(std::map &map_temp) {
+ std::map :: iterator iter_map_data;
+ iter_map_data = map_temp.find("GRUB_PASSWORD");
+ if (iter_map_data != map_temp.end()) {
+ string value = iter_map_data->second;
+ if (value.length() != 0) {
+ Utils::str_replace_all(value, "\"","");
+ chbPasswordProtecc->set_active(1);
+ entryPasswordProtecc->set_text("************");
+ entryPasswordProtecc->set_sensitive(true);
+ }
+ else{
+ chbPasswordProtecc->set_active(0);
+ entryPasswordProtecc->set_text("");
+ }
+ }
+ else {
+ chbPasswordProtecc->set_active(-1);
+ }
+}
+
+string MainWindow::template_item_selected(int size, Glib::RefPtr &list_store) {
+ string cmds = "";
+ for (int index = 0; index < size; index++) {
+ Gtk::TreeModel::Row row = list_store->children()[index];
+ if(row) {
+ if (row[m_columns.check_button] == true) {
+ cmds += row[m_columns.name] + " ";
+ }
+ }
+ }
+ cmds = "\"" + cmds + "\"";
+ 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("btnSynopsis", btnSynopsis);
+ 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);
+ builder->get_widget("chbSecurityLogin", chbSecurityLogin);
+ builder->get_widget("chbPasswordProtecc", chbPasswordProtecc);
+ builder->get_widget("entryPasswordProtecc", entryPasswordProtecc);
+ builder->get_widget("entrySecurityLogin", entrySecurityLogin);
+ builder->get_widget("cmbDefaultDonw", cmbDefaultDonw);
+ #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);
+
+}
+
+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(name_app);
+ 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(configuring_system_boot);
+ lblHeaderName->set_text(name_app);
+ aboutWindows->set_comments(system_boot);
+ lblHeaderAboutTopic->set_label(str_about);
+ aboutWindows->set_website_label(project_Home_page);
+ 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);
+ btnSynopsis->set_label(str_help);
+ btnAbout->set_label(str_about_1);
+ lblHeadeWndWeb->set_text(name_app);
+ btnSaveLocalGlob->set_label(save_all);
+ btnSaveLocal->set_label(save_local);
+ btnSaveGlob->set_label(save_global);
+ btnLoadGlob->set_label(load_global);
+ btnLoadLocal->set_label(load_local);
+ btnSave->set_label(str_save);
+ btnLoad->set_label(str_load);
+ this->set_title(name_app);
+ // Todo: check
+ entrySecurityLogin->set_tooltip_text(loading_animation_without);
+ entryPasswordProtecc->set_tooltip_text(user_password_configuration_edit_mode);
+ chbSecurityLogin->set_tooltip_text(loading_animation_without);
+ chbPasswordProtecc->set_tooltip_text(user_password_configuration_edit_mode);
+ lblDownloadMode->set_text(boot_screen_display_mode);
+ chbSecurityLogin->set_label(boot_menu_user_name);
+ chbPasswordProtecc->set_label(boot_menu_user_password);
+ cmbDownloadMode->append(loading_animation_with);
+ cmbDownloadMode->append(loading_animation_without);
+ cmbDownloadMode->append(no_loading_animation);
+ cmbDownloadMode->append(lack_loading_animation);
+ cmbDefaultDonw->append(last_successful_upload);
+
+ lblhelpHeader->set_text(read_documentation_web);
+ lblhelpText->set_text(_(redirected_documentation));
+ btnReadHelp->set_label(read_online);
+ btnCancelHelp->set_label(cancel);
+ chkAlwaysOpenHelp->set_label(always_redirect);
+ lblwebHeaderName->set_label(name_app);
+}
+
+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;
+}
+
+bool MainWindow::focus_out_txt_password(GdkEventFocus*) {
+ if (entryPasswordProtecc->get_text().length() == 0) {
+ info_status_app(info_box_error_css);
+ imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text(enter_password);
+ boxSave->set_sensitive(false);
+ }
+ else {
+ info_status_app(info_box_ok_css);
+ imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text("");
+ boxSave->set_sensitive(true);
+ string key = entryPasswordProtecc->get_text();
+ if (key != "************") {
+ map_cmd_selection["GRUB_PASSWORD"] = key;
+ }
+
+ }
+ return true;
+}
+bool MainWindow::focus_out_txt_login(GdkEventFocus*) {
+ if (entrySecurityLogin->get_text().length() == 0) {
+ info_status_app(info_box_error_css);
+ imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text(enter_login);
+ boxSave->set_sensitive(false);
+ }
+ else {
+ info_status_app(info_box_ok_css);
+ imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text("");
+ map_cmd_selection["GRUB_USER"] = entrySecurityLogin->get_text();
+ boxSave->set_sensitive(true);
+ }
+ return true;
+}
+
+bool MainWindow::focus_out_txt_kernel(GdkEventFocus*) {
+ this->set_entry_to_tree_view(list_store_kernel, *entryKernel, vec_Option_kernel, size_kernel);
+ return true;
+}
+
+bool MainWindow::focus_out_txt_IPT(GdkEventFocus*) {
+ this->set_entry_to_tree_view(list_store_IPT, *entryIPT, vec_Option_IPT, size_IPT);
+ return true;
+}
+bool MainWindow::focus_out_txt_OTT(GdkEventFocus*) {
+ this->set_entry_to_tree_view(list_store_OTT, *entryOTT, vec_Option_OTT, size_OTT);
+ return true;
+}
+
+void MainWindow::set_entry_to_tree_view(Glib::RefPtr &list_store, Gtk::Entry &entry, std::vector &vec_Option, int size) {
+ flag_blocked_tree_view = true;
+ vector vec_params;
+ std::string text = entry.get_text();
+ Utils::str_replace_all(text, " ", "");
+ vec_params = Utils::split(text, ',');
+ for (auto &name: vec_Option) {
+ this->set_row(list_store, size, name, false);
+ }
+ for (auto &name: vec_params) {
+ this->set_row(list_store, size, name, true);
+ }
+ flag_blocked_tree_view = false;
+}
+
+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(){
+ 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));
+ btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
+ 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_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel));
+ entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT));
+ entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT));
+ entrySecurityLogin->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_login));
+ entryPasswordProtecc->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_password));
+ chbPasswordProtecc->signal_toggled().connect([&]() {change_password_protecc();});
+ chbSecurityLogin->signal_toggled().connect([&]() {change_security_login();});
+ 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_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_kernel));
+ entryIPT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_IPT));
+ entryOTT->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_OTT));
+ }
+ 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));
+}
+
+bool MainWindow::gui_exit(GdkEventAny*) {
+ exit(1);
+ return true;
+}
+
+void MainWindow::change_security_login() {
+ bool index = chbSecurityLogin->get_active();
+ if (index == false) {
+ entrySecurityLogin->set_sensitive(false);
+ entrySecurityLogin->set_text("");
+ boxSave->set_sensitive(true);
+ info_status_app(info_box_ok_css);
+ imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text("");
+ }
+ else if (index == true) {
+ entrySecurityLogin->set_sensitive(true);
+ entrySecurityLogin->set_text("");
+ boxSave->set_sensitive(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) {
+ cmbDefaultDonw->set_active_text(value);
+ }
+ else {
+ cmbDefaultDonw->set_active(0);
+ }
+ }
+ else {
+ cmbDefaultDonw->set_active(-1);
+ }
+}
+
+void MainWindow::change_password_protecc() {
+ // Todo;
+ bool index = chbPasswordProtecc->get_active();
+ if (index == false) {
+ entryPasswordProtecc->set_sensitive(false);
+ entryPasswordProtecc->set_text("");
+ boxSave->set_sensitive(true);
+ info_status_app(info_box_ok_css);
+ imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
+ lblWarning->set_text("");
+ }
+ else if (index == true) {
+ entryPasswordProtecc->set_sensitive(true);
+ entryPasswordProtecc->set_text("");
+ boxSave->set_sensitive(true);
+ }
+ else {
+ boxSave->set_sensitive(true);
+ }
+}
+
+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_global1 = true;
+ bool _flag_save_local1 = true;
+ if (flag_save_global == false) {
+ _flag_save_global1 = this->save_template(global_save, global_remove , "global");
+ }
+ if (flag_save_local == false) {
+ _flag_save_local1 = this->save_template(system_save, system_remove , "system");
+ }
+ if (_flag_save_global1 && _flag_save_local1) {
+ 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_remove(str_flags, ",");
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ map_cmd_selection["GRUB_CMDLINE_LINUX"] = str_flags;
+ str_flags = entryIPT->get_text();
+ Utils::str_remove(str_flags, ",");
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ map_cmd_selection["GRUB_TERMINAL_INPUT"] = str_flags;
+ str_flags = entryOTT->get_text();
+ Utils::str_remove(str_flags, ",");
+ Utils::str_replace_all(str_flags, " \"", "\"");
+ map_cmd_selection["GRUB_TERMINAL_OUTPUT"] = str_flags;
+ if (chbLoadVariantSelectionTimer->get_active()) {
+ int second = spbSecond->get_value();
+ map_cmd_selection["GRUB_TIMEOUT"] = to_string(second);
+ }
+ else {
+ map_cmd_selection["GRUB_TIMEOUT"] = "";
+ }
+ int index = cmbDefaultDonw->get_active_row_number();
+ if (index != 0 && index != -1) {
+ map_cmd_selection["GRUB_DEFAULT"] = cmbDefaultDonw->get_active_text();
+ }
+ else {
+ map_cmd_selection["GRUB_DEFAULT"] = "";
+ }
+ this->set_download_mode();
+ this->set_security_login();
+ this->set_password_protec();
+}
+
+void MainWindow::download_globl_cfg() {
+ 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() {
+ 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_security_login(*map_temp);
+ this->get_password_protec(*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"];
+ if (str_last_launched_os_ubconfig.length() != 0) {
+ cmbDefaultDonw->set_active_text(str_last_launched_os_ubconfig);
+ }
+ else {
+ cmbDefaultDonw->set_active_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, "\"", "");
+ 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_USER"] = "";
+ map_cmd_selection_n["GRUB_PASSWORD"] = "";
+ map_cmd_selection_n["GRUB_DEFAULT"] = "";
+ 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, std::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::synopsis_show() {
+ if (flag_open_browser == true) {
+ this->open_browser();
+ }
+ else {
+ wndShowWeb->show_all();
+ }
+
+}
+
+void MainWindow::open_browser() {
+ #ifdef WEBKIT_FOUND
+ webkit_web_view_load_uri(one, link_doc);
+ wndWeb->show_all();
+ #else
+ this->template_open_browser();
+ #endif
+}
+
+void MainWindow::template_open_browser() {
+ string cmd = cmd_xdg + string(_(link_doc)) + " &";
+ 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 = std::string( buf.get(), buf.get() + size - 1 );
+ }
+ index_error = system(cmd.c_str());
+}
+void MainWindow::info_status_app(string stule) {
+ boxInfo->remove_class(info_box_ok_css);
+ boxInfo->remove_class(info_box_error_css);
+ boxInfo->add_class(stule);
+}
+
+void MainWindow::info_warning_error(int mess) {
+ if (obj_load.get_count_error() > 0 || obj_save.get_count_error() > 0) {
+ info_status_app(info_box_error_css);
+ imgInfo->set_from_icon_name(icon_warning, Gtk::ICON_SIZE_MENU);
+ string mess_error = "";
+ if (mess == 0) {
+ mess_error = string(local_read_error) + str_cmd_error;
+ lblWarning->set_text(mess_error);
+ }
+ else if (mess == 1) {
+ mess_error = string(global_read_error) + str_cmd_error;
+ lblWarning->set_text(mess_error);
+ }
+ else if (mess == 2) {
+ mess_error = string(local_write_error) + str_cmd_error;
+ lblWarning->set_text(mess_error);
+ }
+ else if (mess == 3) {
+ mess_error = string(global_write_error) + str_cmd_error;
+ lblWarning->set_text(mess_error);
+ }
+ else if (mess == 4) {
+ mess_error = string(error_save_all) + str_cmd_error;
+ lblWarning->set_text(mess_error);
+ }
+ str_cmd_error = "";
+ obj_load.set_count_error(0);
+ obj_save.set_count_error(0);
+ }
+ else {
+ info_status_app(info_box_ok_css);
+ imgInfo->set_from_icon_name(icon_checked, Gtk::ICON_SIZE_MENU);
+ if (mess == 0) {
+ lblWarning->set_text(local_load_ok);
+ }
+ else if (mess == 1) {
+ lblWarning->set_text(global_load_ok);
+ }
+ else if (mess == 2) {
+ lblWarning->set_text(local_ok_written);
+ }
+ else if (mess == 3) {
+ lblWarning->set_text(global_ok_written);
+ }
+ else if (mess == 4) {
+ lblWarning->set_text(successfully_save_all);
+ }
+ else if (mess == 5) {
+ lblWarning->set_text(nothing_save);
+ }
+ }
+}
+MainWindow::~MainWindow() {
+ #ifdef WEBKIT_FOUND
+ free(one);
+ #endif
+}
+
+void MainWindow::add_CSS(){
+ Glib::RefPtr cssProvider = Gtk::CssProvider::create();
+ cssProvider->load_from_path(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 lblInfoHead_css = lblInfoHead->get_style_context();
+ Glib::RefPtr boxButton_css = boxButton->get_style_context();
+ Glib::RefPtr boxSave_css = boxSave->get_style_context();
+ boxInfo = boxInfoError->get_style_context();
+ imgBG->set(path_img_head_background);
+ if (socket_trd_id_I == 0 && socket_ext_id_I == 0){
+ boxButton_css->add_class("bkim_no_plug");
+ boxSave_css->add_class("bkim_no_plug");
+ }
+ lblInfoHead_css->add_class("textHead");
+}
+
+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
new file mode 100644
index 0000000..1d2871a
--- /dev/null
+++ b/source/ubl-settings-bootloader.h
@@ -0,0 +1,329 @@
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include