~unity-2d-team/bamf-qt/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * Copyright (C) 2010 Canonical, Ltd.
 *
 * Authors:
 *  Olivier Tilloy <olivier.tilloy@canonical.com>
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; version 3.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include "bamf-plugin.h"

#include <QtDeclarative/qdeclarative.h>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>

#include "bamf-view.h"
#include "bamf-application.h"
#include "bamf-window.h"
#include "bamf-indicator.h"
#include "bamf-control.h"
#include "bamf-matcher.h"

#include "bamf-list.h"

void
BamfPlugin::registerTypes(const char *uri)
{
    const QString message("This type is not meant to be instantiated.");
    qmlRegisterUncreatableType<BamfUintList>(uri, 0, 2, "BamfUintList", message);
    qmlRegisterUncreatableType<BamfView>(uri, 0, 2, "BamfView", message);
    qmlRegisterUncreatableType<BamfViewList>(uri, 0, 2, "BamfViewList", message);
    qmlRegisterUncreatableType<BamfApplication>(uri, 0, 2, "BamfApplication", message);
    qmlRegisterUncreatableType<BamfApplicationList>(uri, 0, 2, "BamfApplicationList", message);
    qmlRegisterUncreatableType<BamfWindow>(uri, 0, 2, "BamfWindow", message);
    qmlRegisterUncreatableType<BamfIndicator>(uri, 0, 2, "BamfIndicator", message);
    qmlRegisterUncreatableType<BamfWindowList>(uri, 0, 2, "BamfWindowList", message);
    qmlRegisterUncreatableType<BamfControl>(uri, 0, 2, "BamfControl", message);
    qmlRegisterUncreatableType<BamfMatcher>(uri, 0, 2, "BamfMatcher", message);
}

void BamfPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri)
{
    BamfMatcher& matcher = BamfMatcher::get_default();
    engine->rootContext()->setContextProperty("BamfMatcher", &matcher);
}

Q_EXPORT_PLUGIN2(QtBamf, BamfPlugin);