Merge lp:~gary-lasker/software-center/unity-launcher-integration-fixes into lp:software-center/5.2

Proposed by Gary Lasker
Status: Merged
Merged at revision: 3063
Proposed branch: lp:~gary-lasker/software-center/unity-launcher-integration-fixes
Merge into: lp:software-center/5.2
Diff against target: 308 lines (+83/-42)
7 files modified
softwarecenter/backend/installbackend_impl/aptd.py (+5/-3)
softwarecenter/backend/unitylauncher.py (+5/-5)
softwarecenter/enums.py (+3/-0)
softwarecenter/ui/gtk3/panes/availablepane.py (+47/-30)
softwarecenter/utils.py (+7/-1)
test/gtk3/test_unity_launcher_integration.py (+2/-2)
test/test_utils.py (+14/-1)
To merge this branch: bzr merge lp:~gary-lasker/software-center/unity-launcher-integration-fixes
Reviewer Review Type Date Requested Status
Michael Vogt Needs Fixing
Matthew Paul Thomas Needs Fixing
Review via email: mp+109976@code.launchpad.net

Commit message

* lp:~gary-lasker/software-center/unity-launcher-integration-fixes:
   - fix bug where for-purchase items are not being added to the Unity
     launcher (LP: #925014)
   - fix bug where the Unity launcher item for an application incorrectly
     points to its app-install-data desktop file rather than its installed
     desktop file (LP: #999427)
   - fix bug where an application's icon remains in the Unity launcher after
     the corresponding application has been uninstalled (LP: #981488)
   - fix bug where the Unity launcher fails to auto-hide after installation
     of a for-purchase item (LP: #1002440)
   - fix bug where items in the "Independent" section are not being added
     to the Unity launcher (LP: #1012877)

Description of the change

This branch delays the firing of the add-to-Unity-launcher dbus call until the corresponding application install has completed. By doing this, Software Center is able to determine the actual installed desktop file path as well as the correct icon path for the installed application (the latter now also works for purchased applications whose icons are stored in the user's software-center cache directory).

This branch fixes five important bugs and obviates the need for immediate corresponding fixes on the Unity side.

The bugs are:

  Bug 925014 - Purchased items are not being added to the Unity launcher
  Bug 999427 - Launcher items added via Ubuntu Software Center incorrectly point to the app-install desktop files rather than the actual installed desktop files
  Bug 981488 - Program's icon stays in Launcher after removing the program
  Bug 1002440 - Unity Launcher Fails To Auto-Hide When Enabled & Installing Commercial Software
  Bug 1012877 - Applications in the "Independent" section are not being added to the Unity launcher

Please see comment #11 of bug 925014 for discussion of this fix with Bilal on the Unity side.

The downside to this fix is that the icon is added at the end of the install now (upon receipt of the "transaction-complete" signal from aptdaemon), and so the "installing" animation in the Unity launcher will no longer occur. This seems a small price to pay, however, to be able to have the five bugs above fixed quickly and in a straightforward manner, fully on the Software Center side.

In addition, this will buy us any time that we may need to fix these bugs on the Unity side, and once this is done we will have the freedom to revert this change and return to the current behavior.

Note that with current Unity version, the newly-added icon will have the tooltip "Waiting to Install". Bilal has a fix for this, please see bug 925014 for his branch and its status.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your work on this branch.

The code looks good, I like the fact that we have a fake PURCHASE_TRANSACTION_ID now
in enums for example.

One minor nitpick would be that I liked that we had a seperate function in 5.0 _register_unity_launcher_transaction_started() for on_transaction_started(). But
given how small it is now its probably not needed.

During manual testing I noticed a delay for up to 20s between the finish of the install and the fly-in animation. This needs to be investigated before this can be merged.
I reproduced this delay on both my quantal box and on precise (to ensure that its not a quantal artifact).

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Ideally, the Launcher item should appear as soon as the download begins. By the time installation finishes, you might have queued up several other things to install or remove, or even closed USC altogether.

In the short term, though, I guess for an item to show up in the Launcher five minutes late is still better than not showing up at all.

I tried r3054 of this branch with Qreator and with IntelliJ IDEA Community Edition.

It did not work at all with Qreator.

With IntelliJ, the Launcher item appeared about ten seconds after installation finished, but its tooltip said "Waiting to install".

review: Needs Fixing
Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hey mpt and mvo! Thanks for the reviews.

Regarding the "waiting to install", that's a one line fix in Unity that Bilal already has a branch in review for (I mentioned it above, see the last paragraph of my MP description).

The dbus signal to Unity is fired by Software Center immediately at the end of install. Any delay from that moment is due to issues in the Unity side. To be specific, I have found that the animation on my machine doesn't happen until I actually "show" my hidden launcher. It's important to note that this is not a regression with this branch, I verified the exact same behavior with current software-center 5.2.2.2 in precise. So it appears to be a regression in Unity, which I will report. Is this the "delay" that you are seeing?

As I said, Software Center fires the dbus signal immediately at the end of the install. If Unity does its work, the animation will happen at that exact moment.

Michael, I didn't use the old code as a model but since I remember very well how it worked I just implemented it directly based on what we have now. While implementing I was thinking about making the registering an explicit method and I agree it's nicer, so I'll make that change. Thank you for the suggestion and for noticing it in the old code!

mpt, I don't see anything like "5 minutes later", unless the install takes 5 minutes (which I am assuming to be the case). But, let's be fair, quick installs add the launcher quickly, with the caveat that I mentioned above about the Launcher unhiding. But that is not related to this fix (as I mentioned above) as it also happens in the released USC. I'll test the packages that you tried to see why Qreater didn't get added.

For the record, I tested this carefully for many cases:

  1. normal installs from the Ubuntu archive
  2. multiple simultaneous installs from the Ubuntu archive
  3. a new purchase
  4. reinstalls of previous purchases

So, I'd like to be clear about what "needs fixing". Based on what I see above, this looks like:

  1. Make the _register_unity_launcher_transaction_started() improvement.
  2. Unity lands and SRUs the "Waiting to install" fix. However, that is outside the scope of this MP and I personally feel this should *not* delay our releasing this current fix as is as it takes care of so many high-target bugs for which we are understandably under a lot of pressure to fix. The Waiting to install message is annoying and ugly, but it's far less annoying and ugly than the bugs being fixed. And this message is cleared after a restart, so it's not permanent.
  3. Verify and figure out why Qreator is not being added. I did not hit this issue with any of the applications that I tested with so this may just be an issue with Qreator
  4. The launcher "unhide" needed before animation. Again, this is not in scope for this SRU as it is also the case even in released USC in Precise right now.

Sound good?

Revision history for this message
Michael Vogt (mvo) wrote :
Download full text (4.0 KiB)

On Wed, Jun 13, 2012 at 01:39:28PM -0000, Gary Lasker wrote:
> Hey mpt and mvo! Thanks for the reviews.
Hi Gary,

thanks for your feedback.

> Regarding the "waiting to install", that's a one line fix in Unity
> that Bilal already has a branch in review for (I mentioned it above,
> see the last paragraph of my MP description).

Yeah, we need to case the unity team to see if/why that merge is
blocked and if there is anything we can do to help getting this
unblocked.

> The dbus signal to Unity is fired by Software Center immediately at
> the end of install. Any delay from that moment is due to issues in
> the Unity side. To be specific, I have found that the animation on
> my machine doesn't happen until I actually "show" my hidden
> launcher. It's important to note that this is not a regression with
> this branch, I verified the exact same behavior with current
> software-center 5.2.2.2 in precise. So it appears to be a regression
> in Unity, which I will report. Is this the "delay" that you are
> seeing?

Yes, that is the delay I'm seeing. Its rather odd and needs
investigation and a bugreport for unity. With that delay the UI looks
rather odd, I had a 20s delay between USC telling me that the app is
installed before it was going to the launcher. Before this was also
there but it was mitigated because the install was usually still in
progress.

> Michael, I didn't use the old code as a model but since I remember
> very well how it worked I just implemented it directly based on what
> we have now. While implementing I was thinking about making the
> registering an explicit method and I agree it's nicer, so I'll make
> that change. Thank you for the suggestion and for noticing it in the
> old code!

Like I said in the review, its really minor and not a blocker.

> So, I'd like to be clear about what "needs fixing". Based on what I see above, this looks like:
>
> 1. Make the _register_unity_launcher_transaction_started()
> improvement.

Low priority, not a blocker (but a low hanging fruit).

> 2. Unity lands and SRUs the "Waiting to install" fix. However,
> that is outside the scope of this MP and I personally feel this
> should *not* delay our releasing this current fix as is as it takes
> care of so many high-target bugs for which we are understandably
> under a lot of pressure to fix. The Waiting to install message is
> annoying and ugly, but it's far less annoying and ugly than the bugs
> being fixed. And this message is cleared after a restart, so it's
> not permanent.

It makes the experience look unpolished, so we need to get in touch
with the unity guys and get information about if there is anything
that is blocking that merge and what we can do to help (and also what
SRU this can go into).

> 3. Verify and figure out why Qreator is not being added. I did not
> hit this issue with any of the applications that I tested with so
> this may just be an issue with Qreator

Yes, that needs investigation, I think its just the fact that it comes
from extras and that our guessing code is not smart enough in this
case. A good fix would be to look at /var/lib/dpkg/info/$pkgname.list
for any desktop file in there if $pkgname.desktop ...

Read more...

3055. By Gary Lasker

REFACTOR: just make a _register_unity_launcher_transaction_started() method. it's nicer

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Interestingly, Qreator's desktop file is named "extras-qreator.desktop", and so yes, our guessing code is not good enough, but it seems that all (two) of the current packages in "Independent" have their desktop file name prepended with "extras-" in the form:

  extras-<pkgname>.desktop

So it seems a convention (sample size of 2) and I'll just add this to the guessing code as this ony applies to purchased and ARB apps only and this has been reliable for purchased apps for cycles now, so adding the extras check should take care of those cases similarly. I've added this now and it seems to work fine, and will write a new bug for this case.

Indeed, /var/lib/dpkg/info/qreator.list has the correct name for the desktop file, so if we decide we do need to parse these files we can do that in a separate branch, as you suggested.

3056. By Gary Lasker

also fix the bug where apps in extras.ubuntu.com are not being added to the Unity launcher, thanks mpt for finding this

3057. By Gary Lasker

add the actual bug number in the comment

Revision history for this message
Gary Lasker (gary-lasker) wrote :

I added bug 1012877 for the case of apps in the extras.ubuntu.com section, this is how also fixed in this branch.

3058. By Gary Lasker

send an empty string for the transaction ID value, this is expected in Bilal's corresponding Unity-side fix at lp:~bilalakhtar/unity/waiting-to-install-tooltip-925014

Revision history for this message
Gary Lasker (gary-lasker) wrote :

I took at look at Bilal's Unity side fix at https://code.launchpad.net/~bilalakhtar/unity/waiting-to-install-tooltip-925014/+merge/108858, and it looks to me to be approved now and ready for merging.

I noticed that his code is expecting an empty value for the transaction ID in the launcher dbus call in order to avoid displaying the "Waiting to install" tooltip, so I made that supporting change in this branch. Note that since we are firing the dbus call at the very end of the transaction now, this value will have no use at the launcher side anyway.

I've included a TODO in the code to document this for when we need to change this back.

Revision history for this message
Gary Lasker (gary-lasker) wrote :

I've submitted a new bug for the Unity team describing the delayed "fly to launcher" behavior when the Unity launcher is set to auto-hide. It's bug 1012896.

Revision history for this message
Bilal Akhtar (bilalakhtar) wrote :

I've fixed the delay bug in this branch:

https://code.launchpad.net/~bilalakhtar/unity/5.0series-sru-software-center-integration-fixes/+merge/110214

That branch also contains the fix to the Waiting to install tooltip and the "launcher stays stuck in revealed mode" bug.

Revision history for this message
Michael Vogt (mvo) wrote :

On Wed, Jun 13, 2012 at 09:20:26PM -0000, Gary Lasker wrote:
> Interestingly, Qreator's desktop file is named "extras-qreator.desktop", and so yes, our guessing code is not good enough, but it seems that all (two) of the current packages in "Independent" have their desktop file name prepended with "extras-" in the form:
>
> extras-<pkgname>.desktop
>
> So it seems a convention (sample size of 2) and I'll just add this to the guessing code as this ony applies to purchased and ARB apps only and this has been reliable for purchased apps for cycles now, so adding the extras check should take care of those cases similarly. I've added this now and it seems to work fine, and will write a new bug for this case.

Yeah, that is the convention for extras.ubuntu.com, thanks for fixing it.

> Indeed, /var/lib/dpkg/info/qreator.list has the correct name for the desktop file, so if we decide we do need to parse these files we can do that in a separate branch, as you suggested.

Could you please file a bug about this so that we can keep track of
it? This would fix it for all cases when we can't guess the desktop
file from the pkgname (unless there are multiple desktop files in the
package in which case we will have to guess or add them all ;).

Cheers,
 Michael

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Bilal, I just want to say thank you very much for your super-fast response in making the needed fixes on the Unity side. :) As always, I very much appreciate your dedication and your good work!!

My best to you,
Gary

Revision history for this message
Gary Lasker (gary-lasker) wrote :

I have a note in to didrocks to try to help get Bilal's branch reviewed and to get an idea about the timeline for when we can expect the fix to appear in a Unity Precise SRU.

Revision history for this message
Michael Vogt (mvo) wrote :

Thanks Gary, that is great to hear.

I will unset the "Needs fixing" as the branch is fine and ready. Given that we need to wait for the current SRU I think the approach to get the timeline for a unity SRU and sync with that (if its not in the too distant future) is the best approach.

Revision history for this message
Michael Vogt (mvo) :
review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :
Revision history for this message
Gary Lasker (gary-lasker) wrote :

I removed bug 946789 and bug 993224 from the changelog set and from the description as, although these are fixed as a side effect of the fix in the branch, the proper and final fix for these will be to have the Unity launcher service monitor all of the installation events from aptdaemon and to react to them accordingly. Since this work on the Unity side is being tracked in bug 1011681, I have marked the above two bugs as duplicates of that one.

Revision history for this message
Michael Vogt (mvo) wrote :

While we are waiting for the unity side, it would be great if you could address the points in:
https://code.launchpad.net/~gary-lasker/software-center/tech-items-to-launcher-fix-lp1006483/+merge/111135/comments/238731 to update the test to the new even sending behavior.

review: Needs Fixing
3059. By Gary Lasker

sync to latest 5.2 branch

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Hi Michael, please check the separate MP for the enhanced set of unit tests here:

  https://code.launchpad.net/~gary-lasker/software-center/launcher-integration-unit-tests/+merge/115236

Thanks!

Revision history for this message
Michael Vogt (mvo) wrote :

On Mon, Jul 16, 2012 at 10:03:18PM -0000, Gary Lasker wrote:
> Hi Michael, please check the separate MP for the enhanced set of unit tests here:
>
> https://code.launchpad.net/~gary-lasker/software-center/launcher-integration-unit-tests/+merge/115236

Thanks for your work on this. I commented in the above
merge-proposal. Its good that the tests are covering the start/end now
and that more of the desktop file cases are checked now. Unfortunately
there seems to be a issue with the patch not quite patching the right
spot (see the MP) so that _fake_send_application_to_launcher_and_check
is not called. That will need addressing before this can land.

Thanks,
 Michael

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'softwarecenter/backend/installbackend_impl/aptd.py'
--- softwarecenter/backend/installbackend_impl/aptd.py 2012-06-28 08:10:33 +0000
+++ softwarecenter/backend/installbackend_impl/aptd.py 2012-07-16 16:45:26 +0000
@@ -29,7 +29,7 @@
29 obfuscate_private_ppa_details,29 obfuscate_private_ppa_details,
30 utf8,30 utf8,
31 )31 )
32from softwarecenter.enums import TransactionTypes32from softwarecenter.enums import TransactionTypes, PURCHASE_TRANSACTION_ID
3333
34from aptdaemon import client34from aptdaemon import client
35from aptdaemon import enums35from aptdaemon import enums
@@ -67,11 +67,13 @@
6767
6868
69class FakePurchaseTransaction(object):69class FakePurchaseTransaction(object):
70
70 def __init__(self, app, iconname):71 def __init__(self, app, iconname):
71 self.pkgname = app.pkgname72 self.pkgname = app.pkgname
72 self.appname = app.appname73 self.appname = app.appname
73 self.iconname = iconname74 self.iconname = iconname
74 self.progress = 075 self.progress = 0
76 self.tid = PURCHASE_TRANSACTION_ID
7577
7678
77class AptdaemonTransaction(BaseTransaction):79class AptdaemonTransaction(BaseTransaction):
@@ -545,8 +547,6 @@
545 and finally installing the specified application once the547 and finally installing the specified application once the
546 package list reload has completed.548 package list reload has completed.
547 """549 """
548 self.emit("transaction-started", app.pkgname, app.appname,
549 "FIXME-NEED-ID-HERE", TransactionTypes.INSTALL)
550 self._logger.info("add_repo_add_key_and_install_app() '%s' '%s' '%s'" %550 self._logger.info("add_repo_add_key_and_install_app() '%s' '%s' '%s'" %
551 (re.sub("deb https://.*@", "", deb_line), # strip out password551 (re.sub("deb https://.*@", "", deb_line), # strip out password
552 signing_key_id,552 signing_key_id,
@@ -565,6 +565,8 @@
565 return565 return
566 # done566 # done
567 fake_trans = FakePurchaseTransaction(app, iconname)567 fake_trans = FakePurchaseTransaction(app, iconname)
568 self.emit("transaction-started", app.pkgname, app.appname,
569 fake_trans.tid, TransactionTypes.INSTALL)
568 self.pending_purchases[app.pkgname] = fake_trans570 self.pending_purchases[app.pkgname] = fake_trans
569 else:571 else:
570 # FIXME: add authenticate_for_added_repo here572 # FIXME: add authenticate_for_added_repo here
571573
=== modified file 'softwarecenter/backend/unitylauncher.py'
--- softwarecenter/backend/unitylauncher.py 2012-04-24 14:22:29 +0000
+++ softwarecenter/backend/unitylauncher.py 2012-07-16 16:45:26 +0000
@@ -33,7 +33,7 @@
33 icon_x,33 icon_x,
34 icon_y,34 icon_y,
35 icon_size,35 icon_size,
36 app_install_desktop_file_path,36 installed_desktop_file_path,
37 trans_id):37 trans_id):
38 self.name = name38 self.name = name
39 self.icon_name = icon_name39 self.icon_name = icon_name
@@ -41,7 +41,7 @@
41 self.icon_x = icon_x41 self.icon_x = icon_x
42 self.icon_y = icon_y42 self.icon_y = icon_y
43 self.icon_size = icon_size43 self.icon_size = icon_size
44 self.app_install_desktop_file_path = app_install_desktop_file_path44 self.installed_desktop_file_path = installed_desktop_file_path
45 self.trans_id = trans_id45 self.trans_id = trans_id
4646
4747
@@ -73,8 +73,8 @@
73 launcher_info.name)73 launcher_info.name)
74 LOG.debug(" launcher_info.icon_file_path: ",74 LOG.debug(" launcher_info.icon_file_path: ",
75 launcher_info.icon_file_path)75 launcher_info.icon_file_path)
76 LOG.debug(" launcher_info.app_install_desktop_file_path: ",76 LOG.debug(" launcher_info.installed_desktop_file_path: ",
77 launcher_info.app_install_desktop_file_path)77 launcher_info.installed_desktop_file_path)
78 LOG.debug(" launcher_info.trans_id: ", launcher_info.trans_id)78 LOG.debug(" launcher_info.trans_id: ", launcher_info.trans_id)
7979
80 try:80 try:
@@ -89,7 +89,7 @@
89 launcher_info.icon_x,89 launcher_info.icon_x,
90 launcher_info.icon_y,90 launcher_info.icon_y,
91 launcher_info.icon_size,91 launcher_info.icon_size,
92 launcher_info.app_install_desktop_file_path,92 launcher_info.installed_desktop_file_path,
93 launcher_info.trans_id)93 launcher_info.trans_id)
94 except Exception as e:94 except Exception as e:
95 LOG.warn("could not send dbus signal to the Unity launcher: (%s)",95 LOG.warn("could not send dbus signal to the Unity launcher: (%s)",
9696
=== modified file 'softwarecenter/enums.py'
--- softwarecenter/enums.py 2012-05-22 14:36:03 +0000
+++ softwarecenter/enums.py 2012-07-16 16:45:26 +0000
@@ -258,6 +258,9 @@
258#carousel app limit to override limit in .menu file for category258#carousel app limit to override limit in .menu file for category
259TOP_RATED_CAROUSEL_LIMIT = 12259TOP_RATED_CAROUSEL_LIMIT = 12
260260
261# Transaction ID for the "fake" purchase transaction
262PURCHASE_TRANSACTION_ID = "FakePurchaseTransactionID"
263
261from .version import VERSION, DISTRO, RELEASE, CODENAME264from .version import VERSION, DISTRO, RELEASE, CODENAME
262USER_AGENT = "Software Center/%s (N;) %s/%s (%s)" % (265USER_AGENT = "Software Center/%s (N;) %s/%s (%s)" % (
263 VERSION, DISTRO, RELEASE, CODENAME)266 VERSION, DISTRO, RELEASE, CODENAME)
264267
=== modified file 'softwarecenter/ui/gtk3/panes/availablepane.py'
--- softwarecenter/ui/gtk3/panes/availablepane.py 2012-06-28 08:10:33 +0000
+++ softwarecenter/ui/gtk3/panes/availablepane.py 2012-07-16 16:45:26 +0000
@@ -37,7 +37,8 @@
37from softwarecenter.paths import APP_INSTALL_PATH37from softwarecenter.paths import APP_INSTALL_PATH
38from softwarecenter.utils import (wait_for_apt_cache_ready,38from softwarecenter.utils import (wait_for_apt_cache_ready,
39 get_exec_line_from_desktop,39 get_exec_line_from_desktop,
40 get_file_path_from_iconname)40 get_file_path_from_iconname,
41 convert_desktop_file_to_installed_location)
41from softwarecenter.db.appfilter import AppFilter42from softwarecenter.db.appfilter import AppFilter
42from softwarecenter.db.database import Application43from softwarecenter.db.database import Application
4344
@@ -381,13 +382,8 @@
381382
382 def on_transaction_started(self, backend, pkgname, appname, trans_id,383 def on_transaction_started(self, backend, pkgname, appname, trans_id,
383 trans_type):384 trans_type):
384 # we only care about installs for the launcher, queue here for385 self._register_unity_launcher_transaction_started(pkgname, appname,
385 # later, see #972710386 trans_id, trans_type)
386 if trans_type == TransactionTypes.INSTALL:
387 transaction_details = TransactionDetails(
388 pkgname, appname, trans_id, trans_type)
389 self.unity_launcher_transaction_queue[pkgname] = (
390 transaction_details)
391387
392 def on_transactions_changed(self, backend, pending_transactions):388 def on_transactions_changed(self, backend, pending_transactions):
393 """internal helper that keeps the action bar up-to-date by389 """internal helper that keeps the action bar up-to-date by
@@ -395,61 +391,82 @@
395 """391 """
396 if self._is_custom_list_search(self.state.search_term):392 if self._is_custom_list_search(self.state.search_term):
397 self._update_action_bar()393 self._update_action_bar()
398 # add app to unity launcher on the first sign of progress
399 # and remove from the pending queue once that is done
400 for pkgname in pending_transactions:
401 if pkgname in self.unity_launcher_transaction_queue:
402 transaction_details = (
403 self.unity_launcher_transaction_queue.pop(pkgname))
404 self._add_application_to_unity_launcher(transaction_details)
405394
406 def on_transaction_complete(self, backend, result):395 def on_transaction_complete(self, backend, result):
407 if result.pkgname in self.unity_launcher_transaction_queue:396 if result.pkgname in self.unity_launcher_transaction_queue:
408 self.unity_launcher_transaction_queue.pop(result.pkgname)397 transaction_details = (
398 self.unity_launcher_transaction_queue.pop(result.pkgname))
399 self._add_application_to_unity_launcher(transaction_details)
400
401 def _register_unity_launcher_transaction_started(self, pkgname, appname,
402 trans_id, trans_type):
403 # at the start of the transaction, we gather details for use later
404 # when it is time to add the installed app to the Unity launcher,
405 # (see #972710). we only care about installs for the launcher
406 # mvo: use softwarecenter.utils explicitly here so that we can monkey
407 # patch it in the test
408 if (trans_type == TransactionTypes.INSTALL and
409 self.add_to_launcher_enabled and
410 softwarecenter.utils.is_unity_running()):
411 transaction_details = TransactionDetails(
412 pkgname, appname, trans_id, trans_type)
413 self.unity_launcher_transaction_queue[pkgname] = (
414 transaction_details)
409415
410 def _add_application_to_unity_launcher(self, transaction_details):416 def _add_application_to_unity_launcher(self, transaction_details):
411 if not self.add_to_launcher_enabled:
412 return
413 # mvo: use use softwarecenter.utils explicitly so that we can monkey
414 # patch it in the test
415 if not softwarecenter.utils.is_unity_running():
416 return
417
418 app = Application(pkgname=transaction_details.pkgname,417 app = Application(pkgname=transaction_details.pkgname,
419 appname=transaction_details.appname)418 appname=transaction_details.appname)
420 appdetails = app.get_details(self.db)419 appdetails = app.get_details(self.db)
420 # convert the app-install desktop file location to the actual installed
421 # desktop file location (or in the case of a purchased item from the
422 # agent, generate the correct installed desktop file location)
423 installed_desktop_file_path = (
424 convert_desktop_file_to_installed_location(appdetails.desktop_file,
425 app.pkgname))
421 # we only add items to the launcher that have a desktop file426 # we only add items to the launcher that have a desktop file
422 if not appdetails.desktop_file:427 if not installed_desktop_file_path:
423 return428 return
424 # do not add apps that have no Exec entry in their desktop file429 # do not add apps that have no Exec entry in their desktop file
425 # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras,430 # (e.g. wine, see LP: #848437 or ubuntu-restricted-extras,
426 # see LP: #913756)431 # see LP: #913756)
427 if (os.path.exists(appdetails.desktop_file) and432 if (os.path.exists(installed_desktop_file_path) and
428 not get_exec_line_from_desktop(appdetails.desktop_file)):433 not get_exec_line_from_desktop(installed_desktop_file_path)):
429 return434 return
430435
431 # now gather up the unity launcher info items and send the app to the436 # now gather up the unity launcher info items and send the app to the
432 # launcher service437 # launcher service
433 launcher_info = self._get_unity_launcher_info(app, appdetails,438 launcher_info = self._get_unity_launcher_info(app, appdetails,
439 installed_desktop_file_path,
434 transaction_details.trans_id)440 transaction_details.trans_id)
435 self.unity_launcher.send_application_to_launcher(441 self.unity_launcher.send_application_to_launcher(
436 transaction_details.pkgname,442 transaction_details.pkgname,
437 launcher_info)443 launcher_info)
438444
439 def _get_unity_launcher_info(self, app, appdetails, trans_id):445 def _get_unity_launcher_info(
446 self, app, appdetails, installed_desktop_file_path, trans_id):
440 (icon_size, icon_x, icon_y) = (447 (icon_size, icon_x, icon_y) = (
441 self._get_onscreen_icon_details_for_launcher_service(app))448 self._get_onscreen_icon_details_for_launcher_service(app))
442 icon_path = get_file_path_from_iconname(449 icon_path = get_file_path_from_iconname(
443 self.icons,450 self.icons,
444 iconname=appdetails.icon_file_name)451 iconname=appdetails.icon)
452 # Note that the transaction ID is not specified because we are firing
453 # the dbus signal at the very end of the installation now, and the
454 # corresponding fix in Unity is expecting this value to be empty (it
455 # would not be useful to the Unity launcher at this point anyway,
456 # as the corresponding transaction would be complete).
457 # Please see bug LP: #925014 and corresponding Unity branch for
458 # further details.
459 # TODO: If and when we re-implement firing the dbus signal at the
460 # start of the transaction, at that time we will need to replace
461 # the empty string below with the trans_id value.
445 launcher_info = UnityLauncherInfo(app.name,462 launcher_info = UnityLauncherInfo(app.name,
446 appdetails.icon,463 appdetails.icon,
447 icon_path,464 icon_path,
448 icon_x,465 icon_x,
449 icon_y,466 icon_y,
450 icon_size,467 icon_size,
451 appdetails.desktop_file,468 installed_desktop_file_path,
452 trans_id)469 "")
453 return launcher_info470 return launcher_info
454471
455 def _get_onscreen_icon_details_for_launcher_service(self, app):472 def _get_onscreen_icon_details_for_launcher_service(self, app):
456473
=== modified file 'softwarecenter/utils.py'
--- softwarecenter/utils.py 2012-05-24 08:55:44 +0000
+++ softwarecenter/utils.py 2012-07-16 16:45:26 +0000
@@ -430,12 +430,18 @@
430 if os.path.exists(installed_desktop_file_path):430 if os.path.exists(installed_desktop_file_path):
431 return installed_desktop_file_path431 return installed_desktop_file_path
432 # lastly, just try checking directly for the desktop file based on the432 # lastly, just try checking directly for the desktop file based on the
433 # pkgname itself433 # pkgname itself for the case of for-purchase items, etc.
434 if pkgname:434 if pkgname:
435 installed_desktop_file_path = "/usr/share/applications/%s.desktop" %\435 installed_desktop_file_path = "/usr/share/applications/%s.desktop" %\
436 pkgname436 pkgname
437 if os.path.exists(installed_desktop_file_path):437 if os.path.exists(installed_desktop_file_path):
438 return installed_desktop_file_path438 return installed_desktop_file_path
439 # files in the extras archive have their desktop filenames prepended
440 # by "extras-", so we check for that also (LP: #1012877)
441 extras_desktop_file_path = ("/usr/share/applications/"
442 "extras-%s.desktop" % pkgname)
443 if os.path.exists(extras_desktop_file_path):
444 return extras_desktop_file_path
439 LOG.warn("Could not determine the installed desktop file path for "445 LOG.warn("Could not determine the installed desktop file path for "
440 "app-install desktop file: '%s'" % app_install_data_file_path)446 "app-install desktop file: '%s'" % app_install_data_file_path)
441 return ""447 return ""
442448
=== modified file 'test/gtk3/test_unity_launcher_integration.py'
--- test/gtk3/test_unity_launcher_integration.py 2012-03-07 06:06:59 +0000
+++ test/gtk3/test_unity_launcher_integration.py 2012-07-16 16:45:26 +0000
@@ -87,8 +87,8 @@
87 # list view case) or 96 pixels (for the details view case)87 # list view case) or 96 pixels (for the details view case)
88 self.assertTrue(launcher_info.icon_size == 32 or88 self.assertTrue(launcher_info.icon_size == 32 or
89 launcher_info.icon_size == 96)89 launcher_info.icon_size == 96)
90 self.assertEqual(launcher_info.app_install_desktop_file_path,90 self.assertEqual(launcher_info.installed_desktop_file_path,
91 self.expected_launcher_info.app_install_desktop_file_path)91 self.expected_launcher_info.installed_desktop_file_path)
92 self.assertEqual(launcher_info.trans_id,92 self.assertEqual(launcher_info.trans_id,
93 self.expected_launcher_info.trans_id)93 self.expected_launcher_info.trans_id)
94 94
9595
=== modified file 'test/test_utils.py'
--- test/test_utils.py 2012-05-24 08:55:44 +0000
+++ test/test_utils.py 2012-07-16 16:45:26 +0000
@@ -18,8 +18,11 @@
18from softwarecenter.utils import (decode_xml_char_reference,18from softwarecenter.utils import (decode_xml_char_reference,
19 release_filename_in_lists_from_deb_line,19 release_filename_in_lists_from_deb_line,
20 get_http_proxy_string_from_libproxy,20 get_http_proxy_string_from_libproxy,
21 get_file_path_from_iconname,
21 )22 )
22from softwarecenter.testutils import do_events23from softwarecenter.testutils import (do_events,
24 get_test_gtk3_icon_cache,
25 )
2326
2427
25class TestSCUtils(unittest.TestCase):28class TestSCUtils(unittest.TestCase):
@@ -215,6 +218,16 @@
215 # cleanup218 # cleanup
216 shutil.rmtree(tmp)219 shutil.rmtree(tmp)
217220
221 def test_get_file_path_from_iconname(self):
222 icons = get_test_gtk3_icon_cache()
223 icon_path = get_file_path_from_iconname(
224 icons,
225 "softwarecenter")
226 self.assertEqual(
227 icon_path,
228 "/usr/share/icons/hicolor/48x48/apps/softwarecenter.svg")
229
230
218class TestExpungeCache(unittest.TestCase):231class TestExpungeCache(unittest.TestCase):
219232
220 def test_expunge_cache(self):233 def test_expunge_cache(self):

Subscribers

People subscribed via source and target branches