Merge lp://qastaging/~gawhelan/do-plugins/Exaile into lp://qastaging/do-plugins

Proposed by Graham Whelan
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~gawhelan/do-plugins/Exaile
Merge into: lp://qastaging/do-plugins
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~gawhelan/do-plugins/Exaile
Reviewer Review Type Date Requested Status
Alex Launi (community) Needs Fixing
Chris S. Needs Fixing
Review via email: mp+4820@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Graham Whelan (gawhelan) wrote :

A plugin for Exaile music player. Most of the code is borrowed from the Rhythmbox plugin just adapted to index Exaile's database.

Revision history for this message
Chris S. (cszikszoy) wrote :

This plugin looks good, but there's still some stuff to fix. Upon a cursory inspection, here are some thoughts:

* General
Don't use the namespace Do.Exaile, just use Exiale. I know rhythmbox uses a Do.* namespace, but this isn't correct.

* Exaile.cs
Database connections should be wrapped in a "using ()" block.
Don't use Console.WriteLine () for debugging or error reporting. You should be using Log<CLASS>.* () for that.

* PreviousAction.cs
Have you ensured that it works correctly? I made the rhythmbox plugin perform "--previous" twice because of a bug with rhythmbox's CLI. I don't have exaile to test, but make sure it's not actually skipping back 2 songs when you perform that action.

review: Needs Fixing
586. By Graham Whelan

Fixed namespace issues and database connection handling

Revision history for this message
Graham Whelan (gawhelan) wrote :

> "This plugin looks good, but there's still some stuff to fix. Upon a cursory inspection, here are some thoughts:

> * General
> Don't use the namespace Do.Exaile, just use Exiale. I know rhythmbox uses a Do.* namespace, but > this isn't correct.

Okay, this is now fixed.

> * Exaile.cs
> Database connections should be wrapped in a "using ()" block.

I've wrapped the creation of the database connection, the database command and the data reader in using () blocks.

> Don't use Console.WriteLine () for debugging or error reporting. You should be using Log<CLASS>.* >() for that.

Yeah, I missed that, sorry. Fixed now.

>* PreviousAction.cs
>Have you ensured that it works correctly? I made the rhythmbox plugin perform "--previous" twice >because of a bug with rhythmbox's CLI. I don't have exaile to test, but make sure it's not >actually skipping back 2 songs when you perform that action."

Exaile has the same problem with it's CLI, the "--prev" switch just skips to the start of the current track unless that track has just started. Performing "--prev" twice works but it's not ideal. You can hear the current track restart before it skips back to the previous track, and sometimes it doesn't skip to the previous track at all. I'm not sure how to fix this.

Thanks for the feedback.

Revision history for this message
Alex Launi (alexlauni) wrote :

In AbstractPlaybackAction:SupportsItem, rather than nesting ifs, do

     public override bool SupportsItem (Item item)
     {
          if (!(item is IApplicationItem))
               return false;
          return ((item as IApplicationItem).Exec.Contains ("exaile") && Exaile.InstanceIsRunning);
     }

In Exaile.cs, dont break home's assignment onto a new line. we observe a loose column line at 120, not 80. And 120 isnt a hard limit either. Fix your code in general to reflect this change.

This exception to this is with LINQ statements, it is LINQ standard to do one statement per line, you're already doing this, so no change is needed.

Should be good for merging after these style fixes.

review: Needs Fixing
587. By Graham Whelan

Some code style fixes

Revision history for this message
Graham Whelan (gawhelan) wrote :

