summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-10-04 12:36:28 -0400
committerTarmac <>2012-10-04 12:36:28 -0400
commitfb4ece34de4ba64cae819f844556511d1d276947 (patch)
tree88ecefb3031484ac8cbfc3358463e3cf593a087d /unity-shared
parentbbfb0cd6bcfaf901e3a3bd49543a11e1188bad28 (diff)
parent22d87a562653695bb0e0ac06e4b65eba1097e460 (diff)
Always remove 'No Image Available' when loading a preview cover-art texture. (LP: #1057035). Fixes: https://bugs.launchpad.net/bugs/1057035. Approved by Michal Hruby.
(bzr r2800)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CoverArt.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/unity-shared/CoverArt.cpp b/unity-shared/CoverArt.cpp
index 5cc5e1788..d45ca65e9 100644
--- a/unity-shared/CoverArt.cpp
+++ b/unity-shared/CoverArt.cpp
@@ -42,6 +42,7 @@ namespace
nux::logging::Logger logger("unity.dash.previews.coverart");
const int ICON_SIZE = 256;
+const int IMAGE_TIMEOUT = 30;
}
NUX_IMPLEMENT_OBJECT_TYPE(CoverArt);
@@ -88,9 +89,7 @@ void CoverArt::AddProperties(GVariantBuilder* builder)
void CoverArt::SetImage(std::string const& image_hint)
{
- spinner_timeout_.reset();
- frame_timeout_.reset();
- waiting_ = false;
+ StopWaiting();
if (slot_handle_ > 0)
{
@@ -98,8 +97,6 @@ void CoverArt::SetImage(std::string const& image_hint)
slot_handle_ = 0;
}
- GIcon* icon = g_icon_new_for_string(image_hint.c_str(), NULL);
-
bool bLoadTexture = false;
bLoadTexture |= g_strrstr(image_hint.c_str(), "://") != NULL;
if (!bLoadTexture && !image_hint.empty())
@@ -115,10 +112,8 @@ void CoverArt::SetImage(std::string const& image_hint)
}
else if (!image_hint.empty())
{
- if (GetLayout())
- GetLayout()->RemoveChildObject(overlay_text_);
-
- if (G_IS_ICON(icon))
+ glib::Object<GIcon> icon(g_icon_new_for_string(image_hint.c_str(), NULL));
+ if (icon.IsType(G_TYPE_ICON))
{
StartWaiting();
slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded));
@@ -133,9 +128,6 @@ void CoverArt::SetImage(std::string const& image_hint)
{
SetNoImageAvailable();
}
-
- if (icon != NULL)
- g_object_unref(icon);
}
void CoverArt::GenerateImage(std::string const& uri)
@@ -159,12 +151,14 @@ void CoverArt::StartWaiting()
if (waiting_)
return;
+ if (GetLayout())
+ GetLayout()->RemoveChildObject(overlay_text_);
waiting_ = true;
rotate_matrix_.Rotate_z(0.0f);
rotation_ = 0.0f;
- spinner_timeout_.reset(new glib::TimeoutSeconds(5, [&]
+ spinner_timeout_.reset(new glib::TimeoutSeconds(IMAGE_TIMEOUT, [&]
{
StopWaiting();
@@ -221,11 +215,13 @@ void CoverArt::IconLoaded(std::string const& texid,
pixbuf_height = (pixbuf_height) ? pixbuf_height: 1; // no zeros please
}
+ if (GetLayout())
+ GetLayout()->RemoveChildObject(overlay_text_);
+
if (pixbuf_width == pixbuf_height)
- {
+ {
// quick path for square icons
texture_screenshot_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
- QueueDraw();
}
else
{
@@ -273,8 +269,8 @@ void CoverArt::IconLoaded(std::string const& texid,
cairo_paint(cr);
texture_screenshot_.Adopt(texture_from_cairo_graphics(cairo_graphics));
- QueueDraw();
}
+ QueueDraw();
}
void CoverArt::TextureLoaded(std::string const& texid,
@@ -291,6 +287,10 @@ void CoverArt::TextureLoaded(std::string const& texid,
SetNoImageAvailable();
return;
}
+
+ if (GetLayout())
+ GetLayout()->RemoveChildObject(overlay_text_);
+
texture_screenshot_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
QueueDraw();
}
@@ -472,13 +472,7 @@ void CoverArt::OnThumbnailError(std::string const& error_hint)
StopWaiting();
texture_screenshot_.Release();
- if (GetLayout())
- {
- GetLayout()->RemoveChildObject(overlay_text_);
- GetLayout()->AddView(overlay_text_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0, nux::LayoutPosition(1));
- ComputeContentSize();
- }
- QueueDraw();
+ SetNoImageAvailable();
notifier_.Release();
}