on xenial help sign in
merge appdate branch as prereq
commitac987a25f425875d3c678d89eba59b6a58a6b41e authorMichael Zanetti <michael.zanetti@canonical.com> dateFri 22 Aug 2014, 18:09 (12 years ago) parentd8c7c26f4d6113
5 files changed+55−5
data/unity8-filewatcher.conf+8 plugins/Unity/Launcher/backend/launcherbackend.cpp+41−4 plugins/Unity/Launcher/backend/launcherbackend.h+2 plugins/Unity/Launcher/launchermodel.cpp+1 plugins/Unity/Launcher/launchermodel.h+3−1
data/unity8-filewatcher.confnew file+8
@@ -0,0 +1,8 @@
1+description "File system watcher for unity8"
2+author "Michael Zanetti <michael.zanetti@canonical.com>"
3+
4+# Workaround for bug 1360208. ~ and * in one expression doesn't work currently
5+start on (file FILE=/home/phablet/.local/share/applications/*.desktop) or (file FILE=/usr/share/applications/*.desktop)
6+
7+exec dbus-send --type=method_call --dest=com.canonical.Unity.Launcher /com/canonical/Unity/Launcher com.canonical.Unity.Launcher.Refresh
8+
plugins/Unity/Launcher/backend/launcherbackend.cpp+41−4
@@ -314,6 +314,19 @@ void LauncherBackend::syncToAccounts()
314314 }
315315}
316316
317+void LauncherBackend::refresh()
318+{
319+ QList<QString> removedApps;
320+ Q_FOREACH (const QString &appId, m_storedApps) {
321+ if (findDesktopFile(appId).isEmpty()) {
322+ removedApps << appId;
323+ }
324+ }
325+ Q_FOREACH (const QString &appId, removedApps) {
326+ Q_EMIT appUninstalled(appId);
327+ }
328+}
329+
317330QString LauncherBackend::findDesktopFile(const QString &appId) const
318331{
319332 int dashPos = -1;
@@ -400,15 +413,23 @@ void LauncherBackend::loadFromVariant(const QVariantMap &details)
400413 }
401414 QString appId = details.value("id").toString();
402415
416+ QString desktopFile = findDesktopFile(appId);
417+ if (desktopFile.isEmpty()) {
418+ return;
419+ }
420+
403421 LauncherBackendItem *item = m_itemCache.value(appId, nullptr);
404422 if (item) {
405423 delete item;
406424 }
407425
408− item = new LauncherBackendItem();
409−
410− item->displayName = details.value("name").toString();
411− item->icon = details.value("icon").toString();
426+ if (qgetenv("USER") == "lightdm") {
427+ item = new LauncherBackendItem();
428+ item->displayName = details.value("name").toString();
429+ item->icon = details.value("icon").toString();
430+ } else {
431+ item = parseDesktopFile(desktopFile);
432+ }
412433 item->count = details.value("count").toInt();
413434 item->countVisible = details.value("countVisible").toBool();
414435
@@ -442,6 +463,16 @@ bool LauncherBackend::handleMessage(const QDBusMessage& message, const QDBusConn
442463 if (message.type() != QDBusMessage::MessageType::MethodCallMessage) {
443464 return false;
444465 }
466+ // First handle methods of the Launcher interface
467+ if (message.interface() == "com.canonical.Unity.Launcher") {
468+ if (message.member() == "Refresh") {
469+ QDBusMessage reply = message.createReply();
470+ refresh();
471+ return connection.send(reply);
472+ }
473+ }
474+
475+ // Now handle dynamic properties (for launcher emblems)
445476 if (message.interface() != "org.freedesktop.DBus.Properties") {
446477 return false;
447478 }
@@ -491,6 +522,12 @@ QString LauncherBackend::introspect(const QString &path) const
491522 if (path == "/com/canonical/Unity/Launcher/" || path == "/com/canonical/Unity/Launcher") {
492523 QString nodes;
493524
525+ // Add Refresh to introspect
526+ nodes = "<interface name=\"com.canonical.Unity.Launcher\">"
527+ "<method name=\"Refresh\"/>"
528+ "</interface>";
529+
530+ // Add dynamic properties for launcher emblems
494531 Q_FOREACH(const QString &appId, m_itemCache.keys()) {
495532 nodes.append("<node name=\"");
496533 nodes.append(encodeAppId(appId));
plugins/Unity/Launcher/backend/launcherbackend.h+2
@@ -166,6 +166,7 @@ Q_SIGNALS:
166166 void progressChanged(const QString &appId, int progress) const;
167167 void countChanged(const QString &appId, int count) const;
168168 void countVisibleChanged(const QString &appId, bool visible) const;
169+ void appUninstalled(const QString &appId);
169170
170171private:
171172 QString findDesktopFile(const QString &appId) const;
@@ -177,6 +178,7 @@ private:
177178 bool isDefaultsItem(const QList<QVariantMap> &apps) const;
178179 void syncFromAccounts();
179180 void syncToAccounts();
181+ void refresh();
180182
181183 QList<QString> m_storedApps;
182184 mutable QHash<QString, LauncherBackendItem*> m_itemCache;
plugins/Unity/Launcher/launchermodel.cpp+1
@@ -34,6 +34,7 @@ LauncherModel::LauncherModel(QObject *parent):
3434{
3535 connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
3636 connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
37+ connect(m_backend, SIGNAL(appUninstalled(QString)), SLOT(requestRemove(QString)));
3738
3839 Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
3940 LauncherItem *item = new LauncherItem(entry,
plugins/Unity/Launcher/launchermodel.h+3−1
@@ -48,7 +48,6 @@ public:
4848 Q_INVOKABLE unity::shell::launcher::LauncherItemInterface* get(int index) const;
4949 Q_INVOKABLE void move(int oldIndex, int newIndex);
5050 Q_INVOKABLE void pin(const QString &appId, int index = -1);
51− Q_INVOKABLE void requestRemove(const QString &appId);
5251 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
5352 Q_INVOKABLE void setUser(const QString &username);
5453 Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
@@ -56,6 +55,9 @@ public:
5655 unity::shell::application::ApplicationManagerInterface* applicationManager() const;
5756 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
5857
58+public Q_SLOTS:
59+ void requestRemove(const QString &appId);
60+
5961private:
6062 void storeAppList();
6163 int findApplication(const QString &appId);