Merge lp:~uriboni/unity-2d/add-fav-from-software-center into lp:unity-2d/3.0

Proposed by Ugo Riboni
Status: Merged
Approved by: Florian Boucault
Approved revision: 460
Merged at revision: 464
Proposed branch: lp:~uriboni/unity-2d/add-fav-from-software-center
Merge into: lp:unity-2d/3.0
Diff against target: 245 lines (+106/-4)
8 files modified
launcher/LauncherItem.qml (+1/-1)
launcher/UnityApplications/CMakeLists.txt (+2/-0)
launcher/UnityApplications/launcherapplication.cpp (+26/-0)
launcher/UnityApplications/launcherapplication.h (+4/-0)
launcher/UnityApplications/launcherapplicationslist.cpp (+20/-3)
launcher/UnityApplications/launcherapplicationslist.h (+1/-0)
launcher/UnityApplications/launcherapplicationslistdbus.cpp (+30/-0)
launcher/UnityApplications/launcherapplicationslistdbus.h (+22/-0)
To merge this branch: bzr merge lp:~uriboni/unity-2d/add-fav-from-software-center
Reviewer Review Type Date Requested Status
Florian Boucault (community) Needs Fixing
Review via email: mp+53630@code.launchpad.net

Commit message

[launcher] Expose a new DBUS method that will be called by Software Center to add new favorites

Description of the change

This MR exposes an object to DBUS that exposes a method that when called causes a new favorite to be added to the Launcher.

This method is currently only called by Software Center in this branch:
lp:~gary-lasker/software-center/launcher-integration-plan-b

To run from that branch to test, you can run from the checkout directory:
PYTHONPATH=. python ./software-center

Note that this implements only a small part of the full spec, but it was agreed that's all we need for Natty with Unity and Software Center developers.

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

The code is good. The current behaviour is reliable.

However there are several user experience issues:
- if the launcher is hidden, it should show when adding the favorite (the same way it shows when an application requests attention)
- the added item should wiggle (the same way it shows when an application requests attention) as to help the user figure out where the application is
- [SOFTWARE CENTER SPECIFIC] the option of adding to the launcher is not very noticeable at all
- [SOFTWARE CENTER SPECIFIC] the option of adding to the launcher disappears as soon as the installation is finished
- [SOFTWARE CENTER SPECIFIC] the option of adding to the launcher does not appear when clicking on the 'install' button from the list of applications

review: Needs Fixing
456. By Ugo Riboni

Make sure the shake animation for urgent apps doesn't always run for the entire 30 loops

457. By Ugo Riboni

When a new favorite is added via software center make it urgent for a bit to attract attention

458. By Ugo Riboni

Initialize the m_forceUrgent variable to prevent a bug

459. By Ugo Riboni

Revert previous incorrect fix.

460. By Ugo Riboni

