quick commit
This commit is contained in:
@@ -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"
|
||||
|
||||
24
include/connection/dbus/dbus.hpp
Normal file
24
include/connection/dbus/dbus.hpp
Normal 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.
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "gdkmm/pixbuf.h"
|
||||
#include "glibmm/variant.h"
|
||||
|
||||
|
||||
|
||||
struct MprisPlayer2Message {
|
||||
std::string title;
|
||||
std::vector<std::string> artist;
|
||||
@@ -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";
|
||||
@@ -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(
|
||||
@@ -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;
|
||||
|
||||
36
include/connection/httpConnection.hpp
Normal file
36
include/connection/httpConnection.hpp
Normal 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);
|
||||
};
|
||||
@@ -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"
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
20
include/widgets/weather.hpp
Normal file
20
include/widgets/weather.hpp
Normal 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 ¤t_text,
|
||||
const std::string &today_text);
|
||||
};
|
||||
Reference in New Issue
Block a user