53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#include "app.hpp"
|
|
|
|
#include <sigc++/sigc++.h>
|
|
#include <vector>
|
|
#include "services/dbus/notification.hpp"
|
|
#include "services/dbus/mpris.hpp"
|
|
#include "services/textureCache.hpp"
|
|
|
|
App::App() {
|
|
this->app = Gtk::Application::create("org.example.mybar");
|
|
this->setupServices();
|
|
this->hyprlandService = HyprlandService::getInstance();
|
|
this->notificationService = std::make_shared<NotificationService>();
|
|
this->mprisController = std::make_shared<MprisController>();
|
|
|
|
app->signal_activate().connect([&]() {
|
|
auto display = Gdk::Display::get_default();
|
|
auto monitors = display->get_monitors();
|
|
|
|
for (guint i = 0; i < monitors->get_n_items(); ++i) {
|
|
auto monitor = std::dynamic_pointer_cast<Gdk::Monitor>(
|
|
monitors->get_object(i)
|
|
);
|
|
|
|
if (monitor) {
|
|
auto bar = std::make_shared<Bar>(monitor->gobj());
|
|
|
|
bar->set_application(app);
|
|
bar->show();
|
|
|
|
std::string monitorName = monitor->get_connector();
|
|
bar->addLeftWidget(hyprlandService->getWorkspaceIndicatorsForMonitor(monitorName));
|
|
hyprlandService->addBar(bar, monitorName);
|
|
|
|
bars.push_back(bar);
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
app->signal_shutdown().connect([&]() {
|
|
this->trayService->stop();
|
|
});
|
|
}
|
|
|
|
void App::setupServices() {
|
|
TextureCacheService::getInstance()->pruneCache();
|
|
|
|
this->trayService->start();
|
|
}
|
|
|
|
int App::run() { return this->app->run(); }
|