Make sure the launcher tiles shake only as long as they are in urgent state.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/LauncherItem.qml'
2--- launcher/LauncherItem.qml 2011-03-14 15:25:50 +0000
3+++ launcher/LauncherItem.qml 2011-03-21 18:22:07 +0000
4@@ -318,7 +318,7 @@
5 alwaysRunToEnd: true
6
7 SequentialAnimation {
8- loops: 30
9+ loops: (urgent) ? 30 : 0
10 NumberAnimation { target: tile; property: "rotation"; to: 15; duration: 150 }
11 NumberAnimation { target: tile; property: "rotation"; to: -15; duration: 150 }
12 }
13
14=== modified file 'launcher/UnityApplications/CMakeLists.txt'
15--- launcher/UnityApplications/CMakeLists.txt 2011-02-11 09:25:11 +0000
16+++ launcher/UnityApplications/CMakeLists.txt 2011-03-21 18:22:07 +0000
17@@ -15,6 +15,7 @@
18 launcheritem.cpp
19 launcherapplication.cpp
20 launcherapplicationslist.cpp
21+ launcherapplicationslistdbus.cpp
22 launcherdevice.cpp
23 launcherdeviceslist.cpp
24 placeentry.cpp
25@@ -32,6 +33,7 @@
26 launcheritem.h
27 launcherapplication.h
28 launcherapplicationslist.h
29+ launcherapplicationslistdbus.h
30 launcherdevice.h
31 launcherdeviceslist.h
32 placeentry.h
33
34=== modified file 'launcher/UnityApplications/launcherapplication.cpp'
35--- launcher/UnityApplications/launcherapplication.cpp 2011-03-21 13:46:48 +0000
36+++ launcher/UnityApplications/launcherapplication.cpp 2011-03-21 18:22:07 +0000
37@@ -54,6 +54,7 @@
38 , m_progress(0), m_progressBarVisible(false)
39 , m_counter(0), m_counterVisible(false)
40 , m_emblem(QString()), m_emblemVisible(false)
41+ , m_forceUrgent(false)
42 {
43 /* Make sure wnck_set_client_type is called only once */
44 static bool client_type_set = false;
45@@ -128,6 +129,10 @@
46 bool
47 LauncherApplication::urgent() const
48 {
49+ if (m_forceUrgent) {
50+ return true;
51+ }
52+
53 if (m_application != NULL) {
54 return m_application->urgent();
55 }
56@@ -135,6 +140,27 @@
57 return false;
58 }
59
60+void
61+LauncherApplication::beginForceUrgent(int duration)
62+{
63+ bool wasUrgent = urgent();
64+ m_forceUrgent = true;
65+ if (wasUrgent != urgent()) {
66+ Q_EMIT urgentChanged(urgent());
67+ }
68+ QTimer::singleShot(duration, this, SLOT(endForceUrgent()));
69+}
70+
71+void
72+LauncherApplication::endForceUrgent()
73+{
74+ bool wasUrgent = urgent();
75+ m_forceUrgent = false;
76+ if (wasUrgent != urgent()) {
77+ Q_EMIT urgentChanged(urgent());
78+ }
79+}
80+
81 bool
82 LauncherApplication::sticky() const
83 {
84
85=== modified file 'launcher/UnityApplications/launcherapplication.h'
86--- launcher/UnityApplications/launcherapplication.h 2011-03-11 01:14:28 +0000
87+++ launcher/UnityApplications/launcherapplication.h 2011-03-21 18:22:07 +0000
88@@ -37,6 +37,7 @@
89 class LauncherApplication : public LauncherItem
90 {
91 Q_OBJECT
92+ friend class LauncherApplicationsListDBUS;
93
94 Q_PROPERTY(bool sticky READ sticky WRITE setSticky NOTIFY stickyChanged)
95 Q_PROPERTY(QString application_type READ application_type NOTIFY applicationTypeChanged)
96@@ -127,6 +128,8 @@
97
98 void onDesktopFileChanged(const QString&);
99 void checkDesktopFileReallyRemoved();
100+ void beginForceUrgent(int duration);
101+ void endForceUrgent();
102
103 private:
104 BamfApplication *m_application;
105@@ -143,6 +146,7 @@
106 bool m_counterVisible;
107 QString m_emblem;
108 bool m_emblemVisible;
109+ bool m_forceUrgent;
110
111 void updateBamfApplicationDependentProperties();
112 void monitorDesktopFile(const QString&);
113
114=== modified file 'launcher/UnityApplications/launcherapplicationslist.cpp'
115--- launcher/UnityApplications/launcherapplicationslist.cpp 2011-03-11 15:44:28 +0000
116+++ launcher/UnityApplications/launcherapplicationslist.cpp 2011-03-21 18:22:07 +0000
117@@ -17,6 +17,7 @@
118 #include "launcherapplication.h"
119 #include "launcherapplicationslist.h"
120 #include "webfavorite.h"
121+#include "launcherapplicationslistdbus.h"
122
123 #include "bamf-matcher.h"
124 #include "bamf-application.h"
125@@ -31,6 +32,8 @@
126 #define FAVORITES_KEY QString("/desktop/unity-2d/launcher/favorites")
127 #define DBUS_SERVICE_UNITY "com.canonical.Unity"
128 #define DBUS_SERVICE_LAUNCHER_ENTRY "com.canonical.Unity.LauncherEntry"
129+#define DBUS_SERVICE_LAUNCHER "com.canonical.Unity.Launcher"
130+#define DBUS_OBJECT_LAUNCHER "/com/canonical/Unity/Launcher"
131
132 LauncherApplicationsList::LauncherApplicationsList(QObject *parent) :
133 QAbstractListModel(parent)
134@@ -38,20 +41,34 @@
135 m_favorites_list = new GConfItemQmlWrapper();
136 m_favorites_list->setKey(FAVORITES_KEY);
137
138+ QDBusConnection session = QDBusConnection::sessionBus();
139 /* FIXME: libunity will send out the Update signal for LauncherEntries
140 only if it finds com.canonical.Unity on the bus, so let's just quickly
141 register ourselves as Unity here. Should be moved somewhere else more proper */
142- if (!QDBusConnection::sessionBus().registerService(DBUS_SERVICE_UNITY)) {
143- qWarning() << "The name com.canonical.Unity is already taken on the bus";
144+ if (!session.registerService(DBUS_SERVICE_UNITY)) {
145+ qWarning() << "The name" << DBUS_SERVICE_UNITY << "is already taken on DBUS";
146 } else {
147 /* Set ourselves up to receive any Update signal coming from any
148 LauncherEntry */
149- QDBusConnection session = QDBusConnection::sessionBus();
150 session.connect(QString(), QString(),
151 DBUS_SERVICE_LAUNCHER_ENTRY, "Update",
152 this, SLOT(onRemoteEntryUpdated(QString,QMap<QString,QVariant>)));
153 }
154
155+ if (!session.registerService(DBUS_SERVICE_LAUNCHER)) {
156+ qWarning() << "The name" << DBUS_SERVICE_LAUNCHER << "is already taken on DBUS";
157+ } else {
158+ /* Set ourselves up to receive a method call from Software Center asking us to add
159+ to favorites an application that is being installed and that the user requested
160+ to be added. */
161+ LauncherApplicationsListDBUS *dbusAdapter = new LauncherApplicationsListDBUS(this);
162+ if (!session.registerObject(DBUS_OBJECT_LAUNCHER, dbusAdapter,
163+ QDBusConnection::ExportAllSlots)) {
164+ qWarning() << "The object" << DBUS_OBJECT_LAUNCHER << "on" << DBUS_SERVICE_LAUNCHER
165+ << "is already present on DBUS.";
166+ }
167+ }
168+
169 load();
170 }
171
172
173=== modified file 'launcher/UnityApplications/launcherapplicationslist.h'
174--- launcher/UnityApplications/launcherapplicationslist.h 2011-03-11 14:56:13 +0000
175+++ launcher/UnityApplications/launcherapplicationslist.h 2011-03-21 18:22:07 +0000
176@@ -34,6 +34,7 @@
177 class LauncherApplicationsList : public QAbstractListModel
178 {
179 Q_OBJECT
180+ friend class LauncherApplicationsListDBUS;
181
182 public:
183 LauncherApplicationsList(QObject *parent = 0);
184
185=== added file 'launcher/UnityApplications/launcherapplicationslistdbus.cpp'
186--- launcher/UnityApplications/launcherapplicationslistdbus.cpp 1970-01-01 00:00:00 +0000
187+++ launcher/UnityApplications/launcherapplicationslistdbus.cpp 2011-03-21 18:22:07 +0000
188@@ -0,0 +1,30 @@
189+#include "launcherapplication.h"
190+#include "launcherapplicationslistdbus.h"
191+#include "launcherapplicationslist.h"
192+
193+LauncherApplicationsListDBUS::LauncherApplicationsListDBUS(QObject *parent) :
194+ QDBusAbstractAdaptor(parent)
195+{
196+}
197+
198+void
199+LauncherApplicationsListDBUS::AddLauncherItemFromPosition(QString icon, QString title,
200+ int icon_x, int icon_y, int icon_size,
201+ QString desktop_file, QString aptdaemon_task)
202+{
203+ Q_UNUSED(icon)
204+ Q_UNUSED(title)
205+ Q_UNUSED(icon_x)
206+ Q_UNUSED(icon_y)
207+ Q_UNUSED(icon_size)
208+ Q_UNUSED(aptdaemon_task)
209+
210+ LauncherApplicationsList* applicationsList = qobject_cast<LauncherApplicationsList*>(parent());
211+ if (applicationsList != NULL && !desktop_file.isEmpty()) {
212+ applicationsList->insertFavoriteApplication(desktop_file);
213+ LauncherApplication *application = applicationsList->m_applicationForDesktopFile.value(desktop_file, NULL);
214+ if (application != NULL) {
215+ application->beginForceUrgent(1500);
216+ }
217+ }
218+}
219
220=== added file 'launcher/UnityApplications/launcherapplicationslistdbus.h'
221--- launcher/UnityApplications/launcherapplicationslistdbus.h 1970-01-01 00:00:00 +0000
222+++ launcher/UnityApplications/launcherapplicationslistdbus.h 2011-03-21 18:22:07 +0000
223@@ -0,0 +1,22 @@
224+#ifndef LAUNCHERAPPLICATIONSLISTDBUS_H
225+#define LAUNCHERAPPLICATIONSLISTDBUS_H
226+
227+#include <QObject>
228+#include <QtDBus/QDBusAbstractAdaptor>
229+
230+class LauncherApplicationsListDBUS : public QDBusAbstractAdaptor
231+{
232+ Q_OBJECT
233+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Launcher")
234+
235+public:
236+ explicit LauncherApplicationsListDBUS(QObject *parent = 0);
237+
238+public Q_SLOTS:
239+ void AddLauncherItemFromPosition(QString icon, QString title,
240+ int icon_x, int icon_y, int icon_size,
241+ QString desktop_file, QString aptdaemon_task);
242+
243+};
244+
245+#endif // LAUNCHERAPPLICATIONSLISTDBUS_H

Subscribers

People subscribed via source and target branches

to all changes: