Clementine-audio-player-Mac.../src/osd_x11.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

2010-01-08 15:52:05 +01:00
// Libnotify headers need to go before Qt ones because they use "signals" as
// a variable name
#include <libnotify/notify.h>
#include <glib.h>
#include "osd.h"
2010-01-08 17:21:22 +01:00
#include <QCoreApplication>
2010-01-08 15:52:05 +01:00
#include <QtDebug>
#include <QTextDocument>
2010-01-08 15:52:05 +01:00
void OSD::Init() {
2010-01-08 16:16:59 +01:00
notification_ = NULL;
2010-01-08 17:21:22 +01:00
notify_init(QCoreApplication::applicationName().toUtf8().constData());
2010-01-08 15:52:05 +01:00
}
2010-02-03 18:21:25 +01:00
bool OSD::CanShowNativeMessages() const {
return true;
}
void OSD::ShowMessageNative(const QString& summary, const QString& message,
const QString& icon) {
2010-01-08 15:52:05 +01:00
if (summary.isNull())
return;
2010-01-08 16:16:59 +01:00
#define STR(x) (x.isNull() ? NULL : x.toUtf8().constData())
2010-01-08 15:52:05 +01:00
2010-01-08 16:16:59 +01:00
if (notification_) {
notify_notification_update(notification_,
STR(summary), STR(Qt::escape(message)), STR(icon));
2010-01-08 16:16:59 +01:00
} else {
notification_ = notify_notification_new(
STR(summary), STR(Qt::escape(message)), STR(icon), NULL);
2010-01-08 16:16:59 +01:00
}
2010-01-08 17:21:22 +01:00
#undef STR
2010-01-08 16:16:59 +01:00
notify_notification_set_urgency(notification_, NOTIFY_URGENCY_LOW);
2010-01-08 16:37:35 +01:00
notify_notification_set_timeout(notification_, timeout_);
2010-01-08 15:52:05 +01:00
GError* error = NULL;
2010-01-08 16:16:59 +01:00
notify_notification_show(notification_, &error);
2010-01-08 15:52:05 +01:00
if (error) {
qDebug() << "Error from notify_notification_show:" << error->message;
g_error_free(error);
}
}
void OSD::ShowMessageNative(const QString& summary, const QString& message,
const QImage& image) {
qWarning() << __PRETTY_FUNCTION__ << ": NOT IMPLEMENTED";
}