diff --git a/source/ublexec.cc b/source/ublexec.cc index 4bc505a..3e6b702 100644 --- a/source/ublexec.cc +++ b/source/ublexec.cc @@ -50,12 +50,16 @@ CmdArgParser::CmdArgParser(const std::string& p_name, const std::string& p_descr } 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("btnFilemaneg", btnFilemaneg); builder->get_widget("btnListApp", btnListApp); @@ -107,22 +111,47 @@ void MainWindow::get_builder(){ 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); - - + 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); + + /* list_Graphics = Gtk::ListStore::create( m_Columns ); list_Graphics->set_sort_column( m_Columns.m_col_description, Gtk::SORT_ASCENDING ); - iconGraphics->set_model(list_Graphics); iconGraphics->set_markup_column(m_Columns.m_col_description); iconGraphics->set_pixbuf_column(m_Columns.m_col_pixbuf); - + */ +} +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_markup_column(m_Columns.m_col_description); + icon->set_pixbuf_column(m_Columns.m_col_pixbuf); } + void MainWindow::add_CSS(){ Glib::RefPtr cssProvider = Gtk::CssProvider::create(); cssProvider->load_from_path(path_css); @@ -179,10 +208,17 @@ void MainWindow::event(){ 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_start_menu)); + iconGraphics->signal_item_activated().connect(sigc::mem_fun(*this,&MainWindow::on_item_activated) ); + +} + +void MainWindow::on_item_activated(const Gtk::TreeModel::Path& path){ + } + void MainWindow::settings(){ this->pars_apps(); - this->builder = builder; + this->get_builder(); this->event(); this->localization(); @@ -238,6 +274,23 @@ void MainWindow::get_path_filemaneg(){ this->close_filemaneg(); } } + +void MainWindow::tempalte_row(string name, string path, Glib::RefPtr &dtk_list){ + Gtk::TreeModel::Row row = *(dtk_list->append()); + row[m_Columns.m_col_filename] = path; + row[m_Columns.m_col_description] = name; + if (std::ifstream(path)){ + row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path); + } + else{ + path = "/usr/share/icons/Faenza/emblems/32/emblem-danger.png"; + row[m_Columns.m_col_pixbuf] = Gdk::Pixbuf::create_from_file(path); + } + + + +} + void MainWindow::open_list_app(){ @@ -245,38 +298,37 @@ void MainWindow::open_list_app(){ string path = ""; for ( const auto &str_app : list_app){ for ( const auto &str_categor : str_app.Categories){ - path = "/usr/share/applications/" + str_app.Icon + ".svg"; + path = "/usr/share/icons/hicolor/32x32/apps/" + str_app.Icon + ".png"; + cout << str_categor << endl; if (str_categor=="Graphics"){ - Gtk::TreeModel::Row row = *(list_Graphics->append()); - row[m_Columns.m_col_filename] = path; - row[m_Columns.m_col_description] = str_app.Name; + this->tempalte_row(str_app.Name, path, list_Graphics); } - else if (str_categor=="Tools"){ - + else if (str_categor=="Utility"){ + this->tempalte_row(str_app.Name, path, list_Tools); } - else if (str_categor=="Internet"){ - + else if (str_categor=="Network"){ + this->tempalte_row(str_app.Name, path, list_Internet); } - else if (str_categor=="Multimedia"){ - + else if (str_categor=="Multimedia" || str_categor== "Video" || str_categor== "Player" || str_categor== "AudioVideo"){ + this->tempalte_row(str_app.Name, path, list_Multimedia); } else if (str_categor=="Settings"){ - + this->tempalte_row(str_app.Name, path, list_Settings); } else if (str_categor=="Education"){ - + this->tempalte_row(str_app.Name, path, list_Education); } else if (str_categor=="Office"){ - + this->tempalte_row(str_app.Name, path, list_Office); } else if (str_categor=="Other"){ - + this->tempalte_row(str_app.Name, path, list_Other); } else if (str_categor=="Development"){ - cout << str_categor << endl; + this->tempalte_row(str_app.Name, path, list_Development); } else if (str_categor=="System"){ - + this->tempalte_row(str_app.Name, path, list_System); } } @@ -284,17 +336,7 @@ void MainWindow::open_list_app(){ dialogStartMenu->show_all(); } -/* -void MainWindow::tmp_desktop(string cmd_name){ - string desktop = ""; - desktop = "[Desktop Entry]\nEncoding=UTF-8\nName=test\nName[ru]=тест\nGenericName=test\nGenericName[ru]=тест\nComment=test\nComment[ru]=test\nType=Application\nExec=pkexec "+cmd_name + - "\nIcon=ublexec\nTerminal=false\nCategories=XFCE;GTK;Settings;DesktopSettings;X-XFCE-SettingsDialog;X-XFCE-SystemSettings;"; - string cmd = ""; - cmd = "touch /tmp/" + cmd_name + ".desktop; echo \"" + desktop + "\" > /tmp/"+cmd_name+".desktop; chmod +x /tmp/"+cmd_name+".desktop"; - cout << cmd << endl; - system(cmd.c_str()); -} -*/ + void MainWindow::start_cmd(){ //txtCmd->set_text(""); @@ -503,10 +545,9 @@ void MainWindow::pars_apps(){ App.Name = Name; App.Type = Type; App.Exec = Exec; - App.Icon = Name; + App.Icon = Icon; if (Mime!=NULL){ App.MimeType = Mime; - cout << App.MimeType << endl; } else{ App.MimeType = ""; diff --git a/source/ublexec.h b/source/ublexec.h index f631439..399867d 100644 --- a/source/ublexec.h +++ b/source/ublexec.h @@ -62,6 +62,7 @@ class MainWindow : public Gtk::ApplicationWindow { public: MainWindow(BaseObjectType* obj, Glib::RefPtr const& builder); MainWindow(Glib::RefPtr const& builder); + void template_apps_obj(Gtk::IconView *icon, Glib::RefPtr >k_list_app); void get_builder(); void add_CSS(); void localization(); @@ -86,6 +87,9 @@ public: void pars_users(); void pars_apps(); void tmp_desktop(string cmd_name); + void on_item_activated(const Gtk::TreeModel::Path& path); + void tempalte_row(string name, string path, Glib::RefPtr &dtk_list); + vector split(const std::string &s, char delim); public: @@ -134,7 +138,7 @@ public: Gtk::Button *btnStartMenuOK; Gtk::Button *btnStartMenuExit; Gtk::Box *boxlistProgramm; - Gtk::Dialog *dialogStartMenu; + Gtk::Window *dialogStartMenu; Gtk::Box *boxColor; Gtk::Label *lblInfoHead; Gtk::Label *lblinfoCmd; @@ -158,10 +162,28 @@ public: Gtk::Label *lblOther; Gtk::Label *lblDevelopment; Gtk::Label *lblSystem; - Gtk::IconView *iconGraphics; + 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; 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; diff --git a/ublexec.glade b/ublexec.glade index 5da0d4d..6cdc251 100644 --- a/ublexec.glade +++ b/ublexec.glade @@ -8,426 +8,417 @@ 1 10 - - 250 - 250 + False - dialog - + + True False vertical - 2 - - + + + True False - end - - - ОК - True - True - True - - - True - True - 0 - - + Выбор программ + + + False + True + 0 + + + + + True + True + in - - Выход + True - True - True + False + + + True + False + vertical + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Графика + + + False + True + 0 + + + + + True + True + 6 + 75 + 1 + 1 + True + + + False + True + 1 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Инструменты + + + False + True + 2 + + + + + True + True + 1 + 1 + 1 + + + False + True + 3 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Интернет + + + False + True + 4 + + + + + True + True + 1 + 1 + 1 + + + False + True + 5 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Мультимедиа + + + False + True + 6 + + + + + True + True + 1 + 1 + 1 + + + False + True + 7 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Настройки + + + False + True + 8 + + + + + True + True + 1 + 1 + 1 + + + False + True + 9 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Образование + + + False + True + 10 + + + + + True + True + 1 + 1 + 1 + + + False + True + 11 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Офис + + + False + True + 12 + + + + + True + True + 1 + 1 + 1 + + + False + True + 13 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Прочие + + + False + True + 14 + + + + + True + True + 1 + 1 + 1 + + + False + True + 15 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Разработка + + + False + True + 16 + + + + + True + True + 1 + 1 + 1 + + + False + True + 17 + + + + + True + False + start + center + 5 + 5 + 5 + 5 + 6 + 6 + Система + + + False + True + 18 + + + + + True + True + 1 + 1 + 1 + + + False + True + 19 + + + + - - True - True - 1 - - False - False - 0 + True + True + 1 - + True False - vertical + end + start - + + ОК True - False - Выбор программ + True + True - False + True 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 - - - False - True - 1 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Инструменты - - - False - True - 2 - - - - - True - True - - - - - - False - True - 3 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Интернет - - - False - True - 4 - - - - - True - True - - - - - - False - True - 5 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Мультимедиа - - - False - True - 6 - - - - - True - True - - - - - - False - True - 7 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Настройки - - - False - True - 8 - - - - - True - True - - - - - - False - True - 9 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Образование - - - False - True - 10 - - - - - True - True - - - - - - False - True - 11 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Офис - - - False - True - 12 - - - - - True - True - - - - - - False - True - 13 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Прочие - - - False - True - 14 - - - - - True - True - - - - - - False - True - 15 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Разработка - - - False - True - 16 - - - - - True - True - - - - - - False - True - 17 - - - - - True - False - start - center - 5 - 5 - 5 - 5 - 6 - 6 - Система - - - False - True - 18 - - - - - True - True - - - - - - False - True - 19 - - - - - - + True True @@ -437,9 +428,9 @@ - True + False True - 1 + 2 @@ -1218,86 +1209,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False Внимание!