close one notification to close all
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <string>
|
||||
#include <sys/socket.h>
|
||||
#include <vector>
|
||||
@@ -25,9 +25,9 @@ class SocketHelper {
|
||||
buffer[bytesRead] = '\0';
|
||||
data = std::string(buffer);
|
||||
} else if (bytesRead == 0) {
|
||||
std::cerr << "Socket closed by peer" << std::endl;
|
||||
spdlog::warn("Socket closed by peer");
|
||||
} else {
|
||||
std::cerr << "Error reading from socket" << std::endl;
|
||||
spdlog::error("Error reading from socket");
|
||||
}
|
||||
|
||||
auto delimiterPos = data.find(delimiter);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -49,4 +49,9 @@ class MediaControlWidget : public Gtk::Box {
|
||||
Gtk::ScrolledWindow imageWrapper;
|
||||
|
||||
void onSpotifyMprisUpdated(const MprisPlayer2Message &message);
|
||||
|
||||
void onRunningStateChanged(MprisController::PlaybackStatus status);
|
||||
void onPlay();
|
||||
void onPause();
|
||||
void onStop();
|
||||
};
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "gtkmm/window.h"
|
||||
|
||||
|
||||
#define DEFAULT_NOTIFICATION_TIMEOUT 4000
|
||||
#define DEFAULT_NOTIFICATION_TIMEOUT 7000
|
||||
|
||||
class BaseNotification : public Gtk::Window {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user