~jorgecs10/do-plugins/quodlibet-plugin

« back to all changes in this revision

Viewing changes to QuodLibet/src/AbstractPlaybackAction.cs

  • Committer: Jorge Cob
  • Date: 2009-05-07 07:35:13 UTC
  • Revision ID: jorgecs10@gmail.com-20090507073513-n2cxazsd3327cdo6
Actions added: next, previous

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  AbstractPlaybackAction.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.Collections.Generic;
 
22
using System.Diagnostics;
 
23
 
 
24
using Do.Universe;
 
25
using Do.Platform;
 
26
 
 
27
 
 
28
namespace Do.QuodLibet
 
29
{
 
30
 
 
31
        public abstract class AbstractPlaybackAction : Act
 
32
        {
 
33
                protected string exec{
 
34
                        get { return "quodlibet"; }
 
35
                }
 
36
 
 
37
                public override IEnumerable<Type> SupportedItemTypes {
 
38
                        get { yield return typeof (IApplicationItem); }
 
39
                }
 
40
                
 
41
                protected string getStatus(){
 
42
                        Process proc = new Process();
 
43
                        proc.StartInfo.FileName = exec;
 
44
                        proc.StartInfo.Arguments = "--status";
 
45
                        proc.StartInfo.RedirectStandardOutput = true;
 
46
                        proc.StartInfo.UseShellExecute = false;
 
47
                        proc.Start();
 
48
                        
 
49
                        string output = proc.StandardOutput.ReadToEnd();
 
50
                        //Log.Info(output);
 
51
                        return output;
 
52
                }
 
53
                
 
54
                public override bool SupportsItem (Item item) 
 
55
                {
 
56
                        if (!(item is IApplicationItem))
 
57
                                return false;
 
58
                        
 
59
                        if ((item as IApplicationItem).Exec.Contains (exec)) {
 
60
                                
 
61
                                
 
62
                                if(!this.getStatus().StartsWith("not-running"))
 
63
                                        return true;
 
64
                        }
 
65
                        return false;
 
66
                }
 
67
        }
 
68
}