Merge lp:~mvo/software-center/fix-gmenu-searcher into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 2982
Proposed branch: lp:~mvo/software-center/fix-gmenu-searcher
Merge into: lp:software-center
Diff against target: 75 lines (+25/-5)
3 files modified
softwarecenter/db/pkginfo_impl/aptcache.py (+1/-0)
softwarecenter/ui/gtk3/gmenusearch.py (+8/-2)
test/test_where_is_it.py (+16/-3)
To merge this branch: bzr merge lp:~mvo/software-center/fix-gmenu-searcher
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+102461@code.launchpad.net

Description of the change

This branch fixes the menu searcher after the app-install-data-ubuntu file layout changed to "pkgname:filename.desktop". It also adds a regression test.

To test do not log into unity (e.g. gnome-panel, xfce, gnome-shell) and run "software-center gedit".
In current trunk you will see no indication where it is and with this branch the information is
there in the details page directly under the "Installed" label.

To post a comment you must log in.
2983. By Michael Vogt

pep8 fixes

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

Thanks mvo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/pkginfo_impl/aptcache.py'
2--- softwarecenter/db/pkginfo_impl/aptcache.py 2012-04-16 09:22:12 +0000
3+++ softwarecenter/db/pkginfo_impl/aptcache.py 2012-04-18 08:54:18 +0000
4@@ -234,6 +234,7 @@
5 def open(self):
6 """ (re)open the cache, this sends cache-invalid, cache-ready signals
7 """
8+ LOG.info("aptcache.open()")
9 self._ready = False
10 self.emit("cache-invalid")
11 from softwarecenter.utils import ExecutionTime
12
13=== modified file 'softwarecenter/ui/gtk3/gmenusearch.py'
14--- softwarecenter/ui/gtk3/gmenusearch.py 2012-03-15 09:32:18 +0000
15+++ softwarecenter/ui/gtk3/gmenusearch.py 2012-04-18 08:54:18 +0000
16@@ -82,8 +82,14 @@
17 root = tree.get_root_directory()
18 self._search_gmenu_dir([root],
19 os.path.basename(desktop_file))
20- if self._found:
21- return self._found
22+ # retry search for app-install-data desktop files
23+ if not self._found and ":" in os.path.basename(desktop_file):
24+ # the desktop files in app-install-data have a layout
25+ # like "pkg:file.desktop" so we need to take that into
26+ # account when searching
27+ desktop_file = os.path.basename(desktop_file).split(":")[1]
28+ self._search_gmenu_dir([root], desktop_file)
29+ return self._found
30
31
32 # these are the old static bindinds that are no longer required
33
34=== modified file 'test/test_where_is_it.py'
35--- test/test_where_is_it.py 2012-01-16 14:42:49 +0000
36+++ test/test_where_is_it.py 2012-04-18 08:54:18 +0000
37@@ -1,5 +1,6 @@
38 #!/usr/bin/python
39
40+import logging
41 import os
42 import unittest
43
44@@ -10,7 +11,7 @@
45 from softwarecenter.db.pkginfo import get_pkg_info
46 from softwarecenter.db.database import StoreDatabase
47 from softwarecenter.db.application import Application
48-
49+from softwarecenter.enums import PkgStates
50
51 class TestWhereIsit(unittest.TestCase):
52 """ tests the "where is it in the menu" code """
53@@ -74,8 +75,20 @@
54 self.assertEqual(found[1].get_icon().get_names()[0],
55 "applications-utilities")
56
57+ def test_where_is_it_real_system(self):
58+ app = Application("", "gedit")
59+ details = app.get_details(self.db)
60+ if details.pkg_state != PkgStates.INSTALLED:
61+ logging.warn("gedit not installed, skipping real menu test")
62+ self.skipTest("gedit not installed")
63+ return
64+ self.assertEqual(details.desktop_file,
65+ "/usr/share/app-install/desktop/gedit:gedit.desktop")
66+ # search the *real* menu
67+ searcher = GMenuSearcher()
68+ found = searcher.get_main_menu_path(details.desktop_file)
69+ self.assertNotEqual(found, None)
70
71 if __name__ == "__main__":
72- import logging
73- logging.basicConfig(level=logging.DEBUG)
74+ #logging.basicConfig(level=logging.DEBUG)
75 unittest.main()

Subscribers

People subscribed via source and target branches