Merge lp:~mefrio-g/light-software-center/libappstore-port into lp:light-software-center
- libappstore-port
- Merge into trunk
Proposed by
Mario Guerriero
Status: | Merged |
---|---|
Merged at revision: | 46 |
Proposed branch: | lp:~mefrio-g/light-software-center/libappstore-port |
Merge into: | lp:light-software-center |
Diff against target: |
653 lines (+54/-315) 8 files modified
build.sh (+1/-1) src/Backend/AppsManager.vala (+0/-207) src/Backend/Backend.vala (+0/-51) src/Frontend.vala (+21/-22) src/Widgets/InfoMessage.vala (+5/-6) src/Widgets/Pages/AppsInfo.vala (+13/-12) src/Widgets/Pages/AppsView.vala (+6/-7) src/Widgets/Pages/CategoriesView.vala (+8/-9) |
To merge this branch: | bzr merge lp:~mefrio-g/light-software-center/libappstore-port |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lubuntu Software Center Team | Pending | ||
Review via email: mp+117167@code.launchpad.net |
Commit message
Description of the change
This is a porting to libappstore lib
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 'build.sh' | |||
2 | --- build.sh 2012-07-10 16:27:53 +0000 | |||
3 | +++ build.sh 2012-07-28 20:36:19 +0000 | |||
4 | @@ -5,7 +5,7 @@ | |||
5 | 5 | echo -e "\t * libsqlheavy-dev" | 5 | echo -e "\t * libsqlheavy-dev" |
6 | 6 | 6 | ||
7 | 7 | 7 | ||
9 | 8 | VALAC_PKGS="--pkg gio-2.0 --pkg packagekit-glib2 --pkg gtk+-3.0 --pkg sqlheavy-0.1" | 8 | VALAC_PKGS="--pkg gio-2.0 --pkg packagekit-glib2 --pkg gtk+-3.0 --pkg sqlheavy-0.1 --pkg appstore" |
10 | 9 | VALAC_FLAGS="--vapidir=vapi/ -X | 9 | VALAC_FLAGS="--vapidir=vapi/ -X |
11 | 10 | -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE" | 10 | -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE" |
12 | 11 | BIN="light-software-center" | 11 | BIN="light-software-center" |
13 | 12 | 12 | ||
14 | === removed directory 'src/Backend' | |||
15 | === removed file 'src/Backend/AppsManager.vala' | |||
16 | --- src/Backend/AppsManager.vala 2012-07-12 14:59:00 +0000 | |||
17 | +++ src/Backend/AppsManager.vala 1970-01-01 00:00:00 +0000 | |||
18 | @@ -1,207 +0,0 @@ | |||
19 | 1 | // Copyright © 2012 Stephen Smally | ||
20 | 2 | // This program is free software; you can redistribute it and/or modify | ||
21 | 3 | // it under the terms of the GNU General Public License as published by | ||
22 | 4 | // the Free Software Foundation; either version 2 of the License, or | ||
23 | 5 | // (at your option) any later version. | ||
24 | 6 | // | ||
25 | 7 | // This program is distributed in the hope that it will be useful, | ||
26 | 8 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 9 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 10 | // GNU General Public License for more details. | ||
29 | 11 | // | ||
30 | 12 | // You should have received a copy of the GNU General Public License | ||
31 | 13 | // along with this program; if not, write to the Free Software | ||
32 | 14 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
33 | 15 | // MA 02110-1301, USA. | ||
34 | 16 | // | ||
35 | 17 | |||
36 | 18 | using PackageKit; | ||
37 | 19 | using SQLHeavy; | ||
38 | 20 | |||
39 | 21 | namespace Lsc.Backend { | ||
40 | 22 | public class AppsManager : Object { | ||
41 | 23 | // Signals | ||
42 | 24 | public signal void app_added (LscApp app); | ||
43 | 25 | public signal void category_added (LscCategory cat); | ||
44 | 26 | public signal void loading_started (LoadingType load, string text); | ||
45 | 27 | public signal void loading_finished (LoadingType load); | ||
46 | 28 | public signal void loading_progress (int percentage); | ||
47 | 29 | public signal void details_received (LscApp app, Package pkg, Details details); | ||
48 | 30 | |||
49 | 31 | // PackageKit stuffs | ||
50 | 32 | private Client client; | ||
51 | 33 | private Control control; | ||
52 | 34 | private Task task; | ||
53 | 35 | private Cancellable transaction; | ||
54 | 36 | |||
55 | 37 | // SQLHeavy stuffs | ||
56 | 38 | private Database database; | ||
57 | 39 | |||
58 | 40 | public void remove_packages (string[] ids, bool deps, bool auto) { | ||
59 | 41 | loading_started (LoadingType.REMOVE, "Removing packages..."); | ||
60 | 42 | task.remove_packages_async (ids, | ||
61 | 43 | deps, | ||
62 | 44 | auto, | ||
63 | 45 | null, | ||
64 | 46 | (p) => { | ||
65 | 47 | if (p.percentage != -1) { | ||
66 | 48 | loading_progress (p.percentage); | ||
67 | 49 | } | ||
68 | 50 | }, | ||
69 | 51 | () => { | ||
70 | 52 | loading_finished (LoadingType.REMOVE); | ||
71 | 53 | }); | ||
72 | 54 | } | ||
73 | 55 | |||
74 | 56 | public void install_packages (string[] ids) { | ||
75 | 57 | loading_started (LoadingType.INSTALL, "Installing packages..."); | ||
76 | 58 | task.install_packages_async (ids, | ||
77 | 59 | null, | ||
78 | 60 | (p) => { | ||
79 | 61 | if (p.percentage != -1) { | ||
80 | 62 | loading_progress (p.percentage); | ||
81 | 63 | } | ||
82 | 64 | }, | ||
83 | 65 | () => { | ||
84 | 66 | loading_finished (LoadingType.INSTALL); | ||
85 | 67 | }); | ||
86 | 68 | } | ||
87 | 69 | |||
88 | 70 | public void get_pkgs (string category) { | ||
89 | 71 | try { | ||
90 | 72 | Query get_query = database.prepare ("SELECT * FROM '%s';".printf (category)); | ||
91 | 73 | QueryResult result = get_query.execute (); | ||
92 | 74 | |||
93 | 75 | for (int record = 1; ! result.finished; record++, result.next ()) { | ||
94 | 76 | app_added (new LscApp ( | ||
95 | 77 | result.fetch_string (0), | ||
96 | 78 | result.fetch_string (1), | ||
97 | 79 | result.fetch_string (2), | ||
98 | 80 | result.fetch_string (3))); | ||
99 | 81 | //if ("x" in result.fetch_string (0)) | ||
100 | 82 | //stdout.printf ("\n%s", result.fetch_string (0)); | ||
101 | 83 | } | ||
102 | 84 | } catch (GLib.Error e) { | ||
103 | 85 | GLib.error ("Error retrieving packages: %s\n", e.message); | ||
104 | 86 | } | ||
105 | 87 | |||
106 | 88 | } | ||
107 | 89 | |||
108 | 90 | private void get_details_2 (LscApp pkg, Package p) { | ||
109 | 91 | client.get_details_async({p.get_id(), null}, | ||
110 | 92 | null, | ||
111 | 93 | () => { | ||
112 | 94 | while (Gtk.events_pending()) { | ||
113 | 95 | Gtk.main_iteration(); | ||
114 | 96 | } | ||
115 | 97 | }, | ||
116 | 98 | (obj, resu) => { | ||
117 | 99 | try { | ||
118 | 100 | Results res = client.generic_finish (resu); | ||
119 | 101 | details_received (pkg, p, res.get_details_array()[0]); | ||
120 | 102 | } catch (GLib.Error e) { | ||
121 | 103 | stderr.printf ("ERROR! %s\n", e.message); | ||
122 | 104 | } | ||
123 | 105 | loading_finished (LoadingType.DETAILS); | ||
124 | 106 | } | ||
125 | 107 | ); | ||
126 | 108 | } | ||
127 | 109 | |||
128 | 110 | public void get_details (LscApp pkg) { | ||
129 | 111 | loading_started (LoadingType.DETAILS, "Loading infos..."); | ||
130 | 112 | client.resolve_async(0, | ||
131 | 113 | {pkg.id, null}, | ||
132 | 114 | null, | ||
133 | 115 | () => { | ||
134 | 116 | while (Gtk.events_pending()) { | ||
135 | 117 | Gtk.main_iteration(); | ||
136 | 118 | } | ||
137 | 119 | }, | ||
138 | 120 | (obj, resu) => { | ||
139 | 121 | try { | ||
140 | 122 | Results res = client.generic_finish (resu); | ||
141 | 123 | get_details_2 (pkg, res.get_package_array()[0]); | ||
142 | 124 | } catch (GLib.Error e) { | ||
143 | 125 | stdout.printf ("ERROR! %s\n", e.message); | ||
144 | 126 | } | ||
145 | 127 | }); | ||
146 | 128 | } | ||
147 | 129 | |||
148 | 130 | private int count_category (string category) { | ||
149 | 131 | try { | ||
150 | 132 | Query q = database.prepare ("SELECT COUNT (*) FROM '%s';".printf (category)); | ||
151 | 133 | QueryResult r = q.execute(); | ||
152 | 134 | return r.fetch_int (0); | ||
153 | 135 | } catch (GLib.Error e) { | ||
154 | 136 | stdout.printf ("ERROR! %s\n", e.message); | ||
155 | 137 | } | ||
156 | 138 | return -1; | ||
157 | 139 | } | ||
158 | 140 | |||
159 | 141 | public void get_categories () { | ||
160 | 142 | loading_started(LoadingType.CATEGORIES, "Loading categories..."); | ||
161 | 143 | try { | ||
162 | 144 | Query cat_query = database.prepare ("SELECT * FROM 'DIRECTORIES';"); | ||
163 | 145 | QueryResult result = cat_query.execute (); | ||
164 | 146 | |||
165 | 147 | for (int record = 1; ! result.finished; record++, result.next ()) { | ||
166 | 148 | category_added (new LscCategory (result.fetch_string (0), | ||
167 | 149 | result.fetch_string (1), | ||
168 | 150 | result.fetch_string (2), | ||
169 | 151 | result.fetch_string (3), | ||
170 | 152 | count_category (result.fetch_string (0)))); | ||
171 | 153 | } | ||
172 | 154 | } catch (GLib.Error e) { | ||
173 | 155 | GLib.error ("Error retrieving packages: %s\n", e.message); | ||
174 | 156 | } | ||
175 | 157 | |||
176 | 158 | loading_finished(LoadingType.CATEGORIES); | ||
177 | 159 | } | ||
178 | 160 | |||
179 | 161 | public void search_for_apps (string search_string) { | ||
180 | 162 | |||
181 | 163 | // Categories | ||
182 | 164 | try { | ||
183 | 165 | Query get_query = database.prepare ("SELECT * FROM 'DIRECTORIES';"); | ||
184 | 166 | QueryResult result = get_query.execute (); | ||
185 | 167 | |||
186 | 168 | // Foreach category | ||
187 | 169 | for (int record = 1; ! result.finished; record++, result.next ()) { | ||
188 | 170 | // Check for a package | ||
189 | 171 | stdout.printf ("\n%s", result.fetch_string (0)); | ||
190 | 172 | try { | ||
191 | 173 | get_query = database.prepare ("SELECT * FROM '%s';".printf (result.fetch_string (0))); | ||
192 | 174 | result = get_query.execute (); | ||
193 | 175 | |||
194 | 176 | for (record = 1; ! result.finished; record++, result.next ()) { | ||
195 | 177 | if (search_string in result.fetch_string (0)) // If something is found let's send the application | ||
196 | 178 | app_added (new LscApp ( | ||
197 | 179 | result.fetch_string (0), | ||
198 | 180 | result.fetch_string (1), | ||
199 | 181 | result.fetch_string (2), | ||
200 | 182 | result.fetch_string (3))); | ||
201 | 183 | } | ||
202 | 184 | } catch (GLib.Error e) { | ||
203 | 185 | GLib.error ("Error retrieving packages: %s\n", e.message); | ||
204 | 186 | } | ||
205 | 187 | } | ||
206 | 188 | } catch (GLib.Error e) { | ||
207 | 189 | GLib.error ("Error retrieving packages: %s\n", e.message); | ||
208 | 190 | } | ||
209 | 191 | } | ||
210 | 192 | |||
211 | 193 | public AppsManager () { | ||
212 | 194 | client = new Client(); | ||
213 | 195 | control = new Control(); | ||
214 | 196 | task = new Task(); | ||
215 | 197 | transaction = new Cancellable(); | ||
216 | 198 | stdout.printf ("Cache age: %ld\n", client.get_cache_age()); | ||
217 | 199 | |||
218 | 200 | try { | ||
219 | 201 | database = new Database ("/var/cache/lsc-vala.db", FileMode.READ); | ||
220 | 202 | } catch (GLib.Error e) { | ||
221 | 203 | GLib.error ("Error opening the database: %s\nPlease run 'lsc-db-build -d /var/cache/lsc-packages.db' as root", e.message); | ||
222 | 204 | } | ||
223 | 205 | } | ||
224 | 206 | } | ||
225 | 207 | } | ||
226 | 208 | 0 | ||
227 | === removed file 'src/Backend/Backend.vala' | |||
228 | --- src/Backend/Backend.vala 2012-07-12 09:21:39 +0000 | |||
229 | +++ src/Backend/Backend.vala 1970-01-01 00:00:00 +0000 | |||
230 | @@ -1,51 +0,0 @@ | |||
231 | 1 | |||
232 | 2 | namespace Lsc.Backend { | ||
233 | 3 | public enum LoadingType { | ||
234 | 4 | PACKAGES, // Loaded packages | ||
235 | 5 | CATEGORIES, // Loaded categories | ||
236 | 6 | DETAILS, // Loading details | ||
237 | 7 | INSTALL, | ||
238 | 8 | REMOVE, // Installed or so | ||
239 | 9 | SEARCH; // When it is searching apps | ||
240 | 10 | } | ||
241 | 11 | |||
242 | 12 | public enum ActionType { | ||
243 | 13 | INSTALL, | ||
244 | 14 | REMOVE; | ||
245 | 15 | } | ||
246 | 16 | |||
247 | 17 | public enum ResponseId { | ||
248 | 18 | INFO, | ||
249 | 19 | INSTALL; | ||
250 | 20 | } | ||
251 | 21 | |||
252 | 22 | public class LscCategory : Object { | ||
253 | 23 | public string id; | ||
254 | 24 | public string name; | ||
255 | 25 | public string summary; | ||
256 | 26 | public string icon; | ||
257 | 27 | public int records; | ||
258 | 28 | |||
259 | 29 | public LscCategory (string id, string name, string summary, string icon, int records = 0) { | ||
260 | 30 | this.id = id; | ||
261 | 31 | this.name = name; | ||
262 | 32 | this.summary = summary; | ||
263 | 33 | this.icon = icon; | ||
264 | 34 | this.records = records; | ||
265 | 35 | } | ||
266 | 36 | } | ||
267 | 37 | |||
268 | 38 | public class LscApp : Object { | ||
269 | 39 | public string id { get; private set; } // A valid id retrieved from a PkPackage | ||
270 | 40 | public string name { get; private set; } | ||
271 | 41 | public string summary { get; private set; } | ||
272 | 42 | public string icon { get; set; } | ||
273 | 43 | |||
274 | 44 | public LscApp (string id, string name, string summary, string icon) { | ||
275 | 45 | this.id = id; | ||
276 | 46 | this.name = name; | ||
277 | 47 | this.summary = summary; | ||
278 | 48 | this.icon = icon; | ||
279 | 49 | } | ||
280 | 50 | } | ||
281 | 51 | } | ||
282 | 52 | 0 | ||
283 | === modified file 'src/Frontend.vala' | |||
284 | --- src/Frontend.vala 2012-07-12 09:21:39 +0000 | |||
285 | +++ src/Frontend.vala 2012-07-28 20:36:19 +0000 | |||
286 | @@ -16,14 +16,13 @@ | |||
287 | 16 | // | 16 | // |
288 | 17 | 17 | ||
289 | 18 | using Gtk; | 18 | using Gtk; |
290 | 19 | using Lsc.Backend; | ||
291 | 20 | using Lsc.Utils; | 19 | using Lsc.Utils; |
292 | 21 | using Lsc.Widgets; | 20 | using Lsc.Widgets; |
293 | 22 | 21 | ||
294 | 23 | namespace Lsc { | 22 | namespace Lsc { |
295 | 24 | // Elements which should be accessible to every void or class | 23 | // Elements which should be accessible to every void or class |
298 | 25 | public LscCategory last_category; | 24 | public AppStore.Category last_category; |
299 | 26 | public LscApp last_app; | 25 | public AppStore.ModelApp last_app; |
300 | 27 | 26 | ||
301 | 28 | public enum PageType { | 27 | public enum PageType { |
302 | 29 | HOMEPAGE, | 28 | HOMEPAGE, |
303 | @@ -49,7 +48,7 @@ | |||
304 | 49 | } | 48 | } |
305 | 50 | 49 | ||
306 | 51 | // Apps Manager which handle the PackageKit connection | 50 | // Apps Manager which handle the PackageKit connection |
308 | 52 | public AppsManager apps_manager; | 51 | public AppStore.AppsManager apps_manager; |
309 | 53 | 52 | ||
310 | 54 | public class Frontend : Window { | 53 | public class Frontend : Window { |
311 | 55 | // Widgets | 54 | // Widgets |
312 | @@ -64,7 +63,7 @@ | |||
313 | 64 | private int _width = 0; | 63 | private int _width = 0; |
314 | 65 | 64 | ||
315 | 66 | public Frontend () { | 65 | public Frontend () { |
317 | 67 | apps_manager = new AppsManager(); | 66 | apps_manager = new AppStore.AppsManager(); |
318 | 68 | 67 | ||
319 | 69 | destroy.connect(Gtk.main_quit); | 68 | destroy.connect(Gtk.main_quit); |
320 | 70 | size_allocate.connect(on_size_allocate); | 69 | size_allocate.connect(on_size_allocate); |
321 | @@ -110,35 +109,35 @@ | |||
322 | 110 | set_focus(null); | 109 | set_focus(null); |
323 | 111 | } | 110 | } |
324 | 112 | 111 | ||
326 | 113 | public void on_info_message_response (ResponseId id, LscApp app) { | 112 | public void on_info_message_response (AppStore.ResponseId id, AppStore.ModelApp app) { |
327 | 114 | switch (id) { | 113 | switch (id) { |
329 | 115 | case ResponseId.INFO: | 114 | case AppStore.ResponseId.INFO: |
330 | 116 | load_details (app); | 115 | load_details (app); |
331 | 117 | break; | 116 | break; |
333 | 118 | case ResponseId.INSTALL: | 117 | case AppStore.ResponseId.INSTALL: |
334 | 119 | break; | 118 | break; |
335 | 120 | } | 119 | } |
336 | 121 | } | 120 | } |
337 | 122 | 121 | ||
339 | 123 | public void load_details (LscApp app) { | 122 | public void load_details (AppStore.ModelApp app) { |
340 | 124 | info_message.set_visible (false); | 123 | info_message.set_visible (false); |
341 | 125 | last_app = app; | 124 | last_app = app; |
342 | 126 | apps_manager.get_details (app); | 125 | apps_manager.get_details (app); |
343 | 127 | pages_view.set_page(PageType.APPSINFO); | 126 | pages_view.set_page(PageType.APPSINFO); |
344 | 128 | } | 127 | } |
345 | 129 | 128 | ||
347 | 130 | public void load_packages (LscCategory category) { | 129 | public void load_packages (AppStore.Category category) { |
348 | 131 | last_category = category; | 130 | last_category = category; |
349 | 132 | pages_view.set_page(PageType.APPSVIEW); | 131 | pages_view.set_page(PageType.APPSVIEW); |
350 | 133 | pages_view.apps_view.apps_tree.clear(); | 132 | pages_view.apps_view.apps_tree.clear(); |
352 | 134 | apps_manager.get_pkgs(category.id); | 133 | apps_manager.get_apps(category.id); |
353 | 135 | toolbar.label.label = category.name; | 134 | toolbar.label.label = category.name; |
354 | 136 | info_message.set_visible (false); | 135 | info_message.set_visible (false); |
355 | 137 | } | 136 | } |
356 | 138 | 137 | ||
358 | 139 | public void on_action_response (ActionType type, string id) { | 138 | public void on_action_response (AppStore.ActionType type, string id) { |
359 | 140 | switch (type) { | 139 | switch (type) { |
361 | 141 | case ActionType.INSTALL: | 140 | case AppStore.ActionType.INSTALL: |
362 | 142 | apps_manager.install_packages ({id, null}); | 141 | apps_manager.install_packages ({id, null}); |
363 | 143 | break; | 142 | break; |
364 | 144 | default: | 143 | default: |
365 | @@ -247,18 +246,18 @@ | |||
366 | 247 | return true; | 246 | return true; |
367 | 248 | } | 247 | } |
368 | 249 | 248 | ||
370 | 250 | public void on_load_started (LoadingType load, string comment) { | 249 | public void on_load_started (AppStore.LoadingType load, string comment) { |
371 | 251 | switch (load) { | 250 | switch (load) { |
373 | 252 | case LoadingType.PACKAGES: | 251 | case AppStore.LoadingType.PACKAGES: |
374 | 253 | progress_info.load (comment); | 252 | progress_info.load (comment); |
375 | 254 | break; | 253 | break; |
377 | 255 | case LoadingType.DETAILS: | 254 | case AppStore.LoadingType.DETAILS: |
378 | 256 | pages_view.apps_info.start_load(); | 255 | pages_view.apps_info.start_load(); |
379 | 257 | break; | 256 | break; |
381 | 258 | case LoadingType.INSTALL: | 257 | case AppStore.LoadingType.INSTALL: |
382 | 259 | progress_info.load (comment); | 258 | progress_info.load (comment); |
383 | 260 | break; | 259 | break; |
385 | 261 | case LoadingType.REMOVE: | 260 | case AppStore.LoadingType.REMOVE: |
386 | 262 | progress_info.load (comment); | 261 | progress_info.load (comment); |
387 | 263 | break; | 262 | break; |
388 | 264 | default: | 263 | default: |
389 | @@ -267,15 +266,15 @@ | |||
390 | 267 | info_box.set_visible (true); | 266 | info_box.set_visible (true); |
391 | 268 | } | 267 | } |
392 | 269 | 268 | ||
394 | 270 | public void on_load_finished (LoadingType load) { | 269 | public void on_load_finished (AppStore.LoadingType load) { |
395 | 271 | switch (load) { | 270 | switch (load) { |
397 | 272 | case LoadingType.CATEGORIES: | 271 | case AppStore.LoadingType.CATEGORIES: |
398 | 273 | rework_categories_columns(); | 272 | rework_categories_columns(); |
399 | 274 | break; | 273 | break; |
401 | 275 | case LoadingType.PACKAGES: | 274 | case AppStore.LoadingType.PACKAGES: |
402 | 276 | progress_info.clear(); | 275 | progress_info.clear(); |
403 | 277 | break; | 276 | break; |
405 | 278 | case LoadingType.DETAILS: | 277 | case AppStore.LoadingType.DETAILS: |
406 | 279 | progress_info.clear(); | 278 | progress_info.clear(); |
407 | 280 | break; | 279 | break; |
408 | 281 | default: | 280 | default: |
409 | 282 | 281 | ||
410 | === modified file 'src/Widgets/InfoMessage.vala' | |||
411 | --- src/Widgets/InfoMessage.vala 2012-07-10 09:44:20 +0000 | |||
412 | +++ src/Widgets/InfoMessage.vala 2012-07-28 20:36:19 +0000 | |||
413 | @@ -16,27 +16,26 @@ | |||
414 | 16 | // | 16 | // |
415 | 17 | 17 | ||
416 | 18 | using Gtk; | 18 | using Gtk; |
417 | 19 | using Lsc.Backend; | ||
418 | 20 | 19 | ||
419 | 21 | namespace Lsc.Widgets { | 20 | namespace Lsc.Widgets { |
420 | 22 | public class InfoMessage : InfoBar { | 21 | public class InfoMessage : InfoBar { |
421 | 23 | // Signals | 22 | // Signals |
423 | 24 | public signal void choosed (ResponseId id, LscApp app); | 23 | public signal void choosed (AppStore.ResponseId id, AppStore.ModelApp app); |
424 | 25 | 24 | ||
425 | 26 | // Widgets | 25 | // Widgets |
426 | 27 | public Label text; | 26 | public Label text; |
427 | 28 | public Button info_button; | 27 | public Button info_button; |
428 | 29 | public Button action_button; | 28 | public Button action_button; |
430 | 30 | private LscApp current_app; | 29 | private AppStore.ModelApp current_app; |
431 | 31 | 30 | ||
433 | 32 | public void update (LscApp app) { | 31 | public void update (AppStore.ModelApp app) { |
434 | 33 | current_app = app; | 32 | current_app = app; |
435 | 34 | set_visible (true); | 33 | set_visible (true); |
436 | 35 | text.set_label("Selected package <b>%s</b>".printf (app.id)); | 34 | text.set_label("Selected package <b>%s</b>".printf (app.id)); |
437 | 36 | } | 35 | } |
438 | 37 | 36 | ||
439 | 38 | public void get_response (InfoBar bar, int id) { | 37 | public void get_response (InfoBar bar, int id) { |
441 | 39 | choosed ((ResponseId) id, current_app); | 38 | choosed ((AppStore.ResponseId) id, current_app); |
442 | 40 | } | 39 | } |
443 | 41 | 40 | ||
444 | 42 | public InfoMessage () { | 41 | public InfoMessage () { |
445 | @@ -51,7 +50,7 @@ | |||
446 | 51 | text.use_markup = true; | 50 | text.use_markup = true; |
447 | 52 | text.ellipsize = Pango.EllipsizeMode.END; | 51 | text.ellipsize = Pango.EllipsizeMode.END; |
448 | 53 | 52 | ||
450 | 54 | add_button(Stock.INFO, ResponseId.INFO); | 53 | add_button(Stock.INFO, AppStore.ResponseId.INFO); |
451 | 55 | 54 | ||
452 | 56 | focus_out_event.connect(() => { | 55 | focus_out_event.connect(() => { |
453 | 57 | set_visible(false); | 56 | set_visible(false); |
454 | 58 | 57 | ||
455 | === modified file 'src/Widgets/Pages/AppsInfo.vala' | |||
456 | --- src/Widgets/Pages/AppsInfo.vala 2012-07-10 19:06:05 +0000 | |||
457 | +++ src/Widgets/Pages/AppsInfo.vala 2012-07-28 20:36:19 +0000 | |||
458 | @@ -18,12 +18,11 @@ | |||
459 | 18 | using Gtk; | 18 | using Gtk; |
460 | 19 | using PackageKit; | 19 | using PackageKit; |
461 | 20 | using Lsc.Widgets; | 20 | using Lsc.Widgets; |
462 | 21 | using Lsc.Backend; | ||
463 | 22 | using Granite.Widgets; | 21 | using Granite.Widgets; |
464 | 23 | 22 | ||
465 | 24 | namespace Lsc.Pages { | 23 | namespace Lsc.Pages { |
466 | 25 | public class AppsInfo : BlankBox { | 24 | public class AppsInfo : BlankBox { |
468 | 26 | public signal void action_response (ActionType type, string id); | 25 | public signal void action_response (AppStore.ActionType type, string id); |
469 | 27 | 26 | ||
470 | 28 | private Separator separator; | 27 | private Separator separator; |
471 | 29 | public RoundBox reviews_box; | 28 | public RoundBox reviews_box; |
472 | @@ -42,15 +41,15 @@ | |||
473 | 42 | private Label license; | 41 | private Label license; |
474 | 43 | private Button action_button; | 42 | private Button action_button; |
475 | 44 | private string pkg_id; | 43 | private string pkg_id; |
477 | 45 | private ActionType action_type; | 44 | private AppStore.ActionType action_type; |
478 | 46 | 45 | ||
480 | 47 | public void set_action (ActionType type) { | 46 | public void set_action (AppStore.ActionType type) { |
481 | 48 | action_type = type; | 47 | action_type = type; |
482 | 49 | switch (type) { | 48 | switch (type) { |
484 | 50 | case ActionType.INSTALL: | 49 | case AppStore.ActionType.INSTALL: |
485 | 51 | action_button.label = "Install"; | 50 | action_button.label = "Install"; |
486 | 52 | break; | 51 | break; |
488 | 53 | case ActionType.REMOVE: | 52 | case AppStore.ActionType.REMOVE: |
489 | 54 | action_button.label = "Remove"; | 53 | action_button.label = "Remove"; |
490 | 55 | break; | 54 | break; |
491 | 56 | } | 55 | } |
492 | @@ -61,17 +60,19 @@ | |||
493 | 61 | case Info.INSTALLED: | 60 | case Info.INSTALLED: |
494 | 62 | status_icon.set_from_stock (Stock.YES, IconSize.MENU); | 61 | status_icon.set_from_stock (Stock.YES, IconSize.MENU); |
495 | 63 | status_label.label = "Installed"; | 62 | status_label.label = "Installed"; |
497 | 64 | set_action (ActionType.REMOVE); | 63 | set_action (AppStore.ActionType.REMOVE); |
498 | 65 | break; | 64 | break; |
499 | 66 | default: | 65 | default: |
500 | 67 | status_icon.set_from_icon_name ("applications-internet", IconSize.MENU); | 66 | status_icon.set_from_icon_name ("applications-internet", IconSize.MENU); |
501 | 68 | status_label.label = "Available"; | 67 | status_label.label = "Available"; |
503 | 69 | set_action (ActionType.INSTALL); | 68 | set_action (AppStore.ActionType.INSTALL); |
504 | 70 | break; | 69 | break; |
505 | 71 | } | 70 | } |
506 | 72 | } | 71 | } |
507 | 73 | 72 | ||
509 | 74 | public void set_details (LscApp app, Package pkg, Details details) { | 73 | public void set_details (AppStore.App app) { |
510 | 74 | var pkg = app.package; | ||
511 | 75 | |||
512 | 75 | pkg_id = pkg.get_id(); | 76 | pkg_id = pkg.get_id(); |
513 | 76 | 77 | ||
514 | 77 | this.show_children(); | 78 | this.show_children(); |
515 | @@ -84,14 +85,14 @@ | |||
516 | 84 | pkg_name.label = "<span size='x-large'><b>%s</b></span>".printf (app.name); | 85 | pkg_name.label = "<span size='x-large'><b>%s</b></span>".printf (app.name); |
517 | 85 | short_description.label = "<big>%s</big>".printf (app.summary); | 86 | short_description.label = "<big>%s</big>".printf (app.summary); |
518 | 86 | 87 | ||
520 | 87 | description.label = details.description; | 88 | description.label = app.description; |
521 | 88 | 89 | ||
522 | 89 | image.set_from_icon_name (app.icon, IconSize.DIALOG); | 90 | image.set_from_icon_name (app.icon, IconSize.DIALOG); |
523 | 90 | 91 | ||
524 | 91 | id.label = pkg.get_name(); | 92 | id.label = pkg.get_name(); |
525 | 92 | version.label = pkg.get_version(); | 93 | version.label = pkg.get_version(); |
528 | 93 | size.label = Utils.size_to_str ((int) details.size); | 94 | size.label = Utils.size_to_str ((int) app.size); |
529 | 94 | license.label = details.license; | 95 | license.label = app.license; |
530 | 95 | details_box.set_visible (false); | 96 | details_box.set_visible (false); |
531 | 96 | s_nb.page = 0; | 97 | s_nb.page = 0; |
532 | 97 | } | 98 | } |
533 | 98 | 99 | ||
534 | === modified file 'src/Widgets/Pages/AppsView.vala' | |||
535 | --- src/Widgets/Pages/AppsView.vala 2012-07-12 09:21:39 +0000 | |||
536 | +++ src/Widgets/Pages/AppsView.vala 2012-07-28 20:36:19 +0000 | |||
537 | @@ -17,13 +17,12 @@ | |||
538 | 17 | 17 | ||
539 | 18 | using Gtk; | 18 | using Gtk; |
540 | 19 | using PackageKit; | 19 | using PackageKit; |
541 | 20 | using Lsc.Backend; | ||
542 | 21 | 20 | ||
543 | 22 | namespace Lsc.Widgets { | 21 | namespace Lsc.Widgets { |
544 | 23 | public class AppsTree : TreeView { | 22 | public class AppsTree : TreeView { |
545 | 24 | // Signals | 23 | // Signals |
548 | 25 | public signal void selected_row (LscApp app); | 24 | public signal void selected_row (AppStore.ModelApp app); |
549 | 26 | public signal void activated_row (LscApp app); | 25 | public signal void activated_row (AppStore.ModelApp app); |
550 | 27 | 26 | ||
551 | 28 | // Vars | 27 | // Vars |
552 | 29 | private IconTheme theme; | 28 | private IconTheme theme; |
553 | @@ -31,7 +30,7 @@ | |||
554 | 31 | private TreeIter iter; | 30 | private TreeIter iter; |
555 | 32 | private new TreePath path; | 31 | private new TreePath path; |
556 | 33 | 32 | ||
558 | 34 | public void append_app (LscApp app) { | 33 | public void append_app (AppStore.ModelApp app) { |
559 | 35 | model.append(out iter); | 34 | model.append(out iter); |
560 | 36 | //model.set(iter, 0, app.icon, 1, "<span size='medium'>"+Utils.escape_text (app.name)+"</span>\n<span size='small'>"+Utils.escape_text (app.summary)+"</span>", 2, app); | 35 | //model.set(iter, 0, app.icon, 1, "<span size='medium'>"+Utils.escape_text (app.name)+"</span>\n<span size='small'>"+Utils.escape_text (app.summary)+"</span>", 2, app); |
561 | 37 | model.set(iter, 0, app.icon, 1, "<b>"+Utils.escape_text (app.name)+"</b>\n"+Utils.escape_text (app.summary), 2, app); // FIXME: this actually take time | 36 | model.set(iter, 0, app.icon, 1, "<b>"+Utils.escape_text (app.name)+"</b>\n"+Utils.escape_text (app.summary), 2, app); // FIXME: this actually take time |
562 | @@ -44,7 +43,7 @@ | |||
563 | 44 | public void on_cursor_changed (TreeView widget) { | 43 | public void on_cursor_changed (TreeView widget) { |
564 | 45 | get_cursor(out path, null); | 44 | get_cursor(out path, null); |
565 | 46 | if (path != null) { | 45 | if (path != null) { |
567 | 47 | LscApp val; | 46 | AppStore.ModelApp val; |
568 | 48 | model.get_iter(out iter, path); | 47 | model.get_iter(out iter, path); |
569 | 49 | model.get(iter, 2, out val); | 48 | model.get(iter, 2, out val); |
570 | 50 | selected_row(val); | 49 | selected_row(val); |
571 | @@ -54,7 +53,7 @@ | |||
572 | 54 | public void on_row_activated (TreePath path, TreeViewColumn column) { | 53 | public void on_row_activated (TreePath path, TreeViewColumn column) { |
573 | 55 | get_cursor(out this.path, null); | 54 | get_cursor(out this.path, null); |
574 | 56 | if (path != null) { | 55 | if (path != null) { |
576 | 57 | LscApp val; | 56 | AppStore.ModelApp val; |
577 | 58 | model.get_iter(out iter, this.path); | 57 | model.get_iter(out iter, this.path); |
578 | 59 | model.get(iter, 2, out val); | 58 | model.get(iter, 2, out val); |
579 | 60 | activated_row(val); | 59 | activated_row(val); |
580 | @@ -69,7 +68,7 @@ | |||
581 | 69 | model = new ListStore(3, | 68 | model = new ListStore(3, |
582 | 70 | t_string, // Icon name | 69 | t_string, // Icon name |
583 | 71 | t_string, // Name and description | 70 | t_string, // Name and description |
585 | 72 | typeof(LscApp) // LscApp object | 71 | typeof(AppStore.ModelApp) // AppStore.App object |
586 | 73 | ); | 72 | ); |
587 | 74 | 73 | ||
588 | 75 | set_model(model); | 74 | set_model(model); |
589 | 76 | 75 | ||
590 | === modified file 'src/Widgets/Pages/CategoriesView.vala' | |||
591 | --- src/Widgets/Pages/CategoriesView.vala 2012-07-11 18:59:07 +0000 | |||
592 | +++ src/Widgets/Pages/CategoriesView.vala 2012-07-28 20:36:19 +0000 | |||
593 | @@ -16,19 +16,18 @@ | |||
594 | 16 | // | 16 | // |
595 | 17 | 17 | ||
596 | 18 | using Gtk; | 18 | using Gtk; |
597 | 19 | using Lsc.Backend; | ||
598 | 20 | 19 | ||
599 | 21 | namespace Lsc.Widgets { | 20 | namespace Lsc.Widgets { |
600 | 22 | public class CategoryButton : EventBox { | 21 | public class CategoryButton : EventBox { |
603 | 23 | private LscCategory desc; | 22 | private AppStore.Category desc; |
604 | 24 | public signal void category_clicked (LscCategory cat); | 23 | public signal void category_clicked (AppStore.Category cat); |
605 | 25 | 24 | ||
606 | 26 | private bool emit_clicked (Widget box, Gdk.EventButton button) { | 25 | private bool emit_clicked (Widget box, Gdk.EventButton button) { |
607 | 27 | category_clicked (desc); | 26 | category_clicked (desc); |
608 | 28 | return true; | 27 | return true; |
609 | 29 | } | 28 | } |
610 | 30 | 29 | ||
612 | 31 | public CategoryButton (LscCategory desc, bool fill = false) { | 30 | public CategoryButton (AppStore.Category desc, bool fill = false) { |
613 | 32 | this.desc = desc; | 31 | this.desc = desc; |
614 | 33 | 32 | ||
615 | 34 | sensitive = ! fill; | 33 | sensitive = ! fill; |
616 | @@ -69,16 +68,16 @@ | |||
617 | 69 | } | 68 | } |
618 | 70 | 69 | ||
619 | 71 | public class CategoriesView : GridView { | 70 | public class CategoriesView : GridView { |
621 | 72 | public signal void category_choosed (LscCategory cat); | 71 | public signal void category_choosed (AppStore.Category cat); |
622 | 73 | 72 | ||
623 | 74 | // Vars | 73 | // Vars |
624 | 75 | private Box box_child; | 74 | private Box box_child; |
625 | 76 | private CategoryButton button_child; | 75 | private CategoryButton button_child; |
626 | 77 | public int columns { get; set; } | 76 | public int columns { get; set; } |
627 | 78 | private int actual_col; | 77 | private int actual_col; |
629 | 79 | private new List<LscCategory> children = null; | 78 | private new List<AppStore.Category> children = null; |
630 | 80 | 79 | ||
632 | 81 | public void add_category (LscCategory cat) { | 80 | public void add_category (AppStore.Category cat) { |
633 | 82 | children.append(cat); | 81 | children.append(cat); |
634 | 83 | } | 82 | } |
635 | 84 | 83 | ||
636 | @@ -89,7 +88,7 @@ | |||
637 | 89 | box_child = null; | 88 | box_child = null; |
638 | 90 | actual_col = columns; | 89 | actual_col = columns; |
639 | 91 | 90 | ||
641 | 92 | foreach (LscCategory button_desc in children) { | 91 | foreach (AppStore.Category button_desc in children) { |
642 | 93 | if (actual_col == columns) { | 92 | if (actual_col == columns) { |
643 | 94 | box_child = new Box(Orientation.HORIZONTAL, 5); | 93 | box_child = new Box(Orientation.HORIZONTAL, 5); |
644 | 95 | box_child.homogeneous = true; | 94 | box_child.homogeneous = true; |
645 | @@ -109,7 +108,7 @@ | |||
646 | 109 | } | 108 | } |
647 | 110 | 109 | ||
648 | 111 | while (actual_col != columns) { | 110 | while (actual_col != columns) { |
650 | 112 | button_child = new CategoryButton(new LscCategory("", "", "", "", 0), true); | 111 | button_child = new CategoryButton(new AppStore.Category("", "", "", "", 0), true); |
651 | 113 | box_child.pack_start(button_child, true, true, 0); | 112 | box_child.pack_start(button_child, true, true, 0); |
652 | 114 | button_child.show_all(); | 113 | button_child.show_all(); |
653 | 115 | actual_col++; | 114 | actual_col++; |