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