Merge pull request 'master' (#3) from Igor1/ublexec:master into develop

Reviewed-on: #3
pull/11/head
Dmitry Razumov 3 years ago
commit b74bde65bb

4
.gitignore vendored

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

@ -20,6 +20,11 @@ all: init build
init: init:
@echo "Initialize ..."; \ @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}" echo "-- Build path: ${CMAKE_BUILD_DIR}"
depend: 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 set(SOURCE_FILES
main.cc main.cc
ublexec.cc ublexec.cc
ublexec.h) ublexec.h
ubl-util-standard.h
ubl-util-standard.c)
set(LIBRARIES set(LIBRARIES
${GTK_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" #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;
} }
} }

@ -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" #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";
string app_name = "ublexec"; 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) 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::OptionGroup{p_name, p_description, p_help} {
Glib::OptionEntry socketIDArg; Glib::OptionEntry socketIDArg;
socketIDArg.set_long_name("socket-id"); socketIDArg.set_long_name("socket-id");
socketIDArg.set_short_name('s');
socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN); socketIDArg.set_flags(Glib::OptionEntry::FLAG_IN_MAIN);
socketIDArg.set_description("Settings manager socket"); 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(socketIDArg, m_socketID);
add_entry(socketExtId, socket_ext_id_I);
add_entry(socketTrdId, socket_trd_id_I);
} }
::Window CmdArgParser::GetSocketID() const{ ::Window CmdArgParser::GetSocketID() const{
return m_socketID; return m_socketID;
@ -88,7 +79,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 +100,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 +121,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 +138,48 @@ 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")); aboutWindows->set_website(_("https://wiki.ublinux.com"));
btnStart->set_label(gettext("Run")); btnSynopsis->set_label(_("Help"));
wndChooseFileWallpaper->set_title(gettext("Please select File")); btnAbout->set_label(_("About the program"));
dialogStartMenu->set_title(gettext("Selecting Programs")); aboutWindows->set_comments(_("ublexec"));
lblInfoHead->set_text(gettext("Running applications as a user with a\nspecified priority")); aboutWindows->set_website_label(_("Project Home Page"));
lblinfoCmd->set_text(gettext("Command Line")); aboutWindows->set_version(_(version_application.c_str()));
lblInfoTime->set_text(gettext("Team")); lblHeaderName->set_text(_("ublexec"));
labInfoExecutTerm->set_text(gettext("Run in the terminal emulator")); this->set_title(_("ublexec"));
lblInfoUser->set_text(gettext("User")); btnStart->set_label(_("Run"));
lblInfoUserOther->set_text(gettext("Run as another user")); wndChooseFileWallpaper->set_title(_("Please select File"));
lblInfoUserName->set_text(gettext("User Name")); dialogStartMenu->set_title(_("Selecting Programs"));
lblInfoNooPriority->set_text(gettext("Priority")); lblInfoHead->set_text(_("Running applications as a user with a\nspecified priority"));
lblInfoExec->set_text(gettext("Change startup priority")); lblinfoCmd->set_text(_("Command Line"));
lblInfoPriority->set_text(gettext("Priority")); lblInfoTime->set_text(_("Team"));
lblMessageError->set_text(gettext("Select an executable file or program")); labInfoExecutTerm->set_text(_("Run in the terminal emulator"));
lblInfoEnterProg->set_text(gettext("Selecting Programs")); lblInfoUser->set_text(_("User"));
lblGraphics->set_text(gettext("Graphics")); lblInfoUserOther->set_text(_("Run as another user"));
lblTools->set_text(gettext("Tools")); lblInfoUserName->set_text(_("User Name"));
lblInternet->set_text(gettext("Internet")); lblInfoNooPriority->set_text(_("Priority"));
lblMultimedia->set_text(gettext("Multimedia")); lblInfoExec->set_text(_("Change startup priority"));
lblSettings->set_text(gettext("Settings")); lblInfoPriority->set_text(_("Priority"));
lblEducation->set_text(gettext("Education")); lblMessageError->set_text(_("Select an executable file or program"));
lblOffice->set_text(gettext("Office")); lblGraphics->set_text(_("Graphics"));
lblOther->set_text(gettext("Other")); lblTools->set_text(_("Tools"));
lblDevelopment->set_text(gettext("Development")); lblInternet->set_text(_("Internet"));
lblSystem->set_text(gettext("System")); 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(){ 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 +200,43 @@ 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();});
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(){ 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();
@ -312,18 +347,13 @@ 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 *boxAbout;
builder->get_widget("boxAbout",boxAbout);
//Gtk::Widget *standartHead; ubl_make_plugs(boxAbout,boxAbout, 0, socket_trd_id_I);
//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);
}
void MainWindow::close_entry_app(){ void MainWindow::close_entry_app(){
this->icon_clear(); this->icon_clear();
dialogStartMenu->hide(); dialogStartMenu->hide();
@ -342,6 +372,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,26 +384,26 @@ 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();
} }
this->denamic_cmd();
} }
void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr<Gtk::ListStore> &dtk_list){ void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr<Gtk::ListStore> &dtk_list){
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.icon_name] = path;
row[m_Columns.app_name_exec] = Exec; row[m_Columns.app_name_exec] = Exec;
if (std::ifstream(path)){ row[m_Columns.float_h_align] = 0.5;
row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path); row[m_Columns.float_w_align] = 0.5;
}
else{
path = "/usr/share/icons/Faenza/emblems/16/emblem-danger.png";
row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path);
}
} }
void MainWindow::open_list_app(){ void MainWindow::open_list_app(){
@ -389,7 +420,7 @@ void MainWindow::open_list_app(){
string path = ""; string path = "";
for ( const auto &st_app : list_app){ for ( const auto &st_app : list_app){
for ( const auto &str_categor : st_app.Categories){ 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"){ if (str_categor=="Graphics"){
this->tempalte_row(st_app.Name,st_app.Exec, path, list_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"){ 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 (cmbUser->get_active_text().length()!=0){
str_nice_cmd = "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; 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){ 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.length()>0){
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.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;
} }
else if (name_app!=""){ if (cmd.find("-e su ")!=string::npos){
cmd = str_nice_cmd + " nohup " + str_cmd_terminal + str_variants_root + name_app; 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();
}
}
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{ else{
user_cmd = this->str_remove(user_cmd, str_cmd_terminal); if (user_cmd.length() != 0){
user_cmd = this->str_remove(user_cmd, str_variants_root); txtCmd->set_text(this->start_cmd(user_cmd));
user_cmd = this->str_remove(user_cmd, str_nice_cmd); }
string str_del = "xterm -e"; else if (path_file.length() != 0){
user_cmd = this->str_remove(user_cmd, str_del); txtCmd->set_text(this->start_cmd(user_cmd));
str_del = "nohup"; }
user_cmd = this->str_remove(user_cmd, str_del); else if (name_app.length() != 0){
str_del = "pkexec --user superadmin env PATH=$PATH DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"; txtCmd->set_text(this->start_cmd(user_cmd));
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";
std::thread t(&me_thread, cmd);
t.detach();
path_file_name = "";
path_file = "";
name_app = "";
} }
void me_thread(string cmd){ bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){
system(cmd.c_str()); if (cmd_old!=txtCmd->get_text()){
user_cmd = txtCmd->get_text();
}
return true;
}
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(){ void MainWindow::changed_user(){
@ -559,23 +614,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 +643,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 +668,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 +686,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,21 @@
#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> #include "ubl-util-standard.c"
using namespace std; using namespace std;
@ -17,6 +23,8 @@ extern string path_app;
extern string app_name; extern string app_name;
extern string path_glade; extern string path_glade;
extern string path_css; extern string path_css;
extern int socket_ext_id_I;
extern int socket_trd_id_I;
void me_thread(string cmd); void me_thread(string cmd);
class CmdArgParser : public Glib::OptionGroup class CmdArgParser : public Glib::OptionGroup
{ {
@ -47,9 +55,10 @@ 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 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 +83,13 @@ public:
void select_System(); void select_System();
void icon_clear(); void icon_clear();
void set_icon_array(); 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); 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 +101,18 @@ 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);
add(icon_name);
} }
Gtk::TreeModelColumn<std::string> m_col_filename; Gtk::TreeModelColumn<std::string> m_col_filename;
Gtk::TreeModelColumn<std::string> icon_name;
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 +154,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 +165,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 +178,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 +195,12 @@ 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 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 execute_cmd = "";
string path_file = ""; string path_file = "";
string name_app = ""; string name_app = "";

@ -4,4 +4,69 @@
.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 {
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 "" msgid ""
msgstr "" msgstr ""
msgid "https://wiki.ublinux.com"
msgstr "https://wiki.ublinux.ru"
msgid "About the program"
msgstr "О программе"
msgid "Help"
msgstr "Справка"
msgid "Project Home Page"
msgstr "Домашняя страница проекта"
msgid "System" msgid "System"
msgstr "Система" msgstr "Система"

Loading…
Cancel
Save