pull/3/head
Igor Belitskiy 3 years ago
commit 6ea211bbd0

4
.gitignore vendored

@ -1,4 +1,6 @@
ublexec.glade~ ublexec.glade~
#ublexec.glade#
test.cpp test.cpp
.vscode .vscode
ublexec ublexec
nohup.out

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 61 KiB

@ -10,7 +10,7 @@ add_definitions(${GTK_CFLAGS_OTHER})
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
#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 -std=c++2a -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wmissing-declarations -fdiagnostics-color=always") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wmissing-declarations -fdiagnostics-color=always -g")
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)

@ -1,21 +1,6 @@
#include <iostream>
#include <cstddef>
#include <cstdlib>
#include <gtkmm.h>
#include <string>
#include <vector>
#include <map>
#include <stdio.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <gtkmm/plug.h>
#include <locale.h>
#include "ublexec.h" #include "ublexec.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
@ -30,6 +15,7 @@ int main(int argc, char** argv)
} }
auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug"); auto app = Gtk::Application::create(argc, argv, "org.gtkmm.example.plug");
auto builder = Gtk::Builder::create_from_file(path_glade); auto builder = Gtk::Builder::create_from_file(path_glade);
setlocale(LC_ALL, "");
bindtextdomain("ublexec", "/usr/share/locale/"); bindtextdomain("ublexec", "/usr/share/locale/");
bind_textdomain_codeset("ublexec", "UTF-8"); bind_textdomain_codeset("ublexec", "UTF-8");
textdomain("ublexec"); textdomain("ublexec");
@ -65,4 +51,4 @@ int main(int argc, char** argv)
return r; return r;
} }
} }

