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
=== modified file 'launcher/LauncherItem.qml'
--- launcher/LauncherItem.qml 2011-03-14 15:25:50 +0000
+++ launcher/LauncherItem.qml 2011-03-21 18:22:07 +0000
@@ -318,7 +318,7 @@
318 alwaysRunToEnd: true318 alwaysRunToEnd: true
319319
320 SequentialAnimation {320 SequentialAnimation {
321 loops: 30321 loops: (urgent) ? 30 : 0
322 NumberAnimation { target: tile; property: "rotation"; to: 15; duration: 150 }322 NumberAnimation { target: tile; property: "rotation"; to: 15; duration: 150 }
323 NumberAnimation { target: tile; property: "rotation"; to: -15; duration: 150 }323 NumberAnimation { target: tile; property: "rotation"; to: -15; duration: 150 }
324 }324 }
325325
=== modified file 'launcher/UnityApplications/CMakeLists.txt'
--- launcher/UnityApplications/CMakeLists.txt 2011-02-11 09:25:11 +0000
+++ launcher/UnityApplications/CMakeLists.txt 2011-03-21 18:22:07 +0000
@@ -15,6 +15,7 @@
15 launcheritem.cpp15 launcheritem.cpp
16 launcherapplication.cpp16 launcherapplication.cpp
17 launcherapplicationslist.cpp17 launcherapplicationslist.cpp
18 launcherapplicationslistdbus.cpp
18 launcherdevice.cpp19 launcherdevice.cpp
19 launcherdeviceslist.cpp20 launcherdeviceslist.cpp
20 placeentry.cpp21 placeentry.cpp
@@ -32,6 +33,7 @@
32 launcheritem.h33 launcheritem.h
33 launcherapplication.h34 launcherapplication.h
34 launcherapplicationslist.h35 launcherapplicationslist.h
36 launcherapplicationslistdbus.h
35 launcherdevice.h37 launcherdevice.h
36 launcherdeviceslist.h38 launcherdeviceslist.h
37 placeentry.h39 placeentry.h
3840
=== modified file 'launcher/UnityApplications/launcherapplication.cpp'
--- launcher/UnityApplications/launcherapplication.cpp 2011-03-21 13:46:48 +0000
+++ launcher/UnityApplications/launcherapplication.cpp 2011-03-21 18:22:07 +0000
@@ -54,6 +54,7 @@
54 , m_progress(0), m_progressBarVisible(false)54 , m_progress(0), m_progressBarVisible(false)
55 , m_counter(0), m_counterVisible(false)55 , m_counter(0), m_counterVisible(false)
56 , m_emblem(QString()), m_emblemVisible(false)56 , m_emblem(QString()), m_emblemVisible(false)
57 , m_forceUrgent(false)
57{58{
58 /* Make sure wnck_set_client_type is called only once */59 /* Make sure wnck_set_client_type is called only once */
59 static bool client_type_set = false;60 static bool client_type_set = false;
@@ -128,6 +129,10 @@
128bool129bool
129LauncherApplication::urgent() const130LauncherApplication::urgent() const
130{131{
132 if (m_forceUrgent) {
133 return true;
134 }
135
131 if (m_application != NULL) {136 if (m_application != NULL) {
132 return m_application->urgent();137 return m_application->urgent();
133 }138 }
@@ -135,6 +140,27 @@
135 return false;140 return false;
136}141}
137142
143void
144LauncherApplication::beginForceUrgent(int duration)
145{
146 bool wasUrgent = urgent();
147 m_forceUrgent = true;
148 if (wasUrgent != urgent()) {
149 Q_EMIT urgentChanged(urgent());
150 }
151 QTimer::singleShot(duration, this, SLOT(endForceUrgent()));
152}
153
154void
155LauncherApplication::endForceUrgent()
156{
157 bool wasUrgent = urgent();
158 m_forceUrgent = false;
159 if (wasUrgent != urgent()) {
160 Q_EMIT urgentChanged(urgent());
161 }
162}
163
138bool164bool
139LauncherApplication::sticky() const165LauncherApplication::sticky() const
140{166{
141167
=== modified file 'launcher/UnityApplications/launcherapplication.h'
--- launcher/UnityApplications/launcherapplication.h 2011-03-11 01:14:28 +0000
+++ launcher/UnityApplications/launcherapplication.h 2011-03-21 18:22:07 +0000
@@ -37,6 +37,7 @@
37class LauncherApplication : public LauncherItem37class LauncherApplication : public LauncherItem
38{38{
39 Q_OBJECT39 Q_OBJECT
40 friend class LauncherApplicationsListDBUS;
4041
41 Q_PROPERTY(bool sticky READ sticky WRITE setSticky NOTIFY stickyChanged)42 Q_PROPERTY(bool sticky READ sticky WRITE setSticky NOTIFY stickyChanged)
42 Q_PROPERTY(QString application_type READ application_type NOTIFY applicationTypeChanged)43 Q_PROPERTY(QString application_type READ application_type NOTIFY applicationTypeChanged)
@@ -127,6 +128,8 @@
127128
128 void onDesktopFileChanged(const QString&);129 void onDesktopFileChanged(const QString&);
129 void checkDesktopFileReallyRemoved();130 void checkDesktopFileReallyRemoved();
131 void beginForceUrgent(int duration);
132 void endForceUrgent();
130133
131private:134private:
132 BamfApplication *m_application;135 BamfApplication *m_application;
@@ -143,6 +146,7 @@
143 bool m_counterVisible;146 bool m_counterVisible;
144 QString m_emblem;147 QString m_emblem;
145 bool m_emblemVisible;148 bool m_emblemVisible;
149 bool m_forceUrgent;
146150
147 void updateBamfApplicationDependentProperties();151 void updateBamfApplicationDependentProperties();
148 void monitorDesktopFile(const QString&);152 void monitorDesktopFile(const QString&);
149153
=== modified file 'launcher/UnityApplications/launcherapplicationslist.cpp'
--- launcher/UnityApplications/launcherapplicationslist.cpp 2011-03-11 15:44:28 +0000
+++ launcher/UnityApplications/launcherapplicationslist.cpp 2011-03-21 18:22:07 +0000
@@ -17,6 +17,7 @@
17#include "launcherapplication.h"17#include "launcherapplication.h"
18#include "launcherapplicationslist.h"18#include "launcherapplicationslist.h"
19#include "webfavorite.h"19#include "webfavorite.h"
20#include "launcherapplicationslistdbus.h"
2021
21#include "bamf-matcher.h"22#include "bamf-matcher.h"
22#include "bamf-application.h"23#include "bamf-application.h"
@@ -31,6 +32,8 @@
31#define FAVORITES_KEY QString("/desktop/unity-2d/launcher/favorites")32#define FAVORITES_KEY QString("/desktop/unity-2d/launcher/favorites")
32#define DBUS_SERVICE_UNITY "com.canonical.Unity"33#define DBUS_SERVICE_UNITY "com.canonical.Unity"
33#define DBUS_SERVICE_LAUNCHER_ENTRY "com.canonical.Unity.LauncherEntry"34#define DBUS_SERVICE_LAUNCHER_ENTRY "com.canonical.Unity.LauncherEntry"
35#define DBUS_SERVICE_LAUNCHER "com.canonical.Unity.Launcher"
36#define DBUS_OBJECT_LAUNCHER "/com/canonical/Unity/Launcher"
3437
35LauncherApplicationsList::LauncherApplicationsList(QObject *parent) :38LauncherApplicationsList::LauncherApplicationsList(QObject *parent) :
36 QAbstractListModel(parent)39 QAbstractListModel(parent)
@@ -38,20 +41,34 @@
38 m_favorites_list = new GConfItemQmlWrapper();41 m_favorites_list = new GConfItemQmlWrapper();
39 m_favorites_list->setKey(FAVORITES_KEY);42 m_favorites_list->setKey(FAVORITES_KEY);
4043
44 QDBusConnection session = QDBusConnection::sessionBus();
41 /* FIXME: libunity will send out the Update signal for LauncherEntries45 /* FIXME: libunity will send out the Update signal for LauncherEntries
42 only if it finds com.canonical.Unity on the bus, so let's just quickly46 only if it finds com.canonical.Unity on the bus, so let's just quickly
43 register ourselves as Unity here. Should be moved somewhere else more proper */47 register ourselves as Unity here. Should be moved somewhere else more proper */
44 if (!QDBusConnection::sessionBus().registerService(DBUS_SERVICE_UNITY)) {48 if (!session.registerService(DBUS_SERVICE_UNITY)) {
45 qWarning() << "The name com.canonical.Unity is already taken on the bus";49 qWarning() << "The name" << DBUS_SERVICE_UNITY << "is already taken on DBUS";
46 } else {50 } else {
47 /* Set ourselves up to receive any Update signal coming from any51 /* Set ourselves up to receive any Update signal coming from any
48 LauncherEntry */52 LauncherEntry */
49 QDBusConnection session = QDBusConnection::sessionBus();
50 session.connect(QString(), QString(),53 session.connect(QString(), QString(),
51 DBUS_SERVICE_LAUNCHER_ENTRY, "Update",54 DBUS_SERVICE_LAUNCHER_ENTRY, "Update",
52 this, SLOT(onRemoteEntryUpdated(QString,QMap<QString,QVariant>)));55 this, SLOT(onRemoteEntryUpdated(QString,QMap<QString,QVariant>)));
53 }56 }
5457
58 if (!session.registerService(DBUS_SERVICE_LAUNCHER)) {
59 qWarning() << "The name" << DBUS_SERVICE_LAUNCHER << "is already taken on DBUS";
60 } else {
61 /* Set ourselves up to receive a method call from Software Center asking us to add
62 to favorites an application that is being installed and that the user requested
63 to be added. */
64 LauncherApplicationsListDBUS *dbusAdapter = new LauncherApplicationsListDBUS(this);
65 if (!session.registerObject(DBUS_OBJECT_LAUNCHER, dbusAdapter,
66 QDBusConnection::ExportAllSlots)) {
67 qWarning() << "The object" << DBUS_OBJECT_LAUNCHER << "on" << DBUS_SERVICE_LAUNCHER
68 << "is already present on DBUS.";
69 }
70 }
71
55 load();72 load();
56}73}
5774
5875
=== modified file 'launcher/UnityApplications/launcherapplicationslist.h'
--- launcher/UnityApplications/launcherapplicationslist.h 2011-03-11 14:56:13 +0000
+++ launcher/UnityApplications/launcherapplicationslist.h 2011-03-21 18:22:07 +0000
@@ -34,6 +34,7 @@
34class LauncherApplicationsList : public QAbstractListModel34class LauncherApplicationsList : public QAbstractListModel
35{35{
36 Q_OBJECT36 Q_OBJECT
37 friend class LauncherApplicationsListDBUS;
3738
38public:39public:
39 LauncherApplicationsList(QObject *parent = 0);40 LauncherApplicationsList(QObject *parent = 0);
4041
=== added file 'launcher/UnityApplications/launcherapplicationslistdbus.cpp'
--- launcher/UnityApplications/launcherapplicationslistdbus.cpp 1970-01-01 00:00:00 +0000
+++ launcher/UnityApplications/launcherapplicationslistdbus.cpp 2011-03-21 18:22:07 +0000
@@ -0,0 +1,30 @@
1#include "launcherapplication.h"
2#include "launcherapplicationslistdbus.h"
3#include "launcherapplicationslist.h"
4
5LauncherApplicationsListDBUS::LauncherApplicationsListDBUS(QObject *parent) :
6 QDBusAbstractAdaptor(parent)
7{
8}
9
10void
11LauncherApplicationsListDBUS::AddLauncherItemFromPosition(QString icon, QString title,
12 int icon_x, int icon_y, int icon_size,
13 QString desktop_file, QString aptdaemon_task)
14{
15 Q_UNUSED(icon)
16 Q_UNUSED(title)
17 Q_UNUSED(icon_x)
18 Q_UNUSED(icon_y)
19 Q_UNUSED(icon_size)
20 Q_UNUSED(aptdaemon_task)
21
22 LauncherApplicationsList* applicationsList = qobject_cast<LauncherApplicationsList*>(parent());
23 if (applicationsList != NULL && !desktop_file.isEmpty()) {
24 applicationsList->insertFavoriteApplication(desktop_file);
25 LauncherApplication *application = applicationsList->m_applicationForDesktopFile.value(desktop_file, NULL);
26 if (application != NULL) {
27 application->beginForceUrgent(1500);
28 }
29 }
30}
031
=== added file 'launcher/UnityApplications/launcherapplicationslistdbus.h'
--- launcher/UnityApplications/launcherapplicationslistdbus.h 1970-01-01 00:00:00 +0000
+++ launcher/UnityApplications/launcherapplicationslistdbus.h 2011-03-21 18:22:07 +0000
@@ -0,0 +1,22 @@
1#ifndef LAUNCHERAPPLICATIONSLISTDBUS_H
2#define LAUNCHERAPPLICATIONSLISTDBUS_H
3
4#include <QObject>
5#include <QtDBus/QDBusAbstractAdaptor>
6
7class LauncherApplicationsListDBUS : public QDBusAbstractAdaptor
8{
9 Q_OBJECT
10 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Launcher")
11
12public:
13 explicit LauncherApplicationsListDBUS(QObject *parent = 0);
14
15public Q_SLOTS:
16 void AddLauncherItemFromPosition(QString icon, QString title,
17 int icon_x, int icon_y, int icon_size,
18 QString desktop_file, QString aptdaemon_task);
19
20};
21
22#endif // LAUNCHERAPPLICATIONSLISTDBUS_H

Subscribers

People subscribed via source and target branches

to all changes: