61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <chrono>
|
|
#include <cstdint>
|
|
#include <sigc++/connection.h>
|
|
|
|
#include "gdkmm/monitor.h"
|
|
#include "gtkmm/window.h"
|
|
|
|
#define DEFAULT_NOTIFICATION_TIMEOUT 6700
|
|
|
|
class BaseNotification : public Gtk::Window {
|
|
public:
|
|
BaseNotification(uint64_t notificationId, std::shared_ptr<Gdk::Monitor> monitor);
|
|
|
|
void pauseAutoClose();
|
|
void resumeAutoClose();
|
|
void startAutoClose(int timeoutMs);
|
|
|
|
uint64_t getNotificationId() const {
|
|
return this->notificationId;
|
|
}
|
|
|
|
sigc::signal<void(uint64_t)> getSignalClose() {
|
|
return this->signalClose;
|
|
}
|
|
|
|
sigc::signal<void(bool)> getSignalHoverChanged() {
|
|
return this->signalHoverChanged;
|
|
}
|
|
|
|
private:
|
|
sigc::signal<void(uint64_t)> signalClose;
|
|
sigc::signal<void(bool)> signalHoverChanged;
|
|
|
|
uint64_t notificationId;
|
|
|
|
bool autoClosePaused = false;
|
|
int autoCloseRemainingMs = 0;
|
|
std::chrono::steady_clock::time_point autoCloseDeadline;
|
|
sigc::connection autoCloseConnection;
|
|
|
|
void ensure_notification_css_loaded();
|
|
|
|
void start_auto_close_timeout(int timeoutMs);
|
|
void pause_auto_close();
|
|
void resume_auto_close();
|
|
|
|
protected:
|
|
bool getAutoClosePaused() const {
|
|
return this->autoClosePaused;
|
|
}
|
|
|
|
int getAutoCloseRemainingMs() const {
|
|
return this->autoCloseRemainingMs;
|
|
}
|
|
|
|
std::chrono::steady_clock::time_point getAutoCloseDeadline() const {
|
|
return this->autoCloseDeadline;
|
|
}
|
|
}; |