|
|
|
|
@ -5,6 +5,7 @@ const string path_app = "/usr/bin/";
|
|
|
|
|
const string path_glade = "/usr/share/ublexec/ui/ublexec.glade";
|
|
|
|
|
const string path_css = "/usr/share/ublexec/css/ublexec.css";
|
|
|
|
|
const string app_name = "ublexec";
|
|
|
|
|
const string path_img_head_background = "/usr/share/ublexec/images/logo-background.png";
|
|
|
|
|
int socket_ext_id_I = 0;
|
|
|
|
|
int socket_trd_id_I = 0;
|
|
|
|
|
|
|
|
|
|
@ -42,6 +43,9 @@ MainWindow::MainWindow(Glib::RefPtr<Gtk::Builder> const& builder) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::get_builder() {
|
|
|
|
|
|
|
|
|
|
builder->get_widget("imgHeadBackground", imgHeadBackground);
|
|
|
|
|
builder->get_widget("overHead", overHead);
|
|
|
|
|
builder->get_widget("btnFilemaneg", btnFilemaneg);
|
|
|
|
|
builder->get_widget("btnListApp", btnListApp);
|
|
|
|
|
builder->get_widget("btnStart", btnStart);
|
|
|
|
|
@ -135,10 +139,9 @@ void MainWindow::add_CSS() {
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> styleContext = Gtk::StyleContext::create();
|
|
|
|
|
Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default();//get default screen
|
|
|
|
|
styleContext->add_provider_for_screen(screen, cssProvider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);//add provider for screen in all application
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> context_box = boxColor->get_style_context();
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> context_lbl_head = lblInfoHead->get_style_context();
|
|
|
|
|
Glib::RefPtr<Gtk::StyleContext> boxAbout_css = boxAbout->get_style_context();
|
|
|
|
|
context_box->add_class("cssboxColor1");
|
|
|
|
|
imgHeadBackground->set(path_img_head_background);
|
|
|
|
|
context_lbl_head->add_class("textHead");
|
|
|
|
|
if (socket_ext_id_I == 0){
|
|
|
|
|
boxAbout_css->add_class("bkim_no_plug");
|
|
|
|
|
@ -149,42 +152,45 @@ void MainWindow::localization() {
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
tm *ltm = localtime(&now);
|
|
|
|
|
unsigned int year= 1900+ ltm->tm_year;
|
|
|
|
|
string str_authors = string(_("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
|
|
|
|
|
string str_authors = string(gettext("Copyright © UBSoft LLC, 2022 - ")) + to_string(year);
|
|
|
|
|
aboutWindows->set_copyright(str_authors);
|
|
|
|
|
aboutWindows->set_website(_("https://wiki.ublinux.com"));
|
|
|
|
|
btnSynopsis->set_label(_("Help"));
|
|
|
|
|
btnAbout->set_label(_("About"));
|
|
|
|
|
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(_("Run applications as another user\nwith the specified 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"));
|
|
|
|
|
btnListApp->set_tooltip_text(_("Application Overview"));
|
|
|
|
|
btnFilemaneg->set_tooltip_text(_("File Overview"));
|
|
|
|
|
aboutWindows->set_website(gettext("https://wiki.ublinux.com"));
|
|
|
|
|
btnSynopsis->set_label(gettext("Help"));
|
|
|
|
|
btnAbout->set_label(gettext("About"));
|
|
|
|
|
aboutWindows->set_comments(gettext("Run as..."));
|
|
|
|
|
aboutWindows->set_website_label(gettext("Project Home Page"));
|
|
|
|
|
aboutWindows->set_version(gettext(version_application.c_str()));
|
|
|
|
|
aboutWindows->set_title(gettext(" Run as..."));
|
|
|
|
|
lblHeaderName->set_text(gettext("Run as..."));
|
|
|
|
|
this->set_title(gettext("Run as..."));
|
|
|
|
|
btnStart->set_label(gettext("Run"));
|
|
|
|
|
wndChooseFileWallpaper->set_title(gettext("Please select File"));
|
|
|
|
|
dialogStartMenu->set_title(gettext("Selecting Programs"));
|
|
|
|
|
lblInfoHead->set_text(gettext("Run applications as another user\nwith the specified 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"));
|
|
|
|
|
messageError->set_title(gettext("Warning!"));
|
|
|
|
|
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"));
|
|
|
|
|
btnListApp->set_tooltip_text(gettext("Application Overview"));
|
|
|
|
|
btnFilemaneg->set_tooltip_text(gettext("File Overview"));
|
|
|
|
|
btnStartMenuExit->set_label(gettext("Cancel"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::event() {
|
|
|
|
|
@ -232,32 +238,32 @@ void MainWindow::sudo_nice(){
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(-20, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("-20 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
|
|
|
|
|
}
|
|
|
|
|
else if (rbSudo->get_active() && response.find("wheel") != string::npos){
|
|
|
|
|
spinPriority->set_range(-20, 19);
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(-20, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("-20 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
|
|
|
|
|
}
|
|
|
|
|
else if (rbSu->get_active()){
|
|
|
|
|
spinPriority->set_range(0, 19);
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(0, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("0 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
|
|
|
|
|
}
|
|
|
|
|
else if (rbPkexec->get_active()){
|
|
|
|
|
spinPriority->set_range(0, 19);
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(0, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("0 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
|
|
|
|
|
}
|
|
|
|
|
this->denamic_cmd();
|
|
|
|
|
}
|
|
|
|
|
@ -271,20 +277,21 @@ void MainWindow::changed_user() {
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(-20, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("-20 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("-20 (High)"));
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
spinPriority->set_range(0, 19);
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(0, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("0 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::delete_cmd(const int &x, const int &y) {
|
|
|
|
|
if (x == 0) {}
|
|
|
|
|
if (y > 1) {
|
|
|
|
|
chbTerminal->set_active(false);
|
|
|
|
|
chbAnotherUser->set_active(false);
|
|
|
|
|
@ -294,6 +301,7 @@ void MainWindow::delete_cmd(const int &x, const int &y) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) {
|
|
|
|
|
if (event) {}
|
|
|
|
|
if (user_cmd.length() != 0) {
|
|
|
|
|
}
|
|
|
|
|
else if (name_app.length() != 0) {
|
|
|
|
|
@ -310,8 +318,13 @@ bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::synopsis_show() {
|
|
|
|
|
string cmd = "xdg-open " + string(_("https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/")) + app_name + " &";
|
|
|
|
|
system(cmd.c_str());
|
|
|
|
|
string cmd = "xdg-open " + string(gettext("https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/")) + app_name + " &";
|
|
|
|
|
if (geteuid() == 0) {
|
|
|
|
|
string response_user = getlogin();
|
|
|
|
|
cmd = "su -l " + response_user + " -c \" DISPLAY=$DISPLAY " + cmd + " \"";
|
|
|
|
|
}
|
|
|
|
|
cout << cmd << endl;
|
|
|
|
|
index_error = system(cmd.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::icon_clear() {
|
|
|
|
|
@ -377,7 +390,7 @@ void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr<Gtk::List
|
|
|
|
|
user_cmd = "";
|
|
|
|
|
txtCmd->set_text(app_name_exec);
|
|
|
|
|
name_app = txtCmd->get_text();
|
|
|
|
|
int len_name_app = name_app.length();
|
|
|
|
|
size_t len_name_app = name_app.length();
|
|
|
|
|
string array_del[] = {"%f", "%F", "%d", "%D", "%n", "%N", "%U"};
|
|
|
|
|
for (auto &del_sim: array_del) {
|
|
|
|
|
str_remove(name_app, del_sim);
|
|
|
|
|
@ -409,9 +422,12 @@ void MainWindow::settings() {
|
|
|
|
|
spinPriority->set_increments(1.0, -1.0);
|
|
|
|
|
scalePriority->set_range(0, 19);
|
|
|
|
|
scalePriority->set_value(0);
|
|
|
|
|
lblTimeEpriorityLow->set_text(_("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(_("0 (High)"));
|
|
|
|
|
lblTimeEpriorityLow->set_text(gettext("19 (Low)"));
|
|
|
|
|
lblTime4EpriorityHigh->set_text(gettext("0 (High)"));
|
|
|
|
|
scalePriority->set_inverted(true);
|
|
|
|
|
Gtk::Widget *boxWidget;
|
|
|
|
|
builder->get_widget("boxColor", boxWidget);
|
|
|
|
|
overHead->add_overlay(*boxWidget);
|
|
|
|
|
this->pars_dir_bin();
|
|
|
|
|
this->pars_dir_terminal();
|
|
|
|
|
this->pars_users();
|
|
|
|
|
@ -427,6 +443,7 @@ void MainWindow::settings() {
|
|
|
|
|
btnBoxAboutDialog->set_visible(false);
|
|
|
|
|
cmbTerminal->set_sensitive(false);
|
|
|
|
|
ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::close_entry_app() {
|
|
|
|
|
@ -605,12 +622,13 @@ string MainWindow::start_cmd(string user_cmd) {
|
|
|
|
|
string user_cmd_X = "xhost +SI:localuser:";
|
|
|
|
|
user_cmd_X += cmbUser->get_active_text();
|
|
|
|
|
user_cmd_X += " > /dev/null 2>&1";
|
|
|
|
|
system(user_cmd_X.c_str());
|
|
|
|
|
index_error = 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->set_title(gettext("Warning!"));
|
|
|
|
|
messageError->show();
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
@ -665,7 +683,7 @@ string MainWindow::start_cmd(string user_cmd) {
|
|
|
|
|
|
|
|
|
|
void MainWindow::call_app(string &cmd) {
|
|
|
|
|
if (cmd.length() != 0) {
|
|
|
|
|
std::thread t([&](string cmd) {system(cmd.c_str());}, cmd);
|
|
|
|
|
std::thread t([&](string cmd) {int index = system(cmd.c_str()); if (index){}}, cmd);
|
|
|
|
|
t.detach();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -679,6 +697,7 @@ void MainWindow::denamic_cmd() {
|
|
|
|
|
name_app = "";
|
|
|
|
|
user_cmd = "";
|
|
|
|
|
txtCmd->set_text(user_cmd);
|
|
|
|
|
messageError->set_title(gettext("Warning!"));
|
|
|
|
|
messageError->show();
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
@ -718,6 +737,7 @@ string MainWindow::call(string cmd) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event) {
|
|
|
|
|
if (event) {}
|
|
|
|
|
if (cmd_old != txtCmd->get_text()) {
|
|
|
|
|
user_cmd = txtCmd->get_text();
|
|
|
|
|
}
|
|
|
|
|
|