diff --git a/Makefile b/Makefile index 178739f..26e4b34 100644 --- a/Makefile +++ b/Makefile @@ -12,21 +12,18 @@ CMAKE_COMMAND = cmake CMAKE_SOURCE_DIR = ./source CMAKE_BUILD_DIR = ./compile DEPENDS = cmake -#PKGNAME = $(MAKEFILE_DIR) -PKGNAME = ublexec +pkgname = $(MAKEFILE_DIR) +#pkgname = ublexec +pkgdir = default_target: all 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; \ + sed -r "s/(version_application = ).*/\1\"$$(grep 'VERSION' VERSION.md | cut -d" " -f2)\";/" -i source/ublexec.h; \ echo "-- Build path: ${CMAKE_BUILD_DIR}" - + depend: @echo "Check depends ..."; \ if [ ! -f /bin/${DEPENDS} ]; then \ @@ -52,10 +49,10 @@ prepare: check: @echo "Check ..."; \ - if [ -f ${CMAKE_BUILD_DIR}/${PKGNAME} ]; then \ + if [ -f ${CMAKE_BUILD_DIR}/${pkgname} ]; then \ echo "Check: OK"; \ else \ - echo "Check: ${CMAKE_BUILD_DIR}/${PKGNAME} not fount !"; \ + echo "Check: ${CMAKE_BUILD_DIR}/${pkgname} not fount !"; \ exit 1; \ fi @@ -72,19 +69,19 @@ uninstall: PATH_FILE_MO="/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ $(RM) "/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ done -# @for SIZE in 16x16 32x32 48x48 scalable; do \ - $(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/${PKGNAME}.svg"; \ - $(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/${PKGNAME}.png"; \ - done -# @for FILE_SVG in $(wildcard *.svg); do \ + @for SIZE in 16x16 32x32 48x48 scalable; do \ + $(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/ru.ublinux.${pkgname}.svg"; \ + $(RM) "/usr/share/icons/hicolor/$${SIZE}/apps/ru.ublinux.${pkgname}.png"; \ + done + @for FILE_SVG in $(wildcard *.svg); do \ for SIZE in 16x16 32x32 48x48 scalable; do \ $(RM) "/usr/share/icons/hicolor/$${SIZE}/status/$${FILE_SVG%.*}".{svg,png,jpg}; \ done; \ done - @$(RM) "/usr/bin/${PKGNAME}" - @$(RM) "/usr/share/applications/${PKGNAME}.desktop" - @$(RM) "/usr/share/polkit-1/actions/ru.ublinux.pkexec.${PKGNAME}.exec.policy" - @$(RM) -rd "/usr/share/${PKGNAME}" + @$(RM) "/usr/bin/${pkgname}" + @$(RM) "/usr/share/applications/${pkgname}.desktop" + @$(RM) "/usr/share/polkit-1/actions/ru.ublinux.pkexec.${pkgname}.exec.policy" + @$(RM) -rd "/usr/share/${pkgname}" @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ &>/dev/null @update-desktop-database --quiet 2>/dev/null @touch /usr/share/applications @@ -94,28 +91,26 @@ install: check uninstall @echo "Install ..." @for FILE_PO in $(wildcard *.po); do \ LANG=$${FILE_PO##*_};LANG=$${LANG%.*}; \ - install -dm755 /usr/share/locale/$${LANG}/LC_MESSAGES; \ + install -dm755 "${pkgdir}/usr/share/locale/$${LANG}/LC_MESSAGES"; \ FILE_MO=$${FILE_PO##*/}; FILE_MO="$${FILE_MO%_*.po}.mo"; \ - PATH_FILE_MO="/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ + PATH_FILE_MO="${pkgdir}/usr/share/locale/$${LANG}/LC_MESSAGES/$${FILE_MO}"; \ echo $${FILE_PO}; \ msgfmt "$${FILE_PO}" -v -f -o "$${PATH_FILE_MO}"; \ done @for SIZE in 16 32 48; do \ - install -dm755 /usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps; \ - rsvg-convert -w $${SIZE} -h $${SIZE} -f svg --keep-image-data ${PKGNAME}.svg -o "/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/${PKGNAME}.svg"; \ + install -dm755 "${pkgdir}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps"; \ + rsvg-convert -w $${SIZE} -h $${SIZE} -f png --keep-image-data "ru.ublinux.${pkgname}.svg" -o "${pkgdir}/usr/share/icons/hicolor/$${SIZE}x$${SIZE}/apps/ru.ublinux.${pkgname}.png"; \ done - @install -dm755 /usr/share/icons/hicolor/scalable/apps - @install -Dm644 -t /usr/share/icons/hicolor/scalable/apps/ ${PKGNAME}.svg - @install -Dm755 -t /usr/bin/ ${CMAKE_BUILD_DIR}/${PKGNAME} - @install -Dm644 -t /usr/share/applications/ ${PKGNAME}.desktop - @install -Dm644 -t /usr/share/polkit-1/actions/ org.ublinux.pkexec.${PKGNAME}.exec.policy - @install -dm755 /usr/share/${PKGNAME}/{ui,css,images} - @install -Dm644 -t /usr/share/${PKGNAME}/ui/ ${PKGNAME}.glade - @install -Dm644 -t /usr/share/${PKGNAME}/css/ style.css - @install -Dm644 -t /usr/share/${PKGNAME}/images/ bg_top.png - @install -Dm644 -t /usr/share/${PKGNAME}/images/ ${PKGNAME}.svg -# @install -Dm644 -t /usr/share/${PKGNAME}/images/ ${PKGNAME}.png - @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ + @install -dm755 "${pkgdir}/usr/share/icons/hicolor/scalable/apps" + @install -Dm644 -t "${pkgdir}/usr/share/icons/hicolor/scalable/apps/" "ru.ublinux.${pkgname}.svg" + @install -Dm755 -t "${pkgdir}/usr/bin/" "${CMAKE_BUILD_DIR}/${pkgname}" + @install -Dm644 -t "${pkgdir}/usr/share/applications/" "${pkgname}.desktop" + @install -Dm644 -t "${pkgdir}/usr/share/polkit-1/actions/" "com.ublinux.pkexec.${pkgname}.exec.policy" + @install -dm755 "${pkgdir}/usr/share/${pkgname}"/{ui,css,images} + @install -Dm644 -t "${pkgdir}/usr/share/${pkgname}/ui/" "${pkgname}.glade" + @install -Dm644 -t "${pkgdir}/usr/share/${pkgname}/css/" style.css + @install -Dm644 -t "${pkgdir}/usr/share/${pkgname}/images/" "logo-background.png" + @gtk-update-icon-cache -fiq /usr/share/icons/hicolor/ &>/dev/null @update-desktop-database --quiet 2>/dev/null @touch /usr/share/applications @echo "Install: OK" diff --git a/VERSION.md b/VERSION.md index 12ebd01..31c5941 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1 +1 @@ -VERSION 1.0 +VERSION 1.2 diff --git a/org.ublinux.pkexec.ublexec.exec.policy b/com.ublinux.pkexec.ublexec.exec.policy similarity index 100% rename from org.ublinux.pkexec.ublexec.exec.policy rename to com.ublinux.pkexec.ublexec.exec.policy diff --git a/devel/update-version b/devel/update-version new file mode 100755 index 0000000..e86b1b4 --- /dev/null +++ b/devel/update-version @@ -0,0 +1,18 @@ +#!/bin/bash +## +## Update VERSION 1.4 +## $1 - Version +## Default - current Version value plus one (in minor section) +## + +FILE_VERSION="VERSION.md" +[[ $1 ]] && VER=$1 +if [[ -z ${VER} ]] ; then + SOURCE_FILE_VERSION=$(find ../ -maxdepth 1 -type f -iname "${FILE_VERSION}" -print -quit) + CURRENT=$(cat ${SOURCE_FILE_VERSION} | grep 'VERSION' | cut -d" " -f2) + MAJOR=$(echo ${CURRENT} | cut -d. -f1) + MINOR=$(echo ${CURRENT} | cut -d. -f2) + VER="${MAJOR}.$(echo $((${MINOR} +1)))" +fi +echo ":: Updated VERSION ${CURRENT} to ${VER}" +find ../ -maxdepth 2 -type f -iname "${FILE_VERSION}" -exec echo ":: Insert version in file: {}" \; -exec sed "s/VERSION *[[:digit:]]*.*/VERSION ${VER}/" -i {} \; \ No newline at end of file diff --git a/bg_top.png b/logo-background.png similarity index 100% rename from bg_top.png rename to logo-background.png diff --git a/ublexec.svg b/ru.ublinux.ublexec.svg similarity index 100% rename from ublexec.svg rename to ru.ublinux.ublexec.svg diff --git a/screenshot/screenshot.png b/screenshot/screenshot.png index f2c3476..a18a4a0 100644 Binary files a/screenshot/screenshot.png and b/screenshot/screenshot.png differ diff --git a/source/main.cc b/source/main.cc old mode 100755 new mode 100644 index dea0329..50150ff --- a/source/main.cc +++ b/source/main.cc @@ -1,17 +1,10 @@ #include "ublexec.h" -int main(int argc, char** argv) -{ - +int main(int argc, char** argv) { string str_cmd_argv = ""; for (int i=1; irun(plug); return 0; } else { - MainWindow* wnd = nullptr; builder->get_widget_derived("window", wnd); auto r = app->run(*wnd); diff --git a/source/ublexec.cc b/source/ublexec.cc index 11fa404..139f269 100644 --- a/source/ublexec.cc +++ b/source/ublexec.cc @@ -1,28 +1,25 @@ #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; +const string path_app = "/usr/bin/"; +const string path_glade = "/usr/share/ublexec/ui/ublexec.glade"; +const string path_css = "/usr/share/ublexec/css/style.css"; +const 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_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); @@ -42,7 +39,7 @@ MainWindow::MainWindow(Glib::RefPtr const& builder) { this->settings(); } -void MainWindow::get_builder(){ +void MainWindow::get_builder() { builder->get_widget("btnFilemaneg", btnFilemaneg); builder->get_widget("btnListApp", btnListApp); builder->get_widget("btnStart", btnStart); @@ -106,29 +103,31 @@ void MainWindow::get_builder(){ builder->get_widget("aboutWindows", aboutWindows); builder->get_widget("btnSettings", btnSettings); builder->get_widget("btnBoxAboutDialog", btnBoxAboutDialog); + builder->get_widget("boxAbout", boxAbout); + builder->get_widget("cmbTerminal", cmbTerminal); } -void MainWindow::set_icon_array(){ - array_icon[0]=this->iconGraphics; - array_icon[1]=this->iconTools; - array_icon[2]=this->iconInternet; - array_icon[3]=this->iconMultimedia; - array_icon[4]=this->iconSettings; - array_icon[5]=this->iconEducation; - array_icon[6]=this->iconOffice; - array_icon[7]=this->iconOther; - array_icon[8]=this->iconDevelopment; - array_icon[9]=this->iconSystem; +void MainWindow::set_icon_array() { + array_icon[0] = this->iconGraphics; + array_icon[1] = this->iconTools; + array_icon[2] = this->iconInternet; + array_icon[3] = this->iconMultimedia; + array_icon[4] = this->iconSettings; + array_icon[5] = this->iconEducation; + array_icon[6] = this->iconOffice; + array_icon[7] = this->iconOther; + array_icon[8] = this->iconDevelopment; + array_icon[9] = this->iconSystem; } -void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_list_app){ +void MainWindow::template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_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_text_column(m_Columns.m_col_description); } -void MainWindow::add_CSS(){ +void MainWindow::add_CSS() { Glib::RefPtr cssProvider = Gtk::CssProvider::create(); cssProvider->load_from_path(path_css); Glib::RefPtr styleContext = Gtk::StyleContext::create(); @@ -140,10 +139,15 @@ void MainWindow::add_CSS(){ context_lbl_head->add_class("textHead"); } -void MainWindow::localization(){ +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); + aboutWindows->set_copyright(str_authors); aboutWindows->set_website(_("https://wiki.ublinux.com")); btnSynopsis->set_label(_("Help")); - btnAbout->set_label(_("About the program")); + btnAbout->set_label(_("About")); aboutWindows->set_comments(_("ublexec")); aboutWindows->set_website_label(_("Project Home Page")); aboutWindows->set_version(_(version_application.c_str())); @@ -154,14 +158,14 @@ void MainWindow::localization(){ 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")); + 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")); + 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")); + lblInfoPriority->set_text(_("Priority:")); lblMessageError->set_text(_("Select an executable file or program")); lblGraphics->set_text(_("Graphics")); lblTools->set_text(_("Tools")); @@ -173,13 +177,14 @@ void MainWindow::localization(){ 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)); btnListApp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_list_app)); btnStart->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::entry_app)); - chbTerminal->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::denamic_cmd)); + chbTerminal->signal_toggled().connect([&]() {cmbTerminal->set_sensitive(chbTerminal->get_active());this->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)); @@ -201,15 +206,78 @@ void MainWindow::event(){ 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)); + btnAbout->signal_activate().connect([&]() {aboutWindows->show();}); + cmbUser->signal_changed().connect([&]() {changed_user();denamic_cmd();}); + rbSudo->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); 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)); + rbSu->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); + rbPkexec->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::sudo_nice)); +} + + +void MainWindow::sudo_nice(){ + string response = this->call("id -Gn"); + if (geteuid() == 0 || cmbUser->get_active_text() == "root" ){ + 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)")); + } + 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)")); + } + 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)")); + } + 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)")); + } + this->denamic_cmd(); +} + +void MainWindow::changed_user() { + Glib::ustring entry_user = cmbUser->get_active_text(); + string response = this->call("id -Gn"); + bool flag_wheel_sudo = (rbSudo->get_active()==true && response.find("wheel") != string::npos); + if (geteuid() == 0 || entry_user == "root" || flag_wheel_sudo==true) { + 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)")); + } + 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)")); + } } -void MainWindow::delete_cmd(const int &x,const int &y){ - if (y>1){ + +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); @@ -217,15 +285,12 @@ void MainWindow::delete_cmd(const int &x,const int &y){ } } -bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event){ - if (user_cmd.length() != 0){ - //user_cmd_old = user_cmd;gi +bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) { + if (user_cmd.length() != 0) { } - else if (name_app.length() != 0){ - //name_app_old = name_app; + else if (name_app.length() != 0) { } - else if (path_file.length() != 0){ - //path_file_old = path_file; + else if (path_file.length() != 0) { } else{ user_cmd = txtCmd->get_text(); @@ -234,12 +299,12 @@ bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event){ return true; } - -void MainWindow::synopsis_show(){ - system("xdg-open https://wiki.ublinux.ru/ru/home &"); +void MainWindow::synopsis_show() { + string cmd = "xdg-open " + string(_("https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/")) + app_name + " &"; + system(cmd.c_str()); } -void MainWindow::icon_clear(){ +void MainWindow::icon_clear() { list_Graphics->clear(); list_Tools->clear(); list_Internet->clear(); @@ -252,45 +317,44 @@ void MainWindow::icon_clear(){ list_System->clear(); } -void MainWindow::ok_close_entry_app(){ +void MainWindow::ok_close_entry_app() { this->icon_clear(); dialogStartMenu->hide(); } -void MainWindow::select_Graphics(){ - this->tempate_icon_select(this->iconGraphics,list_Graphics); +void MainWindow::select_Graphics() { + this->tempate_icon_select(this->iconGraphics, list_Graphics); } -void MainWindow::select_Tools(){ - this->tempate_icon_select(this->iconTools,list_Tools); +void MainWindow::select_Tools() { + this->tempate_icon_select(this->iconTools, list_Tools); } -void MainWindow::select_Internet(){ - this->tempate_icon_select(this->iconInternet,list_Internet); +void MainWindow::select_Internet() { + this->tempate_icon_select(this->iconInternet, list_Internet); } -void MainWindow::select_Multimedia(){ - this->tempate_icon_select(this->iconMultimedia,list_Multimedia); +void MainWindow::select_Multimedia() { + this->tempate_icon_select(this->iconMultimedia, list_Multimedia); } -void MainWindow::select_Settings(){ - this->tempate_icon_select(this->iconSettings,list_Settings); +void MainWindow::select_Settings() { + this->tempate_icon_select(this->iconSettings, list_Settings); } -void MainWindow::select_Education(){ - this->tempate_icon_select(this->iconEducation,list_Education); +void MainWindow::select_Education() { + this->tempate_icon_select(this->iconEducation, list_Education); } -void MainWindow::select_Office(){ - this->tempate_icon_select(this->iconOffice,list_Office); +void MainWindow::select_Office() { + this->tempate_icon_select(this->iconOffice, list_Office); } -void MainWindow::select_Other(){ - this->tempate_icon_select(this->iconOther,list_Other); +void MainWindow::select_Other() { + this->tempate_icon_select(this->iconOther, list_Other); } -void MainWindow::select_Development(){ - this->tempate_icon_select(this->iconDevelopment,list_Development); +void MainWindow::select_Development() { + this->tempate_icon_select(this->iconDevelopment, list_Development); } -void MainWindow::select_System(){ - this->tempate_icon_select(this->iconSystem,list_System); +void MainWindow::select_System() { + this->tempate_icon_select(this->iconSystem, list_System); } -void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list){ +void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list) { auto selected = (*icon).get_selected_items(); - if(!selected.empty()) - { + if(!selected.empty()) { this->set_icon_array(); this->unselect_icon(icon); const Gtk::TreeModel::Path& path = *selected.begin(); @@ -304,90 +368,91 @@ void MainWindow::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtrset_text(app_name_exec); name_app = txtCmd->get_text(); int len_name_app = name_app.length(); - string array_del[] = {"%f","%F","%d","%D","%n","%N","%U"}; - for (auto &del_sim: array_del){ + string array_del[] = {"%f", "%F", "%d", "%D", "%n", "%N", "%U"}; + for (auto &del_sim: array_del) { str_remove(name_app, del_sim); - if (name_app.length()!=len_name_app){ + if (name_app.length() != len_name_app) { txtCmd->set_text(name_app); + this->denamic_cmd(); break; } } } } -void MainWindow::unselect_icon(Gtk::IconView *icon_entry){ - for (int index=0; index<10; ++index){ +void MainWindow::unselect_icon(Gtk::IconView *icon_entry) { + for (int index=0; index<10; ++index) { Gtk::IconView *icon = this->array_icon[index]; - if (icon_entry!=icon){ + if (icon_entry != icon) { icon->unselect_all(); } } } -void MainWindow::settings(){ +void MainWindow::settings() { this->pars_apps(); this->get_builder(); this->event(); this->localization(); this->add_CSS(); - spinPriority->set_range(0,19); - spinPriority->set_increments(1.0,-1.0); - scalePriority->set_range(0,19); + 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 (Низкий)"); - lblTime4EpriorityHigh->set_text("0 (Высокий)"); + lblTimeEpriorityLow->set_text(_("19 (Low)")); + lblTime4EpriorityHigh->set_text(_("0 (High)")); scalePriority->set_inverted(true); this->pars_dir_bin(); + this->pars_dir_terminal(); this->pars_users(); + this->is_user_wheel(); + cmbUser->set_active_text(user_exec_app); this->activ_or_block_execute_epriority(); this->changed_user(); - cmbUser->set_active(0); cmbUser->set_sensitive(false); lblInfoUserName->set_sensitive(false); rbPkexec->set_sensitive(false); rbSu->set_sensitive(false); rbSudo->set_sensitive(false); btnBoxAboutDialog->set_visible(false); - Gtk::Widget *boxAbout; - builder->get_widget("boxAbout",boxAbout); - - ubl_make_plugs(boxAbout,boxAbout, 0, socket_trd_id_I); + cmbTerminal->set_sensitive(false); + ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0); +} -} -void MainWindow::close_entry_app(){ +void MainWindow::close_entry_app() { this->icon_clear(); dialogStartMenu->hide(); } -void MainWindow::start_menu_entry_app(){} +void MainWindow::start_menu_entry_app() {} -void MainWindow::message_gui_close(){ +void MainWindow::message_gui_close() { messageError->hide(); } -void MainWindow::activ_or_block_execute_epriority(){ +void MainWindow::activ_or_block_execute_epriority() { bool flag = cbxExecuteEpriority->get_active(); scalePriority->set_sensitive(flag); spinPriority->set_sensitive(flag); - lblInfoNooPriority->set_sensitive(flag); lblTimeEpriorityLow->set_sensitive(flag); lblTime4EpriorityHigh->set_sensitive(flag); this->denamic_cmd(); } -void MainWindow::open_filemaneg(){ +void MainWindow::open_filemaneg() { + wndChooseFileWallpaper->set_current_folder("/bin/"); wndChooseFileWallpaper->show(); } -void MainWindow::close_filemaneg(){ +void MainWindow::close_filemaneg() { wndChooseFileWallpaper->hide(); } -void MainWindow::get_path_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(); @@ -396,8 +461,38 @@ void MainWindow::get_path_filemaneg(){ this->denamic_cmd(); } -void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr &dtk_list){ +vector MainWindow::find_all(string &text, string &word) { + size_t index{}; + vector list_index; + while ((index = text.find(word, index)) != std::string::npos) + { + index += word.length(); + list_index.push_back(index); + } + return list_index; +} + +void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::RefPtr &dtk_list) { Gtk::TreeModel::Row row = *(dtk_list->append()); + string s_remove[] = {".png", ".jpg", ".jpeg", ".svg", ".xpm"}; + string str_search = "/"; + if (path.find(str_search) != string::npos){ + vector list_index = this->find_all(path, str_search); + int index = list_index.size(); + if (index>1){ + index = index-1; + index = list_index.at(index); + if (index){ + size_t len_path = path.length(); + path = path.substr(index, len_path); + } + } + } + for (string &del: s_remove){ + if (path.find(del) != string::npos){ + str_remove(path, del); + } + } row[m_Columns.m_col_filename] = path; row[m_Columns.m_col_description] = Name; row[m_Columns.icon_name] = path; @@ -406,7 +501,7 @@ void MainWindow::tempalte_row(string Name, string Exec, string path , Glib::Ref row[m_Columns.float_w_align] = 0.5; } -void MainWindow::open_list_app(){ +void MainWindow::open_list_app() { this->template_apps_obj(iconGraphics, list_Graphics); this->template_apps_obj(iconTools, list_Tools); this->template_apps_obj(iconInternet, list_Internet); @@ -418,37 +513,37 @@ void MainWindow::open_list_app(){ this->template_apps_obj(iconDevelopment, list_Development); this->template_apps_obj(iconSystem, list_System); string path = ""; - for ( const auto &st_app : list_app){ - for ( const auto &str_categor : st_app.Categories){ + for ( const auto &st_app: list_app) { + for ( const auto &str_categor: st_app.Categories) { path = st_app.Icon; - if (str_categor=="Graphics"){ + if (str_categor == "Graphics") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Graphics); } - else if (str_categor=="Utility"){ + else if (str_categor == "Utility") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Tools); } - else if (str_categor=="Network"){ - this->tempalte_row(st_app.Name,st_app.Exec, path,list_Internet); + else if (str_categor == "Network") { + this->tempalte_row(st_app.Name,st_app.Exec, path, list_Internet); } - else if (str_categor== "AudioVideo"){ + else if (str_categor == "AudioVideo") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Multimedia); } - else if (str_categor=="Settings"){ + else if (str_categor == "Settings") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Settings); } - else if (str_categor=="Education"){ + else if (str_categor == "Education") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Education); } - else if (str_categor=="Office"){ + else if (str_categor == "Office") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Office); } - else if (str_categor=="Other"){ + else if (str_categor == "Other") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Other); } - else if (str_categor=="Development"){ + else if (str_categor == "Development") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_Development); } - else if (str_categor=="System"){ + else if (str_categor == "System") { this->tempalte_row(st_app.Name,st_app.Exec, path, list_System); } } @@ -457,96 +552,115 @@ void MainWindow::open_list_app(){ } -string MainWindow::start_cmd(string user_cmd){ - string str_cmd_terminal=""; +string MainWindow::start_cmd(string user_cmd) { + string str_cmd_terminal = ""; string str_variants_root = ""; string str_nice_cmd = ""; - if (chbAnotherUser->get_active()){ - if (geteuid()!=0){ - //chbTerminal->set_active(true); - } - if (rbPkexec->get_active()){ - str_variants_root = " pkexec --user " + cmbUser->get_active_text(); - if (cbxExecuteEpriority->get_active()){ + if (chbAnotherUser->get_active()) { + if (rbPkexec->get_active()) { + 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()){ + else if (rbSu->get_active()) { chbTerminal->set_active(true); string str_user = cmbUser->get_active_text(); - if (str_user!="root"){ + if (str_user != "root") { str_variants_root = "su -l " + cmbUser->get_active_text(); } else{ str_variants_root = "su "; } - - str_variants_root += + " -c \" DISPLAY=$DISPLAY "; - if (cbxExecuteEpriority->get_active()){ + 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()) { chbTerminal->set_active(true); - if (getlogin()==cmbUser->get_active_text()){ - str_variants_root="sudo "; + if (user_exec_app==cmbUser->get_active_text()) { + str_variants_root = "sudo "; } else{ - str_variants_root="sudo -u " + cmbUser->get_active_text() + " "; + 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_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; } } } - if (cmbUser->get_active_text().length()!=0){ + if (cmbUser->get_active_text().length() != 0) { 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()); } - if ((cbxExecuteEpriority->get_active()) && (chbAnotherUser->get_active()==false)){ - str_nice_cmd = " nice -n " + to_string(spinPriority->get_value_as_int()) + " "; + 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(); return ""; } - - if (chbTerminal->get_active() == true){ - str_cmd_terminal = "xterm -e "; + if (chbTerminal->get_active() == true) { + string name_terminal = cmbTerminal->get_active_text(); + if (name_terminal.length() != 0){ + if (name_terminal == "xfce4-terminal") { + str_cmd_terminal = "xfce4-terminal -x "; + } + else if (name_terminal == "konsole") { + str_cmd_terminal = "konsole -e "; + } + else if (name_terminal == "xterm") { + str_cmd_terminal = "xterm -e "; + } + else{ + str_cmd_terminal = ""; + } + } + else{ + str_cmd_terminal = ""; + } + } else{ str_cmd_terminal = ""; } - string cmd = ""; - if (path_file.length()>0){ - cmd = "nohup " + str_nice_cmd + str_cmd_terminal + str_variants_root + " xdg-open '" + path_file + "' "; + if (path_file.length() > 0) { + if (access(path_file.c_str(), X_OK) != -1) { + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " " + path_file; + } + else{ + cmd = 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 (name_app.length() > 0) { + cmd = 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 (user_cmd.length() > 0) { + cmd = str_nice_cmd + str_cmd_terminal + str_variants_root + " " + user_cmd; } - if (cmd.find("-e su ")!=string::npos){ + if ((cmd.find("-e su ") != string::npos) || (cmd.find("-x su ") != string::npos)) { cmd+=" \""; } + cmd = "nohup " + 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); +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){ +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); @@ -561,94 +675,91 @@ void MainWindow::denamic_cmd(){ } } else{ - if (user_cmd.length() != 0){ + if (user_cmd.length() != 0) { txtCmd->set_text(this->start_cmd(user_cmd)); } - else if (path_file.length() != 0){ + else if (path_file.length() != 0) { txtCmd->set_text(this->start_cmd(user_cmd)); } - else if (name_app.length() != 0){ + else if (name_app.length() != 0) { txtCmd->set_text(this->start_cmd(user_cmd)); } } } -bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event){ - if (cmd_old!=txtCmd->get_text()){ +string MainWindow::call(string cmd) { + FILE *fp; + int status; + char path[PATH_MAX] = {0}; + fp = popen(cmd.c_str(), "r"); + if (fp == NULL) { + exit(1); + } + while (fgets(path, PATH_MAX, fp) != NULL) { + break; + } + status = pclose(fp); + if (status == -1) { + exit(1); + } + return path; +} + +bool MainWindow::focus_out_txt_cmd(GdkEventFocus* event) { + if (cmd_old != txtCmd->get_text()) { user_cmd = txtCmd->get_text(); } return true; } -void MainWindow::entry_app(){ +void MainWindow::entry_app() { this->denamic_cmd(); - if (name_app.length()==0 && path_file.length()==0){ - + if (name_app.length() == 0 && path_file.length() == 0) { } string cmd = txtCmd->get_text(); this->call_app(cmd); } -void MainWindow::changed_user(){ - Glib::ustring entry_user = cmbUser->get_active_text(); - if (geteuid()==0 || entry_user == "root"){ - 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 (Низкий)"); - lblTime4EpriorityHigh->set_text("-20 (Высокий)"); - } - 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 (Низкий)"); - lblTime4EpriorityHigh->set_text("0 (Высокий)"); - } -} - -void MainWindow::activ_or_block_other_user(){ +void MainWindow::activ_or_block_other_user() { bool flag = chbAnotherUser->get_active(); 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(){ +void MainWindow::change_scale_priority() { 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()); this->denamic_cmd(); } -void MainWindow::pars_dir_bin(){ +void MainWindow::pars_dir_bin() { namespace fs = std::filesystem; std::string path = "/bin"; string file_name = ""; - for (const auto & entry : fs::directory_iterator(path)){ + for (const auto & entry: fs::directory_iterator(path)) { file_name = entry.path().filename().string(); - if (file_name=="su"){ + if (file_name == "su") { flag_su = true; } - else if (file_name=="sudo"){ + else if (file_name == "sudo") { flag_sudo = true; } - else if (file_name=="pkexec"){ + else if (file_name == "pkexec") { flag_pkexec = true; } } @@ -657,7 +768,47 @@ void MainWindow::pars_dir_bin(){ rbSudo->set_sensitive(flag_sudo); } -void MainWindow::pars_users(){ +void MainWindow::pars_dir_terminal() { + namespace fs = std::filesystem; + std::string path = "/bin"; + string file_name = ""; + for (const auto & entry: fs::directory_iterator(path)) { + file_name = entry.path().filename().string(); + if (file_name == "konsole") { + cmbTerminal->append("konsole"); + cmbTerminal->set_active_text("konsole"); + } + else if (file_name == "xfce4-terminal") { + cmbTerminal->append("xfce4-terminal"); + cmbTerminal->set_active_text("xfce4-terminal"); + } + else if (file_name == "xterm") { + cmbTerminal->append("xterm"); + } + } +} + +void MainWindow::is_user_wheel(){ + string response = this->call("id -Gn"); + if (response.find("wheel") == string::npos){ + flag_sudo = false; + rbSudo->set_sensitive(flag_sudo); + } + size_t user_index = response.find(" "); + if (user_index!=string::npos){ + user_exec_app = response.substr(0, user_index); + } +} + +void MainWindow::pars_users() { + //string str_uid_max = this->call("grep \"^UID_MAX\" /etc/login.defs | xargs | cut -d ' ' -f 2)"); + //int uid_max = 0; + //if (str_uid_max.length() > 3){ + // int uid_max = stoi(str_uid_max); + //} + //else{ + int uid_max = 65534; + //} while (true) { errno = 0; passwd* entry = getpwent(); @@ -667,63 +818,61 @@ void MainWindow::pars_users(){ } break; } - - if (entry->pw_uid >= 1000 && entry->pw_uid!=65534){ + if ((entry->pw_uid >= 1000 && entry->pw_uid < uid_max) || entry->pw_uid == 0) { cmbUser->append(entry->pw_name); - } + } } - cmbUser->append("root"); endpwent(); } vector MainWindow::split(const std::string &s, char delim) { - std::stringstream ss(s); - std::string item; - std::vector elems; - while (std::getline(ss, item, delim)) { - elems.push_back(item); - } - return elems; + std::stringstream ss(s); + std::string item; + std::vector elems; + while (std::getline(ss, item, delim)) { + elems.push_back(item); + } + return elems; } -void MainWindow::str_remove(std::string& source, std::string & to_remove){ +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); + i != string::npos; + i = source.find(to_remove)) + source.erase(i, n); } -void MainWindow::pars_apps(){ - if (list_app.size()!=0){return;} +void MainWindow::pars_apps() { + if (list_app.size() != 0 ) {return;} namespace fs = std::filesystem; struct struct_App App; string file_name = ""; string str_Categories; string path = "/usr/share/applications/"; - for (const auto & entry : fs::directory_iterator(path)){ + for (const auto & entry : fs::directory_iterator(path)) { file_name = entry.path().filename().string(); path = "/usr/share/applications/"+file_name; - if (file_name.find(".desktop")!=std::string::npos){ + if (file_name.find(".desktop") != std::string::npos) { GKeyFile *gfile=g_key_file_new(); - g_key_file_load_from_file(gfile,path.c_str(),G_KEY_FILE_KEEP_TRANSLATIONS,NULL); - char *Type=g_key_file_get_string(gfile,"Desktop Entry", "Type",NULL); - char *Name=g_key_file_get_locale_string(gfile,"Desktop Entry","Name",setlocale(LC_ALL,NULL),NULL); - char *Exec=g_key_file_get_string(gfile,"Desktop Entry", "Exec",NULL); - char *Categories=g_key_file_get_locale_string(gfile,"Desktop Entry", "Categories",setlocale(LC_ALL,""),NULL); - char *Icon=g_key_file_get_string(gfile,"Desktop Entry", "Icon",NULL); - char *Mime=g_key_file_get_string(gfile,"Desktop Entry", "MimeType",NULL); - if (Type==NULL) continue; - if (Name==NULL) continue; - if (Exec==NULL) continue; - if (Categories==NULL) continue; - if (Icon==NULL) continue; + g_key_file_load_from_file(gfile, path.c_str(), G_KEY_FILE_KEEP_TRANSLATIONS, NULL); + char *Type = g_key_file_get_string(gfile, "Desktop Entry", "Type", NULL); + char *Name = g_key_file_get_locale_string(gfile, "Desktop Entry", "Name", setlocale(LC_ALL, NULL), NULL); + char *Exec = g_key_file_get_string(gfile, "Desktop Entry", "Exec", NULL); + char *Categories = g_key_file_get_locale_string(gfile, "Desktop Entry", "Categories", setlocale(LC_ALL, ""), NULL); + char *Icon = g_key_file_get_string(gfile, "Desktop Entry", "Icon", NULL); + char *Mime = g_key_file_get_string(gfile, "Desktop Entry", "MimeType", NULL); + if (Type == NULL) continue; + if (Name == NULL) continue; + if (Exec == NULL) continue; + if (Categories == NULL) continue; + if (Icon == NULL) continue; str_Categories = Categories; App.Name = Name; App.Type = Type; App.Exec = Exec; App.Icon = Icon; - if (Mime!=NULL){ + if (Mime != NULL) { App.MimeType = Mime; } else{ @@ -731,7 +880,6 @@ void MainWindow::pars_apps(){ } App.Name_desktop = file_name; App.Categories = split(str_Categories, ';'); - } list_app.push_back(App); } diff --git a/source/ublexec.h b/source/ublexec.h index 5f34098..3a482c5 100644 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -19,10 +19,10 @@ using namespace std; -extern string path_app; -extern string app_name; -extern string path_glade; -extern string path_css; +extern const string path_app; +extern const string app_name; +extern const string path_glade; +extern const string path_css; extern int socket_ext_id_I; extern int socket_trd_id_I; void me_thread(string cmd); @@ -86,142 +86,146 @@ public: void delete_cmd(const int &x,const int &y); void synopsis_show(); void denamic_cmd(); + void is_user_wheel(); + void sudo_nice(); + vector find_all(string &text, string &word); bool focus_out_txt_cmd(GdkEventFocus* event); bool focus_in_txt_cmd(GdkEventFocus* event); void unselect_icon(Gtk::IconView *icon_entry); + void pars_dir_terminal(); void str_remove(std::string& source, std::string & to_remove); + string call(string cmd); vector split(const std::string &s, char delim); - public: - class ModelColumns : public Gtk::TreeModel::ColumnRecord - { - public: - ModelColumns() - { - add(m_col_filename); - 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 m_col_filename; - Gtk::TreeModelColumn icon_name; - Gtk::TreeModelColumn m_col_description; - Gtk::TreeModelColumn app_name_exec; - Gtk::TreeModelColumn > m_col_pixbuf; - Gtk::TreeModelColumn float_h_align; - Gtk::TreeModelColumn float_w_align; - }; - ModelColumns m_Columns; - public: - Glib::RefPtr builder; - Gtk::Button *btnFilemaneg; - Gtk::Button *btnListApp; - Gtk::Button *btnStart; - Gtk::CheckButton *chbTerminal; - Gtk::CheckButton *chbAnotherUser; - Gtk::CheckButton *cbxExecuteEpriority; - Gtk::ComboBoxText *cmbUser; - Gtk::SpinButton *spinPriority; - Gtk::Scale *scalePriority; - Gtk::RadioButton *rbPkexec; - Gtk::RadioButton *rbSu; - Gtk::RadioButton *rbSudo; - Gtk::Entry *txtCmd; - Gtk::FileChooserDialog *wndChooseFileWallpaper; - Gtk::Button *btnFilemangerExit; - Gtk::Button *btnFilemangerOk; - Gtk::Label *lblTimeEpriority; - Gtk::Label *lblTimeEpriorityLow; - Gtk::Label *lblTime4EpriorityHigh; - Gtk::Label *lblUserName; - Gtk::MessageDialog *messageError; - Gtk::Button *btnMessageErrorOk; - Gtk::Label *lblMessageError; - Gtk::Button *btnStartMenuOK; - Gtk::Button *btnStartMenuExit; - Gtk::Window *dialogStartMenu; - Gtk::Box *boxColor; - Gtk::Label *lblInfoHead; - Gtk::Label *lblinfoCmd; - Gtk::Label *lblInfoTime; - Gtk::Label *labInfoExecutTerm; - Gtk::Label *lblInfoUser; - Gtk::Label *lblInfoUserOther; - Gtk::Label *lblInfoUserName; - Gtk::Label *lblInfoNooPriority; - Gtk::Label *lblInfoExec; - Gtk::Label *lblInfoPriority; - - Gtk::Label *lblGraphics; - Gtk::Label *lblTools; - Gtk::Label *lblInternet; - Gtk::Label *lblMultimedia; - Gtk::Label *lblSettings; - Gtk::Label *lblEducation; - Gtk::Label *lblOffice; - Gtk::Label *lblOther; - Gtk::Label *lblDevelopment; - Gtk::Label *lblSystem; - Gtk::Label *lblHeaderName; - - Gtk::IconView *iconGraphics; - Gtk::IconView *iconTools; - Gtk::IconView *iconInternet; - Gtk::IconView *iconMultimedia; - Gtk::IconView *iconSettings; - Gtk::IconView *iconEducation; - Gtk::IconView *iconOffice; - Gtk::IconView *iconOther; - 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 list_Graphics; - Glib::RefPtr list_Tools; - Glib::RefPtr list_Internet; - Glib::RefPtr list_Multimedia; - Glib::RefPtr list_Settings; - Glib::RefPtr list_Education; - Glib::RefPtr list_Office; - Glib::RefPtr list_Other; - Glib::RefPtr list_Development; - Glib::RefPtr 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 = ""; - bool flag_pkexec = false; - bool flag_su = false; - bool flag_sudo = false; - string path_file_name; - struct struct_App{ - string Name_desktop; - string Name; - string Exec; - string Icon; - string MimeType; - string Type; - vector Categories;}; - list list_app; - set set_categories; - int index_exec_gui_apps = 0; - Gtk::IconView* array_icon[10]; - - + class ModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ModelColumns() + { + add(m_col_filename); + 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 m_col_filename; + Gtk::TreeModelColumn icon_name; + Gtk::TreeModelColumn m_col_description; + Gtk::TreeModelColumn app_name_exec; + Gtk::TreeModelColumn > m_col_pixbuf; + Gtk::TreeModelColumn float_h_align; + Gtk::TreeModelColumn float_w_align; + }; + ModelColumns m_Columns; + public: + Glib::RefPtr builder; + Gtk::Button *btnFilemaneg; + Gtk::Button *btnListApp; + Gtk::Button *btnStart; + Gtk::CheckButton *chbTerminal; + Gtk::CheckButton *chbAnotherUser; + Gtk::CheckButton *cbxExecuteEpriority; + Gtk::ComboBoxText *cmbUser; + Gtk::SpinButton *spinPriority; + Gtk::Scale *scalePriority; + Gtk::RadioButton *rbPkexec; + Gtk::RadioButton *rbSu; + Gtk::RadioButton *rbSudo; + Gtk::Entry *txtCmd; + Gtk::FileChooserDialog *wndChooseFileWallpaper; + Gtk::Button *btnFilemangerExit; + Gtk::Button *btnFilemangerOk; + Gtk::Label *lblTimeEpriority; + Gtk::Label *lblTimeEpriorityLow; + Gtk::Label *lblTime4EpriorityHigh; + Gtk::Label *lblUserName; + Gtk::MessageDialog *messageError; + Gtk::Button *btnMessageErrorOk; + Gtk::Label *lblMessageError; + Gtk::Button *btnStartMenuOK; + Gtk::Button *btnStartMenuExit; + Gtk::Window *dialogStartMenu; + Gtk::Box *boxColor; + Gtk::Label *lblInfoHead; + Gtk::Label *lblinfoCmd; + Gtk::Label *lblInfoTime; + Gtk::Label *labInfoExecutTerm; + Gtk::Label *lblInfoUser; + Gtk::Label *lblInfoUserOther; + Gtk::Label *lblInfoUserName; + Gtk::Label *lblInfoNooPriority; + Gtk::Label *lblInfoExec; + Gtk::Label *lblInfoPriority; + Gtk::Label *lblGraphics; + Gtk::Label *lblTools; + Gtk::Label *lblInternet; + Gtk::Label *lblMultimedia; + Gtk::Label *lblSettings; + Gtk::Label *lblEducation; + Gtk::Label *lblOffice; + Gtk::Label *lblOther; + Gtk::Label *lblDevelopment; + Gtk::Label *lblSystem; + Gtk::Label *lblHeaderName; + Gtk::IconView *iconGraphics; + Gtk::IconView *iconTools; + Gtk::IconView *iconInternet; + Gtk::IconView *iconMultimedia; + Gtk::IconView *iconSettings; + Gtk::IconView *iconEducation; + Gtk::IconView *iconOffice; + Gtk::IconView *iconOther; + Gtk::IconView *iconDevelopment; + Gtk::IconView *iconSystem; + Gtk::IconView *iconEntry; + Gtk::MenuItem *btnAbout; + Gtk::MenuItem *btnSynopsis; + Gtk::AboutDialog *aboutWindows; + Gtk::MenuButton *btnSettings; + Gtk::ButtonBox *btnBoxAboutDialog; + Gtk::ComboBoxText *cmbTerminal; + Glib::RefPtr list_Graphics; + Glib::RefPtr list_Tools; + Glib::RefPtr list_Internet; + Glib::RefPtr list_Multimedia; + Glib::RefPtr list_Settings; + Glib::RefPtr list_Education; + Glib::RefPtr list_Office; + Glib::RefPtr list_Other; + Glib::RefPtr list_Development; + Glib::RefPtr list_System; + Gtk::Widget *boxAbout; + public: + string version_application = "1.0"; + string cmd_old = ""; + string user_exec_app = ""; + string user_cmd = ""; + string user_cmd_old = ""; + string name_app_old = ""; + string path_file_old = ""; + string execute_cmd = ""; + string path_file = ""; + string name_app = ""; + bool flag_pkexec = false; + bool flag_su = false; + bool flag_sudo = false; + string path_file_name; + struct struct_App { + string Name_desktop; + string Name; + string Exec; + string Icon; + string MimeType; + string Type; + vector Categories; + }; + list list_app; + set set_categories; + int index_exec_gui_apps = 0; + Gtk::IconView* array_icon[10]; + }; class SettingsPlug : public Gtk::Plug{ diff --git a/style.css b/style.css index 0ea8eb1..dea0dd6 100644 --- a/style.css +++ b/style.css @@ -1,5 +1,5 @@ .cssboxColor1{ - background: url("/usr/share/ublexec/images/bg_top.png") no-repeat; + background: url("/usr/share/ublexec/images/logo-background.png") no-repeat; } .textHead{ text-shadow: 1px 1px #ffffff; @@ -60,13 +60,4 @@ .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)); } \ No newline at end of file diff --git a/ublexec.desktop b/ublexec.desktop index ef0cc9d..5e83001 100644 --- a/ublexec.desktop +++ b/ublexec.desktop @@ -1,14 +1,15 @@ [Desktop Entry] Encoding=UTF-8 Name=ublexec -Name[ru]=Выполнить +Name[ru]=Выполнить как... GenericName=Execution from user rights -GenericName[ru]=Выполнить +GenericName[ru]=Выполнить как... Comment=Execution from user rights -Comment[ru]=Выполнить +Comment[ru]=Выполнить как... Type=Application Exec=ublexec -Icon=ublexec +Icon=ru.ublinux.ublexec Terminal=false X-XfcePluggable=true -Categories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;X-UBL-SettingsManager;X-UBL-SystemSettings; \ No newline at end of file +X-UBLPluggable=true +Categories=XFCE;GTK;Utility;X-GNOME-Utilities;System; \ No newline at end of file diff --git a/ublexec.glade b/ublexec.glade index 09eb905..ca1e689 100644 --- a/ublexec.glade +++ b/ublexec.glade @@ -16,17 +16,19 @@ ubl-settings-datetime dialog True - ublexec + False + False + ubl-exec 1.0 - Copyright © 2023 - UBSoft Software LLC - Setting the date and time + Copyright © UBSoft LLC, 2022 - + ublexec https://ublinux.ru/ Project Home Page Это приложение распространяется без каких-либо гарантий. Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. UBGroup UBGroup - ublexec + ru.ublinux.ublexec True gpl-2-0 @@ -64,6 +66,7 @@ 450 240 False + ru.ublinux.ublexec True @@ -958,8 +961,6 @@ 6 gtk-media-play -<<<<<<< HEAD -======= @@ -988,7 +989,6 @@ True False Synopsis - True @@ -998,17 +998,16 @@ True False - About the program - True + About ->>>>>>> devel False + ru.ublinux.ublexec True @@ -1029,7 +1028,7 @@ 6 6 69 - ublexec + ru.ublinux.ublexec False @@ -1083,9 +1082,10 @@ specified priority True False + True vertical - + True False 5 @@ -1094,6 +1094,7 @@ specified priority 5 6 6 + True 0.019999999552965164 in @@ -1102,14 +1103,16 @@ specified priority False 5 5 + True vertical True False + True - 145 + 0 True False 5 @@ -1118,7 +1121,7 @@ specified priority 5 6 6 - Team + Team: True 0 @@ -1130,7 +1133,7 @@ specified priority - 330 + 381 True True 5 @@ -1148,6 +1151,7 @@ specified priority + 51 True True True @@ -1182,6 +1186,7 @@ specified priority + 51 True True True @@ -1225,9 +1230,10 @@ specified priority False 6 6 + True - 131 + 110 True False 15 @@ -1268,6 +1274,34 @@ specified priority 1 + + + True + False + start + 9 + 5 + 5 + 6 + + + False + True + 2 + + + + + 116 + True + False + + + False + True + 3 + + False @@ -1281,6 +1315,7 @@ specified priority True False + start Command Line @@ -1293,7 +1328,7 @@ specified priority - True + False True 1 @@ -1303,15 +1338,17 @@ specified priority True False 5 + True vertical - + True False 5 5 5 5 + True 0.019999999552965164 in @@ -1320,11 +1357,13 @@ specified priority False 5 5 + True vertical True False + True True @@ -1343,7 +1382,7 @@ specified priority True False - Run as another user + Run as another user: @@ -1426,9 +1465,10 @@ specified priority True False + True - 145 + 123 True False 5 @@ -1437,7 +1477,7 @@ specified priority 5 6 6 - User Name + User Name: True 0 @@ -1449,7 +1489,7 @@ specified priority - 330 + 381 True False 5 @@ -1465,6 +1505,19 @@ specified priority 1 + + + 0 + True + False + 100 + + + False + True + 2 + + False @@ -1478,6 +1531,7 @@ specified priority True False + start User @@ -1490,7 +1544,7 @@ specified priority - True + False True 2 @@ -1500,15 +1554,17 @@ specified priority True False 5 + True vertical - + True False 5 5 5 5 + True 0.019999999552965164 in @@ -1517,6 +1573,7 @@ specified priority False 5 5 + True vertical @@ -1550,6 +1607,7 @@ specified priority True False + True 5 @@ -1560,8 +1618,7 @@ specified priority 5 5 6 - 6 - Priority + Priority: True 0 @@ -1573,14 +1630,14 @@ specified priority + -1 True True 5 5 5 5 - 6 - 6 + 9 adjustment1 20 0 @@ -1601,7 +1658,6 @@ specified priority 5 5 6 - 6 True @@ -1621,9 +1677,10 @@ specified priority True False + False - 65 + 62 True False 15 @@ -1647,7 +1704,6 @@ specified priority 5 5 5 - 6 6 19 (Low) True @@ -1669,7 +1725,6 @@ specified priority 5 5 5 - 6 6 -20 (High) True @@ -1683,7 +1738,7 @@ specified priority - 95 + 107 True False end @@ -1711,6 +1766,7 @@ specified priority True False + start Priority @@ -1723,7 +1779,7 @@ specified priority - True + False True 3 @@ -1751,24 +1807,22 @@ specified priority - True + False True 0 - True + False True 2 -<<<<<<< HEAD -======= - + True False True @@ -1787,7 +1841,7 @@ specified priority True False 32 - ublexec + ru.ublinux.ublexec @@ -1825,11 +1879,11 @@ specified priority ->>>>>>> devel False Внимание! + ru.ublinux.ublexec dialog @@ -1890,6 +1944,7 @@ specified priority 500 400 True + ru.ublinux.ublexec dialog True True diff --git a/ublexec.pot b/ublexec.pot new file mode 100644 index 0000000..dc8b95f --- /dev/null +++ b/ublexec.pot @@ -0,0 +1,127 @@ +# Russian translations for PACKAGE package. +# Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Automatically generated, 2023. +# +msgid "" +msgstr "" + +msgid "https://wiki.ublinux.com" +msgstr "" + +msgid "About" +msgstr "" + +msgid "Help" +msgstr "" + +msgid "Project Home Page" +msgstr "" + +msgid "System" +msgstr "" + +msgid "Development" +msgstr "" + +msgid "Other" +msgstr "" + +msgid "Office" +msgstr "" + +msgid "Education" +msgstr "" + +msgid "Settings" +msgstr "" + +msgid "Multimedia" +msgstr "" + +msgid "Internet" +msgstr "" + +msgid "Tools" +msgstr "" + +msgid "Graphics" +msgstr "" + +msgid "ОК" +msgstr "" + +msgid "Exit" +msgstr "" + +msgid "Selecting Programs" +msgstr "" + +msgid "Running applications as a user with a\nspecified priority" +msgstr "" + +msgid "Team" +msgstr "" + +msgid "Run in the terminal emulator" +msgstr "" + +msgid "Command Line" +msgstr "" + +msgid "Run as another user" +msgstr "" + +msgid "pkexec" +msgstr "" + +msgid "su" +msgstr "" + +msgid "sudo" +msgstr "" + +msgid "User Name" +msgstr "" + +msgid "User" +msgstr "" + +msgid "Change startup priority" +msgstr "" + +msgid "Priority" +msgstr "" + +msgid "19 (Low)" +msgstr "" + +msgid "-20 (High)" +msgstr "" + +msgid "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/" +msgstr "" + +msgid "0 (High)" +msgstr "" + +msgid "Run" +msgstr "" + +msgid "Select an executable file or program" +msgstr "" + +msgid "Please select File" +msgstr "" + +msgid "Warning!" +msgstr "" + +msgid "ublexec" +msgstr "" + +msgid "ubl-exec" +msgstr "" + +msgid "Copyright © UBSoft LLC, 2022 - " +msgstr "" \ No newline at end of file diff --git a/ublexec_ru.po b/ublexec_ru.po index 5f16e42..07acf1b 100644 --- a/ublexec_ru.po +++ b/ublexec_ru.po @@ -1,15 +1,25 @@ -# English translations for PACKAGE package. +# Russian translations for PACKAGE package. # Copyright (C) 2023 THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # Automatically generated, 2023. # msgid "" msgstr "" +"Project-Id-Version: ubconfig 1.0\n" +"Report-Msgid-Bugs-To: info@ublinux.ru\n" +"POT-Creation-Date: 2020-02-22 23:22+0600\n" +"PO-Revision-Date: 2020-02-22 23:28+0600\n" +"Last-Translator: ublinux \n" +"Language-Team: Russian - UBLinux Team \n" +"Language: Russian\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" msgid "https://wiki.ublinux.com" msgstr "https://wiki.ublinux.ru" -msgid "About the program" +msgid "About" msgstr "О программе" msgid "Help" @@ -60,8 +70,8 @@ msgstr "Выбор программ" msgid "Running applications as a user with a\nspecified priority" msgstr "Запуск приложений от имени пользователя с\nуказанным приоритетом" -msgid "Team" -msgstr "Команда" +msgid "Team:" +msgstr "Команда:" msgid "Run in the terminal emulator" msgstr "Выполнить в эмуляторе терминала" @@ -69,8 +79,8 @@ msgstr "Выполнить в эмуляторе терминала" msgid "Command Line" msgstr "Командная строка" -msgid "Run as another user" -msgstr "Выполнить от имени другого пользователя" +msgid "Run as another user:" +msgstr "Выполнить от имени другого пользователя:" msgid "pkexec" msgstr "pkexec" @@ -81,8 +91,8 @@ msgstr "su" msgid "sudo" msgstr "sudo" -msgid "User Name" -msgstr "Имя поьзователя" +msgid "User Name:" +msgstr "Имя пользователя:" msgid "User" msgstr "Пользователь" @@ -90,6 +100,9 @@ msgstr "Пользователь" msgid "Change startup priority" msgstr "Изменить приоритет запуска" +msgid "Priority:" +msgstr "Приоритет:" + msgid "Priority" msgstr "Приоритет" @@ -99,6 +112,12 @@ msgstr "19 (Низкий)" msgid "-20 (High)" msgstr "-20 (Высокий)" +msgid "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/" +msgstr "https://wiki.ublinux.ru/ru/Программное_обеспечение/Программы_и_утилиты/Все/" + +msgid "0 (High)" +msgstr "0 (Высокий)" + msgid "Run" msgstr "Запустить" @@ -112,4 +131,10 @@ msgid "Warning!" msgstr "Внимание!" msgid "ublexec" -msgstr "Выполнить" +msgstr "Выполнить как..." + +msgid "ubl-exec" +msgstr "ubl-exec" + +msgid "Copyright © UBSoft LLC, 2022 - " +msgstr "Авторские права © ООО \"Юбисофт\", 2022 - " \ No newline at end of file