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