Merge lp:~3v1n0/unity/force-resize-gtk-icons into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4023
Proposed branch: lp:~3v1n0/unity/force-resize-gtk-icons
Merge into: lp:unity
Diff against target: 378 lines (+35/-107)
9 files modified
UnityCore/GTKWrapper.h (+0/-73)
dash/ResultRenderer.cpp (+11/-10)
launcher/LauncherIcon.cpp (+4/-5)
launcher/MockLauncherIcon.h (+4/-4)
panel/PanelIndicatorEntryView.cpp (+3/-3)
tests/CMakeLists.txt (+1/-1)
tests/test_gtk_icon_info.cpp (+7/-6)
tests/test_result_renderer.cpp (+1/-1)
unity-shared/IconLoader.cpp (+4/-4)
To merge this branch: bzr merge lp:~3v1n0/unity/force-resize-gtk-icons
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+273313@code.launchpad.net

Commit message

LauncherIcon: force lookup icon by scaling it at the requested size

As bonus, remove unused GtkWrapper class

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Did you forget to push test_gtk_icon_info.cpp?

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'UnityCore/GTKWrapper.h'
2--- UnityCore/GTKWrapper.h 2014-02-26 23:21:06 +0000
3+++ UnityCore/GTKWrapper.h 1970-01-01 00:00:00 +0000
4@@ -1,73 +0,0 @@
5-// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
6-/*
7- * Copyright (C) 2013 Canonical Ltd
8- *
9- * This program is free software: you can redistribute it and/or modify
10- * it under the terms of the GNU General Public License version 3 as
11- * published by the Free Software Foundation.
12- *
13- * This program is distributed in the hope that it will be useful,
14- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16- * GNU General Public License for more details.
17- *
18- * You should have received a copy of the GNU General Public License
19- * along with this program. If not, see <http://www.gnu.org/licenses/>.
20- *
21- * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
22- */
23-
24-#ifndef GTK_WRAPPER
25-
26-#include <gtk/gtk.h>
27-#include <GLibWrapper.h>
28-
29-namespace unity
30-{
31-namespace gtk
32-{
33-
34-#if GTK_CHECK_VERSION(3, 8, 0)
35-
36-typedef glib::Object<GtkIconInfo> IconInfo;
37-
38-#else
39-
40-class IconInfo : boost::noncopyable
41-{
42-public:
43- IconInfo(GtkIconInfo *info = nullptr)
44- : icon_info_(info)
45- {}
46-
47- ~IconInfo()
48- {
49- if (icon_info_)
50- gtk_icon_info_free(icon_info_);
51- }
52-
53- IconInfo& operator=(GtkIconInfo* val)
54- {
55- if (icon_info_ == val)
56- return *this;
57-
58- if (icon_info_)
59- gtk_icon_info_free(icon_info_);
60-
61- icon_info_ = val;
62- return *this;
63- }
64-
65- operator GtkIconInfo*() const { return icon_info_; }
66- operator bool() const { return icon_info_; }
67- GtkIconInfo* RawPtr() const { return icon_info_; }
68-
69-private:
70- GtkIconInfo *icon_info_;
71-};
72-#endif
73-
74-}
75-}
76-
77-#endif // GTK_WRAPPER
78
79=== modified file 'dash/ResultRenderer.cpp'
80--- dash/ResultRenderer.cpp 2014-03-20 04:05:39 +0000
81+++ dash/ResultRenderer.cpp 2015-10-05 16:53:29 +0000
82@@ -21,11 +21,12 @@
83 */
84
85 #include "ResultRenderer.h"
86+#include "unity-shared/RawPixel.h"
87
88 #include <gtk/gtk.h>
89 #include <unity-protocol.h>
90 #include <NuxGraphics/GdkGraphics.h>
91-#include <UnityCore/GTKWrapper.h>
92+#include <UnityCore/GLibWrapper.h>
93
94 namespace unity
95 {
96@@ -34,13 +35,14 @@
97
98 namespace
99 {
100-#define DEFAULT_GICON ". GThemedIcon text-x-preview"
101+const std::string DEFAULT_GICON = ". GThemedIcon text-x-preview";
102+const RawPixel DEFAULT_ICON_SIZE = 64_em;
103
104 GdkPixbuf* _icon_hint_get_drag_pixbuf(std::string icon_hint, int size)
105 {
106 GdkPixbuf *pbuf;
107 GtkIconTheme *theme;
108- gtk::IconInfo info;
109+ glib::Object<GtkIconInfo> info;
110 glib::Error error;
111 glib::Object<GIcon> icon;
112
113@@ -67,11 +69,11 @@
114 {
115 auto anno = glib::object_cast<UnityProtocolAnnotatedIcon>(icon);
116 GIcon *base_icon = unity_protocol_annotated_icon_get_icon(anno);
117- info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, (GtkIconLookupFlags)0);
118+ info = gtk_icon_theme_lookup_by_gicon(theme, base_icon, size, GTK_ICON_LOOKUP_FORCE_SIZE);
119 }
120 else
121 {
122- info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0);
123+ info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, GTK_ICON_LOOKUP_FORCE_SIZE);
124 }
125 }
126 else
127@@ -79,7 +81,7 @@
128 info = gtk_icon_theme_lookup_icon(theme,
129 icon_hint.c_str(),
130 size,
131- (GtkIconLookupFlags) 0);
132+ GTK_ICON_LOOKUP_FORCE_SIZE);
133 }
134
135 if (!info)
136@@ -87,7 +89,7 @@
137 info = gtk_icon_theme_lookup_icon(theme,
138 "application-default-icon",
139 size,
140- (GtkIconLookupFlags) 0);
141+ GTK_ICON_LOOKUP_FORCE_SIZE);
142 }
143
144 if (!gtk_icon_info_get_filename(info))
145@@ -95,7 +97,7 @@
146 info = gtk_icon_theme_lookup_icon(theme,
147 "application-default-icon",
148 size,
149- (GtkIconLookupFlags) 0);
150+ GTK_ICON_LOOKUP_FORCE_SIZE);
151 }
152
153 pbuf = gtk_icon_info_load_icon(info, &error);
154@@ -143,10 +145,9 @@
155
156 nux::NBitmapData* ResultRenderer::GetDndImage(Result const& row) const
157 {
158- nux::GdkGraphics graphics(_icon_hint_get_drag_pixbuf(row.icon_hint, 64));
159+ nux::GdkGraphics graphics(_icon_hint_get_drag_pixbuf(row.icon_hint, DEFAULT_ICON_SIZE.CP(scale)));
160 return graphics.GetBitmap();
161 }
162
163 }
164 }
165-
166
167=== modified file 'launcher/LauncherIcon.cpp'
168--- launcher/LauncherIcon.cpp 2015-04-23 20:16:49 +0000
169+++ launcher/LauncherIcon.cpp 2015-10-05 16:53:29 +0000
170@@ -39,7 +39,6 @@
171 #include "MultiMonitor.h"
172
173 #include <UnityCore/GLibWrapper.h>
174-#include <UnityCore/GTKWrapper.h>
175 #include <UnityCore/Variant.h>
176
177 namespace unity
178@@ -328,11 +327,11 @@
179 return (bool)_current_theme_is_mono;
180
181 GtkIconTheme* default_theme;
182- gtk::IconInfo info;
183+ glib::Object<GtkIconInfo> info;
184 default_theme = gtk_icon_theme_get_default();
185
186 _current_theme_is_mono = (int)false;
187- info = gtk_icon_theme_lookup_icon(default_theme, MONO_TEST_ICON.c_str(), icon_size(), (GtkIconLookupFlags)0);
188+ info = gtk_icon_theme_lookup_icon(default_theme, MONO_TEST_ICON.c_str(), icon_size(), GTK_ICON_LOOKUP_FORCE_SIZE);
189
190 if (!info)
191 return (bool)_current_theme_is_mono;
192@@ -389,8 +388,8 @@
193 bool is_default_theme)
194 {
195 glib::Object<GIcon> icon(g_icon_new_for_string(icon_name.c_str(), nullptr));
196- gtk::IconInfo info;
197- auto flags = static_cast<GtkIconLookupFlags>(0);
198+ glib::Object<GtkIconInfo> info;
199+ auto flags = GTK_ICON_LOOKUP_FORCE_SIZE;
200
201 if (icon.IsType(G_TYPE_ICON))
202 {
203
204=== modified file 'launcher/MockLauncherIcon.h'
205--- launcher/MockLauncherIcon.h 2015-04-03 14:27:47 +0000
206+++ launcher/MockLauncherIcon.h 2015-10-05 16:53:29 +0000
207@@ -32,9 +32,9 @@
208 #include <sigc++/sigc++.h>
209
210 #include <libdbusmenu-glib/menuitem.h>
211+#include <UnityCore/GLibWrapper.h>
212 #include "unity-shared/ApplicationManager.h"
213 #include "unity-shared/TimeUtil.h"
214-#include <UnityCore/GTKWrapper.h>
215
216 #include "AbstractLauncherIcon.h"
217 #include "MultiMonitor.h"
218@@ -368,7 +368,7 @@
219 nux::BaseTexture* TextureFromGtkTheme(const char* icon_name, int size)
220 {
221 GdkPixbuf* pbuf;
222- gtk::IconInfo info;
223+ glib::Object<GtkIconInfo> info;
224 nux::BaseTexture* result = NULL;
225 GError* error = NULL;
226 GIcon* icon;
227@@ -379,7 +379,7 @@
228
229 if (G_IS_ICON(icon))
230 {
231- info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, (GtkIconLookupFlags)0);
232+ info = gtk_icon_theme_lookup_by_gicon(theme, icon, size, GTK_ICON_LOOKUP_FORCE_SIZE);
233 g_object_unref(icon);
234 }
235 else
236@@ -387,7 +387,7 @@
237 info = gtk_icon_theme_lookup_icon(theme,
238 icon_name,
239 size,
240- (GtkIconLookupFlags) 0);
241+ GTK_ICON_LOOKUP_FORCE_SIZE);
242 }
243
244 if (!info)
245
246=== modified file 'panel/PanelIndicatorEntryView.cpp'
247--- panel/PanelIndicatorEntryView.cpp 2015-02-04 09:46:19 +0000
248+++ panel/PanelIndicatorEntryView.cpp 2015-10-05 16:53:29 +0000
249@@ -21,7 +21,7 @@
250 #include <Nux/Nux.h>
251 #include <NuxCore/Logger.h>
252 #include <UnityCore/ConnectionManager.h>
253-#include <UnityCore/GTKWrapper.h>
254+#include <UnityCore/GLibWrapper.h>
255
256 #include <gdk-pixbuf/gdk-pixbuf.h>
257 #include <gtk/gtk.h>
258@@ -224,8 +224,8 @@
259 case GTK_IMAGE_GICON:
260 {
261 GtkIconTheme* theme = gtk_icon_theme_get_default();
262- auto flags = static_cast<GtkIconLookupFlags>(0);
263- gtk::IconInfo info;
264+ auto flags = GTK_ICON_LOOKUP_FORCE_SIZE;
265+ glib::Object<GtkIconInfo> info;
266
267 if (image_type == GTK_IMAGE_GICON)
268 {
269
270=== modified file 'tests/CMakeLists.txt'
271--- tests/CMakeLists.txt 2015-09-30 16:32:38 +0000
272+++ tests/CMakeLists.txt 2015-10-05 16:53:29 +0000
273@@ -226,7 +226,7 @@
274 test_filter_widgets.cpp
275 test_glib_dbus_server.cpp
276 test_gnome_session_manager.cpp
277- test_gtk_wrapper.cpp
278+ test_gtk_icon_info.cpp
279 test_hud_button.cpp
280 test_hud_controller.cpp
281 test_hud_launcher_icon.cpp
282
283=== renamed file 'tests/test_gtk_wrapper.cpp' => 'tests/test_gtk_icon_info.cpp'
284--- tests/test_gtk_wrapper.cpp 2013-05-18 13:35:33 +0000
285+++ tests/test_gtk_icon_info.cpp 2015-10-05 16:53:29 +0000
286@@ -17,8 +17,9 @@
287 * Authored by: Marco Trevisan <marco.trevisan@canonical.com>
288 */
289
290+#include <gtk/gtk.h>
291 #include <gmock/gmock.h>
292-#include <UnityCore/GTKWrapper.h>
293+#include <UnityCore/GLibWrapper.h>
294
295 using namespace unity;
296 using namespace testing;
297@@ -26,23 +27,23 @@
298 namespace
299 {
300
301-TEST(TestGTKWrapper, EmptyIconInfo)
302+TEST(TestGtkIconInfo, EmptyIconInfo)
303 {
304- gtk::IconInfo info;
305+ glib::Object<GtkIconInfo> info;
306 EXPECT_THAT(info.RawPtr(), IsNull());
307 EXPECT_FALSE(info);
308 EXPECT_EQ(info, nullptr);
309 }
310
311-TEST(TestGTKWrapper, ValidIconInfo)
312+TEST(TestGtkIconInfo, ValidIconInfo)
313 {
314 GList *icons = gtk_icon_theme_list_icons(gtk_icon_theme_get_default(), "Emblems");
315
316 for (GList *l = icons; l; l = l->next)
317 {
318 auto icon_name = static_cast <const char*>(l->data);
319- GtkIconInfo *ginfo = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), icon_name, 32, (GtkIconLookupFlags) 0);
320- gtk::IconInfo info(ginfo);
321+ GtkIconInfo *ginfo = gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(), icon_name, 32, GTK_ICON_LOOKUP_FORCE_SIZE);
322+ glib::Object<GtkIconInfo> info(ginfo);
323 ASSERT_THAT(info.RawPtr(), NotNull());
324 ASSERT_TRUE(info);
325 ASSERT_EQ(info, ginfo);
326
327=== modified file 'tests/test_result_renderer.cpp'
328--- tests/test_result_renderer.cpp 2015-09-30 16:32:38 +0000
329+++ tests/test_result_renderer.cpp 2015-10-05 16:53:29 +0000
330@@ -23,7 +23,7 @@
331 #include <glib-object.h>
332
333 #include "unity-shared/DashStyle.h"
334-#include "UnityCore/GTKWrapper.h"
335+#include "UnityCore/GLibWrapper.h"
336 #include "UnityCore/Result.h"
337 #include "dash/ResultRendererTile.h"
338
339
340=== modified file 'unity-shared/IconLoader.cpp'
341--- unity-shared/IconLoader.cpp 2015-02-03 10:47:59 +0000
342+++ unity-shared/IconLoader.cpp 2015-10-05 16:53:29 +0000
343@@ -32,7 +32,7 @@
344 #include <NuxGraphics/CairoGraphics.h>
345 #include <UnityCore/GLibSource.h>
346 #include <UnityCore/GLibSignal.h>
347-#include <UnityCore/GTKWrapper.h>
348+#include <UnityCore/GLibWrapper.h>
349
350 #include "unity-shared/Timer.h"
351 #include "unity-shared/UnitySettings.h"
352@@ -84,7 +84,7 @@
353 IconLoaderCallback slot;
354 Handle handle;
355 Impl* impl;
356- gtk::IconInfo icon_info;
357+ glib::Object<GtkIconInfo> icon_info;
358 bool no_cache;
359 Handle helper_handle;
360 std::list<IconLoaderTask::Ptr> shadow_tasks;
361@@ -164,7 +164,7 @@
362 {
363 int size = max_height < 0 ? max_width : (max_width < 0 ? max_height : MIN(max_height, max_width));
364 GtkIconInfo *info = ::gtk_icon_theme_lookup_icon(impl->theme_, data.c_str(),
365- size, static_cast<GtkIconLookupFlags>(0));
366+ size, GTK_ICON_LOOKUP_FORCE_SIZE);
367 if (info)
368 {
369 icon_info = info;
370@@ -234,7 +234,7 @@
371 else if (icon.IsType(G_TYPE_ICON))
372 {
373 GtkIconInfo *info = ::gtk_icon_theme_lookup_by_gicon(impl->theme_, icon, size,
374- static_cast<GtkIconLookupFlags>(GTK_ICON_LOOKUP_FORCE_SIZE));
375+ GTK_ICON_LOOKUP_FORCE_SIZE);
376 if (info)
377 {
378 icon_info = info;