diff --git a/source/ublexec.cc b/source/ublexec.cc index 3e232b5..d5c5082 100644 --- a/source/ublexec.cc +++ b/source/ublexec.cc @@ -103,7 +103,8 @@ void MainWindow::get_builder() { builder->get_widget("aboutWindows", aboutWindows); builder->get_widget("btnSettings", btnSettings); builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog); - builder->get_widget("boxAbout",boxAbout); + builder->get_widget("boxAbout", boxAbout); + builder->get_widget("cmbTerminal", cmbTerminal); } void MainWindow::set_icon_array() { @@ -176,13 +177,14 @@ void MainWindow::localization() { lblOther->set_text(_("Other")); lblDevelopment->set_text(_("Development")); lblSystem->set_text(_("System")); + } void MainWindow::event() { btnFilemaneg->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_filemaneg)); btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app)); btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app)); - chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::denamic_cmd)); + chbTerminal->signal_toggled().connect([&]() {cmbTerminal->set_sensitive(chbTerminal->get_active());this->denamic_cmd();}); chbAnotherUser->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::activ_or_block_other_user)); spinPriority->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::change_scale_priority)); scalePriority->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::change_spin_priority)); @@ -214,6 +216,7 @@ void MainWindow::event() { rbPkexec->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); } + void MainWindow::sudo_nice(){ if (geteuid() == 0 || cmbUser->get_active_text() == "root"){ spinPriority->set_range(-20, 19); @@ -396,6 +399,7 @@ void MainWindow::settings() { lblTime4EpriorityHigh->set_text("0 (Высокий)"); scalePriority->set_inverted(true); this->pars_dir_bin(); + this->pars_dir_terminal(); this->is_user_wheel(); this->pars_users(); this->activ_or_block_execute_epriority(); @@ -407,6 +411,7 @@ void MainWindow::settings() { rbSu->set_sensitive(false); rbSudo->set_sensitive(false); btnBoxAboutDialog->set_visible(false); + cmbTerminal->set_sensitive(false); ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0); } @@ -596,7 +601,25 @@ string MainWindow::start_cmd(string user_cmd) { return ""; } if (chbTerminal->get_active() == true) { - str_cmd_terminal = "xterm -e "; + string name_terminal = cmbTerminal->get_active_text(); + if (name_terminal.length() != 0){ + if (name_terminal == "xfce4-terminal") { + str_cmd_terminal = "xfce4-terminal -x "; + } + else if (name_terminal == "konsole") { + str_cmd_terminal = "konsole -e "; + } + else if (name_terminal == "xterm") { + str_cmd_terminal = "xterm -e "; + } + else{ + str_cmd_terminal = ""; + } + } + else{ + str_cmd_terminal = ""; + } + } else{ str_cmd_terminal = ""; @@ -611,7 +634,7 @@ string MainWindow::start_cmd(string user_cmd) { else if (user_cmd.length() > 0) { cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd; } - if (cmd.find("-e su ") != string::npos) { + if ((cmd.find("-e su ") != string::npos) || (cmd.find("-x su ") != string::npos)) { cmd+=" \""; } cmd = "nohup " + cmd; @@ -737,6 +760,26 @@ void MainWindow::pars_dir_bin() { rbSudo->set_sensitive(flag_sudo); } +void MainWindow::pars_dir_terminal() { + namespace fs = std::filesystem; + std::string path = "/bin"; + string file_name = ""; + for (const auto & entry: fs::directory_iterator(path)) { + file_name = entry.path().filename().string(); + if (file_name == "konsole") { + cmbTerminal->append("konsole"); + cmbTerminal->set_active_text("konsole"); + } + else if (file_name == "xfce4-terminal") { + cmbTerminal->append("xfce4-terminal"); + cmbTerminal->set_active_text("xfce4-terminal"); + } + else if (file_name == "xterm") { + cmbTerminal->append("xterm"); + } + } +} + void MainWindow::is_user_wheel(){ string response = this->call("id -Gn"); if (response.find("wheel") == string::npos){ diff --git a/source/ublexec.h b/source/ublexec.h index 2a229f8..3a482c5 100755 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -92,6 +92,7 @@ public: bool focus_out_txt_cmd(GdkEventFocus* event); bool focus_in_txt_cmd(GdkEventFocus* event); void unselect_icon(Gtk::IconView *icon_entry); + void pars_dir_terminal(); void str_remove(std::string& source, std::string & to_remove); string call(string cmd); vector split(const std::string &s, char delim); @@ -184,6 +185,7 @@ public: Gtk::AboutDialog *aboutWindows; Gtk::MenuButton *btnSettings; Gtk::ButtonBox *btnBoxAboutDialog; + Gtk::ComboBoxText *cmbTerminal; Glib::RefPtr list_Graphics; Glib::RefPtr list_Tools; Glib::RefPtr list_Internet; diff --git a/ublexec.glade b/ublexec.glade index e499995..5dfc8f4 100644 --- a/ublexec.glade +++ b/ublexec.glade @@ -1080,6 +1080,7 @@ specified priority True False + True vertical @@ -1100,14 +1101,16 @@ specified priority False 5 5 + True vertical True False + True - 145 + 123 True False 5 @@ -1225,9 +1228,10 @@ specified priority False 6 6 + True - 131 + 110 True False 15 @@ -1268,6 +1272,22 @@ specified priority 1 + + + True + False + end + 5 + 5 + 6 + + + False + True + end + 2 + + False @@ -1304,6 +1324,7 @@ specified priority True False 5 + True vertical @@ -1322,11 +1343,13 @@ specified priority False 5 5 + True vertical True False + True True @@ -1428,9 +1451,10 @@ specified priority True False + True - 145 + 123 True False 5 @@ -1516,6 +1540,7 @@ specified priority True False 5 + True vertical @@ -1534,6 +1559,7 @@ specified priority False 5 5 + True vertical @@ -1567,6 +1593,7 @@ specified priority True False + True 5 @@ -1639,9 +1666,10 @@ specified priority True False + False - 65 + 62 True False 15 @@ -1701,7 +1729,7 @@ specified priority - 95 + 107 True False end