Merge lp:~mvo/unity/lp1525186-icon-fallback into lp:unity

Proposed by Michael Vogt
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4056
Proposed branch: lp:~mvo/unity/lp1525186-icon-fallback
Merge into: lp:unity
Diff against target: 51 lines (+19/-1)
1 file modified
panel/PanelIndicatorEntryView.cpp (+19/-1)
To merge this branch: bzr merge lp:~mvo/unity/lp1525186-icon-fallback
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Marco Trevisan (Treviño) Approve
Review via email: mp+280298@code.launchpad.net

Commit message

Display "image-missing" icon in the panel if for some reason a icon can not be loaded.

Description of the change

Fix icon loading in the panel to have a "image-missing" icon if the requested icon can not be loaded.

To reproduce:
- switch to high-contrast theme in unity-system-settings
- observe that there is no icon for the session-indicator

- rebuild with my patch
- observe that there is an icon now

Note that I see in the log:
"""
WARN 2015-12-11 13:01:35 unity.panel.indicator.entry PanelIndicatorEntryView.cp
p:253 failed to load: /org/gtk/libgtk/icons/24x24/status/image-missing.png
"""

So this indicates that the code that tries to find the icon is wrong in some way. However I still think there is value in having a fallback in the panel "if (!pixbuf)" even if this other issue gets fixed as e.g. the encoded icon might be wrong (and we do not check for the Gerror in this case).

To post a comment you must log in.
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Thanks for the MP. See my inline comments please.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:4038
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~mvo/unity/lp1525186-icon-fallback/+merge/280298/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/unity-ci/1374/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-xenial-amd64-ci/26
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-xenial-armhf-ci/26
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-xenial-i386-ci/26

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity-ci/1374/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for the detailed review! I fixed the comments, please let me know if I missed anything :)

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panel/PanelIndicatorEntryView.cpp'
2--- panel/PanelIndicatorEntryView.cpp 2015-10-05 16:52:24 +0000
3+++ panel/PanelIndicatorEntryView.cpp 2015-12-11 16:37:21 +0000
4@@ -40,6 +40,7 @@
5 {
6 DECLARE_LOGGER(logger, "unity.panel.indicator.entry");
7 const int DEFAULT_SPACING = 3;
8+const std::string IMAGE_MISSING = "image-missing";
9 }
10
11 using namespace indicator;
12@@ -204,8 +205,12 @@
13 glib::Object<GdkPixbuf> PanelIndicatorEntryView::MakePixbuf(int size)
14 {
15 glib::Object<GdkPixbuf> pixbuf;
16+
17+ // see if we need to do anything
18+ if (!proxy_->image_visible() || proxy_->image_data().empty())
19+ return pixbuf;
20+
21 auto image_type = proxy_->image_type();
22-
23 switch (image_type)
24 {
25 case GTK_IMAGE_PIXBUF:
26@@ -248,6 +253,11 @@
27 {
28 auto* filename = gtk_icon_info_get_filename(info);
29 pixbuf = gdk_pixbuf_new_from_file_at_size(filename, -1, size, nullptr);
30+ // if that failed, whine and load fallback
31+ if (!pixbuf)
32+ {
33+ LOG_WARN(logger) << "failed to load: " << filename;
34+ }
35 }
36 else if (image_type == GTK_IMAGE_ICON_NAME)
37 {
38@@ -258,6 +268,14 @@
39 }
40 }
41
42+ // have a generic fallback pixbuf if for whatever reason icon loading
43+ // failed (see LP: #1525186)
44+ if (!pixbuf)
45+ {
46+ GtkIconTheme* theme = gtk_icon_theme_get_default();
47+ pixbuf = gtk_icon_theme_load_icon(theme, IMAGE_MISSING.c_str(), size, GTK_ICON_LOOKUP_FORCE_SIZE, nullptr);
48+ }
49+
50 return pixbuf;
51 }
52