Merge lp:~julien-spautz/slingshot/remove-unused-functions into lp:~elementary-pantheon/slingshot/trunk

Proposed by Julien Spautz on 2014-08-16
Status: Merged
Approved by: Cody Garver on 2014-08-31
Approved revision: 442
Merged at revision: 448
Proposed branch: lp:~julien-spautz/slingshot/remove-unused-functions
Merge into: lp:~elementary-pantheon/slingshot/trunk
Diff against target: 220 lines (+4/-109)
4 files modified
CMakeLists.txt (+0/-1)
src/Backend/AppSystem.vala (+3/-97)
src/Utils.vala (+1/-9)
src/Widgets/AppEntry.vala (+0/-2)
To merge this branch: bzr merge lp:~julien-spautz/slingshot/remove-unused-functions
Reviewer Review Type Date Requested Status
elementary Pantheon team 2014-08-16 Pending
Review via email: mp+231083@code.launchpad.net

Commit message

Removed some functions rendered useless by the new Synapse backend and minor code cleanup

Description of the change

Removed some functions rendered useless by the new synapse backend.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-06-12 09:36:00 +0000
3+++ CMakeLists.txt 2014-08-16 15:16:33 +0000
4@@ -127,4 +127,3 @@
5
6 # Translations
7 add_subdirectory (po)
8-
9
10=== modified file 'src/Backend/AppSystem.vala'
11--- src/Backend/AppSystem.vala 2014-06-12 09:36:00 +0000
12+++ src/Backend/AppSystem.vala 2014-08-16 15:16:33 +0000
13@@ -32,7 +32,6 @@
14 public signal void changed ();
15
16 construct {
17-
18 #if HAVE_ZEITGEIST
19 rl_service = new RelevancyService ();
20 rl_service.update_complete.connect (update_popularity);
21@@ -45,11 +44,9 @@
22 categories = new Gee.ArrayList<GMenu.TreeDirectory> ();
23
24 update_app_system ();
25-
26 }
27
28 private void update_app_system () {
29-
30 debug ("Updating Applications menu tree...");
31 #if HAVE_ZEITGEIST
32 rl_service.refresh_popularity ();
33@@ -64,11 +61,9 @@
34 update_apps ();
35
36 changed ();
37-
38 }
39
40 private void update_categories_index () {
41-
42 categories.clear ();
43
44 var iter = apps_menu.get_root_directory ().iter ();
45@@ -80,12 +75,10 @@
46 categories.add (dir);
47 }
48 }
49-
50 }
51
52 #if HAVE_ZEITGEIST
53 private void update_popularity () {
54-
55 foreach (Gee.ArrayList<App> category in apps.values)
56 foreach (App app in category)
57 app.popularity = rl_service.get_app_popularity (app.desktop_id);
58@@ -93,23 +86,16 @@
59 #endif
60
61 private void update_apps () {
62-
63 apps.clear ();
64-
65- foreach (var cat in categories) {
66+ foreach (var cat in categories)
67 apps.set (cat.get_name (), get_apps_by_category (cat));
68- }
69-
70 }
71
72 public Gee.ArrayList<GMenu.TreeDirectory> get_categories () {
73-
74 return categories;
75-
76 }
77
78 public Gee.ArrayList<App> get_apps_by_category (GMenu.TreeDirectory category) {
79-
80 var app_list = new Gee.ArrayList<App> ();
81
82 var iter = category.iter ();
83@@ -130,31 +116,13 @@
84 }
85
86 return app_list;
87-
88 }
89
90 public Gee.HashMap<string, Gee.ArrayList<App>> get_apps () {
91-
92 return apps;
93-
94- }
95-
96- public SList<App> get_apps_by_popularity () {
97-
98- var sorted_apps = new SList<App> ();
99-
100- foreach (Gee.ArrayList<App> category in apps.values) {
101- foreach (App app in category) {
102- sorted_apps.insert_sorted_with_data (app, Utils.sort_apps_by_popularity);
103- }
104- }
105-
106- return sorted_apps;
107-
108 }
109
110 public SList<App> get_apps_by_name () {
111-
112 var sorted_apps = new SList<App> ();
113 string[] sorted_apps_execs = {};
114
115@@ -175,67 +143,5 @@
116 }
117
118 return sorted_apps;
119-
120- }
121-
122- public async Gee.ArrayList<App> search_results (string search) {
123-
124- Idle.add (search_results.callback, Priority.HIGH);
125- yield;
126-
127- var filtered = new Gee.ArrayList<App> ();
128-
129- /** It's a bit stupid algorithm, simply check if the char is present
130- * some of the App values, then assign it a double. This is very simple:
131- * if an App name coincide with the search string they have obvious the
132- * same length, then the fraction will be 1.0.
133- * I've added a small multiplier when matching to a exec name, to give
134- * more priority to app.name
135- **/
136- string[] sorted_apps_execs = {};
137-
138- foreach (Gee.ArrayList<App> category in apps.values) {
139- foreach (App app in category) {
140- if (!(app.exec in sorted_apps_execs)) {
141- sorted_apps_execs += app.exec;
142- if (app.name != null && search in app.name.down ()) {
143- if (search == app.name.down ()[0:search.length])
144- app.relevancy = 0.5 - app.popularity; // It must be minor than 1.0
145- else
146- app.relevancy = app.name.length / search.length - app.popularity;
147- filtered.add (app);
148- } else if (app.exec != null && search in app.exec.down ()) {
149- app.relevancy = app.exec.length / search.length * 10.0 - app.popularity;
150- filtered.add (app);
151- } else if (app.description != null && search in app.description.down ()) {
152- app.relevancy = app.description.length / search.length - app.popularity;
153- filtered.add (app);
154- } else if (app.generic_name != null && search in app.generic_name.down ()) {
155- app.relevancy = app.generic_name.length / search.length - app.popularity;
156- filtered.add (app);
157- } else if (app.keywords != null) {
158- app.relevancy = 0;
159- foreach (string keyword in app.keywords) {
160- foreach (string search_word in search.split (" ")) {
161- if (search_word in keyword.down ()) {
162- app.relevancy += (keyword.length / search_word.length) * (app.keywords.length / search.split (" ").length) - app.popularity;
163- filtered.add (app);
164- }
165- }
166- }
167- }
168- }
169- }
170- }
171-
172- filtered.sort ((a, b) => Utils.sort_apps_by_relevancy ((App) a, (App) b));
173-
174- if (filtered.size > 20) {
175- return (Gee.ArrayList<App>) filtered[0:20];
176- } else {
177- return filtered;
178- }
179-
180- }
181-
182-}
183+ }
184+}
185\ No newline at end of file
186
187=== modified file 'src/Utils.vala'
188--- src/Utils.vala 2013-08-15 11:14:46 +0000
189+++ src/Utils.vala 2014-08-16 15:16:33 +0000
190@@ -29,16 +29,8 @@
191 return widget;
192 }
193
194- public static int sort_apps_by_popularity (Backend.App a, Backend.App b) {
195- return (int) (b.popularity*1000 - a.popularity*1000);
196- }
197-
198 public static int sort_apps_by_name (Backend.App a, Backend.App b) {
199 return a.name.collate (b.name);
200 }
201-
202- public static int sort_apps_by_relevancy (Backend.App a, Backend.App b) {
203- return (int) (a.relevancy*1000 - b.relevancy*1000);
204- }
205 }
206-}
207+}
208\ No newline at end of file
209
210=== modified file 'src/Widgets/AppEntry.vala'
211--- src/Widgets/AppEntry.vala 2014-05-26 06:11:39 +0000
212+++ src/Widgets/AppEntry.vala 2014-08-16 15:16:33 +0000
213@@ -92,8 +92,6 @@
214 }
215
216 protected override bool draw (Cairo.Context cr) {
217-
218-
219 Gtk.Allocation size;
220 get_allocation (out size);
221

Subscribers

People subscribed via source and target branches