Merge lp:~stolowski/unity-lens-applications/reload-gmenu-on-change into lp:unity-lens-applications

Proposed by Paweł Stołowski
Status: Merged
Approved by: Michal Hruby
Approved revision: 320
Merged at revision: 320
Proposed branch: lp:~stolowski/unity-lens-applications/reload-gmenu-on-change
Merge into: lp:unity-lens-applications
Diff against target: 78 lines (+31/-11)
2 files modified
src/daemon.vala (+15/-11)
tests/manual/apps-lens-tests.txt (+16/-0)
To merge this branch: bzr merge lp:~stolowski/unity-lens-applications/reload-gmenu-on-change
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+137128@code.launchpad.net

Commit message

Reload gnome menu tree after receiving 'changed' signal. This is now required by gnome-menu-3.6.0 code.

Description of the change

Reload gnome menu tree after receiving 'changed' signal. This is now required by gnome-menu-3.6.0 code.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/daemon.vala'
2--- src/daemon.vala 2012-11-05 19:18:41 +0000
3+++ src/daemon.vala 2012-11-30 09:16:23 +0000
4@@ -357,26 +357,29 @@
5 app_menu = new GMenu.Tree ("unity-lens-applications.menu",
6 GMenu.TreeFlags.INCLUDE_NODISPLAY);
7
8- try
9- {
10- app_menu.load_sync (); //FIXME: libgnome-menu doesn't provide async method (yet?)
11- }
12- catch (GLib.Error e)
13- {
14- warning ("Failed to load menu entries: %s", e.message);
15- }
16-
17 app_menu.changed.connect (() => {
18 /* Reschedule the timeout if we already have one. The menu tree triggers
19 * many change events during app installation. This way we wait the full
20 * delay *after* the last change event has triggered */
21 if (app_menu_changed_reindex_timeout != 0)
22+ {
23 Source.remove (app_menu_changed_reindex_timeout);
24+ }
25
26 app_menu_changed_reindex_timeout = Timeout.add_seconds (5, build_app_menu_index_and_result_models);
27 });
28 }
29
30+ // gnome menu tree needs to be loaded on startup and after receiving 'changed' signal - see gmenu-tree.c in gnome-menus-3.6.0.
31+ try
32+ {
33+ app_menu.load_sync (); //FIXME: libgnome-menu doesn't provide async method (yet?)
34+ }
35+ catch (GLib.Error e)
36+ {
37+ warning ("Failed to load menu entries: %s", e.message);
38+ }
39+
40 debug ("Indexing application menu");
41 appsearcher = new Unity.Package.Searcher.for_menu (app_menu);
42 app_menu_changed_reindex_timeout = 0;
43@@ -385,8 +388,9 @@
44 }
45
46 /* Called when our app_menu structure changes - probably because something
47- * has been installed or removed. We rebuild the index and update the
48- * result models for global and scope. We need to update both because
49+ * has been installed or removed. We reload gnome menu tree,
50+ * rebuild the index and update the result models for global and scope.
51+ * We need to update both because
52 * we can't know exactly what Unity may be showing */
53 private bool build_app_menu_index_and_result_models ()
54 {
55
56=== modified file 'tests/manual/apps-lens-tests.txt'
57--- tests/manual/apps-lens-tests.txt 2012-10-12 12:05:51 +0000
58+++ tests/manual/apps-lens-tests.txt 2012-11-30 09:16:23 +0000
59@@ -40,3 +40,19 @@
60 Expected Result:
61 Open-source free applications display 'Free' string in ribbons in the search results. Their previews should have 'Developer site' and 'Free Download' buttons.
62 Commercial apps should have the price displayed in ribbons (e.g. 'US$ 8.40'). Their previews should have 'Developer site' and 'Buy US$ ...' buttons.
63+
64+Test updates to gnome menu structure
65+------------------------------------
66+Check that adding/removing applications updates applications lens contents.
67+
68+Setup:
69+At least default ubuntu applications installed.
70+
71+Actions:
72+Open the Dash and switch to the application lens.
73+Right-click one of free apps listed in 'More suggestions' category and install it via its preview.
74+Open the Dash and switch to the application lens again.
75+
76+Expected Result:
77+'Recently used', 'Installed', 'More suggestions' categories are displayed.
78+The new application is listed in the 'Installed' category (note: this may take a few seconds after installation finished).

Subscribers

People subscribed via source and target branches