on xenial help sign in
Handle short appIds in launcher data
commit08b3c3b74695d4e982b31e90705cfb0766e49a52 authorMichael Terry <michael.terry@canonical.com> dateThu 29 May 2014, 14:36 (12 years ago) parent49c02bd
5 files changed+35−3
debian/control+1 plugins/Unity/Launcher/CMakeLists.txt+6−2 plugins/Unity/Launcher/launchermodel.cpp+26 plugins/Unity/Launcher/launchermodel.h+1 qml/GreeterShell.qml+1−1
debian/control+1
@@ -20,6 +20,7 @@ Build-Depends: cmake,
2020 libqt5xmlpatterns5-dev,
2121 libunity-api-dev (>= 7.80.6),
2222 libunity-mir-dev,
23+ libupstart-app-launch2-dev,
2324 libusermetricsoutput1-dev,
2425 libxcb1-dev,
2526 pkg-config,
plugins/Unity/Launcher/CMakeLists.txt+6−2
@@ -2,6 +2,7 @@ include(FindPkgConfig)
22pkg_check_modules(LAUNCHER_API REQUIRED unity-shell-launcher=3)
33pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=1)
44pkg_check_modules(GSETTINGS_QT REQUIRED gsettings-qt)
5+pkg_check_modules(UPSTART_APP_LAUNCH REQUIRED upstart-app-launch-2)
56
67add_definitions(-DSM_BUSNAME=systemBus)
78
@@ -9,6 +10,7 @@ include_directories(
910 ${CMAKE_CURRENT_SOURCE_DIR}
1011 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
1112 ${GSETTINGS_QT_INCLUDE_DIRS}
13+ ${UPSTART_APP_LAUNCH_INCLUDE_DIRS}
1214)
1315
1416set(QMLLAUNCHERPLUGIN_SRC
@@ -28,8 +30,10 @@ add_library(UnityLauncher-qml MODULE
2830 ${QMLLAUNCHERPLUGIN_SRC}
2931 )
3032
31−target_link_libraries(UnityLauncher-qml ${GSETTINGS_QT_LDFLAGS})
32−
33+target_link_libraries(UnityLauncher-qml
34+ ${GSETTINGS_QT_LDFLAGS}
35+ ${UPSTART_APP_LAUNCH_LDFLAGS}
36+)
3337qt5_use_modules(UnityLauncher-qml DBus Qml)
3438
3539add_unity8_plugin(Unity.Launcher 0.1 Unity/Launcher TARGETS UnityLauncher-qml)
plugins/Unity/Launcher/launchermodel.cpp+26
@@ -22,6 +22,7 @@
2222#include "backend/launcherbackend.h"
2323
2424#include <unity/shell/application/ApplicationInfoInterface.h>
25+#include <upstart-app-launch.h>
2526
2627using namespace unity::shell::application;
2728
@@ -195,6 +196,31 @@ void LauncherModel::setUser(const QString &username)
195196 m_backend->setUser(username);
196197}
197198
199+QString LauncherModel::getUrlForAppId(const QString &appId)
200+{
201+ // appId is either an appId or a legacy app name. Let's find out which
202+ QString url;
203+ gchar *package, *app, *version, *longAppId;
204+
205+ // assume legacy app until proven otherwise
206+ url = "application:///" + appId + ".desktop";
207+
208+ if (upstart_app_launch_app_id_parse(appId.first().toLatin1().constData(),
209+ &package, &app, &version)) {
210+ // Turn it back into an appId to test if it's a click app or not
211+ longAppId = upstart_app_launch_triplet_to_app_id(package, app, version);
212+ if (longAppId != nullptr) { // it is a click app!
213+ url = QString("appid://%1/%2/%3").args(package, app, version);
214+ g_free(longAppId);
215+ }
216+ g_free(package);
217+ g_free(app);
218+ g_free(version);
219+ }
220+
221+ return url;
222+}
223+
198224void LauncherModel::refreshStoredApplications()
199225{
200226 // First remove any existing ones
plugins/Unity/Launcher/launchermodel.h+1
@@ -51,6 +51,7 @@ public:
5151 Q_INVOKABLE void requestRemove(const QString &appId);
5252 Q_INVOKABLE void quickListActionInvoked(const QString &appId, int actionIndex);
5353 Q_INVOKABLE void setUser(const QString &username);
54+ Q_INVOKABLE QString getUrlForAppId(const QString &appId) const;
5455
5556 unity::shell::application::ApplicationManagerInterface* applicationManager() const;
5657 void setApplicationManager(unity::shell::application::ApplicationManagerInterface *appManager);
qml/GreeterShell.qml+1−1
@@ -201,7 +201,7 @@ BasicShell {
201201 dragAreaWidth: shell.edgeSize
202202 available: !edgeDemo.active
203203 onLauncherApplicationSelected: {
204− shell.activateApplication("application:///" + appId + ".desktop")
204+ shell.activateApplication(LauncherModel.getUrlForAppId(appId))
205205 }
206206 onShownChanged: {
207207 if (shown) {