Merge lp:~dobey/unity-scope-click/show-price into lp:unity-scope-click

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 87
Merged at revision: 87
Proposed branch: lp:~dobey/unity-scope-click/show-price
Merge into: lp:unity-scope-click
Diff against target: 66 lines (+7/-9)
3 files modified
src/click-scope.vala (+4/-6)
src/click-webservice.vala (+2/-2)
src/test-click-webservice.vala (+1/-1)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/show-price
Reviewer Review Type Date Requested Status
Mike McCracken (community) Approve
PS Jenkins bot continuous-integration Approve
Roberto Alsina (community) Approve
Review via email: mp+198054@code.launchpad.net

Commit message

Refactor the price to not be converted to a string until necessary.
Show the price in the Buy button.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Mike McCracken (mikemc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/click-scope.vala'
2--- src/click-scope.vala 2013-12-05 19:43:31 +0000
3+++ src/click-scope.vala 2013-12-06 13:47:07 +0000
4@@ -129,13 +129,13 @@
5 }
6
7 async Unity.Preview build_uninstalled_preview (Unity.ScopeResult result) {
8- var price = result.metadata.get(METADATA_PRICE).get_string();
9+ var price = result.metadata.get(METADATA_PRICE).get_double();
10 Unity.Preview preview = yield build_app_preview (result);
11 if (!(preview is Unity.GenericPreview)) {
12- if (price == "0.0") {
13+ if (price == 0.0f) {
14 preview.add_action (new Unity.PreviewAction (ACTION_INSTALL_CLICK, ("Install"), null));
15 } else {
16- preview.add_action (new Unity.PreviewAction (ACTION_BUY_CLICK, ("Buy"), null));
17+ preview.add_action (new Unity.PreviewAction (ACTION_BUY_CLICK, ("Buy for %0.2f".printf(price)), null));
18 }
19 }
20 return preview;
21@@ -367,9 +367,7 @@
22 }
23 metadata.insert(METADATA_APP_ID, new GLib.Variant.string(app.app_id));
24 metadata.insert(METADATA_TITLE, new GLib.Variant.string(app.title));
25- if (app.price != null) {
26- metadata.insert(METADATA_PRICE, new GLib.Variant.string(app.price));
27- }
28+ metadata.insert(METADATA_PRICE, new GLib.Variant.double(app.price));
29
30 var result = Unity.ScopeResult.create(uri, app.icon_url, category, Unity.ResultType.DEFAULT, mimetype, app.title, comment, dnd_uri, metadata);
31
32
33=== modified file 'src/click-webservice.vala'
34--- src/click-webservice.vala 2013-10-14 17:46:39 +0000
35+++ src/click-webservice.vala 2013-12-06 13:47:07 +0000
36@@ -50,7 +50,7 @@
37 AppState state;
38 public string app_id { get; set; }
39 public string title { get; set; }
40- public string price { get; set; }
41+ public double price { get; set; }
42 public string icon_url { get; set; }
43 public string uri { get; set; }
44 public static const string CLICK_INSTALL_SCHEMA = "click-install://";
45@@ -77,7 +77,7 @@
46 app_id: _app_id,
47 icon_url: json.get_string_member(JSON_FIELD_ICON_URL),
48 title: json.get_string_member(JSON_FIELD_TITLE),
49- price: json.get_double_member(JSON_FIELD_PRICE).to_string(),
50+ price: json.get_double_member(JSON_FIELD_PRICE),
51 uri: CLICK_INSTALL_SCHEMA + _app_id
52 );
53 state = AppState.AVAILABLE;
54
55=== modified file 'src/test-click-webservice.vala'
56--- src/test-click-webservice.vala 2013-12-05 13:31:54 +0000
57+++ src/test-click-webservice.vala 2013-12-06 13:47:07 +0000
58@@ -52,7 +52,7 @@
59 var app = new AvailableApps.from_json (FAKE_JSON_SEARCH_RESULT)[1];
60 assert_cmpstr (app.app_id, OperatorType.EQUAL, "org.example.fantastiqueapp");
61 assert_cmpstr (app.title, OperatorType.EQUAL, "Fantastic App");
62- assert_cmpstr (app.price, OperatorType.EQUAL, "0");
63+ assert (app.price == 0.0f);
64 assert_cmpstr (app.icon_url, OperatorType.EQUAL, "http://assets.ubuntu.com/sites/ubuntu/504/u/img/ubuntu/features/icon-find-more-apps-64x64.png");
65 } catch (GLib.Error e)
66 {

Subscribers

People subscribed via source and target branches

to all changes: