@ -110,6 +110,14 @@ 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 ( " popInfo " , popInfo ) ;
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 ( ) {
@ -150,6 +158,9 @@ void MainWindow::add_CSS(){
}
}
void MainWindow : : localization ( ) {
void MainWindow : : localization ( ) {
aboutWindows - > set_comments ( gettext ( " ublexec " ) ) ;
aboutWindows - > set_website_label ( gettext ( " Project Home Page " ) ) ;
lblHeaderName - > set_text ( gettext ( " ublexec " ) ) ;
this - > set_title ( gettext ( " ublexec " ) ) ;
this - > set_title ( gettext ( " ublexec " ) ) ;
btnStart - > set_label ( gettext ( " Run " ) ) ;
btnStart - > set_label ( gettext ( " Run " ) ) ;
wndChooseFileWallpaper - > set_title ( gettext ( " Please select File " ) ) ;
wndChooseFileWallpaper - > set_title ( gettext ( " Please select File " ) ) ;
@ -204,6 +215,14 @@ 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_clicked ( ) . connect ( sigc : : mem_fun ( * this , & MainWindow : : synopsis_show ) ) ;
btnAbout - > signal_clicked ( ) . connect ( [ & ] ( ) { aboutWindows - > show ( ) ; } ) ;
btnSettings - > signal_clicked ( ) . connect ( [ & ] ( ) { popInfo - > show ( ) ; } ) ;
}
void MainWindow : : synopsis_show ( ) {
//wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home");
}
}
void MainWindow : : icon_clear ( ) {
void MainWindow : : icon_clear ( ) {
@ -312,6 +331,7 @@ 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 *standartHead;
//Gtk::Widget *plugBox;
//Gtk::Widget *plugBox;
@ -354,7 +374,7 @@ void MainWindow::close_filemaneg(){
void MainWindow : : get_path_filemaneg ( ) {
void MainWindow : : get_path_filemaneg ( ) {
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 ( ) ;
@ -420,7 +440,6 @@ 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 ( ) ;
@ -435,46 +454,28 @@ void MainWindow::start_cmd(){
if ( name_app . length ( ) = = 0 & & path_file . length ( ) = = 0 ) {
if ( name_app . length ( ) = = 0 & & path_file . length ( ) = = 0 ) {
user_cmd = txtCmd - > get_text ( ) ;
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 ) ) {
if ( ( chbAnotherUser - > get_active ( ) ) & & ( cmbUser - > get_active_text ( ) . length ( ) = = 0 ) ) {
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " ;
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " ;
}
}
else if ( chbAnotherUser - > get_active ( ) ) {
else if ( chbAnotherUser - > get_active ( ) ) {
str_variants_root = " pkexec --user " + cmbUser - > get_active_text ( ) + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " ;
str_variants_root = " pkexec --user " + cmbUser - > get_active_text ( ) + " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " ;
}
}
else {
else {
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY " ;
str_variants_root = " pkexec --user ${USER} 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 " ;
str_variants_root = " su -l " + cmbUser - > get_active_text ( ) + " -c \" DISPLAY=$DISPLAY " ;
}
else if ( chbAnotherUser - > get_active ( ) ) {
str_variants_root = " su --user " + cmbUser - > get_active_text ( ) + " " ;
}
else {
str_variants_root = " su " ;
}
}
}
else if ( rbSudo - > get_active ( ) ) {
else if ( rbSudo - > get_active ( ) ) {
if ( ( chbAnotherUser - > get_active ( ) ) & & ( cmbUser - > get_active_text ( ) . length ( ) = = 0 ) ) {
chbTerminal - > set_active ( true ) ;
str_variants_root = " sudo " ;
str_variants_root = " sudo -u " + cmbUser - > get_active_text ( ) + " " ;
}
else if ( chbAnotherUser - > get_active ( ) ) {
str_variants_root = " sudo --user " + cmbUser - > get_active_text ( ) + " " ;
}
else {
str_variants_root = " sudo " ;
}
}
}
}
}
if ( cbxExecuteEpriority - > get_active ( ) ) {
if ( cbxExecuteEpriority - > get_active ( ) ) {
@ -487,38 +488,30 @@ void MainWindow::start_cmd(){
}
}
if ( chbTerminal - > get_active ( ) ) {
if ( chbTerminal - > get_active ( ) ) {
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 = str_nice_cmd + " nohup " + 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 = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + name_app ;
}
}
else {
else {
user_cmd = this - > str_remove ( user_cmd , str_cmd_terminal ) ;
string str_del = " " ;
user_cmd = this - > str_remove ( user_cmd , str_variants_root ) ;
user_cmd = this - > str_remove ( user_cmd , str_nice_cmd ) ;
string str_del = " xterm -e " ;
user_cmd = this - > str_remove ( user_cmd , str_del ) ;
user_cmd = this - > str_remove ( user_cmd , str_del ) ;
str_del = " nohup " ;
vector < std : : string > vec_user_cmd = this - > split ( user_cmd , ' ' ) ;
size_t vec_len = vec_user_cmd . size ( ) ;
user_cmd = vec_user_cmd [ vec_len - 1 ] ;
str_del = " \" " ;
user_cmd = this - > str_remove ( user_cmd , str_del ) ;
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 ;
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + user_cmd ;
if ( str_variants_root . find ( " su -l " ) ! = string : : npos ) {
cmd + = " \" " ;
}
}
}
txtCmd - > set_text ( cmd ) ;
txtCmd - > set_text ( cmd ) ;
@ -559,13 +552,13 @@ 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 ) ;
}
}
}
}
@ -585,13 +578,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 +603,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 ) ;
}
}
}
}
@ -630,7 +623,7 @@ vector<std::string> MainWindow::split(const std::string &s, char delim) {
string MainWindow : : str_remove ( std : : string & source , const std : : string & to_remove ) {
string MainWindow : : str_remove ( std : : string & source , const std : : string & to_remove ) {
auto begin = source . find ( to_remove ) ;
auto begin = source . find ( to_remove ) ;
if ( begin ! = std : : string : : npos ) {
if ( begin ! = std : : string : : npos ) {
int len_to_remove = to_remove . length ( ) ;
int len_to_remove = to_remove . length ( ) ;
source . erase ( begin , begin + len_to_remove ) ;
source . erase ( begin , begin + len_to_remove ) ;
}
}