Merge lp:~nick-dedekind/unity/lp1039020.preview-text-escape into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Nick Dedekind
Approved revision: no longer in the source branch.
Merged at revision: 2633
Proposed branch: lp:~nick-dedekind/unity/lp1039020.preview-text-escape
Merge into: lp:unity
Diff against target: 424 lines (+71/-54)
14 files modified
dash/previews/ActionButton.cpp (+1/-1)
dash/previews/ApplicationPreview.cpp (+7/-8)
dash/previews/GenericPreview.cpp (+3/-4)
dash/previews/MoviePreview.cpp (+3/-4)
dash/previews/MusicPreview.cpp (+2/-2)
dash/previews/PreviewInfoHintWidget.cpp (+2/-2)
dash/previews/PreviewRatingsWidget.cpp (+1/-1)
dash/previews/Track.cpp (+1/-1)
tests/test_previews_application.cpp (+10/-10)
tests/test_previews_generic.cpp (+6/-6)
tests/test_previews_movie.cpp (+6/-6)
tests/test_previews_music.cpp (+5/-5)
unity-shared/StaticCairoText.cpp (+20/-3)
unity-shared/StaticCairoText.h (+4/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp1039020.preview-text-escape
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Sam Spilsbury (community) Approve
Review via email: mp+120522@code.launchpad.net

Commit message

Fixes non-escaped character sequences in dash previews. (LP #1039020)

Description of the change

Fixes non-escaped character sequences in dash previews. (LP #1039020)

Added escape sequent argument to a new StaticCairoText constructor for ease of access.
Dash Previews escape all strings from UnityCore preview models.

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

LGTM

review: Approve
Revision history for this message
Andrea Azzarone (azzar1) wrote :

+ std::string tmp_text = escape_text ? GetEscapedText(text) : text;

You can do:

std::string tmp_text = escape_text ? GetEscapedText(text) : std::move(text);

But using the gcc implementation of std::string coping and moving are equivalent.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

Attempt to merge into lp:unity failed due to conflicts:

text conflict in dash/previews/PreviewRatingsWidget.cpp

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-08-17 08:20:41 +0000
3+++ dash/previews/ActionButton.cpp 2012-08-28 08:32:21 +0000
4@@ -139,7 +139,7 @@
5
6 if (!label_.empty())
7 {
8- static_text_ = new nux::StaticCairoText(label_, NUX_TRACKER_LOCATION);
9+ static_text_ = new nux::StaticCairoText(label_, true, NUX_TRACKER_LOCATION);
10 if (!font_hint_.empty())
11 static_text_->SetFont(font_hint_);
12 static_text_->SetInputEventSensitivity(false);
13
14=== modified file 'dash/previews/ApplicationPreview.cpp'
15--- dash/previews/ApplicationPreview.cpp 2012-08-22 08:16:02 +0000
16+++ dash/previews/ApplicationPreview.cpp 2012-08-28 08:32:21 +0000
17@@ -202,14 +202,14 @@
18 title_subtitle_layout_ = new nux::VLayout();
19 title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
20
21- title_ = new nux::StaticCairoText(app_preview_model->title);
22+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
23 title_->SetLines(-1);
24 title_->SetFont(style.title_font().c_str());
25 title_subtitle_layout_->AddView(title_.GetPointer(), 1);
26
27- if (!app_preview_model->subtitle.Get().empty())
28+ if (!preview_model_->subtitle.Get().empty())
29 {
30- subtitle_ = new nux::StaticCairoText(app_preview_model->subtitle);
31+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
32 subtitle_->SetFont(style.subtitle_size_font().c_str());
33 subtitle_->SetLines(-1);
34 title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1);
35@@ -220,7 +220,7 @@
36
37 if (!app_preview_model->license.Get().empty())
38 {
39- license_ = new nux::StaticCairoText(app_preview_model->license);
40+ license_ = new nux::StaticCairoText(app_preview_model->license, true, NUX_TRACKER_LOCATION);
41 license_->SetFont(style.app_license_font().c_str());
42 license_->SetLines(-1);
43 app_updated_copywrite_layout->AddView(license_.GetPointer(), 1);
44@@ -231,14 +231,14 @@
45 std::stringstream last_update;
46 last_update << _("Last Updated") << " " << app_preview_model->last_update.Get();
47
48- last_update_ = new nux::StaticCairoText(last_update.str());
49+ last_update_ = new nux::StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION);
50 last_update_->SetFont(style.app_last_update_font().c_str());
51 app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1);
52 }
53
54 if (!app_preview_model->copyright.Get().empty())
55 {
56- copywrite_ = new nux::StaticCairoText(app_preview_model->copyright);
57+ copywrite_ = new nux::StaticCairoText(app_preview_model->copyright, true, NUX_TRACKER_LOCATION);
58 copywrite_->SetFont(style.app_copywrite_font().c_str());
59 copywrite_->SetLines(-1);
60 app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1);
61@@ -265,12 +265,11 @@
62
63 if (!preview_model_->description.Get().empty())
64 {
65- description_ = new nux::StaticCairoText("");
66+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
67 description_->SetFont(style.description_font().c_str());
68 description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
69 description_->SetLines(-style.GetDescriptionLineCount());
70 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
71- description_->SetText(app_preview_model->description);
72 app_info_layout->AddView(description_.GetPointer());
73 }
74
75
76=== modified file 'dash/previews/GenericPreview.cpp'
77--- dash/previews/GenericPreview.cpp 2012-08-22 08:16:02 +0000
78+++ dash/previews/GenericPreview.cpp 2012-08-28 08:32:21 +0000
79@@ -168,14 +168,14 @@
80 nux::VLayout* preview_data_layout = new nux::VLayout();
81 preview_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
82
83- title_ = new nux::StaticCairoText(preview_model_->title);
84+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
85 title_->SetLines(-1);
86 title_->SetFont(style.title_font().c_str());
87 preview_data_layout->AddView(title_.GetPointer(), 1);
88
89 if (!preview_model_->subtitle.Get().empty())
90 {
91- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
92+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
93 subtitle_->SetLines(-1);
94 subtitle_->SetFont(style.subtitle_size_font().c_str());
95 preview_data_layout->AddView(subtitle_.GetPointer(), 1);
96@@ -193,12 +193,11 @@
97
98 if (!preview_model_->description.Get().empty())
99 {
100- description_ = new nux::StaticCairoText("");
101+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
102 description_->SetFont(style.description_font().c_str());
103 description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
104 description_->SetLines(-style.GetDescriptionLineCount());
105 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
106- description_->SetText(preview_model_->description);
107 preview_info_layout->AddView(description_.GetPointer());
108 }
109
110
111=== modified file 'dash/previews/MoviePreview.cpp'
112--- dash/previews/MoviePreview.cpp 2012-08-22 08:16:02 +0000
113+++ dash/previews/MoviePreview.cpp 2012-08-28 08:32:21 +0000
114@@ -178,14 +178,14 @@
115 nux::VLayout* app_data_layout = new nux::VLayout();
116 app_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
117
118- title_ = new nux::StaticCairoText(preview_model_->title);
119+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
120 title_->SetLines(-1);
121 title_->SetFont(style.title_font().c_str());
122 app_data_layout->AddView(title_.GetPointer(), 1);
123
124 if (!preview_model_->subtitle.Get().empty())
125 {
126- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
127+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
128 subtitle_->SetLines(-1);
129 subtitle_->SetFont(style.subtitle_size_font().c_str());
130 app_data_layout->AddView(subtitle_.GetPointer(), 1);
131@@ -217,12 +217,11 @@
132
133 if (!preview_model_->description.Get().empty())
134 {
135- description_ = new nux::StaticCairoText("");
136+ description_ = new nux::StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped!
137 description_->SetFont(style.description_font().c_str());
138 description_->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_TOP);
139 description_->SetLines(-style.GetDescriptionLineCount());
140 description_->SetLineSpacing(style.GetDescriptionLineSpacing());
141- description_->SetText(preview_model_->description);
142 preview_info_layout->AddView(description_.GetPointer());
143 }
144 /////////////////////
145
146=== modified file 'dash/previews/MusicPreview.cpp'
147--- dash/previews/MusicPreview.cpp 2012-08-22 08:16:02 +0000
148+++ dash/previews/MusicPreview.cpp 2012-08-28 08:32:21 +0000
149@@ -160,14 +160,14 @@
150 nux::VLayout* album_data_layout = new nux::VLayout();
151 album_data_layout->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle());
152
153- title_ = new nux::StaticCairoText(preview_model_->title);
154+ title_ = new nux::StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION);
155 title_->SetFont(style.title_font().c_str());
156 title_->SetLines(-1);
157 album_data_layout->AddView(title_.GetPointer(), 1);
158
159 if (!preview_model_->subtitle.Get().empty())
160 {
161- subtitle_ = new nux::StaticCairoText(preview_model_->subtitle);
162+ subtitle_ = new nux::StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION);
163 subtitle_->SetFont(style.subtitle_size_font().c_str());
164 subtitle_->SetLines(-1);
165 album_data_layout->AddView(subtitle_.GetPointer(), 1);
166
167=== modified file 'dash/previews/PreviewInfoHintWidget.cpp'
168--- dash/previews/PreviewInfoHintWidget.cpp 2012-08-17 08:20:41 +0000
169+++ dash/previews/PreviewInfoHintWidget.cpp 2012-08-28 08:32:21 +0000
170@@ -160,14 +160,14 @@
171 std::string tmp_display_name = info_hint->display_name;
172 tmp_display_name += ":";
173
174- info_name = new nux::StaticCairoText(tmp_display_name, NUX_TRACKER_LOCATION);
175+ info_name = new nux::StaticCairoText(tmp_display_name, true, NUX_TRACKER_LOCATION);
176 info_name->SetFont(style.info_hint_bold_font());
177 info_name->SetLines(-1);
178 info_name->SetTextAlignment(nux::StaticCairoText::NUX_ALIGN_RIGHT);
179 hint_layout->AddView(info_name.GetPointer(), 0, nux::MINOR_POSITION_CENTER);
180 }
181
182- StaticCairoTextPtr info_value(new nux::StaticCairoText(StringFromVariant(info_hint->value), NUX_TRACKER_LOCATION));
183+ StaticCairoTextPtr info_value(new nux::StaticCairoText(StringFromVariant(info_hint->value), true, NUX_TRACKER_LOCATION));
184 info_value->SetFont(style.info_hint_font());
185 info_value->SetLines(-1);
186 hint_layout->AddView(info_value.GetPointer(), 1, nux::MINOR_POSITION_CENTER);
187
188=== modified file 'dash/previews/PreviewRatingsWidget.cpp'
189--- dash/previews/PreviewRatingsWidget.cpp 2012-08-17 08:20:41 +0000
190+++ dash/previews/PreviewRatingsWidget.cpp 2012-08-28 08:32:21 +0000
191@@ -52,7 +52,7 @@
192 ratings_->SetEditable(false);
193 layout->AddView(ratings_);
194
195- reviews_ = new nux::StaticCairoText("");
196+ reviews_ = new nux::StaticCairoText("", NUX_TRACKER_LOCATION);
197 reviews_->SetFont(style.user_rating_font());
198 layout->AddView(reviews_);
199
200
201=== modified file 'dash/previews/Track.cpp'
202--- dash/previews/Track.cpp 2012-08-22 10:03:52 +0000
203+++ dash/previews/Track.cpp 2012-08-28 08:32:21 +0000
204@@ -159,7 +159,7 @@
205 uri_ = track.uri;
206 progress_ = track.progress;
207
208- title_->SetText(track.title);
209+ title_->SetText(track.title, true);
210
211 std::stringstream ss_track_number;
212 ss_track_number << track.track_number;
213
214=== modified file 'tests/test_previews_application.cpp'
215--- tests/test_previews_application.cpp 2012-08-15 11:23:55 +0000
216+++ tests/test_previews_application.cpp 2012-08-28 08:32:21 +0000
217@@ -70,16 +70,16 @@
218 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_application_preview_new()));
219
220 unity_protocol_application_preview_set_app_icon(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), g_icon_new_for_string("/home/nick/SkypeIcon.png", NULL));
221- unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "License");
222- unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Copywrite");
223+ unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "License & special char");
224+ unity_protocol_application_preview_set_copyright(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "Copywrite & special char");
225 unity_protocol_application_preview_set_last_update(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), "11th Apr 2012");
226 unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 0.8);
227 unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(proto_obj.RawPtr()), 12);
228
229 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
230- unity_protocol_preview_set_title(proto_obj, "Application Title");
231- unity_protocol_preview_set_subtitle(proto_obj, "Application Subtitle");
232- unity_protocol_preview_set_description(proto_obj, "Application Desctiption");
233+ unity_protocol_preview_set_title(proto_obj, "Application Title & special char");
234+ unity_protocol_preview_set_subtitle(proto_obj, "Application Subtitle > special char");
235+ unity_protocol_preview_set_description(proto_obj, "Application Desctiption &lt; special char");
236 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
237 unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
238 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
239@@ -110,12 +110,12 @@
240 {
241 MockApplicationPreview::Ptr preview_view(new MockApplicationPreview(preview_model_));
242
243- EXPECT_EQ(preview_view->title_->GetText(), "Application Title");
244- EXPECT_EQ(preview_view->subtitle_->GetText(), "Application Subtitle");
245- EXPECT_EQ(preview_view->description_->GetText(), "Application Desctiption");
246- EXPECT_EQ(preview_view->license_->GetText(), "License");
247+ EXPECT_EQ(preview_view->title_->GetText(), "Application Title &amp; special char");
248+ EXPECT_EQ(preview_view->subtitle_->GetText(), "Application Subtitle &gt; special char");
249+ EXPECT_EQ(preview_view->description_->GetText(), "Application Desctiption &lt; special char");
250+ EXPECT_EQ(preview_view->license_->GetText(), "License &amp; special char");
251 //EXPECT_EQ(preview_view->last_update_->GetText(), "Last Updated 11th Apr 2012"); // Not 100% sure this will work with translations.
252- EXPECT_EQ(preview_view->copywrite_->GetText(), "Copywrite");
253+ EXPECT_EQ(preview_view->copywrite_->GetText(), "Copywrite &amp; special char");
254
255 EXPECT_EQ(preview_view->app_rating_->GetRating(), 0.8f);
256 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
257
258=== modified file 'tests/test_previews_generic.cpp'
259--- tests/test_previews_generic.cpp 2012-08-15 11:23:55 +0000
260+++ tests/test_previews_generic.cpp 2012-08-28 08:32:21 +0000
261@@ -64,9 +64,9 @@
262 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_generic_preview_new()));
263
264 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
265- unity_protocol_preview_set_title(proto_obj, "Generic Title");
266- unity_protocol_preview_set_subtitle(proto_obj, "Generic Subtitle");
267- unity_protocol_preview_set_description(proto_obj, "Generic Desctiption");
268+ unity_protocol_preview_set_title(proto_obj, "Generic Title & special char");
269+ unity_protocol_preview_set_subtitle(proto_obj, "Generic Subtitle > special char");
270+ unity_protocol_preview_set_description(proto_obj, "Generic Desctiption &lt; special char");
271 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
272 unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
273 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
274@@ -97,9 +97,9 @@
275 {
276 MockGenericPreview::Ptr preview_view(new MockGenericPreview(preview_model_));
277
278- EXPECT_EQ(preview_view->title_->GetText(), "Generic Title");
279- EXPECT_EQ(preview_view->subtitle_->GetText(), "Generic Subtitle");
280- EXPECT_EQ(preview_view->description_->GetText(), "Generic Desctiption");
281+ EXPECT_EQ(preview_view->title_->GetText(), "Generic Title &amp; special char");
282+ EXPECT_EQ(preview_view->subtitle_->GetText(), "Generic Subtitle &gt; special char");
283+ EXPECT_EQ(preview_view->description_->GetText(), "Generic Desctiption &lt; special char");
284
285 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
286 }
287
288=== modified file 'tests/test_previews_movie.cpp'
289--- tests/test_previews_movie.cpp 2012-08-15 11:23:55 +0000
290+++ tests/test_previews_movie.cpp 2012-08-28 08:32:21 +0000
291@@ -70,9 +70,9 @@
292 unity_protocol_movie_preview_set_num_ratings(UNITY_PROTOCOL_MOVIE_PREVIEW(proto_obj.RawPtr()), 12);
293
294 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
295- unity_protocol_preview_set_title(proto_obj, "Movie Title");
296- unity_protocol_preview_set_subtitle(proto_obj, "Movie Subtitle");
297- unity_protocol_preview_set_description(proto_obj, "Movie Desctiption");
298+ unity_protocol_preview_set_title(proto_obj, "Movie Title & special char");
299+ unity_protocol_preview_set_subtitle(proto_obj, "Movie Subtitle > special char");
300+ unity_protocol_preview_set_description(proto_obj, "Movie Desctiption &lt; special char");
301 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
302 unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
303 unity_protocol_preview_add_info_hint(proto_obj, "hint1", "Hint 1", NULL, g_variant_new("s", "string hint 1"));
304@@ -103,9 +103,9 @@
305 {
306 MockMoviePreview::Ptr preview_view(new MockMoviePreview(preview_model_));
307
308- EXPECT_EQ(preview_view->title_->GetText(), "Movie Title");
309- EXPECT_EQ(preview_view->subtitle_->GetText(), "Movie Subtitle");
310- EXPECT_EQ(preview_view->description_->GetText(), "Movie Desctiption");
311+ EXPECT_EQ(preview_view->title_->GetText(), "Movie Title &amp; special char");
312+ EXPECT_EQ(preview_view->subtitle_->GetText(), "Movie Subtitle &gt; special char");
313+ EXPECT_EQ(preview_view->description_->GetText(), "Movie Desctiption &lt; special char");
314
315 EXPECT_EQ(preview_view->rating_->GetRating(), 0.8f);
316 EXPECT_EQ(preview_view->action_buttons_.size(), 2);
317
318=== modified file 'tests/test_previews_music.cpp'
319--- tests/test_previews_music.cpp 2012-08-15 11:23:55 +0000
320+++ tests/test_previews_music.cpp 2012-08-28 08:32:21 +0000
321@@ -65,9 +65,9 @@
322 glib::Object<UnityProtocolPreview> proto_obj(UNITY_PROTOCOL_PREVIEW(unity_protocol_music_preview_new()));
323
324 unity_protocol_preview_set_image_source_uri(proto_obj, "http://ia.media-imdb.com/images/M/MV5BMTM3NDM5MzY5Ml5BMl5BanBnXkFtZTcwNjExMDUwOA@@._V1._SY317_.jpg");
325- unity_protocol_preview_set_title(proto_obj, "Music Title");
326- unity_protocol_preview_set_subtitle(proto_obj, "Music Subtitle");
327- unity_protocol_preview_set_description(proto_obj, "Music Desctiption");
328+ unity_protocol_preview_set_title(proto_obj, "Music Title & special char");
329+ unity_protocol_preview_set_subtitle(proto_obj, "Music Subtitle > special char");
330+ unity_protocol_preview_set_description(proto_obj, "Music Desctiption &lt; special char");
331 unity_protocol_preview_add_action(proto_obj, "action1", "Action 1", NULL, 0);
332 unity_protocol_preview_add_action(proto_obj, "action2", "Action 2", NULL, 0);
333 unity_protocol_preview_add_action(proto_obj, "action3", "Action 3", NULL, 0);
334@@ -100,8 +100,8 @@
335 {
336 MockMusicPreview::Ptr preview_view(new MockMusicPreview(preview_model_));
337
338- EXPECT_EQ(preview_view->title_->GetText(), "Music Title");
339- EXPECT_EQ(preview_view->subtitle_->GetText(), "Music Subtitle");
340+ EXPECT_EQ(preview_view->title_->GetText(), "Music Title &amp; special char");
341+ EXPECT_EQ(preview_view->subtitle_->GetText(), "Music Subtitle &gt; special char");
342
343 EXPECT_EQ(preview_view->action_buttons_.size(), 4);
344 }
345
346=== modified file 'unity-shared/StaticCairoText.cpp'
347--- unity-shared/StaticCairoText.cpp 2012-08-15 16:21:08 +0000
348+++ unity-shared/StaticCairoText.cpp 2012-08-28 08:32:21 +0000
349@@ -162,6 +162,16 @@
350 SetAcceptKeyNavFocusOnMouseDown(false);
351 }
352
353+StaticCairoText::StaticCairoText(std::string const& text, bool escape_text,
354+ NUX_FILE_LINE_DECL)
355+ : View(NUX_FILE_LINE_PARAM)
356+ , pimpl(new Impl(this, escape_text ? GetEscapedText(text) : text))
357+{
358+ SetMinimumSize(1, 1);
359+ SetAcceptKeyNavFocusOnMouseDown(false);
360+}
361+
362+
363 StaticCairoText::~StaticCairoText()
364 {
365 delete pimpl;
366@@ -298,11 +308,13 @@
367 // intentionally left empty
368 }
369
370-void StaticCairoText::SetText(std::string const& text)
371+void StaticCairoText::SetText(std::string const& text, bool escape_text)
372 {
373- if (pimpl->text_ != text)
374+ std::string tmp_text = escape_text ? GetEscapedText(text) : text;
375+
376+ if (pimpl->text_ != tmp_text)
377 {
378- pimpl->text_ = text;
379+ pimpl->text_ = tmp_text;
380 pimpl->need_new_extent_cache_ = true;
381 pimpl->UpdateTexture();
382 sigTextChanged.emit(this);
383@@ -337,6 +349,11 @@
384 return pimpl->text_;
385 }
386
387+std::string StaticCairoText::GetEscapedText(std::string const& text)
388+{
389+ return glib::String(g_markup_escape_text(text.c_str(), -1)).Str();
390+}
391+
392 Color StaticCairoText::GetTextColor() const
393 {
394 return pimpl->text_color_;
395
396=== modified file 'unity-shared/StaticCairoText.h'
397--- unity-shared/StaticCairoText.h 2012-08-15 16:21:08 +0000
398+++ unity-shared/StaticCairoText.h 2012-08-28 08:32:21 +0000
399@@ -52,6 +52,7 @@
400 };
401
402 StaticCairoText(std::string const& text, NUX_FILE_LINE_PROTO);
403+ StaticCairoText(std::string const& text, bool escape_text, NUX_FILE_LINE_PROTO);
404 ~StaticCairoText();
405
406 void PreLayoutManagement();
407@@ -68,7 +69,7 @@
408 bool forceDraw);
409
410 // public API
411- void SetText(std::string const& text);
412+ void SetText(std::string const& text, bool escape_text = false);
413 void SetTextColor(Color const& textColor);
414 void SetTextEllipsize(EllipsizeState state);
415 void SetTextAlignment(AlignState state);
416@@ -95,6 +96,8 @@
417 void SetMaximumSize(int w, int h);
418 void SetMaximumWidth(int w);
419
420+ static std::string GetEscapedText(std::string const& text);
421+
422 protected:
423 // Key navigation
424 virtual bool AcceptKeyNavFocus();