dein bruder
This commit is contained in:
47
src/app.cpp
Normal file
47
src/app.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "app.hpp"
|
||||
|
||||
#include <sigc++/sigc++.h>
|
||||
|
||||
App::App() {
|
||||
this->setupServices();
|
||||
|
||||
this->app = Gtk::Application::create("org.example.mybar");
|
||||
|
||||
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 hyprlanMonitor = this->hyprlandService.getMonitorById(i);
|
||||
|
||||
auto bar = new Bar(monitor->gobj(), hyprlanMonitor);
|
||||
this->hyprlandService.printMonitor(*hyprlanMonitor); // Debugging output
|
||||
|
||||
bar->set_application(app);
|
||||
bar->show();
|
||||
bars.push_back(bar);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app->signal_shutdown().connect([&]() {
|
||||
for (auto bar : bars) {
|
||||
delete bar;
|
||||
}
|
||||
bars.clear();
|
||||
});
|
||||
}
|
||||
|
||||
void App::setupServices() {
|
||||
this->hyprlandService.socketEventSignal.connect(sigc::mem_fun(
|
||||
this->hyprlandService, &HyprlandService::on_hyprland_event));
|
||||
|
||||
this->hyprlandService.start();
|
||||
}
|
||||
|
||||
int App::run() {
|
||||
return this->app->run();
|
||||
}
|
||||
Reference in New Issue
Block a user