testTool: Replace icons on scroll events
Go through the scrolling event actions and based on that update the icon.
Marco Trevisan (TreviƱo)
3 years ago
25 | 25 | 'emoji-food-symbolic', |
26 | 26 | ]; |
27 | 27 | |
28 | const ScrollType = { | |
29 | UP: 0, | |
30 | DOWN: 1, | |
31 | }; | |
32 | ||
28 | 33 | (() => { |
29 | 34 | |
30 | 35 | var app = new Gtk.Application({ |
213 | 218 | }); |
214 | 219 | indicator.connect("scroll-event", (indicator, steps, direction) => { |
215 | 220 | print(`Signal \"scroll-event\" emitted. Steps: ${steps}, Direction: ${direction}`); |
221 | let currentIndex = iconsPool.indexOf(indicator.get_icon()); | |
222 | let iconIndex; | |
223 | ||
224 | if (direction == ScrollType.UP) { | |
225 | iconIndex = (currentIndex + 1) % iconsPool.length; | |
226 | } else { | |
227 | iconIndex = (currentIndex <= 0 ? iconsPool.length : currentIndex) - 1; | |
228 | } | |
229 | ||
230 | indicator.set_icon(iconsPool[iconIndex]); | |
216 | 231 | }); |
217 | 232 | }); |
218 | 233 | app.run(ARGV); |