Merge lp:~thomir/unity/remove-constcharstar into lp:unity

Proposed by Thomi Richards on 2012-03-26
Status: Merged
Approved by: Sam Spilsbury on 2012-03-27
Approved revision: 2175
Merged at revision: 2172
Proposed branch: lp:~thomir/unity/remove-constcharstar
Merge into: lp:unity
Diff against target: 726 lines (+104/-154)
14 files modified
plugins/unityshell/src/HudIcon.cpp (+7/-7)
plugins/unityshell/src/HudIcon.h (+1/-1)
plugins/unityshell/src/IconTexture.cpp (+21/-30)
plugins/unityshell/src/IconTexture.h (+6/-9)
plugins/unityshell/src/LauncherIcon.cpp (+21/-29)
plugins/unityshell/src/LauncherIcon.h (+10/-10)
plugins/unityshell/src/LensBarIcon.cpp (+1/-1)
plugins/unityshell/src/PlacesSimpleTile.cpp (+23/-52)
plugins/unityshell/src/PlacesSimpleTile.h (+8/-9)
plugins/unityshell/src/PreviewApplications.cpp (+2/-2)
plugins/unityshell/src/PreviewGeneric.cpp (+1/-1)
plugins/unityshell/src/PreviewMusic.cpp (+1/-1)
plugins/unityshell/src/PreviewMusicTrack.cpp (+1/-1)
plugins/unityshell/src/unity-places-simple-tile-accessible.cpp (+1/-1)
To merge this branch: bzr merge lp:~thomir/unity/remove-constcharstar
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) 2012-03-26 Approve on 2012-03-27
Review via email: mp+99448@code.launchpad.net

Commit Message

Converted several classes to use std::string instead of const char* or const gchar*.

Description of the Change

Converted IconSource and LauncherIcon methods to use std::string rather than char* or gchar*. This cleans up several bits of code.

To post a comment you must log in.
Sam Spilsbury (smspillaz) wrote :

79 +IconTexture::IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
80 : TextureArea(NUX_TRACKER_LOCATION),
81 _accept_key_nav_focus(false),
82 - _icon_name(NULL),
83 _size(size),
84 _texture_width(0),
85 _texture_height(0),
86 _loading(false),
87 _opacity(1.0f)
88 {
89 - _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON);
90 + _icon_name = icon_name.empty() ? DEFAULT_ICON : icon_name;
91
92 - if (g_strcmp0(_icon_name, "") != 0 && !defer_icon_loading)
93 + if (_icon_name != "" && !defer_icon_loading)

Can you use the initializer directly ?

Thomi Richards (thomir) wrote :

> Can you use the initializer directly ?

Yes! Thanks for pointing that out. Fixed now.

Cheers

2175. By Thomi Richards on 2012-03-27

Use initialiser list.

Brandon Schaefer (brandontschaefer) wrote :

+1 Looks good!

review: Approve
Marco Trevisan (Treviño) (3v1n0) wrote :

