~artmello/ubuntu-ui-extras/ubuntu-ui-extras-fix_1524973

« back to all changes in this revision

Viewing changes to modules/Ubuntu/Components/Extras/plugin/share/notifyqml.cpp

  • Committer: CI Train Bot
  • Author(s): Ugo Riboni
  • Date: 2015-02-04 20:33:44 UTC
  • mfrom: (65.1.46 ubuntu-ui-extras-photo-editor)
  • Revision ID: ci-train-bot@canonical.com-20150204203344-pfmu1ckhooy7oaca
Add a photo editor component, partially based on the Gallery photo editor Fixes: #1368787
Approved by: PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2012-2013 Canonical, Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 */
16
 
 
17
 
#include <glib-object.h>
18
 
#include <libnotify/notify.h>
19
 
 
20
 
#include <QProcess>
21
 
#include <QStringList>
22
 
 
23
 
#include "notifyqml.h"
24
 
 
25
 
Notify::Notify(QObject *parent)
26
 
{
27
 
}
28
 
 
29
 
Notify::~Notify()
30
 
{
31
 
    notify_uninit();
32
 
}
33
 
 
34
 
QString Notify::appName() const
35
 
{
36
 
    return (!notify_is_initted()) ? "" : QString::fromUtf8(notify_get_app_name());
37
 
}
38
 
 
39
 
void Notify::setAppName(const QString &appName)
40
 
{
41
 
    if (!notify_is_initted()) {
42
 
        QByteArray data = appName.toUtf8();
43
 
        notify_init(data.data());
44
 
        Q_EMIT appNameChanged();
45
 
    } else {
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();
50
 
        }
51
 
    }
52
 
}
53
 
 
54
 
void Notify::notify(const QString &title, const QString &message, const QString &icon)
55
 
{
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);
62
 
}