Commit 57335315 authored by Vladislav's avatar Vladislav

optimization

parent f33b8c68
...@@ -19,17 +19,20 @@ int main() { ...@@ -19,17 +19,20 @@ int main() {
w.text_ = _("TASKMGR"); w.text_ = _("TASKMGR");
trays::Menu e; trays::Menu e;
e.text_ = _("CHANGELOG"); e.text_ = _("CHANGELOG");
trays::Menu r;
r.text_ = _("FORCE EXIT");
// linux: png, svg // linux: png, svg
std::string icon_name = "portproton_tray.svg"; std::string icon_name = "portproton_tray.svg";
// absolute path for linux. // absolute path for linux.
auto icon_path =std::filesystem::current_path() / icon_name; auto icon_path = std::filesystem::current_path() / icon_name;
q.on_click_ = [](auto) { system("bash -c pw_tray_winefile &"); }; q.on_click_ = [](auto) { system("bash -c pw_tray_winefile &"); };
w.on_click_ = [](auto) { system("bash -c pw_tray_taskmgr &"); }; w.on_click_ = [](auto) { system("bash -c pw_tray_taskmgr &"); };
e.on_click_ = [](auto) { system("bash -c open_changelog &"); }; e.on_click_ = [](auto) { system("bash -c open_changelog &"); };
r.on_click_ = [](auto) { system("bash -c tray_icon_click_exit"); tray_exit(); };
trays::Tray t{icon_path.string(), {q,w,e}}; trays::Tray t{icon_path.string(), {q,w,e,r}};
t.run(); t.run();
} }
...@@ -16,7 +16,6 @@ class Tray { ...@@ -16,7 +16,6 @@ class Tray {
public: public:
Tray(std::string icon_path, std::vector<Menu> menus = {}); Tray(std::string icon_path, std::vector<Menu> menus = {});
void run(); void run();
void add(Menu menu); void add(Menu menu);
private: private:
......
...@@ -3,23 +3,12 @@ ...@@ -3,23 +3,12 @@
#include <libintl.h> #include <libintl.h>
#include <locale.h> #include <locale.h>
#define _(STRING) gettext(STRING)
trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus) trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
: icon_(icon_path) { : icon_(icon_path) {
for (auto m : menus) { for (auto m : menus) {
add(m); add(m);
} }
setlocale (LC_ALL, "");
bindtextdomain ("tray", getenv("PWD"));
textdomain ("tray");
Menu exit;
exit.on_click_ = [](Menu *) { system("bash -c tray_icon_click_exit"); tray_exit(); };
exit.text_ = _("FORCE EXIT");
add(exit);
tray_.icon = &icon_path[0]; tray_.icon = &icon_path[0];
tray_init(&tray_); tray_init(&tray_);
...@@ -36,9 +25,7 @@ trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus) ...@@ -36,9 +25,7 @@ trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
// you can throw away anythings others. // you can throw away anythings others.
} }
void trays::Tray::run() { void trays::Tray::run() {
while (!tray_loop(1)) { while (!tray_loop(1)) {}
;
}
} }
void trays::Tray::add(Menu menu) { void trays::Tray::add(Menu menu) {
if (!raw_menus_.empty()) { if (!raw_menus_.empty()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment