Merge lp:~victored/beat-box/threads into lp:beat-box
- threads
- Merge into trunk
Proposed by
Victor Martinez
Status: | Merged |
---|---|
Merged at revision: | 654 |
Proposed branch: | lp:~victored/beat-box/threads |
Merge into: | lp:beat-box |
Diff against target: |
3303 lines (+751/-811) (has conflicts) 31 files modified
src/BeatBox.vala (+9/-9) src/CMakeLists.txt (+2/-2) src/Core/FileOperator.vala (+36/-27) src/Core/LibraryManager.vala (+340/-211) src/Core/LibraryWindow.vala (+15/-15) src/Core/PodcastManager.vala (+17/-17) src/DataBase/DataBaseUpdater.vala (+69/-84) src/Devices/CDRomDevice.vala (+3/-3) src/Devices/DeviceManager.vala (+20/-14) src/Devices/iPodDevice.vala (+15/-15) src/Lastfm/LastFM.vala (+116/-133) src/Lastfm/SimilarMedia.vala (+5/-7) src/Lastfm/TopArtistAlbums.vala (+12/-10) src/Lastfm/TopArtistSongs.vala (+8/-10) src/Lists/GenericList.vala (+3/-3) src/Media/LyricFetcher.vala (+7/-7) src/Store/Widgets/AlbumView.vala (+12/-11) src/Store/Widgets/ArtistView.vala (+9/-9) src/Store/Widgets/HomeView.vala (+15/-13) src/Store/Widgets/StoreView.vala (+8/-8) src/Views/SimilarMediaView.vala (+5/-5) src/Widgets/EmbeddedAlert.vala (+3/-9) src/Widgets/SearchSuggester.vala (+3/-3) src/Widgets/StatusBar.vala (+1/-66) src/Widgets/StyledWidgets/StyledArtistImages.vala (+5/-6) src/Widgets/WarningLabel.vala (+0/-99) src/Windows/AddPodcastWindow.vala (+3/-3) src/Windows/RemoveDuplicatesDialog.vala (+3/-3) src/Wrappers/PodcastViewWrapper.vala (+4/-4) src/Wrappers/StationViewWrapper.vala (+3/-3) src/Wrappers/ViewWrapper.vala (+0/-2) Text conflict in src/Devices/DeviceManager.vala Text conflict in src/Lastfm/TopArtistAlbums.vala |
To merge this branch: | bzr merge lp:~victored/beat-box/threads |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Scott Ringwelski | Approve | ||
Review via email: mp+113161@code.launchpad.net |
Commit message
Description of the change
Port to GLib 2.32 thread API
To post a comment you must log in.
lp:~victored/beat-box/threads
updated
- 642. By Victor Martinez
-
Don't use compact class for AZLyrics fetcher and make LibraryManager:
:recheck_ files_not_ found_async( ) actually async
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/BeatBox.vala' |
2 | --- src/BeatBox.vala 2012-06-19 22:50:13 +0000 |
3 | +++ src/BeatBox.vala 2012-07-03 06:49:24 +0000 |
4 | @@ -46,13 +46,7 @@ |
5 | warning ("Error parsing arguments: %s\n", err.message); |
6 | } |
7 | |
8 | - Gdk.threads_init(); |
9 | - Gdk.threads_enter(); |
10 | Gtk.init(ref args); |
11 | - Gdk.threads_leave(); |
12 | - |
13 | - Notify.init("beatbox"); |
14 | - GLib.Environment.set_prgname("beatbox"); |
15 | |
16 | try { |
17 | Gst.init_check (ref args); |
18 | @@ -146,7 +140,7 @@ |
19 | } |
20 | } |
21 | |
22 | - //library_manager.play_files (to_play); |
23 | + //library_manager.play_files (to_play); |
24 | } |
25 | |
26 | protected override void activate () { |
27 | @@ -171,10 +165,16 @@ |
28 | //plugins.hook_new_window (library_window); |
29 | } |
30 | |
31 | + // FIXME: mounting the music folder and accessing the files shold |
32 | + // not be done on separate threads. recheck_files_not_found() should |
33 | + // be called using an Idle.add (Priority.LOW, ...) instead. Same for |
34 | + // podcast checking and album art download. |
35 | + |
36 | // In 10 seconds, check for missing songs. This gives enought time |
37 | // to automount the music folder |
38 | - Timeout.add(10000, () => { |
39 | - library_manager.recheck_files_not_found(); |
40 | + // FIXME: This code is race-condition-prone |
41 | + Timeout.add(10000, () => { |
42 | + library_manager.recheck_files_not_found_async (); |
43 | |
44 | return false; |
45 | }); |
46 | |
47 | === modified file 'src/CMakeLists.txt' |
48 | --- src/CMakeLists.txt 2012-07-02 01:40:25 +0000 |
49 | +++ src/CMakeLists.txt 2012-07-03 06:49:24 +0000 |
50 | @@ -52,7 +52,6 @@ |
51 | Playlists/SmartQuery.vala |
52 | Playlists/SmartPlaylist.vala |
53 | Widgets/TopDisplay.vala |
54 | - Widgets/WarningLabel.vala |
55 | Widgets/SimpleOptionChooser.vala |
56 | Widgets/PresetList.vala |
57 | Widgets/SideBar.vala |
58 | @@ -61,7 +60,7 @@ |
59 | Widgets/StatusBar.vala |
60 | Widgets/SearchSuggester.vala |
61 | Widgets/TaggingArea.vala |
62 | - Widgets/InfoPanel.vala |
63 | + # Widgets/InfoPanel.vala |
64 | Widgets/VolumeWidget.vala |
65 | Widgets/NavigationArrows.vala |
66 | Widgets/EmbeddedAlert.vala |
67 | @@ -177,6 +176,7 @@ |
68 | OPTIONS |
69 | --vapidir=${CMAKE_SOURCE_DIR}/vapi |
70 | --vapidir=${CMAKE_BINARY_DIR}/core/ |
71 | + --target-glib=2.32 |
72 | ${ADD_OPTIONS} |
73 | GENERATE_VAPI |
74 | beatbox |
75 | |
76 | === modified file 'src/Core/FileOperator.vala' |
77 | --- src/Core/FileOperator.vala 2012-06-13 23:54:06 +0000 |
78 | +++ src/Core/FileOperator.vala 2012-07-03 06:49:24 +0000 |
79 | @@ -86,7 +86,7 @@ |
80 | album_art_folder.make_directory_with_parents(null); |
81 | } |
82 | catch(GLib.Error err) { |
83 | - warning ("Could not create folder in cache directory: %s\n", err.message); |
84 | + warning ("Could not create folder in cache directory: %s", err.message); |
85 | } |
86 | } |
87 | } |
88 | @@ -133,14 +133,23 @@ |
89 | } |
90 | } |
91 | catch(GLib.Error err) { |
92 | - warning("Could not pre-scan music folder. Progress percentage may be off: %s\n", err.message); |
93 | + warning("Could not pre-scan music folder. Progress percentage may be off: %s", err.message); |
94 | } |
95 | |
96 | return index; |
97 | } |
98 | - |
99 | - public void* queue_music_files_bootstrap_thread() { |
100 | - queue_music_files(import_file); |
101 | + |
102 | + public async void queue_music_files_bootstrap_async () { |
103 | + try { |
104 | + new Thread<void*>.try (null, queue_music_files_bootstrap_thread); |
105 | + } |
106 | + catch (Error err) { |
107 | + warning ("Could not create thread for queue_music_files_bootstrap: %s", err.message); |
108 | + } |
109 | + } |
110 | + |
111 | + private void* queue_music_files_bootstrap_thread () { |
112 | + queue_music_files (import_file); |
113 | |
114 | return null; |
115 | } |
116 | @@ -163,7 +172,7 @@ |
117 | } |
118 | } |
119 | catch(GLib.Error err) { |
120 | - warning("Could not pre-scan music folder. Progress percentage may be off: %s\n", err.message); |
121 | + warning("Could not pre-scan music folder. Progress percentage may be off: %s", err.message); |
122 | } |
123 | |
124 | // Let it be known that all files are queued and may now finish import |
125 | @@ -254,7 +263,7 @@ |
126 | if(success) { |
127 | foreach(int i in lm.media_ids()) { |
128 | if(lm.media_from_id(i).album_artist == m.album_artist && lm.media_from_id(i).album == m.album) { |
129 | - debug("setting album art for %s by %s\n", lm.media_from_id(i).title, lm.media_from_id(i).artist); |
130 | + debug("setting album art for %s by %s", lm.media_from_id(i).title, lm.media_from_id(i).artist); |
131 | lm.media_from_id(i).setAlbumArtPath(uri); |
132 | } |
133 | } |
134 | @@ -294,10 +303,10 @@ |
135 | if(!inThread && lm.lw.initializationFinished) { |
136 | try { |
137 | inThread = true; |
138 | - Thread.create<void*>(save_media_thread, false); |
139 | + new Thread<void*>.try (null, save_media_thread); |
140 | } |
141 | - catch(GLib.Error err) { |
142 | - warning ("Could not create thread to rescan music folder: %s\n", err.message); |
143 | + catch (Error err) { |
144 | + warning ("Could not create thread to rescan music folder: %s", err.message); |
145 | } |
146 | } |
147 | } |
148 | @@ -332,7 +341,7 @@ |
149 | } |
150 | } |
151 | else { |
152 | - debug ("Could not save %s.\n", s.uri); |
153 | + debug ("Could not save %s.", s.uri); |
154 | } |
155 | } |
156 | |
157 | @@ -357,7 +366,7 @@ |
158 | dest = GLib.File.new_for_path(Path.build_path("/", settings.getMusicFolder(), s.artist.replace("/", "_"), s.album.replace("/", "_"), s.track.to_string() + " " + s.title.replace("/", "_") + ext)); |
159 | |
160 | if(original.get_path() == dest.get_path()) { |
161 | - debug("File is already in correct location\n"); |
162 | + debug("File is already in correct location"); |
163 | return null; |
164 | } |
165 | |
166 | @@ -371,7 +380,7 @@ |
167 | dest.get_parent().make_directory_with_parents(null); |
168 | } |
169 | catch(GLib.Error err) { |
170 | - debug("Could not find new destination!: %s\n", err.message); |
171 | + debug("Could not find new destination!: %s", err.message); |
172 | } |
173 | |
174 | return dest; |
175 | @@ -389,17 +398,17 @@ |
176 | |
177 | /* copy the file over */ |
178 | if(!delete_old) { |
179 | - debug("Copying %s to %s\n", s.uri, dest.get_uri()); |
180 | + debug("Copying %s to %s", s.uri, dest.get_uri()); |
181 | success = original.copy(dest, FileCopyFlags.NONE, null, null); |
182 | } |
183 | else { |
184 | - debug("Moving %s to %s\n", s.uri, dest.get_uri()); |
185 | + debug("Moving %s to %s", s.uri, dest.get_uri()); |
186 | success = original.move(dest, FileCopyFlags.NONE, null, null); |
187 | } |
188 | |
189 | if(success || dest.query_exists()) { |
190 | success = true; |
191 | - debug("success copying file\n"); |
192 | + debug("success copying file"); |
193 | s.uri = dest.get_uri(); |
194 | |
195 | // Save the uri change in the database |
196 | @@ -415,13 +424,13 @@ |
197 | |
198 | if(!GLib.File.new_for_path(albumArtDest).query_exists() && mediaFile.query_exists() && |
199 | mediaFile.copy(GLib.File.new_for_path(albumArtDest), FileCopyFlags.NONE, null, null)) { |
200 | - debug("Copying album art to %s\n", albumArtDest); |
201 | + debug("Copying album art to %s", albumArtDest); |
202 | s.setAlbumArtPath(albumArtDest); |
203 | } |
204 | } |
205 | } |
206 | else |
207 | - warning("Failure: Could not copy imported media %s to media folder %s\n", s.uri, dest.get_path()); |
208 | + warning("Failure: Could not copy imported media %s to media folder %s", s.uri, dest.get_path()); |
209 | |
210 | /* if we are supposed to delete the old, make sure there are no items left in folder if we do */ |
211 | if(delete_old) { |
212 | @@ -430,13 +439,13 @@ |
213 | // must check for .jpg's as well. |
214 | |
215 | if(old_folder_items == 0) { |
216 | - debug("going to delete %s because no files are in it\n", original.get_parent().get_path()); |
217 | + debug("going to delete %s because no files are in it", original.get_parent().get_path()); |
218 | original.get_parent().delete(); |
219 | } |
220 | } |
221 | } |
222 | catch(GLib.Error err) { |
223 | - warning("Could not copy imported media %s to media folder: %s\n", s.uri, err.message); |
224 | + warning("Could not copy imported media %s to media folder: %s", s.uri, err.message); |
225 | } |
226 | |
227 | return success; |
228 | @@ -453,18 +462,18 @@ |
229 | |
230 | //TODO: COPY ALBUM AND IMAGE ARTWORK |
231 | if(old_folder_items == 0) { |
232 | - debug("going to delete %s because no files are in it\n", file.get_parent().get_path()); |
233 | + debug("going to delete %s because no files are in it", file.get_parent().get_path()); |
234 | //original.get_parent().delete(); |
235 | |
236 | var old_folder_parent_items = count_music_files(file.get_parent().get_parent(), ref dummy_list); |
237 | |
238 | if(old_folder_parent_items == 0) { |
239 | - debug("going to delete %s because no files are in it\n", file.get_parent().get_parent().get_path()); |
240 | + debug("going to delete %s because no files are in it", file.get_parent().get_parent().get_path()); |
241 | } |
242 | } |
243 | } |
244 | catch(GLib.Error err) { |
245 | - warning("Could not move file %s to trash: %s (you could be using a file system which is not supported)\n", s, err.message); |
246 | + warning("Could not move file %s to trash: %s (you could be using a file system which is not supported)", s, err.message); |
247 | |
248 | //tell the user the file could not be moved and ask if they'd like to delete permanently instead. |
249 | //Gtk.MessageDialog md = new Gtk.MessageDialog(lm.lw, Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, "Could not trash file %s, would you like to permanently delete it? You cannot undo these changes.", s); |
250 | @@ -491,7 +500,7 @@ |
251 | } |
252 | } |
253 | catch(GLib.Error err) { |
254 | - message("Could not guess content types: %s\n", err.message); |
255 | + message("Could not guess content types: %s", err.message); |
256 | } |
257 | }*/ |
258 | |
259 | @@ -608,10 +617,10 @@ |
260 | fo_progress(_("<b>Copying</b> files to <b>Music Folder</b>..."), 0.0); |
261 | |
262 | try { |
263 | - Thread.create<void*>(copy_imports_thread, false); |
264 | + new Thread<void*>.try (null, copy_imports_thread); |
265 | } |
266 | - catch(GLib.Error err) { |
267 | - warning("Could not create thread to rescan music folder: %s\n", err.message); |
268 | + catch (Error err) { |
269 | + warning ("Could not create thread to rescan music folder: %s", err.message); |
270 | } |
271 | } |
272 | else { |
273 | |
274 | === modified file 'src/Core/LibraryManager.vala' |
275 | --- src/Core/LibraryManager.vala 2012-07-02 23:17:27 +0000 |
276 | +++ src/Core/LibraryManager.vala 2012-07-03 06:49:24 +0000 |
277 | @@ -29,7 +29,15 @@ |
278 | */ |
279 | public class BeatBox.LibraryManager : /*BeatBox.LibraryModel,*/ GLib.Object { |
280 | public static const int PREVIEW_MEDIA_ID = -2; |
281 | - public BeatBox.LibraryWindow lw; |
282 | + |
283 | + // FIXME (BeatBox 0.7+) |
284 | + // At this point, a signal should be emmited |
285 | + // to let LibraryWindow know what's happening |
286 | + // under the hood. |
287 | + // UI code doesn't belong here. |
288 | + public BeatBox.LibraryWindow lw; // Drop this reference |
289 | + |
290 | + |
291 | public BeatBox.Settings settings; |
292 | public BeatBox.DataBaseManager dbm; |
293 | public BeatBox.DataBaseUpdater dbu; |
294 | @@ -38,13 +46,6 @@ |
295 | public BeatBox.DeviceManager device_manager; |
296 | public BeatBox.PodcastManager pm; |
297 | |
298 | - Mutex _media_lock; // lock for _media. use this around _media, _songs |
299 | - Mutex _songs_lock; |
300 | - Mutex _podcasts_lock; |
301 | - Mutex _audiobooks_lock; |
302 | - Mutex _stations_lock; |
303 | - Mutex _playlists_lock; // lock for _playlists |
304 | - Mutex _smart_playlists_lock; // lock for _smart_playlists |
305 | HashMap<int, SmartPlaylist> _smart_playlists; // rowid, smart playlist |
306 | HashMap<int, Playlist> _playlists; // rowid, playlist of all playlists |
307 | HashMap<int, Media> _media; // rowid, media of all medias |
308 | @@ -126,9 +127,12 @@ |
309 | public signal void media_queued(Media m); |
310 | public signal void media_played(Media id, Media? old_id); |
311 | public signal void playback_stopped(int was_playing); |
312 | - |
313 | + |
314 | + // FIXME (BeatBox 0.7+) |
315 | + // Drop reference to LibraryWindow |
316 | public LibraryManager(BeatBox.Settings sett, BeatBox.LibraryWindow lww) { |
317 | this.lw = lww; |
318 | + |
319 | this.settings = sett; |
320 | this.player = new Streamer(this, lw); |
321 | |
322 | @@ -139,14 +143,7 @@ |
323 | |
324 | fo.fo_progress.connect(dbProgress); |
325 | dbm.db_progress.connect(dbProgress); |
326 | - |
327 | - _smart_playlists_lock = new Mutex(); |
328 | - _playlists_lock = new Mutex(); |
329 | - _media_lock = new Mutex(); |
330 | - _songs_lock = new Mutex(); |
331 | - _podcasts_lock = new Mutex(); |
332 | - _audiobooks_lock = new Mutex(); |
333 | - _stations_lock = new Mutex(); |
334 | + |
335 | |
336 | _smart_playlists = new HashMap<int, SmartPlaylist>(); |
337 | _playlists = new HashMap<int, Playlist>(); |
338 | @@ -195,51 +192,73 @@ |
339 | album_list_setup = new TreeViewSetup(MusicList.MusicColumn.TRACK, Gtk.SortType.ASCENDING, ViewWrapper.Hint.ALBUM_LIST); |
340 | |
341 | //load all medias from db |
342 | - _media_lock.lock (); |
343 | foreach(Media s in dbm.load_medias()) { |
344 | - _media.set(s.rowid, s); |
345 | + lock (_media) { |
346 | + _media.set (s.rowid, s); |
347 | + } |
348 | |
349 | - if(s.mediatype == MediaType.SONG) |
350 | - _songs.set(s.rowid, s); |
351 | - else if(s.mediatype == MediaType.PODCAST) |
352 | - _podcasts.set(s.rowid, s); |
353 | - else if(s.mediatype == MediaType.AUDIOBOOK) |
354 | - _audiobooks.set(s.rowid, s); |
355 | - else if(s.mediatype == MediaType.STATION) |
356 | - _stations.set(s.rowid, s); |
357 | - } |
358 | - _media_lock.unlock(); |
359 | - |
360 | - _smart_playlists_lock.lock(); |
361 | - foreach(SmartPlaylist p in dbm.load_smart_playlists()) { |
362 | - _smart_playlists.set(p.get_rowid(), p); |
363 | - } |
364 | - _smart_playlists_lock.unlock(); |
365 | - |
366 | + if (s.mediatype == MediaType.SONG) { |
367 | + lock (_songs) { |
368 | + _songs.set(s.rowid, s); |
369 | + } |
370 | + } |
371 | + else if (s.mediatype == MediaType.PODCAST) { |
372 | + lock (_podcasts) { |
373 | + _podcasts.set(s.rowid, s); |
374 | + } |
375 | + } |
376 | + else if (s.mediatype == MediaType.AUDIOBOOK) { |
377 | + lock (_audiobooks) { |
378 | + _audiobooks.set(s.rowid, s); |
379 | + } |
380 | + } |
381 | + else if(s.mediatype == MediaType.STATION) { |
382 | + lock (_stations) { |
383 | + _stations.set(s.rowid, s); |
384 | + } |
385 | + } |
386 | + } |
387 | + |
388 | + lock (_smart_playlists) { |
389 | + foreach (SmartPlaylist p in dbm.load_smart_playlists()) { |
390 | + _smart_playlists.set (p.get_rowid(), p); |
391 | + } |
392 | + } |
393 | + |
394 | //load all playlists from db |
395 | - _playlists_lock.lock(); |
396 | var playlists_added = new LinkedList<string>(); |
397 | foreach(Playlist p in dbm.load_playlists()) { |
398 | if(!playlists_added.contains(p.get_name())) { // sometimes we get duplicates. don't add duplicates |
399 | - _playlists.set(p.get_rowid(), p); |
400 | + lock (_playlists) { |
401 | + _playlists.set(p.get_rowid(), p); |
402 | + } |
403 | |
404 | if(p.get_name() == "autosaved_music") { |
405 | music_setup = p.tvs; |
406 | music_setup.set_hint(ViewWrapper.Hint.MUSIC); |
407 | - _playlists.unset(p.get_rowid()); |
408 | + |
409 | + lock (_playlists) { |
410 | + _playlists.unset (p.get_rowid()); |
411 | + } |
412 | } |
413 | else if(p.get_name() == "autosaved_podcast") { |
414 | podcast_setup = p.tvs; |
415 | - _playlists.unset(p.get_rowid()); |
416 | + lock (_playlists) { |
417 | + _playlists.unset (p.get_rowid()); |
418 | + } |
419 | } |
420 | else if(p.get_name() == "autosaved_station") { |
421 | station_setup = p.tvs; |
422 | - _playlists.unset(p.get_rowid()); |
423 | + lock (_playlists) { |
424 | + _playlists.unset (p.get_rowid()); |
425 | + } |
426 | } |
427 | else if(p.get_name() == "autosaved_similar") { |
428 | similar_setup = p.tvs; |
429 | similar_setup.set_hint(ViewWrapper.Hint.SIMILAR); |
430 | - _playlists.unset(p.get_rowid()); |
431 | + lock (_playlists) { |
432 | + _playlists.unset (p.get_rowid()); |
433 | + } |
434 | } |
435 | else if(p.get_name() == "autosaved_queue") { |
436 | foreach(var m in medias_from_playlist(p.get_rowid())) { |
437 | @@ -248,27 +267,26 @@ |
438 | |
439 | queue_setup = p.tvs; |
440 | queue_setup.set_hint(ViewWrapper.Hint.QUEUE); |
441 | - _playlists.unset(p.get_rowid()); |
442 | + lock (_playlists) { |
443 | + _playlists.unset (p.get_rowid()); |
444 | + } |
445 | } |
446 | else if(p.get_name() == "autosaved_history") { |
447 | history_setup = p.tvs; |
448 | history_setup.set_hint(ViewWrapper.Hint.HISTORY); |
449 | - _playlists.unset(p.get_rowid()); |
450 | + lock (_playlists) { |
451 | + _playlists.unset (p.get_rowid()); |
452 | + } |
453 | } |
454 | |
455 | playlists_added.add(p.get_name()); |
456 | } |
457 | } |
458 | - _playlists_lock.unlock(); |
459 | |
460 | device_manager = new DeviceManager(this); |
461 | |
462 | // start thread to load all the medias pixbuf's |
463 | - try { |
464 | - Thread.create<void*>(fetch_thread_function, false); |
465 | - } catch(GLib.ThreadError err) { |
466 | - warning("Could not create thread to load media pixbuf's: %s \n", err.message); |
467 | - } |
468 | + fetch_image_cache_async (); |
469 | } |
470 | |
471 | /***************************************** |
472 | @@ -289,6 +307,12 @@ |
473 | |
474 | public bool doProgressNotificationWithTimeout() { |
475 | if(_doing_file_operations) { |
476 | + |
477 | + // FIXME (BeatBox 0.7+) |
478 | + // At this point, a signal should be emmited |
479 | + // to let LibraryWindow know what's happening |
480 | + // under the hood. |
481 | + // UI code doesn't belong here. |
482 | Gdk.threads_enter(); |
483 | progress_notification(null, (double)((double)fo.index)/((double)fo.item_count)); |
484 | Gdk.threads_leave(); |
485 | @@ -303,13 +327,24 @@ |
486 | |
487 | public void set_music_folder(string folder) { |
488 | if(start_file_operations(_("Importing music from %s...").printf("<b>" + Markup.escape_text(folder) + "</b>"))) { |
489 | + |
490 | + // FIXME (BeatBox 0.7+) |
491 | + // At this point, a signal should be emmited |
492 | + // to let LibraryWindow know what's happening |
493 | + // under the hood. |
494 | + // UI code doesn't belong here. |
495 | lw.resetSideTree(true); |
496 | lw.sideTree.removeAllStaticPlaylists(); |
497 | |
498 | clear_medias(); |
499 | _queue.clear(); |
500 | _already_played.clear(); |
501 | - |
502 | + |
503 | + // FIXME (BeatBox 0.7+) |
504 | + // At this point, a signal should be emmited |
505 | + // to let LibraryWindow know what's happening |
506 | + // under the hood. |
507 | + // UI code doesn't belong here. |
508 | lw.resetSideTree(false); |
509 | lw.update_sensitivities(); |
510 | stopPlayback(); |
511 | @@ -317,49 +352,58 @@ |
512 | settings.setMusicMountName(""); |
513 | settings.setMusicFolder(folder); |
514 | |
515 | - try { |
516 | - Thread.create<void*>(set_music_thread_function, false); |
517 | - } |
518 | - catch(GLib.Error err) { |
519 | - warning("Could not create thread to set music folder: %s\n", err.message); |
520 | - } |
521 | + set_music_folder_async (); |
522 | + } |
523 | + } |
524 | + |
525 | + public async void set_music_folder_async () { |
526 | + try { |
527 | + new Thread<void*>.try (null, set_music_thread_function); |
528 | + } |
529 | + catch(Error err) { |
530 | + warning("Could not create thread to set music folder: %s", err.message); |
531 | } |
532 | } |
533 | |
534 | - public void* set_music_thread_function () { |
535 | + private void* set_music_thread_function () { |
536 | var music_folder = GLib.File.new_for_path(settings.getMusicFolder()); |
537 | |
538 | fo.resetProgress(0); |
539 | fo.start_import(FileOperator.ImportType.SET); |
540 | fo.import_file = music_folder; |
541 | - Thread.create<void*>(fo.queue_music_files_bootstrap_thread, false); |
542 | + |
543 | + fo.queue_music_files_bootstrap_async (); |
544 | + |
545 | Timeout.add(100, doProgressNotificationWithTimeout); |
546 | |
547 | return null; |
548 | } |
549 | |
550 | - public void add_files_to_library(LinkedList<string> files) { |
551 | + public async void add_files_to_library_async (LinkedList<string> files) { |
552 | if(start_file_operations(_("Adding files to library...")) && files.size > 0) { |
553 | temp_add_files = files; |
554 | |
555 | try { |
556 | - Thread.create<void*>(add_files_to_library_thread, false); |
557 | + new Thread<void*>.try (null, add_files_to_library_thread); |
558 | } |
559 | - catch(GLib.Error err) { |
560 | - warning ("Could not create thread to add music files: %s\n", err.message); |
561 | + catch (Error err) { |
562 | + warning ("Could not create thread to add music files: %s", err.message); |
563 | } |
564 | } |
565 | } |
566 | - |
567 | - public void* add_files_to_library_thread () { |
568 | + |
569 | + private void* add_files_to_library_thread () { |
570 | + // FIXME: we need a better API for doing this kind of stuff. |
571 | + // FileOperator could emit some signals, and we could |
572 | + // track them here. |
573 | fo.resetProgress(temp_add_files.size - 1); |
574 | Timeout.add(100, doProgressNotificationWithTimeout); |
575 | fo.import_files(temp_add_files, FileOperator.ImportType.IMPORT); |
576 | - |
577 | + |
578 | return null; |
579 | } |
580 | |
581 | - public void add_folder_to_library(LinkedList<File> folders) { |
582 | + public async void add_folder_to_library_async (LinkedList<File> folders) { |
583 | string oper = ""; |
584 | if(folders.size == 1) { |
585 | oper = _("Adding music from %s to library...").printf("<b>" + Markup.escape_text(folders.get(0).get_path()) + "</b>"); |
586 | @@ -372,15 +416,15 @@ |
587 | temp_add_folders = folders; |
588 | |
589 | try { |
590 | - Thread.create<void*>(add_folder_to_library_thread, false); |
591 | + new Thread<void*>.try (null, add_folder_to_library_thread); |
592 | } |
593 | - catch(GLib.Error err) { |
594 | - warning ("Could not create thread to add music folder: %s\n", err.message); |
595 | + catch (Error err) { |
596 | + warning ("Could not create thread to add music folder: %s", err.message); |
597 | } |
598 | } |
599 | } |
600 | |
601 | - public void* add_folder_to_library_thread () { |
602 | + private void* add_folder_to_library_thread () { |
603 | var files = new LinkedList<string>(); |
604 | int items = 0; |
605 | |
606 | @@ -395,18 +439,18 @@ |
607 | return null; |
608 | } |
609 | |
610 | - public void rescan_music_folder() { |
611 | + public async void rescan_music_folder_async () { |
612 | if(start_file_operations(_("Rescanning music folder for changes..."))) { |
613 | try { |
614 | - Thread.create<void*>(rescan_music_thread_function, false); |
615 | + new Thread<void*>.try (null, rescan_music_thread_function); |
616 | } |
617 | - catch(GLib.Error err) { |
618 | - warning ("Could not create thread to rescan music folder: %s\n", err.message); |
619 | + catch (Error err) { |
620 | + warning ("Could not create thread to rescan music folder: %s", err.message); |
621 | } |
622 | } |
623 | } |
624 | - |
625 | - public void* rescan_music_thread_function () { |
626 | + |
627 | + private void* rescan_music_thread_function () { |
628 | HashMap<string, Media> paths = new HashMap<string, Media>(); |
629 | LinkedList<Media> to_remove = new LinkedList<Media>(); |
630 | LinkedList<string> to_import = new LinkedList<string>(); |
631 | @@ -456,30 +500,35 @@ |
632 | return null; |
633 | } |
634 | |
635 | - public void recheck_files_not_found() { |
636 | + public void recheck_files_not_found_async () { |
637 | try { |
638 | - Thread.create<void*>(recheck_files_not_found_thread, false); |
639 | + new Thread<void*>.try (null, recheck_files_not_found_thread); |
640 | } |
641 | - catch(GLib.Error err) { |
642 | - warning ("Could not create thread to check file locations: %s\n", err.message); |
643 | + catch (Error err) { |
644 | + warning ("Could not create thread to check file locations: %s", err.message); |
645 | } |
646 | } |
647 | - |
648 | - public void* recheck_files_not_found_thread () { |
649 | + |
650 | + private void* recheck_files_not_found_thread () { |
651 | Media[] cache_media; |
652 | var not_found = new LinkedList<Media>(); |
653 | var found = new LinkedList<Media>(); // files that location were unknown but now are found |
654 | + |
655 | + // FIXME (BeatBox 0.7+) |
656 | + // At this point, a signal should be emmited |
657 | + // to let LibraryWindow know what's happening |
658 | + // under the hood. |
659 | + // UI code doesn't belong here. |
660 | var not_found_pix = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); |
661 | - |
662 | - _media_lock.lock(); |
663 | + |
664 | cache_media = _media.values.to_array(); |
665 | - _media_lock.unlock(); |
666 | |
667 | for(int i = 0; i < cache_media.length; ++i) { |
668 | var m = cache_media[i]; |
669 | if(m.mediatype == MediaType.STATION || |
670 | (m.mediatype == MediaType.PODCAST && m.uri.has_prefix("http:/"))) { |
671 | // don't try to find this |
672 | + warning ("Found station or podcast with uri prefix 'http:/'"); |
673 | } |
674 | else { |
675 | if(File.new_for_uri(m.uri).query_exists() && m.location_unknown) { |
676 | @@ -499,6 +548,12 @@ |
677 | if(not_found.size > 0) { |
678 | warning("Some media files could not be found and are being marked as such.\n"); |
679 | update_medias(not_found, false, false, true); |
680 | + |
681 | + // FIXME (BeatBox 0.7+) |
682 | + // At this point, a signal should be emmited |
683 | + // to let LibraryWindow know what's happening |
684 | + // under the hood. |
685 | + // UI code doesn't belong here. |
686 | foreach(var m in not_found) { |
687 | lw.media_not_found(m.rowid); |
688 | } |
689 | @@ -506,6 +561,12 @@ |
690 | if(found.size > 0) { |
691 | warning("Some media files whose location were unknown were found.\n"); |
692 | update_medias(found, false, false, true); |
693 | + |
694 | + // FIXME (BeatBox 0.7+) |
695 | + // At this point, a signal should be emmited |
696 | + // to let LibraryWindow know what's happening |
697 | + // under the hood. |
698 | + // UI code doesn't belong here. |
699 | foreach(var m in found) { |
700 | lw.media_found(m.rowid); |
701 | } |
702 | @@ -536,15 +597,13 @@ |
703 | |
704 | public Playlist? playlist_from_name(string name) { |
705 | Playlist? rv = null; |
706 | - |
707 | - _playlists_lock.lock(); |
708 | + |
709 | foreach(var p in _playlists.values) { |
710 | if(p.get_name() == name) { |
711 | rv = p; |
712 | break; |
713 | } |
714 | } |
715 | - _playlists_lock.unlock(); |
716 | |
717 | return rv; |
718 | } |
719 | @@ -556,10 +615,10 @@ |
720 | top_index = i; |
721 | } |
722 | |
723 | - _playlists_lock.lock(); |
724 | - p.set_rowid(top_index + 1); |
725 | - _playlists.set(p.get_rowid(), p); |
726 | - _playlists_lock.unlock(); |
727 | + lock (_playlists) { |
728 | + p.set_rowid(top_index + 1); |
729 | + _playlists.set(p.get_rowid(), p); |
730 | + } |
731 | |
732 | playlist_added(p); |
733 | dbm.add_playlist(p); |
734 | @@ -570,9 +629,9 @@ |
735 | public void remove_playlist(int id) { |
736 | Playlist removed; |
737 | |
738 | - _playlists_lock.lock(); |
739 | - _playlists.unset(id, out removed); |
740 | - _playlists_lock.unlock(); |
741 | + lock (_playlists) { |
742 | + _playlists.unset(id, out removed); |
743 | + } |
744 | |
745 | playlist_removed(removed); |
746 | dbu.removeItem(removed); |
747 | @@ -598,29 +657,29 @@ |
748 | public SmartPlaylist? smart_playlist_from_name(string name) { |
749 | SmartPlaylist? rv = null; |
750 | |
751 | - _smart_playlists_lock.lock(); |
752 | - foreach(var p in _smart_playlists.values) { |
753 | - if(p.get_name() == name) { |
754 | - rv = p; |
755 | - break; |
756 | - } |
757 | + lock (_smart_playlists) { |
758 | + foreach(var p in _smart_playlists.values) { |
759 | + if(p.get_name() == name) { |
760 | + rv = p; |
761 | + break; |
762 | + } |
763 | + } |
764 | } |
765 | - _smart_playlists_lock.unlock(); |
766 | - |
767 | + |
768 | return rv; |
769 | } |
770 | |
771 | public void save_smart_playlists() { |
772 | try { |
773 | - Thread.create<void*>( () => { |
774 | - _smart_playlists_lock.lock(); |
775 | - dbm.save_smart_playlists(_smart_playlists.values); |
776 | - _smart_playlists_lock.unlock(); |
777 | + new Thread<void*>.try (null, () => { |
778 | + lock (_smart_playlists) { |
779 | + dbm.save_smart_playlists(_smart_playlists.values); |
780 | + } |
781 | |
782 | return null; |
783 | - }, false); |
784 | + }); |
785 | } |
786 | - catch(GLib.Error err) { |
787 | + catch(Error err) { |
788 | warning ("Could not create thread to save smart playlists: %s\n", err.message); |
789 | } |
790 | } |
791 | @@ -632,10 +691,10 @@ |
792 | top_index = i; |
793 | } |
794 | |
795 | - _smart_playlists_lock.lock(); |
796 | - p.set_rowid(top_index + 1);// + 1 for 1-based db |
797 | - _smart_playlists.set(p.get_rowid(), p); |
798 | - _smart_playlists_lock.unlock(); |
799 | + lock (_smart_playlists) { |
800 | + p.set_rowid(top_index + 1);// + 1 for 1-based db |
801 | + _smart_playlists.set(p.get_rowid(), p); |
802 | + } |
803 | |
804 | playlist_added(p); |
805 | save_smart_playlists(); |
806 | @@ -646,9 +705,9 @@ |
807 | public void remove_smart_playlist(int id) { |
808 | SmartPlaylist removed; |
809 | |
810 | - _smart_playlists_lock.lock(); |
811 | - _smart_playlists.unset(id, out removed); |
812 | - _smart_playlists_lock.unlock(); |
813 | + lock (_smart_playlists) { |
814 | + _smart_playlists.unset(id, out removed); |
815 | + } |
816 | |
817 | playlist_removed(removed); |
818 | dbu.removeItem(removed); |
819 | @@ -660,7 +719,6 @@ |
820 | |
821 | // We really only want to clear the songs that are permanent and on the file system |
822 | // Dont clear podcasts that link to a url, device media, temporary media, previews, songs |
823 | - _media_lock.lock(); |
824 | var unset = new LinkedList<Media>();//HashMap<int, Media>(); |
825 | var unset_ids = new LinkedList<int>(); |
826 | foreach(int i in _media.keys) { |
827 | @@ -676,26 +734,39 @@ |
828 | } |
829 | } |
830 | } |
831 | - |
832 | - foreach(Media s in unset) { |
833 | - _media.unset(s.rowid); |
834 | - |
835 | - if(s.mediatype == MediaType.SONG) |
836 | - _songs.unset(s.rowid); |
837 | - else if(s.mediatype == MediaType.PODCAST) |
838 | - _podcasts.unset(s.rowid); |
839 | - else if(s.mediatype == MediaType.AUDIOBOOK) |
840 | - _audiobooks.unset(s.rowid); |
841 | - else if(s.mediatype == MediaType.STATION) |
842 | - _stations.unset(s.rowid); |
843 | - } |
844 | - _media_lock.unlock(); |
845 | - |
846 | - _playlists_lock.lock(); |
847 | - foreach(var p in _playlists.values) { |
848 | - p.removeMedias(unset_ids); |
849 | - } |
850 | - _playlists_lock.unlock(); |
851 | + |
852 | + lock (_media) { |
853 | + foreach(Media s in unset) { |
854 | + _media.unset(s.rowid); |
855 | + |
856 | + if(s.mediatype == MediaType.SONG) { |
857 | + lock (_songs) { |
858 | + _songs.unset (s.rowid); |
859 | + } |
860 | + } |
861 | + else if(s.mediatype == MediaType.PODCAST) { |
862 | + lock (_podcasts) { |
863 | + _podcasts.unset (s.rowid); |
864 | + } |
865 | + } |
866 | + else if(s.mediatype == MediaType.AUDIOBOOK) { |
867 | + lock (_audiobooks) { |
868 | + _audiobooks.unset(s.rowid); |
869 | + } |
870 | + } |
871 | + else if(s.mediatype == MediaType.STATION) { |
872 | + lock (_stations) { |
873 | + _stations.unset(s.rowid); |
874 | + } |
875 | + } |
876 | + } |
877 | + } |
878 | + |
879 | + lock (_playlists) { |
880 | + foreach(var p in _playlists.values) { |
881 | + p.removeMedias(unset_ids); |
882 | + } |
883 | + } |
884 | |
885 | dbm.clear_medias(); |
886 | dbm.add_medias(_media.values); |
887 | @@ -790,17 +861,17 @@ |
888 | dbu.update_medias(updates); |
889 | } |
890 | |
891 | - public void save_media() { |
892 | + public async void save_media_async () { |
893 | try { |
894 | - Thread.create<void*>( () => { |
895 | - _media_lock.lock(); |
896 | - dbm.update_medias(_media.values); |
897 | - _media_lock.unlock(); |
898 | + new Thread<void*>.try (null, () => { |
899 | + lock (_media) { |
900 | + dbm.update_medias (_media.values); |
901 | + } |
902 | |
903 | return null; |
904 | - }, false); |
905 | + }); |
906 | } |
907 | - catch(GLib.Error err) { |
908 | + catch(Error err) { |
909 | warning ("Could not create thread to save media: %s\n", err.message); |
910 | } |
911 | } |
912 | @@ -816,13 +887,13 @@ |
913 | public Media? match_media_to_list(Media m, Collection<Media> to_match) { |
914 | Media? rv = null; |
915 | |
916 | - _media_lock.lock(); |
917 | - foreach(var test in to_match) { |
918 | - if(!test.isTemporary && test != m && test.title.down() == m.title.down() && test.artist.down() == m.artist.down()) { |
919 | - rv = test; |
920 | + lock (_media) { |
921 | + foreach(var test in to_match) { |
922 | + if(!test.isTemporary && test != m && test.title.down() == m.title.down() && test.artist.down() == m.artist.down()) { |
923 | + rv = test; |
924 | + } |
925 | } |
926 | } |
927 | - _media_lock.unlock(); |
928 | |
929 | return rv; |
930 | } |
931 | @@ -832,10 +903,8 @@ |
932 | rv.title = title; |
933 | rv.artist = artist; |
934 | Media[] searchable; |
935 | - |
936 | - _media_lock.lock(); |
937 | + |
938 | searchable = _media.values.to_array(); |
939 | - _media_lock.unlock(); |
940 | |
941 | for(int i = 0; i < searchable.length; ++i) { |
942 | Media s = searchable[i]; |
943 | @@ -848,10 +917,8 @@ |
944 | |
945 | public void medias_from_name(Collection<Media> tests, ref LinkedList<int> found, ref LinkedList<Media> not_found) { |
946 | Media[] searchable; |
947 | - |
948 | - _media_lock.lock(); |
949 | + |
950 | searchable = _media.values.to_array(); |
951 | - _media_lock.unlock(); |
952 | |
953 | foreach(Media test in tests) { |
954 | bool found_match = false; |
955 | @@ -872,15 +939,13 @@ |
956 | public Media? media_from_file(string uri) { |
957 | Media? rv = null; |
958 | |
959 | - _media_lock.lock(); |
960 | foreach(Media s in _media.values) { |
961 | if(s.uri == uri) { |
962 | rv = s; |
963 | break; |
964 | } |
965 | } |
966 | - _media_lock.unlock(); |
967 | - |
968 | + |
969 | return rv; |
970 | } |
971 | |
972 | @@ -997,31 +1062,44 @@ |
973 | return; |
974 | |
975 | int top_index = 0; |
976 | - _media_lock.lock(); |
977 | + |
978 | foreach(int i in _media.keys) { |
979 | if(i > top_index) |
980 | top_index = i; |
981 | } |
982 | |
983 | var added = new LinkedList<int>(); |
984 | - foreach(var s in new_media) { |
985 | - if(s.rowid == 0) |
986 | - s.rowid = ++top_index; |
987 | - |
988 | - added.add(s.rowid); |
989 | - |
990 | - _media.set(s.rowid, s); |
991 | - |
992 | - if(s.mediatype == MediaType.SONG) |
993 | - _songs.set(s.rowid, s); |
994 | - else if(s.mediatype == MediaType.PODCAST) |
995 | - _podcasts.set(s.rowid, s); |
996 | - else if(s.mediatype == MediaType.AUDIOBOOK) |
997 | - _audiobooks.set(s.rowid, s); |
998 | - else if(s.mediatype == MediaType.STATION) |
999 | - _stations.set(s.rowid, s); |
1000 | + lock (_media) { |
1001 | + foreach(var s in new_media) { |
1002 | + if(s.rowid == 0) |
1003 | + s.rowid = ++top_index; |
1004 | + |
1005 | + added.add(s.rowid); |
1006 | + |
1007 | + _media.set(s.rowid, s); |
1008 | + |
1009 | + if(s.mediatype == MediaType.SONG) { |
1010 | + lock (_songs) { |
1011 | + _audiobooks.set (s.rowid, s); |
1012 | + } |
1013 | + } |
1014 | + else if(s.mediatype == MediaType.PODCAST) { |
1015 | + lock (_podcasts) { |
1016 | + _podcasts.set (s.rowid, s); |
1017 | + } |
1018 | + } |
1019 | + else if(s.mediatype == MediaType.AUDIOBOOK) { |
1020 | + lock (_audiobooks) { |
1021 | + _audiobooks.set (s.rowid, s); |
1022 | + } |
1023 | + } |
1024 | + else if(s.mediatype == MediaType.STATION) { |
1025 | + lock (_stations) { |
1026 | + _stations.set (s.rowid, s); |
1027 | + } |
1028 | + } |
1029 | + } |
1030 | } |
1031 | - _media_lock.unlock(); |
1032 | |
1033 | if(new_media.size > 0) { |
1034 | dbm.add_medias(new_media); |
1035 | @@ -1055,30 +1133,45 @@ |
1036 | // call now so that lm.media_from_id() still works |
1037 | medias_removed(removedIds); |
1038 | |
1039 | - _media_lock.lock(); |
1040 | - foreach(Media s in toRemove) { |
1041 | - _media.unset(s.rowid); |
1042 | - |
1043 | - if(s.mediatype == MediaType.SONG) |
1044 | - _songs.unset(s.rowid); |
1045 | - else if(s.mediatype == MediaType.PODCAST) |
1046 | - _podcasts.unset(s.rowid); |
1047 | - else if(s.mediatype == MediaType.AUDIOBOOK) |
1048 | - _audiobooks.unset(s.rowid); |
1049 | - else if(s.mediatype == MediaType.STATION) |
1050 | - _stations.unset(s.rowid); |
1051 | + lock (_media) { |
1052 | + foreach(Media s in toRemove) { |
1053 | + _media.unset(s.rowid); |
1054 | + |
1055 | + if(s.mediatype == MediaType.SONG) { |
1056 | + lock (_songs) { |
1057 | + _songs.unset (s.rowid); |
1058 | + } |
1059 | + } |
1060 | + else if(s.mediatype == MediaType.PODCAST) { |
1061 | + lock (_podcasts) { |
1062 | + _podcasts.unset (s.rowid); |
1063 | + } |
1064 | + } |
1065 | + else if(s.mediatype == MediaType.AUDIOBOOK) { |
1066 | + lock (_audiobooks) { |
1067 | + _audiobooks.unset(s.rowid); |
1068 | + } |
1069 | + } |
1070 | + else if(s.mediatype == MediaType.STATION) { |
1071 | + lock (_stations) { |
1072 | + _stations.unset(s.rowid); |
1073 | + } |
1074 | + } |
1075 | + } |
1076 | } |
1077 | - _media_lock.unlock(); |
1078 | - |
1079 | - _playlists_lock.lock(); |
1080 | + |
1081 | foreach(var p in _playlists.values) { |
1082 | p.removeMedias(toRemove); |
1083 | } |
1084 | - _playlists_lock.unlock(); |
1085 | |
1086 | if(_media.size == 0) |
1087 | settings.setMusicFolder(Environment.get_user_special_dir(UserDirectory.MUSIC)); |
1088 | - |
1089 | + |
1090 | + // FIXME (BeatBox 0.7+) |
1091 | + // At this point, a signal should be emmited |
1092 | + // to let LibraryWindow know what's happening |
1093 | + // under the hood. |
1094 | + // UI code doesn't belong here. |
1095 | lw.update_sensitivities(); |
1096 | } |
1097 | |
1098 | @@ -1340,6 +1433,12 @@ |
1099 | if(File.new_for_uri(m.uri).query_exists()) { // we did not know location, but it has re-appearred |
1100 | m.location_unknown = false; |
1101 | m.unique_status_image = null; |
1102 | + |
1103 | + // FIXME (BeatBox 0.7+) |
1104 | + // At this point, a signal should be emmited |
1105 | + // to let LibraryWindow know what's happening |
1106 | + // under the hood. |
1107 | + // UI code doesn't belong here. |
1108 | lw.media_found(m.rowid); |
1109 | } |
1110 | else { // to avoid infinite loop with repeat on, don't try to play next again |
1111 | @@ -1351,9 +1450,16 @@ |
1112 | // check that the file exists |
1113 | var music_folder_uri = File.new_for_path(settings.getMusicFolder()).get_uri(); |
1114 | if((settings.getMusicFolder() != "" && m.uri.has_prefix(music_folder_uri) && !GLib.File.new_for_uri(m.uri).query_exists())) { |
1115 | + |
1116 | + // FIXME (BeatBox 0.7+) |
1117 | + // At this point, a signal should be emmited |
1118 | + // to let LibraryWindow know what's happening |
1119 | + // under the hood. |
1120 | + // UI code doesn't belong here. |
1121 | m.unique_status_image = Icons.PROCESS_ERROR.render(IconSize.MENU, ((ViewWrapper)lw.sideTree.getWidget(lw.sideTree.library_music_iter)).list_view.get_style_context()); |
1122 | m.location_unknown = true; |
1123 | lw.media_not_found(id); |
1124 | + |
1125 | getNext(true); |
1126 | return; |
1127 | } |
1128 | @@ -1392,10 +1498,11 @@ |
1129 | */ |
1130 | Timeout.add(1000, () => { |
1131 | if(media_info.media == m) { |
1132 | + // FIXME (BeatBox 0.7+) : Move to playback manager |
1133 | try { |
1134 | - Thread.create<void*>(change_gains_thread, false); |
1135 | + new Thread<void*>.try (null, change_gains_thread); |
1136 | } |
1137 | - catch(GLib.Error err) { |
1138 | + catch(Error err) { |
1139 | warning("Could not create thread to change gains: %s\n", err.message); |
1140 | } |
1141 | |
1142 | @@ -1417,6 +1524,9 @@ |
1143 | } |
1144 | |
1145 | // FIXME: Slow. Don't read eq. presets from settings. |
1146 | + // FIXME (BeatBox 0.7+) |
1147 | + // Deprecate in favor of PlaybackManager. Currently, this is public |
1148 | + // because EqualizerWindow needs it |
1149 | public void* change_gains_thread () { |
1150 | if(settings.getEqualizerEnabled()) { |
1151 | bool automatic_enabled = settings.getAutoSwitchPreset(); |
1152 | @@ -1479,7 +1589,12 @@ |
1153 | temps.add(s); |
1154 | |
1155 | playMedia(s, false); |
1156 | - |
1157 | + |
1158 | + // FIXME (BeatBox 0.7+) |
1159 | + // At this point, a signal should be emmited |
1160 | + // to let LibraryWindow know what's happening |
1161 | + // under the hood. |
1162 | + // UI code doesn't belong here. |
1163 | if(!playing) { |
1164 | lw.playClicked(); |
1165 | } |
1166 | @@ -1526,19 +1641,26 @@ |
1167 | set_album_art(_media.get(id), pix, emit); |
1168 | } |
1169 | } |
1170 | - |
1171 | + |
1172 | + public async void fetch_image_cache_async () { |
1173 | + try { |
1174 | + new Thread<void*>.try (null, fetch_image_thread_function); |
1175 | + } catch(Error err) { |
1176 | + warning ("Could not create thread to load media pixbuf's: %s \n", err.message); |
1177 | + } |
1178 | + } |
1179 | + |
1180 | /* at the start, load all the pixbufs */ |
1181 | - public void* fetch_thread_function () { |
1182 | + private void* fetch_image_thread_function () { |
1183 | if(in_fetch_thread) |
1184 | return null; |
1185 | - |
1186 | + |
1187 | in_fetch_thread = true; |
1188 | //GStreamerTagger tagger = new GStreamerTagger(this); |
1189 | LinkedList<Media> medias = new LinkedList<Media>(); |
1190 | - _media_lock.lock(); |
1191 | + |
1192 | foreach(var m in _media.values) |
1193 | medias.add(m); |
1194 | - _media_lock.unlock(); |
1195 | |
1196 | // first get from file |
1197 | foreach(var s in medias) { |
1198 | @@ -1658,13 +1780,12 @@ |
1199 | if(emit) { |
1200 | Gee.LinkedList<Media> updated_medias = new Gee.LinkedList<Media>(); |
1201 | |
1202 | - _media_lock.lock(); |
1203 | + |
1204 | foreach(int i in media_ids()) { |
1205 | if(media_from_id(i).album_artist == s.album_artist && media_from_id(i).album == s.album) { |
1206 | updated_medias.add(media_from_id(i)); |
1207 | } |
1208 | } |
1209 | - _media_lock.unlock(); |
1210 | |
1211 | update_medias(updated_medias, false, false, true); |
1212 | } |
1213 | @@ -1677,7 +1798,14 @@ |
1214 | |
1215 | progress_notification(message, 0.0); |
1216 | _doing_file_operations = true; |
1217 | + |
1218 | + // FIXME (BeatBox 0.7+) |
1219 | + // At this point, a signal should be emmited |
1220 | + // to let LibraryWindow know what's happening |
1221 | + // under the hood. |
1222 | + // UI code doesn't belong here. |
1223 | lw.update_sensitivities(); |
1224 | + |
1225 | file_operations_started(); |
1226 | return true; |
1227 | } |
1228 | @@ -1694,15 +1822,16 @@ |
1229 | pm.find_new_podcasts(); |
1230 | } |
1231 | else { |
1232 | - try { |
1233 | - Thread.create<void*>(fetch_thread_function, false); |
1234 | - } |
1235 | - catch(GLib.ThreadError err) { |
1236 | - warning("Could not create thread to load media pixbuf's: %s \n", err.message); |
1237 | - } |
1238 | - |
1239 | + fetch_image_cache_async (); |
1240 | + |
1241 | + // FIXME (BeatBox 0.7+) |
1242 | + // At this point, a signal should be emmited |
1243 | + // to let LibraryWindow know what's happening |
1244 | + // under the hood. |
1245 | + // UI code doesn't belong here. |
1246 | lw.update_sensitivities(); |
1247 | lw.updateInfoLabel(); |
1248 | + |
1249 | file_operations_done(); |
1250 | } |
1251 | } |
1252 | |
1253 | === modified file 'src/Core/LibraryWindow.vala' |
1254 | --- src/Core/LibraryWindow.vala 2012-06-30 20:55:57 +0000 |
1255 | +++ src/Core/LibraryWindow.vala 2012-07-03 06:49:24 +0000 |
1256 | @@ -219,8 +219,8 @@ |
1257 | this.window_position = Gtk.WindowPosition.CENTER; |
1258 | |
1259 | // set the size based on saved settings |
1260 | - this.set_default_size (lm.settings.getWindowWidth(), lm.settings.getWindowHeight()); |
1261 | - if(lm.settings.getWindowMaximized()) { |
1262 | + this.set_default_size (settings.getWindowWidth(), settings.getWindowHeight()); |
1263 | + if(settings.getWindowMaximized()) { |
1264 | window_maximized = true; |
1265 | this.maximize(); |
1266 | } |
1267 | @@ -282,7 +282,7 @@ |
1268 | viewSelector.append(Icons.VIEW_DETAILS.render_image (IconSize.MENU)); |
1269 | viewSelector.append(Icons.VIEW_ICONS.render_image (IconSize.MENU)); |
1270 | viewSelector.valign = showSongInfo.valign = Gtk.Align.CENTER; |
1271 | - viewSelector.selected = lm.settings.getViewMode(); |
1272 | + viewSelector.selected = settings.getViewMode(); |
1273 | |
1274 | viewSelectorBin.margin_left = 12; |
1275 | viewSelectorBin.margin_right = 12; |
1276 | @@ -363,12 +363,12 @@ |
1277 | repeatChooser.appendItem(_("Album")); |
1278 | repeatChooser.appendItem(_("Artist")); |
1279 | repeatChooser.appendItem(_("All")); |
1280 | - repeatChooser.setOption(lm.settings.getRepeatMode()); |
1281 | + repeatChooser.setOption(settings.getRepeatMode()); |
1282 | repeatChooser.setTooltip (_("Disable Repeat"), _("Enable Repeat")); |
1283 | |
1284 | shuffleChooser.appendItem(_("Off")); |
1285 | shuffleChooser.appendItem(_("All")); |
1286 | - shuffleChooser.setOption(lm.settings.getShuffleMode()); |
1287 | + shuffleChooser.setOption(settings.getShuffleMode()); |
1288 | shuffleChooser.setTooltip (_("Turn off Shuffle"), _("Turn on Shuffle")); |
1289 | |
1290 | newPlaylistMenu = new Gtk.Menu(); |
1291 | @@ -445,7 +445,7 @@ |
1292 | |
1293 | show_all(); |
1294 | infoBar.hide(); |
1295 | - searchField.set_text(lm.settings.getSearchString()); |
1296 | + searchField.set_text(settings.getSearchString()); |
1297 | update_sensitivities(); |
1298 | hide_video_mode(); |
1299 | } |
1300 | @@ -713,7 +713,7 @@ |
1301 | if(!initializationFinished) |
1302 | return; |
1303 | |
1304 | - bool folderSet = (lm.settings.getMusicFolder() != ""); |
1305 | + bool folderSet = (settings.getMusicFolder() != ""); |
1306 | bool haveMedias = lm.media_count() > 0; |
1307 | bool doingOps = lm.doing_file_operations(); |
1308 | bool mediaActive = lm.media_active; |
1309 | @@ -811,7 +811,7 @@ |
1310 | |
1311 | var label = ""; |
1312 | if(lm.fo.import_type == FileOperator.ImportType.SET) |
1313 | - label = _("Importing music from") + " <b>" + Markup.escape_text(lm.settings.getMusicFolder()) + "</b>..."; |
1314 | + label = _("Importing music from") + " <b>" + Markup.escape_text(settings.getMusicFolder()) + "</b>..."; |
1315 | else if(lm.fo.import_type == FileOperator.ImportType.RESCAN) |
1316 | label = _("Rescanning music folder for changes..."); |
1317 | else if(lm.fo.import_type == FileOperator.ImportType.IMPORT || |
1318 | @@ -1005,7 +1005,7 @@ |
1319 | void on_quit() { |
1320 | // Stop listening to window state changes |
1321 | this.window_state_event.disconnect(window_state_changed); |
1322 | - lm.settings.setLastMediaPosition((int)((double)lm.player.getPosition()/1000000000)); |
1323 | + settings.setLastMediaPosition((int)((double)lm.player.getPosition()/1000000000)); |
1324 | if(lm.media_active) { |
1325 | lm.media_info.media.resume_pos = (int)((double)lm.player.getPosition()/1000000000); |
1326 | lm.update_media(lm.media_info.media, false, false, false); |
1327 | @@ -1055,13 +1055,13 @@ |
1328 | } |
1329 | } |
1330 | |
1331 | - if(final_folders.size > 0 && GLib.File.new_for_path(lm.settings.getMusicFolder()).query_exists()) { |
1332 | + if(final_folders.size > 0 && GLib.File.new_for_path(settings.getMusicFolder()).query_exists()) { |
1333 | topDisplay.show_progressbar(); |
1334 | |
1335 | - lm.add_folder_to_library(final_folders); |
1336 | + lm.add_folder_to_library_async (final_folders); |
1337 | update_sensitivities(); |
1338 | } |
1339 | - else if(!GLib.File.new_for_path(lm.settings.getMusicFolder()).query_exists()) { |
1340 | + else if(!GLib.File.new_for_path(settings.getMusicFolder()).query_exists()) { |
1341 | doAlert(_("Import Failed"), _("Your library's music folder could not be found. Please make sure your music folder is mounted before importing.")); |
1342 | } |
1343 | } |
1344 | @@ -1080,7 +1080,7 @@ |
1345 | topDisplay.set_label_markup("<b>" + _("Rescanning music folder for changes") + "</b>"); |
1346 | topDisplay.show_progressbar(); |
1347 | |
1348 | - lm.rescan_music_folder(); |
1349 | + lm.rescan_music_folder_async (); |
1350 | update_sensitivities(); |
1351 | } |
1352 | else { |
1353 | @@ -1136,7 +1136,7 @@ |
1354 | //searchField.set_text("up"); |
1355 | |
1356 | if(not_imported.size > 0) { |
1357 | - NotImportedDialog nim = new NotImportedDialog(this, not_imported, lm.settings.getMusicFolder()); |
1358 | + NotImportedDialog nim = new NotImportedDialog(this, not_imported, settings.getMusicFolder()); |
1359 | nim.show(); |
1360 | } |
1361 | |
1362 | @@ -1388,7 +1388,7 @@ |
1363 | files_dragged.add(File.new_for_uri(uri).get_path()); |
1364 | } |
1365 | |
1366 | - lm.add_files_to_library(files_dragged); |
1367 | + lm.add_files_to_library_async (files_dragged); |
1368 | } |
1369 | |
1370 | public void doAlert(string title, string message) { |
1371 | |
1372 | === modified file 'src/Core/PodcastManager.vala' |
1373 | --- src/Core/PodcastManager.vala 2012-06-13 23:54:06 +0000 |
1374 | +++ src/Core/PodcastManager.vala 2012-07-03 06:49:24 +0000 |
1375 | @@ -66,16 +66,16 @@ |
1376 | |
1377 | lm.start_file_operations(FETCHING_NEW); |
1378 | try { |
1379 | - Thread.create<void*>(find_new_podcasts_thread, false); |
1380 | + new Thread<void*>.try (null, find_new_podcasts_thread); |
1381 | } |
1382 | - catch(GLib.ThreadError err) { |
1383 | - stdout.printf("ERROR: Could not create thread to fetch new podcasts: %s \n", err.message); |
1384 | + catch (Error err) { |
1385 | + warning ("Could not create thread to fetch new podcasts: %s", err.message); |
1386 | } |
1387 | |
1388 | lm.have_fetched_new_podcasts = true; |
1389 | } |
1390 | |
1391 | - public void* find_new_podcasts_thread () { |
1392 | + private void* find_new_podcasts_thread () { |
1393 | HashSet<string> rss_urls = new HashSet<string>(); |
1394 | HashSet<string> mp3_urls = new HashSet<string>(); |
1395 | HashMap<string, string> rss_names = new HashMap<string, string>(); |
1396 | @@ -174,7 +174,7 @@ |
1397 | //current_operation = FETCHING_FROM_RSS.printf("<b>" + Markup.escape_text(rss) + "</b>"); |
1398 | Timeout.add(500, doProgressNotificationWithTimeout); |
1399 | |
1400 | - debug("podcast_rss: %s\n", rss); |
1401 | + debug("podcast_rss: %s", rss); |
1402 | |
1403 | // create an HTTP session to twitter |
1404 | var session = new Soup.SessionSync(); |
1405 | @@ -218,7 +218,7 @@ |
1406 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
1407 | if(doc == null) |
1408 | return null; |
1409 | - //stdout.printf("%s\n", (string)message.response_body.data); |
1410 | + //stdout.printf("%s", (string)message.response_body.data); |
1411 | Xml.Node* root = doc->get_root_element (); |
1412 | if (root == null) { |
1413 | delete doc; |
1414 | @@ -279,7 +279,7 @@ |
1415 | Media new_p = new Media(""); |
1416 | |
1417 | for (Xml.Node* item_iter = iter->children; item_iter != null; item_iter = item_iter->next) { |
1418 | - //stdout.printf("name is %s\n", item_iter->name); |
1419 | + //stdout.printf("name is %s", item_iter->name); |
1420 | if(item_iter->name == "title") |
1421 | new_p.title = item_iter->get_content(); |
1422 | else if(name == "author") { |
1423 | @@ -365,14 +365,14 @@ |
1424 | save_locally_ids = ids; |
1425 | |
1426 | try { |
1427 | - Thread.create<void*>(save_episodes_locally_thread, false); |
1428 | + new Thread<void*>.try (null, save_episodes_locally_thread); |
1429 | } |
1430 | - catch(GLib.ThreadError err) { |
1431 | - stdout.printf("ERROR: Could not create thread to save episodes locally: %s \n", err.message); |
1432 | + catch (Error err) { |
1433 | + warning ("Could not create thread to save episodes locally: %s", err.message); |
1434 | } |
1435 | } |
1436 | |
1437 | - public void* save_episodes_locally_thread () { |
1438 | + private void* save_episodes_locally_thread () { |
1439 | if(save_locally_ids == null || save_locally_ids.size == 0) |
1440 | return null; |
1441 | |
1442 | @@ -397,7 +397,7 @@ |
1443 | online_size = online_file.query_info("*", FileQueryInfoFlags.NONE).get_size(); |
1444 | } |
1445 | catch(Error err) { |
1446 | - stdout.printf("Could not read online podcast file's size for progress notification: %s\n", err.message); |
1447 | + stdout.printf("Could not read online podcast file's size for progress notification: %s", err.message); |
1448 | } |
1449 | |
1450 | new_dest = lm.fo.get_new_destination(s); |
1451 | @@ -408,7 +408,7 @@ |
1452 | file_size = (int)(new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size() / 1000000); |
1453 | } |
1454 | catch(Error err) { |
1455 | - stdout.printf("Could not calculate downloaded podcast's file size: %s\n", err.message); |
1456 | + stdout.printf("Could not calculate downloaded podcast's file size: %s", err.message); |
1457 | } |
1458 | |
1459 | s.file_size = file_size; |
1460 | @@ -442,7 +442,7 @@ |
1461 | GLib.File original = GLib.File.new_for_uri(s.uri); |
1462 | |
1463 | /* copy the file over */ |
1464 | - debug("Copying %s to %s\n", s.uri, dest.get_uri()); |
1465 | + debug("Copying %s to %s", s.uri, dest.get_uri()); |
1466 | success = original.copy(dest, FileCopyFlags.NONE, canceller, null); |
1467 | |
1468 | if(success || dest.query_exists()) { |
1469 | @@ -456,10 +456,10 @@ |
1470 | }); |
1471 | } |
1472 | else |
1473 | - warning("Failure: Could not copy imported media %s to media folder %s\n", s.uri, dest.get_path()); |
1474 | + warning("Failure: Could not copy imported media %s to media folder %s", s.uri, dest.get_path()); |
1475 | } |
1476 | catch(GLib.Error err) { |
1477 | - warning("Could not copy imported media %s to media folder: %s\n", s.uri, err.message); |
1478 | + warning("Could not copy imported media %s to media folder: %s", s.uri, err.message); |
1479 | } |
1480 | |
1481 | return success; |
1482 | @@ -483,7 +483,7 @@ |
1483 | current_local_size = new_dest.query_info("*", FileQueryInfoFlags.NONE).get_size(); |
1484 | } |
1485 | catch(Error err) { |
1486 | - stdout.printf("Error reading current size of downloaded podcast: %s\n", err.message); |
1487 | + stdout.printf("Error reading current size of downloaded podcast: %s", err.message); |
1488 | } |
1489 | } |
1490 | |
1491 | |
1492 | === modified file 'src/DataBase/DataBaseUpdater.vala' |
1493 | --- src/DataBase/DataBaseUpdater.vala 2012-06-01 22:48:28 +0000 |
1494 | +++ src/DataBase/DataBaseUpdater.vala 2012-07-03 06:49:24 +0000 |
1495 | @@ -23,34 +23,27 @@ |
1496 | /* Merely a place holder for multiple pieces of information regarding |
1497 | * the current media playing. Mostly here because of dependence. */ |
1498 | |
1499 | -using Gee; |
1500 | |
1501 | -public class BeatBox.DataBaseUpdater : GLib.Object { |
1502 | +public class BeatBox.DataBaseUpdater : Object { |
1503 | private LibraryManager lm; |
1504 | private BeatBox.DataBaseManager dbm; |
1505 | |
1506 | - LinkedList<Media> media_updates; |
1507 | - |
1508 | - Mutex update_mutex; |
1509 | - Mutex remove_mutex; |
1510 | - |
1511 | - LinkedList<GLib.Object> toUpdate; // a queue of things to update |
1512 | - LinkedList<GLib.Object> toRemove; |
1513 | + Gee.LinkedList<Media> media_updates; |
1514 | + |
1515 | + Gee.LinkedList<Object> toUpdate; // a queue of things to update |
1516 | + Gee.LinkedList<Object> toRemove; |
1517 | bool inThread; |
1518 | |
1519 | public DataBaseUpdater(LibraryManager lm, BeatBox.DataBaseManager databm) { |
1520 | this.lm = lm; |
1521 | dbm = databm; |
1522 | |
1523 | - update_mutex = new Mutex(); |
1524 | - remove_mutex = new Mutex(); |
1525 | - |
1526 | - media_updates = new LinkedList<Media>(); |
1527 | - toUpdate = new LinkedList<GLib.Object>(); |
1528 | - toRemove = new LinkedList<GLib.Object>(); |
1529 | + media_updates = new Gee.LinkedList<Media>(); |
1530 | + toUpdate = new Gee.LinkedList<Object>(); |
1531 | + toRemove = new Gee.LinkedList<Object>(); |
1532 | inThread = false; |
1533 | |
1534 | - tree_view_setups = new GLib.List<TreeViewSetup>(); |
1535 | + tree_view_setups = new List<TreeViewSetup>(); |
1536 | |
1537 | Timeout.add(10000, periodic_save); |
1538 | } |
1539 | @@ -61,76 +54,71 @@ |
1540 | return true; |
1541 | } |
1542 | |
1543 | - public void update_item(GLib.Object item) { |
1544 | + public void update_item(Object item) { |
1545 | if(!(toUpdate.contains(item))) |
1546 | toUpdate.offer(item); |
1547 | |
1548 | - if(!inThread && lm.lw.initializationFinished) { |
1549 | - try { |
1550 | - inThread = true; |
1551 | - Thread.create<void*>(update_db_thread_function, false); |
1552 | - } |
1553 | - catch(GLib.ThreadError err) { |
1554 | - stdout.printf("Could not create thread to update database: %s \n", err.message); |
1555 | - } |
1556 | - } |
1557 | - } |
1558 | - |
1559 | - public void update_medias(Collection<Media> updates) { |
1560 | - update_mutex.lock(); |
1561 | - foreach(var s in updates) |
1562 | - media_updates.offer(s); |
1563 | - update_mutex.unlock(); |
1564 | - |
1565 | - if(!inThread && lm.lw.initializationFinished) { |
1566 | - try { |
1567 | - inThread = true; |
1568 | - Thread.create<void*>(update_db_thread_function, false); |
1569 | - } |
1570 | - catch(GLib.ThreadError err) { |
1571 | - stdout.printf("Could not create thread to update database: %s \n", err.message); |
1572 | - } |
1573 | - } |
1574 | - } |
1575 | - |
1576 | - public void removeItem(GLib.Object item) { |
1577 | - remove_mutex.lock(); |
1578 | - if(!(toRemove.contains(item))) |
1579 | - toRemove.offer(item); |
1580 | - remove_mutex.unlock(); |
1581 | - |
1582 | - if(!inThread && lm.lw.initializationFinished) { |
1583 | - try { |
1584 | - inThread = true; |
1585 | - Thread.create<void*>(update_db_thread_function, false); |
1586 | - } |
1587 | - catch(GLib.ThreadError err) { |
1588 | - stdout.printf("Could not create thread to update database: %s \n", err.message); |
1589 | - } |
1590 | - } |
1591 | - } |
1592 | - |
1593 | - public void* update_db_thread_function () { |
1594 | - while(true) { |
1595 | - GLib.Object next; |
1596 | - |
1597 | - update_mutex.lock(); |
1598 | - remove_mutex.lock(); |
1599 | - if(media_updates.size > 0) { |
1600 | - dbm.update_medias(media_updates); |
1601 | - media_updates.clear(); |
1602 | - } |
1603 | - else if((next = toUpdate.poll()) != null) { |
1604 | + update_database_async (); |
1605 | + } |
1606 | + |
1607 | + public void update_medias(Gee.Collection<Media> updates) { |
1608 | + lock (media_updates) { |
1609 | + foreach (var s in updates) |
1610 | + media_updates.offer (s); |
1611 | + } |
1612 | + |
1613 | + update_database_async (); |
1614 | + } |
1615 | + |
1616 | + public void removeItem (Object item) { |
1617 | + lock (toRemove) { |
1618 | + if (!(toRemove.contains(item))) |
1619 | + toRemove.offer (item); |
1620 | + } |
1621 | + |
1622 | + update_database_async (); |
1623 | + } |
1624 | + |
1625 | + private async void update_database_async () { |
1626 | + if(!inThread && lm.lw.initializationFinished) { |
1627 | + try { |
1628 | + inThread = true; |
1629 | + new Thread<void*>.try (null, update_db_thread_function); |
1630 | + } |
1631 | + catch (Error err) { |
1632 | + warning ("Could not create thread to update database: %s", err.message); |
1633 | + inThread = false; |
1634 | + } |
1635 | + } |
1636 | + } |
1637 | + |
1638 | + |
1639 | + Mutex update_db_lock; |
1640 | + |
1641 | + private void* update_db_thread_function () { |
1642 | + update_db_lock.lock (); |
1643 | + |
1644 | + while (true) { |
1645 | + Object? next = null; |
1646 | + |
1647 | + if (media_updates.size > 0) { |
1648 | + dbm.update_medias (media_updates); |
1649 | + media_updates.clear (); |
1650 | + } |
1651 | + else if ((next = toUpdate.poll()) != null) { |
1652 | + // FIXME: NOTHING TO DO |
1653 | if(next is Playlist) { |
1654 | + warning ("update_db_thread_function: %next is Playlist. HANDLE IT!"); |
1655 | //dbm.update_playlist((Playlist)next); |
1656 | } |
1657 | else if(next is SmartPlaylist) { |
1658 | + warning ("update_db_thread_function: %next is SmartPlaylist. HANDLE IT!"); |
1659 | //dbm.update_smart_playlist((SmartPlaylist)next); |
1660 | } |
1661 | } |
1662 | else if((next = toRemove.poll()) != null) { |
1663 | - if(next is LinkedList) { |
1664 | - dbm.remove_medias((LinkedList<string>)next); |
1665 | + if(next is Gee.LinkedList) { |
1666 | + dbm.remove_medias((Gee.LinkedList<string>)next); |
1667 | } |
1668 | else if(next is Playlist) { |
1669 | dbm.remove_playlist((Playlist)next); |
1670 | @@ -141,18 +129,15 @@ |
1671 | } |
1672 | else { |
1673 | inThread = false; |
1674 | - update_mutex.unlock(); |
1675 | - remove_mutex.unlock(); |
1676 | - return null; |
1677 | + break; |
1678 | } |
1679 | - |
1680 | - update_mutex.unlock(); |
1681 | - remove_mutex.unlock(); |
1682 | } |
1683 | |
1684 | + update_db_lock.unlock (); |
1685 | + return null; |
1686 | } |
1687 | |
1688 | - GLib.List<TreeViewSetup> tree_view_setups; |
1689 | + List<TreeViewSetup> tree_view_setups; |
1690 | |
1691 | public void register_autosaved_column (string name, TreeViewSetup setup) { |
1692 | setup.set_data<string>("name", name); |
1693 | @@ -160,7 +145,7 @@ |
1694 | } |
1695 | |
1696 | void save_others() { |
1697 | - var playlists_and_queue = new LinkedList<Playlist>(); |
1698 | + var playlists_and_queue = new Gee.LinkedList<Playlist>(); |
1699 | playlists_and_queue.add_all(lm.playlists()); |
1700 | |
1701 | Playlist p_queue = new Playlist(); |
1702 | @@ -195,7 +180,7 @@ |
1703 | playlists_and_queue.add(p_podcast); |
1704 | playlists_and_queue.add(p_station); |
1705 | |
1706 | - debug("Doing periodic save\n"); |
1707 | + debug("Doing periodic save"); |
1708 | |
1709 | dbm.save_playlists(playlists_and_queue); |
1710 | dbm.save_smart_playlists(lm.smart_playlists()); |
1711 | |
1712 | === modified file 'src/Devices/CDRomDevice.vala' |
1713 | --- src/Devices/CDRomDevice.vala 2012-06-01 22:48:28 +0000 |
1714 | +++ src/Devices/CDRomDevice.vala 2012-07-03 06:49:24 +0000 |
1715 | @@ -69,10 +69,10 @@ |
1716 | lm.progress_cancel_clicked.connect(cancel_transfer); |
1717 | |
1718 | try { |
1719 | - Thread.create<void*>(finish_initialization_thread, false); |
1720 | + new Thread<void*>.try (null, finish_initialization_thread); |
1721 | } |
1722 | - catch(GLib.ThreadError err) { |
1723 | - stdout.printf("ERROR: Could not create thread to finish ipod initialization: %s \n", err.message); |
1724 | + catch (Error err) { |
1725 | + warning ("Could not create thread to finish ipod initialization: %s", err.message); |
1726 | } |
1727 | } |
1728 | |
1729 | |
1730 | === modified file 'src/Devices/DeviceManager.vala' |
1731 | --- src/Devices/DeviceManager.vala 2012-07-02 23:17:27 +0000 |
1732 | +++ src/Devices/DeviceManager.vala 2012-07-03 06:49:24 +0000 |
1733 | @@ -27,7 +27,6 @@ |
1734 | VolumeMonitor vm; |
1735 | LinkedList<Device> devices; |
1736 | |
1737 | - Mutex _pref_lock; |
1738 | HashTable<string, DevicePreferences> _device_preferences; |
1739 | |
1740 | public signal void device_added(Device d); |
1741 | @@ -38,15 +37,14 @@ |
1742 | vm = VolumeMonitor.get(); |
1743 | devices = new LinkedList<Device>(); |
1744 | |
1745 | - _pref_lock = new Mutex(); |
1746 | _device_preferences = new HashTable<string, DevicePreferences>(null, null); |
1747 | |
1748 | // pre-load devices and their preferences |
1749 | - _pref_lock.lock(); |
1750 | - foreach(DevicePreferences dp in lm.dbm.load_devices()) { |
1751 | - _device_preferences.set(dp.id, dp); |
1752 | + lock (_device_preferences) { |
1753 | + foreach(DevicePreferences dp in lm.dbm.load_devices()) { |
1754 | + _device_preferences.set(dp.id, dp); |
1755 | + } |
1756 | } |
1757 | - _pref_lock.unlock(); |
1758 | |
1759 | vm.mount_added.connect(mount_added); |
1760 | vm.mount_changed.connect(mount_changed); |
1761 | @@ -59,10 +57,15 @@ |
1762 | |
1763 | // this can take time if we have to rev up the cd drive |
1764 | try { |
1765 | - Thread.create<void*>(get_pre_existing_mounts, false); |
1766 | + new Thread<void*>.try (null, get_pre_existing_mounts); |
1767 | } |
1768 | +<<<<<<< TREE |
1769 | catch(GLib.ThreadError err) { |
1770 | warning("ERROR: could not create mount getter thread: %s \n", err.message); |
1771 | +======= |
1772 | + catch (Error err) { |
1773 | + warning ("Could not create mount getter thread: %s", err.message); |
1774 | +>>>>>>> MERGE-SOURCE |
1775 | } |
1776 | } |
1777 | |
1778 | @@ -126,6 +129,7 @@ |
1779 | else if(lm.settings.getMusicFolder().contains(mount.get_default_location().get_path())) { |
1780 | // user mounted music folder, rescan for images |
1781 | lm.settings.setMusicMountName(mount.get_volume().get_name()); |
1782 | +<<<<<<< TREE |
1783 | lm.recheck_files_not_found(); |
1784 | |
1785 | try { |
1786 | @@ -134,6 +138,10 @@ |
1787 | catch(GLib.ThreadError err) { |
1788 | message("Could not create thread to load media pixbuf's: %s \n", err.message); |
1789 | } |
1790 | +======= |
1791 | + lm.recheck_files_not_found_async (); |
1792 | + lm.fetch_image_cache_async (); |
1793 | +>>>>>>> MERGE-SOURCE |
1794 | |
1795 | return; |
1796 | } |
1797 | @@ -190,11 +198,9 @@ |
1798 | public GLib.List<DevicePreferences> device_preferences() { |
1799 | var rv = new GLib.List<DevicePreferences>(); |
1800 | |
1801 | - _pref_lock.lock(); |
1802 | - foreach(var pref in _device_preferences.get_values()) { |
1803 | - rv.append(pref); |
1804 | + foreach (var pref in _device_preferences.get_values()) { |
1805 | + rv.append (pref); |
1806 | } |
1807 | - _pref_lock.unlock(); |
1808 | |
1809 | return rv; |
1810 | } |
1811 | @@ -204,8 +210,8 @@ |
1812 | } |
1813 | |
1814 | public void add_device_preferences(DevicePreferences dp) { |
1815 | - _pref_lock.lock(); |
1816 | - _device_preferences.set(dp.id, dp); |
1817 | - _pref_lock.unlock(); |
1818 | + lock (_device_preferences) { |
1819 | + _device_preferences.set(dp.id, dp); |
1820 | + } |
1821 | } |
1822 | } |
1823 | |
1824 | === modified file 'src/Devices/iPodDevice.vala' |
1825 | --- src/Devices/iPodDevice.vala 2012-07-02 22:57:45 +0000 |
1826 | +++ src/Devices/iPodDevice.vala 2012-07-03 06:49:24 +0000 |
1827 | @@ -98,10 +98,10 @@ |
1828 | }); |
1829 | |
1830 | try { |
1831 | - Thread.create<void*>(finish_initialization_thread, false); |
1832 | + new Thread<void*>.try (null, finish_initialization_thread); |
1833 | } |
1834 | - catch(GLib.ThreadError err) { |
1835 | - stdout.printf("ERROR: Could not create thread to finish ipod initialization: %s \n", err.message); |
1836 | + catch(Error err) { |
1837 | + warning ("Could not create thread to finish ipod initialization: %s", err.message); |
1838 | } |
1839 | } |
1840 | |
1841 | @@ -325,10 +325,10 @@ |
1842 | this.list = list; |
1843 | |
1844 | try { |
1845 | - Thread.create<void*>(sync_medias_thread, false); |
1846 | + new Thread<void*>.try (null, sync_medias_thread); |
1847 | } |
1848 | - catch(GLib.ThreadError err) { |
1849 | - stdout.printf("ERROR: Could not create thread to sync medias: %s \n", err.message); |
1850 | + catch (Error err) { |
1851 | + warning ("Could not create thread to sync medias: %s", err.message); |
1852 | return false; |
1853 | } |
1854 | |
1855 | @@ -542,10 +542,10 @@ |
1856 | this.list = list; |
1857 | |
1858 | try { |
1859 | - Thread.create<void*>(add_medias_thread, false); |
1860 | + new Thread<void*>.try (null, add_medias_thread); |
1861 | } |
1862 | - catch(GLib.ThreadError err) { |
1863 | - stdout.printf("ERROR: Could not create thread to add medias: %s \n", err.message); |
1864 | + catch (Error err) { |
1865 | + warning ("Could not create thread to add medias: %s", err.message); |
1866 | return false; |
1867 | } |
1868 | |
1869 | @@ -698,10 +698,10 @@ |
1870 | this.list = list; |
1871 | |
1872 | try { |
1873 | - Thread.create<void*>(remove_medias_thread, false); |
1874 | + new Thread<void*>.try (null, remove_medias_thread); |
1875 | } |
1876 | - catch(GLib.ThreadError err) { |
1877 | - stdout.printf("ERROR: Could not create thread to remove medias: %s \n", err.message); |
1878 | + catch (Error err) { |
1879 | + warning ("Could not create thread to remove medias: %s", err.message); |
1880 | return false; |
1881 | } |
1882 | |
1883 | @@ -931,10 +931,10 @@ |
1884 | current_operation = _("Importing") + " <b>" + ((list.size > 1) ? list.size.to_string() : (list.get(0)).title) + "</b> " + _("items to library..."); |
1885 | |
1886 | try { |
1887 | - Thread.create<void*>(transfer_medias_thread, false); |
1888 | + new Thread<void*>.try (null, transfer_medias_thread); |
1889 | } |
1890 | - catch(GLib.ThreadError err) { |
1891 | - stdout.printf("ERROR: Could not create thread to transfer medias: %s \n", err.message); |
1892 | + catch(Error err) { |
1893 | + warning ("Could not create thread to transfer media: %s", err.message); |
1894 | return false; |
1895 | } |
1896 | |
1897 | |
1898 | === modified file 'src/Lastfm/LastFM.vala' |
1899 | --- src/Lastfm/LastFM.vala 2012-06-06 02:59:17 +0000 |
1900 | +++ src/Lastfm/LastFM.vala 2012-07-03 06:49:24 +0000 |
1901 | @@ -20,10 +20,6 @@ |
1902 | * Boston, MA 02111-1307, USA. |
1903 | */ |
1904 | |
1905 | -using Xml; |
1906 | -using Soup; |
1907 | -using Gee; |
1908 | - |
1909 | public class LastFM.Core : Object { |
1910 | BeatBox.LibraryManager lm; |
1911 | |
1912 | @@ -36,7 +32,7 @@ |
1913 | public string session_key; |
1914 | |
1915 | public signal void logged_in(); |
1916 | - public signal void similar_retrieved(LinkedList<int> similarIDs, LinkedList<BeatBox.Media> similarDont); |
1917 | + public signal void similar_retrieved(Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); |
1918 | public signal void top_artist_songs_retrieved(HashTable<int, BeatBox.Media> songs); |
1919 | public signal void top_artist_albums_retrieved(HashTable<int, BeatBox.ExternalAlbum> albums); |
1920 | public signal void track_fetched(); |
1921 | @@ -46,13 +42,10 @@ |
1922 | LastFM.SimilarMedias similarMedias; |
1923 | LastFM.TopArtistSongs topArtistSongs; |
1924 | LastFM.TopArtistAlbums topArtistAlbums; |
1925 | - |
1926 | - Mutex _artists_lock; |
1927 | - Mutex _albums_lock; |
1928 | - Mutex _tracks_lock; |
1929 | - HashMap<string, LastFM.ArtistInfo> _artists;//key:artist |
1930 | - HashMap<string, LastFM.AlbumInfo> _albums;//key:artist<sep>album |
1931 | - HashMap<string, LastFM.TrackInfo> _tracks;//key:artist<sep>album<sep>track |
1932 | + |
1933 | + Gee.HashMap<string, LastFM.ArtistInfo> _artists;//key:artist |
1934 | + Gee.HashMap<string, LastFM.AlbumInfo> _albums;//key:artist<sep>album |
1935 | + Gee.HashMap<string, LastFM.TrackInfo> _tracks;//key:artist<sep>album<sep>track |
1936 | |
1937 | public Core(BeatBox.LibraryManager lmm) { |
1938 | lm = lmm; |
1939 | @@ -61,32 +54,28 @@ |
1940 | similarMedias = new LastFM.SimilarMedias(lm); |
1941 | topArtistSongs = new LastFM.TopArtistSongs(lm); |
1942 | topArtistAlbums = new LastFM.TopArtistAlbums(lm); |
1943 | - |
1944 | - _artists_lock = new Mutex(); |
1945 | - _albums_lock = new Mutex(); |
1946 | - _tracks_lock = new Mutex(); |
1947 | - |
1948 | - _artists = new HashMap<string, LastFM.ArtistInfo>(); |
1949 | - _albums = new HashMap<string, LastFM.AlbumInfo>(); |
1950 | - _tracks = new HashMap<string, LastFM.TrackInfo>(); |
1951 | - |
1952 | - _artists_lock.lock(); |
1953 | - foreach(LastFM.ArtistInfo a in lm.dbm.load_artists()) { |
1954 | - _artists.set(a.name.down(), a); |
1955 | - } |
1956 | - _artists_lock.unlock(); |
1957 | - |
1958 | - _albums_lock.lock(); |
1959 | - foreach(LastFM.AlbumInfo a in lm.dbm.load_albums()) { |
1960 | - _albums.set(a.name.down() + " by " + a.artist.down(), a); |
1961 | - } |
1962 | - _albums_lock.unlock(); |
1963 | - |
1964 | - _tracks_lock.lock(); |
1965 | - foreach(LastFM.TrackInfo t in lm.dbm.load_tracks()) { |
1966 | - _tracks.set(t.name.down() + " by " + t.artist.down(), t); |
1967 | - } |
1968 | - _tracks_lock.unlock(); |
1969 | + |
1970 | + _artists = new Gee.HashMap<string, LastFM.ArtistInfo>(); |
1971 | + _albums = new Gee.HashMap<string, LastFM.AlbumInfo>(); |
1972 | + _tracks = new Gee.HashMap<string, LastFM.TrackInfo>(); |
1973 | + |
1974 | + lock (_artists) { |
1975 | + foreach (LastFM.ArtistInfo a in lm.dbm.load_artists()) { |
1976 | + _artists.set (a.name.down(), a); |
1977 | + } |
1978 | + } |
1979 | + |
1980 | + lock (_albums) { |
1981 | + foreach (LastFM.AlbumInfo a in lm.dbm.load_albums()) { |
1982 | + _albums.set (a.name.down() + " by " + a.artist.down(), a); |
1983 | + } |
1984 | + } |
1985 | + |
1986 | + lock (_tracks) { |
1987 | + foreach (LastFM.TrackInfo t in lm.dbm.load_tracks()) { |
1988 | + _tracks.set (t.name.down() + " by " + t.artist.down(), t); |
1989 | + } |
1990 | + } |
1991 | |
1992 | similarMedias.similar_retrieved.connect(similar_retrieved_signal); |
1993 | topArtistSongs.top_artist_songs_retrieved.connect(top_artist_songs_retrieved_signal); |
1994 | @@ -94,42 +83,40 @@ |
1995 | } |
1996 | |
1997 | /************* Last FM Artist Stuff ************/ |
1998 | - public GLib.List<LastFM.ArtistInfo> artists() { |
1999 | - var rv = new GLib.List<LastFM.ArtistInfo>(); |
2000 | + public List<LastFM.ArtistInfo> artists () { |
2001 | + var rv = new List<LastFM.ArtistInfo>(); |
2002 | foreach(var artist in _artists.values) |
2003 | rv.append(artist); |
2004 | |
2005 | return rv; |
2006 | } |
2007 | |
2008 | - public void save_artist(LastFM.ArtistInfo artist) { |
2009 | - _artists_lock.lock(); |
2010 | - _artists.set(artist.name.down(), artist); |
2011 | - _artists_lock.unlock(); |
2012 | - } |
2013 | - |
2014 | - public bool artist_info_exists(string artist_key) { |
2015 | - return _artists.get(artist_key.down()) != null; |
2016 | - } |
2017 | - |
2018 | - public LastFM.ArtistInfo? get_artist_from_media(BeatBox.Media m) { |
2019 | - return get_artist(m.album_artist.down()); |
2020 | - } |
2021 | - |
2022 | - public LastFM.ArtistInfo? get_artist(string artist_key) { |
2023 | + public void save_artist (LastFM.ArtistInfo artist) { |
2024 | + lock (_artists) { |
2025 | + _artists.set (artist.name.down(), artist); |
2026 | + } |
2027 | + } |
2028 | + |
2029 | + public bool artist_info_exists (string artist_key) { |
2030 | + return _artists.has_key (artist_key.down()); |
2031 | + } |
2032 | + |
2033 | + public LastFM.ArtistInfo? get_artist_from_media (BeatBox.Media m) { |
2034 | + return get_artist (m.album_artist); |
2035 | + } |
2036 | + |
2037 | + public LastFM.ArtistInfo? get_artist (string artist_key) { |
2038 | LastFM.ArtistInfo? rv = null; |
2039 | |
2040 | - _artists_lock.lock(); |
2041 | - if(artist_info_exists(artist_key.down())) |
2042 | - rv = _artists.get(artist_key.down()); |
2043 | - _artists_lock.unlock(); |
2044 | - |
2045 | + if (artist_info_exists (artist_key)) |
2046 | + rv = _artists.get (artist_key.down()); |
2047 | + |
2048 | return rv; |
2049 | } |
2050 | |
2051 | /************** LastFM Album stuff **************/ |
2052 | - public GLib.List<LastFM.AlbumInfo> albums() { |
2053 | - var rv = new GLib.List<LastFM.AlbumInfo>(); |
2054 | + public List<LastFM.AlbumInfo> albums() { |
2055 | + var rv = new List<LastFM.AlbumInfo>(); |
2056 | foreach(var album in _albums.values) |
2057 | rv.append(album); |
2058 | |
2059 | @@ -137,33 +124,31 @@ |
2060 | } |
2061 | |
2062 | public void save_album(LastFM.AlbumInfo album) { |
2063 | - _albums_lock.lock(); |
2064 | - _albums.set(album.name.down() + " by " + album.artist.down(), album); |
2065 | - _albums_lock.unlock(); |
2066 | + lock (_albums) { |
2067 | + _albums.set(album.name.down() + " by " + album.artist.down(), album); |
2068 | + } |
2069 | } |
2070 | |
2071 | public bool album_info_exists(string album_key) { |
2072 | - return _albums.get(album_key) != null; |
2073 | + return _albums.has_key (album_key.down()); |
2074 | } |
2075 | |
2076 | - public LastFM.AlbumInfo? get_album_from_media(BeatBox.Media m) { |
2077 | - return get_album(m.album.down() + " by " + m.album_artist.down()); |
2078 | + public LastFM.AlbumInfo? get_album_from_media (BeatBox.Media m) { |
2079 | + return get_album (m.album.down() + " by " + m.album_artist.down()); |
2080 | } |
2081 | |
2082 | public LastFM.AlbumInfo? get_album(string album_key) { |
2083 | LastFM.AlbumInfo? rv = null; |
2084 | |
2085 | - _albums_lock.lock(); |
2086 | - if(album_info_exists(album_key.down())) |
2087 | - rv = _albums.get(album_key.down()); |
2088 | - _albums_lock.unlock(); |
2089 | - |
2090 | + if(album_info_exists (album_key)) |
2091 | + rv = _albums.get (album_key.down()); |
2092 | + |
2093 | return rv; |
2094 | } |
2095 | |
2096 | /************** Last FM Track Stuff ***************/ |
2097 | - public GLib.List<LastFM.TrackInfo> tracks() { |
2098 | - var rv = new GLib.List<LastFM.TrackInfo>(); |
2099 | + public List<LastFM.TrackInfo> tracks() { |
2100 | + var rv = new List<LastFM.TrackInfo>(); |
2101 | foreach(var track in _tracks.values) |
2102 | rv.append(track); |
2103 | |
2104 | @@ -171,37 +156,35 @@ |
2105 | } |
2106 | |
2107 | public void save_track(LastFM.TrackInfo track) { |
2108 | - _tracks_lock.lock(); |
2109 | - _tracks.set(track.name.down() + " by " + track.artist.down(), track); |
2110 | - _tracks_lock.unlock(); |
2111 | + lock (_tracks) { |
2112 | + _tracks.set (track.name.down() + " by " + track.artist.down(), track); |
2113 | + } |
2114 | } |
2115 | |
2116 | public bool track_info_exists(string track_key) { |
2117 | - return _tracks.get(track_key.down()) != null; |
2118 | - } |
2119 | - |
2120 | - public LastFM.TrackInfo? get_track_from_media(BeatBox.Media m) { |
2121 | - return get_track(m.title.down() + " by " + m.album_artist.down()); |
2122 | - } |
2123 | - |
2124 | - public LastFM.TrackInfo? get_track(string track_key) { |
2125 | + return _tracks.has_key (track_key.down()); |
2126 | + } |
2127 | + |
2128 | + public LastFM.TrackInfo? get_track_from_media (BeatBox.Media m) { |
2129 | + return get_track (m.title.down() + " by " + m.album_artist.down()); |
2130 | + } |
2131 | + |
2132 | + public LastFM.TrackInfo? get_track (string track_key) { |
2133 | LastFM.TrackInfo? rv = null; |
2134 | |
2135 | - _tracks_lock.lock(); |
2136 | - if(track_info_exists(track_key.down())) |
2137 | - rv = _tracks.get(track_key.down()); |
2138 | - _tracks_lock.unlock(); |
2139 | + if (track_info_exists (track_key.down())) |
2140 | + rv = _tracks.get (track_key.down()); |
2141 | |
2142 | return rv; |
2143 | } |
2144 | |
2145 | /** Last.FM Api functions **/ |
2146 | - public static string fix_for_url(string fix) { |
2147 | - return GLib.Uri.escape_string(fix, null, false); |
2148 | + public static string fix_for_url (string fix) { |
2149 | + return Uri.escape_string (fix, "", false); |
2150 | } |
2151 | |
2152 | public string generate_md5(string text) { |
2153 | - return GLib.Checksum.compute_for_string(ChecksumType.MD5, text, text.length); |
2154 | + return Checksum.compute_for_string(ChecksumType.MD5, text, text.length); |
2155 | } |
2156 | |
2157 | public string generate_getsession_signature(string token) { |
2158 | @@ -227,9 +210,9 @@ |
2159 | public string? getToken() { |
2160 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.gettoken&api_key=" + api; |
2161 | |
2162 | - Xml.Doc* doc = Parser.parse_file (url); |
2163 | + Xml.Doc* doc = Xml.Parser.parse_file (url); |
2164 | if(doc == null) return null; |
2165 | - |
2166 | + |
2167 | Xml.Node* root = doc->get_root_element(); |
2168 | if(root == null) return null; |
2169 | |
2170 | @@ -246,9 +229,9 @@ |
2171 | var sig = generate_getsession_signature(token); |
2172 | var url = "http://ws.audioscrobbler.com/2.0/?method=auth.getSession&api_key=" + api + "&api_sig=" + sig + "&token=" + token; |
2173 | |
2174 | - message("url: %s\n", url); |
2175 | + message ("url: %s", url); |
2176 | |
2177 | - Xml.Doc* doc = Parser.parse_file (url); |
2178 | + Xml.Doc* doc = Xml.Parser.parse_file (url); |
2179 | if(doc == null) return null; |
2180 | |
2181 | Xml.Node* root = doc->get_root_element(); |
2182 | @@ -268,7 +251,7 @@ |
2183 | |
2184 | public bool loveTrack(string title, string artist) { |
2185 | if(session_key == null || session_key == "") { |
2186 | - debug("User tried to ban a track, but is not logged into Last FM\n"); |
2187 | + debug("User tried to ban a track, but is not logged into Last FM"); |
2188 | return false; |
2189 | } |
2190 | |
2191 | @@ -277,7 +260,7 @@ |
2192 | Soup.SessionSync session = new Soup.SessionSync(); |
2193 | Soup.Message message = new Soup.Message ("POST", uri); |
2194 | |
2195 | - var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); |
2196 | + var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2197 | headers.append("api_key", api); |
2198 | headers.append("api_sig", generate_tracklove_signature(artist, title)); |
2199 | headers.append("artist", artist); |
2200 | @@ -298,7 +281,7 @@ |
2201 | |
2202 | public bool banTrack(string title, string artist) { |
2203 | if(session_key == null || session_key == "") { |
2204 | - debug("User tried to ban a track, but is not logged into Last FM\n"); |
2205 | + debug("User tried to ban a track, but is not logged into Last FM"); |
2206 | return false; |
2207 | } |
2208 | |
2209 | @@ -307,7 +290,7 @@ |
2210 | Soup.SessionSync session = new Soup.SessionSync(); |
2211 | Soup.Message message = new Soup.Message ("POST", uri); |
2212 | |
2213 | - var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); |
2214 | + var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2215 | headers.append("api_key", api); |
2216 | headers.append("api_sig", generate_trackban_signature(artist, title)); |
2217 | headers.append("artist", artist); |
2218 | @@ -330,13 +313,13 @@ |
2219 | */ |
2220 | public void fetchCurrentTrackInfo() { |
2221 | try { |
2222 | - Thread.create<void*>(track_thread_function, false); |
2223 | - } catch(GLib.ThreadError err) { |
2224 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2225 | + new Thread<void*>.try (null, track_thread_function); |
2226 | + } catch (Error err) { |
2227 | + warning ("Could not create last fm thread: %s", err.message); |
2228 | } |
2229 | } |
2230 | |
2231 | - void* track_thread_function () { |
2232 | + private void* track_thread_function () { |
2233 | LastFM.TrackInfo track = new LastFM.TrackInfo.basic(); |
2234 | |
2235 | string album_artist_s = lm.media_info.media.album_artist; |
2236 | @@ -364,13 +347,13 @@ |
2237 | |
2238 | public void fetchCurrentAlbumInfo() { |
2239 | try { |
2240 | - Thread.create<void*>(album_thread_function, false); |
2241 | - } catch(GLib.ThreadError err) { |
2242 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2243 | + new Thread<void*>.try (null, album_thread_function); |
2244 | + } catch (Error err) { |
2245 | + warning ("Could not create last fm thread: %s", err.message); |
2246 | } |
2247 | } |
2248 | |
2249 | - void* album_thread_function () { |
2250 | + private void* album_thread_function () { |
2251 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); |
2252 | |
2253 | string album_artist_s = lm.media_info.media.album_artist; |
2254 | @@ -391,12 +374,12 @@ |
2255 | |
2256 | /* If we found an album art, and we don't have one yet, save it to file **/ |
2257 | if(album.url_image.url != null && lm.get_cover_album_art_from_key(album_artist_s, album_s) == null) { |
2258 | - debug("Saving album image locally for %s by %s\n", album_s, album_artist_s); |
2259 | + debug("Saving album image locally for %s by %s", album_s, album_artist_s); |
2260 | lm.save_album_locally(lm.media_info.media.rowid, album.url_image.url, false); |
2261 | } |
2262 | |
2263 | // Fix up the track # on any songs in our library |
2264 | - var updates = new LinkedList<BeatBox.Media>(); |
2265 | + var updates = new Gee.LinkedList<BeatBox.Media>(); |
2266 | foreach(var m in album.tracks()) { |
2267 | var in_lib = lm.media_from_name(m.title, m.artist); |
2268 | if(in_lib != null && in_lib.track != m.track) { |
2269 | @@ -418,13 +401,13 @@ |
2270 | */ |
2271 | public void fetchCurrentArtistInfo() { |
2272 | try { |
2273 | - Thread.create<void*>(artist_thread_function, false); |
2274 | - } catch(GLib.ThreadError err) { |
2275 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2276 | + new Thread<void*>.try (null, artist_thread_function); |
2277 | + } catch (Error err) { |
2278 | + warning ("Could not create last fm thread: %s", err.message); |
2279 | } |
2280 | } |
2281 | |
2282 | - void* artist_thread_function () { |
2283 | + private void* artist_thread_function () { |
2284 | LastFM.ArtistInfo artist = new LastFM.ArtistInfo.basic(); |
2285 | |
2286 | string album_artist_s = lm.media_info.media.album_artist; |
2287 | @@ -456,15 +439,15 @@ |
2288 | */ |
2289 | public void postNowPlaying() { |
2290 | try { |
2291 | - Thread.create<void*>(update_nowplaying_thread_function, false); |
2292 | - } catch(GLib.ThreadError err) { |
2293 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2294 | + new Thread<void*>.try (null, update_nowplaying_thread_function); |
2295 | + } catch (Error err) { |
2296 | + warning ("Could not create last fm thread: %s", err.message); |
2297 | } |
2298 | } |
2299 | |
2300 | void* update_nowplaying_thread_function() { |
2301 | if(session_key == null || session_key == "") { |
2302 | - debug("Last.FM user not logged in\n"); |
2303 | + debug("Last.FM user not logged in"); |
2304 | return null; |
2305 | } |
2306 | if(!lm.media_active) |
2307 | @@ -477,7 +460,7 @@ |
2308 | Soup.SessionSync session = new Soup.SessionSync(); |
2309 | Soup.Message message = new Soup.Message ("POST", uri); |
2310 | |
2311 | - var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); |
2312 | + var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2313 | headers.append("api_key", api); |
2314 | headers.append("api_sig", generate_trackupdatenowplaying_signature(artist, title)); |
2315 | headers.append("artist", artist); |
2316 | @@ -501,15 +484,15 @@ |
2317 | */ |
2318 | public void postScrobbleTrack() { |
2319 | try { |
2320 | - Thread.create<void*>(scrobble_thread_function, false); |
2321 | - } catch(GLib.ThreadError err) { |
2322 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2323 | + new Thread<void*>.try (null, scrobble_thread_function); |
2324 | + } catch (Error err) { |
2325 | + warning ("Could not create last fm thread: %s", err.message); |
2326 | } |
2327 | } |
2328 | |
2329 | void* scrobble_thread_function () { |
2330 | if(session_key == null || session_key == "") { |
2331 | - debug("Last.FM user not logged in\n"); |
2332 | + debug("Last.FM user not logged in"); |
2333 | return null; |
2334 | } |
2335 | if(!lm.media_active) |
2336 | @@ -523,7 +506,7 @@ |
2337 | Soup.SessionSync session = new Soup.SessionSync(); |
2338 | Soup.Message message = new Soup.Message ("POST", uri); |
2339 | |
2340 | - var headers = new Soup.MessageHeaders(MessageHeadersType.REQUEST); |
2341 | + var headers = new Soup.MessageHeaders(Soup.MessageHeadersType.REQUEST); |
2342 | headers.append("api_key", api); |
2343 | headers.append("api_sig", generate_trackscrobble_signature(artist, title, timestamp)); |
2344 | headers.append("artist", artist); |
2345 | @@ -547,7 +530,7 @@ |
2346 | similarMedias.queryForSimilar(lm.media_info.media); |
2347 | } |
2348 | |
2349 | - void similar_retrieved_signal(LinkedList<int> similarIDs, LinkedList<BeatBox.Media> similarDont) { |
2350 | + void similar_retrieved_signal(Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont) { |
2351 | similar_retrieved(similarIDs, similarDont); |
2352 | } |
2353 | |
2354 | @@ -569,19 +552,19 @@ |
2355 | |
2356 | public void fetch_remaining_album_art() { |
2357 | try { |
2358 | - Thread.create<void*>(fetch_remaining_album_art_thread, false); |
2359 | - } catch(GLib.ThreadError err) { |
2360 | - warning ("ERROR: Could not create last fm thread: %s \n", err.message); |
2361 | + new Thread<void*>.try (null, fetch_remaining_album_art_thread); |
2362 | + } catch (Error err) { |
2363 | + warning ("Could not create last fm thread: %s", err.message); |
2364 | } |
2365 | } |
2366 | |
2367 | public void* fetch_remaining_album_art_thread() { |
2368 | var all_media = lm.medias(); |
2369 | - var remaining = new HashMap<string, BeatBox.Album>(); // hashmap of albums with no art |
2370 | + var remaining = new Gee.HashMap<string, BeatBox.Album>(); // hashmap of albums with no art |
2371 | foreach(var m in all_media) { |
2372 | string key = lm.album_key(m); |
2373 | |
2374 | - if(remaining.get(key) != null) // already known |
2375 | + if (remaining.has_key (key)) // already known |
2376 | continue; |
2377 | |
2378 | if(lm.get_cover_album_art(m.rowid) == null) { |
2379 | @@ -603,12 +586,12 @@ |
2380 | |
2381 | /* If we found an album art, save it to file **/ |
2382 | if(album_info != null && album_info.url_image.url != null && album_info.url_image.url != "") { |
2383 | - debug("Saving album image locally for %s by %s\n", album_s, album_artist_s); |
2384 | + debug("Saving album image locally for %s by %s", album_s, album_artist_s); |
2385 | lm.save_album_locally(m.rowid, album_info.url_image.url, false); |
2386 | } |
2387 | } |
2388 | |
2389 | - message("All remaining art fetched\n"); |
2390 | + message("All remaining art fetched"); |
2391 | |
2392 | return null; |
2393 | } |
2394 | |
2395 | === modified file 'src/Lastfm/SimilarMedia.vala' |
2396 | --- src/Lastfm/SimilarMedia.vala 2012-06-02 19:34:06 +0000 |
2397 | +++ src/Lastfm/SimilarMedia.vala 2012-07-03 06:49:24 +0000 |
2398 | @@ -20,8 +20,6 @@ |
2399 | * Boston, MA 02111-1307, USA. |
2400 | */ |
2401 | |
2402 | -using Xml; |
2403 | - |
2404 | public class LastFM.SimilarMedias : Object { |
2405 | BeatBox.LibraryManager _lm; |
2406 | BeatBox.Media _base; |
2407 | @@ -29,7 +27,7 @@ |
2408 | |
2409 | Gee.LinkedList<BeatBox.Media> similar; |
2410 | |
2411 | - public signal void similar_retrieved( Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); |
2412 | + public signal void similar_retrieved (Gee.LinkedList<int> similarIDs, Gee.LinkedList<BeatBox.Media> similarDont); |
2413 | |
2414 | public class SimilarMedias(BeatBox.LibraryManager lm) { |
2415 | _lm = lm; |
2416 | @@ -43,10 +41,10 @@ |
2417 | working = true; |
2418 | |
2419 | try { |
2420 | - Thread.create<void*>(similar_thread_function, false); |
2421 | + new Thread<void*>.try (null, similar_thread_function); |
2422 | } |
2423 | - catch(GLib.ThreadError err) { |
2424 | - warning("ERROR: Could not create similar thread: %s \n", err.message); |
2425 | + catch (Error err) { |
2426 | + warning ("Could not create similar thread: %s", err.message); |
2427 | } |
2428 | } |
2429 | } |
2430 | @@ -107,7 +105,7 @@ |
2431 | Xml.Node* iter; |
2432 | for (iter = node->children; iter != null; iter = iter->next) { |
2433 | |
2434 | - if (iter->type != ElementType.ELEMENT_NODE) { |
2435 | + if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2436 | continue; |
2437 | } |
2438 | |
2439 | |
2440 | === modified file 'src/Lastfm/TopArtistAlbums.vala' |
2441 | --- src/Lastfm/TopArtistAlbums.vala 2012-07-02 23:17:27 +0000 |
2442 | +++ src/Lastfm/TopArtistAlbums.vala 2012-07-03 06:49:24 +0000 |
2443 | @@ -20,8 +20,6 @@ |
2444 | * Boston, MA 02111-1307, USA. |
2445 | */ |
2446 | |
2447 | -using Xml; |
2448 | - |
2449 | public class LastFM.TopArtistAlbums : Object { |
2450 | static const int MAX_RESULTS = 5; |
2451 | BeatBox.LibraryManager _lm; |
2452 | @@ -46,10 +44,10 @@ |
2453 | working = true; |
2454 | |
2455 | try { |
2456 | - Thread.create<void*>(top_artist_albums_thread_function, false); |
2457 | + new Thread<void*>.try (null, top_artist_albums_thread_function); |
2458 | } |
2459 | - catch(GLib.ThreadError err) { |
2460 | - warning("ERROR: Could not create top artist albums thread: %s \n", err.message); |
2461 | + catch (Error err) { |
2462 | + warning ("ERROR: Could not create top artist albums thread: %s", err.message); |
2463 | } |
2464 | } |
2465 | } |
2466 | @@ -79,7 +77,7 @@ |
2467 | async void uri_to_pixbuf(BeatBox.ExternalAlbum album) { |
2468 | GLib.File file = GLib.File.new_for_uri(album.pixbuf_url); |
2469 | if(file == null) { |
2470 | - stdout.printf("Could not read image_uri as file\n"); |
2471 | + message ("Could not read image_uri as file"); |
2472 | return; |
2473 | } |
2474 | |
2475 | @@ -90,7 +88,11 @@ |
2476 | filestream = yield file.read_async(); |
2477 | pix = yield Gdk.Pixbuf.new_from_stream_at_scale_async(filestream, -1, Icons.ALBUM_VIEW_IMAGE_SIZE, true); |
2478 | } catch(GLib.Error err) { |
2479 | +<<<<<<< TREE |
2480 | debug("Failed to save load art locally from %s: %s\n", album.pixbuf_url, err.message); |
2481 | +======= |
2482 | + warning("Failed to save album art locally from %s: %s", album.pixbuf_url, err.message); |
2483 | +>>>>>>> MERGE-SOURCE |
2484 | } |
2485 | |
2486 | if(pix != null) { |
2487 | @@ -113,11 +115,11 @@ |
2488 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
2489 | |
2490 | if(doc == null) |
2491 | - GLib.message("Could not load top artist albums information for %s\n", artist); |
2492 | + GLib.message("Could not load top artist albums information for %s", artist); |
2493 | else if(doc->get_root_element() == null) |
2494 | - GLib.message("Oddly, top artist albums information was invalid\n"); |
2495 | + GLib.message("Oddly, top artist albums information was invalid"); |
2496 | else { |
2497 | - //GLib.message("Getting top artist albums with %s... \n", url); |
2498 | + //GLib.message("Getting top artist albums with %s...", url); |
2499 | toAdd = null; |
2500 | |
2501 | parse_top_artist_albums_nodes(doc->get_root_element(), ""); |
2502 | @@ -132,7 +134,7 @@ |
2503 | |
2504 | Xml.Node* iter; |
2505 | for (iter = node->children; iter != null; iter = iter->next) { |
2506 | - if (iter->type != ElementType.ELEMENT_NODE) { |
2507 | + if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2508 | continue; |
2509 | } |
2510 | |
2511 | |
2512 | === modified file 'src/Lastfm/TopArtistSongs.vala' |
2513 | --- src/Lastfm/TopArtistSongs.vala 2012-06-02 19:34:06 +0000 |
2514 | +++ src/Lastfm/TopArtistSongs.vala 2012-07-03 06:49:24 +0000 |
2515 | @@ -20,8 +20,6 @@ |
2516 | * Boston, MA 02111-1307, USA. |
2517 | */ |
2518 | |
2519 | -using Xml; |
2520 | - |
2521 | public class LastFM.TopArtistSongs : Object { |
2522 | static const int MAX_RESULTS = 15; |
2523 | BeatBox.LibraryManager _lm; |
2524 | @@ -46,15 +44,15 @@ |
2525 | working = true; |
2526 | |
2527 | try { |
2528 | - Thread.create<void*>(top_artist_songs_thread_function, false); |
2529 | + new Thread<void*>.try (null, top_artist_songs_thread_function); |
2530 | } |
2531 | - catch(GLib.ThreadError err) { |
2532 | - warning("ERROR: Could not create similar thread: %s \n", err.message); |
2533 | + catch (Error err) { |
2534 | + warning("ERROR: Could not create similar thread: %s", err.message); |
2535 | } |
2536 | } |
2537 | } |
2538 | |
2539 | - void* top_artist_songs_thread_function () { |
2540 | + private void* top_artist_songs_thread_function () { |
2541 | songs = new HashTable<int, BeatBox.Media>(null, null); |
2542 | |
2543 | getTopArtistTracks(_base.artist); |
2544 | @@ -96,11 +94,11 @@ |
2545 | Xml.Doc* doc = Xml.Parser.parse_memory((string)message.response_body.data, (int)message.response_body.length); |
2546 | |
2547 | if(doc == null) |
2548 | - GLib.message("Could not load top artist songs information for %s\n", artist); |
2549 | + GLib.message("Could not load top artist songs information for %s", artist); |
2550 | else if(doc->get_root_element() == null) |
2551 | - GLib.message("Oddly, similar artist information was invalid\n"); |
2552 | + GLib.message("Oddly, similar artist information was invalid"); |
2553 | else { |
2554 | - //message("Getting similar tracks with %s... \n", url); |
2555 | + //message("Getting similar tracks with %s...", url); |
2556 | toAdd = null; |
2557 | |
2558 | parse_top_artist_tracks_nodes(doc->get_root_element(), ""); |
2559 | @@ -115,7 +113,7 @@ |
2560 | |
2561 | Xml.Node* iter; |
2562 | for (iter = node->children; iter != null; iter = iter->next) { |
2563 | - if (iter->type != ElementType.ELEMENT_NODE) { |
2564 | + if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
2565 | continue; |
2566 | } |
2567 | |
2568 | |
2569 | === modified file 'src/Lists/GenericList.vala' |
2570 | --- src/Lists/GenericList.vala 2012-06-28 02:26:50 +0000 |
2571 | +++ src/Lists/GenericList.vala 2012-07-03 06:49:24 +0000 |
2572 | @@ -278,10 +278,10 @@ |
2573 | // For songs with no attached uri, try opening its lastfm url |
2574 | if(m.uri == "") { |
2575 | try { |
2576 | - Thread.create<void*>(take_action, false); |
2577 | + new Thread<void*>.try (null, take_action); |
2578 | } |
2579 | - catch(GLib.ThreadError err) { |
2580 | - stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); |
2581 | + catch (Error err) { |
2582 | + warning ("Could not create thread to have fun: %s", err.message); |
2583 | } |
2584 | } |
2585 | else { |
2586 | |
2587 | === modified file 'src/Media/LyricFetcher.vala' |
2588 | --- src/Media/LyricFetcher.vala 2012-06-01 22:48:28 +0000 |
2589 | +++ src/Media/LyricFetcher.vala 2012-07-03 06:49:24 +0000 |
2590 | @@ -42,10 +42,10 @@ |
2591 | this.title = title; |
2592 | |
2593 | try { |
2594 | - Thread.create<void*> (fetch_lyrics_thread, false); |
2595 | + new Thread<void*>.try (null, fetch_lyrics_thread); |
2596 | } |
2597 | - catch(GLib.ThreadError err) { |
2598 | - stderr.printf ("ERROR: Could not create lyrics thread: %s \n", err.message); |
2599 | + catch(GLib.Error err) { |
2600 | + warning ("ERROR: Could not create lyrics thread: %s \n", err.message); |
2601 | } |
2602 | } |
2603 | |
2604 | @@ -87,7 +87,7 @@ |
2605 | |
2606 | /** LYRIC SOURCES **/ |
2607 | |
2608 | -private class AZLyricsFetcher : Object { |
2609 | +private class AZLyricsFetcher { |
2610 | |
2611 | private const string URL_FORMAT = "http://www.azlyrics.com/lyrics/%s/%s.html"; |
2612 | |
2613 | @@ -108,7 +108,7 @@ |
2614 | rv.artist = artist; |
2615 | } |
2616 | catch (Error err) { |
2617 | - //stderr.printf("Could not load contents of %s : %s\n", url, err.message); |
2618 | + //warning("Could not load contents of %s : %s\n", url, err.message); |
2619 | load_successful = false; |
2620 | } |
2621 | |
2622 | @@ -122,13 +122,13 @@ |
2623 | load_successful = true; |
2624 | } |
2625 | catch (Error err) { |
2626 | - //stderr.printf ("Could not load contents of %s : %s\n", url, err.message); |
2627 | + //warning ("Could not load contents of %s : %s\n", url, err.message); |
2628 | load_successful = false; |
2629 | } |
2630 | } |
2631 | |
2632 | if (load_successful) |
2633 | - rv.content = parse_lyrics (uintcontent) + "\n"; |
2634 | + rv.content = "\n" + rv.title + "\n" + rv.artist + "\n\n\n" + parse_lyrics (uintcontent) + "\n"; |
2635 | else |
2636 | throw new FetchingError.LYRICS_NOT_FOUND (@"Lyrics not found for $title"); |
2637 | |
2638 | |
2639 | === modified file 'src/Store/Widgets/AlbumView.vala' |
2640 | --- src/Store/Widgets/AlbumView.vala 2012-06-01 22:48:28 +0000 |
2641 | +++ src/Store/Widgets/AlbumView.vala 2012-07-03 06:49:24 +0000 |
2642 | @@ -174,20 +174,21 @@ |
2643 | |
2644 | public void populate() { |
2645 | try { |
2646 | - Thread.create<void*>(setalbum_thread_function, false); |
2647 | - Thread.create<void*>(gettracks_thread_function, false); |
2648 | - Thread.create<void*>(getsimilarreleases_thread_function, false); |
2649 | - Thread.create<void*>(getalbuminfo_thread_function, false); |
2650 | + new Thread<void*>.try (null, setalbum_thread_function); |
2651 | + new Thread<void*>.try (null, gettracks_thread_function); |
2652 | + new Thread<void*>.try (null, getsimilarreleases_thread_function); |
2653 | + new Thread<void*>.try (null, getalbuminfo_thread_function); |
2654 | + |
2655 | storeView.max = 5; |
2656 | storeView.index = 0; |
2657 | storeView.progressNotification(); |
2658 | } |
2659 | - catch(GLib.ThreadError err) { |
2660 | - stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); |
2661 | + catch (Error err) { |
2662 | + warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2663 | } |
2664 | } |
2665 | |
2666 | - public void* setalbum_thread_function () { |
2667 | + private void* setalbum_thread_function () { |
2668 | Store.Release r = store.getRelease(release.releaseID, 200); |
2669 | r.image = Store.store.getPixbuf(r.imagePath, 200, 200); |
2670 | |
2671 | @@ -198,7 +199,7 @@ |
2672 | ++storeView.index; |
2673 | |
2674 | try { |
2675 | - Thread.create<void*>(gettaglabels_thread_function, false); |
2676 | + new Thread<void*>.try (null, gettaglabels_thread_function); |
2677 | } |
2678 | catch (Error e) { |
2679 | critical ("Couldn't get tags: %s", e.message); |
2680 | @@ -227,7 +228,7 @@ |
2681 | return null; |
2682 | } |
2683 | |
2684 | - public void* getsimilarreleases_thread_function () { |
2685 | + private void* getsimilarreleases_thread_function () { |
2686 | foreach(var rel in release.getSimilar(1)) { |
2687 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); |
2688 | similarReleasesList.add(rel); |
2689 | @@ -246,7 +247,7 @@ |
2690 | return null; |
2691 | } |
2692 | |
2693 | - public void* gettaglabels_thread_function () { |
2694 | + private void* gettaglabels_thread_function () { |
2695 | var labels = new LinkedList<Store.TagLabel>(); |
2696 | |
2697 | foreach(var format in release.formats) { |
2698 | @@ -289,7 +290,7 @@ |
2699 | return null; |
2700 | } |
2701 | |
2702 | - public void* getalbuminfo_thread_function () { |
2703 | + private void* getalbuminfo_thread_function () { |
2704 | /* first get album description */ |
2705 | LastFM.AlbumInfo album = new LastFM.AlbumInfo.basic(); |
2706 | |
2707 | |
2708 | === modified file 'src/Store/Widgets/ArtistView.vala' |
2709 | --- src/Store/Widgets/ArtistView.vala 2012-02-04 00:01:35 +0000 |
2710 | +++ src/Store/Widgets/ArtistView.vala 2012-07-03 06:49:24 +0000 |
2711 | @@ -58,7 +58,7 @@ |
2712 | setArtist(artist); |
2713 | } |
2714 | |
2715 | - public void buildUI() { |
2716 | + private void buildUI() { |
2717 | VBox allDetails = new VBox(false, 0); |
2718 | HBox topRow = new HBox(false, 0); |
2719 | VBox topInfo = new VBox(false, 0); |
2720 | @@ -110,19 +110,19 @@ |
2721 | |
2722 | public void populate() { |
2723 | try { |
2724 | - Thread.create<void*>(setartist_thread_function, false); |
2725 | - Thread.create<void*>(gettracks_thread_function, false); |
2726 | - Thread.create<void*>(getreleases_thread_function, false); |
2727 | + new Thread<void*>.try (null, setartist_thread_function); |
2728 | + new Thread<void*>.try (null, gettracks_thread_function); |
2729 | + new Thread<void*>.try (null, getreleases_thread_function); |
2730 | storeView.index = 0; |
2731 | storeView.max = 5; // must get to 6 for progress bar to turn off |
2732 | storeView.progressNotification(); |
2733 | } |
2734 | - catch(GLib.ThreadError err) { |
2735 | - stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); |
2736 | + catch (Error err) { |
2737 | + warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2738 | } |
2739 | } |
2740 | |
2741 | - public void* setartist_thread_function () { |
2742 | + private void* setartist_thread_function () { |
2743 | Store.Artist a = store.getArtist(artist.artistID); |
2744 | ++storeView.index; |
2745 | Idle.add( () => { |
2746 | @@ -134,7 +134,7 @@ |
2747 | return null; |
2748 | } |
2749 | |
2750 | - public void* gettracks_thread_function () { |
2751 | + private void* gettracks_thread_function () { |
2752 | foreach(var track in artist.getTopTracks(1, 25)) |
2753 | topTracksList.add(track); |
2754 | ++storeView.index; |
2755 | @@ -149,7 +149,7 @@ |
2756 | return null; |
2757 | } |
2758 | |
2759 | - public void* getreleases_thread_function () { |
2760 | + private void* getreleases_thread_function () { |
2761 | foreach(var rel in artist.getReleases("album", 1)) { |
2762 | rel.image = Store.store.getPixbuf(rel.imagePath, 100, 100); |
2763 | releasesList.add(rel); |
2764 | |
2765 | === modified file 'src/Store/Widgets/HomeView.vala' |
2766 | --- src/Store/Widgets/HomeView.vala 2012-02-04 00:01:35 +0000 |
2767 | +++ src/Store/Widgets/HomeView.vala 2012-07-03 06:49:24 +0000 |
2768 | @@ -41,7 +41,7 @@ |
2769 | buildUI(); |
2770 | } |
2771 | |
2772 | - public void buildUI() { |
2773 | + private void buildUI() { |
2774 | allItems = new HBox(false, 0); |
2775 | VBox leftItems = new VBox(false, 0); |
2776 | VBox centerItems = new VBox(false, 0); |
2777 | @@ -98,6 +98,7 @@ |
2778 | |
2779 | } |
2780 | |
2781 | + // TODO: Move to utils namespace!! |
2782 | public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) { |
2783 | var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f); |
2784 | alignment.top_padding = top; |
2785 | @@ -111,21 +112,22 @@ |
2786 | |
2787 | public void populate() { |
2788 | try { |
2789 | - Thread.create<void*>(getartists_thread_function, false); |
2790 | - Thread.create<void*>(getreleases_thread_function, false); |
2791 | - Thread.create<void*>(gettracks_thread_function, false); |
2792 | - Thread.create<void*>(gettoprock_thread_function, false); |
2793 | - Thread.create<void*>(getgenres_thread_function, false); |
2794 | + new Thread<void*>.try (null, getartists_thread_function); |
2795 | + new Thread<void*>.try (null, getreleases_thread_function); |
2796 | + new Thread<void*>.try (null, gettracks_thread_function); |
2797 | + new Thread<void*>.try (null, gettoprock_thread_function); |
2798 | + new Thread<void*>.try (null, getgenres_thread_function); |
2799 | + |
2800 | storeView.max = 6; |
2801 | storeView.index = 0; |
2802 | storeView.progressNotification(); |
2803 | } |
2804 | - catch(GLib.ThreadError err) { |
2805 | - stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); |
2806 | + catch (Error err) { |
2807 | + warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2808 | } |
2809 | } |
2810 | |
2811 | - public void* getartists_thread_function () { |
2812 | + private void* getartists_thread_function () { |
2813 | var tops = new LinkedList<Artist>(); |
2814 | |
2815 | foreach(var art in store.topArtists("week", null, null, 1)) |
2816 | @@ -144,7 +146,7 @@ |
2817 | return null; |
2818 | } |
2819 | |
2820 | - public void* getreleases_thread_function () { |
2821 | + private void* getreleases_thread_function () { |
2822 | var tops = new LinkedList<Release>(); |
2823 | |
2824 | foreach(var rel in store.topReleases("week", null, null, 1)) { |
2825 | @@ -163,7 +165,7 @@ |
2826 | return null; |
2827 | } |
2828 | |
2829 | - public void* gettracks_thread_function () { |
2830 | + private void* gettracks_thread_function () { |
2831 | var tops = new LinkedList<Track>(); |
2832 | |
2833 | foreach(var track in store.topTracks("week", null, 1)) |
2834 | @@ -182,7 +184,7 @@ |
2835 | return null; |
2836 | } |
2837 | |
2838 | - public void* gettoprock_thread_function () { |
2839 | + private void* gettoprock_thread_function () { |
2840 | var rock = new LinkedList<Release>(); |
2841 | |
2842 | foreach(var rel in store.topReleases("week", null, "rock", 1)) { |
2843 | @@ -203,7 +205,7 @@ |
2844 | return null; |
2845 | } |
2846 | |
2847 | - public void* getgenres_thread_function () { |
2848 | + private void* getgenres_thread_function () { |
2849 | var gens = new LinkedList<Tag>(); |
2850 | |
2851 | gens.add( new Tag.with_values("pop", "Pop", "") ); |
2852 | |
2853 | === modified file 'src/Store/Widgets/StoreView.vala' |
2854 | --- src/Store/Widgets/StoreView.vala 2012-03-16 05:21:31 +0000 |
2855 | +++ src/Store/Widgets/StoreView.vala 2012-07-03 06:49:24 +0000 |
2856 | @@ -94,16 +94,16 @@ |
2857 | setView(searchPage); |
2858 | |
2859 | try { |
2860 | - Thread.create<void*>(searchtracks_thread_function, false); |
2861 | - Thread.create<void*>(searchartists_thread_function, false); |
2862 | - Thread.create<void*>(searchreleases_thread_function, false); |
2863 | + new Thread<void*>.try (null, searchtracks_thread_function); |
2864 | + new Thread<void*>.try (null, searchartists_thread_function); |
2865 | + new Thread<void*>.try (null, searchreleases_thread_function); |
2866 | } |
2867 | - catch(GLib.ThreadError err) { |
2868 | - stdout.printf("ERROR: Could not create thread to get populate ArtistView: %s \n", err.message); |
2869 | + catch (Error err) { |
2870 | + warning ("Could not create thread to get populate ArtistView: %s", err.message); |
2871 | } |
2872 | } |
2873 | |
2874 | - public void* searchtracks_thread_function () { |
2875 | + private void* searchtracks_thread_function () { |
2876 | var search = new LinkedList<Store.Track>(); |
2877 | |
2878 | foreach(var track in store.searchTracks(lw.searchField.get_text(), 1)) |
2879 | @@ -119,7 +119,7 @@ |
2880 | return null; |
2881 | } |
2882 | |
2883 | - public void* searchartists_thread_function () { |
2884 | + private void* searchartists_thread_function () { |
2885 | var search = new LinkedList<Store.Artist>(); |
2886 | |
2887 | foreach(var artist in store.searchArtists(lw.searchField.get_text(), null, 1)) |
2888 | @@ -135,7 +135,7 @@ |
2889 | return null; |
2890 | } |
2891 | |
2892 | - public void* searchreleases_thread_function () { |
2893 | + private void* searchreleases_thread_function () { |
2894 | var search = new LinkedList<Store.Release>(); |
2895 | |
2896 | foreach(var rel in store.searchReleases(lw.searchField.get_text(), 1)) |
2897 | |
2898 | === modified file 'src/Views/SimilarMediaView.vala' |
2899 | --- src/Views/SimilarMediaView.vala 2012-06-19 22:50:13 +0000 |
2900 | +++ src/Views/SimilarMediaView.vala 2012-07-03 06:49:24 +0000 |
2901 | @@ -83,10 +83,10 @@ |
2902 | |
2903 | public virtual void viewDoubleClick(TreePath path, TreeViewColumn column) { |
2904 | try { |
2905 | - Thread.create<void*>(take_action, false); |
2906 | + new Thread<void*>.try (null, take_action); |
2907 | } |
2908 | - catch(GLib.ThreadError err) { |
2909 | - stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); |
2910 | + catch (Error err) { |
2911 | + warning ("Could not create thread to have fun: %s", err.message); |
2912 | } |
2913 | } |
2914 | |
2915 | @@ -117,8 +117,8 @@ |
2916 | try { |
2917 | GLib.AppInfo.launch_default_for_uri (s.lastfm_url, null); |
2918 | } |
2919 | - catch(Error err) { |
2920 | - stdout.printf("Couldn't open the similar media's last fm page: %s\n", err.message); |
2921 | + catch (Error err) { |
2922 | + warning ("Couldn't open the similar media's last fm page: %s", err.message); |
2923 | } |
2924 | } |
2925 | |
2926 | |
2927 | === modified file 'src/Widgets/EmbeddedAlert.vala' |
2928 | --- src/Widgets/EmbeddedAlert.vala 2012-06-25 23:39:54 +0000 |
2929 | +++ src/Widgets/EmbeddedAlert.vala 2012-07-03 06:49:24 +0000 |
2930 | @@ -20,12 +20,6 @@ |
2931 | * Authored by: Victor Eduardo <victoreduardm@gmail.com> |
2932 | */ |
2933 | |
2934 | -/** |
2935 | - * An alert compliant with elementary's HIG |
2936 | - * |
2937 | - * TODO: Add description and examples |
2938 | - */ |
2939 | - |
2940 | public class BeatBox.EmbeddedAlert : Gtk.EventBox { |
2941 | |
2942 | const string ERROR_ICON = "dialog-error"; |
2943 | @@ -43,11 +37,11 @@ |
2944 | protected Gtk.ButtonBox action_button_box; |
2945 | |
2946 | const int MIN_HORIZONTAL_MARGIN = 84; |
2947 | - const int MIN_VERTICAL_MARGIN = 48; |
2948 | + const int MIN_VERTICAL_MARGIN = 6; |
2949 | |
2950 | public EmbeddedAlert () { |
2951 | get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); |
2952 | - //get_style_context ().add_class (Granite.STYLE_CLASS_CONTENT_VIEW); // This variable is not in granite version in universe |
2953 | + get_style_context ().add_class (Granite.STYLE_CLASS_CONTENT_VIEW); |
2954 | |
2955 | action_button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL); |
2956 | action_button_box.valign = Gtk.Align.START; |
2957 | @@ -125,7 +119,7 @@ |
2958 | bool show_icon = true, Gtk.MessageType type = Gtk.MessageType.WARNING) |
2959 | { |
2960 | // Reset size request |
2961 | - set_size_request (1, 1); |
2962 | + set_size_request (0, 0); |
2963 | |
2964 | if (primary_text == null) |
2965 | primary_text = ""; |
2966 | |
2967 | === modified file 'src/Widgets/SearchSuggester.vala' |
2968 | --- src/Widgets/SearchSuggester.vala 2012-06-01 22:48:28 +0000 |
2969 | +++ src/Widgets/SearchSuggester.vala 2012-07-03 06:49:24 +0000 |
2970 | @@ -71,9 +71,9 @@ |
2971 | //Timeout.add(750, () => { |
2972 | if(new_search == last_search && new_search.length > 2) { |
2973 | try { |
2974 | - Thread.create<void*>(update_contents, false); |
2975 | - } catch(GLib.ThreadError err) { |
2976 | - warning ("ERROR: Could not create search suggester thread: %s \n", err.message); |
2977 | + new Thread<void*>.try (null, update_contents); |
2978 | + } catch (Error err) { |
2979 | + warning ("Could not create search suggester thread: %s", err.message); |
2980 | } |
2981 | } |
2982 | else if(new_search.length <= 2) { |
2983 | |
2984 | === modified file 'src/Widgets/StatusBar.vala' |
2985 | --- src/Widgets/StatusBar.vala 2012-03-04 00:33:20 +0000 |
2986 | +++ src/Widgets/StatusBar.vala 2012-07-03 06:49:24 +0000 |
2987 | @@ -22,81 +22,16 @@ |
2988 | |
2989 | using Gtk; |
2990 | |
2991 | -public class BeatBox.StatusBar : Gtk.Toolbar { |
2992 | +public class BeatBox.StatusBar : Granite.Widgets.StatusBar { |
2993 | |
2994 | public uint total_items {get; private set; default = 0;} |
2995 | public uint total_mbs {get; private set; default = 0;} |
2996 | public uint total_secs {get; private set; default = 0;} |
2997 | public ViewWrapper.Hint media_type {get; private set;} |
2998 | |
2999 | - private Label status_label; |
3000 | - private Box left_box; |
3001 | - private Box right_box; |
3002 | - |
3003 | - private CssProvider style_provider; |
3004 | - private StyleContext context; |
3005 | - |
3006 | private string STATUS_TEXT_FORMAT = _("%s, %s, %s"); |
3007 | |
3008 | - private const string STATUSBAR_STYLESHEET = """ |
3009 | - BeatBoxStatusBar { |
3010 | - border-bottom-width: 0; |
3011 | - border-right-width: 0; |
3012 | - border-left-width: 0; |
3013 | - |
3014 | - -GtkWidget-window-dragging: false; |
3015 | - } |
3016 | - |
3017 | - /* This prevents the huge vertical padding */ |
3018 | - BeatBoxStatusBar .button { |
3019 | - padding: 0px; |
3020 | - } |
3021 | - """; |
3022 | - |
3023 | public StatusBar () { |
3024 | - |
3025 | - style_provider = new CssProvider (); |
3026 | - |
3027 | - try { |
3028 | - style_provider.load_from_data (STATUSBAR_STYLESHEET, -1); |
3029 | - } |
3030 | - catch (Error err) { |
3031 | - warning (err.message); |
3032 | - } |
3033 | - |
3034 | - /* Get rid of the "toolbar" class to avoid inheriting its style, |
3035 | - since we want the widget to look more like a normal statusbar. */ |
3036 | - get_style_context ().remove_class (STYLE_CLASS_TOOLBAR); |
3037 | - |
3038 | - context = new StyleContext (); |
3039 | - context.add_provider_for_screen (get_screen (), style_provider, STYLE_PROVIDER_PRIORITY_THEME); |
3040 | - |
3041 | - status_label = new Label (""); |
3042 | - status_label.set_justify (Justification.CENTER); |
3043 | - |
3044 | - left_box = new Box (Orientation.HORIZONTAL, 0); |
3045 | - right_box = new Box (Orientation.HORIZONTAL, 0); |
3046 | - |
3047 | - var left_item = new ToolItem (); |
3048 | - var status_label_item = new ToolItem (); |
3049 | - var right_item = new ToolItem (); |
3050 | - |
3051 | - left_item.add (left_box); |
3052 | - status_label_item.add (status_label); |
3053 | - right_item.add (right_box); |
3054 | - |
3055 | - status_label_item.set_expand (true); |
3056 | - |
3057 | - this.insert (left_item, 0); |
3058 | - this.insert (status_label_item, 1); |
3059 | - this.insert (right_item, 2); |
3060 | - } |
3061 | - |
3062 | - public void insert_widget (Gtk.Widget widget, bool? use_left_side = false) { |
3063 | - if (use_left_side) |
3064 | - left_box.pack_start (widget, false, false, 3); |
3065 | - else |
3066 | - right_box.pack_start (widget, false, false, 3); |
3067 | } |
3068 | |
3069 | public void set_files_size (uint total_mbs) { |
3070 | |
3071 | === modified file 'src/Widgets/StyledWidgets/StyledArtistImages.vala' |
3072 | --- src/Widgets/StyledWidgets/StyledArtistImages.vala 2012-07-02 23:17:27 +0000 |
3073 | +++ src/Widgets/StyledWidgets/StyledArtistImages.vala 2012-07-03 06:49:24 +0000 |
3074 | @@ -22,7 +22,6 @@ |
3075 | |
3076 | using Gee; |
3077 | using Gtk; |
3078 | -using Xml; |
3079 | |
3080 | public class BeatBox.StyledArtistImages : EventBox { |
3081 | const string api = "YOFT4SZFVZLZZ1SVT"; |
3082 | @@ -118,13 +117,13 @@ |
3083 | images = new LinkedList<Gdk.Pixbuf>(); |
3084 | |
3085 | try { |
3086 | - Thread.create<void*>(fetch_thread_function, false); |
3087 | - } catch(GLib.ThreadError err) { |
3088 | - warning("Could not create thread to load artist pixbuf's: %s \n", err.message); |
3089 | + new Thread<void*>.try (null, fetch_thread_function); |
3090 | + } catch(Error err) { |
3091 | + warning ("Could not create thread to load artist pixbuf's: %s", err.message); |
3092 | } |
3093 | } |
3094 | |
3095 | - public void* fetch_thread_function () { |
3096 | + private void* fetch_thread_function () { |
3097 | var url = "http://developer.echonest.com/api/v4/artist/images?api_key=" + api + "&name=" + |
3098 | LastFM.Core.fix_for_url(current_artist) + "&format=xml&start=0&results=15"; |
3099 | |
3100 | @@ -197,7 +196,7 @@ |
3101 | // Loop over the passed node's children |
3102 | for (Xml.Node* iter = node->children; iter != null; iter = iter->next) { |
3103 | // Spaces between tags are also nodes, discard them |
3104 | - if (iter->type != ElementType.ELEMENT_NODE) { |
3105 | + if (iter->type != Xml.ElementType.ELEMENT_NODE) { |
3106 | continue; |
3107 | } |
3108 | |
3109 | |
3110 | === removed file 'src/Widgets/WarningLabel.vala' |
3111 | --- src/Widgets/WarningLabel.vala 2012-03-29 08:46:09 +0000 |
3112 | +++ src/Widgets/WarningLabel.vala 1970-01-01 00:00:00 +0000 |
3113 | @@ -1,99 +0,0 @@ |
3114 | -/*- |
3115 | - * Copyright (c) 2011-2012 Scott Ringwelski <sgringwe@mtu.edu> |
3116 | - * |
3117 | - * Originally Written by Scott Ringwelski for BeatBox Music Player |
3118 | - * BeatBox Music Player: http://www.launchpad.net/beat-box |
3119 | - * |
3120 | - * This library is free software; you can redistribute it and/or |
3121 | - * modify it under the terms of the GNU Library General Public |
3122 | - * License as published by the Free Software Foundation; either |
3123 | - * version 2 of the License, or (at your option) any later version. |
3124 | - * |
3125 | - * This library is distributed in the hope that it will be useful, |
3126 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3127 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3128 | - * Library General Public License for more details. |
3129 | - * |
3130 | - * You should have received a copy of the GNU Library General Public |
3131 | - * License along with this library; if not, write to the |
3132 | - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
3133 | - * Boston, MA 02111-1307, USA. |
3134 | - */ |
3135 | - |
3136 | -using Gtk; |
3137 | - |
3138 | -public class BeatBox.WarningLabel : EventBox { |
3139 | - |
3140 | - private Label errorLabel; // FIXME: Use Granite.Widgets.WrapLabel |
3141 | - private Image warningIcon; |
3142 | - |
3143 | - public bool show_icon { |
3144 | - get { |
3145 | - return warningIcon.visible; |
3146 | - } |
3147 | - set { |
3148 | - warningIcon.set_no_show_all (!value); |
3149 | - warningIcon.set_visible (value); |
3150 | - } |
3151 | - } |
3152 | - |
3153 | - public WarningLabel(string icon_name = "dialog-warning") { |
3154 | - errorLabel = new Label(""); |
3155 | - warningIcon = Icons.render_image (icon_name, Gtk.IconSize.DIALOG); |
3156 | - |
3157 | - //FIXME: use margins |
3158 | - var content = new Box (Orientation.HORIZONTAL, 10); |
3159 | - var content_wrapper = new Box (Orientation.HORIZONTAL, 0); |
3160 | - var outer_box = new Box (Orientation.VERTICAL, 0); |
3161 | - var top_padding = new Box (Orientation.VERTICAL, 0); |
3162 | - var bottom_padding = new Box (Orientation.VERTICAL, 0); |
3163 | - var left_padding = new Box (Orientation.HORIZONTAL, 0); |
3164 | - var right_padding = new Box (Orientation.HORIZONTAL, 0); |
3165 | - |
3166 | - content.pack_start (wrap_alignment(warningIcon, 0, 10, 10, 10), false, false, 0); |
3167 | - content.pack_start (errorLabel, false, true, 0); |
3168 | - |
3169 | - content_wrapper.pack_start (left_padding, true, true, 0); |
3170 | - content_wrapper.pack_start (content, false, true, 0); |
3171 | - content_wrapper.pack_start (right_padding, true, true, 0); |
3172 | - |
3173 | - outer_box.pack_start (top_padding, true, true, 0); |
3174 | - outer_box.pack_start (content_wrapper, false, true, 10); |
3175 | - outer_box.pack_start (bottom_padding, true, true, 0); |
3176 | - |
3177 | - add(outer_box); |
3178 | - |
3179 | - // Add view-like theming |
3180 | - get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW); |
3181 | - |
3182 | - errorLabel.xalign = 0.5f; |
3183 | - errorLabel.set_justify(Justification.CENTER); |
3184 | - errorLabel.ellipsize = Pango.EllipsizeMode.END; |
3185 | - } |
3186 | - |
3187 | - static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) { |
3188 | - |
3189 | - var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f); |
3190 | - alignment.top_padding = top; |
3191 | - alignment.right_padding = right; |
3192 | - alignment.bottom_padding = bottom; |
3193 | - alignment.left_padding = left; |
3194 | - |
3195 | - alignment.add(widget); |
3196 | - return alignment; |
3197 | - } |
3198 | - |
3199 | - |
3200 | - // We force our HIG here. Whenever show_icon is true, the title has to be left-aligned. |
3201 | - |
3202 | - // FIXME: this should be: set_warning (string primary_text, string secondary_text, bool show_icon = true, ...) |
3203 | - public void setWarning(string warning, Gtk.Justification? justification = Gtk.Justification.LEFT) { |
3204 | - if (!show_icon) |
3205 | - errorLabel.set_justify(Gtk.Justification.CENTER); |
3206 | - else |
3207 | - errorLabel.set_justify(justification); |
3208 | - |
3209 | - errorLabel.set_markup(warning); |
3210 | - } |
3211 | -} |
3212 | - |
3213 | |
3214 | === modified file 'src/Windows/AddPodcastWindow.vala' |
3215 | --- src/Windows/AddPodcastWindow.vala 2012-05-03 04:19:07 +0000 |
3216 | +++ src/Windows/AddPodcastWindow.vala 2012-07-03 06:49:24 +0000 |
3217 | @@ -173,10 +173,10 @@ |
3218 | next = url; |
3219 | |
3220 | try { |
3221 | - Thread.create<void*>(test_url_validity, false); |
3222 | + new Thread<void*>.try (null, test_url_validity); |
3223 | } |
3224 | - catch(GLib.ThreadError err) { |
3225 | - stdout.printf("ERROR: Could not create thread to fetch new podcasts: %s \n", err.message); |
3226 | + catch (Error err) { |
3227 | + warning ("Could not create thread to fetch new podcasts: %s", err.message); |
3228 | } |
3229 | } |
3230 | } |
3231 | |
3232 | === modified file 'src/Windows/RemoveDuplicatesDialog.vala' |
3233 | --- src/Windows/RemoveDuplicatesDialog.vala 2012-06-14 23:08:24 +0000 |
3234 | +++ src/Windows/RemoveDuplicatesDialog.vala 2012-07-03 06:49:24 +0000 |
3235 | @@ -141,10 +141,10 @@ |
3236 | is_working.start(); |
3237 | |
3238 | try { |
3239 | - Thread.create<void*>(find_duplicates_thread, false); |
3240 | + new Thread<void*>.try (null, find_duplicates_thread); |
3241 | } |
3242 | - catch(GLib.ThreadError err) { |
3243 | - stdout.printf("ERROR: Could not create thread to analyze duplicates: %s \n", err.message); |
3244 | + catch (Error err) { |
3245 | + warning ("Could not create thread to analyze duplicates: %s", err.message); |
3246 | } |
3247 | } |
3248 | |
3249 | |
3250 | === modified file 'src/Wrappers/PodcastViewWrapper.vala' |
3251 | --- src/Wrappers/PodcastViewWrapper.vala 2012-06-30 20:55:57 +0000 |
3252 | +++ src/Wrappers/PodcastViewWrapper.vala 2012-07-03 06:49:24 +0000 |
3253 | @@ -61,15 +61,15 @@ |
3254 | void welcome_screen_activated(int index) { |
3255 | if(index == 0) { |
3256 | try { |
3257 | - Thread.create<void*>(take_action, false); |
3258 | + new Thread<void*>.try (null, take_action); |
3259 | } |
3260 | - catch(GLib.ThreadError err) { |
3261 | - stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); |
3262 | + catch (Error err) { |
3263 | + warning ("Could not create thread to have fun: %s", err.message); |
3264 | } |
3265 | } |
3266 | } |
3267 | |
3268 | - public void* take_action () { |
3269 | + private void* take_action () { |
3270 | try { |
3271 | GLib.AppInfo.launch_default_for_uri ("https://www.miroguide.com/toprated/", null); |
3272 | } |
3273 | |
3274 | === modified file 'src/Wrappers/StationViewWrapper.vala' |
3275 | --- src/Wrappers/StationViewWrapper.vala 2012-06-30 20:55:57 +0000 |
3276 | +++ src/Wrappers/StationViewWrapper.vala 2012-07-03 06:49:24 +0000 |
3277 | @@ -61,10 +61,10 @@ |
3278 | void welcome_screen_activated(int index) { |
3279 | if(index == 0) { |
3280 | try { |
3281 | - Thread.create<void*>(take_action, false); |
3282 | + new Thread<void*>.try (null, take_action); |
3283 | } |
3284 | - catch(GLib.ThreadError err) { |
3285 | - stdout.printf("ERROR: Could not create thread to have fun: %s \n", err.message); |
3286 | + catch(Error err) { |
3287 | + warning ("Could not create thread to have fun: %s", err.message); |
3288 | } |
3289 | } |
3290 | } |
3291 | |
3292 | === modified file 'src/Wrappers/ViewWrapper.vala' |
3293 | --- src/Wrappers/ViewWrapper.vala 2012-06-30 20:55:57 +0000 |
3294 | +++ src/Wrappers/ViewWrapper.vala 2012-07-03 06:49:24 +0000 |
3295 | @@ -177,8 +177,6 @@ |
3296 | _artist_filter = ""; |
3297 | _genre_filter = ""; |
3298 | |
3299 | - in_update = new Mutex(); |
3300 | - |
3301 | set_orientation(Orientation.VERTICAL); |
3302 | |
3303 | // Setup container |
I haven't actually tested it yet, but I went through the whole diff and looks great. I did find a few locks that were missing, but maybe they just didn't show up in the diff.
Agree with your comments for the most part.
There was one thing I disagreed with - in lyrics fetcher - but that is no showstopper. Will merge when I get home or you can if you are ok with me skipping testing.
Awesome work!