Merge lp:~nick-dedekind/unity/lp1057035.No-Image-Available into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Michal Hruby
Approved revision: 2797
Merged at revision: 2800
Proposed branch: lp:~nick-dedekind/unity/lp1057035.No-Image-Available
Merge into: lp:unity
Diff against target: 121 lines (+17/-23)
1 file modified
unity-shared/CoverArt.cpp (+17/-23)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp1057035.No-Image-Available
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+128021@code.launchpad.net

Commit message

Always remove 'No Image Available' when loading a preview cover-art texture. (LP: #1057035)

Description of the change

Always remove 'No Image Available' when loading a preview cover-art texture. (LP: #1057035)

To post a comment you must log in.
2796. By Nick Dedekind on 2012-10-04

Changed G_IS_ICON to glib::Object::IsType

2797. By Nick Dedekind on 2012-10-04

Increased cover-art timeout to 30 seconds.

Revision history for this message
Michal Hruby (mhr3) wrote :

Does what the tin says... +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'unity-shared/CoverArt.cpp'
2--- unity-shared/CoverArt.cpp 2012-09-24 21:23:57 +0000
3+++ unity-shared/CoverArt.cpp 2012-10-04 15:39:23 +0000
4@@ -42,6 +42,7 @@
5 nux::logging::Logger logger("unity.dash.previews.coverart");
6
7 const int ICON_SIZE = 256;
8+const int IMAGE_TIMEOUT = 30;
9 }
10
11 NUX_IMPLEMENT_OBJECT_TYPE(CoverArt);
12@@ -88,9 +89,7 @@
13
14 void CoverArt::SetImage(std::string const& image_hint)
15 {
16- spinner_timeout_.reset();
17- frame_timeout_.reset();
18- waiting_ = false;
19+ StopWaiting();
20
21 if (slot_handle_ > 0)
22 {
23@@ -98,8 +97,6 @@
24 slot_handle_ = 0;
25 }
26
27- GIcon* icon = g_icon_new_for_string(image_hint.c_str(), NULL);
28-
29 bool bLoadTexture = false;
30 bLoadTexture |= g_strrstr(image_hint.c_str(), "://") != NULL;
31 if (!bLoadTexture && !image_hint.empty())
32@@ -115,10 +112,8 @@
33 }
34 else if (!image_hint.empty())
35 {
36- if (GetLayout())
37- GetLayout()->RemoveChildObject(overlay_text_);
38-
39- if (G_IS_ICON(icon))
40+ glib::Object<GIcon> icon(g_icon_new_for_string(image_hint.c_str(), NULL));
41+ if (icon.IsType(G_TYPE_ICON))
42 {
43 StartWaiting();
44 slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded));
45@@ -133,9 +128,6 @@
46 {
47 SetNoImageAvailable();
48 }
49-
50- if (icon != NULL)
51- g_object_unref(icon);
52 }
53
54 void CoverArt::GenerateImage(std::string const& uri)
55@@ -159,12 +151,14 @@
56 if (waiting_)
57 return;
58
59+ if (GetLayout())
60+ GetLayout()->RemoveChildObject(overlay_text_);
61 waiting_ = true;
62
63 rotate_matrix_.Rotate_z(0.0f);
64 rotation_ = 0.0f;
65
66- spinner_timeout_.reset(new glib::TimeoutSeconds(5, [&]
67+ spinner_timeout_.reset(new glib::TimeoutSeconds(IMAGE_TIMEOUT, [&]
68 {
69 StopWaiting();
70
71@@ -221,11 +215,13 @@
72 pixbuf_height = (pixbuf_height) ? pixbuf_height: 1; // no zeros please
73 }
74
75+ if (GetLayout())
76+ GetLayout()->RemoveChildObject(overlay_text_);
77+
78 if (pixbuf_width == pixbuf_height)
79- {
80+ {
81 // quick path for square icons
82 texture_screenshot_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
83- QueueDraw();
84 }
85 else
86 {
87@@ -273,8 +269,8 @@
88 cairo_paint(cr);
89
90 texture_screenshot_.Adopt(texture_from_cairo_graphics(cairo_graphics));
91- QueueDraw();
92 }
93+ QueueDraw();
94 }
95
96 void CoverArt::TextureLoaded(std::string const& texid,
97@@ -291,6 +287,10 @@
98 SetNoImageAvailable();
99 return;
100 }
101+
102+ if (GetLayout())
103+ GetLayout()->RemoveChildObject(overlay_text_);
104+
105 texture_screenshot_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
106 QueueDraw();
107 }
108@@ -472,13 +472,7 @@
109 StopWaiting();
110
111 texture_screenshot_.Release();
112- if (GetLayout())
113- {
114- GetLayout()->RemoveChildObject(overlay_text_);
115- GetLayout()->AddView(overlay_text_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL, 100.0, nux::LayoutPosition(1));
116- ComputeContentSize();
117- }
118- QueueDraw();
119+ SetNoImageAvailable();
120 notifier_.Release();
121 }
122