Merge lp:~nick-dedekind/unity/preview-action-extra-text into lp:unity

Proposed by Nick Dedekind on 2012-09-13
Status: Merged
Approved by: Michal Hruby on 2012-09-14
Approved revision: 2687
Merged at revision: 2689
Proposed branch: lp:~nick-dedekind/unity/preview-action-extra-text
Merge into: lp:unity
Diff against target: 550 lines (+190/-17)
10 files modified
dash/previews/ActionButton.cpp (+47/-4)
dash/previews/ActionButton.h (+8/-1)
dash/previews/Preview.cpp (+5/-1)
dash/previews/StandaloneApplicationPreview.cpp (+18/-7)
tests/test_previews_application.cpp (+25/-1)
tests/test_previews_generic.cpp (+25/-1)
tests/test_previews_movie.cpp (+25/-1)
tests/test_previews_music.cpp (+25/-1)
unity-shared/PreviewStyle.cpp (+9/-0)
unity-shared/PreviewStyle.h (+3/-0)
To merge this branch: bzr merge lp:~nick-dedekind/unity/preview-action-extra-text
Reviewer Review Type Date Requested Status
Michal Hruby (community) 2012-09-13 Approve on 2012-09-14
Review via email: mp+124168@code.launchpad.net

Commit Message

Added extra-text to preview actions (for price tags).

Description of the Change

Added extra-text to preview actions (for price tags).

To post a comment you must log in.
Michal Hruby (mhr3) wrote :

Could we get a test? Or will that be done in a separate branch?

review: Needs Information
2686. By Nick Dedekind on 2012-09-13

Added unity test cases for preview extra-text

2687. By Nick Dedekind on 2012-09-13

Added preview action button accessors for label and extra text.

Nick Dedekind (nick-dedekind) wrote :

Added unity tests

Michal Hruby (mhr3) wrote :

