@ -1,6 +1,5 @@
# 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 " ;
@ -95,7 +94,6 @@ void MainWindow::get_builder(){
builder - > get_widget ( " aboutWindows " , aboutWindows ) ;
builder - > get_widget ( " aboutWindows " , aboutWindows ) ;
builder - > get_widget ( " btnSettings " , btnSettings ) ;
builder - > get_widget ( " btnSettings " , btnSettings ) ;
builder - > get_widget ( " btnBoxAboutDialog " , btnBoxAboutDialog ) ;
builder - > get_widget ( " btnBoxAboutDialog " , btnBoxAboutDialog ) ;
}
}
void MainWindow : : set_icon_array ( ) {
void MainWindow : : set_icon_array ( ) {
@ -111,7 +109,6 @@ 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 ) ;
@ -120,9 +117,7 @@ void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr<Gtk::ListSt
icon - > set_pixbuf_column ( m_Columns . m_col_pixbuf ) ;
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 ( ) ;
@ -132,7 +127,6 @@ 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 ( ) {
@ -201,8 +195,7 @@ void MainWindow::event(){
}
}
void MainWindow : : synopsis_show ( ) {
void MainWindow : : synopsis_show ( ) {
//wrapper_system("xdg-open https://wiki.ublinux.ru/ru/home");
system ( " xdg-open https://wiki.ublinux.ru/ru/home & " ) ;
}
}
void MainWindow : : icon_clear ( ) {
void MainWindow : : icon_clear ( ) {
@ -312,17 +305,15 @@ void MainWindow::settings(){
rbSu - > set_sensitive ( false ) ;
rbSu - > set_sensitive ( false ) ;
rbSudo - > set_sensitive ( false ) ;
rbSudo - > set_sensitive ( false ) ;
btnBoxAboutDialog - > set_visible ( false ) ;
btnBoxAboutDialog - > set_visible ( false ) ;
/*
//Gtk::Widget *standartHead;
Gtk : : Widget * boxButton ;
//Gtk::Widget *plugBox;
Gtk : : Widget * boxAbout ;
//Gtk::Window *window;
builder - > get_widget ( " plugBox " , plugBox ) ;
//Gtk::Widget *btnSave;
builder - > get_widget ( " window " , window ) ;
//builder->get_widget("standartHead",standartHead);
builder - > get_widget ( " boxButton " , boxButton ) ;
//builder->get_widget("plugBox",plugBox);
builder - > get_widget ( " boxAbout " , boxAbout ) ;
//builder->get_widget("window",window);
ubl_make_plugs ( boxAbout , boxButton , socket_ext_id_I , socket_trd_id_I ) ;
//builder->get_widget("btnSave",btnSave);
*/
//ubl_get_standard_ui(standartHead,plugBox,btnSave,window,"ublexec.svg",_("Running applications as a user with a\nspecified priority"),_("ublexec"),0,0);
}
}
void MainWindow : : close_entry_app ( ) {
void MainWindow : : close_entry_app ( ) {
this - > icon_clear ( ) ;
this - > icon_clear ( ) ;
@ -459,7 +450,7 @@ void MainWindow::start_cmd(){
}
}
}
}
if ( cbxExecuteEpriority - > get_active ( ) ) {
if ( cbxExecuteEpriority - > get_active ( ) ) {
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 ) {
@ -481,18 +472,27 @@ void MainWindow::start_cmd(){
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 {
bool flag_xdg = false ;
if ( user_cmd . find ( " xdg-open " ) ! = string : : npos ) {
flag_xdg = true ;
}
string str_del = " " ;
string str_del = " " ;
user_cmd = this - > str_remove ( user_cmd , str_del ) ;
this - > str_remove ( user_cmd , str_del ) ;
str_del = " \" " ;
this - > str_remove ( user_cmd , str_del ) ;
vector < std : : string > vec_user_cmd = this - > split ( user_cmd , ' ' ) ;
vector < std : : string > vec_user_cmd = this - > split ( user_cmd , ' ' ) ;
size_t vec_len = vec_user_cmd . size ( ) ;
size_t vec_len = vec_user_cmd . size ( ) ;
user_cmd = vec_user_cmd [ vec_len - 1 ] ;
user_cmd = vec_user_cmd [ vec_len - 1 ] ;
str_del = " \" " ;
if ( flag_xdg = = false ) {
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 ) {
if ( str_variants_root . find ( " su -l " ) ! = string : : npos ) {
cmd + = " \" " ;
cmd + = " \" " ;
}
}
}
}
else {
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + " xdg-open " + user_cmd ;
}
}
txtCmd - > set_text ( cmd ) ;
txtCmd - > set_text ( cmd ) ;
cmd + = " > /dev/null 2>&1 " ;
cmd + = " > /dev/null 2>&1 " ;
@ -601,13 +601,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 ( ) {