master #3

Merged
asmeron merged 37 commits from Igor1/ublexec:master into develop 3 years ago

2
.gitignore vendored

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

@ -20,6 +20,11 @@ all: init build
init:
@echo "Initialize ..."; \
version="$$(cat VERSION.md)"; \
version=$${version:8}; \
search="s/string version_application.*$&"; \
replace="string version_application = \"$${version}\";"; \
sed -i -e "$$search/$$replace/gi" source/ublexec.h; \
echo "-- Build path: ${CMAKE_BUILD_DIR}"
depend:

@ -0,0 +1 @@
VERSION 1.0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 61 KiB

@ -17,7 +17,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(SOURCE_FILES
main.cc
ublexec.cc
ublexec.h)
ublexec.h
ubl-util-standard.h
ubl-util-standard.c)
set(LIBRARIES
${GTK_LIBRARIES}

@ -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"
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 builder = Gtk::Builder::create_from_file(path_glade);
setlocale(LC_ALL, "");
bindtextdomain("ublexec", "/usr/share/locale/");
bind_textdomain_codeset("ublexec", "UTF-8");
textdomain("ublexec");

@ -0,0 +1,69 @@
#include "ubl-util-standard.h"
#ifndef __cplusplus
#ifndef UBL_GET_STANDARD_UI
#define UBL_GET_STANDARD_UI
inline returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id){
returnstruct *ret=(returnstruct*)malloc(sizeof(returnstruct*));
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=LeftWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugLeft=plug;
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=RightWidget;
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
ret->plugRight=plug;
}
return ret;
}
#endif
#else
inline void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id){
if (left_plug_id>0&&LeftWidget){
GtkWidget *plug=gtk_plug_new(left_plug_id);
GtkWidget *toplug=GTK_WIDGET(LeftWidget->gobj());
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
}
if (right_plug_id>0&&RightWidget){
GtkWidget *plug=gtk_plug_new(right_plug_id);
GtkWidget *toplug=GTK_WIDGET(RightWidget->gobj());
if (gtk_widget_get_parent(GTK_WIDGET(toplug))){
g_object_ref(G_OBJECT(toplug));
GtkWidget *parent=gtk_widget_get_parent(toplug);
gtk_container_remove(GTK_CONTAINER(parent),toplug);
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
} else
gtk_container_add(GTK_CONTAINER(plug),GTK_WIDGET(toplug));
gtk_widget_show(GTK_WIDGET(plug));
}
}
#endif

@ -0,0 +1,20 @@
#ifndef __cplusplus
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
typedef struct {
GtkWidget *plugLeft;
GtkWidget *plugRight;
} returnstruct;
static returnstruct *ubl_make_plugs(GtkWidget *LeftWidget, GtkWidget *RightWidget, int left_plug_id, int right_plug_id);
#else
#include <gtkmm.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <gtkmm/plug.h>
static void ubl_make_plugs(Gtk::Widget *LeftWidget, Gtk::Widget *RightWidget, int left_plug_id, int right_plug_id);
#endif

