Merge lp:~didrocks/unity/fix683444 into lp:unity

Proposed by Didier Roche on 2010-12-02
Status: Merged
Merged at revision: 657
Proposed branch: lp:~didrocks/unity/fix683444
Merge into: lp:unity
Diff against target: 77 lines (+38/-1)
3 files modified
src/LauncherIcon.cpp (+33/-0)
src/LauncherIcon.h (+1/-0)
src/SimpleLauncherIcon.cpp (+4/-1)
To merge this branch: bzr merge lp:~didrocks/unity/fix683444
Reviewer Review Type Date Requested Status
Jason Smith (community) 2010-12-02 Approve on 2010-12-02
Review via email: mp+42493@code.launchpad.net

Description of the Change

Fix bug of unknown icon when the desktop file is setting a custom one (absolute
path)

To post a comment you must log in.
Jason Smith (jassmith) wrote :

+1 approved

review: Approve
lp:~didrocks/unity/fix683444 updated on 2010-12-02
653. By Didier Roche on 2010-12-02

free the gerror(s)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/LauncherIcon.cpp'
2--- src/LauncherIcon.cpp 2010-12-02 16:01:38 +0000
3+++ src/LauncherIcon.cpp 2010-12-02 16:21:46 +0000
4@@ -223,6 +223,7 @@
5 g_warning ("Unable to load '%s' from icon theme: %s",
6 icon_name,
7 error ? error->message : "unknown");
8+ g_error_free (error);
9
10 if (g_strcmp0 (icon_name, "folder") == 0)
11 return NULL;
12@@ -233,6 +234,38 @@
13 return result;
14 }
15
16+nux::BaseTexture * LauncherIcon::TextureFromPath (const char *icon_name, int size)
17+{
18+
19+ GdkPixbuf *pbuf;
20+ nux::BaseTexture *result;
21+ GError *error = NULL;
22+
23+ if (!icon_name)
24+ return TextureFromGtkTheme (DEFAULT_ICON, size);
25+
26+ pbuf = gdk_pixbuf_new_from_file_at_size (icon_name, size, size, &error);
27+
28+ if (GDK_IS_PIXBUF (pbuf))
29+ {
30+ result = nux::CreateTextureFromPixbuf (pbuf);
31+ ColorForIcon (pbuf, _background_color, _glow_color);
32+
33+ g_object_unref (pbuf);
34+ }
35+ else
36+ {
37+ g_warning ("Unable to load '%s' icon: %s",
38+ icon_name,
39+ error->message : "unknown");
40+ g_error_free (error);
41+
42+ return TextureFromGtkTheme (DEFAULT_ICON, size);
43+ }
44+
45+ return result;
46+}
47+
48 void LauncherIcon::SetTooltipText(const TCHAR* text)
49 {
50 m_TooltipText = text;
51
52=== modified file 'src/LauncherIcon.h'
53--- src/LauncherIcon.h 2010-12-02 15:56:08 +0000
54+++ src/LauncherIcon.h 2010-12-02 16:21:46 +0000
55@@ -143,6 +143,7 @@
56 virtual bool IconOwnsWindow (Window w) { return false; }
57
58 nux::BaseTexture * TextureFromGtkTheme (const char *name, int size);
59+ nux::BaseTexture * TextureFromPath (const char *name, int size);
60
61 nux::NString m_TooltipText;
62 //! the window this icon belong too.
63
64=== modified file 'src/SimpleLauncherIcon.cpp'
65--- src/SimpleLauncherIcon.cpp 2010-11-24 18:59:55 +0000
66+++ src/SimpleLauncherIcon.cpp 2010-12-02 16:21:46 +0000
67@@ -78,7 +78,10 @@
68 if (!m_IconName)
69 return 0;
70
71- m_Icon = TextureFromGtkTheme (m_IconName, size);
72+ if (g_str_has_prefix (m_IconName, "/"))
73+ m_Icon = TextureFromPath (m_IconName, size);
74+ else
75+ m_Icon = TextureFromGtkTheme (m_IconName, size);
76 return m_Icon;
77 }
78