~ubuntu-branches/ubuntu/natty/unity-2d/natty-updates

« back to all changes in this revision

Viewing changes to panel/app/panelmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert, Oliver Grawert, Aurélien Gâteau
  • Date: 2011-04-08 16:03:10 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20110408160310-yth7qb9kbgabkqk0
Tags: 3.8.2-0ubuntu1
[ Oliver Grawert ]
* New upstream bugfix release
 - (LP: #632526)  Dash elipsizes file and application names too soon, making them
   unreadable
 - (LP: #669926) [launcher] Web favorites support
 - (LP: #708479) Dash view should use "Prefferred Applications" icons where
   appropriate
 - (LP: #718686) [dash] Group of results sometimes badly positioned
 - (LP: #727483) unity-2d-panel crashed with SIGSEGV in g_return_if_fail_warning()
 - (LP: #731449) [launcher] Dragging a tile at the top of the launcher while
   autoscrolling makes autoscroll wrong afterwards
 - (LP: #736097) [dash] home screen misses icons for applications that are not
   installed
 - (LP: #744999) [launcher] launchers are truncated when too many items to fit
   onscreen
 - (LP: #745077) [spread] clicking launcher with open windows not working correctly
   across workspaces
 - (LP: #745237) [dash] search field default string not translated
 - (LP: #746693) [launcher] .places messages not i18nized
 - (LP: #747836) [dash] Banshee no longer works from the dash home page in 3.8.2
 - (LP: #750753) [dash] showing/hiding places causing graphical corruption
 - (LP: #670608) [dash] Home screen customization should be easy
 - (LP: #683084) Global menu doesn't work well with more than one screen
 - (LP: #714646) [launcher] icons jagged edges during animation
 - (LP: #717744) [panel] inactive menus are clickable
 - (LP: #729002) First four items in Dash begin "Find" "Find" "Find" "Find"
 - (LP: #745758) [spread] super+s should toggle the workspace switcher
 - (LP: #751284) [launcher] Escaping of title broken with webfavorites
 - (LP: #751325) [panel] circle of friends button icon needs to be updated to match
   Unity's
 - (LP: #697816) [launcher] if an urgent window is available then the spread should
   not be activated
 - (LP: #729478) [launcher] Clicking middle mouse button should launch another
   instance of application
 - (LP: #750244) [launcher] Newly installed lenses don’t appear
 - (LP: #752948) Home's "Shortcuts" not i18n/l10n

[ Aurélien Gâteau ]
* Include .mo files in unity-2d package (LP: #751425)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of unity-2d
 
3
 *
 
4
 * Copyright 2010 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Olivier Tilloy <olivier.tilloy@canonical.com>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; version 3.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful,
 
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 * GNU General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 
20
 */
 
21
 
 
22
// Self
 
23
#include "panelmanager.h"
 
24
 
 
25
// Local
 
26
#include <config.h>
 
27
 
 
28
// Applets
 
29
#include <appindicator/appindicatorapplet.h>
 
30
#include <appname/appnameapplet.h>
 
31
#include <homebutton/homebuttonapplet.h>
 
32
#include <indicator/indicatorapplet.h>
 
33
#include <legacytray/legacytrayapplet.h>
 
34
 
 
35
// Unity
 
36
#include <unity2dpanel.h>
 
37
 
 
38
// Qt
 
39
#include <QApplication>
 
40
#include <QDesktopWidget>
 
41
#include <QLabel>
 
42
 
 
43
using namespace Unity2d;
 
44
 
 
45
static QPalette getPalette()
 
46
{
 
47
    QPalette palette;
 
48
 
 
49
    /* Should use the panel's background provided by Unity but it turns
 
50
       out not to be good. It would look like:
 
51
 
 
52
         QBrush bg(QPixmap("theme:/panel_background.png"));
 
53
    */
 
54
    QBrush bg(QPixmap(unity2dDirectory() + "/panel/artwork/background.png"));
 
55
    palette.setBrush(QPalette::Window, bg);
 
56
    palette.setBrush(QPalette::Button, bg);
 
57
    palette.setColor(QPalette::WindowText, Qt::white);
 
58
    palette.setColor(QPalette::ButtonText, Qt::white);
 
59
    return palette;
 
60
}
 
61
 
 
62
static QLabel* createSeparator()
 
63
{
 
64
    QLabel* label = new QLabel;
 
65
    QPixmap pix(unity2dDirectory() + "/panel/artwork/divider.png");
 
66
    label->setPixmap(pix);
 
67
    label->setFixedSize(pix.size());
 
68
    return label;
 
69
}
 
70
 
 
71
static Unity2dPanel* instantiatePanel(int screen)
 
72
{
 
73
    Unity2dPanel* panel = new Unity2dPanel;
 
74
    panel->setEdge(Unity2dPanel::TopEdge);
 
75
    panel->setPalette(getPalette());
 
76
    panel->setFixedHeight(24);
 
77
 
 
78
    int primary = QApplication::desktop()->primaryScreen();
 
79
    if (screen == primary) {
 
80
        panel->addWidget(new HomeButtonApplet);
 
81
        panel->addWidget(createSeparator());
 
82
    }
 
83
    panel->addWidget(new AppNameApplet);
 
84
    if (screen == primary) {
 
85
        /* It doesn’t make sense to have more than one instance of the systray,
 
86
           XEmbed’ed windows can be displayed only once anyway. */
 
87
        panel->addWidget(new LegacyTrayApplet);
 
88
    }
 
89
    panel->addWidget(new IndicatorApplet);
 
90
    return panel;
 
91
}
 
92
 
 
93
PanelManager::PanelManager(QObject* parent)
 
94
    : QObject(parent)
 
95
{
 
96
    QDesktopWidget* desktop = QApplication::desktop();
 
97
    for(int i = 0; i < desktop->screenCount(); ++i) {
 
98
        Unity2dPanel* panel = instantiatePanel(i);
 
99
        m_panels.append(panel);
 
100
        panel->show();
 
101
        panel->move(desktop->screenGeometry(i).topLeft());
 
102
    }
 
103
    connect(desktop, SIGNAL(screenCountChanged(int)), SLOT(onScreenCountChanged(int)));
 
104
}
 
105
 
 
106
PanelManager::~PanelManager()
 
107
{
 
108
    qDeleteAll(m_panels);
 
109
}
 
110
 
 
111
void
 
112
PanelManager::onScreenCountChanged(int newCount)
 
113
{
 
114
    QDesktopWidget* desktop = QApplication::desktop();
 
115
    int size = m_panels.size();
 
116
    /* Update the position of existing panels, and instantiate new panels. */
 
117
    for (int i = 0; i < newCount; ++i) {
 
118
        Unity2dPanel* panel;
 
119
        if (i < size) {
 
120
            panel = m_panels[i];
 
121
        } else {
 
122
            panel = instantiatePanel(i);
 
123
            m_panels.append(panel);
 
124
        }
 
125
        panel->show();
 
126
        panel->move(desktop->screenGeometry(i).topLeft());
 
127
    }
 
128
    /* Remove extra panels if any. */
 
129
    while (m_panels.size() > newCount) {
 
130
        delete m_panels.takeLast();
 
131
    }
 
132
}
 
133
 
 
134
#include "panelmanager.moc"
 
135