Добавлено динамическое обновление команды

pull/3/head
Igor Belitskiy 3 years ago
parent ca9bee553c
commit bb2cc550be

@ -162,9 +162,8 @@ void MainWindow::localization(){
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));
@ -197,9 +196,32 @@ void MainWindow::event(){
}); });
rbSu->signal_toggled().connect(sigc::mem_fun(*this,&MainWindow::nice_hight)); rbSu->signal_toggled().connect(sigc::mem_fun(*this,&MainWindow::nice_hight));
rbPkexec->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(){ void MainWindow::nice_hight(){
Glib::ustring entry_user = cmbUser->get_active_text(); Glib::ustring entry_user = cmbUser->get_active_text();
if (geteuid() != 0){ if (geteuid() != 0){
spinPriority->set_range(0,19); spinPriority->set_range(0,19);
@ -208,7 +230,8 @@ void MainWindow::nice_hight(){
scalePriority->set_value(0); scalePriority->set_value(0);
lblTimeEpriorityLow->set_text("19 (Низкий)"); lblTimeEpriorityLow->set_text("19 (Низкий)");
lblTime4EpriorityHigh->set_text("0 (Высокий)"); lblTime4EpriorityHigh->set_text("0 (Высокий)");
} }
this->denamic_cmd();
} }
@ -275,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();
@ -351,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(){
@ -362,6 +389,8 @@ 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{
@ -437,14 +466,10 @@ void MainWindow::open_list_app(){
} }
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);
@ -489,10 +514,10 @@ void MainWindow::start_cmd(){
} }
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{
@ -505,41 +530,65 @@ void MainWindow::start_cmd(){
else if (name_app!=""){ else if (name_app!=""){
cmd = "nohup " + str_nice_cmd + 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){
bool flag_xdg = false; cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd;
if (user_cmd.find("xdg-open")!=string::npos){ }
flag_xdg=true; if (cmd.find("-e su ")!=string::npos){
} cmd+=" \"";
string 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, ' ');
size_t vec_len = vec_user_cmd.size();
user_cmd = vec_user_cmd[vec_len-1];
if (flag_xdg==false){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + user_cmd;
if (cmd.find("-e su ") != string::npos){
cmd += "\"";
}
}
else{
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open " + 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){ bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
system(cmd.c_str()); //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(){
@ -576,14 +625,17 @@ void MainWindow::activ_or_block_other_user(){
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(){

@ -52,10 +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 entry_app();
void nice_hight(); void nice_hight();
void execute_terminal(){}
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();
@ -81,6 +82,9 @@ public:
void icon_clear(); void icon_clear();
void set_icon_array(); void set_icon_array();
void synopsis_show(); 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);
void str_remove(std::string& source, std::string & to_remove); void str_remove(std::string& source, std::string & to_remove);
@ -187,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 = "";

@ -29,28 +29,24 @@
margin:2px 2px 0 2px; margin:2px 2px 0 2px;
padding: 5px 10px 3px 5px; padding: 5px 10px 3px 5px;
background:@theme_selected_bg_color; background:@theme_selected_bg_color;
border-radius:2px;
border-color:transparent; border-color:transparent;
} }
.menuitemmiddle:hover* { .menuitemmiddle:hover* {
margin:0 2px 0 2px; margin:0 2px 0 2px;
padding: 3px 10px 3px 5px; padding: 3px 10px 3px 5px;
background:@theme_selected_bg_color; background:@theme_selected_bg_color;
border-radius:2px;
border-color:transparent; border-color:transparent;
} }
.menuitembottom:hover* { .menuitembottom:hover* {
margin:0 2px 2px 2px; margin:0 2px 2px 2px;
padding: 3px 10px 5px 5px; padding: 3px 10px 5px 5px;
background:@theme_selected_bg_color; background:@theme_selected_bg_color;
border-radius:2px;
border-color:transparent; border-color:transparent;
} }
.menuitembottom{ .menuitembottom{
margin-top:0px; margin-top:0px;
border-color:alpha(@theme_text_color, 0.4); border-color:alpha(@theme_text_color, 0.4);
border-style:solid; border-style:solid;
border-radius:0 0 5px 5px;
border-left-width:1px; border-left-width:1px;
border-bottom-width:1px; border-bottom-width:1px;
border-right-width:1px; border-right-width:1px;
@ -68,7 +64,6 @@
margin-bottom:0px; margin-bottom:0px;
border-color:alpha(@theme_text_color, 0.4); border-color:alpha(@theme_text_color, 0.4);
border-style:solid; border-style:solid;
border-radius:5px 5px 0 0;
border-left-width:1px; border-left-width:1px;
border-top-width:1px; border-top-width:1px;
border-right-width:1px; border-right-width:1px;

@ -133,7 +133,9 @@
<property name="margin">1</property> <property name="margin">1</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -204,7 +206,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -279,7 +283,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -353,7 +359,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -427,7 +435,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -497,11 +507,13 @@
<object class="GtkIconView" id="iconEducation"> <object class="GtkIconView" id="iconEducation">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="margin">6</property> <property name="margin">1</property>
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -575,7 +587,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -649,7 +663,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -723,7 +739,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>
@ -797,7 +815,9 @@
<property name="resize-mode">queue</property> <property name="resize-mode">queue</property>
<property name="item-orientation">horizontal</property> <property name="item-orientation">horizontal</property>
<property name="columns">1</property> <property name="columns">1</property>
<property name="item-width">120</property> <property name="item-width">350</property>
<property name="row-spacing">1</property>
<property name="column-spacing">1</property>
<property name="item-padding">1</property> <property name="item-padding">1</property>
<child> <child>
<object class="GtkCellRendererPixbuf"/> <object class="GtkCellRendererPixbuf"/>

Loading…
Cancel
Save