@ -1,28 +1,5 @@
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <memory>
#include <gtkmm.h>
#include <ostream>
#include <ctime>
#include <vector>
#include <map>
#include <fstream>
#include <filesystem>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <gtkmm/plug.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <string>
#include <pwd.h>
#include <thread>
#include "ublexec.h" #include "ublexec.h"
using namespace std; using namespace std;
string path_app= "/usr/bin/"; string path_app= "/usr/bin/";
string path_glade= "/usr/share/ublexec/ui/ublexec.glade"; string path_glade= "/usr/share/ublexec/ui/ublexec.glade";
string path_css = "/usr/share/ublexec/css/style.css"; string path_css = "/usr/share/ublexec/css/style.css";
@ -88,7 +65,6 @@ void MainWindow::get_builder(){
builder->get_widget("lblInfoNooPriority", lblInfoNooPriority); builder->get_widget("lblInfoNooPriority", lblInfoNooPriority);
builder->get_widget("lblInfoExec", lblInfoExec); builder->get_widget("lblInfoExec", lblInfoExec);
builder->get_widget("lblInfoPriority", lblInfoPriority); builder->get_widget("lblInfoPriority", lblInfoPriority);
builder->get_widget("lblInfoEnterProg", lblInfoEnterProg);
builder->get_widget("boxColor", boxColor); builder->get_widget("boxColor", boxColor);
builder->get_widget("lblGraphics", lblGraphics); builder->get_widget("lblGraphics", lblGraphics);
builder->get_widget("lblTools", lblTools); builder->get_widget("lblTools", lblTools);
@ -110,6 +86,12 @@ void MainWindow::get_builder(){
builder->get_widget("iconDevelopment", iconDevelopment); builder->get_widget("iconDevelopment", iconDevelopment);
builder->get_widget("iconSystem", iconSystem); builder->get_widget("iconSystem", iconSystem);
builder->get_widget("lblSystem", lblSystem); builder->get_widget("lblSystem", lblSystem);
builder->get_widget("lblHeaderName", lblHeaderName);
builder->get_widget("btnSynopsis", btnSynopsis);
builder->get_widget("btnAbout", btnAbout);
builder->get_widget("aboutWindows", aboutWindows);
builder->get_widget("btnSettings", btnSettings);
builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog);
} }
void MainWindow::set_icon_array(){ void MainWindow::set_icon_array(){
@ -125,18 +107,14 @@ void MainWindow::set_icon_array(){
array_icon[9]=this->iconSystem; array_icon[9]=this->iconSystem;
} }
void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr<Gtk::ListStore> &gtk_list_app){ void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr<Gtk::ListStore> &gtk_list_app){
gtk_list_app = Gtk::ListStore::create(m_Columns); gtk_list_app = Gtk::ListStore::create(m_Columns);
gtk_list_app->set_sort_column(m_Columns.m_col_description, Gtk::SORT_ASCENDING); gtk_list_app->set_sort_column(m_Columns.m_col_description, Gtk::SORT_ASCENDING);
icon->set_model(gtk_list_app); icon->set_model(gtk_list_app);
icon->set_markup_column(m_Columns.m_col_description); icon->set_text_column(m_Columns.m_col_description);
icon->set_pixbuf_column(m_Columns.m_col_pixbuf);
} }
void MainWindow::add_CSS(){ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create(); Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
cssProvider->load_from_path(path_css); cssProvider->load_from_path(path_css);
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create(); Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
@ -146,44 +124,46 @@ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context(); Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context();
context_box->add_class("cssboxColor1"); context_box->add_class("cssboxColor1");
context_lbl_head->add_class("textHead"); context_lbl_head->add_class("textHead");
} }
void MainWindow::localization(){ void MainWindow::localization(){
this->set_title(gettext("ublexec")); btnSynopsis->set_label(_("Synopsis"));
btnStart->set_label(gettext("Run")); btnAbout->set_label(_("About the program"));
wndChooseFileWallpaper->set_title(gettext("Please select File")); aboutWindows->set_comments(_("ublexec"));
dialogStartMenu->set_title(gettext("Selecting Programs")); aboutWindows->set_website_label(_("Project Home Page"));
lblInfoHead->set_text(gettext("Running applications as a user with a\nspecified priority")); lblHeaderName->set_text(_("ublexec"));
lblinfoCmd->set_text(gettext("Command Line")); this->set_title(_("ublexec"));
lblInfoTime->set_text(gettext("Team")); btnStart->set_label(_("Run"));
labInfoExecutTerm->set_text(gettext("Run in the terminal emulator")); wndChooseFileWallpaper->set_title(_("Please select File"));
lblInfoUser->set_text(gettext("User")); dialogStartMenu->set_title(_("Selecting Programs"));
lblInfoUserOther->set_text(gettext("Run as another user")); lblInfoHead->set_text(_("Running applications as a user with a\nspecified priority"));
lblInfoUserName->set_text(gettext("User Name")); lblinfoCmd->set_text(_("Command Line"));
lblInfoNooPriority->set_text(gettext("Priority")); lblInfoTime->set_text(_("Team"));
lblInfoExec->set_text(gettext("Change startup priority")); labInfoExecutTerm->set_text(_("Run in the terminal emulator"));
lblInfoPriority->set_text(gettext("Priority")); lblInfoUser->set_text(_("User"));
lblMessageError->set_text(gettext("Select an executable file or program")); lblInfoUserOther->set_text(_("Run as another user"));
lblInfoEnterProg->set_text(gettext("Selecting Programs")); lblInfoUserName->set_text(_("User Name"));
lblGraphics->set_text(gettext("Graphics")); lblInfoNooPriority->set_text(_("Priority"));
lblTools->set_text(gettext("Tools")); lblInfoExec->set_text(_("Change startup priority"));
lblInternet->set_text(gettext("Internet")); lblInfoPriority->set_text(_("Priority"));
lblMultimedia->set_text(gettext("Multimedia")); lblMessageError->set_text(_("Select an executable file or program"));
lblSettings->set_text(gettext("Settings")); lblGraphics->set_text(_("Graphics"));
lblEducation->set_text(gettext("Education")); lblTools->set_text(_("Tools"));
lblOffice->set_text(gettext("Office")); lblInternet->set_text(_("Internet"));
lblOther->set_text(gettext("Other")); lblMultimedia->set_text(_("Multimedia"));
lblDevelopment->set_text(gettext("Development")); lblSettings->set_text(_("Settings"));
lblSystem->set_text(gettext("System")); lblEducation->set_text(_("Education"));
lblOffice->set_text(_("Office"));
lblOther->set_text(_("Other"));
lblDevelopment->set_text(_("Development"));
lblSystem->set_text(_("System"));
} }
void MainWindow::event(){ void MainWindow::event(){
btnFilemaneg->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_filemaneg)); btnFilemaneg->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_filemaneg));
btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app)); btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app));
btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::start_cmd)); btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app));
cmbUser->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::changed_user)); chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::denamic_cmd));
//chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::execute_terminal));
chbAnotherUser->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::activ_or_block_other_user)); 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)); 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)); scalePriority->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::change_spin_priority));
@ -204,6 +184,59 @@ void MainWindow::event(){
iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other)); iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other));
iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development)); iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development));
iconSystem->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_System)); iconSystem->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_System));
btnSynopsis->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::synopsis_show));
btnAbout->signal_activate().connect([&](){aboutWindows->show();});
rbSudo->signal_toggled().connect([&](){
spinPriority->set_range(-20,19);
spinPriority->set_increments(1.0,-1.0);
scalePriority->set_range(-20,19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text("19 (Низкий)");
lblTime4EpriorityHigh->set_text("-20 (Высокий)");
});
rbSu->signal_toggled().connect(sigc::mem_fun(*this,&MainWindow::nice_hight));
rbPkexec->signal_toggled().connect(sigc::mem_fun(*this,&MainWindow::nice_hight));
cmbUser->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::denamic_cmd));
rbSudo->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::denamic_cmd));
txtCmd->signal_focus_out_event().connect(sigc::mem_fun(*this, &MainWindow::focus_out_txt_cmd));
txtCmd->signal_focus_in_event().connect(sigc::mem_fun(*this, &MainWindow::focus_in_txt_cmd));
}
bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event){
if (user_cmd.length() != 0){
//txtCmd->set_text(user_cmd);
}
else if (name_app.length() != 0){
//txtCmd->set_text(name_app);
}
else if (path_file.length() != 0){
//txtCmd->set_text(path_file);
}
else{
user_cmd = txtCmd->get_text();
//txtCmd->set_text(user_cmd);
}
cmd_old = txtCmd->get_text();
return true;
}
void MainWindow::nice_hight(){
Glib::ustring entry_user = cmbUser->get_active_text();
if (geteuid() != 0){
spinPriority->set_range(0,19);
spinPriority->set_increments(1.0,-1.0);
scalePriority->set_range(0,19);
scalePriority->set_value(0);
lblTimeEpriorityLow->set_text("19 (Низкий)");
lblTime4EpriorityHigh->set_text("0 (Высокий)");
}
this->denamic_cmd();
}
void MainWindow::synopsis_show(){
system("xdg-open https://wiki.ublinux.ru/ru/home &");
} }
void MainWindow::icon_clear(){ void MainWindow::icon_clear(){
@ -213,7 +246,6 @@ void MainWindow::icon_clear(){
list_Multimedia->clear(); list_Multimedia->clear();
list_Settings->clear(); list_Settings->clear();
list_Education->clear(); list_Education->clear();
list_Graphics->clear();
list_Office->clear(); list_Office->clear();
list_Other->clear(); list_Other->clear();
list_Development->clear(); list_Development->clear();
@ -266,6 +298,9 @@ void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr<Gtk::List
Gtk::TreeModel::Row row = *iter; Gtk::TreeModel::Row row = *iter;
auto app_name_exec = row[m_Columns.app_name_exec]; auto app_name_exec = row[m_Columns.app_name_exec];
const Glib::ustring description = row[m_Columns.m_col_description]; const Glib::ustring description = row[m_Columns.m_col_description];
path_file = "";
name_app = "";
user_cmd = "";
txtCmd->set_text(app_name_exec); txtCmd->set_text(app_name_exec);
name_app = txtCmd->get_text(); name_app = txtCmd->get_text();
int len_name_app = name_app.length(); int len_name_app = name_app.length();
@ -290,6 +325,7 @@ void MainWindow::unselect_icon(Gtk::IconView *icon_entry){
} }
void MainWindow::settings(){ void MainWindow::settings(){
system("nohup xhost + local: > /dev/null 2>&1 &");
this->pars_apps(); this->pars_apps();
this->get_builder(); this->get_builder();
this->event(); this->event();
@ -312,18 +348,17 @@ void MainWindow::settings(){
rbPkexec->set_sensitive(false); rbPkexec->set_sensitive(false);
rbSu->set_sensitive(false); rbSu->set_sensitive(false);
rbSudo->set_sensitive(false); rbSudo->set_sensitive(false);
btnBoxAboutDialog->set_visible(false);
//Gtk::Widget *standartHead; /*
//Gtk::Widget *plugBox; Gtk::Widget *boxButton;
//Gtk::Window *window; Gtk::Widget *boxAbout;
//Gtk::Widget *btnSave; builder->get_widget("plugBox",plugBox);
//builder->get_widget("standartHead",standartHead); builder->get_widget("window",window);
//builder->get_widget("plugBox",plugBox); builder->get_widget("boxButton",boxButton);
//builder->get_widget("window",window); builder->get_widget("boxAbout",boxAbout);
//builder->get_widget("btnSave",btnSave); ubl_make_plugs(boxAbout,boxButton, socket_ext_id_I, socket_trd_id_I);
//ubl_get_standard_ui(standartHead,plugBox,btnSave,window,"ublexec.svg",gettext("Running applications as a user with a\nspecified priority"),gettext("ublexec"),0,0); */
}
}
void MainWindow::close_entry_app(){ void MainWindow::close_entry_app(){
this->icon_clear(); this->icon_clear();
dialogStartMenu->hide(); dialogStartMenu->hide();
@ -342,6 +377,7 @@ void MainWindow::activ_or_block_execute_epriority(){
lblInfoNooPriority->set_sensitive(flag); lblInfoNooPriority->set_sensitive(flag);
lblTimeEpriorityLow->set_sensitive(flag); lblTimeEpriorityLow->set_sensitive(flag);
lblTime4EpriorityHigh->set_sensitive(flag); lblTime4EpriorityHigh->set_sensitive(flag);
this->denamic_cmd();
} }
void MainWindow::open_filemaneg(){ void MainWindow::open_filemaneg(){
@ -353,8 +389,10 @@ void MainWindow::close_filemaneg(){
} }
void MainWindow::get_path_filemaneg(){ void MainWindow::get_path_filemaneg(){
name_app = "";
user_cmd = "";
path_file = wndChooseFileWallpaper->get_filename(); path_file = wndChooseFileWallpaper->get_filename();
if (path_file.length()==0){} if (path_file.length() == 0){}
else{ else{
txtCmd->set_text(path_file); txtCmd->set_text(path_file);
this->close_filemaneg(); this->close_filemaneg();
@ -365,7 +403,6 @@ void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::Ref
Gtk::TreeModel::Row row = *(dtk_list->append()); Gtk::TreeModel::Row row = *(dtk_list->append());
row[m_Columns.m_col_filename] = path; row[m_Columns.m_col_filename] = path;
row[m_Columns.m_col_description] = Name; row[m_Columns.m_col_description] = Name;
row[m_Columns.app_name_exec] = Exec;
if (std::ifstream(path)){ if (std::ifstream(path)){
row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path); row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path);
} }
@ -373,6 +410,9 @@ void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::Ref
path = "/usr/share/icons/Faenza/emblems/16/emblem-danger.png"; path = "/usr/share/icons/Faenza/emblems/16/emblem-danger.png";
row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path); row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path);
} }
row[m_Columns.app_name_exec] = Exec;
row[m_Columns.float_h_align] = 0.5;
row[m_Columns.float_w_align] = 0.5;
} }
void MainWindow::open_list_app(){ void MainWindow::open_list_app(){
@ -420,118 +460,135 @@ void MainWindow::open_list_app(){
else if (str_categor=="System"){ else if (str_categor=="System"){
this->tempalte_row(st_app.Name,st_app.Exec, path, list_System); this->tempalte_row(st_app.Name,st_app.Exec, path, list_System);
} }
} }
} }
dialogStartMenu->show_all(); dialogStartMenu->show_all();
} }
void MainWindow::start_cmd(){ string MainWindow::start_cmd(string user_cmd=""){
string str_cmd_terminal=""; string str_cmd_terminal="";
string str_variants_root = ""; string str_variants_root = "";
string str_nice_cmd = ""; string str_nice_cmd = "";
string user_cmd = "";
if (name_app.length()==0 && path_file.length()==0){
user_cmd = txtCmd->get_text();
}
//=========================================
if (chbAnotherUser->get_active()){ if (chbAnotherUser->get_active()){
if (geteuid()!=0){ if (geteuid()!=0){
//chbTerminal->set_active(true); //chbTerminal->set_active(true);
} }
if (rbPkexec->get_active()){ if (rbPkexec->get_active()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) { str_variants_root = " pkexec --user " + cmbUser->get_active_text();
if (cbxExecuteEpriority->get_active()){
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY "; str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int());
}
else if (chbAnotherUser->get_active()){
str_variants_root = " pkexec --user " + cmbUser->get_active_text() + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
else{
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
} }
str_variants_root += " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
} }
else if (rbSu->get_active()){ else if (rbSu->get_active()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) { chbTerminal->set_active(true);
str_variants_root="su "; string str_user = cmbUser->get_active_text();
} if (str_user!="root"){
else if (chbAnotherUser->get_active()){ str_variants_root = "su -l " + cmbUser->get_active_text();
str_variants_root="su --user " + cmbUser->get_active_text() + " ";
} }
else{ else{
str_variants_root="su"; str_variants_root = "su ";
}
str_variants_root += + " -c \" DISPLAY=$DISPLAY ";
if (cbxExecuteEpriority->get_active()){
str_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
} }
} }
else if (rbSudo->get_active()){ else if (rbSudo->get_active()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) { chbTerminal->set_active(true);
if (getlogin()==cmbUser->get_active_text()){
str_variants_root="sudo "; str_variants_root="sudo ";
} }
else if (chbAnotherUser->get_active()){
str_variants_root="sudo --user " + cmbUser->get_active_text() + " ";
}
else{ else{
str_variants_root="sudo "; str_variants_root="sudo -u " + cmbUser->get_active_text() + " ";
}
if (cbxExecuteEpriority->get_active()){
str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
} }
} }
} }
if (cbxExecuteEpriority->get_active()){ if ((cbxExecuteEpriority->get_active()) && (chbAnotherUser->get_active()==false)){
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; str_nice_cmd = " nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
} }
if (user_cmd.length()==0 && name_app.length()==0 && path_file.length()==0){ if (user_cmd.length()==0 && name_app.length()==0 && path_file.length()==0){
messageError->show(); messageError->show();
return; return "";
} }
if (chbTerminal->get_active()){ if (chbTerminal->get_active() == true){
str_cmd_terminal=" xterm -e "; str_cmd_terminal = "xterm -e ";
} }
else{ else{
str_cmd_terminal=""; str_cmd_terminal = "";
} }
string cmd = ""; string cmd = "";
if (path_file!=""){ if (path_file != ""){
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' "; cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' ";
} }
else if (name_app!=""){ else if (name_app!=""){
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + name_app; cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + name_app;
} }
else{ else if (user_cmd.length()>0){
user_cmd = this->str_remove(user_cmd, str_cmd_terminal); cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd;
user_cmd = this->str_remove(user_cmd, str_variants_root); }
user_cmd = this->str_remove(user_cmd, str_nice_cmd); if (cmd.find("-e su ")!=string::npos){
string str_del = "xterm -e"; cmd+=" \"";
user_cmd = this->str_remove(user_cmd, str_del);
str_del = "nohup";
user_cmd = this->str_remove(user_cmd, str_del);
str_del = "pkexec --user superadmin env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY";
user_cmd = this->str_remove(user_cmd, str_del);
str_del = " &";
user_cmd = this->str_remove(user_cmd, str_del);
for (int index=-20; index<20; index++){
str_del = to_string(index);
user_cmd = this->str_remove(user_cmd, str_del);
}
str_del = cmbUser->get_active_text();
user_cmd = this->str_remove(user_cmd, str_del);
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + user_cmd ;
} }
txtCmd->set_text(cmd);
cmd += " > /dev/null 2>&1"; cmd += " > /dev/null 2>&1";
std::thread t(&me_thread, cmd);
t.detach(); return cmd;
path_file_name = ""; }
void MainWindow::call_app(string &cmd){
path_file = ""; path_file = "";
name_app = ""; name_app = "";
if (cmd.length() != 0){
std::thread t([&](string cmd){system(cmd.c_str());}, cmd);
t.detach();
}
} }
void MainWindow::denamic_cmd(){
if (chbTerminal->get_active()==true || chbAnotherUser->get_active()==true || cbxExecuteEpriority->get_active()==true){
if (txtCmd->get_text().length()==0){
chbTerminal->set_active(false);
chbAnotherUser->set_active(false);
cbxExecuteEpriority->set_active(false);
path_file = "";
name_app = "";
user_cmd = "";
txtCmd->set_text(user_cmd);
messageError->show();
}
else{
txtCmd->set_text(this->start_cmd(user_cmd));
}
}
else{
if (user_cmd.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
}
void me_thread(string cmd){ }
system(cmd.c_str());
bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
//this->focus_in_txt_cmd(event);
if (cmd_old!=txtCmd->get_text()){
user_cmd = txtCmd->get_text();
}
this->denamic_cmd();
return true;
}
void MainWindow::entry_app(){
if (name_app.length()==0 && path_file.length()==0){
}
string cmd = txtCmd->get_text();
this->call_app(cmd);
} }
void MainWindow::changed_user(){ void MainWindow::changed_user(){
@ -559,23 +616,26 @@ void MainWindow::activ_or_block_other_user(){
cmbUser->set_active(0); cmbUser->set_active(0);
cmbUser->set_sensitive(flag); cmbUser->set_sensitive(flag);
lblInfoUserName->set_sensitive(flag); lblInfoUserName->set_sensitive(flag);
if (flag_pkexec==true){ if (flag_pkexec == true){
rbPkexec->set_sensitive(flag); rbPkexec->set_sensitive(flag);
} }
if (flag_su==true){ if (flag_su == true){
rbSu->set_sensitive(flag); rbSu->set_sensitive(flag);
} }
if (flag_sudo==true){ if (flag_sudo == true){
rbSudo->set_sensitive(flag); rbSudo->set_sensitive(flag);
} }
this->denamic_cmd();
} }
void MainWindow::change_scale_priority(){ void MainWindow::change_scale_priority(){
scalePriority->set_value(spinPriority->get_value_as_int()); scalePriority->set_value(spinPriority->get_value_as_int());
this->denamic_cmd();
} }
void MainWindow::change_spin_priority(){ void MainWindow::change_spin_priority(){
spinPriority->set_value(scalePriority->get_value()); spinPriority->set_value(scalePriority->get_value());
this->denamic_cmd();
} }
void MainWindow::pars_dir_bin(){ void MainWindow::pars_dir_bin(){
@ -585,13 +645,13 @@ void MainWindow::pars_dir_bin(){
for (const auto & entry : fs::directory_iterator(path)){ for (const auto & entry : fs::directory_iterator(path)){
file_name = entry.path().filename().string(); file_name = entry.path().filename().string();
if (file_name=="su"){ if (file_name=="su"){
flag_su=true; flag_su = true;
} }
else if (file_name=="sudo"){ else if (file_name=="sudo"){
flag_sudo=true; flag_sudo = true;
} }
else if (file_name=="pkexec"){ else if (file_name=="pkexec"){
flag_pkexec=true; flag_pkexec = true;
} }
} }
rbPkexec->set_sensitive(flag_pkexec); rbPkexec->set_sensitive(flag_pkexec);
@ -610,7 +670,7 @@ void MainWindow::pars_users(){
break; break;
} }
if (entry->pw_uid>=1000 && entry->pw_uid!=65534){ if (entry->pw_uid >= 1000 && entry->pw_uid!=65534){
cmbUser->append(entry->pw_name); cmbUser->append(entry->pw_name);
} }
} }
@ -628,13 +688,12 @@ vector<std::string> MainWindow::split(const std::string &s, char delim) {
return elems; return elems;
} }
string MainWindow::str_remove(std::string& source, const std::string& to_remove){ void MainWindow::str_remove(std::string& source, std::string & to_remove){
auto begin = source.find(to_remove); string::size_type n = to_remove.length();
if (begin!=std::string::npos){ for (string::size_type i = source.find(to_remove);
int len_to_remove = to_remove.length(); i != string::npos;
source.erase(begin, begin+len_to_remove); i = source.find(to_remove))
} source.erase(i, n);
return source;
} }
void MainWindow::pars_apps(){ void MainWindow::pars_apps(){

@ -1,15 +1,20 @@
#include <gtkmm/window.h>
#include <iostream> #include <glibmm/i18n.h>
#include <gtkmm/plug.h>
#include <gtkmm/stock.h>
#include <gtkmm.h> #include <gtkmm.h>
#include <iostream>
#include <map>
#include <string> #include <string>
#include <array>
#include <vector> #include <vector>
#include <map> #include <fstream>
#include <filesystem>
#include <stdio.h> #include <stdio.h>
#include <gtkmm/stock.h> #include <pwd.h>
#include <gtkmm/window.h> #include <ostream>
#include <gtkmm/plug.h> #include <thread>
#include <locale.h> #include <algorithm>
#include <libintl.h>
using namespace std; using namespace std;
@ -47,9 +52,11 @@ public:
void close_filemaneg(); void close_filemaneg();
void get_path_filemaneg(); void get_path_filemaneg();
void open_list_app(); void open_list_app();
void start_cmd(); string start_cmd(string user_cmd);
void call_app(string &cmd);
void changed_user(); void changed_user();
void execute_terminal(){} void entry_app();
void nice_hight();
void execute_another_User(){} void execute_another_User(){}
void activ_or_block_other_user(); void activ_or_block_other_user();
void change_scale_priority(); void change_scale_priority();
@ -74,9 +81,13 @@ public:
void select_System(); void select_System();
void icon_clear(); void icon_clear();
void set_icon_array(); void set_icon_array();
void synopsis_show();
void denamic_cmd();
bool focus_out_txt_cmd(GdkEventFocus* event);
bool focus_in_txt_cmd(GdkEventFocus* event);
//static void me_thread(string cmd); //static void me_thread(string cmd);
void unselect_icon(Gtk::IconView *icon_entry); void unselect_icon(Gtk::IconView *icon_entry);
string str_remove(std::string& source, const std::string& to_remove); void str_remove(std::string& source, std::string & to_remove);
vector<std::string> split(const std::string &s, char delim); vector<std::string> split(const std::string &s, char delim);
public: public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord class ModelColumns : public Gtk::TreeModel::ColumnRecord
@ -88,12 +99,16 @@ public:
add(m_col_description); add(m_col_description);
add(m_col_pixbuf); add(m_col_pixbuf);
add(app_name_exec); add(app_name_exec);
add(float_h_align);
add(float_w_align);
} }
Gtk::TreeModelColumn<std::string> m_col_filename; Gtk::TreeModelColumn<std::string> m_col_filename;
Gtk::TreeModelColumn<Glib::ustring> m_col_description; Gtk::TreeModelColumn<Glib::ustring> m_col_description;
Gtk::TreeModelColumn<Glib::ustring> app_name_exec; Gtk::TreeModelColumn<Glib::ustring> app_name_exec;
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > m_col_pixbuf; Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > m_col_pixbuf;
Gtk::TreeModelColumn<float> float_h_align;
Gtk::TreeModelColumn<float> float_w_align;
}; };
ModelColumns m_Columns; ModelColumns m_Columns;
public: public:
@ -135,7 +150,6 @@ public:
Gtk::Label *lblInfoNooPriority; Gtk::Label *lblInfoNooPriority;
Gtk::Label *lblInfoExec; Gtk::Label *lblInfoExec;
Gtk::Label *lblInfoPriority; Gtk::Label *lblInfoPriority;
Gtk::Label *lblInfoEnterProg;
Gtk::Label *lblGraphics; Gtk::Label *lblGraphics;
Gtk::Label *lblTools; Gtk::Label *lblTools;
@ -147,6 +161,7 @@ public:
Gtk::Label *lblOther; Gtk::Label *lblOther;
Gtk::Label *lblDevelopment; Gtk::Label *lblDevelopment;
Gtk::Label *lblSystem; Gtk::Label *lblSystem;
Gtk::Label *lblHeaderName;
Gtk::IconView *iconGraphics; Gtk::IconView *iconGraphics;
Gtk::IconView *iconTools; Gtk::IconView *iconTools;
@ -159,6 +174,11 @@ public:
Gtk::IconView *iconDevelopment; Gtk::IconView *iconDevelopment;
Gtk::IconView *iconSystem; Gtk::IconView *iconSystem;
Gtk::IconView *iconEntry; Gtk::IconView *iconEntry;
Gtk::MenuItem *btnAbout;
Gtk::MenuItem *btnSynopsis;
Gtk::AboutDialog *aboutWindows;
Gtk::MenuButton *btnSettings;
Gtk::ButtonBox *btnBoxAboutDialog;
Glib::RefPtr<Gtk::ListStore> list_Graphics; Glib::RefPtr<Gtk::ListStore> list_Graphics;
Glib::RefPtr<Gtk::ListStore> list_Tools; Glib::RefPtr<Gtk::ListStore> list_Tools;
@ -171,6 +191,11 @@ public:
Glib::RefPtr<Gtk::ListStore> list_Development; Glib::RefPtr<Gtk::ListStore> list_Development;
Glib::RefPtr<Gtk::ListStore> list_System; Glib::RefPtr<Gtk::ListStore> list_System;
public: public:
string cmd_old = "";
string user_cmd="";
string user_cmd_old="";
string name_app_old="";
string path_file_old="";
string execute_cmd = ""; string execute_cmd = "";
string path_file = ""; string path_file = "";
string name_app = ""; string name_app = "";

