summaryrefslogtreecommitdiff
path: root/plugins/unityshell
diff options
authorThomi Richards <thomi.richards@canonical.com>2012-03-26 22:29:39 -0400
committerTarmac <>2012-03-26 22:29:39 -0400
commitd0404e30202fccc9ca203ae1c40dda495fc1c827 (patch)
tree5c02764cacef9fb000270ad5f4b3a251df9ad159 /plugins/unityshell
parentd2e96461791e6b8dc68212bc8bd7586eccafd88f (diff)
parent5f7083f2288a12de27f6507ba45f784cd119fcab (diff)
Converted several classes to use std::string instead of const char* or const gchar*.. Fixes: . Approved by Brandon Schaefer.
(bzr r2172)
Diffstat (limited to 'plugins/unityshell')
-rw-r--r--plugins/unityshell/src/HudIcon.cpp14
-rw-r--r--plugins/unityshell/src/HudIcon.h2
-rw-r--r--plugins/unityshell/src/IconTexture.cpp49
-rw-r--r--plugins/unityshell/src/IconTexture.h15
-rw-r--r--plugins/unityshell/src/LauncherIcon.cpp50
-rw-r--r--plugins/unityshell/src/LauncherIcon.h16
-rw-r--r--plugins/unityshell/src/LensBarIcon.cpp2
-rw-r--r--plugins/unityshell/src/PlacesSimpleTile.cpp75
-rw-r--r--plugins/unityshell/src/PlacesSimpleTile.h17
-rw-r--r--plugins/unityshell/src/PreviewApplications.cpp4
-rw-r--r--plugins/unityshell/src/PreviewGeneric.cpp2
-rw-r--r--plugins/unityshell/src/PreviewMusic.cpp2
-rw-r--r--plugins/unityshell/src/PreviewMusicTrack.cpp2
-rw-r--r--plugins/unityshell/src/unity-places-simple-tile-accessible.cpp2
14 files changed, 101 insertions, 151 deletions
diff --git a/plugins/unityshell/src/HudIcon.cpp b/plugins/unityshell/src/HudIcon.cpp
index 3b213447c..02a75446c 100644
--- a/plugins/unityshell/src/HudIcon.cpp
+++ b/plugins/unityshell/src/HudIcon.cpp
@@ -23,7 +23,7 @@ namespace
{
nux::logging::Logger logger("unity.hud.icon");
}
-
+
namespace unity
{
namespace hud
@@ -36,7 +36,7 @@ Icon::Icon(nux::BaseTexture* texture, guint width, guint height)
icon_renderer_.SetTargetSize(54, 46, 0);
}
-Icon::Icon(const char* icon_name, unsigned int size, bool defer_icon_loading)
+Icon::Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
: unity::IconTexture(icon_name, size, defer_icon_loading)
{
Init();
@@ -53,8 +53,8 @@ void Icon::Init()
background_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_back_54.png", -1, true));
gloss_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_shine_54.png", -1, true));
edge_.Adopt(nux::CreateTexture2DFromFile(PKGDATADIR"/launcher_icon_edge_54.png", -1, true));
-
- texture_updated.connect([&] (nux::BaseTexture* texture)
+
+ texture_updated.connect([&] (nux::BaseTexture* texture)
{
icon_texture_source_ = new HudIconTextureSource(nux::ObjectPtr<nux::BaseTexture>(texture));
icon_texture_source_->ColorForIcon(_pixbuf_cached);
@@ -78,12 +78,12 @@ void Icon::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
arg.window_indicators = true;
arg.backlight_intensity = 1.0f;
arg.alpha = 1.0f;
-
+
std::list<unity::ui::RenderArg> args;
args.push_front(arg);
-
- auto toplevel = GetToplevel();
+
+ auto toplevel = GetToplevel();
icon_renderer_.SetTargetSize(54, 46, 0);
icon_renderer_.PreprocessIcons(args, toplevel->GetGeometry());
icon_renderer_.RenderIcon(GfxContext, arg, toplevel->GetGeometry(), toplevel->GetGeometry());
diff --git a/plugins/unityshell/src/HudIcon.h b/plugins/unityshell/src/HudIcon.h
index 82ddf3ba9..274808f8d 100644
--- a/plugins/unityshell/src/HudIcon.h
+++ b/plugins/unityshell/src/HudIcon.h
@@ -52,7 +52,7 @@ class Icon : public unity::IconTexture
public:
typedef nux::ObjectPtr<IconTexture> Ptr;
Icon(nux::BaseTexture* texture, guint width, guint height);
- Icon(const char* icon_name, unsigned int size, bool defer_icon_loading = false);
+ Icon(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
~Icon();
protected:
diff --git a/plugins/unityshell/src/IconTexture.cpp b/plugins/unityshell/src/IconTexture.cpp
index 10536afee..aa2b6b830 100644
--- a/plugins/unityshell/src/IconTexture.cpp
+++ b/plugins/unityshell/src/IconTexture.cpp
@@ -46,7 +46,6 @@ using namespace unity;
IconTexture::IconTexture(nux::BaseTexture* texture, guint width, guint height)
: TextureArea(NUX_TRACKER_LOCATION),
_accept_key_nav_focus(false),
- _icon_name(NULL),
_size(height),
_texture_cached(texture),
_texture_width(width),
@@ -57,39 +56,31 @@ IconTexture::IconTexture(nux::BaseTexture* texture, guint width, guint height)
SetMinMaxSize(width, height);
}
-IconTexture::IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading)
- : TextureArea(NUX_TRACKER_LOCATION),
- _accept_key_nav_focus(false),
- _icon_name(NULL),
- _size(size),
- _texture_width(0),
- _texture_height(0),
- _loading(false),
- _opacity(1.0f)
+IconTexture::IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading)
+ : TextureArea(NUX_TRACKER_LOCATION)
+ , _accept_key_nav_focus(false)
+ , _icon_name(icon_name.empty() ? DEFAULT_ICON : icon_name)
+ , _size(size)
+ , _texture_width(0)
+ , _texture_height(0)
+ , _loading(false)
+ , _opacity(1.0f)
{
- _icon_name = g_strdup(icon_name ? icon_name : DEFAULT_ICON);
- if (g_strcmp0(_icon_name, "") != 0 && !defer_icon_loading)
+ if (_icon_name != "" && !defer_icon_loading)
LoadIcon();
}
-IconTexture::~IconTexture()
+void IconTexture::SetByIconName(std::string const& icon_name, unsigned int size)
{
- g_free(_icon_name);
-}
-
-void IconTexture::SetByIconName(const char* icon_name, unsigned int size)
-{
- g_free(_icon_name);
- _icon_name = g_strdup(icon_name);
+ _icon_name = icon_name;
_size = size;
LoadIcon();
}
-void IconTexture::SetByFilePath(const char* file_path, unsigned int size)
+void IconTexture::SetByFilePath(std::string const& file_path, unsigned int size)
{
- g_free(_icon_name);
- _icon_name = g_strdup(file_path);
+ _icon_name = file_path;
_size = size;
LoadIcon();
@@ -99,22 +90,22 @@ void IconTexture::LoadIcon()
{
LOG_DEBUG(logger) << "LoadIcon called (" << _icon_name << ") - loading: " << _loading;
static const char* const DEFAULT_GICON = ". GThemedIcon text-x-preview";
- if (!g_strcmp0(_icon_name, ""))
+ if (_icon_name.empty())
return;
-
+
if (_loading)
return;
_loading = true;
- glib::Object<GIcon> icon(::g_icon_new_for_string(_icon_name ? _icon_name : DEFAULT_GICON, NULL));
+ glib::Object<GIcon> icon(::g_icon_new_for_string(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), NULL));
if (icon)
{
- IconLoader::GetDefault().LoadFromGIconString(_icon_name ? _icon_name : DEFAULT_GICON,
+ IconLoader::GetDefault().LoadFromGIconString(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(),
_size,
sigc::mem_fun(this, &IconTexture::IconLoaded));
}
- else if (g_str_has_prefix(_icon_name, "http://"))
+ else if (_icon_name.find("http://") == 0)
{
IconLoader::GetDefault().LoadFromURI(_icon_name,
_size, sigc::mem_fun(this, &IconTexture::IconLoaded));
@@ -143,7 +134,7 @@ void IconTexture::Refresh(GdkPixbuf* pixbuf)
// Try and get a texture from the texture cache
std::string id("IconTexture.");
- id += _icon_name ? _icon_name : DEFAULT_ICON;
+ id += _icon_name.empty() ? DEFAULT_ICON : _icon_name;
_texture_cached = cache.FindTexture(id,
_texture_width,
_texture_height,
diff --git a/plugins/unityshell/src/IconTexture.h b/plugins/unityshell/src/IconTexture.h
index 7bfdc1a64..2b8979710 100644
--- a/plugins/unityshell/src/IconTexture.h
+++ b/plugins/unityshell/src/IconTexture.h
@@ -37,11 +37,10 @@ class IconTexture : public nux::TextureArea, public unity::debug::Introspectable
{
public:
IconTexture(nux::BaseTexture* texture, guint width, guint height);
- IconTexture(const char* icon_name, unsigned int size, bool defer_icon_loading = false);
- ~IconTexture();
+ IconTexture(std::string const& icon_name, unsigned int size, bool defer_icon_loading = false);
- void SetByIconName(const char* icon_name, unsigned int size);
- void SetByFilePath(const char* file_path, unsigned int size);
+ void SetByIconName(std::string const& icon_name, unsigned int size);
+ void SetByFilePath(std::string const& file_path, unsigned int size);
void GetTextureSize(int* width, int* height);
void LoadIcon();
@@ -54,7 +53,7 @@ public:
nux::BaseTexture* texture();
sigc::signal<void, nux::BaseTexture*> texture_updated;
-
+
protected:
// Key navigation
virtual bool AcceptKeyNavFocus();
@@ -64,7 +63,7 @@ protected:
void AddProperties(GVariantBuilder* builder);
virtual bool DoCanFocus();
GdkPixbuf* _pixbuf_cached;
-
+
protected:
void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
@@ -73,11 +72,9 @@ private:
void Refresh(GdkPixbuf* pixbuf);
void IconLoaded(std::string const& icon_name, unsigned size, GdkPixbuf* pixbuf);
- // FIXME: make _icon_name a std::string.
- char* _icon_name;
+ std::string _icon_name;
unsigned int _size;
-
nux::ObjectPtr<nux::BaseTexture> _texture_cached;
// FIXME: make these two a nux::Size.
int _texture_width;
diff --git a/plugins/unityshell/src/LauncherIcon.cpp b/plugins/unityshell/src/LauncherIcon.cpp
index 955174f2f..69a25dd69 100644
--- a/plugins/unityshell/src/LauncherIcon.cpp
+++ b/plugins/unityshell/src/LauncherIcon.cpp
@@ -332,23 +332,21 @@ GtkIconTheme* LauncherIcon::GetUnityTheme()
return _unity_theme;
}
-nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(const char* icon_name, int size, bool update_glow_colors)
+nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(std::string icon_name, int size, bool update_glow_colors)
{
GtkIconTheme* default_theme;
nux::BaseTexture* result = NULL;
- if (!icon_name)
+ if (icon_name.empty())
{
- // This leaks, so log if we do this.
- LOG_WARN(logger) << "Leaking... no icon_name passed in.";
- icon_name = g_strdup(DEFAULT_ICON.c_str());
+ icon_name = DEFAULT_ICON;
}
default_theme = gtk_icon_theme_get_default();
// FIXME: we need to create some kind of -unity postfix to see if we are looking to the unity-icon-theme
// for dedicated unity icons, then remove the postfix and degrade to other icon themes if not found
- if ((g_strcmp0(icon_name, "workspace-switcher") == 0) && IsMonoDefaultTheme())
+ if (icon_name == "workspace-switcher" && IsMonoDefaultTheme())
result = TextureFromSpecificGtkTheme(GetUnityTheme(), icon_name, size, update_glow_colors);
if (!result)
@@ -356,7 +354,7 @@ nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(const char* icon_name, int s
if (!result)
{
- if (g_strcmp0(icon_name, "folder") == 0)
+ if (icon_name == "folder")
result = NULL;
else
result = TextureFromSpecificGtkTheme(default_theme, "folder", size, update_glow_colors);
@@ -367,7 +365,7 @@ nux::BaseTexture* LauncherIcon::TextureFromGtkTheme(const char* icon_name, int s
}
nux::BaseTexture* LauncherIcon::TextureFromSpecificGtkTheme(GtkIconTheme* theme,
- const char* icon_name,
+ std::string const& icon_name,
int size,
bool update_glow_colors,
bool is_default_theme)
@@ -377,7 +375,7 @@ nux::BaseTexture* LauncherIcon::TextureFromSpecificGtkTheme(GtkIconTheme* theme,
GIcon* icon;
GtkIconLookupFlags flags = (GtkIconLookupFlags) 0;
- icon = g_icon_new_for_string(icon_name, NULL);
+ icon = g_icon_new_for_string(icon_name.c_str(), NULL);
if (G_IS_ICON(icon))
{
@@ -386,7 +384,7 @@ nux::BaseTexture* LauncherIcon::TextureFromSpecificGtkTheme(GtkIconTheme* theme,
}
else
{
- info = gtk_icon_theme_lookup_icon(theme,icon_name, size, flags);
+ info = gtk_icon_theme_lookup_icon(theme, icon_name.c_str(), size, flags);
}
if (!info && !is_default_theme)
@@ -423,15 +421,15 @@ nux::BaseTexture* LauncherIcon::TextureFromSpecificGtkTheme(GtkIconTheme* theme,
return result;
}
-nux::BaseTexture* LauncherIcon::TextureFromPath(const char* icon_name, int size, bool update_glow_colors)
+nux::BaseTexture* LauncherIcon::TextureFromPath(std::string const& icon_name, int size, bool update_glow_colors)
{
nux::BaseTexture* result;
- if (!icon_name)
- return TextureFromGtkTheme(DEFAULT_ICON.c_str(), size, update_glow_colors);
+ if (icon_name.empty())
+ return TextureFromGtkTheme(DEFAULT_ICON, size, update_glow_colors);
glib::Error error;
- glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(icon_name, size, size, &error));
+ glib::Object<GdkPixbuf> pbuf(gdk_pixbuf_new_from_file_at_size(icon_name.c_str(), size, size, &error));
if (GDK_IS_PIXBUF(pbuf.RawPtr()))
{
@@ -445,7 +443,7 @@ nux::BaseTexture* LauncherIcon::TextureFromPath(const char* icon_name, int size,
LOG_WARN(logger) << "Unable to load '" << icon_name
<< "' icon: " << error;
- result = TextureFromGtkTheme(DEFAULT_ICON.c_str(), size, update_glow_colors);
+ result = TextureFromGtkTheme(DEFAULT_ICON, size, update_glow_colors);
}
return result;
@@ -914,11 +912,11 @@ LauncherIcon::SetEmblem(LauncherIcon::BaseTexturePtr const& emblem)
}
void
-LauncherIcon::SetEmblemIconName(const char* name)
+LauncherIcon::SetEmblemIconName(std::string const& name)
{
BaseTexturePtr emblem;
- if (g_str_has_prefix(name, "/"))
+ if (name.at(0) == '/')
emblem = TextureFromPath(name, 22, false);
else
emblem = TextureFromGtkTheme(name, 22, false);
@@ -929,11 +927,8 @@ LauncherIcon::SetEmblemIconName(const char* name)
}
void
-LauncherIcon::SetEmblemText(const char* text)
+LauncherIcon::SetEmblemText(std::string const& text)
{
- if (text == NULL)
- return;
-
PangoLayout* layout = NULL;
PangoContext* pangoCtx = NULL;
@@ -967,7 +962,7 @@ LauncherIcon::SetEmblemText(const char* text)
pango_layout_set_width(layout, pango_units_from_double(width - 4.0f));
pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_NONE);
- pango_layout_set_markup_with_accel(layout, text, -1, '_', NULL);
+ pango_layout_set_markup_with_accel(layout, text.c_str(), -1, '_', NULL);
pangoCtx = pango_layout_get_context(layout); // is not ref'ed
pango_cairo_context_set_font_options(pangoCtx,
@@ -1085,14 +1080,13 @@ LauncherIcon::OnRemoteCountChanged(LauncherEntryRemote* remote)
if (!remote->CountVisible())
return;
- gchar* text;
+ std::string text;
if (remote->Count() > 9999)
- text = g_strdup_printf("****");
+ text = "****";
else
- text = g_strdup_printf("%i", (int) remote->Count());
+ text = std::to_string( (int) remote->Count());
SetEmblemText(text);
- g_free(text);
}
void
@@ -1124,9 +1118,7 @@ LauncherIcon::OnRemoteCountVisibleChanged(LauncherEntryRemote* remote)
{
if (remote->CountVisible())
{
- gchar* text = g_strdup_printf("%i", (int) remote->Count());
- SetEmblemText(text);
- g_free(text);
+ SetEmblemText(std::to_string( (int) remote->Count()));
}
else
{
diff --git a/plugins/unityshell/src/LauncherIcon.h b/plugins/unityshell/src/LauncherIcon.h
index 9ca65028d..670737e42 100644
--- a/plugins/unityshell/src/LauncherIcon.h
+++ b/plugins/unityshell/src/LauncherIcon.h
@@ -123,9 +123,9 @@ public:
float GetProgress();
- void SetEmblemIconName(const char* name);
+ void SetEmblemIconName(std::string const& name);
- void SetEmblemText(const char* text);
+ void SetEmblemText(std::string const& text);
void DeleteEmblem();
@@ -195,9 +195,9 @@ public:
virtual bool IsVisible() const { return false; }
virtual void AboutToRemove() {}
-
+
virtual void Stick(bool save = true) {}
-
+
virtual void UnStick() {}
protected:
@@ -253,11 +253,11 @@ protected:
virtual bool HandlesSpread () { return false; }
- nux::BaseTexture* TextureFromGtkTheme(const char* name, int size, bool update_glow_colors = true);
+ nux::BaseTexture* TextureFromGtkTheme(std::string name, int size, bool update_glow_colors = true);
- nux::BaseTexture* TextureFromSpecificGtkTheme(GtkIconTheme* theme, const char* name, int size, bool update_glow_colors = true, bool is_default_theme = false);
+ nux::BaseTexture* TextureFromSpecificGtkTheme(GtkIconTheme* theme, std::string const& name, int size, bool update_glow_colors = true, bool is_default_theme = false);
- nux::BaseTexture* TextureFromPath(const char* name, int size, bool update_glow_colors = true);
+ nux::BaseTexture* TextureFromPath(std::string const& name, int size, bool update_glow_colors = true);
static bool IsMonoDefaultTheme();
@@ -323,7 +323,7 @@ private:
gint64 _shortcut;
IconType _icon_type;
-
+
std::vector<nux::Point3> _center;
std::vector<bool> _has_visible_window;
std::vector<nux::Point3> _last_stable;
diff --git a/plugins/unityshell/src/LensBarIcon.cpp b/plugins/unityshell/src/LensBarIcon.cpp
index 297d8ef2c..946b40686 100644
--- a/plugins/unityshell/src/LensBarIcon.cpp
+++ b/plugins/unityshell/src/LensBarIcon.cpp
@@ -28,7 +28,7 @@ namespace dash
NUX_IMPLEMENT_OBJECT_TYPE(LensBarIcon);
LensBarIcon::LensBarIcon(std::string id_, std::string icon_hint)
- : IconTexture(icon_hint.c_str(), 24)
+ : IconTexture(icon_hint, 24)
, id(id_)
, active(false)
, inactive_opacity_(0.4f)
diff --git a/plugins/unityshell/src/PlacesSimpleTile.cpp b/plugins/unityshell/src/PlacesSimpleTile.cpp
index f6545a491..d23e99c85 100644
--- a/plugins/unityshell/src/PlacesSimpleTile.cpp
+++ b/plugins/unityshell/src/PlacesSimpleTile.cpp
@@ -37,23 +37,19 @@ namespace unity
{
NUX_IMPLEMENT_OBJECT_TYPE(PlacesSimpleTile);
-PlacesSimpleTile::PlacesSimpleTile(const char* icon_name,
- const char* label,
+PlacesSimpleTile::PlacesSimpleTile(std::string const& icon_name,
+ std::string const& label,
int icon_size,
bool defer_icon_loading,
const void* id)
: PlacesTile(NUX_TRACKER_LOCATION, id),
- _label(NULL),
- _icon(NULL),
- _uri(NULL),
+ _label(label),
+ _icon(icon_name),
_idealiconsize(icon_size)
{
dash::Style& style = dash::Style::Instance();
nux::VLayout* layout = new nux::VLayout("", NUX_TRACKER_LOCATION);
- _label = g_strdup(label);
- _icon = g_strdup(icon_name);
-
_icontex = new IconTexture(_icon, icon_size, defer_icon_loading);
_icontex->SetMinMaxSize(style.GetTileWidth(), icon_size);
AddChild(_icontex);
@@ -76,14 +72,6 @@ PlacesSimpleTile::PlacesSimpleTile(const char* icon_name,
SetDndEnabled(true, false);
}
-
-PlacesSimpleTile::~PlacesSimpleTile()
-{
- g_free(_label);
- g_free(_icon);
- g_free(_uri);
-}
-
bool
PlacesSimpleTile::DndSourceDragBegin()
{
@@ -104,14 +92,14 @@ PlacesSimpleTile::DndSourceGetDragImage()
GError* error = NULL;
GIcon* icon;
- const char* icon_name = _icon;
+ std::string icon_name = _icon;
int size = 64;
- if (!icon_name)
+ if (icon_name.empty())
icon_name = "application-default-icon";
theme = gtk_icon_theme_get_default();
- icon = g_icon_new_for_string(icon_name, NULL);
+ icon = g_icon_new_for_string(icon_name.c_str(), NULL);
if (G_IS_ICON(icon))
{
@@ -121,7 +109,7 @@ PlacesSimpleTile::DndSourceGetDragImage()
else
{
info = gtk_icon_theme_lookup_icon(theme,
- icon_name,
+ icon_name.c_str(),
size,
(GtkIconLookupFlags) 0);
}
@@ -155,23 +143,21 @@ PlacesSimpleTile::DndSourceGetDragImage()
return result;
}
-std::list<const char*>
-PlacesSimpleTile::DndSourceGetDragTypes()
+std::list<const char*> PlacesSimpleTile::DndSourceGetDragTypes()
{
std::list<const char*> result;
result.push_back("text/uri-list");
return result;
}
-const char*
-PlacesSimpleTile::DndSourceGetDataForType(const char* type, int* size, int* format)
+const char* PlacesSimpleTile::DndSourceGetDataForType(const char* type, int* size, int* format)
{
*format = 8;
- if (_uri)
+ if (!_uri.empty())
{
- *size = strlen(_uri);
- return _uri;
+ *size = _uri.size();
+ return _uri.c_str();
}
else
{
@@ -180,14 +166,12 @@ PlacesSimpleTile::DndSourceGetDataForType(const char* type, int* size, int* form
}
}
-void
-PlacesSimpleTile::DndSourceDragFinished(nux::DndAction result)
+void PlacesSimpleTile::DndSourceDragFinished(nux::DndAction result)
{
UnReference();
}
-nux::Geometry
-PlacesSimpleTile::GetHighlightGeometry()
+nux::Geometry PlacesSimpleTile::GetHighlightGeometry()
{
nux::Geometry base = GetGeometry();
int width = 0, height = 0;
@@ -202,50 +186,37 @@ PlacesSimpleTile::GetHighlightGeometry()
return _highlight_geometry;
}
-const char*
-PlacesSimpleTile::GetLabel()
+std::string PlacesSimpleTile::GetLabel() const
{
return _label;
}
-const char*
-PlacesSimpleTile::GetIcon()
+std::string PlacesSimpleTile::GetIcon() const
{
return _icon;
}
-const char*
-PlacesSimpleTile::GetURI()
+std::string PlacesSimpleTile::GetURI() const
{
return _uri;
}
-void
-PlacesSimpleTile::SetURI(const char* uri)
+void PlacesSimpleTile::SetURI(std::string const& uri)
{
- if (_uri)
- g_free(_uri);
-
- _uri = NULL;
-
- if (uri)
- _uri = g_strdup(uri);
+ _uri = uri;
}
-std::string
-PlacesSimpleTile::GetName() const
+std::string PlacesSimpleTile::GetName() const
{
return "PlacesTile";
}
-void
-PlacesSimpleTile::AddProperties(GVariantBuilder* builder)
+void PlacesSimpleTile::AddProperties(GVariantBuilder* builder)
{
unity::variant::BuilderWrapper(builder).add(GetGeometry());
}
-void
-PlacesSimpleTile::LoadIcon()
+void PlacesSimpleTile::LoadIcon()
{
_icontex->LoadIcon();
diff --git a/plugins/unityshell/src/PlacesSimpleTile.h b/plugins/unityshell/src/PlacesSimpleTile.h
index 561cc3b6a..8994bc864 100644
--- a/plugins/unityshell/src/PlacesSimpleTile.h
+++ b/plugins/unityshell/src/PlacesSimpleTile.h
@@ -35,13 +35,12 @@ class PlacesSimpleTile : public unity::debug::Introspectable, public PlacesTile
NUX_DECLARE_OBJECT_TYPE(PlacesSimpleTile, PlacesTile);
public:
- PlacesSimpleTile(const char* icon, const char* label, int icon_size = 64, bool defer_icon_loading = false, const void* id = NULL);
- ~PlacesSimpleTile();
+ PlacesSimpleTile(std::string const& icon, std::string const& label, int icon_size = 64, bool defer_icon_loading = false, const void* id = NULL);
- const char* GetLabel();
- const char* GetIcon();
- const char* GetURI();
- void SetURI(const char* uri);
+ std::string GetLabel() const;
+ std::string GetIcon() const;
+ std::string GetURI() const;
+ void SetURI(std::string const& uri);
void LoadIcon();
@@ -59,9 +58,9 @@ protected:
private:
nux::Geometry _highlight_geometry;
- char* _label;
- char* _icon;
- char* _uri;
+ std::string _label;
+ std::string _icon;
+ std::string _uri;
int _idealiconsize;
IconTexture* _icontex;
nux::StaticCairoText* _cairotext;
diff --git a/plugins/unityshell/src/PreviewApplications.cpp b/plugins/unityshell/src/PreviewApplications.cpp
index e621fecfe..66f8aa049 100644
--- a/plugins/unityshell/src/PreviewApplications.cpp
+++ b/plugins/unityshell/src/PreviewApplications.cpp
@@ -54,8 +54,8 @@ namespace unity {
void PreviewApplications::BuildLayout()
{
- IconTexture *screenshot = new IconTexture (preview_->screenshot_icon_hint.c_str(), 420);
- IconTexture *icon = new IconTexture (preview_->icon_hint.c_str(), 80);
+ IconTexture *screenshot = new IconTexture(preview_->screenshot_icon_hint, 420);
+ IconTexture *icon = new IconTexture(preview_->icon_hint, 80);
nux::StaticCairoText *name = new nux::StaticCairoText (preview_->name, NUX_TRACKER_LOCATION);
name->SetFont("Ubuntu 25");
diff --git a/plugins/unityshell/src/PreviewGeneric.cpp b/plugins/unityshell/src/PreviewGeneric.cpp
index 13507a5df..029766f96 100644
--- a/plugins/unityshell/src/PreviewGeneric.cpp
+++ b/plugins/unityshell/src/PreviewGeneric.cpp
@@ -54,7 +54,7 @@ namespace unity {
void PreviewGeneric::BuildLayout()
{
- IconTexture *icon = new IconTexture (preview_->icon_hint.c_str(), 300);
+ IconTexture *icon = new IconTexture(preview_->icon_hint, 300);
nux::StaticCairoText *name = new nux::StaticCairoText (preview_->name, NUX_TRACKER_LOCATION);
name->SetFont("Ubuntu 25");
diff --git a/plugins/unityshell/src/PreviewMusic.cpp b/plugins/unityshell/src/PreviewMusic.cpp
index c3c1e3c47..43f310f59 100644
--- a/plugins/unityshell/src/PreviewMusic.cpp
+++ b/plugins/unityshell/src/PreviewMusic.cpp
@@ -57,7 +57,7 @@ namespace unity {
void PreviewMusicAlbum::BuildLayout()
{
- IconTexture *cover = new IconTexture (preview_->album_cover.c_str(), 400);
+ IconTexture *cover = new IconTexture (preview_->album_cover, 400);
nux::StaticCairoText *title = new nux::StaticCairoText(preview_->name, NUX_TRACKER_LOCATION);
title->SetFont("Ubuntu 25");
diff --git a/plugins/unityshell/src/PreviewMusicTrack.cpp b/plugins/unityshell/src/PreviewMusicTrack.cpp
index ccb7a7475..b0447d5ae 100644
--- a/plugins/unityshell/src/PreviewMusicTrack.cpp
+++ b/plugins/unityshell/src/PreviewMusicTrack.cpp
@@ -56,7 +56,7 @@ namespace unity {
void PreviewMusicTrack::BuildLayout()
{
- IconTexture *cover = new IconTexture (preview_->album_cover.c_str(), 400);
+ IconTexture *cover = new IconTexture(preview_->album_cover, 400);
nux::StaticCairoText *title = new nux::StaticCairoText(preview_->title, NUX_TRACKER_LOCATION);
title->SetFont("Ubuntu 25");
diff --git a/plugins/unityshell/src/unity-places-simple-tile-accessible.cpp b/plugins/unityshell/src/unity-places-simple-tile-accessible.cpp
index 72b8e3983..9084388fb 100644
--- a/plugins/unityshell/src/unity-places-simple-tile-accessible.cpp
+++ b/plugins/unityshell/src/unity-places-simple-tile-accessible.cpp
@@ -129,7 +129,7 @@ unity_places_simple_tile_accessible_get_name(AtkObject* obj)
tile = dynamic_cast<unity::PlacesSimpleTile*>(nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(obj)));
if (tile != NULL)
{
- name = tile->GetLabel();
+ name = tile->GetLabel().c_str();
pango_parse_markup(name, -1, 0, NULL,
&self->priv->stripped_name,
NULL, NULL);