2
* Copyright (C) 2012-2013 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include <glib-object.h>
18
#include <libnotify/notify.h>
21
#include <QStringList>
23
#include "notifyqml.h"
25
Notify::Notify(QObject *parent)
34
QString Notify::appName() const
36
return (!notify_is_initted()) ? "" : QString::fromUtf8(notify_get_app_name());
39
void Notify::setAppName(const QString &appName)
41
if (!notify_is_initted()) {
42
QByteArray data = appName.toUtf8();
43
notify_init(data.data());
44
Q_EMIT appNameChanged();
46
if (appName != QString::fromUtf8(notify_get_app_name())) {
47
QByteArray data = appName.toUtf8();
48
notify_set_app_name(data.data());
49
Q_EMIT appNameChanged();
54
void Notify::notify(const QString &title, const QString &message, const QString &icon)
56
QByteArray titleData = title.toUtf8();
57
QByteArray messageData = message.toUtf8();
58
QByteArray iconData = icon.toUtf8();
59
NotifyNotification* notification = notify_notification_new(titleData.data(), messageData.data(), iconData.data());
60
notify_notification_show(notification, NULL);
61
g_object_unref(notification);