@ -4,4 +4,67 @@
.textHead{ .textHead{
text-shadow: 1px 1px #ffffff; text-shadow: 1px 1px #ffffff;
} }
.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;
}
.menuitemmiddle:hover {
background:@theme_bg_color;
}
.menuitembottom:hover {
background:@theme_bg_color;
}
.menuitemtop:hover* {
margin:2px 2px 0 2px;
padding: 5px 10px 3px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitemmiddle:hover* {
margin:0 2px 0 2px;
padding: 3px 10px 3px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitembottom:hover* {
margin:0 2px 2px 2px;
padding: 3px 10px 5px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitembottom{
margin-top:0px;
border-color:alpha(@theme_text_color, 0.4);
border-style:solid;
border-left-width:1px;
border-bottom-width:1px;
border-right-width:1px;
}
.menuitemmiddle{
margin-top:0px;
margin-bottom:0px;
border-color:alpha(@theme_text_color, 0.4);
border-style:solid;
border-left-width:1px;
border-right-width:1px;
}
.menuitemtop{
margin-bottom:0px;
border-color:alpha(@theme_text_color, 0.4);
border-style:solid;
border-left-width:1px;
border-top-width:1px;
border-right-width:1px;
}

File diff suppressed because it is too large Load Diff

@ -6,6 +6,15 @@
msgid "" msgid ""
msgstr "" msgstr ""
msgid "About the program"
msgstr "О программе"
msgid "Synopsis"
msgstr "Справка"
msgid "Project Home Page"
msgstr "Домашняя страница проекта"
msgid "System" msgid "System"
msgstr "Система" msgstr "Система"

Loading…
Cancel
Save