#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ubl-util-standard.c" #include #include "../compile/ubl-cmake.h" #ifdef WEBKIT_FOUND #include #endif #define str_tooltip_filemanager _("Program view") #define str_tooltip_list_app _("File view") #define copyright _("Copyright © UBSoft LLC, 2022 - ") #define define_name_app _("Run as...") #define name_app_1 _("ublexec") #define website _("https://wiki.ublinux.com") #define home_page _("Project hompage") #define space_name_app _(" Run as...") #define str_about_1 _("About") #define str_help _("Help") #define read_online _("Read online") #define cancel _("Cancel") #define always_redirect _("Always redirect") #define read_documentation_web _("Would you like to read documentation in the Web?") #define redirected_documentation _("You will be redirected to documentation website where documentation is\ntranslated and supported by community.") #define str_help_h _("GTK \"Run applications as another user with the specified priority\" for ""UBLinux\n""\n""Usage: ublexec [OPTIONS...]\n""Options:\n"" -h, --help\t Show this help\n"" -V, --version\t Show package version\n"" -x APP_NAME Running the program\n"" -e FILE_NAME Running the file\n") #define str_version _("ublexec version: ") #define nice_19 _("19 (Low)") #define nice_0 _("0 (High)") #define nice__20 _("-20 (High)") #define str_close _("Close") #define str_localization_system _("System") #define str_localization_development _("Development") #define str_localization_other _("Other") #define str_localization_office _("Office") #define str_localization_education _("Education") #define str_localization_settings _("Settings") #define str_localization_multimedia _("Multimedia") #define str_localization_internet _("Internet") #define str_localization_tools _("Tools") #define str_localization_graphics _("Graphics") #define str_localization_attention _("Attention") #define str_localization_priority _("Priority") #define str_run_of_user _("Run as another user:") #define str_select_app_program _("Select an executable file or program") #define str_change_priority _("Change startup priority") #define str_run_terminal _("Run in the terminal emulator") #define str_file_overview _("File Overview") #define str_application_overview _("Application Overview") #define str_run_applications_as_another _("Run applications as another user\nwith the specified priority") #define str_localization_username _("User Name:") #define str_selecting_programs _("Selecting Programs") #define str_please_select_file _("Please select File") #define str_localization_cmd_line _("Command Line") #define str_localization_user _("User") #define str_localization_team _("Command:") #define str_run _("Run") #define const_link_doc "https://wiki.ublinux.com/ru/Программное_обеспечение/Программы_и_утилиты/Все/ublexec" #define cmd_xdg "xdg-open " #define cmd_execute "su -l %s -c \" DISPLAY=$DISPLAY %s \"" #define path_app "/usr/bin/" #define path_glade "/com/ublinux/ui/ublexec.glade" #define path_css "/com/ublinux/css/ublexec.css" #define app_name "ublexec" #define path_img_head_background "/com/ublinux/images/ublexec-banner.png" #define path_all_applications "/usr/share/applications/" #define file_source_login_min_max "/etc/login.defs" #define no_print_cmd "nohup %s > /dev/null 2>&1" using namespace std; extern string name_app_cmd; extern int socket_ext_id_I; extern int socket_trd_id_I; extern int flag_prog_file; extern string version_application; void me_thread(string cmd); class CmdArgParser : public Glib::OptionGroup { public: CmdArgParser(const std::string& p_name, const std::string& p_description, const std::string& p_help); ::Window GetSocketID() const; private: int m_socketID = 0; }; class MainWindow : public Gtk::ApplicationWindow { public: MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); MainWindow(Glib::RefPtr const& builder); ~MainWindow(); void template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_list_app); void get_builder(); void add_CSS(); void localization(); void event(); void settings(); void close_entry_app(); void start_menu_entry_app(); void message_gui_close(); void activ_or_block_execute_epriority(); void open_filemaneg(); void close_filemaneg(); void get_path_filemaneg(); void open_list_app(); string start_cmd(string user_cmd); void call_app(string &cmd); void changed_user(); void entry_app(); void execute_another_User(){} void activ_or_block_other_user(); void change_scale_priority(); void change_spin_priority(); void pars_dir_bin(); void pars_users(); void pars_apps(); void select_Graphics(); void tmp_desktop(string cmd_name); void on_item_activated(const Gtk::TreeModel::Path& path); void tempalte_row(string Name, string Exec, string path , Glib::RefPtr &dtk_list); void tempate_icon_select(Gtk::IconView *icon, Glib::RefPtr >k_list); void ok_close_entry_app(); void select_Tools(); void select_Internet(); void select_Multimedia(); void select_Settings(); void select_Education(); void select_Office(); void select_Other(); void select_Development(); void select_System(); void icon_clear(); void set_icon_array(); void delete_cmd(const int &x,const int &y); void help_show(); void denamic_cmd(); void temp_help_show(); void open_help(); void is_user_wheel(); void sudo_nice(); void template_open_browser(string link_doc); void open_browser(); 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(); unsigned short read_uid_min_max(string filename, string search); 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::Window *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 *btnhelp; 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::Image *imgHeadBackground; Gtk::Overlay *overHead; Gtk::Widget *boxAbout; Gtk::Label *lblHeaderAboutTopic; Gtk::Label *lblHeadeWndWeb; Gtk::Label *lblwebHeaderName; Gtk::Label *lblhelpText; Gtk::Label *lblhelpHeader; Gtk::CheckButton *chkAlwaysOpenHelp; Gtk::Button *btnReadHelp; Gtk::Button *btnCancelHelp; Gtk::Window *wndShowWeb; Gtk::Entry *CommandEntry; Gtk::CheckButton *CommandCheck; #ifdef WEBKIT_FOUND Gtk::Window *wndWeb; Gtk::Widget *three; WebKitWebView *my_web_kit = NULL; #endif public: string termunal_cmd[3] = {"konsole -e ", "xfce4-terminal -x ", "xterm -e "}; 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 = ""; int index_error = 0; bool flag_pkexec = false; bool flag_su = false; bool flag_sudo = false; bool flag_open_browser = false; string path_file_name; string global_lick_doc; 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{ public: Gtk::Window *window; SettingsPlug(::Window p_socketID, Glib::RefPtr builder); private: Gtk::Widget *plugBox; Gtk::Widget *parent; }; void help(); void wrapper_help_show(GtkWidget *self, char* link, gpointer user_data); void set_sensitive_from_check(Gtk::CheckButton *check, Gtk::Widget *widget);