Commit 57335315 authored by Vladislav's avatar Vladislav

optimization

parent f33b8c68
......@@ -19,17 +19,20 @@ int main() {
w.text_ = _("TASKMGR");
trays::Menu e;
e.text_ = _("CHANGELOG");
trays::Menu r;
r.text_ = _("FORCE EXIT");
// linux: png, svg
std::string icon_name = "portproton_tray.svg";
// 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 &"); };
w.on_click_ = [](auto) { system("bash -c pw_tray_taskmgr &"); };
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();
}
......@@ -16,7 +16,6 @@ class Tray {
public:
Tray(std::string icon_path, std::vector<Menu> menus = {});
void run();
void add(Menu menu);
private:
......
......@@ -3,23 +3,12 @@
#include <libintl.h>
#include <locale.h>
#define _(STRING) gettext(STRING)
trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
: icon_(icon_path) {
for (auto m : menus) {
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_init(&tray_);
......@@ -36,9 +25,7 @@ trays::Tray::Tray(std::string icon_path, std::vector<Menu> menus)
// you can throw away anythings others.
}
void trays::Tray::run() {
while (!tray_loop(1)) {
;
}
while (!tray_loop(1)) {}
}
void trays::Tray::add(Menu menu) {
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