diff --git a/source/main.cc b/source/main.cc index 0f9293c..91c417f 100644 --- a/source/main.cc +++ b/source/main.cc @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -24,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/source/ublexec.cc b/source/ublexec.cc index 09e7732..6127199 100644 --- a/source/ublexec.cc +++ b/source/ublexec.cc @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -98,6 +97,37 @@ void MainWindow::get_builder(){ builder->get_widget("lblInfoPriority", lblInfoPriority); builder->get_widget("lblInfoPriority", lblInfoEnterProg); 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("lblSystem", lblSystem); + 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("liststoreGraphics", liststoreGraphics); + builder->get_widget("liststoreTools", liststoreTools); + builder->get_widget("liststoreInternet", liststoreInternet); + builder->get_widget("liststoreMultimedia", liststoreMultimedia); + builder->get_widget("liststoreSettings", liststoreSettings); + builder->get_widget("liststoreEducation", liststoreEducation); + builder->get_widget("liststoreOffice", liststoreOffice); + builder->get_widget("liststoreOther", liststoreOther); + builder->get_widget("liststoreDevelopment", liststoreDevelopment); + builder->get_widget("liststoreSystem", liststoreSystem); } void MainWindow::add_CSS(){ @@ -127,7 +157,16 @@ void MainWindow::localization(){ lblInfoPriority->set_text(gettext("Priority:")); lblMessageError->set_text(gettext("Select an executable file or program")); lblInfoEnterProg->set_text(gettext("Selecting Programs")); - + lblGraphics->set_text(gettext("Graphics")); + lblTools->set_text(gettext("Tools")); + lblInternet->set_text(gettext("Internet")); + lblMultimedia->set_text(gettext("Multimedia")); + lblSettings->set_text(gettext("Settings")); + lblEducation->set_text(gettext("Education")); + lblOffice->set_text(gettext("Office")); + lblOther->set_text(gettext("Other")); + lblDevelopment->set_text(gettext("Development")); + lblSystem->set_text(gettext("System")); } void MainWindow::event(){ @@ -196,13 +235,54 @@ void MainWindow::get_path_filemaneg(){ } } void MainWindow::open_list_app(){ + //liststoreDevelopment = iconDevelopment->get_model(); + /* + for ( const auto &str_app : list_app){ + for ( const auto &str_categor : str_app.Categories){ + if (str_categor=="Graphics"){ + + } + else if (str_categor=="Tools"){ + + } + else if (str_categor=="Internet"){ + + } + else if (str_categor=="Multimedia"){ + + } + else if (str_categor=="Settings"){ + + } + else if (str_categor=="Education"){ + + } + else if (str_categor=="Office"){ + + } + else if (str_categor=="Other"){ + + } + else if (str_categor=="Development"){ + cout << str_categor << endl; + } + else if (str_categor=="System"){ + + } + + } + } for (const auto & str_categor : set_categories){ Gtk::Label* Label1 = new Gtk::Label(str_categor); Gtk::IconView* icon = new Gtk::IconView(); boxlistProgramm->pack_start(*icon); boxlistProgramm->pack_start(*Label1); - dialogStartMenu->show_all(); + } + + */ + dialogStartMenu->show_all(); + } void MainWindow::start_cmd(){ //txtCmd->set_text(""); @@ -284,7 +364,6 @@ void MainWindow::start_cmd(){ } string cmd = ""; cmd = "" + str_cmd_terminal + str_variants_root + str_nice_cmd + user_cmd + " &"; - cout << cmd << endl; txtCmd->set_text(cmd); system(cmd.c_str()); @@ -370,73 +449,55 @@ void MainWindow::pars_users(){ 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); + // elems.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson) + } + return elems; +} + void MainWindow::pars_apps(){ + if (list_app.size()!=0){return;} namespace fs = std::filesystem; - string file_name=""; - std::string line; - int index_equals = 0; - string key = ""; - string value = ""; - for (const auto & entry : fs::directory_iterator("/usr/share/applications/")){ + struct struct_App App; + string file_name = ""; + string str_Categories; + string path = "/usr/share/applications/"; + 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){ - std::ifstream in(entry.path()); - if (in.is_open()){ - while (getline(in, line)){ - index_equals=line.find("="); - if (index_equals!=std::string::npos){ - key = line.substr(0, index_equals); - value = line.substr(index_equals+1,line.length()); - struct_App App; - if (key=="Name"){ - App.Name = value; - } - else if (key=="Type"){ - App.Type = value; - } - else if (key=="Exec"){ - App.Exec = value; - } - else if (key=="Icon"){ - App.Icon = value; - } - else if (key=="Icon"){ - App.Icon = value; - } - else if (key=="MimeType"){ - App.Icon = value; - } - else if (key=="Categories"){ - App.Categories = value; - string substr1 = ";"; - int index=0; - int old_index=0; - while ((index = value.find(substr1, index)) != std::string::npos) { - if ((value.length()-1)!=index){ - string s = value.substr(old_index, index); - if (s.find(";") != std::string::npos){ - s=s.replace(0,s.length(), ";"); - set_categories.insert(s); - } - else{ - if (value.substr(old_index, index).find(";") == std::string::npos){ - set_categories.insert(value.substr(old_index, index)); - } - } - } - if ((value.length()-1)==index){ - if (value.substr(old_index, index).find(";") == std::string::npos){ - set_categories.insert(value.substr(index,value.length())); - } - } - old_index=index; - index += substr1.length(); - } - } - } - } + 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); + 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 = Name; + App.Name_desktop = file_name; + App.Categories = split(str_Categories, ';'); + for ( const auto &text : App.Categories){ + set_categories.insert(text); + } + } + list_app.push_back(App); } } SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr builder) @@ -452,3 +513,4 @@ SettingsPlug::SettingsPlug(::Window p_socketID, Glib::RefPtr build + diff --git a/source/ublexec.h b/source/ublexec.h index 49b9dec..7d05c8b 100644 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -85,6 +85,7 @@ public: void pars_dir_bin(); void pars_users(); void pars_apps(); + vector split(const std::string &s, char delim); public: Glib::RefPtr builder; @@ -115,6 +116,7 @@ public: Gtk::Button *btnStartMenuExit; Gtk::Box *boxlistProgramm; Gtk::Dialog *dialogStartMenu; + Gtk::Box *boxColor; Gtk::Label *lblInfoHead; Gtk::Label *lblinfoCmd; Gtk::Label *lblInfoTime; @@ -126,7 +128,40 @@ public: Gtk::Label *lblInfoExec; Gtk::Label *lblInfoPriority; Gtk::Label *lblInfoEnterProg; - Gtk::Box *boxColor; + + 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::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::ListStore *liststoreGraphics; + Gtk::ListStore *liststoreTools; + Gtk::ListStore *liststoreInternet; + Gtk::ListStore *liststoreMultimedia; + Gtk::ListStore *liststoreSettings; + Gtk::ListStore *liststoreEducation; + Gtk::ListStore *liststoreOffice; + Gtk::ListStore *liststoreOther; + Gtk::ListStore *liststoreDevelopment; + Gtk::ListStore *liststoreSystem; + @@ -137,12 +172,14 @@ public: bool flag_sudo = false; string path_file_name; struct struct_App{ + string Name_desktop; string Name; string Exec; string Icon; string MimeType; string Type; - string Categories;}; + vector Categories; + }; list list_app; set set_categories; diff --git a/ublexec.glade b/ublexec.glade index 768ed98..36549df 100644 --- a/ublexec.glade +++ b/ublexec.glade @@ -8,107 +8,6 @@ 1 10 - - False - Внимание! - dialog - - - False - vertical - 2 - - - False - end - - - ОК - True - True - True - - - True - True - 0 - - - - - Выход - True - True - True - - - True - True - 1 - - - - - False - False - 0 - - - - - True - False - vertical - - - True - False - Выбор программ - - - False - True - 0 - - - - - True - True - in - - - True - False - - - True - False - vertical - - - - - - - - - - True - True - 1 - - - - - True - True - 1 - - - - - True False @@ -914,6 +813,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 250 + 470 + False + dialog + + + False + vertical + 2 + + + False + end + + + ОК + True + True + True + + + True + True + 0 + + + + + Выход + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + vertical + + + True + False + Выбор программ + + + False + True + 0 + + + + + True + True + in + + + True + False + + + True + False + vertical + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Графика + + + False + True + 0 + + + + + True + True + 6 + horizontal + liststoreGraphics + + + False + True + 1 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Инструменты + + + False + True + 2 + + + + + True + True + 6 + horizontal + liststoreTools + + + False + True + 3 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Интернет + + + False + True + 4 + + + + + True + True + 6 + horizontal + liststoreInternet + + + False + True + 5 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Мультимедиа + + + False + True + 6 + + + + + True + True + 6 + horizontal + liststoreMultimedia + + + False + True + 7 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Настройки + + + False + True + 8 + + + + + True + True + 6 + horizontal + liststoreSettings + + + False + True + 9 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Образование + + + False + True + 10 + + + + + True + True + 6 + horizontal + liststoreEducation + + + False + True + 11 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Офис + + + False + True + 12 + + + + + True + True + 6 + horizontal + liststoreOffice + + + False + True + 13 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Прочие + + + False + True + 14 + + + + + True + True + 6 + horizontal + liststoreOther + + + False + True + 15 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Разработка + + + False + True + 16 + + + + + True + True + 6 + horizontal + liststoreDevelopment + + + False + True + 17 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Система + + + False + True + 18 + + + + + True + True + 6 + horizontal + liststoreSystem + + + False + True + 19 + + + + + + + + + True + True + 1 + + + + + True + True + 1 + + + + + False Внимание! diff --git a/ublexec_ru.po b/ublexec_ru.po index e395e0c..051caa7 100644 --- a/ublexec_ru.po +++ b/ublexec_ru.po @@ -6,6 +6,36 @@ msgid "" 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 "ОК"