Merge lp:~tintou/wingpanel-indicator-sound/gresource into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk

Proposed by Corentin Noël
Status: Merged
Approved by: Danielle Foré
Approved revision: 137
Merged at revision: 137
Proposed branch: lp:~tintou/wingpanel-indicator-sound/gresource
Merge into: lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
Diff against target: 437 lines (+338/-16)
5 files modified
cmake/GResource.cmake (+67/-0)
data/image-mask.svg (+235/-0)
data/mask.gresource.xml (+6/-0)
src/CMakeLists.txt (+4/-1)
src/Widgets/MprisGui.vala (+26/-15)
To merge this branch: bzr merge lp:~tintou/wingpanel-indicator-sound/gresource
Reviewer Review Type Date Requested Status
Danielle Foré Needs Fixing
Review via email: mp+313515@code.launchpad.net

Commit message

* Add image_mask to gresource
* Create image_mask with gtk.overlay instead of cairo composite

To post a comment you must log in.
136. By Corentin Noël

Use its own vector assets

Revision history for this message
Danielle Foré (danrabbit) wrote :

Just a small issue here. It looks like the mask is always applied, even when using the default music player icon ;)

review: Needs Fixing
137. By Corentin Noël

Use overlay instead of hardcoded pixbufs

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'cmake/GResource.cmake'
2--- cmake/GResource.cmake 1970-01-01 00:00:00 +0000
3+++ cmake/GResource.cmake 2016-12-21 23:45:45 +0000
4@@ -0,0 +1,67 @@
5+#
6+# Copyright (C) 2013 Venom authors and contributors
7+#
8+# This file is part of Venom.
9+#
10+# Venom is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation, either version 3 of the License, or
13+# (at your option) any later version.
14+#
15+# Venom is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with Venom. If not, see <http://www.gnu.org/licenses/>.
22+#
23+
24+FIND_PROGRAM(GLIB_COMPILE_RESOURCES_EXECUTABLE NAMES glib-compile-resources)
25+MARK_AS_ADVANCED(GLIB_COMPILE_RESOURCES_EXECUTABLE)
26+
27+INCLUDE(CMakeParseArguments)
28+
29+FUNCTION(GLIB_COMPILE_RESOURCES output)
30+ CMAKE_PARSE_ARGUMENTS(ARGS "" "SOURCE" "" ${ARGN})
31+ SET(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
32+ SET(out_files "")
33+
34+ FOREACH(src ${ARGS_SOURCE} ${ARGS_UNPARSED_ARGUMENTS})
35+ SET(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
36+ GET_FILENAME_COMPONENT(WORKING_DIR ${in_file} PATH)
37+ STRING(REPLACE ".xml" ".c" src ${src})
38+ SET(out_file "${DIRECTORY}/${src}")
39+ GET_FILENAME_COMPONENT(OUPUT_DIR ${out_file} PATH)
40+ FILE(MAKE_DIRECTORY ${OUPUT_DIR})
41+ LIST(APPEND out_files "${DIRECTORY}/${src}")
42+
43+ #FIXME implicit depends currently not working
44+ EXECUTE_PROCESS(
45+ COMMAND
46+ ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
47+ "--generate-dependencies"
48+ ${in_file}
49+ WORKING_DIRECTORY ${WORKING_DIR}
50+ OUTPUT_VARIABLE in_file_dep
51+ )
52+ STRING(REGEX REPLACE "(\r?\n)" ";" in_file_dep "${in_file_dep}")
53+ SET(in_file_dep_path "")
54+ FOREACH(dep ${in_file_dep})
55+ LIST(APPEND in_file_dep_path "${WORKING_DIR}/${dep}")
56+ ENDFOREACH(dep ${in_file_dep})
57+ ADD_CUSTOM_COMMAND(
58+ OUTPUT ${out_file}
59+ WORKING_DIRECTORY ${WORKING_DIR}
60+ COMMAND
61+ ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
62+ ARGS
63+ "--generate-source"
64+ "--target=${out_file}"
65+ ${in_file}
66+ DEPENDS
67+ ${in_file};${in_file_dep_path}
68+ )
69+ ENDFOREACH(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
70+ SET(${output} ${out_files} PARENT_SCOPE)
71+ENDFUNCTION(GLIB_COMPILE_RESOURCES)
72
73=== added file 'data/image-mask.svg'
74--- data/image-mask.svg 1970-01-01 00:00:00 +0000
75+++ data/image-mask.svg 2016-12-21 23:45:45 +0000
76@@ -0,0 +1,235 @@
77+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
78+<svg
79+ xmlns:dc="http://purl.org/dc/elements/1.1/"
80+ xmlns:cc="http://creativecommons.org/ns#"
81+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
82+ xmlns:svg="http://www.w3.org/2000/svg"
83+ xmlns="http://www.w3.org/2000/svg"
84+ xmlns:xlink="http://www.w3.org/1999/xlink"
85+ width="48"
86+ height="48"
87+ id="svg2"
88+ version="1.1">
89+ <defs
90+ id="defs4">
91+ <linearGradient
92+ x1="45.447727"
93+ y1="92.539597"
94+ x2="45.447727"
95+ y2="7.0165396"
96+ id="ButtonShadow-9"
97+ gradientUnits="userSpaceOnUse"
98+ gradientTransform="scale(1.0058652,0.994169)">
99+ <stop
100+ id="stop3750-3"
101+ style="stop-color:#000000;stop-opacity:1"
102+ offset="0" />
103+ <stop
104+ id="stop3752-1"
105+ style="stop-color:#000000;stop-opacity:0.58823532"
106+ offset="1" />
107+ </linearGradient>
108+ <filter
109+ id="filter3174-4"
110+ style="color-interpolation-filters:sRGB">
111+ <feGaussianBlur
112+ id="feGaussianBlur3176-5"
113+ stdDeviation="1.71" />
114+ </filter>
115+ <linearGradient
116+ x1="45.447727"
117+ y1="92.539597"
118+ x2="45.447727"
119+ y2="7.0165396"
120+ id="ButtonShadow"
121+ gradientUnits="userSpaceOnUse"
122+ gradientTransform="scale(1.0058652,0.994169)">
123+ <stop
124+ id="stop3750-9"
125+ style="stop-color:#000000;stop-opacity:1"
126+ offset="0" />
127+ <stop
128+ id="stop3752-7"
129+ style="stop-color:#000000;stop-opacity:0.58823532"
130+ offset="1" />
131+ </linearGradient>
132+ <filter
133+ id="filter3174"
134+ style="color-interpolation-filters:sRGB">
135+ <feGaussianBlur
136+ id="feGaussianBlur3176"
137+ stdDeviation="1.71" />
138+ </filter>
139+ <linearGradient
140+ xlink:href="#ButtonShadow-9"
141+ id="linearGradient6176"
142+ gradientUnits="userSpaceOnUse"
143+ gradientTransform="scale(1.0058652,0.994169)"
144+ x1="45.447727"
145+ y1="92.539597"
146+ x2="45.447727"
147+ y2="7.0165396" />
148+ <linearGradient
149+ xlink:href="#ButtonShadow"
150+ id="linearGradient6178"
151+ gradientUnits="userSpaceOnUse"
152+ gradientTransform="scale(1.0058652,0.994169)"
153+ x1="45.447727"
154+ y1="92.539597"
155+ x2="45.447727"
156+ y2="7.0165396" />
157+ <linearGradient
158+ id="linearGradient3688-464-309-9-2-4-2">
159+ <stop
160+ offset="0"
161+ style="stop-color:#181818;stop-opacity:1"
162+ id="stop2889-7-9-6-9" />
163+ <stop
164+ offset="1"
165+ style="stop-color:#181818;stop-opacity:0"
166+ id="stop2891-6-6-1-7" />
167+ </linearGradient>
168+ <linearGradient
169+ gradientTransform="matrix(1.1578952,0,0,0.6428571,-3.78948,16.2857)"
170+ gradientUnits="userSpaceOnUse"
171+ xlink:href="#linearGradient3702-501-757-8-4-1-1-9"
172+ id="linearGradient6084"
173+ y2="39.999443"
174+ x2="25.058096"
175+ y1="47.027729"
176+ x1="25.058096" />
177+ <linearGradient
178+ id="linearGradient3702-501-757-8-4-1-1-9">
179+ <stop
180+ offset="0"
181+ style="stop-color:#181818;stop-opacity:0"
182+ id="stop2895-8-9-9-1-4" />
183+ <stop
184+ offset="0.5"
185+ style="stop-color:#181818;stop-opacity:1"
186+ id="stop2897-7-8-7-7-3" />
187+ <stop
188+ offset="1"
189+ style="stop-color:#181818;stop-opacity:0"
190+ id="stop2899-4-5-1-5-6" />
191+ </linearGradient>
192+ <linearGradient
193+ gradientTransform="translate(0,1)"
194+ gradientUnits="userSpaceOnUse"
195+ xlink:href="#linearGradient3924-1-7-54"
196+ id="linearGradient3028-82"
197+ y2="43"
198+ x2="23.99999"
199+ y1="4.999989"
200+ x1="23.99999" />
201+ <linearGradient
202+ id="linearGradient3924-1-7-54">
203+ <stop
204+ offset="0"
205+ style="stop-color:#ffffff;stop-opacity:1"
206+ id="stop3926-3-4-4" />
207+ <stop
208+ offset="0.06316455"
209+ style="stop-color:#ffffff;stop-opacity:0.23529412"
210+ id="stop3928-91-41-8" />
211+ <stop
212+ offset="0.95056331"
213+ style="stop-color:#ffffff;stop-opacity:0.15686275"
214+ id="stop3930-6-6-6" />
215+ <stop
216+ offset="1"
217+ style="stop-color:#ffffff;stop-opacity:0.39215687"
218+ id="stop3932-6-6-7" />
219+ </linearGradient>
220+ <radialGradient
221+ gradientTransform="matrix(2.3201719,0,0,0.89999994,28.617841,5.0999865)"
222+ gradientUnits="userSpaceOnUse"
223+ xlink:href="#linearGradient3688-464-309-9-2-4-2"
224+ id="radialGradient3013-3"
225+ fy="43.5"
226+ fx="4.9929786"
227+ r="2.5"
228+ cy="43.5"
229+ cx="4.9929786" />
230+ <radialGradient
231+ gradientTransform="matrix(-2.3201719,0,0,-0.89999994,19.382168,83.399981)"
232+ gradientUnits="userSpaceOnUse"
233+ xlink:href="#linearGradient3688-464-309-9-2-4-2"
234+ id="radialGradient3015-3"
235+ fy="43.5"
236+ fx="4.9929786"
237+ r="2.5"
238+ cy="43.5"
239+ cx="4.9929786" />
240+ </defs>
241+ <metadata
242+ id="metadata7">
243+ <rdf:RDF>
244+ <cc:Work
245+ rdf:about="">
246+ <dc:format>image/svg+xml</dc:format>
247+ <dc:type
248+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
249+ <dc:title></dc:title>
250+ </cc:Work>
251+ </rdf:RDF>
252+ </metadata>
253+ <g
254+ transform="translate(906.27272,-451.79544)"
255+ style="display:none"
256+ id="layer2">
257+ <rect
258+ style="opacity:0.9;fill:url(#linearGradient6178);fill-opacity:1;fill-rule:nonzero;stroke:none;filter:url(#filter3174)"
259+ id="rect3745"
260+ y="7"
261+ x="5"
262+ ry="6"
263+ rx="6"
264+ height="85"
265+ width="86" />
266+ </g>
267+ <g
268+ transform="translate(903,-452.15908)"
269+ style="display:none"
270+ id="layer2-4">
271+ <rect
272+ style="opacity:0.9;fill:url(#linearGradient6176);fill-opacity:1;fill-rule:nonzero;stroke:none;filter:url(#filter3174-4)"
273+ id="rect3745-5"
274+ y="7"
275+ x="5"
276+ ry="6"
277+ rx="6"
278+ height="85"
279+ width="86" />
280+ </g>
281+ <rect
282+ width="37"
283+ height="37"
284+ rx="1"
285+ ry="1"
286+ x="5.5"
287+ y="6.4999828"
288+ id="rect6741-11-6"
289+ style="opacity:0.4;fill:none;stroke:url(#linearGradient3028-82);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
290+ <rect
291+ width="39"
292+ height="39"
293+ rx="2"
294+ ry="2"
295+ x="4.5"
296+ y="5.4999828"
297+ id="rect5505-21-3-2-7-4"
298+ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.3;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
299+ <path
300+ id="rect4188"
301+ d="M 7.7890625 45 L 7.7890625 46.5 L 40.210938 46.5 L 40.210938 45 L 7.7890625 45 z "
302+ style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.3;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:url(#linearGradient6084);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate;filter-blend-mode:normal;filter-gaussianBlur-deviation:0" />
303+ <path
304+ id="rect2801-3"
305+ d="M 44 42 L 44 42.5 C 44 43.885 42.885 45 41.5 45 L 40.210938 45 L 40.210938 46.5 L 46 46.5 L 46 42 L 44 42 z "
306+ style="fill:url(#radialGradient3013-3);fill-opacity:1;stroke:none;opacity:0.3" />
307+ <path
308+ id="rect3696-6"
309+ d="M 2 42 L 2 46.5 L 7.7890625 46.5 L 7.7890625 45 L 6.5 45 C 5.115 45 4 43.885 4 42.5 L 4 42 L 2 42 z "
310+ style="fill:url(#radialGradient3015-3);fill-opacity:1;stroke:none;opacity:0.3" />
311+</svg>
312
313=== added file 'data/mask.gresource.xml'
314--- data/mask.gresource.xml 1970-01-01 00:00:00 +0000
315+++ data/mask.gresource.xml 2016-12-21 23:45:45 +0000
316@@ -0,0 +1,6 @@
317+<?xml version="1.0" encoding="UTF-8"?>
318+<gresources>
319+ <gresource prefix="/io/elementary/wingpanel/sound">
320+ <file compressed="true" preprocess="xml-stripblanks">image-mask.svg</file>
321+ </gresource>
322+</gresources>
323
324=== modified file 'src/CMakeLists.txt'
325--- src/CMakeLists.txt 2016-11-07 15:14:18 +0000
326+++ src/CMakeLists.txt 2016-12-21 23:45:45 +0000
327@@ -34,7 +34,10 @@
328 --thread
329 )
330
331-add_library (${CMAKE_PROJECT_NAME} MODULE ${VALA_C})
332+include (GResource)
333+glib_compile_resources (GLIB_RESOURCES_MASK ../data/mask.gresource.xml)
334+
335+add_library (${CMAKE_PROJECT_NAME} MODULE ${VALA_C} ${GLIB_RESOURCES_MASK})
336 target_link_libraries(${CMAKE_PROJECT_NAME} ${DEPS_LIBRARIES})
337
338 # Installation
339
340=== modified file 'src/Widgets/MprisGui.vala'
341--- src/Widgets/MprisGui.vala 2016-11-07 15:14:18 +0000
342+++ src/Widgets/MprisGui.vala 2016-12-21 23:45:45 +0000
343@@ -27,6 +27,7 @@
344
345 private Gtk.Revealer player_revealer;
346 private Gtk.Image? background = null;
347+ private Gtk.Image mask;
348 private Gtk.Label title_label;
349 private Gtk.Label artist_label;
350 private Gtk.Button prev_btn;
351@@ -146,15 +147,20 @@
352 var player_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
353
354 background = new Gtk.Image ();
355-
356- background.margin_start = 4;
357- background.margin_end = 4;
358- background.margin_bottom = 2;
359- background.can_focus = true;
360+ mask = new Gtk.Image.from_resource ("/io/elementary/wingpanel/sound/image-mask.svg");
361+ mask.no_show_all = true;
362+ mask.pixel_size = 48;
363+ var overlay = new Gtk.Overlay ();
364+ overlay.add (background);
365+ overlay.add_overlay (mask);
366+ overlay.margin_start = 4;
367+ overlay.margin_end = 4;
368+ overlay.margin_bottom = 2;
369+ overlay.can_focus = true;
370 var background_box = new Gtk.EventBox ();
371 background_box.add_events (Gdk.EventMask.BUTTON_PRESS_MASK);
372 background_box.button_press_event.connect (raise_player);
373- background_box.add (background);
374+ background_box.add (overlay);
375 player_box.pack_start (background_box, false, false, 0);
376
377 var titles_events = new Gtk.EventBox ();
378@@ -388,6 +394,8 @@
379 private void update_art (string uri) {
380 if (!uri.has_prefix ("file://") && !uri.has_prefix ("http")) {
381 background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG);
382+ mask.no_show_all = true;
383+ mask.hide ();
384 return;
385 }
386 if (uri.has_prefix ("file://")) {
387@@ -395,6 +403,8 @@
388 try {
389 var pbuf = new Gdk.Pixbuf.from_file_at_size (fname, ICON_SIZE, ICON_SIZE);
390 background.set_from_pixbuf (mask_pixbuf (pbuf));
391+ mask.no_show_all = false;
392+ mask.show ();
393 } catch (Error e) {
394 //background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG);
395 }
396@@ -409,11 +419,16 @@
397 GLib.File file = GLib.File.new_for_uri (uri);
398 try {
399 GLib.InputStream stream = yield file.read_async (Priority.DEFAULT, load_remote_art_cancel);
400- Gdk.Pixbuf pixbuf = yield new Gdk.Pixbuf.from_stream_at_scale_async
401- (stream, ICON_SIZE, ICON_SIZE, true, load_remote_art_cancel);
402- background.set_from_pixbuf (mask_pixbuf (pixbuf));
403+ Gdk.Pixbuf pixbuf = yield new Gdk.Pixbuf.from_stream_async (stream, load_remote_art_cancel);
404+ if (pixbuf != null) {
405+ background.set_from_pixbuf (mask_pixbuf (pixbuf));
406+ mask.no_show_all = false;
407+ mask.show ();
408+ }
409 } catch (Error e) {
410 background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG);
411+ mask.no_show_all = true;
412+ mask.hide ();
413 }
414 }
415
416@@ -430,6 +445,8 @@
417 last_artUrl = "";
418 background.pixel_size = ICON_SIZE;
419 background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG);
420+ mask.no_show_all = true;
421+ mask.hide ();
422 }
423
424 string title;
425@@ -474,12 +491,6 @@
426 Gdk.cairo_set_source_pixbuf (cr, input, offset_x, offset_y);
427 cr.paint ();
428
429- cr.reset_clip ();
430-
431- var mask = new Cairo.ImageSurface.from_png ("/usr/share/gala/image-mask.png");
432- cr.set_source_surface (mask, 0, 0);
433- cr.paint ();
434-
435 return Gdk.pixbuf_get_from_surface (surface, 0, 0, mask_size, mask_size);
436 }
437 }

Subscribers

People subscribed via source and target branches

to all changes: