quick commit

This commit is contained in:
2026-02-04 15:52:31 +01:00
parent 0463c37543
commit ce0643b6ac
26 changed files with 929 additions and 45 deletions

View File

@@ -4,7 +4,8 @@
#include "bar/bar.hpp"
#include "services/hyprland.hpp"
#include "services/dbus/notification.hpp"
#include "connection/dbus/notification.hpp"
#include "connection/dbus/tray.hpp"
#include "glibmm/refptr.h"
#include "gtkmm/application.h"

View File

@@ -0,0 +1,24 @@
#pragma once
#include <giomm.h>
#include <sigc++/sigc++.h>
class DbusConnection {
public:
virtual ~DbusConnection() = default;
protected:
Glib::RefPtr<Gio::DBus::Connection> connection;
void connect_session_async(const sigc::slot<void(const Glib::RefPtr<Gio::AsyncResult> &)> &callback) {
Gio::DBus::Connection::get(Gio::DBus::BusType::SESSION, callback);
}
static void ensure_gio_init() {
try {
Gio::init();
} catch (const Glib::Error &) {
// Already initialized.
}
}
};

View File

@@ -10,8 +10,6 @@
#include "gdkmm/pixbuf.h"
#include "glibmm/variant.h"
struct MprisPlayer2Message {
std::string title;
std::vector<std::string> artist;

View File

@@ -5,9 +5,10 @@
#include <sigc++/sigc++.h>
#include <set>
#include <vector>
#include "services/dbus/messages.hpp"
#include "connection/dbus/dbus.hpp"
#include "connection/dbus/messages.hpp"
class MprisController {
class MprisController : public DbusConnection {
public:
struct PlayerState {
std::string title;
@@ -51,7 +52,6 @@ class MprisController {
PlaybackStatus currentPlaybackStatus = PlaybackStatus::Stopped;
Glib::RefPtr<Gio::DBus::Connection> m_connection;
Glib::RefPtr<Gio::DBus::Proxy> m_proxy;
Glib::RefPtr<Gio::DBus::Proxy> m_dbus_proxy;
std::string m_player_bus_name = "org.mpris.MediaPlayer2.spotify";

View File

@@ -5,6 +5,7 @@
#include <gtkmm.h>
#include <sigc++/sigc++.h>
#include "connection/dbus/dbus.hpp"
#include "giomm/dbusconnection.h"
#include "giomm/dbusownname.h"
#include "glib.h"
@@ -39,7 +40,7 @@ const Glib::ustring introspection_xml = R"(
</node>
)";
class NotificationService {
class NotificationService : public DbusConnection {
public:
NotificationService() : notificationIdCounter(1) {
Gio::DBus::own_name(

View File

@@ -15,7 +15,9 @@
#include <string>
#include <vector>
class TrayService {
#include "connection/dbus/dbus.hpp"
class TrayService : public DbusConnection {
inline static TrayService *instance = nullptr;
public:
struct Item {
@@ -85,7 +87,6 @@ class TrayService {
bool addSignalPending = false;
};
Glib::RefPtr<Gio::DBus::Connection> connection;
Glib::RefPtr<Gio::DBus::NodeInfo> nodeInfo;
Gio::DBus::InterfaceVTable vtable;

View File

@@ -0,0 +1,36 @@
#pragma once
#include <map>
#include <string>
struct HttpResponse {
long status_code = 0;
std::string body;
std::map<std::string, std::string> headers;
std::string error;
bool ok() const {
return error.empty();
}
};
class HttpConnection {
public:
static HttpResponse get(const std::string &url,
const std::map<std::string, std::string> &headers = {},
long timeout_ms = 0);
static HttpResponse post(const std::string &url,
const std::string &body,
const std::map<std::string, std::string> &headers = {},
const std::string &content_type = "application/json",
long timeout_ms = 0);
private:
static HttpResponse performRequest(const std::string &method,
const std::string &url,
const std::string &body,
const std::map<std::string, std::string> &headers,
const std::string &content_type,
long timeout_ms);
};

View File

@@ -6,7 +6,7 @@
#include <sys/types.h>
#include <vector>
#include "services/dbus/messages.hpp"
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
#include "gdkmm/monitor.h"

View File

@@ -6,6 +6,7 @@
#include "gtkmm/label.h"
#include "gtkmm/stack.h"
#include "widgets/controlCenter/mediaControl.hpp"
#include "widgets/weather.hpp"
#include <unordered_map>
@@ -18,7 +19,7 @@ class ControlCenter : public Popover {
Gtk::Box tabRow;
Gtk::Stack contentStack;
Gtk::Box controlCenterContainer;
Gtk::Label testLabel;
WeatherWidget weatherWidget;
Gtk::Button mediaControl;
Gtk::Button testTabButton;
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();

View File

@@ -7,7 +7,7 @@
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "services/dbus/mpris.hpp"
#include "connection/dbus/mpris.hpp"
class MediaControlWidget : public Gtk::Box {
public:

View File

@@ -2,7 +2,7 @@
#include <spdlog/spdlog.h>
#include "services/dbus/messages.hpp"
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
#include "gtkmm/box.h"

View File

@@ -2,7 +2,7 @@
#pragma once
#include <cstdint>
#include "services/dbus/messages.hpp"
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
class NotificationWindow : public BaseNotification {

View File

@@ -3,7 +3,7 @@
#include <cstdint>
#include <memory>
#include "services/dbus/messages.hpp"
#include "connection/dbus/messages.hpp"
#include "widgets/notification/baseNotification.hpp"
#include "gtkmm/centerbox.h"

View File

@@ -17,7 +17,7 @@
#include <string>
#include <vector>
#include "services/tray.hpp"
#include "connection/dbus/tray.hpp"
#include "components/base/button.hpp"
class TrayIconWidget : public Button {

View File

@@ -0,0 +1,20 @@
#pragma once
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <sigc++/sigc++.h>
class WeatherWidget : public Gtk::Box {
public:
WeatherWidget();
private:
Gtk::Label titleLabel;
Gtk::Label currentLabel;
Gtk::Label todayLabel;
bool onRefreshTick();
void fetchWeather();
void applyWeatherText(const std::string &current_text,
const std::string &today_text);
};