Merge lp:~philip.scott/wingpanel-indicator-sound/mpris-gui-gobject into lp:~wingpanel-devs/wingpanel-indicator-sound/trunk
- mpris-gui-gobject
- Merge into trunk
Proposed by
Felipe Escoto
Status: | Merged |
---|---|
Approved by: | Djax |
Approved revision: | 124 |
Merged at revision: | 123 |
Proposed branch: | lp:~philip.scott/wingpanel-indicator-sound/mpris-gui-gobject |
Merge into: | lp:~wingpanel-devs/wingpanel-indicator-sound/trunk |
Prerequisite: | lp:~philip.scott/wingpanel-indicator-sound/remember-last-player |
Diff against target: |
416 lines (+119/-102) 4 files modified
src/Indicator.vala (+1/-1) src/Services/Settings.vala (+10/-0) src/Widgets/MprisGui.vala (+103/-97) src/Widgets/MprisWidget.vala (+5/-4) |
To merge this branch: | bzr merge lp:~philip.scott/wingpanel-indicator-sound/mpris-gui-gobject |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Djax | Approve | ||
Review via email: mp+309089@code.launchpad.net |
Commit message
mprisGUI to GObject Style. There should be no changes to functionality
Description of the change
Updates MprisGui.vala code to use gobject style construction and properties
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/Indicator.vala' | |||
2 | --- src/Indicator.vala 2016-09-09 21:03:14 +0000 | |||
3 | +++ src/Indicator.vala 2016-10-23 14:46:21 +0000 | |||
4 | @@ -271,7 +271,7 @@ | |||
5 | 271 | int position = 0; | 271 | int position = 0; |
6 | 272 | main_grid = new Gtk.Grid (); | 272 | main_grid = new Gtk.Grid (); |
7 | 273 | 273 | ||
9 | 274 | var mpris = new Widgets.MprisWidget (settings); | 274 | var mpris = new Widgets.MprisWidget (); |
10 | 275 | 275 | ||
11 | 276 | mpris.close.connect (() => { | 276 | mpris.close.connect (() => { |
12 | 277 | close (); | 277 | close (); |
13 | 278 | 278 | ||
14 | === modified file 'src/Services/Settings.vala' | |||
15 | --- src/Services/Settings.vala 2015-06-09 18:43:23 +0000 | |||
16 | +++ src/Services/Settings.vala 2016-10-23 14:46:21 +0000 | |||
17 | @@ -20,7 +20,17 @@ | |||
18 | 20 | public double max_volume { get; set; } | 20 | public double max_volume { get; set; } |
19 | 21 | public string[] last_title_info { get; set; } | 21 | public string[] last_title_info { get; set; } |
20 | 22 | 22 | ||
21 | 23 | private static Sound.Services.Settings? instance = null; | ||
22 | 24 | |||
23 | 23 | public Settings () { | 25 | public Settings () { |
24 | 24 | base ("org.pantheon.desktop.wingpanel.indicators.sound"); | 26 | base ("org.pantheon.desktop.wingpanel.indicators.sound"); |
25 | 25 | } | 27 | } |
26 | 28 | |||
27 | 29 | public static Sound.Services.Settings get_instance () { | ||
28 | 30 | if (instance == null) { | ||
29 | 31 | instance = new Sound.Services.Settings (); | ||
30 | 32 | } | ||
31 | 33 | |||
32 | 34 | return instance; | ||
33 | 35 | } | ||
34 | 26 | } | 36 | } |
35 | 27 | 37 | ||
36 | === modified file 'src/Widgets/MprisGui.vala' | |||
37 | --- src/Widgets/MprisGui.vala 2016-10-23 14:46:21 +0000 | |||
38 | +++ src/Widgets/MprisGui.vala 2016-10-23 14:46:21 +0000 | |||
39 | @@ -3,7 +3,7 @@ | |||
40 | 3 | * | 3 | * |
41 | 4 | * Copyright | 4 | * Copyright |
42 | 5 | * 2014 Ikey Doherty <ikey.doherty@gmail.com> | 5 | * 2014 Ikey Doherty <ikey.doherty@gmail.com> |
44 | 6 | * 2015 Wingpanel Developers | 6 | * 2016 Wingpanel Developers |
45 | 7 | * | 7 | * |
46 | 8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
47 | 9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
48 | @@ -23,26 +23,85 @@ | |||
49 | 23 | public class Sound.Widgets.ClientWidget : Gtk.Box { | 23 | public class Sound.Widgets.ClientWidget : Gtk.Box { |
50 | 24 | private const string NOT_PLAYING = _("Not currently playing"); | 24 | private const string NOT_PLAYING = _("Not currently playing"); |
51 | 25 | 25 | ||
52 | 26 | public signal void close (); | ||
53 | 27 | |||
54 | 28 | private Gtk.Revealer player_revealer; | ||
55 | 29 | private Gtk.Image? background = null; | ||
56 | 30 | private Gtk.Label title_label; | ||
57 | 31 | private Gtk.Label artist_label; | ||
58 | 32 | private Gtk.Button prev_btn; | ||
59 | 33 | private Gtk.Button play_btn; | ||
60 | 34 | private Gtk.Button next_btn; | ||
61 | 35 | private Icon? app_icon = null; | ||
62 | 36 | private Cancellable load_remote_art_cancel; | ||
63 | 37 | |||
64 | 38 | private bool launched_by_indicator = false; | ||
65 | 39 | private string app_name = _("Music player"); | ||
66 | 40 | private string last_artUrl; | ||
67 | 41 | |||
68 | 26 | public string mpris_name = ""; | 42 | public string mpris_name = ""; |
69 | 27 | 43 | ||
88 | 28 | Gtk.Revealer player_revealer; | 44 | private AppInfo? ainfo; |
89 | 29 | Gtk.Image? background = null; | 45 | |
90 | 30 | public Services.MprisClient? client = null; | 46 | public AppInfo? app_info { |
91 | 31 | Services.Settings settings; | 47 | get { |
92 | 32 | 48 | return ainfo; | |
93 | 33 | Gtk.Label title_label; | 49 | } set { |
94 | 34 | Gtk.Label artist_label; | 50 | ainfo = value; |
95 | 35 | Gtk.Button prev_btn; | 51 | if (ainfo != null) { |
96 | 36 | Gtk.Button play_btn; | 52 | app_name = ainfo.get_display_name (); |
97 | 37 | Gtk.Button next_btn; | 53 | if (app_name == "") { |
98 | 38 | AppInfo? ainfo; | 54 | app_name = ainfo.get_name (); |
99 | 39 | Icon? app_icon = null; | 55 | } |
100 | 40 | string app_name = _("Music player"); | 56 | |
101 | 41 | Cancellable load_remote_art_cancel; | 57 | app_icon = value.get_icon (); |
102 | 42 | string last_artUrl; | 58 | if (app_icon == null) { |
103 | 43 | bool launched_by_indicator = false; | 59 | app_icon = new ThemedIcon ("application-default-icon"); |
104 | 44 | 60 | } | |
105 | 45 | public signal void close (); | 61 | |
106 | 62 | background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG); | ||
107 | 63 | } | ||
108 | 64 | } | ||
109 | 65 | } | ||
110 | 66 | |||
111 | 67 | private Services.MprisClient? client_ = null; | ||
112 | 68 | |||
113 | 69 | public Services.MprisClient? client { | ||
114 | 70 | get { | ||
115 | 71 | return client_; | ||
116 | 72 | } set { | ||
117 | 73 | this.client_ = value; | ||
118 | 74 | if (value != null) { | ||
119 | 75 | if (client.player.desktop_entry != "") { | ||
120 | 76 | app_info = new DesktopAppInfo (client.player.desktop_entry + ".desktop"); | ||
121 | 77 | } | ||
122 | 78 | |||
123 | 79 | connect_to_client (); | ||
124 | 80 | update_play_status (); | ||
125 | 81 | update_from_meta (); | ||
126 | 82 | update_controls (); | ||
127 | 83 | |||
128 | 84 | if (launched_by_indicator) { | ||
129 | 85 | Idle.add (()=> { | ||
130 | 86 | try { | ||
131 | 87 | launched_by_indicator = false; | ||
132 | 88 | client.player.play_pause (); | ||
133 | 89 | } catch (Error e) { | ||
134 | 90 | warning ("Could not play/pause: %s", e.message); | ||
135 | 91 | } | ||
136 | 92 | |||
137 | 93 | return false; | ||
138 | 94 | }); | ||
139 | 95 | } | ||
140 | 96 | } else { | ||
141 | 97 | (play_btn.get_image () as Gtk.Image).set_from_icon_name ("media-playback-start-symbolic", Gtk.IconSize.LARGE_TOOLBAR); | ||
142 | 98 | prev_btn.set_sensitive (false); | ||
143 | 99 | next_btn.set_sensitive (false); | ||
144 | 100 | Sound.Services.Settings.get_instance ().last_title_info = {app_info.get_id (), title_label.get_text (), artist_label.get_text (), last_artUrl}; | ||
145 | 101 | this.mpris_name = ""; | ||
146 | 102 | } | ||
147 | 103 | } | ||
148 | 104 | } | ||
149 | 46 | 105 | ||
150 | 47 | /** | 106 | /** |
151 | 48 | * Create a new ClientWidget | 107 | * Create a new ClientWidget |
152 | @@ -50,67 +109,42 @@ | |||
153 | 50 | * @param client The underlying MprisClient instance to use | 109 | * @param client The underlying MprisClient instance to use |
154 | 51 | */ | 110 | */ |
155 | 52 | public ClientWidget (Services.MprisClient mpris_client) { | 111 | public ClientWidget (Services.MprisClient mpris_client) { |
176 | 53 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 0); | 112 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 0, client: mpris_client); |
157 | 54 | this.client = mpris_client; | ||
158 | 55 | |||
159 | 56 | load_remote_art_cancel = new Cancellable (); | ||
160 | 57 | |||
161 | 58 | if (client.player.desktop_entry != "") { | ||
162 | 59 | ainfo = new DesktopAppInfo (client.player.desktop_entry + ".desktop"); | ||
163 | 60 | if (ainfo != null) { | ||
164 | 61 | app_icon = ainfo.get_icon (); | ||
165 | 62 | app_name = ainfo.get_display_name (); | ||
166 | 63 | if (app_name == "") { | ||
167 | 64 | app_name = ainfo.get_name (); | ||
168 | 65 | } | ||
169 | 66 | } | ||
170 | 67 | } | ||
171 | 68 | if (app_icon == null) { | ||
172 | 69 | app_icon = new ThemedIcon ("application-default-icon"); | ||
173 | 70 | } | ||
174 | 71 | |||
175 | 72 | create_ui (); | ||
177 | 73 | } | 113 | } |
178 | 74 | 114 | ||
179 | 75 | /** | 115 | /** |
180 | 76 | * Create a new ClientWidget for the default player | 116 | * Create a new ClientWidget for the default player |
181 | 77 | * | 117 | * |
182 | 78 | * @param info The AppInfo of the default music player | 118 | * @param info The AppInfo of the default music player |
183 | 79 | * @param settings Sound indicator settings | ||
184 | 80 | */ | 119 | */ |
200 | 81 | public ClientWidget.default (AppInfo info, Services.Settings settings) { | 120 | public ClientWidget.default (AppInfo info) { |
201 | 82 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 0); | 121 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 0, app_info: info, client: null); |
202 | 83 | 122 | ||
203 | 84 | this.client = null; | 123 | if (Sound.Services.Settings.get_instance ().last_title_info.length == 4) { |
204 | 85 | this.settings = settings; | 124 | string[] title_info = Sound.Services.Settings.get_instance ().last_title_info; |
205 | 86 | load_remote_art_cancel = new Cancellable (); | 125 | if (title_info[0] == app_info.get_id ()) { |
191 | 87 | |||
192 | 88 | ainfo = info; | ||
193 | 89 | app_icon = ainfo.get_icon (); | ||
194 | 90 | app_name = ainfo.get_display_name (); | ||
195 | 91 | |||
196 | 92 | create_ui (); | ||
197 | 93 | if (settings.last_title_info.length == 4) { | ||
198 | 94 | string[] title_info = settings.last_title_info; | ||
199 | 95 | if (title_info[0] == ainfo.get_id ()) { | ||
206 | 96 | title_label.set_markup ("<b>%s</b>".printf (Markup.escape_text (title_info[1]))); | 126 | title_label.set_markup ("<b>%s</b>".printf (Markup.escape_text (title_info[1]))); |
207 | 97 | artist_label.set_text (title_info[2]); | 127 | artist_label.set_text (title_info[2]); |
208 | 98 | if (title_info[3] != "") { | 128 | if (title_info[3] != "") { |
209 | 99 | update_art (title_info[3]); | 129 | update_art (title_info[3]); |
210 | 100 | } | 130 | } |
211 | 131 | |||
212 | 101 | return; | 132 | return; |
213 | 102 | } | 133 | } |
214 | 103 | } | 134 | } |
215 | 135 | |||
216 | 104 | title_label.set_markup ("<b>%s</b>".printf (Markup.escape_text (app_name))); | 136 | title_label.set_markup ("<b>%s</b>".printf (Markup.escape_text (app_name))); |
217 | 105 | artist_label.set_text (NOT_PLAYING); | 137 | artist_label.set_text (NOT_PLAYING); |
218 | 106 | } | 138 | } |
219 | 107 | 139 | ||
221 | 108 | private void create_ui () { | 140 | construct { |
222 | 141 | load_remote_art_cancel = new Cancellable (); | ||
223 | 142 | |||
224 | 109 | player_revealer = new Gtk.Revealer (); | 143 | player_revealer = new Gtk.Revealer (); |
225 | 110 | player_revealer.reveal_child = true; | 144 | player_revealer.reveal_child = true; |
226 | 111 | var player_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); | 145 | var player_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
227 | 112 | 146 | ||
229 | 113 | background = new Gtk.Image.from_gicon (app_icon, Gtk.IconSize.DIALOG); | 147 | background = new Gtk.Image (); |
230 | 114 | 148 | ||
231 | 115 | background.margin_start = 4; | 149 | background.margin_start = 4; |
232 | 116 | background.margin_end = 4; | 150 | background.margin_end = 4; |
233 | @@ -148,7 +182,7 @@ | |||
234 | 148 | prev_btn = btn; | 182 | prev_btn = btn; |
235 | 149 | btn.clicked.connect (()=> { | 183 | btn.clicked.connect (()=> { |
236 | 150 | Idle.add (()=> { | 184 | Idle.add (()=> { |
238 | 151 | if (client.player.can_go_previous) { | 185 | if (client.player.can_go_previous) { |
239 | 152 | if(!Thread.supported ()) { | 186 | if(!Thread.supported ()) { |
240 | 153 | warning ("Threading is not supported. DBus timeout could be blocking UI"); | 187 | warning ("Threading is not supported. DBus timeout could be blocking UI"); |
241 | 154 | try { | 188 | try { |
242 | @@ -170,6 +204,7 @@ | |||
243 | 170 | return false; | 204 | return false; |
244 | 171 | }); | 205 | }); |
245 | 172 | }); | 206 | }); |
246 | 207 | |||
247 | 173 | controls.pack_start (btn, false, false, 0); | 208 | controls.pack_start (btn, false, false, 0); |
248 | 174 | 209 | ||
249 | 175 | btn = make_control_button ("media-playback-start-symbolic"); | 210 | btn = make_control_button ("media-playback-start-symbolic"); |
250 | @@ -197,6 +232,7 @@ | |||
251 | 197 | return false; | 232 | return false; |
252 | 198 | }); | 233 | }); |
253 | 199 | }); | 234 | }); |
254 | 235 | |||
255 | 200 | controls.pack_start (btn, false, false, 0); | 236 | controls.pack_start (btn, false, false, 0); |
256 | 201 | 237 | ||
257 | 202 | btn = make_control_button ("media-skip-forward-symbolic"); | 238 | btn = make_control_button ("media-skip-forward-symbolic"); |
258 | @@ -225,6 +261,7 @@ | |||
259 | 225 | return false; | 261 | return false; |
260 | 226 | }); | 262 | }); |
261 | 227 | }); | 263 | }); |
262 | 264 | |||
263 | 228 | controls.pack_start (btn, false, false, 0); | 265 | controls.pack_start (btn, false, false, 0); |
264 | 229 | 266 | ||
265 | 230 | controls.set_halign (Gtk.Align.CENTER); | 267 | controls.set_halign (Gtk.Align.CENTER); |
266 | @@ -233,7 +270,6 @@ | |||
267 | 233 | 270 | ||
268 | 234 | player_box.pack_end (controls, false, false, 0); | 271 | player_box.pack_end (controls, false, false, 0); |
269 | 235 | 272 | ||
270 | 236 | |||
271 | 237 | if (client != null) { | 273 | if (client != null) { |
272 | 238 | connect_to_client (); | 274 | connect_to_client (); |
273 | 239 | update_play_status (); | 275 | update_play_status (); |
274 | @@ -245,36 +281,6 @@ | |||
275 | 245 | pack_start (player_revealer); | 281 | pack_start (player_revealer); |
276 | 246 | } | 282 | } |
277 | 247 | 283 | ||
278 | 248 | public void set_client (string name, Services.MprisClient client) { | ||
279 | 249 | this.mpris_name = name; | ||
280 | 250 | this.client = client; | ||
281 | 251 | connect_to_client (); | ||
282 | 252 | update_play_status (); | ||
283 | 253 | update_from_meta (); | ||
284 | 254 | update_controls (); | ||
285 | 255 | if (launched_by_indicator) { | ||
286 | 256 | Idle.add (()=> { | ||
287 | 257 | try { | ||
288 | 258 | launched_by_indicator = false; | ||
289 | 259 | client.player.play_pause (); | ||
290 | 260 | } catch (Error e) { | ||
291 | 261 | warning ("Could not play/pause: %s", e.message); | ||
292 | 262 | } | ||
293 | 263 | return false; | ||
294 | 264 | }); | ||
295 | 265 | } | ||
296 | 266 | } | ||
297 | 267 | |||
298 | 268 | public void remove_client () { | ||
299 | 269 | (play_btn.get_image () as Gtk.Image).set_from_icon_name ("media-playback-start-symbolic", Gtk.IconSize.LARGE_TOOLBAR); | ||
300 | 270 | prev_btn.set_sensitive (false); | ||
301 | 271 | next_btn.set_sensitive (false); | ||
302 | 272 | settings.last_title_info = {ainfo.get_id (), title_label.get_text (), artist_label.get_text (), last_artUrl}; | ||
303 | 273 | |||
304 | 274 | this.client = null; | ||
305 | 275 | this.mpris_name = ""; | ||
306 | 276 | } | ||
307 | 277 | |||
308 | 278 | private void connect_to_client () { | 284 | private void connect_to_client () { |
309 | 279 | client.prop.properties_changed.connect ((i,p,inv)=> { | 285 | client.prop.properties_changed.connect ((i,p,inv)=> { |
310 | 280 | if (i == "org.mpris.MediaPlayer2.Player") { | 286 | if (i == "org.mpris.MediaPlayer2.Player") { |
311 | @@ -322,8 +328,8 @@ | |||
312 | 322 | return null; | 328 | return null; |
313 | 323 | }); | 329 | }); |
314 | 324 | } | 330 | } |
317 | 325 | } else if (ainfo != null) { | 331 | } else if (app_info != null) { |
318 | 326 | ainfo.launch (null, null); | 332 | app_info.launch (null, null); |
319 | 327 | } | 333 | } |
320 | 328 | } catch (Error e) { | 334 | } catch (Error e) { |
321 | 329 | warning ("Could not launch player"); | 335 | warning ("Could not launch player"); |
322 | @@ -355,7 +361,7 @@ | |||
323 | 355 | /** | 361 | /** |
324 | 356 | * Update play status based on player requirements | 362 | * Update play status based on player requirements |
325 | 357 | */ | 363 | */ |
327 | 358 | void update_play_status () { | 364 | private void update_play_status () { |
328 | 359 | switch (client.player.playback_status) { | 365 | switch (client.player.playback_status) { |
329 | 360 | case "Playing": | 366 | case "Playing": |
330 | 361 | (play_btn.get_image () as Gtk.Image).set_from_icon_name ("media-playback-pause-symbolic", Gtk.IconSize.LARGE_TOOLBAR); | 367 | (play_btn.get_image () as Gtk.Image).set_from_icon_name ("media-playback-pause-symbolic", Gtk.IconSize.LARGE_TOOLBAR); |
331 | @@ -370,7 +376,7 @@ | |||
332 | 370 | /** | 376 | /** |
333 | 371 | * Update prev/next sensitivity based on player requirements | 377 | * Update prev/next sensitivity based on player requirements |
334 | 372 | */ | 378 | */ |
336 | 373 | void update_controls () { | 379 | private void update_controls () { |
337 | 374 | prev_btn.set_sensitive (client.player.can_go_previous); | 380 | prev_btn.set_sensitive (client.player.can_go_previous); |
338 | 375 | next_btn.set_sensitive (client.player.can_go_next); | 381 | next_btn.set_sensitive (client.player.can_go_next); |
339 | 376 | } | 382 | } |
340 | @@ -378,7 +384,7 @@ | |||
341 | 378 | /** | 384 | /** |
342 | 379 | * Utility, handle updating the album art | 385 | * Utility, handle updating the album art |
343 | 380 | */ | 386 | */ |
345 | 381 | void update_art (string uri) { | 387 | private void update_art (string uri) { |
346 | 382 | if (!uri.has_prefix ("file://") && !uri.has_prefix ("http")) { | 388 | if (!uri.has_prefix ("file://") && !uri.has_prefix ("http")) { |
347 | 383 | background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG); | 389 | background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG); |
348 | 384 | return; | 390 | return; |
349 | @@ -389,7 +395,7 @@ | |||
350 | 389 | var pbuf = new Gdk.Pixbuf.from_file_at_size (fname, ICON_SIZE, ICON_SIZE); | 395 | var pbuf = new Gdk.Pixbuf.from_file_at_size (fname, ICON_SIZE, ICON_SIZE); |
351 | 390 | background.set_from_pixbuf (mask_pixbuf (pbuf)); | 396 | background.set_from_pixbuf (mask_pixbuf (pbuf)); |
352 | 391 | } catch (Error e) { | 397 | } catch (Error e) { |
354 | 392 | background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG); | 398 | //background.set_from_gicon (app_icon, Gtk.IconSize.DIALOG); |
355 | 393 | } | 399 | } |
356 | 394 | } else { | 400 | } else { |
357 | 395 | load_remote_art_cancel.cancel (); | 401 | load_remote_art_cancel.cancel (); |
358 | @@ -398,7 +404,7 @@ | |||
359 | 398 | } | 404 | } |
360 | 399 | } | 405 | } |
361 | 400 | 406 | ||
363 | 401 | async void load_remote_art (string uri) { | 407 | private async void load_remote_art (string uri) { |
364 | 402 | GLib.File file = GLib.File.new_for_uri (uri); | 408 | GLib.File file = GLib.File.new_for_uri (uri); |
365 | 403 | try { | 409 | try { |
366 | 404 | GLib.InputStream stream = yield file.read_async (Priority.DEFAULT, load_remote_art_cancel); | 410 | GLib.InputStream stream = yield file.read_async (Priority.DEFAULT, load_remote_art_cancel); |
367 | @@ -445,7 +451,7 @@ | |||
368 | 445 | } | 451 | } |
369 | 446 | } | 452 | } |
370 | 447 | 453 | ||
372 | 448 | static Gdk.Pixbuf? mask_pixbuf (Gdk.Pixbuf pixbuf) { | 454 | private static Gdk.Pixbuf? mask_pixbuf (Gdk.Pixbuf pixbuf) { |
373 | 449 | var size = ICON_SIZE; | 455 | var size = ICON_SIZE; |
374 | 450 | var mask_offset = 4; | 456 | var mask_offset = 4; |
375 | 451 | var mask_size_offset = mask_offset * 2; | 457 | var mask_size_offset = mask_offset * 2; |
376 | 452 | 458 | ||
377 | === modified file 'src/Widgets/MprisWidget.vala' | |||
378 | --- src/Widgets/MprisWidget.vala 2016-10-23 14:46:21 +0000 | |||
379 | +++ src/Widgets/MprisWidget.vala 2016-10-23 14:46:21 +0000 | |||
380 | @@ -19,7 +19,7 @@ | |||
381 | 19 | HashTable<string,ClientWidget> ifaces; | 19 | HashTable<string,ClientWidget> ifaces; |
382 | 20 | public signal void close (); | 20 | public signal void close (); |
383 | 21 | 21 | ||
385 | 22 | public MprisWidget(Services.Settings settings) { | 22 | public MprisWidget() { |
386 | 23 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 1); | 23 | Object (orientation: Gtk.Orientation.VERTICAL, spacing: 1); |
387 | 24 | 24 | ||
388 | 25 | ifaces = new HashTable<string,ClientWidget>(str_hash, str_equal); | 25 | ifaces = new HashTable<string,ClientWidget>(str_hash, str_equal); |
389 | @@ -31,7 +31,7 @@ | |||
390 | 31 | 31 | ||
391 | 32 | default_music = AppInfo.get_default_for_type ("audio/x-vorbis+ogg", false); | 32 | default_music = AppInfo.get_default_for_type ("audio/x-vorbis+ogg", false); |
392 | 33 | if (default_music != null) { | 33 | if (default_music != null) { |
394 | 34 | default_widget = new ClientWidget.default (default_music, settings); | 34 | default_widget = new ClientWidget.default (default_music); |
395 | 35 | 35 | ||
396 | 36 | default_widget.close.connect (() => { | 36 | default_widget.close.connect (() => { |
397 | 37 | close (); | 37 | close (); |
398 | @@ -62,7 +62,8 @@ | |||
399 | 62 | */ | 62 | */ |
400 | 63 | void add_iface (string name, Services.MprisClient iface) { | 63 | void add_iface (string name, Services.MprisClient iface) { |
401 | 64 | if (iface.player.desktop_entry == default_music.get_id ().replace (".desktop","")) { | 64 | if (iface.player.desktop_entry == default_music.get_id ().replace (".desktop","")) { |
403 | 65 | default_widget.set_client (name, iface); | 65 | default_widget.mpris_name = name; |
404 | 66 | default_widget.client = iface; | ||
405 | 66 | ifaces.insert(name, default_widget); | 67 | ifaces.insert(name, default_widget); |
406 | 67 | default_widget.no_show_all = false; | 68 | default_widget.no_show_all = false; |
407 | 68 | default_widget.visible = true; | 69 | default_widget.visible = true; |
408 | @@ -89,7 +90,7 @@ | |||
409 | 89 | */ | 90 | */ |
410 | 90 | void destroy_iface(string name) { | 91 | void destroy_iface(string name) { |
411 | 91 | if (default_widget.mpris_name == name) { | 92 | if (default_widget.mpris_name == name) { |
413 | 92 | default_widget.remove_client (); | 93 | default_widget.client = null; |
414 | 93 | } else { | 94 | } else { |
415 | 94 | var widg = ifaces[name]; | 95 | var widg = ifaces[name]; |
416 | 95 | if (widg != null) { | 96 | if (widg != null) { |
Seems to have no regressions. Nice. Thx.
Btw. in vala the default visibility is private so it is not really necessary.