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
=== modified file 'src/Backend/AppSystem.vala'
--- src/Backend/AppSystem.vala 2012-03-11 17:15:45 +0000
+++ src/Backend/AppSystem.vala 2012-04-25 19:37:18 +0000
@@ -163,10 +163,14 @@
163 public SList<App> get_apps_by_name () {163 public SList<App> get_apps_by_name () {
164164
165 var sorted_apps = new SList<App> ();165 var sorted_apps = new SList<App> ();
166 string[] sorted_apps_execs = {};
166167
167 foreach (ArrayList<App> category in apps.values) {168 foreach (ArrayList<App> category in apps.values) {
168 foreach (App app in category) {169 foreach (App app in category) {
169 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);170 if (!(app.exec in sorted_apps_execs)) {
171 sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_name);
172 sorted_apps_execs += app.exec;
173 }
170 }174 }
171 }175 }
172176
@@ -188,27 +192,29 @@
188 * I've added a small multiplier when matching to a exec name, to give192 * I've added a small multiplier when matching to a exec name, to give
189 * more priority to app.name193 * more priority to app.name
190 **/194 **/
195 string[] sorted_apps_execs = {};
191 foreach (ArrayList<App> category in apps.values) {196 foreach (ArrayList<App> category in apps.values) {
192 foreach (App app in category) {197 foreach (App app in category) {
193 198 if (!(app.exec in sorted_apps_execs)) {
194 if (search in app.name.down ()) {199 sorted_apps_execs += app.exec;
195 if (search == app.name.down ()[0:search.length])200 if (search in app.name.down ()) {
196 app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0201 if (search == app.name.down ()[0:search.length])
197 else202 app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0
198 app.relevancy = app.name.length / search.length - app.popularity;203 else
199 filtered.add (app);204 app.relevancy = app.name.length / search.length - app.popularity;
200 }205 filtered.add (app);
201206 }
202 else if (search in app.exec.down ()) {207
203 app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;208 else if (search in app.exec.down ()) {
204 filtered.add (app);209 app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;
205 }210 filtered.add (app);
206211 }
207 else if (search in app.description.down ()) {212
208 app.relevancy = app.description.length / search.length - app.popularity;213 else if (search in app.description.down ()) {
209 filtered.add (app);214 app.relevancy = app.description.length / search.length - app.popularity;
210 }215 filtered.add (app);
211216 }
217 }
212 }218 }
213 }219 }
214220

Subscribers

People subscribed via source and target branches