You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ubl-settings-bootloader/source/ubl-settings-bootloader.cc

239 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "ubl-settings-bootloader.h"
using namespace std;
string path_app= "/usr/bin/";
string path_glade= "/usr/share/ubl-settings-bootloader/ui/ubl-settings-bootloader.glade";
string path_css = "/usr/share/ubl-settings-bootloader/css/style.css";
string app_name = "ubl-settings-bootloader";
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_short_name('s');
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketIDArg.set_description("Settings manager socket");
add_entry(socketIDArg, m_socketID);
}
::Window CmdArgParser::GetSocketID() const{
return m_socketID;
}
SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr<Gtk::Builder> 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();
}
MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr<Gtk::Builder> const& builder)
: Gtk::ApplicationWindow(obj), builder{builder} {
this->builder = builder;
this->settings();
}
MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
this->builder = builder;
this->settings();
}
void MainWindow::settings(){
this->get_builder();
this->localization();
this->event();
this->add_CSS();
}
void MainWindow::get_monitor_size(){
GdkRectangle workarea;
gdk_monitor_get_workarea(
gdk_display_get_primary_monitor(gdk_display_get_default()),&workarea);
screen_width = workarea.width;
screen_hight = workarea.height;
}
void MainWindow::get_builder(){
builder->get_widget("chbLoadVariantSelectionTimer", chbLoadVariantSelectionTimer);
builder->get_widget("chbLastSelectionWillBecome", chbLastSelectionWillBecome);
builder->get_widget("chbQuiet", chbQuiet);
builder->get_widget("chbSplash", chbSplash);
builder->get_widget("chbPlymouth", chbPlymouth);
builder->get_widget("chbAcpi", chbAcpi);
builder->get_widget("chbNоapic", chbNоapic);
builder->get_widget("chbNolapic", chbNolapic);
builder->get_widget("chbSingle", chbSingle);
builder->get_widget("chbHomodeset", chbHomodeset);
builder->get_widget("chbI915Enable", chbI915Enable);
builder->get_widget("chbAhci", chbAhci);
builder->get_widget("chbSndIntel", chbSndIntel);
builder->get_widget("chbintelMax1", chbintelMax1);
builder->get_widget("chbintelMax4", chbintelMax4);
builder->get_widget("chbconsoleIT", chbconsoleIT);
builder->get_widget("chbSerialIT", chbSerialIT);
builder->get_widget("chbofConsoleIT", chbofConsoleIT);
builder->get_widget("chbAtKeyboard", chbAtKeyboard);
builder->get_widget("chbUsbKeyboard", chbUsbKeyboard);
builder->get_widget("chbofConsoleOT", chbofConsoleOT);
builder->get_widget("chbSerialOT", chbSerialOT);
builder->get_widget("chbconsoleOT", chbconsoleOT);
builder->get_widget("chbGfxterm", chbGfxterm);
builder->get_widget("chbVgaText", chbVgaText);
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("lblDownloadMenu", lblDownloadMenu);
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("entryIT", entryIT);
builder->get_widget("entryOT", entryOT);
builder->get_widget("boxInput1", boxInput1);
builder->get_widget("boxInput2", boxInput2);
builder->get_widget("boxOtput1", boxOtput1);
builder->get_widget("boxOtput2", boxOtput2);
builder->get_widget("boxKernel", boxKernel);
builder->get_widget("boxKernel1", boxKernel1);
builder->get_widget("boxKernel2", boxKernel2);
builder->get_widget("aboutWindows", aboutWindows);
builder->get_widget("boxColor", boxColor);
}
void MainWindow::localization(){
lblInfoHead->set_text(gettext("Configuring system boot parameters"));
lblHeaderName->set_text(gettext("UBConfig - Loading"));
aboutWindows->set_comments(gettext("Setting bootloader"));
aboutWindows->set_website_label(gettext("Project Home Page"));
lblInfoCommand->set_text(gettext("Command line parameters:"));
lblInfoCommand1->set_text(gettext("Command line parameters:"));
lblInfoCommand2->set_text(gettext("Command line parameters:"));
lblInfoDefaultDonw->set_text(gettext("Default download"));
lblInfoSeconds->set_text(gettext("Seconds"));
lblDownloadMenu->set_text(gettext("Download menu"));
lblInfoInputTerminal->set_text(gettext("Input terminal"));
lblInfoOutputTerminal->set_text(gettext("Output terminal"));
chbLoadVariantSelectionTimer->set_label(gettext("Load variant selection timer"));
chbLastSelectionWillBecome->set_label(gettext("The last selection will become the default boot choice"));
chbQuiet->set_label(gettext("quiet (Downloading without text messages)"));
chbSplash->set_label(gettext("splash (Show welcome window)"));
chbPlymouth->set_label(gettext("no plymouth (Disable Plymouth)"));
chbAcpi->set_label(gettext("acpi=off (Disable ACPI)"));
chbNоapic->set_label(gettext("nоapic (Disable APIC)"));
chbNolapic->set_label(gettext("nolapic (Disable local APIC)"));
chbSingle->set_label(gettext("single (Single User Mode)"));
chbHomodeset->set_label(gettext("nomodeset (Disable kernel selection and loading of video drivers)"));
chbI915Enable->set_label(gettext("i915.enable_dc=0 (Disable GPU power management)"));
chbAhci->set_label(gettext("ahci.mobile_jpm_policy=1 (Maximum performance, power management)"));
chbSndIntel->set_label(gettext("snd-intel-dspcfg.dsp_driver=1 (Forced selection of a sound device driver from Intel)"));
chbintelMax1->set_label(gettext("intel_idle max_cstate=1 (Prevents the processor from going into a deep sleep state)"));
chbintelMax4->set_label(gettext("intel_idle.max_cstate=4 (Eliminates flickering laptop display on processors Ultra Voltage)"));
chbconsoleIT->set_label(gettext("console (PC BIOS & console EFI)"));
chbSerialIT->set_label(gettext("serial (Serial terminal)"));
chbofConsoleIT->set_label(gettext("ofconsole (Console Open Firmware)"));
chbAtKeyboard ->set_label(gettext("at_keyboard (Keyboard PC AT (Coreboot))"));
chbUsbKeyboard->set_label(gettext("usb_keyboard (Keyboard USB Keyboard (protocol HID Boot))"));
chbofConsoleOT->set_label(gettext("ofconsole (Console Open Firmware)"));
chbSerialOT->set_label(gettext("serial (Serial terminal)"));
chbconsoleOT->set_label(gettext("console (PC BIOS & console EFI)"));
chbGfxterm->set_label(gettext("gfxterm (Output in graphical mode)"));
chbVgaText->set_label(gettext("chbVgaText"));
//set_label(gettext("Command line parameters:"));
}
void MainWindow::event(){
chbintelMax1->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax1));
chbintelMax4->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::fn_event_intelMax4));
signal_configure_event().connect(sigc::mem_fun(*this, &MainWindow::gui_set_orientation), false);
}
void MainWindow::fn_event_intelMax1(){
chbintelMax4->set_active(false);
}
void MainWindow::fn_event_intelMax4(){
chbintelMax1->set_active(false);
}
bool MainWindow::gui_set_orientation(GdkEventConfigure* event){
if (event){}
int w,h;
this->get_monitor_size();
w = this->get_width();
h = this->get_height();
int padding = w*0.11;
float padding_interest = 0.6;
if ((width!=w) || heigh!=h){
if (((screen_width/2)<=w) && ((screen_hight-padding)<=h)){
boxOtput1->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxOtput2->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxInput1->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxInput2->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxKernel->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxKernel1->set_orientation(Gtk::ORIENTATION_VERTICAL);
boxKernel2->set_orientation(Gtk::ORIENTATION_VERTICAL);
cout << 1 << endl;
}
else if (((screen_width*padding_interest)<=w) && ((screen_hight*padding_interest)<=h)){
boxOtput1->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxOtput2->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxInput1->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxInput2->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxKernel->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxKernel1->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
boxKernel2->set_orientation(Gtk::ORIENTATION_HORIZONTAL);
cout << 2 << endl;
}
else{
}
width=w;
heigh=h;
}
return false;
}
void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
cssProvider->load_from_path(path_css);
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
Glib::RefPtr<Gdk::Screen> 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<Gtk::StyleContext> context_box = boxColor->get_style_context();
Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context();
context_box->add_class("cssboxColor1");
context_lbl_head->add_class("textHead");
}