Awesome!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/ActionButton.cpp'
2--- dash/previews/ActionButton.cpp 2012-09-10 15:43:52 +0000
3+++ dash/previews/ActionButton.cpp 2012-09-13 16:15:29 +0000
4@@ -50,7 +50,7 @@
5 SetAcceptKeyNavFocusOnMouseDown(false);
6 SetAcceptKeyNavFocusOnMouseEnter(false);
7 Init();
8- BuildLayout(label, icon_hint);
9+ BuildLayout(label, icon_hint, "");
10 }
11
12 ActionButton::~ActionButton()
13@@ -105,7 +105,19 @@
14 SetMinimumWidth(kMinButtonWidth);
15 }
16
17-void ActionButton::BuildLayout(std::string const& label, std::string const& icon_hint)
18+void ActionButton::SetExtraHint(std::string const& extra_hint, std::string const& font_hint)
19+{
20+ extra_font_hint_= font_hint;
21+ if (extra_text_)
22+ {
23+ extra_text_->SetFont(extra_font_hint_);
24+ ComputeContentSize();
25+ QueueDraw();
26+ }
27+ BuildLayout(label_, icon_hint_, extra_hint);
28+}
29+
30+void ActionButton::BuildLayout(std::string const& label, std::string const& icon_hint, std::string const& extra_hint)
31 {
32 if (icon_hint != icon_hint_)
33 {
34@@ -121,7 +133,7 @@
35 image_ = new IconTexture(icon_hint, icon_size);
36 image_->texture_updated.connect([&](nux::BaseTexture*)
37 {
38- BuildLayout(label_, icon_hint_);
39+ BuildLayout(label_, icon_hint_, extra_hint_);
40 });
41 image_->SetInputEventSensitivity(false);
42 image_->SetMinMaxSize(icon_size, icon_size);
43@@ -147,16 +159,37 @@
44 }
45 }
46
47+ if (extra_hint != extra_hint_)
48+ {
49+ extra_hint_ = extra_hint;
50+ if (extra_text_)
51+ {
52+ extra_text_.Release();
53+ extra_text_ = NULL;
54+ }
55+
56+ if (!extra_hint_.empty())
57+ {
58+ extra_text_ = new nux::StaticCairoText(extra_hint_, true, NUX_TRACKER_LOCATION);
59+ if (!extra_font_hint_.empty())
60+ extra_text_->SetFont(extra_font_hint_);
61+ extra_text_->SetInputEventSensitivity(false);
62+ extra_text_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_CENTRE);
63+ }
64+ }
65+
66 RemoveLayout();
67
68 nux::HLayout* layout = new nux::HLayout();
69 layout->SetHorizontalInternalMargin(6);
70- layout->SetPadding(2, 11, 2, 11);
71+ layout->SetPadding(2, 0, 2, 0);
72 layout->AddSpace(0,1);
73 if (image_)
74 layout->AddView(image_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
75 if (static_text_)
76 layout->AddView(static_text_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
77+ if (extra_text_)
78+ layout->AddView(extra_text_.GetPointer(), 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
79 layout->AddSpace(0,1);
80 SetLayout(layout);
81
82@@ -302,5 +335,15 @@
83 QueueDraw();
84 }
85
86+std::string ActionButton::GetLabel() const
87+{
88+ return label_;
89+}
90+
91+std::string ActionButton::GetExtraText() const
92+{
93+ return extra_hint_;
94+}
95+
96 } // namespace dash
97 } // namespace unity
98
99=== modified file 'dash/previews/ActionButton.h'
100--- dash/previews/ActionButton.h 2012-08-16 09:09:37 +0000
101+++ dash/previews/ActionButton.h 2012-09-13 16:15:29 +0000
102@@ -49,10 +49,14 @@
103 sigc::signal<void, ActionButton*, std::string const&> click;
104
105 void SetFont(std::string const& font_hint);
106+ void SetExtraHint(std::string const& extra_hint, std::string const& font_hint);
107
108 void Activate();
109 void Deactivate();
110
111+ std::string GetLabel() const;
112+ std::string GetExtraText() const;
113+
114 protected:
115 virtual long ComputeContentSize();
116 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
117@@ -64,7 +68,7 @@
118 void RedrawTheme(nux::Geometry const& geom, cairo_t* cr, nux::ButtonVisualState faked_state);
119 void RedrawFocusOverlay(nux::Geometry const& geom, cairo_t* cr);
120
121- void BuildLayout(std::string const& label, std::string const& icon_hint);
122+ void BuildLayout(std::string const& label, std::string const& icon_hint, std::string const& extra_hint);
123
124 // From debug::Introspectable
125 std::string GetName() const;
126@@ -83,9 +87,12 @@
127 std::string action_hint_;
128 std::string icon_hint_;
129 std::string font_hint_;
130+ std::string extra_hint_;
131+ std::string extra_font_hint_;
132
133 nux::ObjectPtr<IconTexture> image_;
134 nux::ObjectPtr<nux::StaticCairoText> static_text_;
135+ nux::ObjectPtr<nux::StaticCairoText> extra_text_;
136 };
137
138 } // namespace dash
139
140=== modified file 'dash/previews/Preview.cpp'
141--- dash/previews/Preview.cpp 2012-08-22 08:16:02 +0000
142+++ dash/previews/Preview.cpp 2012-09-13 16:15:29 +0000
143@@ -136,6 +136,8 @@
144 dash::Preview::ActionPtr action = actions[action_iter];
145
146 ActionButton* button = new ActionButton(action->id, action->display_name, action->icon_hint, NUX_TRACKER_LOCATION);
147+ button->SetFont(style.action_font());
148+ button->SetExtraHint(action->extra_text, style.action_extra_font());
149 AddChild(button);
150 button->click.connect(sigc::mem_fun(this, &Preview::OnActionActivated));
151 buttons.push_back(button);
152@@ -165,9 +167,11 @@
153 uint action_iter = 0;
154 for (uint i = 0; i < actions.size(); i++)
155 {
156- dash::Preview::ActionPtr action = actions[action_iter];
157+ dash::Preview::ActionPtr action = actions[action_iter++];
158
159 ActionButton* button = new ActionButton(action->id, action->display_name, action->icon_hint, NUX_TRACKER_LOCATION);
160+ button->SetFont(style.action_font());
161+ button->SetExtraHint(action->extra_text, style.action_extra_font());
162 AddChild(button);
163 button->click.connect(sigc::mem_fun(this, &Preview::OnActionActivated));
164 buttons.push_back(button);
165
166=== modified file 'dash/previews/StandaloneApplicationPreview.cpp'
167--- dash/previews/StandaloneApplicationPreview.cpp 2012-08-10 12:55:06 +0000
168+++ dash/previews/StandaloneApplicationPreview.cpp 2012-09-13 16:15:29 +0000
169@@ -164,6 +164,9 @@
170 glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
171 glib::Object<GIcon> iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL));
172
173+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
174+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99"));
175+
176 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
177
178 unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
179@@ -173,13 +176,12 @@
180 unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 0.5);
181 unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 17);
182
183-
184 unity_protocol_preview_set_image_source_uri(proto_obj, "file:///home/nick/Skype.png");
185 unity_protocol_preview_set_title(proto_obj, app_name.str().c_str());
186 unity_protocol_preview_set_subtitle(proto_obj, subtitle);
187 unity_protocol_preview_set_description(proto_obj, description);
188 unity_protocol_preview_add_action(proto_obj, "uninstall", "Uninstall", iconHint1, 0);
189- unity_protocol_preview_add_action(proto_obj, "launch", "Launch", iconHint2, 0);
190+ unity_protocol_preview_add_action_with_hints(proto_obj, "launch", "Download", iconHint2, 0, action_hints1);
191 unity_protocol_preview_add_info_hint(proto_obj, "time", "Total time", iconHint1, g_variant_new("s", "16 h 34miin 45sec"));
192 unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh"));
193 unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("i", 12));
194@@ -190,6 +192,7 @@
195 dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v));
196 container_->Preview(preview_model, previews::Navigation::RIGHT);
197
198+ g_hash_table_unref(action_hints1);
199 }
200
201 void TestRunner::NavRight()
202@@ -206,10 +209,11 @@
203 glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
204 glib::Object<GIcon> iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL));
205
206+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
207+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99"));
208+
209 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
210
211-
212-
213 unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
214 unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Proprietary");
215 unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "(c) Skype 2012");
216@@ -222,7 +226,7 @@
217 unity_protocol_preview_set_subtitle(proto_obj, subtitle);
218 unity_protocol_preview_set_description(proto_obj, description);
219 unity_protocol_preview_add_action(proto_obj, "uninstall", "Uninstall", iconHint1, 0);
220- unity_protocol_preview_add_action(proto_obj, "launch", "Launch", iconHint2, 0);
221+ unity_protocol_preview_add_action_with_hints(proto_obj, "launch", "Download", iconHint2, 0, action_hints1);
222 unity_protocol_preview_add_info_hint(proto_obj, "time", "Total time", iconHint1, g_variant_new("s", "16 h 34miin 45sec"));
223 unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh"));
224 unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("d", 12.1));
225@@ -232,6 +236,8 @@
226
227 dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v));
228 container_->Preview(preview_model, previews::Navigation::RIGHT);
229+
230+ g_hash_table_unref(action_hints1);
231 }
232
233 void TestRunner::NavLeft()
234@@ -251,7 +257,10 @@
235 glib::Object<GIcon> iconHint2(g_icon_new_for_string("/usr/share/unity/5/lens-nav-home.svg", NULL));
236 glib::Object<GIcon> iconHint3(g_icon_new_for_string("/usr/share/unity/5/lens-nav-people.svg", NULL));
237
238- glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
239+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
240+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99"));
241+
242+ glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
243
244
245 unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
246@@ -266,7 +275,7 @@
247 unity_protocol_preview_set_subtitle(proto_obj, subtitle);
248 unity_protocol_preview_set_description(proto_obj, description);
249 unity_protocol_preview_add_action(proto_obj, "uninstall", "Uninstall", iconHint1, 0);
250- unity_protocol_preview_add_action(proto_obj, "launch", "Launch", iconHint2, 0);
251+ unity_protocol_preview_add_action_with_hints(proto_obj, "launch", "Download", iconHint2, 0, action_hints1);
252 unity_protocol_preview_add_info_hint(proto_obj, "time", "Total time", iconHint1, g_variant_new("s", "16 h 34miin 45sec"));
253 unity_protocol_preview_add_info_hint(proto_obj, "energy", "Energy", iconHint2, g_variant_new("s", "58.07 mWh"));
254 unity_protocol_preview_add_info_hint(proto_obj, "load", "CPU Load", iconHint3, g_variant_new("i", 22));
255@@ -277,6 +286,8 @@
256 dash::Preview::Ptr preview_model(dash::Preview::PreviewForVariant(v));
257 container_->Preview(preview_model, previews::Navigation::LEFT);
258
259+ g_hash_table_unref(action_hints1);
260+
261 return false;
262 }));
263 }
264
265=== modified file 'tests/test_previews_application.cpp'
266--- tests/test_previews_application.cpp 2012-08-21 09:47:11 +0000
267+++ tests/test_previews_application.cpp 2012-09-13 16:15:29 +0000
268@@ -34,6 +34,7 @@
269 #include "dash/previews/ApplicationPreview.h"
270 #include "dash/previews/PreviewInfoHintWidget.h"
271 #include "dash/previews/PreviewRatingsWidget.h"
272+#include "dash/previews/ActionButton.h"
273 #include "test_utils.h"
274 using namespace unity;
275 using namespace unity::dash;
276@@ -69,6 +70,9 @@
277 {
278 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
279
280+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
281+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£30.99"));
282+
283 unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
284 unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "License & special char");
285 unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Copywrite & special char");
286@@ -81,13 +85,15 @@
287 unity_protocol_preview_set_subtitle(proto_obj, "Application Subtitle > special char");
288 unity_protocol_preview_set_description(proto_obj, "Application Desctiption &lt; special char");
289 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
290- unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
291+ unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action 2", NULL, 0, action_hints1);
292 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
293 unity_protocol_preview_add_info_hint(proto_obj, "hint2", "Hint 2", NULL, g_variant_new("s", "string hint 2"));
294 unity_protocol_preview_add_info_hint(proto_obj, "hint3", "Hint 3", NULL, g_variant_new("i", 12));
295
296 glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef());
297 preview_model_ = dash::Preview::PreviewForVariant(v);
298+
299+ g_hash_table_unref(action_hints1);
300 }
301
302 nux::BaseWindow* parent_window_;
303@@ -119,6 +125,24 @@
304
305 EXPECT_EQ(preview_view->app_rating_->GetRating(), 0.8f);
306 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
307+
308+ if (preview_view->action_buttons_.size() >= 2)
309+ {
310+ auto iter = preview_view->action_buttons_.begin();
311+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
312+ {
313+ ActionButton *action = static_cast<ActionButton*>(*iter);
314+ EXPECT_EQ(action->GetLabel(), "Action 1");
315+ EXPECT_EQ(action->GetExtraText(), "");
316+ }
317+ iter++;
318+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
319+ {
320+ ActionButton *action = static_cast<ActionButton*>(*iter);
321+ EXPECT_EQ(action->GetLabel(), "Action 2");
322+ EXPECT_EQ(action->GetExtraText(), "£30.99");
323+ }
324+ }
325 }
326
327 }
328
329=== modified file 'tests/test_previews_generic.cpp'
330--- tests/test_previews_generic.cpp 2012-08-21 09:47:11 +0000
331+++ tests/test_previews_generic.cpp 2012-09-13 16:15:29 +0000
332@@ -32,6 +32,7 @@
333 #include <unity-protocol.h>
334 #include "UnityCore/GenericPreview.h"
335 #include "dash/previews/GenericPreview.h"
336+#include "dash/previews/ActionButton.h"
337 #include "test_utils.h"
338 using namespace unity;
339 using namespace unity::dash;
340@@ -63,18 +64,23 @@
341 {
342 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_generic_preview_new()));
343
344+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
345+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("2.00"));
346+
347 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
348 unity_protocol_preview_set_title(proto_obj, "Generic Title & special char");
349 unity_protocol_preview_set_subtitle(proto_obj, "Generic Subtitle > special char");
350 unity_protocol_preview_set_description(proto_obj, "Generic Desctiption &lt; special char");
351 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
352- unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
353+ unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action 2", NULL, 0, action_hints1);
354 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
355 unity_protocol_preview_add_info_hint(proto_obj, "hint2", "Hint 2", NULL, g_variant_new("s", "string hint 2"));
356 unity_protocol_preview_add_info_hint(proto_obj, "hint3", "Hint 3", NULL, g_variant_new("i", 12));
357
358 glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef());
359 preview_model_ = dash::Preview::PreviewForVariant(v);
360+
361+ g_hash_table_unref(action_hints1);
362 }
363
364 nux::BaseWindow* parent_window_;
365@@ -102,6 +108,24 @@
366 EXPECT_EQ(preview_view->description_->GetText(), "Generic Desctiption &lt; special char");
367
368 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
369+
370+ if (preview_view->action_buttons_.size() >= 2)
371+ {
372+ auto iter = preview_view->action_buttons_.begin();
373+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
374+ {
375+ ActionButton *action = static_cast<ActionButton*>(*iter);
376+ EXPECT_EQ(action->GetLabel(), "Action 1");
377+ EXPECT_EQ(action->GetExtraText(), "");
378+ }
379+ iter++;
380+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
381+ {
382+ ActionButton *action = static_cast<ActionButton*>(*iter);
383+ EXPECT_EQ(action->GetLabel(), "Action 2");
384+ EXPECT_EQ(action->GetExtraText(), "2.00");
385+ }
386+ }
387 }
388
389 }
390
391=== modified file 'tests/test_previews_movie.cpp'
392--- tests/test_previews_movie.cpp 2012-08-21 09:47:11 +0000
393+++ tests/test_previews_movie.cpp 2012-09-13 16:15:29 +0000
394@@ -34,6 +34,7 @@
395 #include "dash/previews/MoviePreview.h"
396 #include "dash/previews/PreviewInfoHintWidget.h"
397 #include "dash/previews/PreviewRatingsWidget.h"
398+#include "dash/previews/ActionButton.h"
399 #include "test_utils.h"
400 using namespace unity;
401 using namespace unity::dash;
402@@ -66,6 +67,9 @@
403 {
404 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_movie_preview_new()));
405
406+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
407+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£1.00"));
408+
409 unity_protocol_movie_preview_set_rating(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), 0.8);
410 unity_protocol_movie_preview_set_num_ratings(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), 12);
411
412@@ -74,13 +78,15 @@
413 unity_protocol_preview_set_subtitle(proto_obj, "Movie Subtitle > special char");
414 unity_protocol_preview_set_description(proto_obj, "Movie Desctiption &lt; special char");
415 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
416- unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
417+ unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action 2", NULL, 0, action_hints1);
418 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
419 unity_protocol_preview_add_info_hint(proto_obj, "hint2", "Hint 2", NULL, g_variant_new("s", "string hint 2"));
420 unity_protocol_preview_add_info_hint(proto_obj, "hint3", "Hint 3", NULL, g_variant_new("i", 12));
421
422 glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef());
423 preview_model_ = dash::Preview::PreviewForVariant(v);
424+
425+ g_hash_table_unref(action_hints1);
426 }
427
428 nux::BaseWindow* parent_window_;
429@@ -109,6 +115,24 @@
430
431 EXPECT_EQ(preview_view->rating_->GetRating(), 0.8f);
432 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
433+
434+ if (preview_view->action_buttons_.size() >= 2)
435+ {
436+ auto iter = preview_view->action_buttons_.begin();
437+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
438+ {
439+ ActionButton *action = static_cast<ActionButton*>(*iter);
440+ EXPECT_EQ(action->GetLabel(), "Action 1");
441+ EXPECT_EQ(action->GetExtraText(), "");
442+ }
443+ iter++;
444+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
445+ {
446+ ActionButton *action = static_cast<ActionButton*>(*iter);
447+ EXPECT_EQ(action->GetLabel(), "Action 2");
448+ EXPECT_EQ(action->GetExtraText(), "£1.00");
449+ }
450+ }
451 }
452
453 }
454
455=== modified file 'tests/test_previews_music.cpp'
456--- tests/test_previews_music.cpp 2012-08-21 09:47:11 +0000
457+++ tests/test_previews_music.cpp 2012-09-13 16:15:29 +0000
458@@ -34,6 +34,7 @@
459 #include "dash/previews/MusicPreview.h"
460 #include "dash/previews/PreviewInfoHintWidget.h"
461 #include "dash/previews/PreviewRatingsWidget.h"
462+#include "dash/previews/ActionButton.h"
463 #include "test_utils.h"
464 using namespace unity;
465 using namespace unity::dash;
466@@ -64,12 +65,15 @@
467 {
468 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_music_preview_new()));
469
470+ GHashTable* action_hints1(g_hash_table_new(g_direct_hash, g_direct_equal));
471+ g_hash_table_insert (action_hints1, g_strdup ("extra-text"), g_variant_new_string("£3.99"));
472+
473 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
474 unity_protocol_preview_set_title(proto_obj, "Music Title & special char");
475 unity_protocol_preview_set_subtitle(proto_obj, "Music Subtitle > special char");
476 unity_protocol_preview_set_description(proto_obj, "Music Desctiption &lt; special char");
477 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
478- unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
479+ unity_protocol_preview_add_action_with_hints(proto_obj, "action2", "Action 2", NULL, 0, action_hints1);
480 unity_protocol_preview_add_action(proto_obj, "action3", "Action 3", NULL, 0);
481 unity_protocol_preview_add_action(proto_obj, "action4", "Action 4", NULL, 0);
482 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
483@@ -78,6 +82,8 @@
484
485 glib::Variant v(dee_serializable_serialize(DEE_SERIALIZABLE(proto_obj.RawPtr())), glib::StealRef());
486 preview_model_ = dash::Preview::PreviewForVariant(v);
487+
488+ g_hash_table_unref(action_hints1);
489 }
490
491 nux::BaseWindow* parent_window_;
492@@ -104,6 +110,24 @@
493 EXPECT_EQ(preview_view->subtitle_->GetText(), "Music Subtitle &gt; special char");
494
495 EXPECT_EQ(preview_view->action_buttons_.size(), 4);
496+
497+ if (preview_view->action_buttons_.size() >= 2)
498+ {
499+ auto iter = preview_view->action_buttons_.begin();
500+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
501+ {
502+ ActionButton *action = static_cast<ActionButton*>(*iter);
503+ EXPECT_EQ(action->GetLabel(), "Action 1");
504+ EXPECT_EQ(action->GetExtraText(), "");
505+ }
506+ iter++;
507+ if ((*iter)->Type().IsDerivedFromType(ActionButton::StaticObjectType))
508+ {
509+ ActionButton *action = static_cast<ActionButton*>(*iter);
510+ EXPECT_EQ(action->GetLabel(), "Action 2");
511+ EXPECT_EQ(action->GetExtraText(), "£3.99");
512+ }
513+ }
514 }
515
516 }
517
518=== modified file 'unity-shared/PreviewStyle.cpp'
519--- unity-shared/PreviewStyle.cpp 2012-09-10 15:43:52 +0000
520+++ unity-shared/PreviewStyle.cpp 2012-09-13 16:15:29 +0000
521@@ -305,6 +305,15 @@
522 std::string Style::description_font() const
523 {
524 return "Ubuntu Light 10";
525+
526+}
527+std::string Style::action_font() const
528+{
529+ return "Ubuntu 11";
530+}
531+std::string Style::action_extra_font() const
532+{
533+ return "Ubuntu Bold 11";
534 }
535
536 std::string Style::app_license_font() const
537
538=== modified file 'unity-shared/PreviewStyle.h'
539--- unity-shared/PreviewStyle.h 2012-09-04 10:45:31 +0000
540+++ unity-shared/PreviewStyle.h 2012-09-13 16:15:29 +0000
541@@ -90,6 +90,9 @@
542 std::string subtitle_size_font() const;
543 std::string description_font() const;
544
545+ std::string action_font() const;
546+ std::string action_extra_font() const;
547+
548 nux::AbstractPaintLayer* GetBackgroundLayer() const;
549
550 ////////////////////////////////