Oh, I was doing the same for TextureIcon in the hud tests/cleanup branch... I figure I've to remerge trunk now ;)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/HudIcon.cpp'
2--- plugins/unityshell/src/HudIcon.cpp 2012-02-08 19:56:13 +0000
3+++ plugins/unityshell/src/HudIcon.cpp 2012-03-27 01:41:18 +0000
4@@ -23,7 +23,7 @@
5 {
6 nux::logging::Logger logger("unity.hud.icon");
7 }
8-
9+
10 namespace unity
11 {
12 namespace hud
13@@ -36,7 +36,7 @@
14 icon_renderer_.SetTargetSize(54, 46, 0);
15 }
16
17-Icon::Icon(const char* icon_name, unsigned int size, bool defer_icon_loading)
18+Icon::Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
19 : unity::IconTexture(icon_name, size, defer_icon_loading)
20 {
21 Init();
22@@ -53,8 +53,8 @@
23 background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
24 gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
25 edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));
26-
27- texture_updated.connect([&] (nux::BaseTexture* texture)
28+
29+ texture_updated.connect([&] (nux::BaseTexture* texture)
30 {
31 icon_texture_source_ = new HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture>(texture));
32 icon_texture_source_->ColorForIcon(_pixbuf_cached);
33@@ -78,12 +78,12 @@
34 arg.window_indicators = true;
35 arg.backlight_intensity = 1.0f;
36 arg.alpha = 1.0f;
37-
38+
39 std::list<unity::ui::RenderArg> args;
40 args.push_front(arg);
41
42-
43- auto toplevel = GetToplevel();
44+
45+ auto toplevel = GetToplevel();
46 icon_renderer_.SetTargetSize(54, 46, 0);
47 icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
48 icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
49
50=== modified file 'plugins/unityshell/src/HudIcon.h'
51--- plugins/unityshell/src/HudIcon.h 2012-02-08 19:55:48 +0000
52+++ plugins/unityshell/src/HudIcon.h 2012-03-27 01:41:18 +0000
53@@ -52,7 +52,7 @@
54 public:
55 typedef nux::ObjectPtr<IconTexture> Ptr;
56 Icon(nux::BaseTexture* texture, guint width, guint height);
57- Icon(const char* icon_name, unsigned int size, bool defer_icon_loading = false);
58+ Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
59 ~Icon();
60
61 protected:
62
63=== modified file 'plugins/unityshell/src/IconTexture.cpp'
64--- plugins/unityshell/src/IconTexture.cpp 2012-03-14 06:24:18 +0000
65+++ plugins/unityshell/src/IconTexture.cpp 2012-03-27 01:41:18 +0000
66@@ -46,7 +46,6 @@
67 IconTexture::IconTexture(nux::BaseTexture* texture, guint width, guint height)
68 : TextureArea(NUX_TRACKER_LOCATION),
69 _accept_key_nav_focus(false),
70- _icon_name(NULL),
71 _size(height),
72 _texture_cached(texture),
73 _texture_width(width),
74@@ -57,39 +56,31 @@
75 SetMinMaxSize(width, height);
76 }
77
78-IconTexture::IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading)
79- : TextureArea(NUX_TRACKER_LOCATION),
80- _accept_key_nav_focus(false),
81- _icon_name(NULL),
82- _size(size),
83- _texture_width(0),
84- _texture_height(0),
85- _loading(false),
86- _opacity(1.0f)
87+IconTexture::IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
88+ : TextureArea(NUX_TRACKER_LOCATION)
89+ , _accept_key_nav_focus(false)
90+ , _icon_name(icon_name.empty() ? DEFAULT_ICON : icon_name)
91+ , _size(size)
92+ , _texture_width(0)
93+ , _texture_height(0)
94+ , _loading(false)
95+ , _opacity(1.0f)
96 {
97- _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON);
98
99- if (g_strcmp0(_icon_name, "") != 0 && !defer_icon_loading)
100+ if (_icon_name != "" && !defer_icon_loading)
101 LoadIcon();
102 }
103
104-IconTexture::~IconTexture()
105-{
106- g_free(_icon_name);
107-}
108-
109-void IconTexture::SetByIconName(const char* icon_name, unsigned int size)
110-{
111- g_free(_icon_name);
112- _icon_name = g_strdup(icon_name);
113+void IconTexture::SetByIconName(std::string const& icon_name, unsigned int size)
114+{
115+ _icon_name = icon_name;
116 _size = size;
117 LoadIcon();
118 }
119
120-void IconTexture::SetByFilePath(const char* file_path, unsigned int size)
121+void IconTexture::SetByFilePath(std::string const& file_path, unsigned int size)
122 {
123- g_free(_icon_name);
124- _icon_name = g_strdup(file_path);
125+ _icon_name = file_path;
126 _size = size;
127
128 LoadIcon();
129@@ -99,22 +90,22 @@
130 {
131 LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
132 static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
133- if (!g_strcmp0(_icon_name, ""))
134+ if (_icon_name.empty())
135 return;
136-
137+
138 if (_loading)
139 return;
140 _loading = true;
141
142- glib::Object<GIcon> icon(::g_icon_new_for_string(_icon_name ? _icon_name : DEFAULT_GICON, NULL));
143+ glib::Object<GIcon> icon(::g_icon_new_for_string(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), NULL));
144
145 if (icon)
146 {
147- IconLoader::GetDefault().LoadFromGIconString(_icon_name ? _icon_name : DEFAULT_GICON,
148+ IconLoader::GetDefault().LoadFromGIconString(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(),
149 _size,
150 sigc::mem_fun(this, &IconTexture::IconLoaded));
151 }
152- else if (g_str_has_prefix(_icon_name, "http://"))
153+ else if (_icon_name.find("http://") == 0)
154 {
155 IconLoader::GetDefault().LoadFromURI(_icon_name,
156 _size, sigc::mem_fun(this, &IconTexture::IconLoaded));
157@@ -143,7 +134,7 @@
158
159 // Try and get a texture from the texture cache
160 std::string id("IconTexture.");
161- id += _icon_name ? _icon_name : DEFAULT_ICON;
162+ id += _icon_name.empty() ? DEFAULT_ICON : _icon_name;
163 _texture_cached = cache.FindTexture(id,
164 _texture_width,
165 _texture_height,
166
167=== modified file 'plugins/unityshell/src/IconTexture.h'
168--- plugins/unityshell/src/IconTexture.h 2012-03-14 06:24:18 +0000
169+++ plugins/unityshell/src/IconTexture.h 2012-03-27 01:41:18 +0000
170@@ -37,11 +37,10 @@
171 {
172 public:
173 IconTexture(nux::BaseTexture* texture, guint width, guint height);
174- IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading = false);
175- ~IconTexture();
176+ IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
177
178- void SetByIconName(const char* icon_name, unsigned int size);
179- void SetByFilePath(const char* file_path, unsigned int size);
180+ void SetByIconName(std::string const& icon_name, unsigned int size);
181+ void SetByFilePath(std::string const& file_path, unsigned int size);
182 void GetTextureSize(int* width, int* height);
183
184 void LoadIcon();
185@@ -54,7 +53,7 @@
186 nux::BaseTexture* texture();
187
188 sigc::signal<void, nux::BaseTexture*> texture_updated;
189-
190+
191 protected:
192 // Key navigation
193 virtual bool AcceptKeyNavFocus();
194@@ -64,7 +63,7 @@
195 void AddProperties(GVariantBuilder* builder);
196 virtual bool DoCanFocus();
197 GdkPixbuf* _pixbuf_cached;
198-
199+
200 protected:
201 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
202
203@@ -73,11 +72,9 @@
204 void Refresh(GdkPixbuf* pixbuf);
205 void IconLoaded(std::string const& icon_name, unsigned size, GdkPixbuf* pixbuf);
206
207- // FIXME: make _icon_name a std::string.
208- char* _icon_name;
209+ std::string _icon_name;
210 unsigned int _size;
211
212-
213 nux::ObjectPtr<nux::BaseTexture> _texture_cached;
214 // FIXME: make these two a nux::Size.
215 int _texture_width;
216
217=== modified file 'plugins/unityshell/src/LauncherIcon.cpp'
218--- plugins/unityshell/src/LauncherIcon.cpp 2012-03-21 12:31:11 +0000
219+++ plugins/unityshell/src/LauncherIcon.cpp 2012-03-27 01:41:18 +0000
220@@ -332,23 +332,21 @@
221 return _unity_theme;
222 }
223
224-nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(const char* icon_name, int size, bool update_glow_colors)
225+nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors)
226 {
227 GtkIconTheme* default_theme;
228 nux::BaseTexture* result = NULL;
229
230- if (!icon_name)
231+ if (icon_name.empty())
232 {
233- // This leaks, so log if we do this.
234- LOG_WARN(logger) << "Leaking... no icon_name passed in.";
235- icon_name = g_strdup(DEFAULT_ICON.c_str());
236+ icon_name = DEFAULT_ICON;
237 }
238
239 default_theme = gtk_icon_theme_get_default();
240
241 // FIXME: we need to create some kind of -unity postfix to see if we are looking to the unity-icon-theme
242 // for dedicated unity icons, then remove the postfix and degrade to other icon themes if not found
243- if ((g_strcmp0(icon_name, "workspace-switcher") == 0) && IsMonoDefaultTheme())
244+ if (icon_name == "workspace-switcher" && IsMonoDefaultTheme())
245 result = TextureFromSpecificGtkTheme(GetUnityTheme(), icon_name, size, update_glow_colors);
246
247 if (!result)
248@@ -356,7 +354,7 @@
249
250 if (!result)
251 {
252- if (g_strcmp0(icon_name, "folder") == 0)
253+ if (icon_name == "folder")
254 result = NULL;
255 else
256 result = TextureFromSpecificGtkTheme(default_theme, "folder", size, update_glow_colors);
257@@ -367,7 +365,7 @@
258 }
259
260 nux::BaseTexture* LauncherIcon::TextureFromSpecificGtkTheme(GtkIconTheme* theme,
261- const char* icon_name,
262+ std::string const& icon_name,
263 int size,
264 bool update_glow_colors,
265 bool is_default_theme)
266@@ -377,7 +375,7 @@
267 GIcon* icon;
268 GtkIconLookupFlags flags = (GtkIconLookupFlags) 0;
269
270- icon = g_icon_new_for_string(icon_name, NULL);
271+ icon = g_icon_new_for_string(icon_name.c_str(), NULL);
272
273 if (G_IS_ICON(icon))
274 {
275@@ -386,7 +384,7 @@
276 }
277 else
278 {
279- info = gtk_icon_theme_lookup_icon(theme,icon_name, size, flags);
280+ info = gtk_icon_theme_lookup_icon(theme, icon_name.c_str(), size, flags);
281 }
282
283 if (!info && !is_default_theme)
284@@ -423,15 +421,15 @@
285 return result;
286 }
287
288-nux::BaseTexture* LauncherIcon::TextureFromPath(const char* icon_name, int size, bool update_glow_colors)
289+nux::BaseTexture* LauncherIcon::TextureFromPath(std::string const& icon_name, int size, bool update_glow_colors)
290 {
291 nux::BaseTexture* result;
292
293- if (!icon_name)
294- return TextureFromGtkTheme(DEFAULT_ICON.c_str(), size, update_glow_colors);
295+ if (icon_name.empty())
296+ return TextureFromGtkTheme(DEFAULT_ICON, size, update_glow_colors);
297
298 glib::Error error;
299- glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(icon_name, size, size, &error));
300+ glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(icon_name.c_str(), size, size, &error));
301
302 if (GDK_IS_PIXBUF(pbuf.RawPtr()))
303 {
304@@ -445,7 +443,7 @@
305 LOG_WARN(logger) << "Unable to load '" << icon_name
306 << "' icon: " << error;
307
308- result = TextureFromGtkTheme(DEFAULT_ICON.c_str(), size, update_glow_colors);
309+ result = TextureFromGtkTheme(DEFAULT_ICON, size, update_glow_colors);
310 }
311
312 return result;
313@@ -914,11 +912,11 @@
314 }
315
316 void
317-LauncherIcon::SetEmblemIconName(const char* name)
318+LauncherIcon::SetEmblemIconName(std::string const& name)
319 {
320 BaseTexturePtr emblem;
321
322- if (g_str_has_prefix(name, "/"))
323+ if (name.at(0) == '/')
324 emblem = TextureFromPath(name, 22, false);
325 else
326 emblem = TextureFromGtkTheme(name, 22, false);
327@@ -929,11 +927,8 @@
328 }
329
330 void
331-LauncherIcon::SetEmblemText(const char* text)
332+LauncherIcon::SetEmblemText(std::string const& text)
333 {
334- if (text == NULL)
335- return;
336-
337 PangoLayout* layout = NULL;
338
339 PangoContext* pangoCtx = NULL;
340@@ -967,7 +962,7 @@
341 pango_layout_set_width(layout, pango_units_from_double(width - 4.0f));
342 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
343 pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
344- pango_layout_set_markup_with_accel(layout, text, -1, '_', NULL);
345+ pango_layout_set_markup_with_accel(layout, text.c_str(), -1, '_', NULL);
346
347 pangoCtx = pango_layout_get_context(layout); // is not ref'ed
348 pango_cairo_context_set_font_options(pangoCtx,
349@@ -1085,14 +1080,13 @@
350 if (!remote->CountVisible())
351 return;
352
353- gchar* text;
354+ std::string text;
355 if (remote->Count() > 9999)
356- text = g_strdup_printf("****");
357+ text = "****";
358 else
359- text = g_strdup_printf("%i", (int) remote->Count());
360+ text = std::to_string( (int) remote->Count());
361
362 SetEmblemText(text);
363- g_free(text);
364 }
365
366 void
367@@ -1124,9 +1118,7 @@
368 {
369 if (remote->CountVisible())
370 {
371- gchar* text = g_strdup_printf("%i", (int) remote->Count());
372- SetEmblemText(text);
373- g_free(text);
374+ SetEmblemText(std::to_string( (int) remote->Count()));
375 }
376 else
377 {
378
379=== modified file 'plugins/unityshell/src/LauncherIcon.h'
380--- plugins/unityshell/src/LauncherIcon.h 2012-03-22 15:14:49 +0000
381+++ plugins/unityshell/src/LauncherIcon.h 2012-03-27 01:41:18 +0000
382@@ -123,9 +123,9 @@
383
384 float GetProgress();
385
386- void SetEmblemIconName(const char* name);
387+ void SetEmblemIconName(std::string const& name);
388
389- void SetEmblemText(const char* text);
390+ void SetEmblemText(std::string const& text);
391
392 void DeleteEmblem();
393
394@@ -195,9 +195,9 @@
395 virtual bool IsVisible() const { return false; }
396
397 virtual void AboutToRemove() {}
398-
399+
400 virtual void Stick(bool save = true) {}
401-
402+
403 virtual void UnStick() {}
404
405 protected:
406@@ -253,11 +253,11 @@
407
408 virtual bool HandlesSpread () { return false; }
409
410- nux::BaseTexture* TextureFromGtkTheme(const char* name, int size, bool update_glow_colors = true);
411-
412- nux::BaseTexture* TextureFromSpecificGtkTheme(GtkIconTheme* theme, const char* name, int size, bool update_glow_colors = true, bool is_default_theme = false);
413-
414- nux::BaseTexture* TextureFromPath(const char* name, int size, bool update_glow_colors = true);
415+ nux::BaseTexture* TextureFromGtkTheme(std::string name, int size, bool update_glow_colors = true);
416+
417+ nux::BaseTexture* TextureFromSpecificGtkTheme(GtkIconTheme* theme, std::string const& name, int size, bool update_glow_colors = true, bool is_default_theme = false);
418+
419+ nux::BaseTexture* TextureFromPath(std::string const& name, int size, bool update_glow_colors = true);
420
421 static bool IsMonoDefaultTheme();
422
423@@ -323,7 +323,7 @@
424 gint64 _shortcut;
425
426 IconType _icon_type;
427-
428+
429 std::vector<nux::Point3> _center;
430 std::vector<bool> _has_visible_window;
431 std::vector<nux::Point3> _last_stable;
432
433=== modified file 'plugins/unityshell/src/LensBarIcon.cpp'
434--- plugins/unityshell/src/LensBarIcon.cpp 2012-03-14 06:24:18 +0000
435+++ plugins/unityshell/src/LensBarIcon.cpp 2012-03-27 01:41:18 +0000
436@@ -28,7 +28,7 @@
437 NUX_IMPLEMENT_OBJECT_TYPE(LensBarIcon);
438
439 LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint)
440- : IconTexture(icon_hint.c_str(), 24)
441+ : IconTexture(icon_hint, 24)
442 , id(id_)
443 , active(false)
444 , inactive_opacity_(0.4f)
445
446=== modified file 'plugins/unityshell/src/PlacesSimpleTile.cpp'
447--- plugins/unityshell/src/PlacesSimpleTile.cpp 2012-03-14 06:24:18 +0000
448+++ plugins/unityshell/src/PlacesSimpleTile.cpp 2012-03-27 01:41:18 +0000
449@@ -37,23 +37,19 @@
450 {
451 NUX_IMPLEMENT_OBJECT_TYPE(PlacesSimpleTile);
452
453-PlacesSimpleTile::PlacesSimpleTile(const char* icon_name,
454- const char* label,
455+PlacesSimpleTile::PlacesSimpleTile(std::string const& icon_name,
456+ std::string const& label,
457 int icon_size,
458 bool defer_icon_loading,
459 const void* id)
460 : PlacesTile(NUX_TRACKER_LOCATION, id),
461- _label(NULL),
462- _icon(NULL),
463- _uri(NULL),
464+ _label(label),
465+ _icon(icon_name),
466 _idealiconsize(icon_size)
467 {
468 dash::Style& style = dash::Style::Instance();
469 nux::VLayout* layout = new nux::VLayout("", NUX_TRACKER_LOCATION);
470
471- _label = g_strdup(label);
472- _icon = g_strdup(icon_name);
473-
474 _icontex = new IconTexture(_icon, icon_size, defer_icon_loading);
475 _icontex->SetMinMaxSize(style.GetTileWidth(), icon_size);
476 AddChild(_icontex);
477@@ -76,14 +72,6 @@
478 SetDndEnabled(true, false);
479 }
480
481-
482-PlacesSimpleTile::~PlacesSimpleTile()
483-{
484- g_free(_label);
485- g_free(_icon);
486- g_free(_uri);
487-}
488-
489 bool
490 PlacesSimpleTile::DndSourceDragBegin()
491 {
492@@ -104,14 +92,14 @@
493 GError* error = NULL;
494 GIcon* icon;
495
496- const char* icon_name = _icon;
497+ std::string icon_name = _icon;
498 int size = 64;
499
500- if (!icon_name)
501+ if (icon_name.empty())
502 icon_name = "application-default-icon";
503
504 theme = gtk_icon_theme_get_default();
505- icon = g_icon_new_for_string(icon_name, NULL);
506+ icon = g_icon_new_for_string(icon_name.c_str(), NULL);
507
508 if (G_IS_ICON(icon))
509 {
510@@ -121,7 +109,7 @@
511 else
512 {
513 info = gtk_icon_theme_lookup_icon(theme,
514- icon_name,
515+ icon_name.c_str(),
516 size,
517 (GtkIconLookupFlags) 0);
518 }
519@@ -155,23 +143,21 @@
520 return result;
521 }
522
523-std::list<const char*>
524-PlacesSimpleTile::DndSourceGetDragTypes()
525+std::list<const char*> PlacesSimpleTile::DndSourceGetDragTypes()
526 {
527 std::list<const char*> result;
528 result.push_back("text/uri-list");
529 return result;
530 }
531
532-const char*
533-PlacesSimpleTile::DndSourceGetDataForType(const char* type, int* size, int* format)
534+const char* PlacesSimpleTile::DndSourceGetDataForType(const char* type, int* size, int* format)
535 {
536 *format = 8;
537
538- if (_uri)
539+ if (!_uri.empty())
540 {
541- *size = strlen(_uri);
542- return _uri;
543+ *size = _uri.size();
544+ return _uri.c_str();
545 }
546 else
547 {
548@@ -180,14 +166,12 @@
549 }
550 }
551
552-void
553-PlacesSimpleTile::DndSourceDragFinished(nux::DndAction result)
554+void PlacesSimpleTile::DndSourceDragFinished(nux::DndAction result)
555 {
556 UnReference();
557 }
558
559-nux::Geometry
560-PlacesSimpleTile::GetHighlightGeometry()
561+nux::Geometry PlacesSimpleTile::GetHighlightGeometry()
562 {
563 nux::Geometry base = GetGeometry();
564 int width = 0, height = 0;
565@@ -202,50 +186,37 @@
566 return _highlight_geometry;
567 }
568
569-const char*
570-PlacesSimpleTile::GetLabel()
571+std::string PlacesSimpleTile::GetLabel() const
572 {
573 return _label;
574 }
575
576-const char*
577-PlacesSimpleTile::GetIcon()
578+std::string PlacesSimpleTile::GetIcon() const
579 {
580 return _icon;
581 }
582
583-const char*
584-PlacesSimpleTile::GetURI()
585+std::string PlacesSimpleTile::GetURI() const
586 {
587 return _uri;
588 }
589
590-void
591-PlacesSimpleTile::SetURI(const char* uri)
592+void PlacesSimpleTile::SetURI(std::string const& uri)
593 {
594- if (_uri)
595- g_free(_uri);
596-
597- _uri = NULL;
598-
599- if (uri)
600- _uri = g_strdup(uri);
601+ _uri = uri;
602 }
603
604-std::string
605-PlacesSimpleTile::GetName() const
606+std::string PlacesSimpleTile::GetName() const
607 {
608 return "PlacesTile";
609 }
610
611-void
612-PlacesSimpleTile::AddProperties(GVariantBuilder* builder)
613+void PlacesSimpleTile::AddProperties(GVariantBuilder* builder)
614 {
615 unity::variant::BuilderWrapper(builder).add(GetGeometry());
616 }
617
618-void
619-PlacesSimpleTile::LoadIcon()
620+void PlacesSimpleTile::LoadIcon()
621 {
622 _icontex->LoadIcon();
623
624
625=== modified file 'plugins/unityshell/src/PlacesSimpleTile.h'
626--- plugins/unityshell/src/PlacesSimpleTile.h 2012-03-14 06:24:18 +0000
627+++ plugins/unityshell/src/PlacesSimpleTile.h 2012-03-27 01:41:18 +0000
628@@ -35,13 +35,12 @@
629 NUX_DECLARE_OBJECT_TYPE(PlacesSimpleTile, PlacesTile);
630 public:
631
632- PlacesSimpleTile(const char* icon, const char* label, int icon_size = 64, bool defer_icon_loading = false, const void* id = NULL);
633- ~PlacesSimpleTile();
634+ PlacesSimpleTile(std::string const& icon, std::string const& label, int icon_size = 64, bool defer_icon_loading = false, const void* id = NULL);
635
636- const char* GetLabel();
637- const char* GetIcon();
638- const char* GetURI();
639- void SetURI(const char* uri);
640+ std::string GetLabel() const;
641+ std::string GetIcon() const;
642+ std::string GetURI() const;
643+ void SetURI(std::string const& uri);
644
645 void LoadIcon();
646
647@@ -59,9 +58,9 @@
648
649 private:
650 nux::Geometry _highlight_geometry;
651- char* _label;
652- char* _icon;
653- char* _uri;
654+ std::string _label;
655+ std::string _icon;
656+ std::string _uri;
657 int _idealiconsize;
658 IconTexture* _icontex;
659 nux::StaticCairoText* _cairotext;
660
661=== modified file 'plugins/unityshell/src/PreviewApplications.cpp'
662--- plugins/unityshell/src/PreviewApplications.cpp 2012-03-16 01:48:22 +0000
663+++ plugins/unityshell/src/PreviewApplications.cpp 2012-03-27 01:41:18 +0000
664@@ -54,8 +54,8 @@
665
666 void PreviewApplications::BuildLayout()
667 {
668- IconTexture *screenshot = new IconTexture (preview_->screenshot_icon_hint.c_str(), 420);
669- IconTexture *icon = new IconTexture (preview_->icon_hint.c_str(), 80);
670+ IconTexture *screenshot = new IconTexture(preview_->screenshot_icon_hint, 420);
671+ IconTexture *icon = new IconTexture(preview_->icon_hint, 80);
672 nux::StaticCairoText *name = new nux::StaticCairoText (preview_->name, NUX_TRACKER_LOCATION);
673 name->SetFont("Ubuntu 25");
674
675
676=== modified file 'plugins/unityshell/src/PreviewGeneric.cpp'
677--- plugins/unityshell/src/PreviewGeneric.cpp 2012-03-16 01:48:22 +0000
678+++ plugins/unityshell/src/PreviewGeneric.cpp 2012-03-27 01:41:18 +0000
679@@ -54,7 +54,7 @@
680
681 void PreviewGeneric::BuildLayout()
682 {
683- IconTexture *icon = new IconTexture (preview_->icon_hint.c_str(), 300);
684+ IconTexture *icon = new IconTexture(preview_->icon_hint, 300);
685 nux::StaticCairoText *name = new nux::StaticCairoText (preview_->name, NUX_TRACKER_LOCATION);
686 name->SetFont("Ubuntu 25");
687
688
689=== modified file 'plugins/unityshell/src/PreviewMusic.cpp'
690--- plugins/unityshell/src/PreviewMusic.cpp 2012-03-16 01:48:22 +0000
691+++ plugins/unityshell/src/PreviewMusic.cpp 2012-03-27 01:41:18 +0000
692@@ -57,7 +57,7 @@
693
694 void PreviewMusicAlbum::BuildLayout()
695 {
696- IconTexture *cover = new IconTexture (preview_->album_cover.c_str(), 400);
697+ IconTexture *cover = new IconTexture (preview_->album_cover, 400);
698 nux::StaticCairoText *title = new nux::StaticCairoText(preview_->name, NUX_TRACKER_LOCATION);
699 title->SetFont("Ubuntu 25");
700
701
702=== modified file 'plugins/unityshell/src/PreviewMusicTrack.cpp'
703--- plugins/unityshell/src/PreviewMusicTrack.cpp 2012-03-16 01:48:22 +0000
704+++ plugins/unityshell/src/PreviewMusicTrack.cpp 2012-03-27 01:41:18 +0000
705@@ -56,7 +56,7 @@
706
707 void PreviewMusicTrack::BuildLayout()
708 {
709- IconTexture *cover = new IconTexture (preview_->album_cover.c_str(), 400);
710+ IconTexture *cover = new IconTexture(preview_->album_cover, 400);
711 nux::StaticCairoText *title = new nux::StaticCairoText(preview_->title, NUX_TRACKER_LOCATION);
712 title->SetFont("Ubuntu 25");
713
714
715=== modified file 'plugins/unityshell/src/unity-places-simple-tile-accessible.cpp'
716--- plugins/unityshell/src/unity-places-simple-tile-accessible.cpp 2011-09-15 13:58:42 +0000
717+++ plugins/unityshell/src/unity-places-simple-tile-accessible.cpp 2012-03-27 01:41:18 +0000
718@@ -129,7 +129,7 @@
719 tile = dynamic_cast<unity::PlacesSimpleTile*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
720 if (tile != NULL)
721 {
722- name = tile->GetLabel();
723+ name = tile->GetLabel().c_str();
724 pango_parse_markup(name, -1, 0, NULL,
725 &self->priv->stripped_name,
726 NULL, NULL);