Merge lp:~mhr3/unity/icon-loader-width-and-height into lp:unity
- icon-loader-width-and-height
- Merge into trunk
Proposed by
Michal Hruby
Status: | Merged |
---|---|
Approved by: | Omer Akram |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2690 |
Proposed branch: | lp:~mhr3/unity/icon-loader-width-and-height |
Merge into: | lp:unity |
Prerequisite: | lp:~nick-dedekind/unity/dash-results.focus+size |
Diff against target: |
1235 lines (+416/-178) 15 files modified
dash/ResultRendererTile.cpp (+11/-17) dash/ResultRendererTile.h (+1/-1) launcher/DeviceNotificationDisplayImp.cpp (+4/-3) plugins/unityshell/resources/emblem_apps.svg (+19/-0) plugins/unityshell/resources/emblem_books.svg (+9/-0) plugins/unityshell/resources/emblem_clothes.svg (+8/-0) plugins/unityshell/resources/emblem_music.svg (+15/-0) plugins/unityshell/resources/emblem_video.svg (+17/-0) tests/test_icon_loader.cpp (+6/-6) unity-shared/CoverArt.cpp (+16/-10) unity-shared/CoverArt.h (+3/-3) unity-shared/IconLoader.cpp (+290/-127) unity-shared/IconLoader.h (+9/-5) unity-shared/IconTexture.cpp (+7/-5) unity-shared/IconTexture.h (+1/-1) |
To merge this branch: | bzr merge lp:~mhr3/unity/icon-loader-width-and-height |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Omer Akram (community) | Approve | ||
John Lea (community) | design | Approve | |
Nick Dedekind (community) | Approve | ||
Review via email: mp+124013@code.launchpad.net |
Commit message
Change the IconLoader methods to allow specifying both maximum width and height. Updated rendering of the icon ribbons.
Description of the change
Change the IconLoader methods to allow specifying both maximum width and height. Also updated rendering of the icon ribbons.
To post a comment you must log in.
Revision history for this message
Nick Dedekind (nick-dedekind) wrote : | # |
Revision history for this message
John Lea (johnlea) : | # |
review:
Approve
(design)
Revision history for this message
Unity Merger (unity-merger) wrote : | # |
The prerequisite lp:~nick-dedekind/unity/dash-results.focus+size has not yet been merged into lp:unity.
Revision history for this message
Unity Merger (unity-merger) wrote : | # |
No proposals found for merge of lp:~nick-dedekind/unity/dash-results.focus+size into lp:unity.
Revision history for this message
Omer Akram (om26er) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'dash/ResultRendererTile.cpp' | |||
2 | --- dash/ResultRendererTile.cpp 2012-09-13 10:12:22 +0000 | |||
3 | +++ dash/ResultRendererTile.cpp 2012-09-13 10:12:22 +0000 | |||
4 | @@ -204,7 +204,7 @@ | |||
5 | 204 | void ResultRendererTile::LoadIcon(Result& row) | 204 | void ResultRendererTile::LoadIcon(Result& row) |
6 | 205 | { | 205 | { |
7 | 206 | Style& style = Style::Instance(); | 206 | Style& style = Style::Instance(); |
9 | 207 | std::string const& icon_hint = row.icon_hint; | 207 | std::string icon_hint(row.icon_hint); |
10 | 208 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" | 208 | #define DEFAULT_GICON ". GThemedIcon text-x-preview" |
11 | 209 | std::string icon_name; | 209 | std::string icon_name; |
12 | 210 | if (G_UNLIKELY(neko)) | 210 | if (G_UNLIKELY(neko)) |
13 | @@ -222,26 +222,20 @@ | |||
14 | 222 | icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON; | 222 | icon_name = !icon_hint.empty() ? icon_hint : DEFAULT_GICON; |
15 | 223 | } | 223 | } |
16 | 224 | 224 | ||
18 | 225 | GIcon* icon = g_icon_new_for_string(icon_name.c_str(), NULL); | 225 | glib::Object<GIcon> icon(g_icon_new_for_string(icon_name.c_str(), NULL)); |
19 | 226 | TextureContainer* container = row.renderer<TextureContainer*>(); | 226 | TextureContainer* container = row.renderer<TextureContainer*>(); |
20 | 227 | 227 | ||
21 | 228 | IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_hint, row); | 228 | IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_hint, row); |
22 | 229 | 229 | ||
30 | 230 | if (g_strrstr(icon_name.c_str(), "://")) | 230 | if (icon.IsType(G_TYPE_ICON)) |
31 | 231 | { | 231 | { |
32 | 232 | container->slot_handle = IconLoader::GetDefault().LoadFromURI(icon_name, style.GetTileImageSize(), slot); | 232 | bool use_large_icon = icon.IsType(G_TYPE_FILE_ICON) || !icon.IsType(G_TYPE_THEMED_ICON); |
33 | 233 | } | 233 | container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, style.GetTileImageSize(), use_large_icon ? style.GetTileImageSize() : style.GetTileGIconSize(), slot); |
27 | 234 | else if (G_IS_ICON(icon)) | ||
28 | 235 | { | ||
29 | 236 | container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(icon_name, g_str_has_prefix(icon_name.c_str(), "/") ? style.GetTileImageSize() : style.GetTileGIconSize(), slot); | ||
34 | 237 | } | 234 | } |
35 | 238 | else | 235 | else |
36 | 239 | { | 236 | { |
38 | 240 | container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, style.GetTileGIconSize(), slot); | 237 | container->slot_handle = IconLoader::GetDefault().LoadFromIconName(icon_name, -1, style.GetTileGIconSize(), slot); |
39 | 241 | } | 238 | } |
40 | 242 | |||
41 | 243 | if (icon != NULL) | ||
42 | 244 | g_object_unref(icon); | ||
43 | 245 | } | 239 | } |
44 | 246 | 240 | ||
45 | 247 | nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& texid, | 241 | nux::BaseTexture* ResultRendererTile::CreateTextureCallback(std::string const& texid, |
46 | @@ -321,7 +315,8 @@ | |||
47 | 321 | 315 | ||
48 | 322 | 316 | ||
49 | 323 | void ResultRendererTile::IconLoaded(std::string const& texid, | 317 | void ResultRendererTile::IconLoaded(std::string const& texid, |
51 | 324 | unsigned size, | 318 | int max_width, |
52 | 319 | int max_height, | ||
53 | 325 | glib::Object<GdkPixbuf> const& pixbuf, | 320 | glib::Object<GdkPixbuf> const& pixbuf, |
54 | 326 | std::string icon_name, | 321 | std::string icon_name, |
55 | 327 | Result& row) | 322 | Result& row) |
56 | @@ -333,7 +328,7 @@ | |||
57 | 333 | if (pixbuf && container) | 328 | if (pixbuf && container) |
58 | 334 | { | 329 | { |
59 | 335 | TextureCache& cache = TextureCache::GetDefault(); | 330 | TextureCache& cache = TextureCache::GetDefault(); |
61 | 336 | BaseTexturePtr texture(cache.FindTexture(icon_name, size, size, | 331 | BaseTexturePtr texture(cache.FindTexture(icon_name, max_width, max_height, |
62 | 337 | sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateTextureCallback), pixbuf))); | 332 | sigc::bind(sigc::mem_fun(this, &ResultRendererTile::CreateTextureCallback), pixbuf))); |
63 | 338 | 333 | ||
64 | 339 | BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", style.GetTileIconHightlightWidth(), style.GetTileIconHightlightHeight(), sigc::mem_fun(this, &ResultRendererTile::DrawHighlight))); | 334 | BaseTexturePtr texture_prelight(cache.FindTexture("resultview_prelight", style.GetTileIconHightlightWidth(), style.GetTileIconHightlightHeight(), sigc::mem_fun(this, &ResultRendererTile::DrawHighlight))); |
65 | @@ -350,9 +345,8 @@ | |||
66 | 350 | { | 345 | { |
67 | 351 | // we need to load a missing icon | 346 | // we need to load a missing icon |
68 | 352 | IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_name, row); | 347 | IconLoader::IconLoaderCallback slot = sigc::bind(sigc::mem_fun(this, &ResultRendererTile::IconLoaded), icon_name, row); |
70 | 353 | container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(". GThemedIcon text-x-preview", size, slot); | 348 | container->slot_handle = IconLoader::GetDefault().LoadFromGIconString(". GThemedIcon text-x-preview", max_width, max_height, slot); |
71 | 354 | } | 349 | } |
72 | 355 | |||
73 | 356 | } | 350 | } |
74 | 357 | 351 | ||
75 | 358 | 352 | ||
76 | 359 | 353 | ||
77 | === modified file 'dash/ResultRendererTile.h' | |||
78 | --- dash/ResultRendererTile.h 2012-09-13 10:12:22 +0000 | |||
79 | +++ dash/ResultRendererTile.h 2012-09-13 10:12:22 +0000 | |||
80 | @@ -90,7 +90,7 @@ | |||
81 | 90 | nux::ObjectPtr<nux::BaseTexture> normal_cache_; | 90 | nux::ObjectPtr<nux::BaseTexture> normal_cache_; |
82 | 91 | private: | 91 | private: |
83 | 92 | //icon loading callbacks | 92 | //icon loading callbacks |
85 | 93 | void IconLoaded(std::string const& texid, unsigned size, | 93 | void IconLoaded(std::string const& texid, int max_width, int max_height, |
86 | 94 | glib::Object<GdkPixbuf> const& pixbuf, | 94 | glib::Object<GdkPixbuf> const& pixbuf, |
87 | 95 | std::string icon_name, Result& row); | 95 | std::string icon_name, Result& row); |
88 | 96 | nux::BaseTexture* CreateTextureCallback(std::string const& texid, | 96 | nux::BaseTexture* CreateTextureCallback(std::string const& texid, |
89 | 97 | 97 | ||
90 | === modified file 'launcher/DeviceNotificationDisplayImp.cpp' | |||
91 | --- launcher/DeviceNotificationDisplayImp.cpp 2012-08-22 09:03:25 +0000 | |||
92 | +++ launcher/DeviceNotificationDisplayImp.cpp 2012-09-13 10:12:22 +0000 | |||
93 | @@ -40,12 +40,13 @@ | |||
94 | 40 | void Show(std::string const& icon_name, std::string const& volume_name) | 40 | void Show(std::string const& icon_name, std::string const& volume_name) |
95 | 41 | { | 41 | { |
96 | 42 | int icon_size = 48; | 42 | int icon_size = 48; |
98 | 43 | IconLoader::GetDefault().LoadFromGIconString(icon_name, icon_size, | 43 | IconLoader::GetDefault().LoadFromGIconString(icon_name, -1, icon_size, |
99 | 44 | sigc::bind(sigc::mem_fun(this, &Impl::ShowNotificationWhenIconIsReady), volume_name)); | 44 | sigc::bind(sigc::mem_fun(this, &Impl::ShowNotificationWhenIconIsReady), volume_name)); |
100 | 45 | } | 45 | } |
101 | 46 | 46 | ||
102 | 47 | void ShowNotificationWhenIconIsReady(std::string const& icon_name, | 47 | void ShowNotificationWhenIconIsReady(std::string const& icon_name, |
104 | 48 | unsigned size, | 48 | int max_width, |
105 | 49 | int max_height, | ||
106 | 49 | glib::Object<GdkPixbuf> const& pixbuf, | 50 | glib::Object<GdkPixbuf> const& pixbuf, |
107 | 50 | std::string const& volume_name) | 51 | std::string const& volume_name) |
108 | 51 | { | 52 | { |
109 | @@ -55,7 +56,7 @@ | |||
110 | 55 | 56 | ||
111 | 56 | notify_notification_set_hint(notification, "x-canonical-private-synchronous", g_variant_new_boolean(TRUE)); | 57 | notify_notification_set_hint(notification, "x-canonical-private-synchronous", g_variant_new_boolean(TRUE)); |
112 | 57 | 58 | ||
114 | 58 | if (GDK_IS_PIXBUF(pixbuf.RawPtr())) | 59 | if (pixbuf) |
115 | 59 | notify_notification_set_image_from_pixbuf(notification, pixbuf); | 60 | notify_notification_set_image_from_pixbuf(notification, pixbuf); |
116 | 60 | 61 | ||
117 | 61 | notify_notification_show(notification, nullptr); | 62 | notify_notification_show(notification, nullptr); |
118 | 62 | 63 | ||
119 | === added file 'plugins/unityshell/resources/emblem_apps.svg' | |||
120 | --- plugins/unityshell/resources/emblem_apps.svg 1970-01-01 00:00:00 +0000 | |||
121 | +++ plugins/unityshell/resources/emblem_apps.svg 2012-09-13 10:12:22 +0000 | |||
122 | @@ -0,0 +1,19 @@ | |||
123 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
124 | 2 | <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
125 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
126 | 4 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
127 | 5 | width="14px" height="14px" viewBox="0 0 14 14" enable-background="new 0 0 14 14" xml:space="preserve"> | ||
128 | 6 | <path fill="#DC4A26" d="M8.5,4.504v7.997c0,0.55-0.469,0.999-1.018,0.999H6.498c-0.55,0-0.998-0.449-0.998-0.999V4.504H8.5z"/> | ||
129 | 7 | <g> | ||
130 | 8 | <path fill="#DC4A26" d="M4.5,4.504h-2v-1h2V1.505c0-0.55-0.45-1-1-1H1.501c-0.55,0-1,0.45-1,1L0.5,12.501 | ||
131 | 9 | c0,0.55,0.45,0.999,1,0.999h1.999c0.55,0,1-0.449,1-0.999V10.5L2.5,10.502v-1L4.499,9.5V7.503H2.5v-1h2"/> | ||
132 | 10 | </g> | ||
133 | 11 | <path fill="#DC4A26" d="M4.5,6.503v-1l0,0V6.503L4.5,6.503z"/> | ||
134 | 12 | <path fill="#DC4A26" d="M4.5,9.502v-1h0L4.5,9.502L4.5,9.502z"/> | ||
135 | 13 | <path fill="#DC4A26" d="M4.5,12.499L4.5,12.499L4.5,12.499L4.5,12.499L4.5,12.499z"/> | ||
136 | 14 | <path fill="#DC4A26" d="M11.866,0.508v1.237C12.102,1.856,12.3,2.052,12.3,2.286c0,0.354-0.358,0.64-0.8,0.64s-0.8-0.286-0.8-0.64 | ||
137 | 15 | c0-0.234,0.198-0.43,0.433-0.541V0.508C10.66,0.972,9.5,2.321,9.5,2.917c0,0.884,1.116,1.6,2,1.6s2-0.716,2-1.6 | ||
138 | 16 | C13.5,2.321,12.34,0.972,11.866,0.508z"/> | ||
139 | 17 | <path fill="#DC4A26" d="M5.501,3.499L7.047,0.5L8.5,3.499H5.501z"/> | ||
140 | 18 | <path fill="#DC4A26" d="M13.5,5.503v6.998c0,0.55-0.45,0.999-1,0.999h-2c-0.55,0-1-0.449-1-0.999V5.503H13.5z"/> | ||
141 | 19 | </svg> | ||
142 | 0 | 20 | ||
143 | === added file 'plugins/unityshell/resources/emblem_books.svg' | |||
144 | --- plugins/unityshell/resources/emblem_books.svg 1970-01-01 00:00:00 +0000 | |||
145 | +++ plugins/unityshell/resources/emblem_books.svg 2012-09-13 10:12:22 +0000 | |||
146 | @@ -0,0 +1,9 @@ | |||
147 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
148 | 2 | <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
149 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
150 | 4 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
151 | 5 | width="14px" height="14px" viewBox="0 0 14 14" enable-background="new 0 0 14 14" xml:space="preserve"> | ||
152 | 6 | <path fill="#DC4A26" d="M7,1.879C6.961,1.473,6.427,0.227,1,1.5c0,3.222,0,7.449,0,11C7.009,10.945,7,13,7,13s-0.009-2.055,6-0.5 | ||
153 | 7 | c0-3.551,0-7.778,0-11C7.574,0.227,7.039,1.473,7,1.879z M5,9H2V8h3V9z M5,7H2V6h3V7z M5,5H2V4h3V5z M7.5,12h-1V2h1V12z M12,9H9V8h3 | ||
154 | 8 | V9z M12,7H9V6h3V7z M12,5H9V4h3V5z"/> | ||
155 | 9 | </svg> | ||
156 | 0 | 10 | ||
157 | === added file 'plugins/unityshell/resources/emblem_clothes.svg' | |||
158 | --- plugins/unityshell/resources/emblem_clothes.svg 1970-01-01 00:00:00 +0000 | |||
159 | +++ plugins/unityshell/resources/emblem_clothes.svg 2012-09-13 10:12:22 +0000 | |||
160 | @@ -0,0 +1,8 @@ | |||
161 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
162 | 2 | <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
163 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
164 | 4 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
165 | 5 | width="14px" height="14px" viewBox="0 0 14 14" enable-background="new 0 0 14 14" xml:space="preserve"> | ||
166 | 6 | <path fill="#DC4A26" d="M10.997,13V5.013l1.505,0.772L14,2.942L10.974,1L8.988,1.002c0,1.121-0.916,2.029-2.046,2.029 | ||
167 | 7 | S5.012,2.123,5.012,1.002L2.969,1L0,2.942l1.498,2.843l1.447-0.772V13H10.997z"/> | ||
168 | 8 | </svg> | ||
169 | 0 | 9 | ||
170 | === added file 'plugins/unityshell/resources/emblem_music.svg' | |||
171 | --- plugins/unityshell/resources/emblem_music.svg 1970-01-01 00:00:00 +0000 | |||
172 | +++ plugins/unityshell/resources/emblem_music.svg 2012-09-13 10:12:22 +0000 | |||
173 | @@ -0,0 +1,15 @@ | |||
174 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
175 | 2 | <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
176 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
177 | 4 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
178 | 5 | width="14px" height="14px" viewBox="0 0 14 14" enable-background="new 0 0 14 14" xml:space="preserve"> | ||
179 | 6 | <g> | ||
180 | 7 | <g> | ||
181 | 8 | <path fill="#DC4A26" d="M13,0.598c0-0.386-0.307-0.651-0.683-0.588L5.672,1.186C5.296,1.249,5,1.617,5,2.005v7.249 | ||
182 | 9 | C4.228,8.862,3.14,8.925,2.157,9.52c-1.393,0.841-2.033,2.413-1.43,3.506c0.603,1.094,2.223,1.299,3.615,0.455 | ||
183 | 10 | c1.078-0.65,1.697-1.735,1.648-2.699L6,10.789V3.624c0-0.386,0.277-0.756,0.653-0.818l4.684-0.823C11.712,1.919,12,2.184,12,2.57 | ||
184 | 11 | v4.684c-0.771-0.393-1.86-0.329-2.843,0.265C7.764,8.36,7.123,9.931,7.727,11.024c0.603,1.094,2.222,1.3,3.615,0.456 | ||
185 | 12 | c1.069-0.646,1.689-1.721,1.649-2.68L13,8.808V0.598z"/> | ||
186 | 13 | </g> | ||
187 | 14 | </g> | ||
188 | 15 | </svg> | ||
189 | 0 | 16 | ||
190 | === added file 'plugins/unityshell/resources/emblem_video.svg' | |||
191 | --- plugins/unityshell/resources/emblem_video.svg 1970-01-01 00:00:00 +0000 | |||
192 | +++ plugins/unityshell/resources/emblem_video.svg 2012-09-13 10:12:22 +0000 | |||
193 | @@ -0,0 +1,17 @@ | |||
194 | 1 | <?xml version="1.0" encoding="utf-8"?> | ||
195 | 2 | <!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> | ||
196 | 3 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | ||
197 | 4 | <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" | ||
198 | 5 | width="14px" height="14px" viewBox="0 0 14 14" enable-background="new 0 0 14 14" xml:space="preserve"> | ||
199 | 6 | <g> | ||
200 | 7 | <g> | ||
201 | 8 | <path fill="#DC4A26" d="M12.301,2.5H1.7C1.315,2.5,1,2.813,1,3.196v7.608C1,11.188,1.315,11.5,1.7,11.5h10.601 | ||
202 | 9 | c0.385,0,0.699-0.312,0.699-0.696V3.196C13,2.813,12.686,2.5,12.301,2.5z M2.989,10.455H1.994V9.498h0.996V10.455z M2.989,8.49 | ||
203 | 10 | H1.994V7.5h0.996V8.49z M2.989,6.494H1.994V5.535h0.996V6.494z M2.989,4.496H1.994V3.538h0.996V4.496z M8.006,7.841 | ||
204 | 11 | C7.659,8.126,7.308,8.404,6.954,8.677C6.6,8.947,6.255,9.197,5.92,9.426c-0.335,0.229-0.64,0.422-0.913,0.579V4.026 | ||
205 | 12 | c0.261,0.158,0.559,0.35,0.894,0.578c0.335,0.229,0.68,0.476,1.034,0.74c0.354,0.265,0.708,0.54,1.061,0.825 | ||
206 | 13 | c0.355,0.286,0.687,0.565,0.998,0.836C8.684,7.276,8.354,7.555,8.006,7.841z M11.992,10.455h-0.996V9.498h0.996V10.455z | ||
207 | 14 | M11.992,8.49h-0.996V7.5h0.996V8.49z M11.992,6.494h-0.996V5.535h0.996V6.494z M11.992,4.496h-0.996V3.538h0.996V4.496z"/> | ||
208 | 15 | </g> | ||
209 | 16 | </g> | ||
210 | 17 | </svg> | ||
211 | 0 | 18 | ||
212 | === modified file 'tests/test_icon_loader.cpp' | |||
213 | --- tests/test_icon_loader.cpp 2012-08-20 18:41:49 +0000 | |||
214 | +++ tests/test_icon_loader.cpp 2012-09-13 10:12:22 +0000 | |||
215 | @@ -47,7 +47,7 @@ | |||
216 | 47 | bool got_callback; | 47 | bool got_callback; |
217 | 48 | 48 | ||
218 | 49 | LoadResult() : pixbuf(NULL), got_callback(false) {} | 49 | LoadResult() : pixbuf(NULL), got_callback(false) {} |
220 | 50 | void IconLoaded(std::string const& icon_name, unsigned size, | 50 | void IconLoaded(std::string const& icon_name, int max_width, int max_height, |
221 | 51 | glib::Object<GdkPixbuf> const& buf) | 51 | glib::Object<GdkPixbuf> const& buf) |
222 | 52 | { | 52 | { |
223 | 53 | pixbuf = buf; | 53 | pixbuf = buf; |
224 | @@ -71,7 +71,7 @@ | |||
225 | 71 | IconLoader& icon_loader = IconLoader::GetDefault(); | 71 | IconLoader& icon_loader = IconLoader::GetDefault(); |
226 | 72 | volatile bool timeout_reached = false; | 72 | volatile bool timeout_reached = false; |
227 | 73 | 73 | ||
229 | 74 | icon_loader.LoadFromIconName("gedit-icon", 48, sigc::mem_fun(load_result, | 74 | icon_loader.LoadFromIconName("gedit-icon", -1, 48, sigc::mem_fun(load_result, |
230 | 75 | &LoadResult::IconLoaded)); | 75 | &LoadResult::IconLoaded)); |
231 | 76 | 76 | ||
232 | 77 | guint tid = g_timeout_add (10000, TimeoutReached, (gpointer)(&timeout_reached)); | 77 | guint tid = g_timeout_add (10000, TimeoutReached, (gpointer)(&timeout_reached)); |
233 | @@ -93,7 +93,7 @@ | |||
234 | 93 | volatile bool timeout_reached = false; | 93 | volatile bool timeout_reached = false; |
235 | 94 | 94 | ||
236 | 95 | 95 | ||
238 | 96 | icon_loader.LoadFromGIconString(". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'gedit-icon'%3E,%20'ribbon':%20%3C'foo'%3E%7D", 48, sigc::mem_fun(load_result, | 96 | icon_loader.LoadFromGIconString(". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'gedit-icon'%3E,%20'ribbon':%20%3C'foo'%3E%7D", -1, 48, sigc::mem_fun(load_result, |
239 | 97 | &LoadResult::IconLoaded)); | 97 | &LoadResult::IconLoaded)); |
240 | 98 | 98 | ||
241 | 99 | guint tid = g_timeout_add (10000, TimeoutReached, (gpointer)(&timeout_reached)); | 99 | guint tid = g_timeout_add (10000, TimeoutReached, (gpointer)(&timeout_reached)); |
242 | @@ -125,7 +125,7 @@ | |||
243 | 125 | // be cached already! | 125 | // be cached already! |
244 | 126 | for (int i = 0; i < load_count; i++) | 126 | for (int i = 0; i < load_count; i++) |
245 | 127 | { | 127 | { |
247 | 128 | handles[i] = icon_loader.LoadFromIconName("web-browser", 48, | 128 | handles[i] = icon_loader.LoadFromIconName("web-browser", -1, 48, |
248 | 129 | sigc::mem_fun(results[i], &LoadResult::IconLoaded)); | 129 | sigc::mem_fun(results[i], &LoadResult::IconLoaded)); |
249 | 130 | } | 130 | } |
250 | 131 | 131 | ||
251 | @@ -190,7 +190,7 @@ | |||
252 | 190 | for (GList *it = icons; it != NULL; it = it->next) | 190 | for (GList *it = icons; it != NULL; it = it->next) |
253 | 191 | { | 191 | { |
254 | 192 | const char *icon_name = static_cast<char*>(it->data); | 192 | const char *icon_name = static_cast<char*>(it->data); |
256 | 193 | icon_loader.LoadFromIconName(icon_name, 48, sigc::mem_fun(results[i++], | 193 | icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun(results[i++], |
257 | 194 | &LoadResult::IconLoaded)); | 194 | &LoadResult::IconLoaded)); |
258 | 195 | if (i >= icon_count) break; | 195 | if (i >= icon_count) break; |
259 | 196 | } | 196 | } |
260 | @@ -235,7 +235,7 @@ | |||
261 | 235 | for (GList *it = icons; it != NULL; it = it->next) | 235 | for (GList *it = icons; it != NULL; it = it->next) |
262 | 236 | { | 236 | { |
263 | 237 | const char *icon_name = static_cast<char*>(it->data); | 237 | const char *icon_name = static_cast<char*>(it->data); |
265 | 238 | int handle = icon_loader.LoadFromIconName(icon_name, 48, sigc::mem_fun( | 238 | int handle = icon_loader.LoadFromIconName(icon_name, -1, 48, sigc::mem_fun( |
266 | 239 | results[i], &LoadResult::IconLoaded)); | 239 | results[i], &LoadResult::IconLoaded)); |
267 | 240 | handles[i++] = handle; | 240 | handles[i++] = handle; |
268 | 241 | if (i >= icon_count) break; | 241 | if (i >= icon_count) break; |
269 | 242 | 242 | ||
270 | === modified file 'unity-shared/CoverArt.cpp' | |||
271 | --- unity-shared/CoverArt.cpp 2012-09-03 22:45:44 +0000 | |||
272 | +++ unity-shared/CoverArt.cpp 2012-09-13 10:12:22 +0000 | |||
273 | @@ -41,7 +41,7 @@ | |||
274 | 41 | { | 41 | { |
275 | 42 | nux::logging::Logger logger("unity.dash.previews.coverart"); | 42 | nux::logging::Logger logger("unity.dash.previews.coverart"); |
276 | 43 | 43 | ||
278 | 44 | const int icon_width = 256; | 44 | const int ICON_SIZE = 256; |
279 | 45 | } | 45 | } |
280 | 46 | 46 | ||
281 | 47 | NUX_IMPLEMENT_OBJECT_TYPE(CoverArt); | 47 | NUX_IMPLEMENT_OBJECT_TYPE(CoverArt); |
282 | @@ -109,9 +109,9 @@ | |||
283 | 109 | 109 | ||
284 | 110 | // texture from file. | 110 | // texture from file. |
285 | 111 | if (bLoadTexture) | 111 | if (bLoadTexture) |
287 | 112 | { | 112 | { |
288 | 113 | StartWaiting(); | 113 | StartWaiting(); |
290 | 114 | slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ~0, sigc::mem_fun(this, &CoverArt::TextureLoaded)); | 114 | slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, -1, -1, sigc::mem_fun(this, &CoverArt::TextureLoaded)); |
291 | 115 | } | 115 | } |
292 | 116 | else if (!image_hint.empty()) | 116 | else if (!image_hint.empty()) |
293 | 117 | { | 117 | { |
294 | @@ -121,12 +121,12 @@ | |||
295 | 121 | if (G_IS_ICON(icon)) | 121 | if (G_IS_ICON(icon)) |
296 | 122 | { | 122 | { |
297 | 123 | StartWaiting(); | 123 | StartWaiting(); |
299 | 124 | slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, icon_width, sigc::mem_fun(this, &CoverArt::IconLoaded)); | 124 | slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded)); |
300 | 125 | } | 125 | } |
301 | 126 | else | 126 | else |
302 | 127 | { | 127 | { |
303 | 128 | StartWaiting(); | 128 | StartWaiting(); |
305 | 129 | slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, icon_width, sigc::mem_fun(this, &CoverArt::IconLoaded)); | 129 | slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded)); |
306 | 130 | } | 130 | } |
307 | 131 | } | 131 | } |
308 | 132 | else | 132 | else |
309 | @@ -195,7 +195,10 @@ | |||
310 | 195 | } | 195 | } |
311 | 196 | } | 196 | } |
312 | 197 | 197 | ||
314 | 198 | void CoverArt::IconLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf) | 198 | void CoverArt::IconLoaded(std::string const& texid, |
315 | 199 | int max_width, | ||
316 | 200 | int max_height, | ||
317 | 201 | glib::Object<GdkPixbuf> const& pixbuf) | ||
318 | 199 | { | 202 | { |
319 | 200 | // Finished waiting | 203 | // Finished waiting |
320 | 201 | StopWaiting(); | 204 | StopWaiting(); |
321 | @@ -207,7 +210,7 @@ | |||
322 | 207 | return; | 210 | return; |
323 | 208 | } | 211 | } |
324 | 209 | 212 | ||
326 | 210 | int height = size; | 213 | int height = max_height; |
327 | 211 | 214 | ||
328 | 212 | int pixbuf_width, pixbuf_height; | 215 | int pixbuf_width, pixbuf_height; |
329 | 213 | pixbuf_width = gdk_pixbuf_get_width(pixbuf); | 216 | pixbuf_width = gdk_pixbuf_get_width(pixbuf); |
330 | @@ -232,7 +235,7 @@ | |||
331 | 232 | float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 | 235 | float aspect = static_cast<float>(pixbuf_height) / pixbuf_width; // already sanitized width/height so can not be 0.0 |
332 | 233 | if (aspect < 1.0f) | 236 | if (aspect < 1.0f) |
333 | 234 | { | 237 | { |
335 | 235 | pixbuf_width = icon_width; | 238 | pixbuf_width = ICON_SIZE; |
336 | 236 | pixbuf_height = pixbuf_width * aspect; | 239 | pixbuf_height = pixbuf_width * aspect; |
337 | 237 | 240 | ||
338 | 238 | if (pixbuf_height > height) | 241 | if (pixbuf_height > height) |
339 | @@ -274,7 +277,10 @@ | |||
340 | 274 | } | 277 | } |
341 | 275 | } | 278 | } |
342 | 276 | 279 | ||
344 | 277 | void CoverArt::TextureLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf) | 280 | void CoverArt::TextureLoaded(std::string const& texid, |
345 | 281 | int max_width, | ||
346 | 282 | int max_height, | ||
347 | 283 | glib::Object<GdkPixbuf> const& pixbuf) | ||
348 | 278 | { | 284 | { |
349 | 279 | // Finished waiting | 285 | // Finished waiting |
350 | 280 | StopWaiting(); | 286 | StopWaiting(); |
351 | @@ -489,4 +495,4 @@ | |||
352 | 489 | 495 | ||
353 | 490 | } | 496 | } |
354 | 491 | } | 497 | } |
355 | 492 | } | ||
356 | 493 | \ No newline at end of file | 498 | \ No newline at end of file |
357 | 499 | } | ||
358 | 494 | 500 | ||
359 | === modified file 'unity-shared/CoverArt.h' | |||
360 | --- unity-shared/CoverArt.h 2012-08-28 10:15:19 +0000 | |||
361 | +++ unity-shared/CoverArt.h 2012-09-13 10:12:22 +0000 | |||
362 | @@ -70,8 +70,8 @@ | |||
363 | 70 | void OnThumbnailError(std::string const& error_hint); | 70 | void OnThumbnailError(std::string const& error_hint); |
364 | 71 | bool OnFrameTimeout(); | 71 | bool OnFrameTimeout(); |
365 | 72 | 72 | ||
368 | 73 | void IconLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf); | 73 | void IconLoaded(std::string const& texid, int max_width, int max_height, glib::Object<GdkPixbuf> const& pixbuf); |
369 | 74 | void TextureLoaded(std::string const& texid, unsigned size, glib::Object<GdkPixbuf> const& pixbuf); | 74 | void TextureLoaded(std::string const& texid, int max_width, int max_height, glib::Object<GdkPixbuf> const& pixbuf); |
370 | 75 | 75 | ||
371 | 76 | void StartWaiting(); | 76 | void StartWaiting(); |
372 | 77 | void StopWaiting(); | 77 | void StopWaiting(); |
373 | @@ -105,4 +105,4 @@ | |||
374 | 105 | } | 105 | } |
375 | 106 | } | 106 | } |
376 | 107 | 107 | ||
377 | 108 | #endif // APPLICATIONSCREENSHOT_H | ||
378 | 109 | \ No newline at end of file | 108 | \ No newline at end of file |
379 | 109 | #endif // APPLICATIONSCREENSHOT_H | ||
380 | 110 | 110 | ||
381 | === modified file 'unity-shared/IconLoader.cpp' | |||
382 | --- unity-shared/IconLoader.cpp 2012-08-20 18:41:49 +0000 | |||
383 | +++ unity-shared/IconLoader.cpp 2012-09-13 10:12:22 +0000 | |||
384 | @@ -18,6 +18,7 @@ | |||
385 | 18 | */ | 18 | */ |
386 | 19 | 19 | ||
387 | 20 | #include "IconLoader.h" | 20 | #include "IconLoader.h" |
388 | 21 | #include "config.h" | ||
389 | 21 | 22 | ||
390 | 22 | #include <queue> | 23 | #include <queue> |
391 | 23 | #include <sstream> | 24 | #include <sstream> |
392 | @@ -39,7 +40,8 @@ | |||
393 | 39 | namespace | 40 | namespace |
394 | 40 | { | 41 | { |
395 | 41 | nux::logging::Logger logger("unity.iconloader"); | 42 | nux::logging::Logger logger("unity.iconloader"); |
397 | 42 | const unsigned MIN_ICON_SIZE = 2; | 43 | const int MIN_ICON_SIZE = 2; |
398 | 44 | const int RIBBON_PADDING = 2; | ||
399 | 43 | } | 45 | } |
400 | 44 | 46 | ||
401 | 45 | class IconLoader::Impl | 47 | class IconLoader::Impl |
402 | @@ -48,25 +50,29 @@ | |||
403 | 48 | // The Handle typedef is used to explicitly indicate which integers are | 50 | // The Handle typedef is used to explicitly indicate which integers are |
404 | 49 | // infact our opaque handles. | 51 | // infact our opaque handles. |
405 | 50 | typedef int Handle; | 52 | typedef int Handle; |
408 | 51 | static const int FONT_SIZE = 10; | 53 | static const int FONT_SIZE = 8; |
409 | 52 | static const int MIN_FONT_SIZE = 6; | 54 | static const int MIN_FONT_SIZE = 5; |
410 | 53 | 55 | ||
411 | 54 | Impl(); | 56 | Impl(); |
412 | 55 | 57 | ||
413 | 56 | Handle LoadFromIconName(std::string const& icon_name, | 58 | Handle LoadFromIconName(std::string const& icon_name, |
415 | 57 | unsigned size, | 59 | int max_width, |
416 | 60 | int max_height, | ||
417 | 58 | IconLoaderCallback slot); | 61 | IconLoaderCallback slot); |
418 | 59 | 62 | ||
419 | 60 | Handle LoadFromGIconString(std::string const& gicon_string, | 63 | Handle LoadFromGIconString(std::string const& gicon_string, |
421 | 61 | unsigned size, | 64 | int max_width, |
422 | 65 | int max_height, | ||
423 | 62 | IconLoaderCallback slot); | 66 | IconLoaderCallback slot); |
424 | 63 | 67 | ||
425 | 64 | Handle LoadFromFilename(std::string const& filename, | 68 | Handle LoadFromFilename(std::string const& filename, |
427 | 65 | unsigned size, | 69 | int max_width, |
428 | 70 | int max_height, | ||
429 | 66 | IconLoaderCallback slot); | 71 | IconLoaderCallback slot); |
430 | 67 | 72 | ||
431 | 68 | Handle LoadFromURI(std::string const& uri, | 73 | Handle LoadFromURI(std::string const& uri, |
433 | 69 | unsigned size, | 74 | int max_width, |
434 | 75 | int max_height, | ||
435 | 70 | IconLoaderCallback slot); | 76 | IconLoaderCallback slot); |
436 | 71 | 77 | ||
437 | 72 | void DisconnectHandle(Handle handle); | 78 | void DisconnectHandle(Handle handle); |
438 | @@ -88,7 +94,8 @@ | |||
439 | 88 | 94 | ||
440 | 89 | IconLoaderRequestType type; | 95 | IconLoaderRequestType type; |
441 | 90 | std::string data; | 96 | std::string data; |
443 | 91 | unsigned int size; | 97 | int max_width; |
444 | 98 | int max_height; | ||
445 | 92 | std::string key; | 99 | std::string key; |
446 | 93 | IconLoaderCallback slot; | 100 | IconLoaderCallback slot; |
447 | 94 | Handle handle; | 101 | Handle handle; |
448 | @@ -103,12 +110,14 @@ | |||
449 | 103 | 110 | ||
450 | 104 | IconLoaderTask(IconLoaderRequestType type_, | 111 | IconLoaderTask(IconLoaderRequestType type_, |
451 | 105 | std::string const& data_, | 112 | std::string const& data_, |
453 | 106 | unsigned size_, | 113 | int max_width_, |
454 | 114 | int max_height_, | ||
455 | 107 | std::string const& key_, | 115 | std::string const& key_, |
456 | 108 | IconLoaderCallback slot_, | 116 | IconLoaderCallback slot_, |
457 | 109 | Handle handle_, | 117 | Handle handle_, |
458 | 110 | Impl* self_) | 118 | Impl* self_) |
460 | 111 | : type(type_), data(data_), size(size_), key(key_) | 119 | : type(type_), data(data_), max_width(max_width_) |
461 | 120 | , max_height(max_height_), key(key_) | ||
462 | 112 | , slot(slot_), handle(handle_), impl(self_) | 121 | , slot(slot_), handle(handle_), impl(self_) |
463 | 113 | , icon_info(nullptr), no_cache(false), helper_handle(0), idle_id(0) | 122 | , icon_info(nullptr), no_cache(false), helper_handle(0), idle_id(0) |
464 | 114 | {} | 123 | {} |
465 | @@ -126,13 +135,16 @@ | |||
466 | 126 | void InvokeSlot() | 135 | void InvokeSlot() |
467 | 127 | { | 136 | { |
468 | 128 | if (slot) | 137 | if (slot) |
470 | 129 | slot(data, size, result); | 138 | slot(data, max_width, max_height, result); |
471 | 130 | 139 | ||
472 | 131 | // notify shadow tasks | 140 | // notify shadow tasks |
473 | 132 | for (auto shadow_task : shadow_tasks) | 141 | for (auto shadow_task : shadow_tasks) |
474 | 133 | { | 142 | { |
475 | 134 | if (shadow_task->slot) | 143 | if (shadow_task->slot) |
477 | 135 | shadow_task->slot(shadow_task->data, shadow_task->size, result); | 144 | shadow_task->slot(shadow_task->data, |
478 | 145 | shadow_task->max_width, | ||
479 | 146 | shadow_task->max_height, | ||
480 | 147 | result); | ||
481 | 136 | 148 | ||
482 | 137 | impl->task_map_.erase(shadow_task->handle); | 149 | impl->task_map_.erase(shadow_task->handle); |
483 | 138 | } | 150 | } |
484 | @@ -143,10 +155,10 @@ | |||
485 | 143 | bool Process() | 155 | bool Process() |
486 | 144 | { | 156 | { |
487 | 145 | // Check the cache again, as previous tasks might have wanted the same | 157 | // Check the cache again, as previous tasks might have wanted the same |
489 | 146 | if (impl->CacheLookup(key, data, size, slot)) | 158 | if (impl->CacheLookup(key, data, max_width, max_height, slot)) |
490 | 147 | return true; | 159 | return true; |
491 | 148 | 160 | ||
493 | 149 | LOG_DEBUG(logger) << "Processing " << data << " at size " << size; | 161 | LOG_DEBUG(logger) << "Processing " << data << " at size " << max_height; |
494 | 150 | 162 | ||
495 | 151 | // Rely on the compiler to tell us if we miss a new type | 163 | // Rely on the compiler to tell us if we miss a new type |
496 | 152 | switch (type) | 164 | switch (type) |
497 | @@ -161,7 +173,7 @@ | |||
498 | 161 | 173 | ||
499 | 162 | LOG_WARNING(logger) << "Request type " << type | 174 | LOG_WARNING(logger) << "Request type " << type |
500 | 163 | << " is not supported (" << data | 175 | << " is not supported (" << data |
502 | 164 | << " " << size << ")"; | 176 | << " " << max_width << "x" << max_height << ")"; |
503 | 165 | result = nullptr; | 177 | result = nullptr; |
504 | 166 | InvokeSlot(); | 178 | InvokeSlot(); |
505 | 167 | 179 | ||
506 | @@ -170,6 +182,7 @@ | |||
507 | 170 | 182 | ||
508 | 171 | bool ProcessIconNameTask() | 183 | bool ProcessIconNameTask() |
509 | 172 | { | 184 | { |
510 | 185 | int size = max_height < 0 ? max_width : (max_width < 0 ? max_height : MIN(max_height, max_width)); | ||
511 | 173 | GtkIconInfo* info = ::gtk_icon_theme_lookup_icon(impl->theme_, data.c_str(), | 186 | GtkIconInfo* info = ::gtk_icon_theme_lookup_icon(impl->theme_, data.c_str(), |
512 | 174 | size, static_cast<GtkIconLookupFlags>(0)); | 187 | size, static_cast<GtkIconLookupFlags>(0)); |
513 | 175 | if (info) | 188 | if (info) |
514 | @@ -195,6 +208,7 @@ | |||
515 | 195 | { | 208 | { |
516 | 196 | glib::Error error; | 209 | glib::Error error; |
517 | 197 | glib::Object<GIcon> icon(::g_icon_new_for_string(data.c_str(), &error)); | 210 | glib::Object<GIcon> icon(::g_icon_new_for_string(data.c_str(), &error)); |
518 | 211 | int size = max_height < 0 ? max_width : (max_width < 0 ? max_height : MIN(max_height, max_width)); | ||
519 | 198 | 212 | ||
520 | 199 | if (icon.IsType(UNITY_PROTOCOL_TYPE_ANNOTATED_ICON)) | 213 | if (icon.IsType(UNITY_PROTOCOL_TYPE_ANNOTATED_ICON)) |
521 | 200 | { | 214 | { |
522 | @@ -205,8 +219,12 @@ | |||
523 | 205 | 219 | ||
524 | 206 | no_cache = true; | 220 | no_cache = true; |
525 | 207 | auto helper_slot = sigc::bind(sigc::mem_fun(this, &IconLoaderTask::BaseIconLoaded), glib::object_cast<UnityProtocolAnnotatedIcon>(icon)); | 221 | auto helper_slot = sigc::bind(sigc::mem_fun(this, &IconLoaderTask::BaseIconLoaded), glib::object_cast<UnityProtocolAnnotatedIcon>(icon)); |
526 | 222 | int base_icon_width = max_width > 0 ? max_width - RIBBON_PADDING * 2 : -1; | ||
527 | 223 | int base_icon_height = base_icon_width < 0 ? max_height - RIBBON_PADDING *2 : max_height; | ||
528 | 208 | helper_handle = impl->LoadFromGIconString(gicon_string.Str(), | 224 | helper_handle = impl->LoadFromGIconString(gicon_string.Str(), |
530 | 209 | size, helper_slot); | 225 | base_icon_width, |
531 | 226 | base_icon_height, | ||
532 | 227 | helper_slot); | ||
533 | 210 | 228 | ||
534 | 211 | return false; | 229 | return false; |
535 | 212 | } | 230 | } |
536 | @@ -271,40 +289,32 @@ | |||
537 | 271 | return false; | 289 | return false; |
538 | 272 | } | 290 | } |
539 | 273 | 291 | ||
541 | 274 | void CategoryIconLoaded(std::string const& base_icon_string, unsigned size, | 292 | void CategoryIconLoaded(std::string const& base_icon_string, |
542 | 293 | int max_width, int max_height, | ||
543 | 275 | glib::Object<GdkPixbuf> const& category_pixbuf, | 294 | glib::Object<GdkPixbuf> const& category_pixbuf, |
544 | 276 | glib::Object<UnityProtocolAnnotatedIcon> const& anno_icon) | 295 | glib::Object<UnityProtocolAnnotatedIcon> const& anno_icon) |
545 | 277 | { | 296 | { |
546 | 278 | helper_handle = 0; | 297 | helper_handle = 0; |
559 | 279 | if (category_pixbuf) | 298 | bool has_emblem = category_pixbuf; |
548 | 280 | { | ||
549 | 281 | // assuming the category pixbuf is smaller than result | ||
550 | 282 | gdk_pixbuf_composite(category_pixbuf, result, // src, dest | ||
551 | 283 | 0, 0, // dest_x, dest_y | ||
552 | 284 | gdk_pixbuf_get_width(category_pixbuf), // dest_w | ||
553 | 285 | gdk_pixbuf_get_height(category_pixbuf), // dest_h | ||
554 | 286 | 0.0, 0.0, // offset_x, offset_y | ||
555 | 287 | 1.0, 1.0, // scale_x, scale_y | ||
556 | 288 | GDK_INTERP_NEAREST, // interpolation | ||
557 | 289 | 255); // src_alpha | ||
558 | 290 | } | ||
560 | 291 | 299 | ||
561 | 292 | const gchar* detail_text = unity_protocol_annotated_icon_get_ribbon(anno_icon); | 300 | const gchar* detail_text = unity_protocol_annotated_icon_get_ribbon(anno_icon); |
562 | 293 | if (detail_text) | 301 | if (detail_text) |
563 | 294 | { | 302 | { |
564 | 303 | const int SHADOW_BOTTOM_PADDING = 2; | ||
565 | 304 | const int SHADOW_SIDE_PADDING = 1; | ||
566 | 295 | int icon_w = gdk_pixbuf_get_width(result); | 305 | int icon_w = gdk_pixbuf_get_width(result); |
567 | 296 | int icon_h = gdk_pixbuf_get_height(result); | 306 | int icon_h = gdk_pixbuf_get_height(result); |
568 | 297 | 307 | ||
569 | 298 | int max_font_height; | 308 | int max_font_height; |
570 | 299 | CalculateTextHeight(nullptr, &max_font_height); | 309 | CalculateTextHeight(nullptr, &max_font_height); |
571 | 300 | 310 | ||
576 | 301 | max_font_height = max_font_height * 9 / 8; // let's have some padding on the stripe | 311 | // FIXME: design wants the tags 2px wider than the original icon |
577 | 302 | int pixbuf_size = static_cast<int>( | 312 | int pixbuf_width = icon_w; |
578 | 303 | sqrt(max_font_height*max_font_height*8)); | 313 | int pixbuf_height = max_font_height * 5 / 4 + SHADOW_BOTTOM_PADDING; |
579 | 304 | if (pixbuf_size > icon_w) pixbuf_size = icon_w; | 314 | if (pixbuf_height > icon_h) pixbuf_height = icon_h; |
580 | 305 | 315 | ||
581 | 306 | nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, | 316 | nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, |
583 | 307 | pixbuf_size, pixbuf_size); | 317 | pixbuf_width, pixbuf_height); |
584 | 308 | std::shared_ptr<cairo_t> cr(cairo_graphics.GetContext(), cairo_destroy); | 318 | std::shared_ptr<cairo_t> cr(cairo_graphics.GetContext(), cairo_destroy); |
585 | 309 | 319 | ||
586 | 310 | glib::Object<PangoLayout> layout; | 320 | glib::Object<PangoLayout> layout; |
587 | @@ -325,10 +335,9 @@ | |||
588 | 325 | pango_layout_set_font_description(layout, desc.get()); | 335 | pango_layout_set_font_description(layout, desc.get()); |
589 | 326 | pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); | 336 | pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); |
590 | 327 | 337 | ||
595 | 328 | double size_dbl = static_cast<double>(pixbuf_size); | 338 | // magic constant for the text width based on the white curve |
596 | 329 | // we'll allow tiny bit of overflow since the text is rotated and there | 339 | double max_text_width = has_emblem ? |
597 | 330 | // is some space left... FIXME: 10/9? / 11/10? | 340 | pixbuf_width * 0.72 : pixbuf_width; |
594 | 331 | double max_text_width = sqrt(size_dbl*size_dbl / 2) * 9/8; | ||
598 | 332 | 341 | ||
599 | 333 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); | 342 | pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR); |
600 | 334 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); | 343 | pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END); |
601 | @@ -337,9 +346,8 @@ | |||
602 | 337 | pango_layout_set_markup(layout, escaped_text, -1); | 346 | pango_layout_set_markup(layout, escaped_text, -1); |
603 | 338 | 347 | ||
604 | 339 | pango_context = pango_layout_get_context(layout); // is not ref'ed | 348 | pango_context = pango_layout_get_context(layout); // is not ref'ed |
608 | 340 | // FIXME: for reasons unknown, it looks better without this | 349 | pango_cairo_context_set_font_options(pango_context, |
609 | 341 | //pango_cairo_context_set_font_options(pango_context, | 350 | gdk_screen_get_font_options(screen)); |
607 | 342 | // gdk_screen_get_font_options(screen)); | ||
610 | 343 | pango_cairo_context_set_resolution(pango_context, | 351 | pango_cairo_context_set_resolution(pango_context, |
611 | 344 | dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE); | 352 | dpi == -1 ? 96.0f : dpi/(float) PANGO_SCALE); |
612 | 345 | pango_layout_context_changed(layout); | 353 | pango_layout_context_changed(layout); |
613 | @@ -361,32 +369,117 @@ | |||
614 | 361 | 369 | ||
615 | 362 | cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER); | 370 | cairo_set_operator(cr.get(), CAIRO_OPERATOR_OVER); |
616 | 363 | 371 | ||
617 | 364 | // draw the trapezoid | ||
618 | 365 | cairo_move_to(cr.get(), 0.0, size_dbl); | ||
619 | 366 | cairo_line_to(cr.get(), size_dbl, 0.0); | ||
620 | 367 | cairo_line_to(cr.get(), size_dbl, size_dbl / 2.0); | ||
621 | 368 | cairo_line_to(cr.get(), size_dbl / 2.0, size_dbl); | ||
622 | 369 | cairo_close_path(cr.get()); | ||
623 | 370 | |||
624 | 371 | // this should be #dd4814 | 372 | // this should be #dd4814 |
626 | 372 | cairo_set_source_rgba(cr.get(), 0.86666f, 0.28235f, 0.07843f, 1.0f); | 373 | const double ORANGE_R = 0.86666; |
627 | 374 | const double ORANGE_G = 0.28235; | ||
628 | 375 | const double ORANGE_B = 0.07843; | ||
629 | 376 | |||
630 | 377 | double belt_w = static_cast<double>(pixbuf_width - SHADOW_SIDE_PADDING * 2); | ||
631 | 378 | double belt_h = static_cast<double>(pixbuf_height - SHADOW_BOTTOM_PADDING); | ||
632 | 379 | |||
633 | 380 | // translate to make space for the shadow | ||
634 | 381 | cairo_save(cr.get()); | ||
635 | 382 | cairo_translate(cr.get(), 1.0, 1.0); | ||
636 | 383 | |||
637 | 384 | cairo_set_source_rgba(cr.get(), ORANGE_R, ORANGE_G, ORANGE_B, 1.0); | ||
638 | 385 | |||
639 | 386 | cairo_rectangle(cr.get(), 0.0, 0.0, belt_w, belt_h); | ||
640 | 387 | cairo_fill_preserve(cr.get()); | ||
641 | 388 | |||
642 | 389 | std::shared_ptr<cairo_pattern_t> pattern( | ||
643 | 390 | cairo_pattern_create_linear(0.0, 0.0, belt_w, 0.0), | ||
644 | 391 | cairo_pattern_destroy); | ||
645 | 392 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 1.0, 1.0, 1.0, 0.235294); | ||
646 | 393 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.02, 1.0, 1.0, 1.0, 0.0); | ||
647 | 394 | if (!has_emblem) | ||
648 | 395 | { | ||
649 | 396 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.98, 1.0, 1.0, 1.0, 0.0); | ||
650 | 397 | cairo_pattern_add_color_stop_rgba(pattern.get(), 1.0, 1.0, 1.0, 1.0, 0.235294); | ||
651 | 398 | } | ||
652 | 399 | cairo_pattern_add_color_stop_rgba(pattern.get(), 1.0, 1.0, 1.0, 1.0, 0.0); | ||
653 | 400 | |||
654 | 401 | cairo_set_source(cr.get(), pattern.get()); | ||
655 | 373 | cairo_fill(cr.get()); | 402 | cairo_fill(cr.get()); |
656 | 374 | 403 | ||
663 | 375 | // draw the text (rotated!) | 404 | if (has_emblem) |
664 | 376 | cairo_set_source_rgba(cr.get(), 1.0f, 1.0f, 1.0f, 1.0f); | 405 | { |
665 | 377 | cairo_move_to(cr.get(), size_dbl * 0.25, size_dbl); | 406 | // paint the curve |
666 | 378 | cairo_rotate(cr.get(), -G_PI_4); // rotate by -45 degrees | 407 | const double CURVE_START_XPOS = 0.631163; // 0.651163 |
667 | 379 | 408 | const double CURVE_CP1_XPOS = CURVE_START_XPOS + 0.068023; | |
668 | 380 | pango_cairo_update_layout(cr.get(), layout); | 409 | const double CURVE_CP2_XPOS = CURVE_START_XPOS + 0.07; |
669 | 410 | const double CURVE_CP3_XPOS = CURVE_START_XPOS + 0.102965; | ||
670 | 411 | const double CURVE_CP4_XPOS = CURVE_START_XPOS + 0.161511; | ||
671 | 412 | const double CURVE_CP5_XPOS = CURVE_START_XPOS + 0.197093; | ||
672 | 413 | const double CURVE_END_XPOS = CURVE_START_XPOS + 0.265779; | ||
673 | 414 | |||
674 | 415 | const double CURVE_START_X = CURVE_START_XPOS * belt_w; | ||
675 | 416 | |||
676 | 417 | cairo_set_source_rgba(cr.get(), 1.0, 1.0, 1.0, 1.0); | ||
677 | 418 | |||
678 | 419 | cairo_move_to(cr.get(), CURVE_START_XPOS * belt_w, belt_h); | ||
679 | 420 | cairo_curve_to(cr.get(), CURVE_CP1_XPOS * belt_w, belt_h, | ||
680 | 421 | CURVE_CP2_XPOS * belt_w, 0.9825 * belt_h, | ||
681 | 422 | CURVE_CP3_XPOS * belt_w, 0.72725 * belt_h); | ||
682 | 423 | cairo_line_to(cr.get(), CURVE_CP4_XPOS * belt_w, 0.27275 * belt_h); | ||
683 | 424 | cairo_curve_to(cr.get(), CURVE_CP5_XPOS * belt_w, 0.0, | ||
684 | 425 | CURVE_CP5_XPOS * belt_w, 0.0, | ||
685 | 426 | CURVE_END_XPOS * belt_w, 0.0); | ||
686 | 427 | cairo_line_to(cr.get(), belt_w, 0.0); | ||
687 | 428 | cairo_line_to(cr.get(), belt_w, belt_h); | ||
688 | 429 | cairo_close_path(cr.get()); | ||
689 | 430 | cairo_fill(cr.get()); | ||
690 | 431 | |||
691 | 432 | // and the highlight | ||
692 | 433 | pattern.reset(cairo_pattern_create_linear(CURVE_START_X, 0.0, belt_w, 0.0), | ||
693 | 434 | cairo_pattern_destroy); | ||
694 | 435 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 1.0, 1.0, 1.0, 0.0); | ||
695 | 436 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.95, 1.0, 1.0, 1.0, 0.0); | ||
696 | 437 | cairo_pattern_add_color_stop_rgba(pattern.get(), 1.0, 0.0, 0.0, 0.0, 0.235294); | ||
697 | 438 | cairo_set_source(cr.get(), pattern.get()); | ||
698 | 439 | cairo_rectangle(cr.get(), CURVE_START_X, 0.0, belt_w - CURVE_START_X, belt_h); | ||
699 | 440 | cairo_fill(cr.get()); | ||
700 | 441 | |||
701 | 442 | // paint the emblem | ||
702 | 443 | int category_pb_w = gdk_pixbuf_get_width(category_pixbuf); | ||
703 | 444 | int category_pb_h = gdk_pixbuf_get_height(category_pixbuf); | ||
704 | 445 | double category_pb_x = | ||
705 | 446 | belt_w - category_pb_w > CURVE_CP4_XPOS * belt_w ? | ||
706 | 447 | CURVE_CP4_XPOS * belt_w + ((1 - CURVE_CP4_XPOS) * belt_w - category_pb_w) / 2 : CURVE_CP4_XPOS * belt_w; | ||
707 | 448 | gdk_cairo_set_source_pixbuf(cr.get(), category_pixbuf, | ||
708 | 449 | category_pb_x, (belt_h - category_pb_h) / 2); | ||
709 | 450 | cairo_paint(cr.get()); | ||
710 | 451 | } | ||
711 | 452 | |||
712 | 453 | cairo_set_source_rgba(cr.get(), 1.0, 1.0, 1.0, 1.0); | ||
713 | 454 | cairo_move_to(cr.get(), 0.0, belt_h / 2); | ||
714 | 381 | pango_layout_get_pixel_size(layout, nullptr, &text_height); | 455 | pango_layout_get_pixel_size(layout, nullptr, &text_height); |
715 | 382 | // current point is now in the middle of the stripe, need to translate | 456 | // current point is now in the middle of the stripe, need to translate |
716 | 383 | // it, so that the text is centered | 457 | // it, so that the text is centered |
717 | 384 | cairo_rel_move_to(cr.get(), 0.0, text_height / -2.0); | 458 | cairo_rel_move_to(cr.get(), 0.0, text_height / -2.0); |
718 | 385 | double diagonal = sqrt(size_dbl*size_dbl*2); | ||
719 | 386 | // x coordinate also needs to be shifted | ||
720 | 387 | cairo_rel_move_to(cr.get(), (diagonal - max_text_width) / 4, 0.0); | ||
721 | 388 | pango_cairo_show_layout(cr.get(), layout); | 459 | pango_cairo_show_layout(cr.get(), layout); |
722 | 389 | 460 | ||
723 | 461 | // paint the shadow | ||
724 | 462 | cairo_restore(cr.get()); | ||
725 | 463 | |||
726 | 464 | pattern.reset(cairo_pattern_create_linear(0.0, belt_h, 0.0, belt_h + SHADOW_BOTTOM_PADDING), | ||
727 | 465 | cairo_pattern_destroy); | ||
728 | 466 | cairo_pattern_add_color_stop_rgba(pattern.get(), 0.0, 0.0, 0.0, 0.0, 0.2); | ||
729 | 467 | cairo_pattern_add_color_stop_rgba(pattern.get(), 1.0, 0.0, 0.0, 0.0, 0.0); | ||
730 | 468 | |||
731 | 469 | cairo_set_source(cr.get(), pattern.get()); | ||
732 | 470 | |||
733 | 471 | cairo_rectangle(cr.get(), 0.0, belt_h, belt_w, SHADOW_BOTTOM_PADDING); | ||
734 | 472 | cairo_fill(cr.get()); | ||
735 | 473 | |||
736 | 474 | cairo_set_source_rgba(cr.get(), 0.0, 0.0, 0.0, 0.1); | ||
737 | 475 | cairo_move_to(cr.get(), 0.0, 1.0); | ||
738 | 476 | cairo_line_to(cr.get(), 0.0, belt_h); | ||
739 | 477 | cairo_stroke(cr.get()); | ||
740 | 478 | |||
741 | 479 | cairo_move_to(cr.get(), belt_w, 1.0); | ||
742 | 480 | cairo_line_to(cr.get(), belt_w, belt_h); | ||
743 | 481 | cairo_stroke(cr.get()); | ||
744 | 482 | |||
745 | 390 | // FIXME: going from image_surface to pixbuf, and then to texture :( | 483 | // FIXME: going from image_surface to pixbuf, and then to texture :( |
746 | 391 | glib::Object<GdkPixbuf> detail_pb( | 484 | glib::Object<GdkPixbuf> detail_pb( |
747 | 392 | gdk_pixbuf_get_from_surface(cairo_graphics.GetSurface(), | 485 | gdk_pixbuf_get_from_surface(cairo_graphics.GetSurface(), |
748 | @@ -394,13 +487,14 @@ | |||
749 | 394 | cairo_graphics.GetWidth(), | 487 | cairo_graphics.GetWidth(), |
750 | 395 | cairo_graphics.GetHeight())); | 488 | cairo_graphics.GetHeight())); |
751 | 396 | 489 | ||
752 | 490 | int y_pos = icon_h - pixbuf_height - max_font_height / 2; | ||
753 | 397 | gdk_pixbuf_composite(detail_pb, result, // src, dest | 491 | gdk_pixbuf_composite(detail_pb, result, // src, dest |
760 | 398 | icon_w - pixbuf_size, // dest_x | 492 | 0, // dest_x |
761 | 399 | icon_h - pixbuf_size, // dest_y | 493 | y_pos, // dest_y |
762 | 400 | pixbuf_size, // dest_w | 494 | pixbuf_width, // dest_w |
763 | 401 | pixbuf_size, // dest_h | 495 | pixbuf_height, // dest_h |
764 | 402 | icon_w - pixbuf_size, // offset_x | 496 | 0, // offset_x |
765 | 403 | icon_h - pixbuf_size, // offset_y | 497 | y_pos, // offset_y |
766 | 404 | 1.0, 1.0, // scale_x, scale_y | 498 | 1.0, 1.0, // scale_x, scale_y |
767 | 405 | GDK_INTERP_NEAREST, // interpolation | 499 | GDK_INTERP_NEAREST, // interpolation |
768 | 406 | 255); // src_alpha | 500 | 255); // src_alpha |
769 | @@ -409,29 +503,76 @@ | |||
770 | 409 | idle_id = g_idle_add(LoadIconComplete, this); | 503 | idle_id = g_idle_add(LoadIconComplete, this); |
771 | 410 | } | 504 | } |
772 | 411 | 505 | ||
774 | 412 | void BaseIconLoaded(std::string const& base_icon_string, unsigned size, | 506 | void BaseIconLoaded(std::string const& base_icon_string, |
775 | 507 | int max_width, int max_height, | ||
776 | 413 | glib::Object<GdkPixbuf> const& base_pixbuf, | 508 | glib::Object<GdkPixbuf> const& base_pixbuf, |
777 | 414 | glib::Object<UnityProtocolAnnotatedIcon> const& anno_icon) | 509 | glib::Object<UnityProtocolAnnotatedIcon> const& anno_icon) |
778 | 415 | { | 510 | { |
779 | 416 | helper_handle = 0; | 511 | helper_handle = 0; |
780 | 417 | if (base_pixbuf) | 512 | if (base_pixbuf) |
781 | 418 | { | 513 | { |
783 | 419 | result = gdk_pixbuf_copy(base_pixbuf); | 514 | LOG_DEBUG(logger) << "Base icon loaded: '" << base_icon_string << |
784 | 515 | "' size: " << gdk_pixbuf_get_width(base_pixbuf) << 'x' << | ||
785 | 516 | gdk_pixbuf_get_height(base_pixbuf); | ||
786 | 517 | |||
787 | 518 | // we need extra space for the ribbon | ||
788 | 519 | result = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, | ||
789 | 520 | gdk_pixbuf_get_width(base_pixbuf) + RIBBON_PADDING * 2, | ||
790 | 521 | gdk_pixbuf_get_height(base_pixbuf)); | ||
791 | 522 | gdk_pixbuf_fill(result, 0x0); | ||
792 | 523 | gdk_pixbuf_copy_area(base_pixbuf, 0, 0, | ||
793 | 524 | gdk_pixbuf_get_width(base_pixbuf), | ||
794 | 525 | gdk_pixbuf_get_height(base_pixbuf), | ||
795 | 526 | result, | ||
796 | 527 | RIBBON_PADDING, 0); | ||
797 | 420 | // FIXME: can we composite the pixbuf in helper thread? | 528 | // FIXME: can we composite the pixbuf in helper thread? |
798 | 421 | UnityProtocolCategoryType category = unity_protocol_annotated_icon_get_category(anno_icon); | 529 | UnityProtocolCategoryType category = unity_protocol_annotated_icon_get_category(anno_icon); |
799 | 422 | auto helper_slot = sigc::bind(sigc::mem_fun(this, &IconLoaderTask::CategoryIconLoaded), anno_icon); | 530 | auto helper_slot = sigc::bind(sigc::mem_fun(this, &IconLoaderTask::CategoryIconLoaded), anno_icon); |
802 | 423 | unsigned cat_size = size / 4; | 531 | int max_font_height; |
803 | 424 | // FIXME: we still don't have the category assets | 532 | CalculateTextHeight(nullptr, &max_font_height); |
804 | 533 | unsigned cat_size = max_font_height * 9 / 8; | ||
805 | 425 | switch (category) | 534 | switch (category) |
806 | 426 | { | 535 | { |
807 | 536 | case UNITY_PROTOCOL_CATEGORY_TYPE_BOOK: | ||
808 | 537 | helper_handle = | ||
809 | 538 | impl->LoadFromFilename(PKGDATADIR"/emblem_books.svg", -1, cat_size, helper_slot); | ||
810 | 539 | break; | ||
811 | 427 | case UNITY_PROTOCOL_CATEGORY_TYPE_MUSIC: | 540 | case UNITY_PROTOCOL_CATEGORY_TYPE_MUSIC: |
812 | 428 | helper_handle = | 541 | helper_handle = |
815 | 429 | impl->LoadFromIconName("emblem-favorite", cat_size, helper_slot); | 542 | impl->LoadFromFilename(PKGDATADIR"/emblem_music.svg", -1, cat_size, helper_slot); |
816 | 430 | break; | 543 | break; |
817 | 544 | case UNITY_PROTOCOL_CATEGORY_TYPE_MOVIE: | ||
818 | 545 | helper_handle = | ||
819 | 546 | impl->LoadFromFilename(PKGDATADIR"/emblem_video.svg", -1, cat_size, helper_slot); | ||
820 | 547 | break; | ||
821 | 548 | case UNITY_PROTOCOL_CATEGORY_TYPE_CLOTHES: | ||
822 | 549 | case UNITY_PROTOCOL_CATEGORY_TYPE_SHOES: | ||
823 | 550 | helper_handle = | ||
824 | 551 | impl->LoadFromFilename(PKGDATADIR"/emblem_clothes.svg", -1, cat_size, helper_slot); | ||
825 | 552 | break; | ||
826 | 553 | case UNITY_PROTOCOL_CATEGORY_TYPE_GAMES: | ||
827 | 554 | case UNITY_PROTOCOL_CATEGORY_TYPE_ELECTRONICS: | ||
828 | 555 | case UNITY_PROTOCOL_CATEGORY_TYPE_COMPUTERS: | ||
829 | 556 | case UNITY_PROTOCOL_CATEGORY_TYPE_OFFICE: | ||
830 | 557 | case UNITY_PROTOCOL_CATEGORY_TYPE_HOME: | ||
831 | 558 | case UNITY_PROTOCOL_CATEGORY_TYPE_GARDEN: | ||
832 | 559 | case UNITY_PROTOCOL_CATEGORY_TYPE_PETS: | ||
833 | 560 | case UNITY_PROTOCOL_CATEGORY_TYPE_TOYS: | ||
834 | 561 | case UNITY_PROTOCOL_CATEGORY_TYPE_CHILDREN: | ||
835 | 562 | case UNITY_PROTOCOL_CATEGORY_TYPE_BABY: | ||
836 | 563 | case UNITY_PROTOCOL_CATEGORY_TYPE_WATCHES: | ||
837 | 564 | case UNITY_PROTOCOL_CATEGORY_TYPE_SPORTS: | ||
838 | 565 | case UNITY_PROTOCOL_CATEGORY_TYPE_OUTDOORS: | ||
839 | 566 | case UNITY_PROTOCOL_CATEGORY_TYPE_GROCERY: | ||
840 | 567 | case UNITY_PROTOCOL_CATEGORY_TYPE_HEALTH: | ||
841 | 568 | case UNITY_PROTOCOL_CATEGORY_TYPE_BEAUTY: | ||
842 | 569 | case UNITY_PROTOCOL_CATEGORY_TYPE_DIY: | ||
843 | 570 | case UNITY_PROTOCOL_CATEGORY_TYPE_TOOLS: | ||
844 | 571 | case UNITY_PROTOCOL_CATEGORY_TYPE_CAR: | ||
845 | 431 | default: | 572 | default: |
846 | 432 | // rest of the processing is the CategoryIconLoaded, lets invoke it | 573 | // rest of the processing is the CategoryIconLoaded, lets invoke it |
847 | 433 | glib::Object<GdkPixbuf> null_pixbuf; | 574 | glib::Object<GdkPixbuf> null_pixbuf; |
849 | 434 | helper_slot("", cat_size, null_pixbuf); | 575 | helper_slot("", -1, cat_size, null_pixbuf); |
850 | 435 | break; | 576 | break; |
851 | 436 | } | 577 | } |
852 | 437 | } | 578 | } |
853 | @@ -463,32 +604,23 @@ | |||
854 | 463 | glib::String contents; | 604 | glib::String contents; |
855 | 464 | gsize length = 0; | 605 | gsize length = 0; |
856 | 465 | 606 | ||
858 | 466 | if (::g_file_load_contents(file, canc, &contents, &length, | 607 | if (g_file_load_contents(file, canc, &contents, &length, |
859 | 467 | nullptr, &task->error)) | 608 | nullptr, &task->error)) |
860 | 468 | { | 609 | { |
861 | 469 | glib::Object<GInputStream> stream( | 610 | glib::Object<GInputStream> stream( |
863 | 470 | ::g_memory_input_stream_new_from_data(contents.Value(), length, nullptr)); | 611 | g_memory_input_stream_new_from_data(contents.Value(), length, nullptr)); |
864 | 471 | 612 | ||
881 | 472 | if (task->size != static_cast<unsigned int>(~0)) | 613 | task->result = gdk_pixbuf_new_from_stream_at_scale(stream, |
882 | 473 | { | 614 | task->max_width, |
883 | 474 | task->result = ::gdk_pixbuf_new_from_stream_at_scale(stream, | 615 | task->max_height, |
884 | 475 | -1, | 616 | TRUE, |
885 | 476 | task->size, | 617 | canc, |
886 | 477 | TRUE, | 618 | &task->error); |
887 | 478 | canc, | 619 | g_input_stream_close(stream, canc, nullptr); |
872 | 479 | &task->error); | ||
873 | 480 | } | ||
874 | 481 | else | ||
875 | 482 | { | ||
876 | 483 | task->result = ::gdk_pixbuf_new_from_stream(stream, | ||
877 | 484 | canc, | ||
878 | 485 | &task->error); | ||
879 | 486 | } | ||
880 | 487 | ::g_input_stream_close(stream, canc, nullptr); | ||
888 | 488 | } | 620 | } |
889 | 489 | } | 621 | } |
890 | 490 | 622 | ||
892 | 491 | ::g_io_scheduler_job_send_to_mainloop_async (job, LoadIconComplete, task, nullptr); | 623 | g_io_scheduler_job_send_to_mainloop_async (job, LoadIconComplete, task, nullptr); |
893 | 492 | 624 | ||
894 | 493 | return FALSE; | 625 | return FALSE; |
895 | 494 | } | 626 | } |
896 | @@ -509,7 +641,9 @@ | |||
897 | 509 | task->result = nullptr; | 641 | task->result = nullptr; |
898 | 510 | 642 | ||
899 | 511 | LOG_WARNING(logger) << "Unable to load icon " << task->data | 643 | LOG_WARNING(logger) << "Unable to load icon " << task->data |
901 | 512 | << " at size " << task->size << ": " << task->error; | 644 | << " at size " |
902 | 645 | << task->max_width << "x" << task->max_height | ||
903 | 646 | << ": " << task->error; | ||
904 | 513 | } | 647 | } |
905 | 514 | 648 | ||
906 | 515 | impl->finished_tasks_.push_back(task); | 649 | impl->finished_tasks_.push_back(task); |
907 | @@ -528,21 +662,24 @@ | |||
908 | 528 | }; | 662 | }; |
909 | 529 | 663 | ||
910 | 530 | Handle ReturnCachedOrQueue(std::string const& data, | 664 | Handle ReturnCachedOrQueue(std::string const& data, |
912 | 531 | unsigned size, | 665 | int max_width, |
913 | 666 | int max_height, | ||
914 | 532 | IconLoaderCallback slot, | 667 | IconLoaderCallback slot, |
915 | 533 | IconLoaderRequestType type); | 668 | IconLoaderRequestType type); |
916 | 534 | 669 | ||
917 | 535 | Handle QueueTask(std::string const& key, | 670 | Handle QueueTask(std::string const& key, |
918 | 536 | std::string const& data, | 671 | std::string const& data, |
920 | 537 | unsigned size, | 672 | int max_width, |
921 | 673 | int max_height, | ||
922 | 538 | IconLoaderCallback slot, | 674 | IconLoaderCallback slot, |
923 | 539 | IconLoaderRequestType type); | 675 | IconLoaderRequestType type); |
924 | 540 | 676 | ||
926 | 541 | std::string Hash(std::string const& data, unsigned size); | 677 | std::string Hash(std::string const& data, int max_width, int max_height); |
927 | 542 | 678 | ||
928 | 543 | bool CacheLookup(std::string const& key, | 679 | bool CacheLookup(std::string const& key, |
929 | 544 | std::string const& data, | 680 | std::string const& data, |
931 | 545 | unsigned size, | 681 | int max_width, |
932 | 682 | int max_height, | ||
933 | 546 | IconLoaderCallback slot); | 683 | IconLoaderCallback slot); |
934 | 547 | 684 | ||
935 | 548 | // Looping idle callback function | 685 | // Looping idle callback function |
936 | @@ -600,52 +737,67 @@ | |||
937 | 600 | } | 737 | } |
938 | 601 | 738 | ||
939 | 602 | int IconLoader::Impl::LoadFromIconName(std::string const& icon_name, | 739 | int IconLoader::Impl::LoadFromIconName(std::string const& icon_name, |
941 | 603 | unsigned size, | 740 | int max_width, |
942 | 741 | int max_height, | ||
943 | 604 | IconLoaderCallback slot) | 742 | IconLoaderCallback slot) |
944 | 605 | { | 743 | { |
946 | 606 | if (no_load_ || icon_name.empty() || size < MIN_ICON_SIZE || !slot) | 744 | if (no_load_ || icon_name.empty() || !slot || |
947 | 745 | ((max_width >= 0 && max_width < MIN_ICON_SIZE) || | ||
948 | 746 | (max_height >= 0 && max_height < MIN_ICON_SIZE))) | ||
949 | 607 | return 0; | 747 | return 0; |
950 | 608 | 748 | ||
951 | 609 | // We need to check this because of legacy desktop files | 749 | // We need to check this because of legacy desktop files |
952 | 610 | if (icon_name[0] == '/') | 750 | if (icon_name[0] == '/') |
953 | 611 | { | 751 | { |
955 | 612 | return LoadFromFilename(icon_name, size, slot); | 752 | return LoadFromFilename(icon_name, max_width, max_height, slot); |
956 | 613 | } | 753 | } |
957 | 614 | 754 | ||
959 | 615 | return ReturnCachedOrQueue(icon_name, size, slot, REQUEST_TYPE_ICON_NAME); | 755 | return ReturnCachedOrQueue(icon_name, max_width, max_height, slot, |
960 | 756 | REQUEST_TYPE_ICON_NAME); | ||
961 | 616 | } | 757 | } |
962 | 617 | 758 | ||
963 | 618 | int IconLoader::Impl::LoadFromGIconString(std::string const& gicon_string, | 759 | int IconLoader::Impl::LoadFromGIconString(std::string const& gicon_string, |
965 | 619 | unsigned size, | 760 | int max_width, |
966 | 761 | int max_height, | ||
967 | 620 | IconLoaderCallback slot) | 762 | IconLoaderCallback slot) |
968 | 621 | { | 763 | { |
970 | 622 | if (no_load_ || gicon_string.empty() || size < MIN_ICON_SIZE || !slot) | 764 | if (no_load_ || gicon_string.empty() || !slot || |
971 | 765 | ((max_width >= 0 && max_width < MIN_ICON_SIZE) || | ||
972 | 766 | (max_height >= 0 && max_height < MIN_ICON_SIZE))) | ||
973 | 623 | return 0; | 767 | return 0; |
974 | 624 | 768 | ||
976 | 625 | return ReturnCachedOrQueue(gicon_string, size, slot, REQUEST_TYPE_GICON_STRING); | 769 | return ReturnCachedOrQueue(gicon_string, max_width, max_height, slot, |
977 | 770 | REQUEST_TYPE_GICON_STRING); | ||
978 | 626 | } | 771 | } |
979 | 627 | 772 | ||
980 | 628 | int IconLoader::Impl::LoadFromFilename(std::string const& filename, | 773 | int IconLoader::Impl::LoadFromFilename(std::string const& filename, |
982 | 629 | unsigned size, | 774 | int max_width, |
983 | 775 | int max_height, | ||
984 | 630 | IconLoaderCallback slot) | 776 | IconLoaderCallback slot) |
985 | 631 | { | 777 | { |
987 | 632 | if (no_load_ || filename.empty() || size < MIN_ICON_SIZE || !slot) | 778 | if (no_load_ || filename.empty() || !slot || |
988 | 779 | ((max_width >= 0 && max_width < MIN_ICON_SIZE) || | ||
989 | 780 | (max_height >= 0 && max_height < MIN_ICON_SIZE))) | ||
990 | 633 | return 0; | 781 | return 0; |
991 | 634 | 782 | ||
992 | 635 | glib::Object<GFile> file(::g_file_new_for_path(filename.c_str())); | 783 | glib::Object<GFile> file(::g_file_new_for_path(filename.c_str())); |
993 | 636 | glib::String uri(::g_file_get_uri(file)); | 784 | glib::String uri(::g_file_get_uri(file)); |
994 | 637 | 785 | ||
996 | 638 | return LoadFromURI(uri.Str(), size, slot); | 786 | return LoadFromURI(uri.Str(), max_width, max_height, slot); |
997 | 639 | } | 787 | } |
998 | 640 | 788 | ||
999 | 641 | int IconLoader::Impl::LoadFromURI(std::string const& uri, | 789 | int IconLoader::Impl::LoadFromURI(std::string const& uri, |
1001 | 642 | unsigned size, | 790 | int max_width, |
1002 | 791 | int max_height, | ||
1003 | 643 | IconLoaderCallback slot) | 792 | IconLoaderCallback slot) |
1004 | 644 | { | 793 | { |
1006 | 645 | if (no_load_ || uri.empty() || size < MIN_ICON_SIZE || !slot) | 794 | if (no_load_ || uri.empty() || !slot || |
1007 | 795 | ((max_width >= 0 && max_width < MIN_ICON_SIZE) || | ||
1008 | 796 | (max_height >= 0 && max_height < MIN_ICON_SIZE))) | ||
1009 | 646 | return 0; | 797 | return 0; |
1010 | 647 | 798 | ||
1012 | 648 | return ReturnCachedOrQueue(uri, size, slot, REQUEST_TYPE_URI); | 799 | return ReturnCachedOrQueue(uri, max_width, max_height, slot, |
1013 | 800 | REQUEST_TYPE_URI); | ||
1014 | 649 | } | 801 | } |
1015 | 650 | 802 | ||
1016 | 651 | void IconLoader::Impl::DisconnectHandle(Handle handle) | 803 | void IconLoader::Impl::DisconnectHandle(Handle handle) |
1017 | @@ -699,16 +851,17 @@ | |||
1018 | 699 | // | 851 | // |
1019 | 700 | 852 | ||
1020 | 701 | int IconLoader::Impl::ReturnCachedOrQueue(std::string const& data, | 853 | int IconLoader::Impl::ReturnCachedOrQueue(std::string const& data, |
1022 | 702 | unsigned size, | 854 | int max_width, |
1023 | 855 | int max_height, | ||
1024 | 703 | IconLoaderCallback slot, | 856 | IconLoaderCallback slot, |
1025 | 704 | IconLoaderRequestType type) | 857 | IconLoaderRequestType type) |
1026 | 705 | { | 858 | { |
1027 | 706 | Handle result = 0; | 859 | Handle result = 0; |
1029 | 707 | std::string key(Hash(data, size)); | 860 | std::string key(Hash(data, max_width, max_height)); |
1030 | 708 | 861 | ||
1032 | 709 | if (!CacheLookup(key, data, size, slot)) | 862 | if (!CacheLookup(key, data, max_width, max_height, slot)) |
1033 | 710 | { | 863 | { |
1035 | 711 | result = QueueTask(key, data, size, slot, type); | 864 | result = QueueTask(key, data, max_width, max_height, slot, type); |
1036 | 712 | } | 865 | } |
1037 | 713 | return result; | 866 | return result; |
1038 | 714 | } | 867 | } |
1039 | @@ -716,11 +869,15 @@ | |||
1040 | 716 | 869 | ||
1041 | 717 | int IconLoader::Impl::QueueTask(std::string const& key, | 870 | int IconLoader::Impl::QueueTask(std::string const& key, |
1042 | 718 | std::string const& data, | 871 | std::string const& data, |
1044 | 719 | unsigned size, | 872 | int max_width, |
1045 | 873 | int max_height, | ||
1046 | 720 | IconLoaderCallback slot, | 874 | IconLoaderCallback slot, |
1047 | 721 | IconLoaderRequestType type) | 875 | IconLoaderRequestType type) |
1048 | 722 | { | 876 | { |
1050 | 723 | auto task = std::make_shared<IconLoaderTask>(type, data, size, key, slot, ++handle_counter_, this); | 877 | auto task = std::make_shared<IconLoaderTask>(type, data, |
1051 | 878 | max_width, max_height, | ||
1052 | 879 | key, slot, | ||
1053 | 880 | ++handle_counter_, this); | ||
1054 | 724 | auto iter = queued_tasks_.find(key); | 881 | auto iter = queued_tasks_.find(key); |
1055 | 725 | 882 | ||
1056 | 726 | if (iter != queued_tasks_.end()) | 883 | if (iter != queued_tasks_.end()) |
1057 | @@ -744,7 +901,8 @@ | |||
1058 | 744 | tasks_.push(task); | 901 | tasks_.push(task); |
1059 | 745 | task_map_[task->handle] = task; | 902 | task_map_[task->handle] = task; |
1060 | 746 | 903 | ||
1062 | 747 | LOG_DEBUG(logger) << "Pushing task " << data << " at size " << size | 904 | LOG_DEBUG(logger) << "Pushing task " << data << " at size " |
1063 | 905 | << max_width << "x" << max_height | ||
1064 | 748 | << ", queue size now at " << tasks_.size(); | 906 | << ", queue size now at " << tasks_.size(); |
1065 | 749 | 907 | ||
1066 | 750 | if (!idle_) | 908 | if (!idle_) |
1067 | @@ -754,16 +912,17 @@ | |||
1068 | 754 | return task->handle; | 912 | return task->handle; |
1069 | 755 | } | 913 | } |
1070 | 756 | 914 | ||
1072 | 757 | std::string IconLoader::Impl::Hash(std::string const& data, unsigned size) | 915 | std::string IconLoader::Impl::Hash(std::string const& data, int max_width, int max_height) |
1073 | 758 | { | 916 | { |
1074 | 759 | std::ostringstream sout; | 917 | std::ostringstream sout; |
1076 | 760 | sout << data << ":" << size; | 918 | sout << data << ":" << max_width << "x" << max_height; |
1077 | 761 | return sout.str(); | 919 | return sout.str(); |
1078 | 762 | } | 920 | } |
1079 | 763 | 921 | ||
1080 | 764 | bool IconLoader::Impl::CacheLookup(std::string const& key, | 922 | bool IconLoader::Impl::CacheLookup(std::string const& key, |
1081 | 765 | std::string const& data, | 923 | std::string const& data, |
1083 | 766 | unsigned size, | 924 | int max_width, |
1084 | 925 | int max_height, | ||
1085 | 767 | IconLoaderCallback slot) | 926 | IconLoaderCallback slot) |
1086 | 768 | { | 927 | { |
1087 | 769 | auto iter = cache_.find(key); | 928 | auto iter = cache_.find(key); |
1088 | @@ -772,7 +931,7 @@ | |||
1089 | 772 | if (found && slot) | 931 | if (found && slot) |
1090 | 773 | { | 932 | { |
1091 | 774 | glib::Object<GdkPixbuf> const& pixbuf = iter->second; | 933 | glib::Object<GdkPixbuf> const& pixbuf = iter->second; |
1093 | 775 | slot(data, size, pixbuf); | 934 | slot(data, max_width, max_height, pixbuf); |
1094 | 776 | } | 935 | } |
1095 | 777 | 936 | ||
1096 | 778 | return found; | 937 | return found; |
1097 | @@ -848,31 +1007,35 @@ | |||
1098 | 848 | } | 1007 | } |
1099 | 849 | 1008 | ||
1100 | 850 | int IconLoader::LoadFromIconName(std::string const& icon_name, | 1009 | int IconLoader::LoadFromIconName(std::string const& icon_name, |
1102 | 851 | unsigned size, | 1010 | int max_width, |
1103 | 1011 | int max_height, | ||
1104 | 852 | IconLoaderCallback slot) | 1012 | IconLoaderCallback slot) |
1105 | 853 | { | 1013 | { |
1107 | 854 | return pimpl->LoadFromIconName(icon_name, size, slot); | 1014 | return pimpl->LoadFromIconName(icon_name, max_width, max_height, slot); |
1108 | 855 | } | 1015 | } |
1109 | 856 | 1016 | ||
1110 | 857 | int IconLoader::LoadFromGIconString(std::string const& gicon_string, | 1017 | int IconLoader::LoadFromGIconString(std::string const& gicon_string, |
1112 | 858 | unsigned size, | 1018 | int max_width, |
1113 | 1019 | int max_height, | ||
1114 | 859 | IconLoaderCallback slot) | 1020 | IconLoaderCallback slot) |
1115 | 860 | { | 1021 | { |
1117 | 861 | return pimpl->LoadFromGIconString(gicon_string, size, slot); | 1022 | return pimpl->LoadFromGIconString(gicon_string, max_width, max_height, slot); |
1118 | 862 | } | 1023 | } |
1119 | 863 | 1024 | ||
1120 | 864 | int IconLoader::LoadFromFilename(std::string const& filename, | 1025 | int IconLoader::LoadFromFilename(std::string const& filename, |
1122 | 865 | unsigned size, | 1026 | int max_width, |
1123 | 1027 | int max_height, | ||
1124 | 866 | IconLoaderCallback slot) | 1028 | IconLoaderCallback slot) |
1125 | 867 | { | 1029 | { |
1127 | 868 | return pimpl->LoadFromFilename(filename, size, slot); | 1030 | return pimpl->LoadFromFilename(filename, max_width, max_height, slot); |
1128 | 869 | } | 1031 | } |
1129 | 870 | 1032 | ||
1130 | 871 | int IconLoader::LoadFromURI(std::string const& uri, | 1033 | int IconLoader::LoadFromURI(std::string const& uri, |
1132 | 872 | unsigned size, | 1034 | int max_width, |
1133 | 1035 | int max_height, | ||
1134 | 873 | IconLoaderCallback slot) | 1036 | IconLoaderCallback slot) |
1135 | 874 | { | 1037 | { |
1137 | 875 | return pimpl->LoadFromURI(uri, size, slot); | 1038 | return pimpl->LoadFromURI(uri, max_width, max_height, slot); |
1138 | 876 | } | 1039 | } |
1139 | 877 | 1040 | ||
1140 | 878 | void IconLoader::DisconnectHandle(int handle) | 1041 | void IconLoader::DisconnectHandle(int handle) |
1141 | 879 | 1042 | ||
1142 | === modified file 'unity-shared/IconLoader.h' | |||
1143 | --- unity-shared/IconLoader.h 2012-07-16 11:03:32 +0000 | |||
1144 | +++ unity-shared/IconLoader.h 2012-09-13 10:12:22 +0000 | |||
1145 | @@ -32,7 +32,7 @@ | |||
1146 | 32 | class IconLoader : public boost::noncopyable | 32 | class IconLoader : public boost::noncopyable |
1147 | 33 | { | 33 | { |
1148 | 34 | public: | 34 | public: |
1150 | 35 | typedef std::function<void(std::string const&, unsigned, glib::Object<GdkPixbuf> const&)> IconLoaderCallback; | 35 | typedef std::function<void(std::string const&, int, int, glib::Object<GdkPixbuf> const&)> IconLoaderCallback; |
1151 | 36 | 36 | ||
1152 | 37 | IconLoader(); | 37 | IconLoader(); |
1153 | 38 | ~IconLoader(); | 38 | ~IconLoader(); |
1154 | @@ -45,19 +45,23 @@ | |||
1155 | 45 | */ | 45 | */ |
1156 | 46 | 46 | ||
1157 | 47 | int LoadFromIconName(std::string const& icon_name, | 47 | int LoadFromIconName(std::string const& icon_name, |
1159 | 48 | unsigned size, | 48 | int max_width, |
1160 | 49 | int max_height, | ||
1161 | 49 | IconLoaderCallback slot); | 50 | IconLoaderCallback slot); |
1162 | 50 | 51 | ||
1163 | 51 | int LoadFromGIconString(std::string const& gicon_string, | 52 | int LoadFromGIconString(std::string const& gicon_string, |
1165 | 52 | unsigned size, | 53 | int max_width, |
1166 | 54 | int max_height, | ||
1167 | 53 | IconLoaderCallback slot); | 55 | IconLoaderCallback slot); |
1168 | 54 | 56 | ||
1169 | 55 | int LoadFromFilename(std::string const& filename, | 57 | int LoadFromFilename(std::string const& filename, |
1171 | 56 | unsigned size, | 58 | int max_width, |
1172 | 59 | int max_height, | ||
1173 | 57 | IconLoaderCallback slot); | 60 | IconLoaderCallback slot); |
1174 | 58 | 61 | ||
1175 | 59 | int LoadFromURI(std::string const& uri, | 62 | int LoadFromURI(std::string const& uri, |
1177 | 60 | unsigned size, | 63 | int max_width, |
1178 | 64 | int max_height, | ||
1179 | 61 | IconLoaderCallback slot); | 65 | IconLoaderCallback slot); |
1180 | 62 | 66 | ||
1181 | 63 | void DisconnectHandle(int handle); | 67 | void DisconnectHandle(int handle); |
1182 | 64 | 68 | ||
1183 | === modified file 'unity-shared/IconTexture.cpp' | |||
1184 | --- unity-shared/IconTexture.cpp 2012-08-07 15:46:38 +0000 | |||
1185 | +++ unity-shared/IconTexture.cpp 2012-09-13 10:12:22 +0000 | |||
1186 | @@ -111,21 +111,21 @@ | |||
1187 | 111 | 111 | ||
1188 | 112 | glib::Object<GIcon> icon(g_icon_new_for_string(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), NULL)); | 112 | glib::Object<GIcon> icon(g_icon_new_for_string(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), NULL)); |
1189 | 113 | 113 | ||
1191 | 114 | if (G_IS_ICON(icon.RawPtr())) | 114 | if (icon.IsType(G_TYPE_ICON)) |
1192 | 115 | { | 115 | { |
1193 | 116 | _handle = IconLoader::GetDefault().LoadFromGIconString(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), | 116 | _handle = IconLoader::GetDefault().LoadFromGIconString(_icon_name.empty() ? DEFAULT_GICON : _icon_name.c_str(), |
1195 | 117 | _size, | 117 | -1, _size, |
1196 | 118 | sigc::mem_fun(this, &IconTexture::IconLoaded)); | 118 | sigc::mem_fun(this, &IconTexture::IconLoaded)); |
1197 | 119 | } | 119 | } |
1198 | 120 | else if (_icon_name.find("http://") == 0) | 120 | else if (_icon_name.find("http://") == 0) |
1199 | 121 | { | 121 | { |
1200 | 122 | _handle = IconLoader::GetDefault().LoadFromURI(_icon_name, | 122 | _handle = IconLoader::GetDefault().LoadFromURI(_icon_name, |
1202 | 123 | _size, sigc::mem_fun(this, &IconTexture::IconLoaded)); | 123 | -1, _size, sigc::mem_fun(this, &IconTexture::IconLoaded)); |
1203 | 124 | } | 124 | } |
1204 | 125 | else | 125 | else |
1205 | 126 | { | 126 | { |
1206 | 127 | _handle = IconLoader::GetDefault().LoadFromIconName(_icon_name, | 127 | _handle = IconLoader::GetDefault().LoadFromIconName(_icon_name, |
1208 | 128 | _size, | 128 | -1, _size, |
1209 | 129 | sigc::mem_fun(this, &IconTexture::IconLoaded)); | 129 | sigc::mem_fun(this, &IconTexture::IconLoaded)); |
1210 | 130 | } | 130 | } |
1211 | 131 | } | 131 | } |
1212 | @@ -153,7 +153,9 @@ | |||
1213 | 153 | _loading = false; | 153 | _loading = false; |
1214 | 154 | } | 154 | } |
1215 | 155 | 155 | ||
1217 | 156 | void IconTexture::IconLoaded(std::string const& icon_name, unsigned size, | 156 | void IconTexture::IconLoaded(std::string const& icon_name, |
1218 | 157 | int max_width, | ||
1219 | 158 | int max_height, | ||
1220 | 157 | glib::Object<GdkPixbuf> const& pixbuf) | 159 | glib::Object<GdkPixbuf> const& pixbuf) |
1221 | 158 | { | 160 | { |
1222 | 159 | _handle = 0; | 161 | _handle = 0; |
1223 | 160 | 162 | ||
1224 | === modified file 'unity-shared/IconTexture.h' | |||
1225 | --- unity-shared/IconTexture.h 2012-08-07 15:46:38 +0000 | |||
1226 | +++ unity-shared/IconTexture.h 2012-09-13 10:12:22 +0000 | |||
1227 | @@ -79,7 +79,7 @@ | |||
1228 | 79 | private: | 79 | private: |
1229 | 80 | nux::BaseTexture* CreateTextureCallback(std::string const& texid, int width, int height); | 80 | nux::BaseTexture* CreateTextureCallback(std::string const& texid, int width, int height); |
1230 | 81 | void Refresh(glib::Object<GdkPixbuf> const& pixbuf); | 81 | void Refresh(glib::Object<GdkPixbuf> const& pixbuf); |
1232 | 82 | void IconLoaded(std::string const& icon_name, unsigned size, glib::Object<GdkPixbuf> const& pixbuf); | 82 | void IconLoaded(std::string const& icon_name, int max_width, int max_height, glib::Object<GdkPixbuf> const& pixbuf); |
1233 | 83 | 83 | ||
1234 | 84 | std::string _icon_name; | 84 | std::string _icon_name; |
1235 | 85 | unsigned int _size; | 85 | unsigned int _size; |
502 + int size = max_height < 0 ? max_width : max_height;
510 + int size = max_height < 0 ? max_width : max_height;
I think it should use the minimum of the values if max_height < 0. so.
int size = max_height < 0 ? max_width : (max_width < 0 ? max_height : MIN(max_height, max_width));
784 switch (category) CATEGORY_ TYPE_BOOK: ilename( PKGDATADIR" /emblem_ books.svg" , -1, cat_size, helper_slot); CATEGORY_ TYPE_MUSIC:
785 {
786 + case UNITY_PROTOCOL_
787 + helper_handle =
788 + impl->LoadFromF
789 + break;
790 case UNITY_PROTOCOL_
Could we put the category->resource mapping in the Dash Style?
Other than these the code looks good. I trust it meets visual design requirements :)