diff --git a/Makefile b/Makefile index 61b9849..ad374d7 100644 --- a/Makefile +++ b/Makefile @@ -120,7 +120,6 @@ install: check uninstall @install -Dm644 -t "${DESTDIR}${PREFIX}/share/icons/hicolor/scalable/apps/" "com.ublinux.${PKGNAME}.svg" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" - @install -Dm755 -t "${DESTDIR}/usr/share/${PKGNAME}/csv/" "${PKGNAME}_terminals.csv" @install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy" @sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy @if [ -z ${DESTDIR} ]; then \ diff --git a/source/ubl-utils.c b/source/ubl-utils.c index 2041cd3..a273009 100644 --- a/source/ubl-utils.c +++ b/source/ubl-utils.c @@ -638,11 +638,11 @@ char *yon_char_replace(char *source, char *find, char*replace){ char *temp=NULL; if(!strstr(replace,find)){ while ((final=strstr(source,find))){ - temp=malloc(strlen(source)-strlen(final)); - memset(temp,0,strlen(source)-strlen(final)+strlen(replace)); + temp=malloc(strlen(source)-strlen(final))+1; + memset(temp,0,strlen(source)-strlen(final)+strlen(replace)+1); memcpy(temp,source,strlen(source)-strlen(final)); temp=yon_char_append(temp,replace); - source=yon_char_append(temp,final+1); + source=yon_char_append(temp,final+strlen(find)); } } diff --git a/source/ublexec.c b/source/ublexec.c index 9d237ef..8590057 100644 --- a/source/ublexec.c +++ b/source/ublexec.c @@ -171,68 +171,28 @@ void on_setup_command(GtkWidget *self, main_window *widgets){ char *target = (char*)gtk_entry_get_text(GTK_ENTRY(widgets->TargetNameEntry)); if (target&&strcmp(target,"")){ char *final_command; - char *terminal_exec = yon_dictionary_get_data(yon_dictionary_get(&main_config.terminals,(char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo))),terminal_info*)->exec_file; - char *terminal_hold = yon_dictionary_get_data(main_config.terminals,terminal_info*)->hold; - char *terminal_exec_arg = yon_dictionary_get_data(main_config.terminals,terminal_info*)->exec_arg; + int terminal_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)); + int chosen_terminal = gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo)); + terminal_info *terminal = yon_dictionary_get_data(yon_dictionary_get_nth(main_config.terminals,chosen_terminal),terminal_info*); + int user_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck)); char *user = (char*)gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(widgets->runWithUserCombo)); - char *priority = yon_char_append("nice -n ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserCheck))){ - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck))){ - final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "pkexec ", NULL); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root - final_command = yon_char_unite(final_command, " --user root env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR SESSION_MANAGER=$SESSION_MANAGER GNOME_DESKTOP_SESSION_ID=$GNOME_DESKTOP_SESSION_ID KDE_FULL_SESSION=$KDE_FULL_SESSION ",NULL); - } else { - final_command = yon_char_unite(final_command, " --user ",user," env HOME=$HOME DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); - } - - if (strstr(target,".")){ - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,NULL); - } else { - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,NULL); - } - - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck))){ - final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "su ", NULL); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root - final_command = yon_char_unite(final_command, " --preserve-environment --command \"setsid ",NULL); - } else { - final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --login ",user," --command \"setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); - } - - if (strstr(target,".")){ - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open ",target,"\"",NULL); - } else { - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," ") : "",target,"\"",NULL); - } - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){ - final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL); - } - - } else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck))){ - final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ",!strstr(target,".") ? terminal_hold : ""," ",terminal_exec_arg," ",NULL) : "", "sudo ", NULL); - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))==0){ //root - final_command = yon_char_unite(final_command, " --preserve-env setsid ",NULL); - } else { - final_command = yon_char_unite("xhost +SI:localuser:",user,"; ",final_command, " --user ",user," setsid env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS XDG_SESSION_TYPE=$XDG_SESSION_TYPE ",NULL); - } - - if (strstr(target,".")){ - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "xdg-open '",target,"'",NULL); - } else { - final_command = yon_char_unite(final_command,gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority," '") : "'",target,"'",NULL); - } - if (gtk_combo_box_get_active(GTK_COMBO_BOX(widgets->runWithUserCombo))){ - final_command = yon_char_unite(final_command,"; sleep 10 && xhost -SI:localuser:",user,NULL); - } - - } - } else { - if (strstr(target,".")){ - final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "", "setsid xdg-open ",target,NULL); - } else { - final_command = yon_char_unite(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithTerminalCheck)) ? yon_char_unite(terminal_exec," ", !strstr(target,".") ? terminal_hold : "",!strstr(target,".") ? " " : "", terminal_exec_arg, " ",NULL) : "",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)) ? yon_char_append(priority, " ") : "",target,NULL); - } - } + int pkexec_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserPkexecCheck)); + int su_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSuCheck)); + int sudo_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->runWithUserSudoCheck)); + int priority_check = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->priorityCheck)); + char *priority = priority_check ? yon_char_append(" -p ",yon_char_from_long(gtk_spin_button_get_value(GTK_SPIN_BUTTON(widgets->prioritySpin)))) : ""; + int size; + char *command = yon_char_unite(get_run_command_command, + terminal_check ? yon_char_append(" -t ", terminal->name_simple) : "", + user_check ? yon_char_append(" -u ", user) : "", + user_check&&pkexec_check ? " -e pkexec" : "", + user_check&&su_check ? " -e su" : "", + user_check&&sudo_check ? " -e sudo" : "", + priority_check ? priority : "", + yon_char_append(" ",target), + NULL); + config_str gotten_command = yon_config_load(command,&size); + final_command = yon_char_divide_search(*gotten_command,"\n",-1); gtk_entry_set_text(GTK_ENTRY(widgets->commandEntry),final_command); free(final_command); } @@ -362,18 +322,16 @@ main_window *setup_window(){ config_str terminals = yon_config_load(get_terminals_info_command,&size); - for (int i=0;iname = terminal_parsed[0]; - term->exec_file = terminal_parsed[1]; - term->hold = terminal_parsed[2]; - term->exec_arg = terminal_parsed[3]; - yon_dictionary_add_or_create_if_exists_with_data(main_config.terminals,term->name,term); - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo),term->name); + terminal_info *term = g_malloc0(sizeof(terminal_info)); + term->exec = terminal_parsed[0]; + term->name_simple = terminal_parsed[1]; + term->name = terminal_parsed[2]; + if (!access(term->exec,F_OK)) {gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets->runWithTerminalCombo),term->name); + yon_dictionary_add_or_create_if_exists_with_data(main_config.terminals,term->name,term); } } gtk_combo_box_set_active(GTK_COMBO_BOX(widgets->runWithTerminalCombo),0); diff --git a/source/ublexec.cc b/source/ublexec.cc deleted file mode 100644 index ed6f8af..0000000 --- a/source/ublexec.cc +++ /dev/null @@ -1,1058 +0,0 @@ -#include "ublexec.h" -using namespace std; - - -int flag_prog_file = 0; -string name_app_cmd = ""; -string version_application = "2.27"; -int socket_ext_id_I = 0; -int socket_trd_id_I = 0; - -MainWindow* obj_main; -void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data) { - if (self && user_data) {} - obj_main->global_lick_doc = link; - obj_main->aboutWindows->hide(); - obj_main->temp_help_show(); -} - -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); -} -::Window CmdArgParser::GetSocketID() const{ - return m_socketID; -} - -MainWindow::MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder) - : Gtk::ApplicationWindow(obj), builder{builder} { - this->builder = builder; - this->settings(); -} - -MainWindow::MainWindow(Glib::RefPtr const& builder) { - this->builder = builder; - this->settings(); -} - -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); - builder->get_widget("chbTerminal", chbTerminal); - builder->get_widget("chbAnotherUser", chbAnotherUser); - builder->get_widget("cbxExecuteEpriority", cbxExecuteEpriority); - builder->get_widget("cmbUser", cmbUser); - builder->get_widget("spinPriority", spinPriority); - builder->get_widget("scalePriority", scalePriority); - builder->get_widget("rbPkexec", rbPkexec); - builder->get_widget("rbSu", rbSu); - builder->get_widget("rbSudo", rbSudo); - builder->get_widget("txtCmd", txtCmd); - builder->get_widget("wndChooseFileWallpaper", wndChooseFileWallpaper); - builder->get_widget("btnFilemangerExit", btnFilemangerExit); - builder->get_widget("btnFilemangerOk", btnFilemangerOk); - builder->get_widget("lblTimeEpriorityLow", lblTimeEpriorityLow); - builder->get_widget("lblTime4EpriorityHigh", lblTime4EpriorityHigh); - builder->get_widget("messageError", messageError); - builder->get_widget("lblMessageError", lblMessageError); - builder->get_widget("btnMessageErrorOk", btnMessageErrorOk); - builder->get_widget("dialogStartMenu", dialogStartMenu); - builder->get_widget("btnStartMenuOK", btnStartMenuOK); - builder->get_widget("btnStartMenuExit", btnStartMenuExit); - builder->get_widget("lblInfoHead", lblInfoHead); - builder->get_widget("lblinfoCmd", lblinfoCmd); - builder->get_widget("lblInfoTime", lblInfoTime); - builder->get_widget("labInfoExecutTerm", labInfoExecutTerm); - builder->get_widget("lblInfoUser", lblInfoUser); - builder->get_widget("lblInfoUserOther", lblInfoUserOther); - builder->get_widget("lblInfoUserName", lblInfoUserName); - builder->get_widget("lblInfoNooPriority", lblInfoNooPriority); - builder->get_widget("lblInfoExec", lblInfoExec); - builder->get_widget("lblInfoPriority", lblInfoPriority); - builder->get_widget("boxColor", boxColor); - builder->get_widget("lblGraphics", lblGraphics); - builder->get_widget("lblTools", lblTools); - builder->get_widget("lblInternet", lblInternet); - builder->get_widget("lblMultimedia", lblMultimedia); - builder->get_widget("lblSettings", lblSettings); - builder->get_widget("lblEducation", lblEducation); - builder->get_widget("lblOffice", lblOffice); - builder->get_widget("lblOther", lblOther); - builder->get_widget("lblDevelopment", lblDevelopment); - builder->get_widget("iconGraphics", iconGraphics); - builder->get_widget("iconTools", iconTools); - builder->get_widget("iconInternet", iconInternet); - builder->get_widget("iconMultimedia", iconMultimedia); - builder->get_widget("iconSettings", iconSettings); - builder->get_widget("iconEducation", iconEducation); - builder->get_widget("iconOffice", iconOffice); - builder->get_widget("iconOther", iconOther); - builder->get_widget("iconDevelopment", iconDevelopment); - builder->get_widget("iconSystem", iconSystem); - builder->get_widget("lblSystem", lblSystem); - builder->get_widget("lblHeaderName", lblHeaderName); - builder->get_widget("btnhelp", btnhelp); - builder->get_widget("btnAbout", btnAbout); - 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); - builder->get_widget("lblHeaderAboutTopic", lblHeaderAboutTopic); - - builder->get_widget("lblwebHeaderName", lblwebHeaderName); - builder->get_widget("lblhelpText", lblhelpText); - builder->get_widget("lblhelpHeader", lblhelpHeader); - builder->get_widget("chkAlwaysOpenHelp", chkAlwaysOpenHelp); - builder->get_widget("btnReadHelp", btnReadHelp); - builder->get_widget("btnCancelHelp", btnCancelHelp); - builder->get_widget("wndShowWeb", wndShowWeb); - builder->get_widget("lblHeadeWndWeb", lblHeadeWndWeb); - - #ifdef WEBKIT_FOUND - builder->get_widget("wndWeb", wndWeb); - #endif -} - -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) { - 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() { - Glib::RefPtr cssProvider = Gtk::CssProvider::create(); - cssProvider->load_from_resource(path_css); - Glib::RefPtr styleContext = Gtk::StyleContext::create(); - Glib::RefPtr 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 context_lbl_head = lblInfoHead->get_style_context(); - Glib::RefPtr boxAbout_css = boxAbout->get_style_context(); - imgHeadBackground->set_from_resource(path_img_head_background); - for (auto &view: array_icon) { - Glib::RefPtr view_css = view->get_style_context(); - view_css->add_class("view_app"); - } - context_lbl_head->add_class("textHead"); - if (socket_ext_id_I == 0){ - boxAbout_css->add_class("bkim_no_plug"); - } -} - -void MainWindow::localization() { - time_t now = time(0); - tm *ltm = localtime(&now); - unsigned int year= 1900+ ltm->tm_year; - string str_authors = string(copyright) + to_string(year); - aboutWindows->set_copyright(str_authors); - aboutWindows->set_website(website); - btnhelp->set_label(str_help); - btnAbout->set_label(str_about_1); - aboutWindows->set_comments(define_name_app); - aboutWindows->set_website_label(home_page ); - aboutWindows->set_version(_(version_application.c_str())); - aboutWindows->set_title(space_name_app ); - lblHeaderAboutTopic->set_label(space_name_app ); - lblHeaderName->set_text(define_name_app); - this->set_title(define_name_app); - btnStart->set_label(str_run); - wndChooseFileWallpaper->set_title(str_please_select_file); - dialogStartMenu->set_title(str_selecting_programs); - lblInfoHead->set_text(define_name_app); - lblinfoCmd->set_text(str_localization_cmd_line); - lblInfoTime->set_text(str_localization_team); - labInfoExecutTerm->set_text(str_run_terminal); - lblInfoUser->set_text(str_localization_user); - lblInfoUserOther->set_text(str_run_of_user); - lblInfoUserName->set_text(str_localization_username); - lblInfoNooPriority->set_text(str_localization_priority); - lblInfoExec->set_text(str_change_priority); - lblInfoPriority->set_text(string(str_localization_priority) + ":"); - lblMessageError->set_text(str_select_app_program); - messageError->set_title(str_localization_attention); - lblGraphics->set_text(str_localization_graphics); - lblTools->set_text(str_localization_tools); - lblInternet->set_text(str_localization_internet); - lblMultimedia->set_text(str_localization_multimedia); - lblSettings->set_text(str_localization_settings); - lblEducation->set_text(str_localization_education); - lblOffice->set_text(str_localization_office); - lblOther->set_text(str_localization_other); - lblDevelopment->set_text(str_localization_development); - lblSystem->set_text(str_localization_system); - btnListApp->set_tooltip_text(str_application_overview); - btnFilemaneg->set_tooltip_text(str_file_overview); - btnMessageErrorOk->set_label(str_close); - lblhelpHeader->set_text(read_documentation_web); - lblhelpText->set_text(redirected_documentation); - btnReadHelp->set_label(read_online); - btnCancelHelp->set_label(cancel); - chkAlwaysOpenHelp->set_label(always_redirect); - lblwebHeaderName->set_label(name_app_1); - lblHeadeWndWeb->set_label(define_name_app); - lblwebHeaderName->set_label(define_name_app); - btnFilemaneg->set_tooltip_text(str_tooltip_filemanager); - btnListApp->set_tooltip_text(str_tooltip_list_app); -} - -void MainWindow::event() { - g_signal_connect(G_OBJECT(aboutWindows->gobj()), "activate-link", G_CALLBACK(wrapper_help_show), this); - btnCancelHelp->signal_clicked().connect([&]() {wndShowWeb->hide();}); - chkAlwaysOpenHelp->signal_toggled().connect([&]() {flag_open_browser = true;}); - btnReadHelp->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::open_browser)); - btnhelp->signal_activate().connect(sigc::mem_fun(*this, &MainWindow::open_help)); - 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([&]() {cmbTerminal->set_sensitive(chbTerminal->get_active());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)); - btnFilemangerExit->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::close_filemaneg)); - btnFilemangerOk->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::get_path_filemaneg)); - cbxExecuteEpriority->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::activ_or_block_execute_epriority)); - btnMessageErrorOk->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::message_gui_close)); - btnStartMenuOK->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::start_menu_entry_app)); - btnStartMenuExit->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::close_entry_app)); - btnStartMenuOK->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::ok_close_entry_app)); - iconGraphics->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Graphics)); - iconTools->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Tools)); - iconInternet->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Internet)); - iconMultimedia->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Multimedia)); - iconSettings->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Settings)); - iconEducation->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Education)); - iconOffice->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Office)); - iconOther->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Other)); - iconDevelopment->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_Development)); - iconSystem->signal_selection_changed().connect(sigc::mem_fun(*this,&MainWindow::select_System)); - btnAbout->signal_activate().connect([&]() {aboutWindows->show();}); - cmbUser->signal_changed().connect([&]() {changed_user();this->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)); - cmbTerminal->signal_changed().connect([&]() {this->denamic_cmd();}); -} - - - -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(nice_19); - lblTime4EpriorityHigh->set_text(nice__20); - } - 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(nice_19); - lblTime4EpriorityHigh->set_text(nice__20); - } - 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(nice_19); - lblTime4EpriorityHigh->set_text(nice_0); - } - 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(nice_19); - lblTime4EpriorityHigh->set_text(nice_0); - } - 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(nice_19); - lblTime4EpriorityHigh->set_text(nice__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(nice_19); - lblTime4EpriorityHigh->set_text(nice_0); - } -} - -void MainWindow::delete_cmd(const int &x, const int &y) { - if (x == 0) {} - if (y > 1) { - chbTerminal->set_active(false); - chbAnotherUser->set_active(false); - cbxExecuteEpriority->set_active(false); - name_app = ""; - path_file = ""; - user_cmd = ""; - txtCmd->set_text(""); - } -} - -bool MainWindow::focus_in_txt_cmd(GdkEventFocus* event) { - if (event) {} - if (user_cmd.length() != 0) { - } - else if (name_app.length() != 0) { - } - else if (path_file.length() != 0) { - } - else{ - user_cmd = txtCmd->get_text(); - } - cmd_old = txtCmd->get_text(); - return true; -} - -void MainWindow::temp_help_show() { - if (flag_open_browser == true) { - this->open_browser(); - } - else { - wndShowWeb->show_all(); - } - -} - -void MainWindow::open_help() { - global_lick_doc = const_link_doc; - temp_help_show(); -} - -void MainWindow::open_browser() { - #ifdef WEBKIT_FOUND - if (my_web_kit) { - gtk_widget_destroy(GTK_WIDGET(my_web_kit)); - } - my_web_kit = WEBKIT_WEB_VIEW(webkit_web_view_new()); - three = Glib::wrap(GTK_WIDGET(my_web_kit)); - wndWeb->add(*three); - webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); - wndWeb->show_all(); - webkit_web_view_load_uri(my_web_kit, _(global_lick_doc.c_str())); - wndWeb->show_all(); - #else - this->template_open_browser(global_lick_doc); - #endif - wndShowWeb->hide(); -} - -void MainWindow::template_open_browser(string link_doc) { - string cmd = cmd_xdg + string(_(link_doc.c_str())) + " &"; - string buf = ""; - if (geteuid() == 0) { - string response_user = getlogin(); - int size_s = std::snprintf(nullptr, 0, cmd_execute, response_user.c_str(), cmd.c_str()) + 1; - auto size = static_cast(size_s); - std::unique_ptr buf(new char[ size ]); - std::snprintf(buf.get(), size, cmd_execute, response_user.c_str(), cmd.c_str()); - cmd = string(buf.get(), buf.get() + size - 1); - } - index_error = system(cmd.c_str()); -} - -void MainWindow::icon_clear() { - list_Graphics->clear(); - list_Tools->clear(); - list_Internet->clear(); - list_Multimedia->clear(); - list_Settings->clear(); - list_Education->clear(); - list_Office->clear(); - list_Other->clear(); - list_Development->clear(); - list_System->clear(); -} - -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_Tools() { - this->tempate_icon_select(this->iconTools, list_Tools); -} -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_Settings() { - this->tempate_icon_select(this->iconSettings, list_Settings); -} -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_Other() { - this->tempate_icon_select(this->iconOther, list_Other); -} -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::tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list) { - auto selected = (*icon).get_selected_items(); - if(!selected.empty()) { - this->set_icon_array(); - this->unselect_icon(icon); - const Gtk::TreeModel::Path& path = *selected.begin(); - Gtk::TreeModel::iterator iter = gtk_list->get_iter(path); - Gtk::TreeModel::Row row = *iter; - auto app_name_exec = row[m_Columns.app_name_exec]; - const Glib::ustring description = row[m_Columns.m_col_description]; - path_file = ""; - name_app = ""; - user_cmd = ""; - txtCmd->set_text(app_name_exec); - name_app = txtCmd->get_text(); - 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); - if (name_app.length() != len_name_app) { - txtCmd->set_text(name_app); - break; - } - } - this->denamic_cmd(); - - } -} - -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) { - icon->unselect_all(); - } - } -} - -void MainWindow::settings() { - obj_main = this; - if (flag_prog_file == 1){ - user_cmd = name_app_cmd; - } - if (flag_prog_file == 2){ - path_file = name_app_cmd; - } - - this->pars_apps(); - this->get_builder(); - this->event(); - this->localization(); - this->set_icon_array(); - this->add_CSS(); - spinPriority->set_range(0, 19); - spinPriority->set_increments(1.0, -1.0); - scalePriority->set_range(0, 19); - scalePriority->set_value(0); - lblTimeEpriorityLow->set_text(nice_19); - lblTime4EpriorityHigh->set_text(nice_0); - 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(); - this->is_user_wheel(); - cmbUser->set_active_text(user_exec_app); - this->activ_or_block_execute_epriority(); - this->changed_user(); - cmbUser->set_sensitive(false); - lblInfoUserName->set_sensitive(false); - rbPkexec->set_sensitive(false); - rbSu->set_sensitive(false); - rbSudo->set_sensitive(false); - btnBoxAboutDialog->set_visible(false); - cmbTerminal->set_sensitive(false); - ubl_make_plugs(boxAbout, boxAbout, socket_ext_id_I, 0); -} - -void MainWindow::close_entry_app() { - this->icon_clear(); - dialogStartMenu->hide(); -} - -void MainWindow::start_menu_entry_app() {} - -void MainWindow::message_gui_close() { - messageError->hide(); -} - -void MainWindow::activ_or_block_execute_epriority() { - bool flag = cbxExecuteEpriority->get_active(); - scalePriority->set_sensitive(flag); - spinPriority->set_sensitive(flag); - lblTimeEpriorityLow->set_sensitive(flag); - lblTime4EpriorityHigh->set_sensitive(flag); - this->denamic_cmd(); -} - -void MainWindow::open_filemaneg() { - wndChooseFileWallpaper->set_current_folder("/bin/"); - wndChooseFileWallpaper->show(); -} - -void MainWindow::close_filemaneg() { - wndChooseFileWallpaper->hide(); -} - -void MainWindow::get_path_filemaneg() { - name_app = ""; - user_cmd = ""; - path_file = wndChooseFileWallpaper->get_filename(); - if (path_file.length() == 0) {} - else{ - txtCmd->set_text(path_file); - this->close_filemaneg(); - - } - this->denamic_cmd(); -} - -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; - row[m_Columns.app_name_exec] = Exec; - row[m_Columns.float_h_align] = 0.5; - row[m_Columns.float_w_align] = 0.5; -} - -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); - this->template_apps_obj(iconMultimedia, list_Multimedia); - this->template_apps_obj(iconSettings, list_Settings); - this->template_apps_obj(iconEducation, list_Education); - this->template_apps_obj(iconOffice, list_Office); - this->template_apps_obj(iconOther, list_Other); - 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) { - path = st_app.Icon; - if (str_categor == "Graphics") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Graphics); - } - 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 == "AudioVideo") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Multimedia); - } - else if (str_categor == "Settings") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Settings); - } - else if (str_categor == "Education") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Education); - } - else if (str_categor == "Office") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Office); - } - else if (str_categor == "Other") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Other); - } - else if (str_categor == "Development") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_Development); - } - else if (str_categor == "System") { - this->tempalte_row(st_app.Name,st_app.Exec, path, list_System); - } - } - } - dialogStartMenu->show_all(); -} - - -string MainWindow::start_cmd(string user_cmd) { - string str_cmd_terminal = ""; - string str_variants_root = ""; - string str_nice_cmd = ""; - 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()) { - chbTerminal->set_active(true); - string str_user = cmbUser->get_active_text(); - if (str_user != "root") { - str_variants_root = "su -l " + cmbUser->get_active_text(); - } - else{ - str_variants_root = "su "; - } - str_variants_root += " -c \" DISPLAY=$DISPLAY "; - if (cbxExecuteEpriority->get_active()) { - str_variants_root += "nice -n " + to_string(spinPriority->get_value_as_int()) + " "; - } - } - else if (rbSudo->get_active()) { - chbTerminal->set_active(true); - if (user_exec_app==cmbUser->get_active_text()) { - str_variants_root = "sudo "; - } - else{ - 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 (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"; - 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(str_localization_attention); - messageError->show(); - return ""; - } - if (chbTerminal->get_active() == true) { - string name_terminal_arr = ""; - string name_terminal = cmbTerminal->get_active_text(); - if (name_terminal.length() != 0) { - int len_termunal_cmd = sizeof(termunal_cmd)/sizeof(*termunal_cmd); - for (int index = 0; index 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 = str_nice_cmd + str_cmd_terminal + str_variants_root + name_app; - } - 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) || (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) {int index = system(cmd.c_str()); if (index){}}, 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->set_title(str_localization_attention); - messageError->show(); - } - else{ - txtCmd->set_text(this->start_cmd(user_cmd)); - } - } - else{ - if (user_cmd.length() != 0) { - txtCmd->set_text(this->start_cmd(user_cmd)); - } - else if (path_file.length() != 0) { - txtCmd->set_text(this->start_cmd(user_cmd)); - } - else if (name_app.length() != 0) { - txtCmd->set_text(this->start_cmd(user_cmd)); - } - } -} - -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 (event) {} - 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::activ_or_block_other_user() { - bool flag = chbAnotherUser->get_active(); - cmbUser->set_sensitive(flag); - lblInfoUserName->set_sensitive(flag); - if (flag_pkexec == true) { - rbPkexec->set_sensitive(flag); - } - if (flag_su == true) { - rbSu->set_sensitive(flag); - } - if (flag_sudo == true) { - rbSudo->set_sensitive(flag); - } - this->denamic_cmd(); -} - -void MainWindow::change_scale_priority() { - scalePriority->set_value(spinPriority->get_value_as_int()); - this->denamic_cmd(); -} - -void MainWindow::change_spin_priority() { - spinPriority->set_value(scalePriority->get_value()); - this->denamic_cmd(); -} - -void MainWindow::pars_dir_bin() { - 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 == "su") { - flag_su = true; - } - else if (file_name == "sudo") { - flag_sudo = true; - } - else if (file_name == "pkexec") { - flag_pkexec = true; - } - } - rbPkexec->set_sensitive(flag_pkexec); - rbSu->set_sensitive(flag_su); - rbSudo->set_sensitive(flag_sudo); -} - -void MainWindow::pars_dir_terminal() { - namespace fs = std::filesystem; - std::string path = "/bin"; - string file_name = ""; - string name_terminal = ""; - for (const auto & entry: fs::directory_iterator(path)) { - file_name = entry.path().filename().string(); - int len_termunal_cmd = sizeof(termunal_cmd)/sizeof(*termunal_cmd); - for (int index = 0; index < len_termunal_cmd; ++index) { - name_terminal = termunal_cmd[index]; - size_t index_term = name_terminal.find(" "); - if (index_term != string::npos){ - name_terminal = name_terminal.substr(0, index_term); - if (name_terminal == file_name) { - cmbTerminal->append(name_terminal); - cmbTerminal->set_active_text(name_terminal); - } - } - } - } -} - -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); - } -} - -unsigned short MainWindow::read_uid_min_max(string filename, string search){ - std::string line; - int uid = 0; - string remove_tab = "\t"; - string remove_space = " "; - std::ifstream in(filename); // окрываем файл для чтения - if (in.is_open()){ - while (getline(in, line)){ - try{ - if (line.find(search) != string::npos && (line.find("SYS_"+search) == string::npos)) { - this->str_remove(line, search); - this->str_remove(line, remove_space); - this->str_remove(line, remove_tab); - uid = atoi(line.c_str()); - } - } - catch (int x) { - if (search == "UID_MIN"){ - uid = 1000; - } - else{ - uid = 65534; - } - - } - - } - } - else{ - if (search == "UID_MIN") { - uid = 1000; - } - else{ - uid = 65534; - } - } - in.close(); - return uid; - -} - -void MainWindow::pars_users() { - unsigned short uid_min = this->read_uid_min_max(file_source_login_min_max, "UID_MIN"); - unsigned short uid_max = this->read_uid_min_max(file_source_login_min_max, "UID_MAX"); - while (true) { - errno = 0; - passwd* entry = getpwent(); - if (!entry) { - if (errno) { - break; - } - break; - } - if ((entry->pw_uid >= uid_min && entry->pw_uid < uid_max) || entry->pw_uid == 0) { - cmbUser->append(entry->pw_name); - } - } - 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; -} - -void MainWindow::str_remove(std::string& source, std::string to_remove) { - string::size_type n = to_remove.length(); - for (string::size_type i = source.find(to_remove); - i != string::npos; - i = source.find(to_remove)) - source.erase(i, n); -} - -void MainWindow::pars_apps() { - if (list_app.size() != 0 ) {return;} - namespace fs = std::filesystem; - struct struct_App App; - string file_name = ""; - string str_Categories; - string path = path_all_applications; - for (const auto & entry : fs::directory_iterator(path)) { - file_name = entry.path().filename().string(); - path = string(path_all_applications) +file_name; - 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; - str_Categories = Categories; - App.Name = Name; - App.Type = Type; - App.Exec = Exec; - App.Icon = Icon; - if (Mime != NULL) { - App.MimeType = Mime; - } - else{ - App.MimeType = ""; - } - App.Name_desktop = file_name; - App.Categories = split(str_Categories, ';'); - } - list_app.push_back(App); - } -} - -SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) - : Gtk::Plug{p_socketID} { - MainWindow* wnd = nullptr; - builder->get_widget_derived("window", wnd); - builder->get_widget("plugBox", plugBox); - plugBox->get_parent()->remove(*plugBox); - add(*plugBox); - show_all_children(); -} - -MainWindow::~MainWindow() { -} - -void help() { - cout << str_help_h; -} - - - diff --git a/source/ublexec.h b/source/ublexec.h index 5ea1bd6..e98e0e3 100644 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -26,7 +26,8 @@ #define get_user_id_min_command "grep \"^UID_MIN\" /etc/login.defs |grep -vE '(nologin|false)$' | sed -e 's/\t/ /g' -e 's/ */ /g'|grep -oE \"[0-9]{1,}\"" #define get_user_id_max_command "grep \"^UID_MAX\" /etc/login.defs | sed -e 's/\t/ /g' -e 's/ */ /g'|grep -oE \"[0-9]{1,}\"" #define get_users_command "getent passwd |cut -d: -f1,3" -#define get_terminals_info_command "grep \"\" /usr/share/ublexec/csv/ublexec_terminals.csv" +#define get_terminals_info_command "ublexec-cli -l|sed -e 's/\t/ /g' -e 's/^ *//g' -e 's/ */:/g'|cut -d':' -f1,2,3" +#define get_run_command_command "ublexec-cli -q -o" #define LocalePath "/usr/share/locale" #define LocaleName "ublexec" @@ -58,9 +59,8 @@ typedef struct { typedef struct { char *name; - char *exec_file; - char *hold; - char *exec_arg; + char *name_simple; + char *exec; } terminal_info; typedef struct { diff --git a/ublexec.glade b/ublexec.glade index b31d342..b326415 100644 --- a/ublexec.glade +++ b/ublexec.glade @@ -1,13 +1,9 @@ - + - - True - True - 6 - - + + False False True @@ -19,9 +15,9 @@ ublexec 1.0 Copyright © 2022 - 2023, UBSoft LLC - ublexec + Run as... https://ublinux.ru/ - Project Home Page + Project hompage Это приложение распространяется без каких-либо гарантий. Подробнее в <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.html">GNU General Public License, версии 2 или позднее</a>. UBGroup @@ -36,7 +32,7 @@ vertical 2 - + False end @@ -46,9 +42,6 @@ 1 - - - @@ -57,7 +50,7 @@ False True - + True False 5 @@ -65,7 +58,7 @@ 5 5 2 - ublexec + Run as... @@ -75,7 +68,6 @@ - -20 19 1 10 @@ -183,9 +175,238 @@ - - 410 - 240 + + 450 + False + False + 450 + 250 + dialog-question-symbolic + + + True + False + vertical + + + True + False + + + True + False + start + 20 + 20 + dialog-question-symbolic + 6 + + + False + True + 0 + + + + + True + False + vertical + + + True + False + start + 10 + 5 + Would you like to read documentation in the Web? + True + 0 + + + + + + + False + True + 0 + + + + + True + False + start + start + 10 + 10 + You will be redirected to documentation website where documentation is +translated and supported by community. + True + 0 + + + + True + True + 1 + + + + + Always redirect to online documentation + True + True + False + end + 10 + True + + + + False + True + 2 + + + + + + True + True + 1 + + + + + + True + True + 0 + + + + + True + False + 5 + 5 + 5 + 5 + 5 + 5 + 30 + True + + + Cancel + True + True + True + + + + True + True + 0 + + + + + Open documentation + True + True + True + + + + True + True + 1 + + + + + False + True + 1 + + + + + + + True + False + True + + + True + False + Run as... + + + + + + + + True + False + 32 + dialog-question-symbolic + + + + + + + True + False + media-playback-start-symbolic + + + + + + + + + + + + + + + + + + + True + False + False + False + 4 + dropdown-menu + + + 800 + 600 False com.ublinux.ublexec @@ -194,2124 +415,739 @@ False vertical - + True - True - in + False - + True False 5 5 5 5 + 5 5 - natural - - - True - False - 1 - 1 - 5 - 0 - etched-out - - - True - False - 12 - - - True - False - vertical - - - True - True - - - True - False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 4 - 5 - - - - - False - True - 1 - - - - - - - True - False - Graphics - - - - - False - True - 1 - - + 25 + + + False + True + 0 + + + + + True + False + start + 5 + 5 + 5 + 5 + 6 + 6 + + + + + + + False + True + 1 + + + + + False + True + 0 + + + + + True + False + + + 81 + True + False + start + + + -1 + + + + + False + True + 1 + + + + + True + False + 5 + 5 + 5 + 5 + vertical + + + True + False + vertical + 5 + + + True + False + True + vertical + + + True + False + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + True + vertical + 5 - + True - True + False + True + 5 - + True False + + + True + True + 1 + + + + + True + True + True + File view + end + 5 - + True False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - + center + center + 5 + 5 + 5 + 5 + 3 + 3 + folder-symbolic + - - False - True - 1 - + + + False + True + 2 + - - - True - False - Tools - - - - - False - True - 3 - - - - - True - True - 1 - + True - False + True + True + Program view + end - + True False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - + center + center + 5 + 5 + 5 + 5 + system-run-symbolic - - False - True - 1 - + - - - - True - False - Internet - + + False + True + 3 + False True - 5 + 0 - + True - True + False + True + 5 - + True - False + True + False + start + center + True True False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - + Run in the terminal emulator - - False - True - 1 - + + False + True + 1 + - - + + True + False False - Multimedia + + True + True + 2 + False True - 7 + 1 + + + + + True + False + start + File or app for running + + + + + True + True + 0 + + + + + False + True + 0 + + + + + True + False + True + vertical + + + True + False + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + True + vertical + 5 - + True - True + False + True + 5 - + True - False + True + False + start + center + True - + True False - 7 - 7 - 7 - 7 + Run as another user: - - False - True - 0 - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - - - - - - True - False - Settings + + False + True + 0 + - - - False - True - 9 - - - - - True - True - - True - False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - - - - - + + pkexec True - False - Education + False + True + False + 6 + True + runWithUserSuCheck + + False + True + 1 + - - - False - True - 11 - - - - - True - True - + + su True - False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - + False + True + False + True + runWithUserPkexecCheck + + False + True + 2 + - - + + + sudo True - False - Office + False + True + False + True + runWithUserSuCheck + + False + True + 3 + False True - 13 + 0 - + True - True + False + True + 5 - + True False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - + User Name: + True + 0 + + False + True + 0 + - - + + True + False False - Other + + True + True + 1 + False True - 15 + 1 + + + + + True + False + start + User + + + + + True + True + 0 + + + + + False + True + 1 + + + + + True + False + True + vertical + + + True + False + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + True + vertical + 5 - + True True + False + start + center + True - - True - False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - - - - - + True False - Development + Change startup priority False True - 17 + 0 - + True - True + False + True + 5 - - True - False - - - True - False - 7 - 7 - 7 - 7 - - - False - True - 0 - - - - - True - True - 1 - queue - horizontal - 1 - 350 - 1 - 1 - 1 - - - - 5 - 5 - 6 - 2 - - - - - - 5 - 4 - - - - - False - True - 1 - - - - - - + + 5 True False - System - - - - - False - True - 19 - - - - - - - - - - True - False - - - - - - - - - - - - True - True - 1 - - - - - True - False - end - start - - - gtk-cancel - True - True - True - 5 - 5 - 5 - 5 - 6 - 6 - True - - - True - True - 0 - - - - - gtk-ok - -1 - -1 - True - True - True - 5 - 5 - 5 - 5 - 6 - 6 - True - - - True - True - 1 - - - - - False - True - 2 - - - - - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - gtk-media-play - - - - - - - - - - - - - - - - - - - True - False - False - False - 4 - dropdown-menu - - - True - False - Help - - - - - - True - False - About - - - - - - False - com.ublinux.ublexec - - - True - False - vertical - - - True - False - - - 81 - True - False - start - - - -1 - - - - - False - True - 0 - - - - - True - False - vertical - - - True - False - vertical - - - True - False - True - vertical - - - True - False - 5 - 5 - 5 - 5 - 6 - 6 - True - 0.019999999552965164 - in - - - True - False - 5 - 5 - True - vertical - - - True - False - True - - - 0 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - Team: - True - 0 - - - False - True - 0 - - - - - 440 - True - True - 5 - 5 - 5 - 5 - 6 - 6 - - - True - True - 1 - - - - - 51 - True - True - True - end - 5 - 5 - 5 - 5 - 6 - 6 - - - True - False - center - center - 5 - 5 - 5 - 5 - 3 - 3 - gtk-directory - - - - - False - True - 2 - - - - - 51 - True - True - True - end - 5 - 5 - 5 - 5 - 6 - 6 - - - True - False - center - center - 5 - 5 - 5 - 5 - view-list-details - - - - - False - True - 3 - - - - - False - True - 0 - - - - - True - False - 6 - 6 - True - - - 44 - True - False - 15 - 5 - 15 - 5 - - - False - True - 0 - - - - - True - True - False - start - center - 5 - 5 - 5 - 5 - 6 - True - - - True - False - Run in the terminal emulator - - + center + Priority: + True + 0 False - True - 1 - - - - - True - False - start - 2 - 5 - 5 - 6 - - - False - True - 2 - - - - - 116 - True - False - - - False - True - 3 - - - - - False - True - 1 - - - - - - - True - False - start - Command Line - - - - - True - True - 0 - - - - - False - True - 1 - - - - - True - False - 5 - True - vertical - - - True - False - 5 - 5 - 5 - 5 - True - 0.019999999552965164 - in - - - True - False - 5 - 5 - True - vertical - - - True - False - True - - - True - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - True - - - True - False - Run as another user: - - - - - False - True - 0 - - - - - pkexec - True - True - False - 6 - 6 - 6 - True - rbSu - - - False - True - 1 - - - - - su - True - True - False - 3 - 31 - 3 - 31 - True - rbPkexec - - - False - True - 2 - - - - - sudo - True - True - False - 6 - 6 - 6 - 6 - True - rbSu - - - False - True - 3 - - - - - 95 - True - False - end - 15 - 5 - 15 - 5 - - - False - True - 4 - - - - - False - True - 0 - - - - - True - False - True - - - 123 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - User Name: - True - 0 - - - False - True - 0 - - - - - 374 - True - False - 5 - 5 - 5 - 5 - 6 - 6 - - - False - True - 1 - - - - - 0 - True - False - 100 - - - False - True - 2 - - - - - False - True - 1 - - - - - - - True - False - start - User - - - - - True - True - 0 - - - - - False - True - 2 - - - - - True - False - 5 - True - vertical - - - True - False - 5 - 5 - 5 - 5 - True - 0.019999999552965164 - in - - - True - False - 5 - 5 - True - vertical - - - True - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - True - - - True - False - Change startup priority - - - - - False - True - 0 - - - - - True - False - True - - - 5 - True - False - 5 - 5 - 5 - 5 - 13 - Priority: - True - 0 - - - False - True - 0 - - - - - -1 - True - True - 5 - 5 - 5 - 5 - adjustment1 - 20 - 0 - 0 - - - True - True - 1 - - - - - True - True - 5 - 5 - 5 - 5 - 15 - True - - - False - True - 2 - - - - - False - True - 1 - - - - - True - False - 9 - False - - - 62 - True - False - 15 - 5 - 15 - 5 - 0 - - - False - True - 0 - - - - - 145 - True - False - 5 - 5 - 5 - 5 - 6 - 19 (Low) - True - 0 - - - False - True - 1 - - - - - True - False - end - center - 5 - 5 - 5 - 5 - 6 - -20 (High) - True - 0 - - - True - True - 3 - - - - - 107 - True - False - end - 15 - 5 - 15 - 5 - - - False - True - 4 - - - - - False - True - 2 - - - - - - - True - False - start - Priority - - - - - True - True - 0 - - - - - False - True - 3 - - - - - Run - True - True - True - 5 - 5 - 5 - 5 - 6 - 6 - image1 - True - - - False - True - 4 - - - - - False - True - 0 - - - - - False - True - 2 - - - - - - - True - False - True - - - True - False - center - Ublexec - - - - - - - - True - False - 32 - com.ublinux.ublexec - - - - - True - False - - - True - True - False - True - True - menu1 - none - - - True - False - open-menu-symbolic - - - - - False - True - 0 - - - - - end - 1 - - - - - - - False - start - False - - - True - False - vertical - - - True - False - - - True - False - center - 20 - 20 - 20 - 20 - 20 - 20 - dialog-warning-symbolic - 6 - - - False - True - 1 - - - - - True - False - 10 - 25 - 10 - 25 - 20 - 20 - Select an executable file or program - True - 0 - - - True - True - 2 - - - - - True - True - 0 - - - - - Close - True - True - True - 5 - 5 - 5 - 5 - 5 - 5 - - - False - True - 2 - - - - - - - True - False - Warning! - True - - - True - False - 32 - com.ublinux.ublexec - 5 - - - - - - - False - Please select File - True - center - 500 - 400 - True - com.ublinux.ublexec - dialog - True - True - - - False - vertical - 2 - - - False - end - - - gtk-cancel - True - True - True - True - - - True - True - 0 - - - - - gtk-ok - True - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - - - - - - False - start - start - False - 450 - 250 - dialog-question-symbolic - - - True - False - vertical - - - True - False - - - True - False - start - 20 - 20 - dialog-question-symbolic - 6 - - - False - True - 0 - - - - - True - False - vertical - - - True - False - start - 10 - 5 - Would you like to read documentation in the Web? - True - 0 - - - - + True + 0 + + + + + True + False + True + 15 + adjustment1 + True + 20 + 0 + 0 + + + True + True + 1 + + + + + True + False + True + center + adjustment1 + True + + + False + True + 2 + + + + + False + True + 1 + + + + + True + False + 120 + 120 + False + 5 + + + True + False + 19 (Low) + 0 + + + False + True + 1 + + + + + True + False + end + center + 0 (High) + 0 + + + True + True + 3 + + + + + False + True + 2 + + + + + + + True + False + start + Priority + + + + + True + True + 0 + + False True - 0 + 2 - + True False - start - start - 10 - 10 - You will be redirected to documentation website where documentation is translated and supported by community. - True - 0 - + True + 0.019999999552965164 + in + + + True + False + 5 + 5 + 5 + 5 + 5 + True + vertical + 5 + + + True + False + True + 5 + + + Edit + True + True + False + True + + + False + True + 0 + + + + + True + False + True + + + True + True + 1 + + + + + False + True + 0 + + + + + + + True + False + start + Command line + + True True - 1 + 3 - - Always redirect to online documentation + + Run True True - False - end - 10 - True - + True + image1 + True False True - 2 + end + 4 - - - - True - True - 1 - - - - - - True - True - 0 - - - - - True - False - 5 - 5 - 5 - 5 - 5 - 5 - 30 - True - - - Cancel - True - True - True - - True + False True 0 - - - Read Online - True - True - True - - - - True - True - 1 - - False True - 1 + 2 - + True False True - + True False - ublexec + center + Run as... @@ -2322,12 +1158,47 @@ True False 32 - dialog-question-symbolic + com.ublinux.ublexec + + + + + True + False + + + True + True + False + True + True + menu2 + none + + + + + + False + True + 0 + + + + end + 1 + + + + + + + 800 600 @@ -2347,7 +1218,7 @@ True False - ublexec + Run as... diff --git a/ublexec_terminals.csv b/ublexec_terminals.csv deleted file mode 100644 index 42ad3b6..0000000 --- a/ublexec_terminals.csv +++ /dev/null @@ -1,7 +0,0 @@ -XTerm (xterm emulator):/usr/bin/xterm:-hold:-e -XFCE (xfce4-terminal emulator):/usr/bin/xfce4-terminal:--hold:-x -Mate (mate-terminal emulator):/usr/bin/mate-terminal:--window-with-profile=HoldOpen:-e -Gnome (gnome-terminal emulator):/usr/bin/gnome-terminal:--window-with-profile=HoldOpen:-e -KDE (konsole emulator):/usr/bin/konsole:-hold:-e -Enlightenment (terminology emulator):/usr/bin/terminology:--hold:-e -LXDE (lxterminal emulator):/usr/bin/lxterminal::-e \ No newline at end of file