~haakan/do-plugins/sshfix

« back to all changes in this revision

Viewing changes to MPD/src/MPDItems.cs

  • Committer: Jason Smith
  • Date: 2008-12-24 04:37:17 UTC
  • mto: This revision was merged to the branch mainline in revision 337.
  • Revision ID: jassmith@gmail.com-20081224043717-9yq3uhajlmnyyg5k
Merge community into official

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  MPDItems.cs
 
2
//
 
3
//  GNOME Do is the legal property of its developers, whose names are too numerous
 
4
//  to list here.  Please refer to the COPYRIGHT file distributed with this
 
5
//  source distribution.
 
6
//
 
7
//  This program is free software: you can redistribute it and/or modify
 
8
//  it under the terms of the GNU General Public License as published by
 
9
//  the Free Software Foundation, either version 3 of the License, or
 
10
//  (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU General Public License for more details.
 
16
//
 
17
//  You should have received a copy of the GNU General Public License
 
18
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
using System;
 
21
using System.Threading;
 
22
using System.Diagnostics;
 
23
 
 
24
 
 
25
using Do.Universe;
 
26
 
 
27
namespace MPD
 
28
{
 
29
        class BrowseMusicItem: Item
 
30
        {
 
31
                string name, description;
 
32
 
 
33
                public BrowseMusicItem (string name, string description)
 
34
                {
 
35
                        this.name = name;
 
36
                        this.description = description;
 
37
                }
 
38
 
 
39
                public override string Name { get { return name; } }
 
40
                public override string Description { get { return description; } }
 
41
                public override string Icon { get { return "gtk-cdrom"; } }
 
42
        }
 
43
 
 
44
        class BrowseArtistsMusicItem : BrowseMusicItem
 
45
        {
 
46
                public BrowseArtistsMusicItem ():
 
47
                        base ("Browse Artists", "Browse MPD Music by Artist")
 
48
                {
 
49
                }
 
50
        }
 
51
 
 
52
        class BrowseAlbumsMusicItem : BrowseMusicItem
 
53
        {
 
54
                public BrowseAlbumsMusicItem ():
 
55
                        base ("Browse Albums", "Browse MPD Music by Album")
 
56
                {
 
57
                }
 
58
        }
 
59
        class BrowseAllMusicItem : BrowseMusicItem
 
60
        {
 
61
                ArtistMusicItem artist;
 
62
                public BrowseAllMusicItem (ArtistMusicItem artist):
 
63
                        base ("Browse Music", "All songs by " + artist.Artist)
 
64
                {
 
65
                        this.artist = artist;
 
66
                }
 
67
                public ArtistMusicItem Artist { get { return artist; } }
 
68
        }
 
69
        public class MPDRunnableItem : Item, IRunnableItem
 
70
        {
 
71
                public static readonly MPDRunnableItem[] DefaultItems =
 
72
                        new MPDRunnableItem[] {
 
73
 
 
74
                                new MPDRunnableItem ("Play",
 
75
                                                "Play Current Track in MPD",
 
76
                                                "player_play",
 
77
                                                "play"),
 
78
 
 
79
                                new MPDRunnableItem ("Pause",
 
80
                                                "Pause MPD Playback",
 
81
                                                "player_pause",
 
82
                                                "pause"),
 
83
 
 
84
                                new MPDRunnableItem ("Next",
 
85
                                                "Play Next Track in MPD",
 
86
                                                "player_end",
 
87
                                                "next"),
 
88
 
 
89
                                new MPDRunnableItem ("Previous",
 
90
                                                "Play Previous Track in MPD",
 
91
                                                "player_start",
 
92
                                                "previous"),
 
93
 
 
94
                                new MPDRunnableItem ("Volume Up",
 
95
                                                "Increase MPD Playback Volume",
 
96
                                                "audio-volume-high",
 
97
                                                "volume +10"),
 
98
 
 
99
                                new MPDRunnableItem ("Volume Down",
 
100
                                                "Decrease MPD Playback Volume",
 
101
                                                "audio-volume-low",
 
102
                                                "volume -10"),
 
103
 
 
104
                            new MPDRunnableItem ("Update",
 
105
                                    "Refresh MPD Database",
 
106
                                    "reload",
 
107
                                                "update"),
 
108
                        };
 
109
 
 
110
                string name, description, icon, command;
 
111
 
 
112
                public MPDRunnableItem (string name, string description, string icon, string command)
 
113
                {
 
114
                        this.name = name;
 
115
                        this.description = description;
 
116
                        this.icon = icon;
 
117
                        this.command = command;
 
118
                }
 
119
 
 
120
                public override string Name { get { return name; } }
 
121
                public override string Description { get { return description; } }
 
122
                public override string Icon { get { return icon; } }
 
123
 
 
124
                public void Run ()
 
125
                {
 
126
                        new Thread ((ThreadStart) delegate {
 
127
                                        MPD.Client (command);
 
128
                                        }).Start ();
 
129
                }
 
130
 
 
131
        }
 
132
}