Thanks, I've made the suggested code style changes.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'Exaile'
2=== added file 'Exaile/Makefile.am'
3--- Exaile/Makefile.am 1970-01-01 00:00:00 +0000
4+++ Exaile/Makefile.am 2009-03-24 02:28:22 +0000
5@@ -0,0 +1,29 @@
6+include $(top_srcdir)/build.rules.mk
7+
8+ASSEMBLY=Exaile
9+
10+FILES = \
11+ src/MusicItems.cs \
12+ src/Exaile.cs \
13+ src/ExaileItems.cs \
14+ src/PlayAction.cs \
15+ src/MusicItemSource.cs \
16+ src/AbstractPlaybackAction.cs \
17+ src/NextAction.cs \
18+ src/PauseAction.cs \
19+ src/PreviousAction.cs \
20+ src/PlayItemAction.cs
21+
22+RESOURCES = \
23+ Resources/Exaile.addin.xml
24+
25+REFERENCES = \
26+ System \
27+ System.Core \
28+ System.Xml \
29+ System.Data \
30+ Mono.Posix \
31+ Mono.Data.Sqlite \
32+ $(GTK_SHARP_20_LIBS) \
33+ $(DO_PLATFORM_LIBS) \
34+ $(DO_UNIVERSE_LIBS)
35
36=== added directory 'Exaile/Resources'
37=== added file 'Exaile/Resources/Exaile.addin.xml'
38--- Exaile/Resources/Exaile.addin.xml 1970-01-01 00:00:00 +0000
39+++ Exaile/Resources/Exaile.addin.xml 2009-03-24 02:28:22 +0000
40@@ -0,0 +1,29 @@
41+<Addin
42+ id="Exaile"
43+ namespace="Do"
44+ version="0.1"
45+ name="Exaile"
46+ description="Search and play music in Exaile."
47+ author="Graham Whelan"
48+ category="Community"
49+ >
50+
51+ <Runtime>
52+ <Import assembly="Exaile.dll"/>
53+ </Runtime>
54+
55+ <Dependencies>
56+ <Addin id="Universe" version="1.0" />
57+ </Dependencies>
58+
59+ <Extension path = "/Do/ItemSource">
60+ <ItemSource type="Do.Exaile.MusicItemSource" />
61+ </Extension>
62+ <Extension path= "/Do/Action">
63+ <Action type="Do.Exaile.PlayAction" />
64+ <Action type="Do.Exaile.PlayItemAction" />
65+ <Action type="Do.Exaile.PauseAction" />
66+ <Action type="Do.Exaile.NextAction" />
67+ <Action type="Do.Exaile.PreviousAction" />
68+ </Extension>
69+</Addin>
70
71=== added directory 'Exaile/src'
72=== added file 'Exaile/src/AbstractPlaybackAction.cs'
73--- Exaile/src/AbstractPlaybackAction.cs 1970-01-01 00:00:00 +0000
74+++ Exaile/src/AbstractPlaybackAction.cs 2009-03-24 02:28:22 +0000
75@@ -0,0 +1,49 @@
76+// AbstractPlaybackAction.cs
77+//
78+// GNOME Do is the legal property of its developers, whose names are too numerous
79+// to list here. Please refer to the COPYRIGHT file distributed with this
80+// source distribution.
81+//
82+// This program is free software: you can redistribute it and/or modify
83+// it under the terms of the GNU General Public License as published by
84+// the Free Software Foundation, either version 3 of the License, or
85+// (at your option) any later version.
86+//
87+// This program is distributed in the hope that it will be useful,
88+// but WITHOUT ANY WARRANTY; without even the implied warranty of
89+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
90+// GNU General Public License for more details.
91+//
92+// You should have received a copy of the GNU General Public License
93+// along with this program. If not, see <http://www.gnu.org/licenses/>.
94+
95+using System;
96+using System.Collections.Generic;
97+
98+using Do.Universe;
99+
100+
101+namespace Do.Exaile
102+{
103+
104+ public abstract class AbstractPlaybackAction : Act
105+ {
106+
107+ public override IEnumerable<Type> SupportedItemTypes {
108+ get {
109+ yield return typeof (IApplicationItem);
110+ }
111+ }
112+
113+ public override bool SupportsItem (Item item)
114+ {
115+ if (!(item is IApplicationItem))
116+ return false;
117+ if ((item as IApplicationItem).Exec.Contains ("exaile")) {
118+ if (Exaile.InstanceIsRunning)
119+ return true;
120+ }
121+ return false;
122+ }
123+ }
124+}
125
126=== added file 'Exaile/src/Exaile.cs'
127--- Exaile/src/Exaile.cs 1970-01-01 00:00:00 +0000
128+++ Exaile/src/Exaile.cs 2009-03-24 02:28:22 +0000
129@@ -0,0 +1,193 @@
130+// Exaile.cs
131+//
132+// GNOME Do is the legal property of its developers, whose names are too
133+// numerous to list here. Please refer to the COPYRIGHT file distributed
134+// with this source distribution.
135+//
136+// This program is free software: you can redistribute it and/or modify
137+// it under the terms of the GNU General Public License as published by
138+// the Free Software Foundation, either version 3 of the License, or
139+// (at your option) any later version.
140+//
141+// This program is distributed in the hope that it will be useful,
142+// but WITHOUT ANY WARRANTY; without even the implied warranty of
143+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+// GNU General Public License for more details.
145+//
146+// You should have received a copy of the GNU General Public License
147+// along with this program. If not, see <http://www.gnu.org/licenses/>.
148+
149+using System;
150+using System.IO;
151+using System.Linq;
152+using System.Threading;
153+using System.Diagnostics;
154+using System.Collections.Generic;
155+
156+using Mono.Data.Sqlite;
157+
158+using Do.Platform;
159+
160+namespace Do.Exaile
161+{
162+
163+ public static class Exaile
164+ {
165+
166+ static readonly string MusicLibraryFile;
167+ static readonly string CoverArtDirectory;
168+
169+ static ICollection<SongMusicItem> songs;
170+
171+ static Timer clear_songs_timer;
172+ const int SecondsSongsCached = 45;
173+
174+ static Exaile ()
175+ {
176+ string home =
177+ Environment.GetFolderPath (Environment.SpecialFolder.Personal);
178+
179+ MusicLibraryFile = Path.Combine (home, ".exaile/music.db");
180+
181+ CoverArtDirectory = Path.Combine (home, ".exaile/covers");
182+
183+ clear_songs_timer = new Timer (state =>
184+ Gtk.Application.Invoke ((sender, args) => songs.Clear ()));
185+
186+ songs = new List<SongMusicItem> ();
187+ }
188+
189+ public static void LoadAlbumsAndArtists (
190+ out List<AlbumMusicItem> albums_out,
191+ out List<ArtistMusicItem> artists_out)
192+ {
193+ albums_out = new List<AlbumMusicItem> ();
194+ artists_out = new List<ArtistMusicItem> ();
195+
196+ Dictionary<string, AlbumMusicItem> albums =
197+ new Dictionary<string, AlbumMusicItem> ();
198+ Dictionary<string, ArtistMusicItem> artists =
199+ new Dictionary<string, ArtistMusicItem> ();
200+
201+ foreach (SongMusicItem song in LoadAllSongs ()) {
202+ if (!artists.ContainsKey (song.Artist) ||
203+ artists[song.Artist].Cover == null)
204+ {
205+ artists[song.Artist] =
206+ new ArtistMusicItem (song.Artist, song.Cover);
207+ }
208+ if (!albums.ContainsKey (song.Album) ||
209+ albums[song.Album].Cover == null)
210+ {
211+ albums[song.Album] =
212+ new AlbumMusicItem (song.Album, song.Artist, song.Year,
213+ song.Cover);
214+ }
215+ }
216+ albums_out.AddRange (albums.Values);
217+ artists_out.AddRange (artists.Values);
218+ }
219+
220+ public static IEnumerable<SongMusicItem> LoadSongsFor (MusicItem item)
221+ {
222+ if (item is SongMusicItem)
223+ return new SongMusicItem[] { item as SongMusicItem };
224+
225+ else if (item is ArtistMusicItem)
226+ return LoadAllSongs ()
227+ .Where (song => song.Artist.Contains (item.Name))
228+ .OrderBy (song => song.Album).ThenBy (song => song.Track);
229+
230+ else if (item is AlbumMusicItem)
231+ return LoadAllSongs ()
232+ .Where (song => song.Album == item.Name)
233+ .OrderBy (song => song.Track);
234+
235+ else
236+ return Enumerable.Empty<SongMusicItem> ();
237+ }
238+
239+ public static IEnumerable<SongMusicItem> LoadAllSongs ()
240+ {
241+ // Begin a new timer to clear the songs.
242+ clear_songs_timer.Change (SecondsSongsCached*1000, Timeout.Infinite);
243+
244+ if (songs.Any ()) return songs;
245+
246+ // Song list is not cached. Load songs from database.
247+ try {
248+ string connectionString = "URI=file:" + MusicLibraryFile;
249+ System.Data.IDbConnection dbcon =
250+ new SqliteConnection(connectionString);
251+ dbcon.Open();
252+ System.Data.IDbCommand dbcmd = dbcon.CreateCommand();
253+ dbcmd.CommandText =
254+ "SELECT tracks.title, artists.name, albums.name, " +
255+ "tracks.year, albums.image, paths.name, tracks.track " +
256+ "FROM tracks " +
257+ "JOIN artists ON tracks.artist = artists.id " +
258+ "JOIN albums ON tracks.album = albums.id " +
259+ "JOIN paths ON tracks.path = paths.id";
260+ System.Data.IDataReader reader = dbcmd.ExecuteReader();
261+
262+ while(reader.Read()) {
263+ string name = reader.GetString(0);
264+ string artist = reader.GetString(1);
265+ string album = reader.GetString(2);
266+ string year = reader.GetString(3);
267+ object image_value = reader.GetValue(4);
268+ string cover = null;
269+ string file = reader.GetString(5);
270+ int track = reader.GetInt32(6);
271+
272+ if (image_value is string) {
273+ cover = Path.Combine(CoverArtDirectory,
274+ image_value as string);
275+ }
276+
277+ songs.Add(new SongMusicItem(name, artist, album, year,
278+ cover, file, track));
279+ }
280+
281+ } catch (Exception e) {
282+ Console.Error.WriteLine (
283+ "Could not read Exaile database file: " + e.Message);
284+ }
285+ return songs;
286+ }
287+
288+ public static bool InstanceIsRunning
289+ {
290+ get {
291+ try {
292+ ProcessStartInfo pinfo =
293+ new ProcessStartInfo ("pgrep", "exaile");
294+ pinfo.UseShellExecute = false;
295+ pinfo.RedirectStandardOutput = true;
296+
297+ Process pgrep = Process.Start (pinfo);
298+ pgrep.WaitForExit ();
299+ return pgrep.ExitCode == 0;
300+ } catch (Exception e) {
301+ Log.Error ("Could not determine if Exaile is running: {0}", e.Message);
302+ Log.Debug (e.StackTrace);
303+ }
304+ return true;
305+ }
306+ }
307+
308+ public static void Client (string command)
309+ {
310+ Client (command, false);
311+ }
312+
313+ public static void Client (string command, bool wait)
314+ {
315+ try {
316+ Process client = Process.Start ("exaile", command);
317+ if (wait) client.WaitForExit ();
318+ } catch {
319+ }
320+ }
321+ }
322+}
323
324=== added file 'Exaile/src/ExaileItems.cs'
325--- Exaile/src/ExaileItems.cs 1970-01-01 00:00:00 +0000
326+++ Exaile/src/ExaileItems.cs 2009-03-24 02:28:22 +0000
327@@ -0,0 +1,111 @@
328+// ExaileItems.cs
329+//
330+// GNOME Do is the legal property of its developers, whose names are too
331+// numerous to list here. Please refer to the COPYRIGHT file distributed with
332+// this source distribution.
333+//
334+// This program is free software: you can redistribute it and/or modify
335+// it under the terms of the GNU General Public License as published by
336+// the Free Software Foundation, either version 3 of the License, or
337+// (at your option) any later version.
338+//
339+// This program is distributed in the hope that it will be useful,
340+// but WITHOUT ANY WARRANTY; without even the implied warranty of
341+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
342+// GNU General Public License for more details.
343+//
344+// You should have received a copy of the GNU General Public License
345+// along with this program. If not, see <http://www.gnu.org/licenses/>.
346+
347+using System;
348+using System.Diagnostics;
349+using System.Collections.Generic;
350+
351+using Mono.Unix;
352+
353+using Do.Universe;
354+using Do.Platform;
355+
356+namespace Do.Exaile
357+{
358+
359+ class BrowseMusicItem: Item
360+ {
361+ string name, description;
362+
363+ public BrowseMusicItem (string name, string description)
364+ {
365+ this.name = name;
366+ this.description = description;
367+ }
368+
369+ public override string Name { get { return name; } }
370+ public override string Description { get { return description; } }
371+ public override string Icon { get { return "gtk-cdrom"; } }
372+ }
373+
374+ class BrowseArtistsMusicItem : BrowseMusicItem
375+ {
376+ public BrowseArtistsMusicItem ():
377+ base (Catalog.GetString ("Browse Artists"),
378+ Catalog.GetString ("Browse Exaile Music by Artist"))
379+ {
380+ }
381+ }
382+
383+ class BrowseAlbumsMusicItem : BrowseMusicItem
384+ {
385+ public BrowseAlbumsMusicItem ():
386+ base (Catalog.GetString ("Browse Albums"),
387+ Catalog.GetString ("Browse Exaile Music by Album"))
388+ {
389+ }
390+ }
391+
392+ public class ExaileRunnableItem : Item, IRunnableItem
393+ {
394+ public static readonly IEnumerable<ExaileRunnableItem> Items = new [] {
395+ new ExaileRunnableItem (
396+ Catalog.GetString ("Show Current Track"),
397+ Catalog.GetString ("Show Notification of Current Track in Exaile"),
398+ "gnome-mime-audio",
399+ "--gui-query"),
400+
401+ new ExaileRunnableItem (
402+ Catalog.GetString ("Volume Up"),
403+ Catalog.GetString ("Increase Exaile Playback Volume"),
404+ "audio-volume-high",
405+ "--increase_vol=10"),
406+
407+ new ExaileRunnableItem (
408+ Catalog.GetString ("Volume Down"),
409+ Catalog.GetString ("Decrease Exaile Playback Volume"),
410+ "audio-volume-low",
411+ "--decrease_vol=10"),
412+ };
413+
414+ string name, description, icon;
415+
416+ public ExaileRunnableItem (string name, string description, string icon, string command)
417+ {
418+ this.name = name;
419+ this.description = description;
420+ this.icon = icon;
421+ Command = command;
422+ }
423+
424+ string Command { get; set; }
425+
426+ public override string Name { get { return name; } }
427+ public override string Description { get { return description; } }
428+ public override string Icon { get { return icon; } }
429+
430+ public void Run ()
431+ {
432+ Services.Application.RunOnThread (() => {
433+ Exaile.Client (Command);
434+ });
435+ }
436+
437+ }
438+}
439
440=== added file 'Exaile/src/MusicItemSource.cs'
441--- Exaile/src/MusicItemSource.cs 1970-01-01 00:00:00 +0000
442+++ Exaile/src/MusicItemSource.cs 2009-03-24 02:28:22 +0000
443@@ -0,0 +1,120 @@
444+// MusicItemSource.cs
445+//
446+// GNOME Do is the legal property of its developers, whose names are too
447+// numerous to list here. Please refer to the COPYRIGHT file distributed with
448+// this source distribution.
449+//
450+// This program is free software: you can redistribute it and/or modify
451+// it under the terms of the GNU General Public License as published by
452+// the Free Software Foundation, either version 3 of the License, or
453+// (at your option) any later version.
454+//
455+// This program is distributed in the hope that it will be useful,
456+// but WITHOUT ANY WARRANTY; without even the implied warranty of
457+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
458+// GNU General Public License for more details.
459+//
460+// You should have received a copy of the GNU General Public License
461+// along with this program. If not, see <http://www.gnu.org/licenses/>.
462+
463+using System;
464+using System.Linq;
465+using System.Collections.Generic;
466+
467+using Mono.Unix;
468+
469+using Do.Universe;
470+using Do.Platform;
471+
472+namespace Do.Exaile
473+{
474+
475+ public class MusicItemSource : ItemSource
476+ {
477+ List<Item> items;
478+ List<AlbumMusicItem> albums;
479+ List<ArtistMusicItem> artists;
480+
481+ public MusicItemSource ()
482+ {
483+ items = new List<Item> ();
484+ }
485+
486+ public override string Name {
487+ get { return Catalog.GetString ("Exaile Music"); }
488+ }
489+
490+ public override string Description {
491+ get { return Catalog.GetString ("Provides access to artists and albums from Exaile."); }
492+ }
493+
494+ public override string Icon {
495+ get { return "exaile"; }
496+ }
497+
498+ public override IEnumerable<Type> SupportedItemTypes {
499+ get {
500+ yield return typeof (MusicItem);
501+ yield return typeof (BrowseMusicItem);
502+ yield return typeof (IApplicationItem);
503+ }
504+ }
505+
506+ public override IEnumerable<Item> Items {
507+ get { return items; }
508+ }
509+
510+ bool IsExaile (Item item)
511+ {
512+ return item is IApplicationItem && IsExaile (item as IApplicationItem);
513+ }
514+
515+ bool IsExaile (IApplicationItem item)
516+ {
517+ return item.Exec.Contains ("exaile");
518+ }
519+
520+ public override IEnumerable<Item> ChildrenOfItem (Item parent) {
521+ if (IsExaile (parent)) {
522+ yield return new BrowseAlbumsMusicItem ();
523+ yield return new BrowseArtistsMusicItem ();
524+ foreach (Item item in ExaileRunnableItem.Items)
525+ yield return item;
526+ }
527+ else if (parent is ArtistMusicItem) {
528+ foreach (AlbumMusicItem album in albums.Where (album => album.Artist.Contains (parent.Name)))
529+ yield return album;
530+ }
531+ else if (parent is AlbumMusicItem) {
532+ foreach (SongMusicItem song in Exaile.LoadSongsFor (parent as AlbumMusicItem))
533+ yield return song;
534+ }
535+ else if (parent is BrowseAlbumsMusicItem) {
536+ foreach (AlbumMusicItem album in albums)
537+ yield return album;
538+ }
539+ else if (parent is BrowseArtistsMusicItem) {
540+ foreach (ArtistMusicItem artist in artists)
541+ yield return artist;
542+ }
543+ }
544+
545+ public override void UpdateItems ()
546+ {
547+ items.Clear ();
548+
549+ // Add volume and display controls.
550+ foreach (Item item in ExaileRunnableItem.Items)
551+ items.Add (item);
552+
553+ // Add browse features.
554+ items.Add (new BrowseAlbumsMusicItem ());
555+ items.Add (new BrowseArtistsMusicItem ());
556+
557+ // Add albums and artists.
558+ Exaile.LoadAlbumsAndArtists (out albums, out artists);
559+ foreach (Item album in albums) items.Add (album);
560+ foreach (Item artist in artists) items.Add (artist);
561+ }
562+ }
563+}
564
565=== added file 'Exaile/src/MusicItems.cs'
566--- Exaile/src/MusicItems.cs 1970-01-01 00:00:00 +0000
567+++ Exaile/src/MusicItems.cs 2009-03-24 02:28:22 +0000
568@@ -0,0 +1,114 @@
569+// MusicItems.cs
570+//
571+// GNOME Do is the legal property of its developers, whose names are too
572+// numerous to list here. Please refer to the COPYRIGHT file distributed with
573+// this source distribution.
574+//
575+// This program is free software: you can redistribute it and/or modify
576+// it under the terms of the GNU General Public License as published by
577+// the Free Software Foundation, either version 3 of the License, or
578+// (at your option) any later version.
579+//
580+// This program is distributed in the hope that it will be useful,
581+// but WITHOUT ANY WARRANTY; without even the implied warranty of
582+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
583+// GNU General Public License for more details.
584+//
585+// You should have received a copy of the GNU General Public License
586+// along with this program. If not, see <http://www.gnu.org/licenses/>.
587+
588+using System;
589+using System.Collections.Generic;
590+
591+using Mono.Unix;
592+
593+using Do.Universe;
594+
595+namespace Do.Exaile
596+{
597+
598+ public abstract class MusicItem : Item
599+ {
600+ protected string name, artist, year, cover;
601+
602+ public MusicItem ()
603+ {
604+ }
605+
606+ public MusicItem (string name, string artist, string year, string cover):
607+ this ()
608+ {
609+ this.name = name;
610+ this.artist = artist;
611+ this.year = year;
612+ this.cover = cover;
613+ }
614+
615+ public override string Name { get { return name; } }
616+ public override string Description { get { return artist; } }
617+ public override string Icon { get { return Cover ?? "gtk-cdrom"; } }
618+
619+ public virtual string Artist { get { return artist; } }
620+ public virtual string Year { get { return year; } }
621+ public virtual string Cover { get { return cover; } }
622+
623+ }
624+
625+ public class AlbumMusicItem : MusicItem
626+ {
627+ public AlbumMusicItem (string name, string artist, string year, string cover):
628+ base (name, artist, year, cover)
629+ {
630+ }
631+ }
632+
633+ public class ArtistMusicItem : MusicItem
634+ {
635+ public ArtistMusicItem (string artist, string cover):
636+ base ()
637+ {
638+ this.artist = this.name = artist;
639+ this.cover = cover;
640+ }
641+
642+ public override string Description
643+ {
644+ get {
645+ return string.Format (Catalog.GetString ("All music by") + " {0}", artist);
646+ }
647+ }
648+ }
649+
650+ public class SongMusicItem : MusicItem, IComparable<SongMusicItem>
651+ {
652+ string file, album;
653+ int track;
654+
655+ public SongMusicItem (string name, string artist, string album, string year, string cover, string file, int track):
656+ base (name, artist, year, cover)
657+ {
658+ this.file = file;
659+ this.album = album;
660+ this.track = track;
661+ }
662+
663+ public override string Icon { get { return "gnome-mime-audio"; } }
664+ public override string Description
665+ {
666+ get {
667+ return string.Format ("{0} - {1}", artist, album);
668+ }
669+ }
670+
671+ public virtual string File { get { return file; } }
672+ public virtual string Album { get { return album; } }
673+ public virtual int Track { get { return track; } }
674+
675+ public int CompareTo (SongMusicItem other)
676+ {
677+ if (album.CompareTo (other.Album) == 0)
678+ return track - other.Track;
679+ return album.CompareTo (other.Album);
680+ }
681+ }
682+}
683
684=== added file 'Exaile/src/NextAction.cs'
685--- Exaile/src/NextAction.cs 1970-01-01 00:00:00 +0000
686+++ Exaile/src/NextAction.cs 2009-03-24 02:28:22 +0000
687@@ -0,0 +1,61 @@
688+// NextAction.cs
689+//
690+// GNOME Do is the legal property of its developers, whose names are too numerous
691+// to list here. Please refer to the COPYRIGHT file distributed with this
692+// source distribution.
693+//
694+// This program is free software: you can redistribute it and/or modify
695+// it under the terms of the GNU General Public License as published by
696+// the Free Software Foundation, either version 3 of the License, or
697+// (at your option) any later version.
698+//
699+// This program is distributed in the hope that it will be useful,
700+// but WITHOUT ANY WARRANTY; without even the implied warranty of
701+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
702+// GNU General Public License for more details.
703+//
704+// You should have received a copy of the GNU General Public License
705+// along with this program. If not, see <http://www.gnu.org/licenses/>.
706+
707+using System;
708+using System.Linq;
709+using System.Threading;
710+using System.Diagnostics;
711+using System.Collections.Generic;
712+
713+using Mono.Unix;
714+
715+using Do.Universe;
716+
717+
718+namespace Do.Exaile
719+{
720+
721+ public class NextAction : AbstractPlaybackAction
722+ {
723+
724+ public NextAction ()
725+ {
726+ }
727+
728+ public override string Name {
729+ get { return Catalog.GetString ("Next"); }
730+ }
731+
732+ public override string Description {
733+ get { return Catalog.GetString ("Skip to the next track in Exaile."); }
734+ }
735+
736+ public override string Icon {
737+ get { return "media-skip-forward"; }
738+ }
739+
740+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
741+ {
742+ new Thread ((ThreadStart) delegate {
743+ Exaile.Client ("--next");
744+ }).Start ();
745+ return null;
746+ }
747+ }
748+}
749
750=== added file 'Exaile/src/PauseAction.cs'
751--- Exaile/src/PauseAction.cs 1970-01-01 00:00:00 +0000
752+++ Exaile/src/PauseAction.cs 2009-03-24 02:28:22 +0000
753@@ -0,0 +1,61 @@
754+// PauseAction.cs
755+//
756+// GNOME Do is the legal property of its developers, whose names are too numerous
757+// to list here. Please refer to the COPYRIGHT file distributed with this
758+// source distribution.
759+//
760+// This program is free software: you can redistribute it and/or modify
761+// it under the terms of the GNU General Public License as published by
762+// the Free Software Foundation, either version 3 of the License, or
763+// (at your option) any later version.
764+//
765+// This program is distributed in the hope that it will be useful,
766+// but WITHOUT ANY WARRANTY; without even the implied warranty of
767+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
768+// GNU General Public License for more details.
769+//
770+// You should have received a copy of the GNU General Public License
771+// along with this program. If not, see <http://www.gnu.org/licenses/>.
772+
773+using System;
774+using System.Linq;
775+using System.Threading;
776+using System.Diagnostics;
777+using System.Collections.Generic;
778+
779+using Mono.Unix;
780+
781+using Do.Universe;
782+
783+
784+namespace Do.Exaile
785+{
786+
787+ public class PauseAction : AbstractPlaybackAction
788+ {
789+
790+ public PauseAction ()
791+ {
792+ }
793+
794+ public override string Name {
795+ get { return Catalog.GetString ("Pause"); }
796+ }
797+
798+ public override string Description {
799+ get { return Catalog.GetString ("Pause music in Exaile."); }
800+ }
801+
802+ public override string Icon {
803+ get { return "media-playback-pause"; }
804+ }
805+
806+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
807+ {
808+ new Thread ((ThreadStart) delegate {
809+ Exaile.Client ("--play-pause");
810+ }).Start ();
811+ return null;
812+ }
813+ }
814+}
815
816=== added file 'Exaile/src/PlayAction.cs'
817--- Exaile/src/PlayAction.cs 1970-01-01 00:00:00 +0000
818+++ Exaile/src/PlayAction.cs 2009-03-24 02:28:22 +0000
819@@ -0,0 +1,61 @@
820+// PlayAction.cs
821+//
822+// GNOME Do is the legal property of its developers, whose names are too numerous
823+// to list here. Please refer to the COPYRIGHT file distributed with this
824+// source distribution.
825+//
826+// This program is free software: you can redistribute it and/or modify
827+// it under the terms of the GNU General Public License as published by
828+// the Free Software Foundation, either version 3 of the License, or
829+// (at your option) any later version.
830+//
831+// This program is distributed in the hope that it will be useful,
832+// but WITHOUT ANY WARRANTY; without even the implied warranty of
833+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
834+// GNU General Public License for more details.
835+//
836+// You should have received a copy of the GNU General Public License
837+// along with this program. If not, see <http://www.gnu.org/licenses/>.
838+
839+using System;
840+using System.Linq;
841+using System.Threading;
842+using System.Diagnostics;
843+using System.Collections.Generic;
844+
845+using Mono.Unix;
846+
847+using Do.Universe;
848+
849+
850+namespace Do.Exaile
851+{
852+
853+ public class PlayAction : AbstractPlaybackAction
854+ {
855+
856+ public PlayAction ()
857+ {
858+ }
859+
860+ public override string Name {
861+ get { return Catalog.GetString ("Play"); }
862+ }
863+
864+ public override string Description {
865+ get { return Catalog.GetString ("Play music in Exaile."); }
866+ }
867+
868+ public override string Icon {
869+ get { return "media-playback-start"; }
870+ }
871+
872+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
873+ {
874+ new Thread ((ThreadStart) delegate {
875+ Exaile.Client ("--play-pause");
876+ }).Start ();
877+ return null;
878+ }
879+ }
880+}
881
882=== added file 'Exaile/src/PlayItemAction.cs'
883--- Exaile/src/PlayItemAction.cs 1970-01-01 00:00:00 +0000
884+++ Exaile/src/PlayItemAction.cs 2009-03-24 02:28:22 +0000
885@@ -0,0 +1,76 @@
886+// PlayItemAction.cs
887+//
888+// GNOME Do is the legal property of its developers, whose names are too numerous
889+// to list here. Please refer to the COPYRIGHT file distributed with this
890+// source distribution.
891+//
892+// This program is free software: you can redistribute it and/or modify
893+// it under the terms of the GNU General Public License as published by
894+// the Free Software Foundation, either version 3 of the License, or
895+// (at your option) any later version.
896+//
897+// This program is distributed in the hope that it will be useful,
898+// but WITHOUT ANY WARRANTY; without even the implied warranty of
899+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
900+// GNU General Public License for more details.
901+//
902+// You should have received a copy of the GNU General Public License
903+// along with this program. If not, see <http://www.gnu.org/licenses/>.
904+
905+using System;
906+using System.Linq;
907+using System.Threading;
908+using System.Diagnostics;
909+using System.Collections.Generic;
910+
911+using Mono.Unix;
912+
913+using Do.Universe;
914+
915+namespace Do.Exaile
916+{
917+
918+ public class PlayItemAction : Act
919+ {
920+
921+ public PlayItemAction ()
922+ {
923+ }
924+
925+ public override string Name {
926+ get { return Catalog.GetString ("Play"); }
927+ }
928+
929+ public override string Description {
930+ get { return Catalog.GetString ("Play an item in Exaile."); }
931+ }
932+
933+ public override string Icon {
934+ get { return "exaile"; }
935+ }
936+
937+ public override IEnumerable<Type> SupportedItemTypes {
938+ get {
939+ yield return typeof (MusicItem);
940+ }
941+ }
942+
943+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
944+ {
945+ new Thread ((ThreadStart) delegate {
946+
947+ foreach (Item item in items) {
948+ string enqueue = "";
949+
950+ if (item is MusicItem) {
951+ foreach (SongMusicItem song in Exaile.LoadSongsFor (item as MusicItem)) {
952+ enqueue += string.Format ("\"{0}\" ", song.File);
953+ }
954+ Exaile.Client (enqueue);
955+ }
956+ }
957+ }).Start ();
958+ return null;
959+ }
960+ }
961+}
962
963=== added file 'Exaile/src/PreviousAction.cs'
964--- Exaile/src/PreviousAction.cs 1970-01-01 00:00:00 +0000
965+++ Exaile/src/PreviousAction.cs 2009-03-24 02:28:22 +0000
966@@ -0,0 +1,62 @@
967+// PreviousAction.cs
968+//
969+// GNOME Do is the legal property of its developers, whose names are too numerous
970+// to list here. Please refer to the COPYRIGHT file distributed with this
971+// source distribution.
972+//
973+// This program is free software: you can redistribute it and/or modify
974+// it under the terms of the GNU General Public License as published by
975+// the Free Software Foundation, either version 3 of the License, or
976+// (at your option) any later version.
977+//
978+// This program is distributed in the hope that it will be useful,
979+// but WITHOUT ANY WARRANTY; without even the implied warranty of
980+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
981+// GNU General Public License for more details.
982+//
983+// You should have received a copy of the GNU General Public License
984+// along with this program. If not, see <http://www.gnu.org/licenses/>.
985+
986+using System;
987+using System.Linq;
988+using System.Threading;
989+using System.Diagnostics;
990+using System.Collections.Generic;
991+
992+using Mono.Unix;
993+
994+using Do.Universe;
995+
996+
997+namespace Do.Exaile
998+{
999+
1000+ public class PreviousAction : AbstractPlaybackAction
1001+ {
1002+
1003+ public PreviousAction ()
1004+ {
1005+ }
1006+
1007+ public override string Name {
1008+ get { return Catalog.GetString ("Previous"); }
1009+ }
1010+
1011+ public override string Description {
1012+ get { return Catalog.GetString ("Skip to the previous track in Exaile."); }
1013+ }
1014+
1015+ public override string Icon {
1016+ get { return "media-skip-backward"; }
1017+ }
1018+
1019+ public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modifierItems)
1020+ {
1021+ new Thread ((ThreadStart) delegate {
1022+ Exaile.Client ("--prev", true);
1023+ Exaile.Client ("--prev");
1024+ }).Start ();
1025+ return null;
1026+ }
1027+ }
1028+}
1029
1030=== modified file 'Makefile.am'
1031--- Makefile.am 2009-03-09 10:09:56 +0000
1032+++ Makefile.am 2009-03-24 02:28:22 +0000
1033@@ -18,6 +18,7 @@
1034 EOG-Slideshow \
1035 Epiphany \
1036 Evolution \
1037+ Exaile \
1038 File \
1039 Firefox \
1040 Flickr \
1041
1042=== modified file 'configure.ac'
1043--- configure.ac 2009-03-20 23:05:29 +0000
1044+++ configure.ac 2009-03-24 02:28:22 +0000
1045@@ -135,6 +135,7 @@
1046 EOG-Slideshow/Makefile
1047 Epiphany/Makefile
1048 Evolution/Makefile
1049+Exaile/Makefile
1050 File/Makefile
1051 Firefox/Makefile
1052 Flickr/Makefile

Subscribers

People subscribed via source and target branches