@@ -27,20 +27,15 @@ using namespace unity::shell::application;
2727
2828LauncherModel::LauncherModel(QObject *parent):
2929 LauncherModelInterface(parent),
30− m_backend(new LauncherBackend(this)),
30+ m_greeterMode(qgetenv("XDG_SESSION_CLASS") == "greeter"),
31+ m_backend(new LauncherBackend(m_greeterMode, this)),
3132 m_appManager(0)
3233{
3334 connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
3435 connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
36+ connect(m_backend, SIGNAL(refreshApplications()), SLOT(refreshStoredApplications()));
3537
36− Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
37− LauncherItem *item = new LauncherItem(entry,
38− m_backend->displayName(entry),
39− m_backend->icon(entry),
40− this);
41− item->setPinned(true);
42− m_list.append(item);
43− }
38+ refreshStoredApplications();
4439}
4540
4641LauncherModel::~LauncherModel()
@@ -139,7 +134,8 @@ void LauncherModel::pin(const QString &appId, int index)
139134 beginInsertRows(QModelIndex(), index, index);
140135 LauncherItem *item = new LauncherItem(appId,
141136 m_backend->displayName(appId),
142− m_backend->icon(appId));
137+ m_backend->icon(appId),
138+ !m_greeterMode);
143139 item->setPinned(true);
144140 m_list.insert(index, item);
145141 endInsertRows();
@@ -199,6 +195,40 @@ void LauncherModel::setUser(const QString &username)
199195 m_backend->setUser(username);
200196}
201197
198+void LauncherModel::refreshStoredApplications()
199+{
200+ // First remove any existing ones
201+ QList<int> storedAppIndices;
202+ for (int i = 0; i < m_list.count(); ++i) {
203+ if (!m_list.at(i)->recent()) {
204+ storedAppIndices << i;
205+ }
206+ }
207+ int run = 0;
208+ while (storedAppIndices.count() > 0) {
209+ beginRemoveRows(QModelIndex(), storedAppIndices.first() - run, storedAppIndices.first() - run);
210+ m_list.takeAt(storedAppIndices.first() - run)->deleteLater();
211+ endRemoveRows();
212+ storedAppIndices.takeFirst();
213+ ++run;
214+ }
215+
216+ // Now insert all stored apps at beginning of list
217+ QStringList storedApplications = m_backend->storedApplications();
218+ beginInsertRows(QModelIndex(), 0, storedApplications.size() - 1);
219+ run = 0;
220+ Q_FOREACH (const QString &entry, storedApplications) {
221+ LauncherItem *item = new LauncherItem(entry,
222+ m_backend->displayName(entry),
223+ m_backend->icon(entry),
224+ !m_greeterMode,
225+ this);
226+ item->setPinned(true);
227+ m_list.insert(run++, item);
228+ }
229+ endInsertRows();
230+}
231+
202232ApplicationManagerInterface *LauncherModel::applicationManager() const
203233{
204234 return m_appManager;
@@ -302,7 +332,7 @@ void LauncherModel::applicationAdded(const QModelIndex &parent, int row)
302332 if (found) {
303333 // Shall we paint some running/recent app highlight? If yes, do it here.
304334 } else {
305− LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString());
335+ LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), !m_greeterMode);
306336 item->setRecent(true);
307337 item->setFocused(app->focused());
308338