Merge lp:~voluntatefaber/slingshot/bug919587 into lp:~elementary-pantheon/slingshot/trunk

Proposed by Andrea Basso
Status: Merged
Merged at revision: 171
Proposed branch: lp:~voluntatefaber/slingshot/bug919587
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 67 lines (+26/-20)
1 file modified
src/Backend/AppSystem.vala (+26/-20)
To merge this branch: bzr merge lp:~voluntatefaber/slingshot/bug919587
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+103548@code.launchpad.net
To post a comment you must log in.
170. By Andrea Basso

Slingshot now doesn't show duplicates in search as well

Revision history for this message
Cody Garver (codygarver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Backend/AppSystem.vala'
2--- src/Backend/AppSystem.vala 2012-03-11 17:15:45 +0000
3+++ src/Backend/AppSystem.vala 2012-04-25 19:37:18 +0000
4@@ -163,10 +163,14 @@
5 public SList<App> get_apps_by_name () {
6
7 var sorted_apps = new SList<App> ();
8+ string[] sorted_apps_execs = {};
9
10 foreach (ArrayList<App> category in apps.values) {
11 foreach (App app in category) {
12- sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
13+ if (!(app.exec in sorted_apps_execs)) {
14+ sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
15+ sorted_apps_execs += app.exec;
16+ }
17 }
18 }
19
20@@ -188,27 +192,29 @@
21 * I've added a small multiplier when matching to a exec name, to give
22 * more priority to app.name
23 **/
24+ string[] sorted_apps_execs = {};
25 foreach (ArrayList<App> category in apps.values) {
26 foreach (App app in category) {
27-
28- if (search in app.name.down ()) {
29- if (search == app.name.down ()[0:search.length])
30- app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0
31- else
32- app.relevancy = app.name.length / search.length - app.popularity;
33- filtered.add (app);
34- }
35-
36- else if (search in app.exec.down ()) {
37- app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;
38- filtered.add (app);
39- }
40-
41- else if (search in app.description.down ()) {
42- app.relevancy = app.description.length / search.length - app.popularity;
43- filtered.add (app);
44- }
45-
46+ if (!(app.exec in sorted_apps_execs)) {
47+ sorted_apps_execs += app.exec;
48+ if (search in app.name.down ()) {
49+ if (search == app.name.down ()[0:search.length])
50+ app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0
51+ else
52+ app.relevancy = app.name.length / search.length - app.popularity;
53+ filtered.add (app);
54+ }
55+
56+ else if (search in app.exec.down ()) {
57+ app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;
58+ filtered.add (app);
59+ }
60+
61+ else if (search in app.description.down ()) {
62+ app.relevancy = app.description.length / search.length - app.popularity;
63+ filtered.add (app);
64+ }
65+ }
66 }
67 }
68

Subscribers

People subscribed via source and target branches