Merge lp:~jamesh/unity-lens-applications/scope-previews into lp:~unity-team/unity-lens-applications/libunity7-compatible
- scope-previews
- Merge into libunity7-compatible
Status: | Merged |
---|---|
Approved by: | Michal Hruby |
Approved revision: | 348 |
Merged at revision: | 344 |
Proposed branch: | lp:~jamesh/unity-lens-applications/scope-previews |
Merge into: | lp:~unity-team/unity-lens-applications/libunity7-compatible |
Diff against target: |
615 lines (+313/-256) 1 file modified
src/daemon.vala (+313/-256) |
To merge this branch: | bzr merge lp:~jamesh/unity-lens-applications/scope-previews |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Michal Hruby (community) | Approve | ||
Review via email: mp+161534@code.launchpad.net |
Commit message
Add screenshots to local scope previews with information obtained from the software center, escape markup characters in descriptions and don't allow the user to disable the applications scope.
Description of the change
When creating previews for local scopes, look up the package name in the software center index (requires scopes to be included in the app-install data) and then query the data provider for screenshots to include in the preview. This
As the preview() method was getting quite long, I also took the opportunity to split it into the app preview and scope preview cases into their own methods.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 344. By James Henstridge
-
Escape special characters in the scope description when producing
previews. - 345. By James Henstridge
-
Don't include scope description in comment field of search results.
- 346. By James Henstridge
-
Don't show the enable/disable buttons in the preview of the applications
scope.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:346
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
- 347. By James Henstridge
-
Merge from libunity7-
compatible, fixing conflict
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:347
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 348. By James Henstridge
-
Also remove the disable action for the home scope.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:348
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/daemon.vala' | |||
2 | --- src/daemon.vala 2013-04-30 18:46:48 +0000 | |||
3 | +++ src/daemon.vala 2013-05-01 19:21:29 +0000 | |||
4 | @@ -1080,7 +1080,6 @@ | |||
5 | 1080 | var uri = @"scope://$(info.desktop_file)"; | 1080 | var uri = @"scope://$(info.desktop_file)"; |
6 | 1081 | var name = info.application_name; | 1081 | var name = info.application_name; |
7 | 1082 | var icon_hint = info.icon; | 1082 | var icon_hint = info.icon; |
8 | 1083 | var comment = info.description; | ||
9 | 1084 | var category = info.desktop_file in disabled_scope_ids ? | 1083 | var category = info.desktop_file in disabled_scope_ids ? |
10 | 1085 | Category.AVAILABLE : Category.INSTALLED; | 1084 | Category.AVAILABLE : Category.INSTALLED; |
11 | 1086 | 1085 | ||
12 | @@ -1103,7 +1102,7 @@ | |||
13 | 1103 | ResultType.DEFAULT, | 1102 | ResultType.DEFAULT, |
14 | 1104 | "application/x-unity-scope", | 1103 | "application/x-unity-scope", |
15 | 1105 | name != "" ? name : uri, | 1104 | name != "" ? name : uri, |
17 | 1106 | comment, | 1105 | "", |
18 | 1107 | "", // dnd_uri ?! | 1106 | "", // dnd_uri ?! |
19 | 1108 | empty_asv); | 1107 | empty_asv); |
20 | 1109 | } | 1108 | } |
21 | @@ -1310,282 +1309,340 @@ | |||
22 | 1310 | 1309 | ||
23 | 1311 | public Unity.Preview preview (string uri) | 1310 | public Unity.Preview preview (string uri) |
24 | 1312 | { | 1311 | { |
29 | 1313 | Unity.ApplicationPreview? preview = null; | 1312 | Unity.Preview? preview = null; |
26 | 1314 | |||
27 | 1315 | string pkgname = ""; | ||
28 | 1316 | string appname = ""; | ||
30 | 1317 | bool installed = uri.has_prefix ("application://"); | 1313 | bool installed = uri.has_prefix ("application://"); |
31 | 1318 | bool is_scope = uri.has_prefix ("scope://"); | 1314 | bool is_scope = uri.has_prefix ("scope://"); |
32 | 1319 | 1315 | ||
33 | 1320 | if (installed || uri.has_prefix ("unity-install://")) | 1316 | if (installed || uri.has_prefix ("unity-install://")) |
34 | 1321 | { | 1317 | { |
66 | 1322 | string desktopfile = null; | 1318 | preview = make_app_preview (uri, installed); |
67 | 1323 | if (installed) | 1319 | } |
68 | 1324 | { | 1320 | else if (is_scope) |
69 | 1325 | desktopfile = uri.substring (14); //remove "application://" prefix | 1321 | { |
70 | 1326 | 1322 | preview = make_scope_preview (uri); | |
71 | 1327 | // de-mangle desktop file names back to what S-C expects | 1323 | } |
72 | 1328 | if (sc_mangler.contains (desktopfile)) | 1324 | return preview; |
73 | 1329 | { | 1325 | } |
74 | 1330 | desktopfile = sc_mangler.get (desktopfile); | 1326 | |
75 | 1331 | } | 1327 | private SoftwareCenterData.AppDetailsData get_app_details (string appname, string pkgname) throws Error |
76 | 1332 | 1328 | { | |
77 | 1333 | Unity.Package.PackageInfo pkginfo = pkgsearcher.get_by_desktop_file (desktopfile); | 1329 | if (sc_data_provider == null) |
78 | 1334 | if (pkginfo != null) | 1330 | { |
79 | 1335 | { | 1331 | sc_data_provider = new SoftwareCenterDataCache (TOP_RATED_ITEMS_CACHE_LIFETIME); |
80 | 1336 | appname = pkginfo.application_name; | 1332 | sc_data_provider.connect_to (); |
81 | 1337 | pkgname = pkginfo.package_name; | 1333 | } |
82 | 1338 | } | 1334 | |
83 | 1339 | } | 1335 | debug ("Requesting pkg info: %s, %s\n", pkgname, appname); |
84 | 1340 | else // unity-install | 1336 | return sc_data_provider.get_app_details (appname, pkgname); |
85 | 1341 | { | 1337 | } |
86 | 1342 | string app = uri.substring (16); //remove "unity-install://" prefix | 1338 | |
87 | 1343 | string[] parts = app.split ("/"); | 1339 | private Unity.Preview make_app_preview (string uri, bool installed) |
88 | 1344 | if (parts.length > 1) | 1340 | { |
89 | 1345 | { | 1341 | Unity.ApplicationPreview? preview = null; |
90 | 1346 | pkgname = parts[0]; | 1342 | string desktopfile = null; |
91 | 1347 | appname = parts[1]; | 1343 | string pkgname = ""; |
92 | 1348 | } | 1344 | string appname = ""; |
93 | 1349 | } | 1345 | |
94 | 1350 | 1346 | if (installed) | |
95 | 1351 | if (pkgname != "") | 1347 | { |
96 | 1352 | { | 1348 | desktopfile = uri.substring (14); //remove "application://" prefix |
97 | 1349 | |||
98 | 1350 | // de-mangle desktop file names back to what S-C expects | ||
99 | 1351 | if (sc_mangler.contains (desktopfile)) | ||
100 | 1352 | { | ||
101 | 1353 | desktopfile = sc_mangler.get (desktopfile); | ||
102 | 1354 | } | ||
103 | 1355 | |||
104 | 1356 | Unity.Package.PackageInfo pkginfo = pkgsearcher.get_by_desktop_file (desktopfile); | ||
105 | 1357 | if (pkginfo != null) | ||
106 | 1358 | { | ||
107 | 1359 | appname = pkginfo.application_name; | ||
108 | 1360 | pkgname = pkginfo.package_name; | ||
109 | 1361 | } | ||
110 | 1362 | } | ||
111 | 1363 | else // unity-install | ||
112 | 1364 | { | ||
113 | 1365 | string app = uri.substring (16); //remove "unity-install://" prefix | ||
114 | 1366 | string[] parts = app.split ("/"); | ||
115 | 1367 | if (parts.length > 1) | ||
116 | 1368 | { | ||
117 | 1369 | pkgname = parts[0]; | ||
118 | 1370 | appname = parts[1]; | ||
119 | 1371 | } | ||
120 | 1372 | } | ||
121 | 1373 | |||
122 | 1374 | if (pkgname != "") | ||
123 | 1375 | { | ||
124 | 1376 | try { | ||
125 | 1377 | var details = get_app_details (appname, pkgname); | ||
126 | 1378 | |||
127 | 1379 | Icon? icon = null; | ||
128 | 1380 | if (installed) | ||
129 | 1381 | icon = new GLib.ThemedIcon (details.icon); | ||
130 | 1382 | else | ||
131 | 1383 | { | ||
132 | 1384 | icon = find_pkg_icon (null, details.icon); | ||
133 | 1385 | if (icon.to_string () == GENERIC_APP_ICON && details.icon_url != null && details.icon_url != "") | ||
134 | 1386 | { | ||
135 | 1387 | icon = new GLib.FileIcon (File.new_for_uri (details.icon_url)); | ||
136 | 1388 | } | ||
137 | 1389 | } | ||
138 | 1390 | |||
139 | 1391 | Icon? screenshot = null; | ||
140 | 1392 | |||
141 | 1393 | if (details.screenshot != null) | ||
142 | 1394 | { | ||
143 | 1395 | File scr_file = File.new_for_uri (details.screenshot); | ||
144 | 1396 | screenshot = new FileIcon (scr_file); | ||
145 | 1397 | } | ||
146 | 1398 | |||
147 | 1399 | string subtitle = ""; | ||
148 | 1400 | if (details.version != "") | ||
149 | 1401 | subtitle = _("Version %s").printf (details.version); | ||
150 | 1402 | if (details.size > 0) | ||
151 | 1403 | { | ||
152 | 1404 | if (subtitle != "") | ||
153 | 1405 | subtitle += ", "; | ||
154 | 1406 | subtitle += ("Size %s").printf (GLib.format_size (details.size)); | ||
155 | 1407 | } | ||
156 | 1408 | preview = new Unity.ApplicationPreview (details.name, subtitle, details.description, icon, screenshot); | ||
157 | 1409 | preview.license = details.license; | ||
158 | 1410 | |||
159 | 1411 | init_ratings_db (); | ||
160 | 1412 | if (ratings != null) | ||
161 | 1413 | { | ||
162 | 1414 | Unity.Ratings.Result result; | ||
163 | 1415 | ratings.query (pkgname, out result); | ||
164 | 1416 | preview.set_rating (result.average_rating / 5.0f, result.total_rating); | ||
165 | 1417 | } | ||
166 | 1418 | |||
167 | 1419 | if (details.hardware_requirements != "") | ||
168 | 1420 | preview.add_info (new InfoHint ("hardware-requirements", _("Hardware requirements"), null, details.hardware_requirements)); | ||
169 | 1421 | |||
170 | 1422 | if (uri.has_prefix ("unity-install://")) // application needs to be purchased/installed | ||
171 | 1423 | { | ||
172 | 1424 | // uninstalled and not purchased before | ||
173 | 1425 | if (details.pkg_state == SoftwareCenterData.PackageState.NEEDS_PURCHASE) | ||
174 | 1426 | { | ||
175 | 1427 | var buy_action = new Unity.PreviewAction ("buy", _("Buy"), null); | ||
176 | 1428 | if (details.price != null && details.price != "") | ||
177 | 1429 | { | ||
178 | 1430 | buy_action.extra_text = details.price; | ||
179 | 1431 | } | ||
180 | 1432 | |||
181 | 1433 | buy_action.activated.connect (start_software_center); | ||
182 | 1434 | preview.add_action (buy_action); | ||
183 | 1435 | } | ||
184 | 1436 | else // uninstalled, purchased before | ||
185 | 1437 | { | ||
186 | 1438 | |||
187 | 1439 | Unity.PreviewAction install_action = null; | ||
188 | 1440 | if (details.raw_price == null || details.raw_price == "") | ||
189 | 1441 | { | ||
190 | 1442 | install_action = new Unity.PreviewAction ("install", _("Free Download"), null); | ||
191 | 1443 | install_action.activated.connect (app_preview_install); | ||
192 | 1444 | } | ||
193 | 1445 | else | ||
194 | 1446 | { | ||
195 | 1447 | install_action = new Unity.PreviewAction ("install", _("Install"), null); | ||
196 | 1448 | install_action.activated.connect (start_software_center); | ||
197 | 1449 | } | ||
198 | 1450 | preview.add_action (install_action); | ||
199 | 1451 | } | ||
200 | 1452 | |||
201 | 1453 | if (details.website != null && details.website != "") | ||
202 | 1454 | { | ||
203 | 1455 | preview_developer_website = details.website; | ||
204 | 1456 | var website_action = new Unity.PreviewAction ("website", _("Developer Site"), null); | ||
205 | 1457 | website_action.activated.connect (app_preview_website); | ||
206 | 1458 | preview.add_action (website_action); | ||
207 | 1459 | } | ||
208 | 1460 | } | ||
209 | 1461 | else // application is already installed | ||
210 | 1462 | { | ||
211 | 1463 | preview.add_info (new InfoHint ("date-installed", _("Installed on"), null, details.installation_date)); | ||
212 | 1464 | var launch_action = new Unity.PreviewAction ("launch", _("Launch"), null); | ||
213 | 1465 | preview.add_action (launch_action); | ||
214 | 1466 | if (!details.is_desktop_dependency) | ||
215 | 1467 | { | ||
216 | 1468 | var uninstall_action = new Unity.PreviewAction ("uninstall", _("Uninstall"), null); | ||
217 | 1469 | uninstall_action.activated.connect (app_preview_uninstall); | ||
218 | 1470 | preview.add_action (uninstall_action); | ||
219 | 1471 | } | ||
220 | 1472 | } | ||
221 | 1473 | |||
222 | 1474 | preview_installable_desktop_file = details.desktop_file; | ||
223 | 1475 | preview_installable_icon_file = details.icon; | ||
224 | 1476 | } | ||
225 | 1477 | catch (Error e) | ||
226 | 1478 | { | ||
227 | 1479 | warning ("Failed to get package details for '%s': %s", uri, e.message); | ||
228 | 1480 | preview = null; | ||
229 | 1481 | } | ||
230 | 1482 | } | ||
231 | 1483 | |||
232 | 1484 | // xapian db doesn't know this .desktop file or S-C dbus data provider fails, | ||
233 | 1485 | // fallback to DesktopAppInfo (based on installed .desktop file) if available | ||
234 | 1486 | if (preview == null && desktopfile != null) | ||
235 | 1487 | { | ||
236 | 1488 | var app_info = new DesktopAppInfo (desktopfile); | ||
237 | 1489 | if (app_info != null) | ||
238 | 1490 | { | ||
239 | 1491 | preview = new Unity.ApplicationPreview (app_info.get_display_name (), "", app_info.get_description () ?? "", app_info.get_icon (), null); | ||
240 | 1492 | var launch_action = new Unity.PreviewAction ("launch", _("Launch"), null); | ||
241 | 1493 | preview.add_action (launch_action); | ||
242 | 1494 | } | ||
243 | 1495 | } | ||
244 | 1496 | |||
245 | 1497 | if (preview == null) | ||
246 | 1498 | { | ||
247 | 1499 | warning ("No pksearcher nor desktop app info for '%s'", uri); | ||
248 | 1500 | } | ||
249 | 1501 | return preview; | ||
250 | 1502 | } | ||
251 | 1503 | |||
252 | 1504 | private Unity.Preview make_scope_preview(string uri) | ||
253 | 1505 | { | ||
254 | 1506 | Unity.ApplicationPreview? preview = null; | ||
255 | 1507 | var scope_id = uri.substring (8); | ||
256 | 1508 | bool scope_disabled = scope_id in disabled_scope_ids; | ||
257 | 1509 | |||
258 | 1510 | // figure out if the scope is remote | ||
259 | 1511 | bool is_remote_scope = false; | ||
260 | 1512 | var info = scopesearcher.get_by_desktop_file (scope_id); | ||
261 | 1513 | |||
262 | 1514 | Dee.ModelIter found_iter = null; | ||
263 | 1515 | if (info == null) | ||
264 | 1516 | { | ||
265 | 1517 | var iter = remote_scopes_model.get_first_iter (); | ||
266 | 1518 | var end_iter = remote_scopes_model.get_last_iter (); | ||
267 | 1519 | while (iter != end_iter) | ||
268 | 1520 | { | ||
269 | 1521 | if (remote_scopes_model.get_string (iter, 0) == scope_id) | ||
270 | 1522 | { | ||
271 | 1523 | is_remote_scope = true; | ||
272 | 1524 | found_iter = iter; | ||
273 | 1525 | break; | ||
274 | 1526 | } | ||
275 | 1527 | iter = remote_scopes_model.next (iter); | ||
276 | 1528 | } | ||
277 | 1529 | } | ||
278 | 1530 | |||
279 | 1531 | if (is_remote_scope) | ||
280 | 1532 | { | ||
281 | 1533 | var name = remote_scopes_model.get_string (found_iter, 1); | ||
282 | 1534 | if (name == null || name == "") | ||
283 | 1535 | name = remote_scopes_model.get_string (found_iter, 0); | ||
284 | 1536 | var description = remote_scopes_model.get_string (found_iter, 2); | ||
285 | 1537 | if (description != null) | ||
286 | 1538 | description = Markup.escape_text(description); | ||
287 | 1539 | Icon? icon = null; | ||
288 | 1540 | Icon? screenshot = null; | ||
289 | 1541 | var icon_hint = remote_scopes_model.get_string (found_iter, 3); | ||
290 | 1542 | var screenshot_url = remote_scopes_model.get_string (found_iter, 4); | ||
291 | 1543 | try | ||
292 | 1544 | { | ||
293 | 1545 | if (icon_hint != "") icon = Icon.new_for_string (icon_hint); | ||
294 | 1546 | if (screenshot_url != "") screenshot = Icon.new_for_string (screenshot_url); | ||
295 | 1547 | } | ||
296 | 1548 | catch (Error err) | ||
297 | 1549 | { | ||
298 | 1550 | warning ("%s", err.message); | ||
299 | 1551 | } | ||
300 | 1552 | |||
301 | 1553 | if (icon == null) icon = get_default_scope_icon (); | ||
302 | 1554 | |||
303 | 1555 | preview = new Unity.ApplicationPreview (name, | ||
304 | 1556 | "", | ||
305 | 1557 | description, | ||
306 | 1558 | icon, | ||
307 | 1559 | screenshot); | ||
308 | 1560 | } | ||
309 | 1561 | else if (info != null) | ||
310 | 1562 | { | ||
311 | 1563 | var name = info.application_name; | ||
312 | 1564 | if (name == null || name == "") | ||
313 | 1565 | name = info.desktop_file; | ||
314 | 1566 | var subtitle = ""; | ||
315 | 1567 | var description = info.description; | ||
316 | 1568 | if (description != null) | ||
317 | 1569 | description = Markup.escape_text(description); | ||
318 | 1570 | Icon? icon = null; | ||
319 | 1571 | Icon? screenshot = null; | ||
320 | 1572 | try | ||
321 | 1573 | { | ||
322 | 1574 | if (info.icon != null && info.icon != "") | ||
323 | 1575 | icon = Icon.new_for_string (info.icon); | ||
324 | 1576 | } | ||
325 | 1577 | catch (Error err) | ||
326 | 1578 | { | ||
327 | 1579 | warning ("%s", err.message); | ||
328 | 1580 | } | ||
329 | 1581 | if (icon == null) | ||
330 | 1582 | icon = get_default_scope_icon (); | ||
331 | 1583 | |||
332 | 1584 | // de-mangle desktop file names back to what S-C expects | ||
333 | 1585 | string mangled_id; | ||
334 | 1586 | if (sc_mangler.contains (scope_id)) | ||
335 | 1587 | { | ||
336 | 1588 | mangled_id = sc_mangler.get (scope_id); | ||
337 | 1589 | } | ||
338 | 1590 | else | ||
339 | 1591 | { | ||
340 | 1592 | mangled_id = scope_id; | ||
341 | 1593 | } | ||
342 | 1594 | |||
343 | 1595 | Unity.Package.PackageInfo pkginfo = pkgsearcher.get_by_desktop_file (mangled_id); | ||
344 | 1596 | if (pkginfo != null) | ||
345 | 1597 | { | ||
346 | 1598 | SoftwareCenterData.AppDetailsData? details; | ||
347 | 1353 | try { | 1599 | try { |
371 | 1354 | if (sc_data_provider == null) | 1600 | details = get_app_details(pkginfo.application_name, |
372 | 1355 | { | 1601 | pkginfo.package_name); |
373 | 1356 | sc_data_provider = new SoftwareCenterDataCache (TOP_RATED_ITEMS_CACHE_LIFETIME); | 1602 | } catch (Error e) { |
374 | 1357 | sc_data_provider.connect_to (); | 1603 | details = null; |
375 | 1358 | } | 1604 | } |
376 | 1359 | 1605 | if (details != null) { | |
377 | 1360 | debug ("Requesting pkg info: %s, %s\n", pkgname, appname); | 1606 | if (details.version != "") |
378 | 1361 | var details = sc_data_provider.get_app_details (appname, pkgname); | 1607 | subtitle = _("Version %s").printf (details.version); |
356 | 1362 | |||
357 | 1363 | Icon? icon = null; | ||
358 | 1364 | if (installed) | ||
359 | 1365 | icon = new GLib.ThemedIcon (details.icon); | ||
360 | 1366 | else | ||
361 | 1367 | { | ||
362 | 1368 | icon = find_pkg_icon (null, details.icon); | ||
363 | 1369 | if (icon.to_string () == GENERIC_APP_ICON && details.icon_url != null && details.icon_url != "") | ||
364 | 1370 | { | ||
365 | 1371 | icon = new GLib.FileIcon (File.new_for_uri (details.icon_url)); | ||
366 | 1372 | } | ||
367 | 1373 | } | ||
368 | 1374 | |||
369 | 1375 | Icon? screenshot = null; | ||
370 | 1376 | |||
379 | 1377 | if (details.screenshot != null) | 1608 | if (details.screenshot != null) |
380 | 1378 | { | 1609 | { |
381 | 1379 | File scr_file = File.new_for_uri (details.screenshot); | 1610 | File scr_file = File.new_for_uri (details.screenshot); |
382 | 1380 | screenshot = new FileIcon (scr_file); | 1611 | screenshot = new FileIcon (scr_file); |
383 | 1381 | } | 1612 | } |
487 | 1382 | 1613 | } | |
488 | 1383 | string subtitle = ""; | 1614 | } |
489 | 1384 | if (details.version != "") | 1615 | |
490 | 1385 | subtitle = _("Version %s").printf (details.version); | 1616 | preview = new Unity.ApplicationPreview (name, |
491 | 1386 | if (details.size > 0) | 1617 | subtitle, |
492 | 1387 | { | 1618 | description, |
493 | 1388 | if (subtitle != "") | 1619 | icon, |
494 | 1389 | subtitle += ", "; | 1620 | screenshot); |
392 | 1390 | subtitle += ("Size %s").printf (GLib.format_size (details.size)); | ||
393 | 1391 | } | ||
394 | 1392 | preview = new Unity.ApplicationPreview (details.name, subtitle, details.description, icon, screenshot); | ||
395 | 1393 | preview.license = details.license; | ||
396 | 1394 | |||
397 | 1395 | init_ratings_db (); | ||
398 | 1396 | if (ratings != null) | ||
399 | 1397 | { | ||
400 | 1398 | Unity.Ratings.Result result; | ||
401 | 1399 | ratings.query (pkgname, out result); | ||
402 | 1400 | preview.set_rating (result.average_rating / 5.0f, result.total_rating); | ||
403 | 1401 | } | ||
404 | 1402 | |||
405 | 1403 | if (details.hardware_requirements != "") | ||
406 | 1404 | preview.add_info (new InfoHint ("hardware-requirements", _("Hardware requirements"), null, details.hardware_requirements)); | ||
407 | 1405 | |||
408 | 1406 | if (uri.has_prefix ("unity-install://")) // application needs to be purchased/installed | ||
409 | 1407 | { | ||
410 | 1408 | // uninstalled and not purchased before | ||
411 | 1409 | if (details.pkg_state == SoftwareCenterData.PackageState.NEEDS_PURCHASE) | ||
412 | 1410 | { | ||
413 | 1411 | var buy_action = new Unity.PreviewAction ("buy", _("Buy"), null); | ||
414 | 1412 | if (details.price != null && details.price != "") | ||
415 | 1413 | { | ||
416 | 1414 | buy_action.extra_text = details.price; | ||
417 | 1415 | } | ||
418 | 1416 | |||
419 | 1417 | buy_action.activated.connect (start_software_center); | ||
420 | 1418 | preview.add_action (buy_action); | ||
421 | 1419 | } | ||
422 | 1420 | else // uninstalled, purchased before | ||
423 | 1421 | { | ||
424 | 1422 | |||
425 | 1423 | Unity.PreviewAction install_action = null; | ||
426 | 1424 | if (details.raw_price == null || details.raw_price == "") | ||
427 | 1425 | { | ||
428 | 1426 | install_action = new Unity.PreviewAction ("install", _("Free Download"), null); | ||
429 | 1427 | install_action.activated.connect (app_preview_install); | ||
430 | 1428 | } | ||
431 | 1429 | else | ||
432 | 1430 | { | ||
433 | 1431 | install_action = new Unity.PreviewAction ("install", _("Install"), null); | ||
434 | 1432 | install_action.activated.connect (start_software_center); | ||
435 | 1433 | } | ||
436 | 1434 | preview.add_action (install_action); | ||
437 | 1435 | } | ||
438 | 1436 | |||
439 | 1437 | if (details.website != null && details.website != "") | ||
440 | 1438 | { | ||
441 | 1439 | preview_developer_website = details.website; | ||
442 | 1440 | var website_action = new Unity.PreviewAction ("website", _("Developer Site"), null); | ||
443 | 1441 | website_action.activated.connect (app_preview_website); | ||
444 | 1442 | preview.add_action (website_action); | ||
445 | 1443 | } | ||
446 | 1444 | } | ||
447 | 1445 | else // application is already installed | ||
448 | 1446 | { | ||
449 | 1447 | preview.add_info (new InfoHint ("date-installed", _("Installed on"), null, details.installation_date)); | ||
450 | 1448 | var launch_action = new Unity.PreviewAction ("launch", _("Launch"), null); | ||
451 | 1449 | preview.add_action (launch_action); | ||
452 | 1450 | if (!details.is_desktop_dependency) | ||
453 | 1451 | { | ||
454 | 1452 | var uninstall_action = new Unity.PreviewAction ("uninstall", _("Uninstall"), null); | ||
455 | 1453 | uninstall_action.activated.connect (app_preview_uninstall); | ||
456 | 1454 | preview.add_action (uninstall_action); | ||
457 | 1455 | } | ||
458 | 1456 | } | ||
459 | 1457 | |||
460 | 1458 | preview_installable_desktop_file = details.desktop_file; | ||
461 | 1459 | preview_installable_icon_file = details.icon; | ||
462 | 1460 | } | ||
463 | 1461 | catch (Error e) | ||
464 | 1462 | { | ||
465 | 1463 | warning ("Failed to get package details for '%s': %s", uri, e.message); | ||
466 | 1464 | preview = null; | ||
467 | 1465 | } | ||
468 | 1466 | } | ||
469 | 1467 | |||
470 | 1468 | // xapian db doesn't know this .desktop file or S-C dbus data provider fails, | ||
471 | 1469 | // fallback to DesktopAppInfo (based on installed .desktop file) if available | ||
472 | 1470 | if (preview == null && desktopfile != null) | ||
473 | 1471 | { | ||
474 | 1472 | var app_info = new DesktopAppInfo (desktopfile); | ||
475 | 1473 | if (app_info != null) | ||
476 | 1474 | { | ||
477 | 1475 | preview = new Unity.ApplicationPreview (app_info.get_display_name (), "", app_info.get_description () ?? "", app_info.get_icon (), null); | ||
478 | 1476 | var launch_action = new Unity.PreviewAction ("launch", _("Launch"), null); | ||
479 | 1477 | preview.add_action (launch_action); | ||
480 | 1478 | } | ||
481 | 1479 | } | ||
482 | 1480 | |||
483 | 1481 | if (preview == null) | ||
484 | 1482 | { | ||
485 | 1483 | warning ("No pksearcher nor desktop app info for '%s'", uri); | ||
486 | 1484 | } | ||
495 | 1485 | } | 1621 | } |
497 | 1486 | else if (is_scope) | 1622 | if (preview != null && scope_id != "home.scope" && |
498 | 1623 | scope_id != "applications.scope") | ||
499 | 1487 | { | 1624 | { |
585 | 1488 | var scope_id = uri.substring (8); | 1625 | PreviewAction action; |
586 | 1489 | bool scope_disabled = scope_id in disabled_scope_ids; | 1626 | preview.set_rating(-1.0f, 0); |
587 | 1490 | 1627 | if (scope_disabled) | |
588 | 1491 | // figure out if the scope is remote | 1628 | { |
589 | 1492 | bool is_remote_scope = false; | 1629 | action = new Unity.PreviewAction ("enable-scope", _("Enable"), null); |
590 | 1493 | var info = scopesearcher.get_by_desktop_file (scope_id); | 1630 | action.activated.connect (() => |
506 | 1494 | |||
507 | 1495 | Dee.ModelIter found_iter = null; | ||
508 | 1496 | if (info == null) | ||
509 | 1497 | { | ||
510 | 1498 | var iter = remote_scopes_model.get_first_iter (); | ||
511 | 1499 | var end_iter = remote_scopes_model.get_last_iter (); | ||
512 | 1500 | while (iter != end_iter) | ||
513 | 1501 | { | ||
514 | 1502 | if (remote_scopes_model.get_string (iter, 0) == scope_id) | ||
515 | 1503 | { | ||
516 | 1504 | is_remote_scope = true; | ||
517 | 1505 | found_iter = iter; | ||
518 | 1506 | break; | ||
519 | 1507 | } | ||
520 | 1508 | iter = remote_scopes_model.next (iter); | ||
521 | 1509 | } | ||
522 | 1510 | } | ||
523 | 1511 | |||
524 | 1512 | if (is_remote_scope) | ||
525 | 1513 | { | ||
526 | 1514 | var name = remote_scopes_model.get_string (found_iter, 1); | ||
527 | 1515 | if (name == null || name == "") | ||
528 | 1516 | name = remote_scopes_model.get_string (found_iter, 0); | ||
529 | 1517 | var description = remote_scopes_model.get_string (found_iter, 2); | ||
530 | 1518 | Icon? icon = null; | ||
531 | 1519 | Icon? screenshot = null; | ||
532 | 1520 | var icon_hint = remote_scopes_model.get_string (found_iter, 3); | ||
533 | 1521 | var screenshot_url = remote_scopes_model.get_string (found_iter, 4); | ||
534 | 1522 | try | ||
535 | 1523 | { | ||
536 | 1524 | if (icon_hint != "") icon = Icon.new_for_string (icon_hint); | ||
537 | 1525 | if (screenshot_url != "") screenshot = Icon.new_for_string (screenshot_url); | ||
538 | 1526 | } | ||
539 | 1527 | catch (Error err) | ||
540 | 1528 | { | ||
541 | 1529 | warning ("%s", err.message); | ||
542 | 1530 | } | ||
543 | 1531 | |||
544 | 1532 | if (icon == null) icon = get_default_scope_icon (); | ||
545 | 1533 | |||
546 | 1534 | preview = new Unity.ApplicationPreview (name, | ||
547 | 1535 | "", | ||
548 | 1536 | description, | ||
549 | 1537 | icon, | ||
550 | 1538 | screenshot); | ||
551 | 1539 | } | ||
552 | 1540 | else if (info != null) | ||
553 | 1541 | { | ||
554 | 1542 | var name = info.application_name; | ||
555 | 1543 | if (name == null || name == "") | ||
556 | 1544 | name = info.desktop_file; | ||
557 | 1545 | // XXX: add this to package info. | ||
558 | 1546 | var description = info.description; | ||
559 | 1547 | Icon? icon = null; | ||
560 | 1548 | try | ||
561 | 1549 | { | ||
562 | 1550 | if (info.icon != null && info.icon != "") | ||
563 | 1551 | icon = Icon.new_for_string (info.icon); | ||
564 | 1552 | } | ||
565 | 1553 | catch (Error err) | ||
566 | 1554 | { | ||
567 | 1555 | warning ("%s", err.message); | ||
568 | 1556 | } | ||
569 | 1557 | if (icon == null) | ||
570 | 1558 | icon = get_default_scope_icon (); | ||
571 | 1559 | |||
572 | 1560 | preview = new Unity.ApplicationPreview (name, | ||
573 | 1561 | "", | ||
574 | 1562 | description, | ||
575 | 1563 | icon, | ||
576 | 1564 | null); | ||
577 | 1565 | } | ||
578 | 1566 | if (preview != null) { | ||
579 | 1567 | PreviewAction action; | ||
580 | 1568 | preview.set_rating(-1.0f, 0); | ||
581 | 1569 | if (scope_disabled) | ||
582 | 1570 | { | ||
583 | 1571 | action = new Unity.PreviewAction ("enable-scope", _("Enable"), null); | ||
584 | 1572 | action.activated.connect (() => | ||
591 | 1573 | { | 1631 | { |
592 | 1574 | enable_scope (scope_id); | 1632 | enable_scope (scope_id); |
593 | 1575 | return new ActivationResponse.with_preview (this.preview (uri)); | 1633 | return new ActivationResponse.with_preview (this.preview (uri)); |
594 | 1576 | }); | 1634 | }); |
600 | 1577 | } | 1635 | } |
601 | 1578 | else | 1636 | else |
602 | 1579 | { | 1637 | { |
603 | 1580 | action = new Unity.PreviewAction ("disable-scope", _("Disable"), null); | 1638 | action = new Unity.PreviewAction ("disable-scope", _("Disable"), null); |
604 | 1581 | action.activated.connect (() => | 1639 | action.activated.connect (() => |
605 | 1582 | { | 1640 | { |
606 | 1583 | disable_scope (scope_id); | 1641 | disable_scope (scope_id); |
607 | 1584 | return new ActivationResponse.with_preview (this.preview (uri)); | 1642 | return new ActivationResponse.with_preview (this.preview (uri)); |
608 | 1585 | }); | 1643 | }); |
609 | 1586 | } | ||
610 | 1587 | preview.add_action (action); | ||
611 | 1588 | } | 1644 | } |
612 | 1645 | preview.add_action (action); | ||
613 | 1589 | } | 1646 | } |
614 | 1590 | return preview; | 1647 | return preview; |
615 | 1591 | } | 1648 | } |
PASSED: Continuous integration, rev:343 jenkins. qa.ubuntu. com/job/ unity-team- unity-lens- applications- libunity7- compatible- ci/11/ jenkins. qa.ubuntu. com/job/ unity-team- unity-lens- applications- libunity7- compatible- raring- amd64-ci/ 11
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-team- unity-lens- applications- libunity7- compatible- ci/11/rebuild
http://