Merge lp:~stolowski/unity-lens-music/remove-banshee-preview-fix into lp:unity-lens-music

Proposed by Paweł Stołowski
Status: Rejected
Rejected by: Michal Hruby
Proposed branch: lp:~stolowski/unity-lens-music/remove-banshee-preview-fix
Merge into: lp:unity-lens-music
Diff against target: 274 lines (+49/-206)
1 file modified
src/banshee-scope.vala (+49/-206)
To merge this branch: bzr merge lp:~stolowski/unity-lens-music/remove-banshee-preview-fix
Reviewer Review Type Date Requested Status
Neil J. Patel Pending
Review via email: mp+126957@code.launchpad.net

Commit message

Reverted banshee preview support for now; it's not going to be released with Q.

Description of the change

Reverted banshee preview support for now; it's not going to be released with Q.

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

Rejecting, no need to revert this anymore.

Unmerged revisions

112. By Paweł Stołowski

Reverted banshee preview support for now; it's not going to be released with Q.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/banshee-scope.vala'
2--- src/banshee-scope.vala 2012-09-28 10:27:26 +0000
3+++ src/banshee-scope.vala 2012-09-28 13:10:30 +0000
4@@ -24,8 +24,6 @@
5 public class BansheeScopeProxy : SimpleScope
6 {
7 private BansheeCollection collection;
8- private PreviewPlayer preview_player;
9- private Unity.MusicPreview? music_preview;
10
11 public BansheeScopeProxy ()
12 {
13@@ -52,212 +50,57 @@
14 protected override int num_results_global_search { get { return 20; } }
15 protected override int num_results_lens_search { get { return 50; } }
16
17-
18- public void closed (Unity.Preview preview)
19- {
20- if (preview_player != null)
21- {
22- try
23- {
24- preview_player.close ();
25- }
26- catch (Error e)
27- {
28- warning ("Failed to close preview player: %s", e.message);
29- }
30- }
31- }
32-
33- public void play (Unity.Preview preview, string uri)
34- {
35- debug ("play request: '%s'", uri);
36-
37- try
38- {
39- if (preview_player == null)
40- {
41- preview_player = new PreviewPlayer ();
42- preview_player.progress.connect (on_progress_changed);
43- preview_player.connect_to ();
44- }
45-
46- // we will receive state back in on_progress_changed, but set it now so that it's immediately reflected in the dash
47- music_preview.current_track_uri = uri;
48- music_preview.current_progress = 0.0f;
49- music_preview.current_track_state = Unity.MusicPreview.TrackState.PLAYING;
50-
51- preview_player.play (uri);
52- }
53- catch (Error e)
54- {
55- warning ("Failed to play '%s': %s", uri, e.message);
56- }
57- }
58-
59- public void pause (Unity.Preview preview, string uri)
60- {
61- debug ("pause request: '%s'", uri);
62-
63- try
64- {
65- if (preview_player != null)
66- {
67- // we will receive state back in on_progress_changed, but set it now so that it's immediately reflected in the dash
68- music_preview.current_track_uri = uri;
69- music_preview.current_track_state = Unity.MusicPreview.TrackState.PAUSED;
70-
71- preview_player.pause ();
72- }
73- }
74- catch (Error e)
75- {
76- warning ("Failed to pause '%s': %s", uri, e.message);
77- }
78- }
79-
80- private void on_progress_changed (string uri, Unity.MusicPreview.TrackState state, double progress)
81- {
82- if (preview != null)
83- {
84- music_preview.current_track_uri = uri;
85- music_preview.current_track_state = state;
86- music_preview.current_progress = (float)progress;
87- }
88- }
89-
90-
91 public Unity.Preview preview (string uri)
92 {
93- music_preview = null;
94- GLib.Icon? icon_file = null;
95- GLib.Icon? missing_icon_file = new GLib.FileIcon (File.new_for_path (ALBUM_MISSING_PREVIEW_ICON_PATH));
96-
97- if (Uri.parse_scheme (uri) == "album")
98- {
99- string[] split = uri.split ("/"); //FIXME: there must be more reliable way
100- if (split.length >= 4)
101- {
102- string artist = split[2];
103- string title = split[3];
104-
105- foreach (unowned Track track in collection.get_album_tracks_detailed (title, artist))
106- {
107- if (music_preview == null)
108- {
109- if (track.artwork_path != null && track.artwork_path != "" && FileUtils.test(track.artwork_path, FileTest.EXISTS))
110- icon_file = new GLib.ThemedIcon(track.artwork_path);
111- else
112- icon_file = missing_icon_file;
113- music_preview = new Unity.MusicPreview (title, artist, icon_file);
114- }
115- var tm = new Unity.TrackMetadata();
116- tm.uri = track.uri;
117- tm.track_no = track.track_number;
118- tm.title = track.title ?? "";
119- tm.length = track.duration;
120- music_preview.add_track(tm);
121- }
122- }
123- else
124- {
125- warning ("Invalid uri: %s", uri);
126- }
127- }
128- else // preview single track
129- {
130- Track? track = collection.get_album_track (uri);
131- if (track != null)
132- {
133- if (track.artwork_path != null && track.artwork_path != "" && FileUtils.test(track.artwork_path, FileTest.EXISTS))
134- icon_file = new GLib.ThemedIcon(track.artwork_path);
135- else
136- icon_file = missing_icon_file;
137- music_preview = new Unity.MusicPreview (track.title, track.artist, icon_file);
138- var tm = new Unity.TrackMetadata();
139- tm.uri = track.uri;
140- tm.track_no = track.track_number;
141- tm.title = track.title ?? "";
142- tm.length = track.duration;
143- music_preview.add_track(tm);
144- }
145- }
146-
147- if (preview != null)
148- {
149- var play_action = new Unity.PreviewAction ("play", _("Play"), null);
150- play_action.activated.connect (play_in_banshee);
151- music_preview.add_action (play_action);
152-
153- var show_folder_action = new Unity.PreviewAction ("show_in_folder", _("Show in Folder"), null);
154- show_folder_action.activated.connect (show_in_folder);
155- music_preview.add_action (show_folder_action);
156-
157- music_preview.play.connect (play);
158- music_preview.pause.connect (pause);
159- music_preview.closed.connect (closed);
160- }
161-
162- return music_preview;
163- }
164-
165- private Unity.ActivationResponse play_in_banshee (string uri)
166- {
167- return activate (uri);
168- }
169-
170- private Unity.ActivationResponse show_in_folder (string uri)
171- {
172- File? track_file = null;
173-
174- if (Uri.parse_scheme (uri) == "album")
175- {
176- string[] split = uri.split ("/");
177- if (split.length >= 4)
178- {
179- string artist = split[2];
180- string title = split[3];
181- var album = new Album ()
182- {
183- title = split[3],
184- artist = split[2]
185- };
186- var tracks = collection.get_track_uris (album);
187- if (tracks.length > 0)
188- {
189- track_file = File.new_for_uri (tracks[0]);
190- }
191- }
192- else
193- {
194- warning ("Invalid uri: %s", uri);
195- return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED);
196- }
197- }
198- else //file
199- {
200- track_file = File.new_for_uri (uri);
201- }
202-
203- File? parent_dir = track_file.get_parent ();
204- if (parent_dir != null)
205- {
206- try
207- {
208- GLib.AppInfo.launch_default_for_uri (parent_dir.get_uri (), null);
209- return new Unity.ActivationResponse (Unity.HandledType.HIDE_DASH);
210- }
211- catch (GLib.Error e)
212- {
213- warning ("Failed to launch application for uri '%s': %s", parent_dir.get_uri (), e.message);
214- }
215- }
216- else
217- {
218- warning ("Failed to get parent dir for uri: '%s'", uri);
219- }
220- return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED);
221- }
222-
223+ Unity.MusicPreview? preview = null;
224+ GLib.Icon? icon_file = null;
225+ GLib.Icon? missing_icon_file = new GLib.FileIcon (File.new_for_path (ALBUM_MISSING_PREVIEW_ICON_PATH));
226+
227+ if (Uri.parse_scheme (uri) == "album")
228+ {
229+ string[] split = uri.split ("/");
230+ string artist = split[2];
231+ string title = split[3];
232+
233+ foreach (unowned Track track in collection.get_album_tracks_detailed (title, artist))
234+ {
235+ if (preview == null)
236+ {
237+ if (track.artwork_path != null && track.artwork_path != "" && FileUtils.test(track.artwork_path, FileTest.EXISTS))
238+ icon_file = new GLib.ThemedIcon(track.artwork_path);
239+ else
240+ icon_file = missing_icon_file;
241+ preview = new Unity.MusicPreview (title, artist, icon_file);
242+ }
243+ var tm = new Unity.TrackMetadata();
244+ tm.uri = track.uri;
245+ tm.track_no = track.track_number;
246+ tm.title = track.title ?? "";
247+ tm.length = track.duration;
248+ preview.add_track(tm);
249+ }
250+ }
251+ else // preview single track
252+ {
253+ Track? track = collection.get_album_track (uri);
254+ if (track != null)
255+ {
256+ if (track.artwork_path != null && track.artwork_path != "" && FileUtils.test(track.artwork_path, FileTest.EXISTS))
257+ icon_file = new GLib.ThemedIcon(track.artwork_path);
258+ else
259+ icon_file = missing_icon_file;
260+ preview = new Unity.MusicPreview (track.title, track.artist, icon_file);
261+ var tm = new Unity.TrackMetadata();
262+ tm.uri = track.uri;
263+ tm.track_no = track.track_number;
264+ tm.title = track.title ?? "";
265+ tm.length = track.duration;
266+ preview.add_track(tm);
267+ }
268+ }
269+
270+ return preview;
271+ }
272
273 /**
274 * Tells banshee to play the selected uri(s)

Subscribers

People subscribed via source and target branches

to all changes: