~sil2100/unity-2d/precise-security

« back to all changes in this revision

Viewing changes to launcher/app/launcher.cpp

  • Committer: Aurelien Gateau
  • Date: 2010-11-10 08:57:29 UTC
  • mto: This revision was merged to the branch mainline in revision 284.
  • Revision ID: aurelien.gateau@canonical.com-20101110085729-fl1ye7impkqhm0w6
Added a section about const correct-ness

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Canonical, Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *  Olivier Tilloy <olivier.tilloy@canonical.com>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; version 3.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <gtk/gtk.h>
 
21
#include <QApplication>
 
22
#include <QDesktopWidget>
 
23
#include <QDeclarativeEngine>
 
24
#include <QDeclarativeContext>
 
25
 
 
26
#include "config.h"
 
27
#include "launcherview.h"
 
28
 
 
29
int main(int argc, char *argv[])
 
30
{
 
31
    /* UnityApplications plugin uses GTK APIs to retrieve theme icons
 
32
       (gtk_icon_theme_get_default) and requires a call to gtk_init */
 
33
    gtk_init(&argc, &argv);
 
34
 
 
35
    QApplication application(argc, argv);
 
36
 
 
37
    LauncherView view;
 
38
    view.setAttribute(Qt::WA_X11NetWmWindowTypeDock);
 
39
    /* FIXME: possible optimisations */
 
40
//    view.setAttribute(Qt::WA_OpaquePaintEvent);
 
41
//    view.setAttribute(Qt::WA_NoSystemBackground);
 
42
    view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
 
43
    view.setFocus();
 
44
 
 
45
    if (QCoreApplication::applicationDirPath() == INSTALL_PREFIX "/bin")
 
46
    {
 
47
        /* Running installed */
 
48
        view.engine()->addImportPath(QString(INSTALL_PREFIX "/lib/qt4/imports"));
 
49
        /* Note: baseUrl seems to be picky: if it does not end with a slash,
 
50
           setSource() will fail */
 
51
        view.engine()->setBaseUrl(QUrl::fromLocalFile(INSTALL_PREFIX "/" UNITY_QT_DIR "/launcher/"));
 
52
    }
 
53
    else
 
54
    {
 
55
        /* Uninstalled: make sure local plugins such as UnityApplications are
 
56
           importable */
 
57
        view.engine()->addImportPath(QString("."));
 
58
    }
 
59
 
 
60
    view.rootContext()->setContextProperty("launcherView", &view);
 
61
    view.setSource(QUrl("./Launcher.qml"));
 
62
 
 
63
    view.show();
 
64
    QDesktopWidget* desktop = QApplication::desktop();
 
65
    view.workAreaResized(desktop->screenNumber(&view));
 
66
    QObject::connect(desktop, SIGNAL(workAreaResized(int)), &view, SLOT(workAreaResized(int)));
 
67
 
 
68
    return application.exec();
 
69
}
 
70