@ -1,40 +1,31 @@
#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"
using namespace std;
string path_app= "/usr/bin/";
string path_glade= "/usr/share/ublexec/ui/ublexec.glade";
string path_css = "/usr/share/ublexec/css/style.css";
string app_name = "ublexec";
int socket_ext_id_I=0;
int socket_trd_id_I=0;
CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help)
: Glib::OptionGroup{p_name, p_description, p_help} {
Glib::OptionEntry socketIDArg;
socketIDArg.set_long_name("socket-id");
socketIDArg.set_short_name('s');
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketIDArg.set_description("Settings manager socket");
Glib::OptionEntry socketExtId;
socketExtId.set_long_name("socket-ext-id");
socketExtId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketExtId.set_description("Settings manager secondary socket");
Glib::OptionEntry socketTrdId;
socketTrdId.set_long_name("socket-trd-id");
socketTrdId.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketTrdId.set_description("Settings manager secondary socket");
add_entry(socketIDArg, m_socketID);
add_entry(socketExtId, socket_ext_id_I);
add_entry(socketTrdId, socket_trd_id_I);
}
::Window CmdArgParser::GetSocketID() const{
return m_socketID;
@ -88,7 +79,6 @@ void MainWindow::get_builder(){
builder->get_widget("lblInfoNooPriority", lblInfoNooPriority);
builder->get_widget("lblInfoExec", lblInfoExec);
builder->get_widget("lblInfoPriority", lblInfoPriority);
builder->get_widget("lblInfoEnterProg", lblInfoEnterProg);
builder->get_widget("boxColor", boxColor);
builder->get_widget("lblGraphics", lblGraphics);
builder->get_widget("lblTools", lblTools);
@ -110,6 +100,12 @@ void MainWindow::get_builder(){
builder->get_widget("iconDevelopment", iconDevelopment);
builder->get_widget("iconSystem", iconSystem);
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(){
@ -125,18 +121,14 @@ void MainWindow::set_icon_array(){
array_icon[9]=this->iconSystem;
}
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->set_sort_column(m_Columns.m_col_description, Gtk::SORT_ASCENDING);
icon->set_model(gtk_list_app);
icon->set_markup_column(m_Columns.m_col_description);
icon->set_pixbuf_column(m_Columns.m_col_pixbuf);
icon->set_text_column(m_Columns.m_col_description);
}
void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::CssProvider> cssProvider = Gtk::CssProvider::create();
cssProvider->load_from_path(path_css);
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
@ -146,44 +138,48 @@ void MainWindow::add_CSS(){
Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context();
context_box->add_class("cssboxColor1");
context_lbl_head->add_class("textHead");
}
void MainWindow::localization(){
this->set_title(gettext("ublexec"));
btnStart->set_label(gettext("Run"));
wndChooseFileWallpaper->set_title(gettext("Please select File"));
dialogStartMenu->set_title(gettext("Selecting Programs"));
lblInfoHead->set_text(gettext("Running applications as a user with a\nspecified priority"));
lblinfoCmd->set_text(gettext("Command Line"));
lblInfoTime->set_text(gettext("Team"));
labInfoExecutTerm->set_text(gettext("Run in the terminal emulator"));
lblInfoUser->set_text(gettext("User"));
lblInfoUserOther->set_text(gettext("Run as another user"));
lblInfoUserName->set_text(gettext("User Name"));
lblInfoNooPriority->set_text(gettext("Priority"));
lblInfoExec->set_text(gettext("Change startup priority"));
lblInfoPriority->set_text(gettext("Priority"));
lblMessageError->set_text(gettext("Select an executable file or program"));
lblInfoEnterProg->set_text(gettext("Selecting Programs"));
lblGraphics->set_text(gettext("Graphics"));
lblTools->set_text(gettext("Tools"));
lblInternet->set_text(gettext("Internet"));
lblMultimedia->set_text(gettext("Multimedia"));
lblSettings->set_text(gettext("Settings"));
lblEducation->set_text(gettext("Education"));
lblOffice->set_text(gettext("Office"));
lblOther->set_text(gettext("Other"));
lblDevelopment->set_text(gettext("Development"));
lblSystem->set_text(gettext("System"));
aboutWindows->set_website(_("https://wiki.ublinux.com"));
btnSynopsis->set_label(_("Help"));
btnAbout->set_label(_("About the program"));
aboutWindows->set_comments(_("ublexec"));
aboutWindows->set_website_label(_("Project Home Page"));
aboutWindows->set_version(_(version_application.c_str()));
lblHeaderName->set_text(_("ublexec"));
this->set_title(_("ublexec"));
btnStart->set_label(_("Run"));
wndChooseFileWallpaper->set_title(_("Please select File"));
dialogStartMenu->set_title(_("Selecting Programs"));
lblInfoHead->set_text(_("Running applications as a user with a\nspecified priority"));
lblinfoCmd->set_text(_("Command Line"));
lblInfoTime->set_text(_("Team"));
labInfoExecutTerm->set_text(_("Run in the terminal emulator"));
lblInfoUser->set_text(_("User"));
lblInfoUserOther->set_text(_("Run as another user"));
lblInfoUserName->set_text(_("User Name"));
lblInfoNooPriority->set_text(_("Priority"));
lblInfoExec->set_text(_("Change startup priority"));
lblInfoPriority->set_text(_("Priority"));
lblMessageError->set_text(_("Select an executable file or program"));
lblGraphics->set_text(_("Graphics"));
lblTools->set_text(_("Tools"));
lblInternet->set_text(_("Internet"));
lblMultimedia->set_text(_("Multimedia"));
lblSettings->set_text(_("Settings"));
lblEducation->set_text(_("Education"));
lblOffice->set_text(_("Office"));
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::start_cmd));
cmbUser->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::changed_user));
//chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::execute_terminal));
btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app));
chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::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));
@ -204,6 +200,43 @@ void MainWindow::event(){
iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other));
iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development));
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();});
cmbUser->signal_changed().connect([&](){denamic_cmd();changed_user();});
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));
txtCmd->signal_delete_text().connect(sigc::mem_fun(*this, &MainWindow::delete_cmd));
}
void MainWindow::delete_cmd(const int &x,const int &y){
if (y>1){
chbTerminal->set_active(false);
chbAnotherUser->set_active(false);
cbxExecuteEpriority->set_active(false);
txtCmd->set_text("");
}
}
bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event){
if (user_cmd.length() != 0){
//user_cmd_old = user_cmd;gi
}
else if (name_app.length() != 0){
//name_app_old = name_app;
}
else if (path_file.length() != 0){
//path_file_old = path_file;
}
else{
user_cmd = txtCmd->get_text();
}
cmd_old = txtCmd->get_text();
return true;
}
void MainWindow::synopsis_show(){
system("xdg-open https://wiki.ublinux.ru/ru/home &");
}
void MainWindow::icon_clear(){
@ -213,7 +246,6 @@ void MainWindow::icon_clear(){
list_Multimedia->clear();
list_Settings->clear();
list_Education->clear();
list_Graphics->clear();
list_Office->clear();
list_Other->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;
auto app_name_exec = row[m_Columns.app_name_exec];
const Glib::ustring description = row[m_Columns.m_col_description];
path_file = "";
name_app = "";
user_cmd = "";
txtCmd->set_text(app_name_exec);
name_app = txtCmd->get_text();
int len_name_app = name_app.length();
@ -312,16 +347,11 @@ void MainWindow::settings(){
rbPkexec->set_sensitive(false);
rbSu->set_sensitive(false);
rbSudo->set_sensitive(false);
btnBoxAboutDialog->set_visible(false);
Gtk::Widget *boxAbout;
builder->get_widget("boxAbout",boxAbout);
//Gtk::Widget *standartHead;
//Gtk::Widget *plugBox;
//Gtk::Window *window;
//Gtk::Widget *btnSave;
//builder->get_widget("standartHead",standartHead);
//builder->get_widget("plugBox",plugBox);
//builder->get_widget("window",window);
//builder->get_widget("btnSave",btnSave);
//ubl_get_standard_ui(standartHead,plugBox,btnSave,window,"ublexec.svg",gettext("Running applications as a user with a\nspecified priority"),gettext("ublexec"),0,0);
ubl_make_plugs(boxAbout,boxAbout, 0, socket_trd_id_I);
}
void MainWindow::close_entry_app(){
@ -342,6 +372,7 @@ void MainWindow::activ_or_block_execute_epriority(){
lblInfoNooPriority->set_sensitive(flag);
lblTimeEpriorityLow->set_sensitive(flag);
lblTime4EpriorityHigh->set_sensitive(flag);
this->denamic_cmd();
}
void MainWindow::open_filemaneg(){
@ -353,26 +384,26 @@ void MainWindow::close_filemaneg(){
}
void MainWindow::get_path_filemaneg(){
name_app = "";
user_cmd = "";
path_file = wndChooseFileWallpaper->get_filename();
if (path_file.length()==0){}
if (path_file.length() == 0){}
else{
txtCmd->set_text(path_file);
this->close_filemaneg();
}
this->denamic_cmd();
}
void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr<Gtk::ListStore> &dtk_list){
Gtk::TreeModel::Row row = *(dtk_list->append());
row[m_Columns.m_col_filename] = path;
row[m_Columns.m_col_description] = Name;
row[m_Columns.icon_name] = path;
row[m_Columns.app_name_exec] = Exec;
if (std::ifstream(path)){
row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path);
}
else{
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.float_h_align] = 0.5;
row[m_Columns.float_w_align] = 0.5;
}
void MainWindow::open_list_app(){
@ -389,7 +420,7 @@ void MainWindow::open_list_app(){
string path = "";
for ( const auto &st_app : list_app){
for ( const auto &str_categor : st_app.Categories){
path = "/usr/share/icons/hicolor/16x16/apps/" + st_app.Icon + ".png";
path = st_app.Icon;
if (str_categor=="Graphics"){
this->tempalte_row(st_app.Name,st_app.Exec, path, list_Graphics);
}
@ -420,118 +451,142 @@ void MainWindow::open_list_app(){
else if (str_categor=="System"){
this->tempalte_row(st_app.Name,st_app.Exec, path, list_System);
}
}
}
dialogStartMenu->show_all();
}
void MainWindow::start_cmd(){
string MainWindow::start_cmd(string user_cmd){
string str_cmd_terminal="";
string str_variants_root = "";
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 (geteuid()!=0){
//chbTerminal->set_active(true);
}
if (rbPkexec->get_active()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) {
str_variants_root = " pkexec --user ${USER} env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
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 = " pkexec --user " + cmbUser->get_active_text();
if (cbxExecuteEpriority->get_active()){
str_variants_root += " nice -n " + to_string(spinPriority->get_value_as_int());
}
str_variants_root += " env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY ";
}
else if (rbSu->get_active()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) {
str_variants_root="su ";
}
else if (chbAnotherUser->get_active()){
str_variants_root="su --user " + cmbUser->get_active_text() + " ";
chbTerminal->set_active(true);
string str_user = cmbUser->get_active_text();
if (str_user!="root"){
str_variants_root = "su -l " + cmbUser->get_active_text();
}
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()){
if ((chbAnotherUser->get_active()) && (cmbUser->get_active_text().length()==0)) {
chbTerminal->set_active(true);
if (getlogin()==cmbUser->get_active_text()){
str_variants_root="sudo ";
}
else if (chbAnotherUser->get_active()){
str_variants_root="sudo --user " + cmbUser->get_active_text() + " ";
}
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()){
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " ";
if (cmbUser->get_active_text().length()!=0){
string user_cmd_X = "xhost +SI:localuser:";
user_cmd_X += cmbUser->get_active_text();
system(user_cmd_X.c_str());
}
if ((cbxExecuteEpriority->get_active()) && (chbAnotherUser->get_active()==false)){
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){
messageError->show();
return;
return "";
}
if (chbTerminal->get_active()){
str_cmd_terminal=" xterm -e ";
if (chbTerminal->get_active() == true){
str_cmd_terminal = "xterm -e ";
}
else{
str_cmd_terminal="";
str_cmd_terminal = "";
}
string cmd = "";
if (path_file!=""){
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' ";
if (path_file.length()>0){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' ";
}
else if (name_app.length()>0){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + name_app;
}
else if (user_cmd.length()>0){
cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd;
}
if (cmd.find("-e su ")!=string::npos){
cmd+=" \"";
}
cmd += " > /dev/null 2>&1";
return cmd;
}
void MainWindow::call_app(string &cmd){
if (cmd.length() != 0){
std::thread t([&](string cmd){system(cmd.c_str());}, cmd);
t.detach();
}
else if (name_app!=""){
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + name_app;
}
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{
user_cmd = this->str_remove(user_cmd, str_cmd_terminal);
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);
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);
if (user_cmd.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
else if (path_file.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
else if (name_app.length() != 0){
txtCmd->set_text(this->start_cmd(user_cmd));
}
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";
std::thread t(&me_thread, cmd);
t.detach();
path_file_name = "";
path_file = "";
name_app = "";
bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
if (cmd_old!=txtCmd->get_text()){
user_cmd = txtCmd->get_text();
}
return true;
}
void me_thread(string cmd){
system(cmd.c_str());
void MainWindow::entry_app(){
this->denamic_cmd();
if (name_app.length()==0 && path_file.length()==0){
}
string cmd = txtCmd->get_text();
this->call_app(cmd);
}
void MainWindow::changed_user(){
@ -559,23 +614,26 @@ void MainWindow::activ_or_block_other_user(){
cmbUser->set_active(0);
cmbUser->set_sensitive(flag);
lblInfoUserName->set_sensitive(flag);
if (flag_pkexec==true){
if (flag_pkexec == true){
rbPkexec->set_sensitive(flag);
}
if (flag_su==true){
if (flag_su == true){
rbSu->set_sensitive(flag);
}
if (flag_sudo==true){
if (flag_sudo == true){
rbSudo->set_sensitive(flag);
}
this->denamic_cmd();
}
void MainWindow::change_scale_priority(){
scalePriority->set_value(spinPriority->get_value_as_int());
this->denamic_cmd();
}
void MainWindow::change_spin_priority(){
spinPriority->set_value(scalePriority->get_value());
this->denamic_cmd();
}
void MainWindow::pars_dir_bin(){
@ -585,13 +643,13 @@ void MainWindow::pars_dir_bin(){
for (const auto & entry : fs::directory_iterator(path)){
file_name = entry.path().filename().string();
if (file_name=="su"){
flag_su=true;
flag_su = true;
}
else if (file_name=="sudo"){
flag_sudo=true;
flag_sudo = true;
}
else if (file_name=="pkexec"){
flag_pkexec=true;
flag_pkexec = true;
}
}
rbPkexec->set_sensitive(flag_pkexec);
@ -610,7 +668,7 @@ void MainWindow::pars_users(){
break;
}
if (entry->pw_uid>=1000 && entry->pw_uid!=65534){
if (entry->pw_uid >= 1000 && entry->pw_uid!=65534){
cmbUser->append(entry->pw_name);
}
}
@ -628,13 +686,12 @@ vector<std::string> MainWindow::split(const std::string &s, char delim) {
return elems;
}
string MainWindow::str_remove(std::string& source, const std::string& to_remove){
auto begin = source.find(to_remove);
if (begin!=std::string::npos){
int len_to_remove = to_remove.length();
source.erase(begin, begin+len_to_remove);
}
return source;
void MainWindow::str_remove(std::string& source, std::string & to_remove){
string::size_type n = to_remove.length();
for (string::size_type i = source.find(to_remove);
i != string::npos;
i = source.find(to_remove))
source.erase(i, n);
}
void MainWindow::pars_apps(){

@ -1,15 +1,21 @@
#include <iostream>
#include <gtkmm/window.h>
#include <glibmm/i18n.h>
#include <gtkmm/plug.h>
#include <gtkmm/stock.h>
#include <gtkmm.h>
#include <iostream>
#include <map>
#include <string>
#include <array>
#include <vector>
#include <map>
#include <fstream>
#include <filesystem>
#include <stdio.h>
#include <gtkmm/stock.h>
#include <gtkmm/window.h>
#include <gtkmm/plug.h>
#include <locale.h>
#include <libintl.h>
#include <pwd.h>
#include <ostream>
#include <thread>
#include <algorithm>
#include "ubl-util-standard.c"
using namespace std;
@ -17,6 +23,8 @@ extern string path_app;
extern string app_name;
extern string path_glade;
extern string path_css;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
void me_thread(string cmd);
class CmdArgParser : public Glib::OptionGroup
{
@ -47,9 +55,10 @@ public:
void close_filemaneg();
void get_path_filemaneg();
void open_list_app();
void start_cmd();
string start_cmd(string user_cmd);
void call_app(string &cmd);
void changed_user();
void execute_terminal(){}
void entry_app();
void execute_another_User(){}
void activ_or_block_other_user();
void change_scale_priority();
@ -74,9 +83,13 @@ public:
void select_System();
void icon_clear();
void set_icon_array();
//static void me_thread(string cmd);
void delete_cmd(const int &x,const int &y);
void synopsis_show();
void denamic_cmd();
bool focus_out_txt_cmd(GdkEventFocus* event);
bool focus_in_txt_cmd(GdkEventFocus* event);
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);
public:
class ModelColumns : public Gtk::TreeModel::ColumnRecord
@ -88,12 +101,18 @@ public:
add(m_col_description);
add(m_col_pixbuf);
add(app_name_exec);
add(float_h_align);
add(float_w_align);
add(icon_name);
}
Gtk::TreeModelColumn<std::string> m_col_filename;
Gtk::TreeModelColumn<std::string> icon_name;
Gtk::TreeModelColumn<Glib::ustring> m_col_description;
Gtk::TreeModelColumn<Glib::ustring> app_name_exec;
Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > m_col_pixbuf;
Gtk::TreeModelColumn<float> float_h_align;
Gtk::TreeModelColumn<float> float_w_align;
};
ModelColumns m_Columns;
public:
@ -135,7 +154,6 @@ public:
Gtk::Label *lblInfoNooPriority;
Gtk::Label *lblInfoExec;
Gtk::Label *lblInfoPriority;
Gtk::Label *lblInfoEnterProg;
Gtk::Label *lblGraphics;
Gtk::Label *lblTools;
@ -147,6 +165,7 @@ public:
Gtk::Label *lblOther;
Gtk::Label *lblDevelopment;
Gtk::Label *lblSystem;
Gtk::Label *lblHeaderName;
Gtk::IconView *iconGraphics;
Gtk::IconView *iconTools;
@ -159,6 +178,11 @@ public:
Gtk::IconView *iconDevelopment;
Gtk::IconView *iconSystem;
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_Tools;
@ -171,6 +195,12 @@ public:
Glib::RefPtr<Gtk::ListStore> list_Development;
Glib::RefPtr<Gtk::ListStore> list_System;
public:
string version_application = "1.0";
string cmd_old = "";
string user_cmd="";
string user_cmd_old="";
string name_app_old="";
string path_file_old="";
string execute_cmd = "";
string path_file = "";
string name_app = "";

@ -4,4 +4,69 @@
.textHead{
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 {
border-radius:3px;
background:@theme_bg_color;
}
.menuitemmiddle:hover {
border-radius:3px;
background:@theme_bg_color;
}
.menuitembottom:hover {
border-radius:3px;
background:@theme_bg_color;
}
.menuitemtop:hover* {
border-radius:3px;
margin:2px 2px 0 2px;
padding: 5px 10px 3px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitemmiddle:hover* {
border-radius:3px;
margin:0 2px 0 2px;
padding: 3px 10px 3px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitembottom:hover* {
border-radius:3px;
margin:0 2px 2px 2px;
padding: 3px 10px 5px 5px;
background:@theme_selected_bg_color;
border-color:transparent;
}
.menuitembottom{
margin-top:0px;
}
.menuitemmiddle{
margin-top:0px;
margin-bottom:0px;
}
.menuitemtop{
margin-bottom:0px;
}
.bkim{
background-image: -gtk-gradient(linear,
left top, left bottom,
from(@entry_background_a),
color-stop(0.20, @entry_background_b),
color-stop(0.85, @entry_background_c),
to(@entry_background_d));
}

File diff suppressed because it is too large Load Diff

@ -6,6 +6,18 @@
msgid ""
msgstr ""
msgid "https://wiki.ublinux.com"
msgstr "https://wiki.ublinux.ru"
msgid "About the program"
asmeron commented 3 years ago
Review

Исправить на
(en) Help
(ru) Справка

Исправить на (en) Help (ru) Справка
msgstr "О программе"
msgid "Help"
msgstr "Справка"
msgid "Project Home Page"
msgstr "Домашняя страница проекта"
msgid "System"
msgstr "Система"

Loading…
Cancel
Save