close one notification to close all
This commit is contained in:
@@ -6,13 +6,14 @@
|
||||
#include <map>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
#include "gdkmm/pixbuf.h"
|
||||
#include "glibmm/variant.h"
|
||||
|
||||
|
||||
|
||||
struct MprisPlayer2Message {
|
||||
std::string title;
|
||||
std::string artist;
|
||||
std::vector<std::string> artist;
|
||||
std::string artwork_url;
|
||||
int64_t length_ms;
|
||||
|
||||
@@ -21,6 +22,12 @@ struct MprisPlayer2Message {
|
||||
std::function<void()> previous;
|
||||
};
|
||||
|
||||
enum NotificationUrgency {
|
||||
LOW = 0,
|
||||
NORMAL = 1,
|
||||
CRITICAL = 2
|
||||
};
|
||||
|
||||
struct NotifyMessage {
|
||||
std::string app_name;
|
||||
uint32_t replaces_id;
|
||||
@@ -28,8 +35,10 @@ struct NotifyMessage {
|
||||
std::string summary;
|
||||
std::string body;
|
||||
std::vector<std::string> actions;
|
||||
std::map<std::string, Glib::VariantBase> hints;
|
||||
NotificationUrgency urgency = NORMAL;
|
||||
int32_t expire_timeout;
|
||||
// Callback to invoke when an action is triggered
|
||||
std::function<void(const std::string& action_id)> on_action;
|
||||
// image data (if any) from dbus
|
||||
std::optional<Glib::RefPtr<Gdk::Pixbuf>> imageData;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <giomm.h>
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <vector>
|
||||
@@ -7,6 +8,18 @@
|
||||
|
||||
class MprisController {
|
||||
public:
|
||||
struct PlayerState {
|
||||
std::string title;
|
||||
std::vector<std::string> artist;
|
||||
std::string artwork_url;
|
||||
int64_t length_ms;
|
||||
};
|
||||
enum class PlaybackStatus {
|
||||
Playing,
|
||||
Paused,
|
||||
Stopped,
|
||||
};
|
||||
|
||||
static std::shared_ptr<MprisController> getInstance();
|
||||
|
||||
void toggle_play();
|
||||
@@ -15,15 +28,25 @@ class MprisController {
|
||||
void emit_seeked(int64_t position_us);
|
||||
|
||||
sigc::signal<void(const MprisPlayer2Message &)> &signal_mpris_updated();
|
||||
sigc::signal<void(PlaybackStatus)> &signal_playback_status_changed();
|
||||
sigc::signal<void(int64_t)> &signal_playback_position_changed();
|
||||
|
||||
private:
|
||||
MprisController();
|
||||
std::map<std::string, PlaybackStatus> playbackStatusMap = {
|
||||
{"Playing", PlaybackStatus::Playing},
|
||||
{"Paused", PlaybackStatus::Paused},
|
||||
{"Stopped", PlaybackStatus::Stopped},
|
||||
};
|
||||
|
||||
bool playerRunning = false;
|
||||
PlaybackStatus currentPlaybackStatus = PlaybackStatus::Stopped;
|
||||
|
||||
Glib::RefPtr<Gio::DBus::Connection> m_connection;
|
||||
Glib::RefPtr<Gio::DBus::Proxy> m_proxy;
|
||||
|
||||
sigc::signal<void(const MprisPlayer2Message &)> mprisUpdatedSignal;
|
||||
sigc::signal<void(PlaybackStatus)> playbackStatusChangedSignal;
|
||||
sigc::signal<void(int64_t)> playbackPositionChangedSignal;
|
||||
|
||||
void on_bus_connected(const Glib::RefPtr<Gio::AsyncResult> &result);
|
||||
void signalNotification();
|
||||
|
||||
Reference in New Issue
Block a user