Commit 4045c599 authored by Aaron Bockover's avatar Aaron Bockover Committed by Aaron Bockover

Sensitize/desensitize audio cd rows based on their rip state

2006-03-20  Aaron Bockover  <aaron@abock.org>

    * src/PlaylistView.cs: Sensitize/desensitize audio cd rows based on
    their rip state

    * src/Banshee.Base/AudioCdRipper.cs: Update newly ripped track with
    its ripped URI so it can be played while the rest of the disk is
    ripping

    * src/Banshee.Base/Library.cs: Removed unused function

    * src/Banshee.Base/PlayerEngineCore.cs: Do not attempt to play track
    if it is explicitly marked as being unable to play; reversed order of
    Reset/Close in Close wrapper

    * src/Banshee.Base/TrackInfo.cs: Mark CanPlay as virtual

    * src/Banshee.Base/TrackInfoHeader.cs (SetIdle): Hide the box

    * src/Banshee.Base/AudioCd/AudioCdDisk.cs: Added an IsRipping property

    * src/Banshee.Base/AudioCd/AudioCdTrackInfo.cs: Added Disk, IsRipped, and
    CanPlay properties

    * src/Banshee.Base/Sources/AudioCdSource.cs: If current playing track
    in the engine is from the CD, shut down the engine; set disk.IsRipping
    accordingly

    * src/Banshee.Base/Sources/LibrarySource.cs: Removed old cruft

    * src/Banshee.MediaEngine/Helix/HelixRemotePlayerEngine.cs: Updated
    to reflect minor changes in the Buffering API in PlayerEngine

    * src/Banshee.Plugins/NotificationAreaIcon/NotificationAreaIconPlugin.cs:
    Guard against a potential nullref
parent f0b6d516
2006-03-20 Aaron Bockover <aaron@abock.org>
* src/PlaylistView.cs: Sensitize/desensitize audio cd rows based on
their rip state
* src/Banshee.Base/AudioCdRipper.cs: Update newly ripped track with
its ripped URI so it can be played while the rest of the disk is
ripping
* src/Banshee.Base/Library.cs: Removed unused function
* src/Banshee.Base/PlayerEngineCore.cs: Do not attempt to play track
if it is explicitly marked as being unable to play; reversed order of
Reset/Close in Close wrapper
* src/Banshee.Base/TrackInfo.cs: Mark CanPlay as virtual
* src/Banshee.Base/TrackInfoHeader.cs (SetIdle): Hide the box
* src/Banshee.Base/AudioCd/AudioCdDisk.cs: Added an IsRipping property
* src/Banshee.Base/AudioCd/AudioCdTrackInfo.cs: Added Disk, IsRipped, and
CanPlay properties
* src/Banshee.Base/Sources/AudioCdSource.cs: If current playing track
in the engine is from the CD, shut down the engine; set disk.IsRipping
accordingly
* src/Banshee.Base/Sources/LibrarySource.cs: Removed old cruft
* src/Banshee.MediaEngine/Helix/HelixRemotePlayerEngine.cs: Updated
to reflect minor changes in the Buffering API in PlayerEngine
* src/Banshee.Plugins/NotificationAreaIcon/NotificationAreaIconPlugin.cs:
Guard against a potential nullref
2006-03-19 Aaron Bockover <aaron@abock.org>
* entagged-sharp/EncodingInfo.cs: Handle invalid integer durations
......
......@@ -79,7 +79,7 @@ namespace Banshee.Base
//mb_disc.Client.Debug = true;
foreach(SimpleTrack mb_track in mb_disc) {
AudioCdTrackInfo track = new AudioCdTrackInfo(device_node);
AudioCdTrackInfo track = new AudioCdTrackInfo(this);
track.Duration = new TimeSpan(mb_track.Length * TimeSpan.TicksPerSecond);
track.TrackIndex = mb_track.Index;
track.Artist = Catalog.GetString("Unknown Artist");
......@@ -297,5 +297,11 @@ namespace Banshee.Base
public IEnumerable Tracks {
get { return tracks; }
}
private bool is_ripping = false;
public bool IsRipping {
get { return is_ripping; }
set { is_ripping = value; }
}
}
}
/***************************************************************************
* AudioCdTrackInfo.cs
*
* Copyright (C) 2005 Novell
* Written by Aaron Bockover (aaron@aaronbock.net)
* Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
......@@ -39,14 +38,15 @@ namespace Banshee.Base
public class AudioCdTrackInfo : TrackInfo
{
private int track_index;
private string device;
private bool do_rip;
private bool is_ripped;
private AudioCdDisk disk;
public AudioCdTrackInfo(string device)
public AudioCdTrackInfo(AudioCdDisk disk)
{
PreviousTrack = Gtk.TreeIter.Zero;
CanSaveToDatabase = false;
this.device = device;
this.disk = disk;
do_rip = true;
}
......@@ -63,31 +63,35 @@ namespace Banshee.Base
}
public int TrackIndex {
get {
return track_index;
}
get { return track_index; }
set {
track_index = value;
TrackNumber = (uint)value;
uri = new Uri("cdda://" + track_index + "#" + device);
uri = new Uri("cdda://" + track_index + "#" + disk.DeviceNode);
}
}
public string Device {
get {
return device;
}
get { return disk.DeviceNode; }
}
public AudioCdDisk Disk {
get { return disk; }
}
public bool CanRip {
get {
return do_rip;
}
set {
do_rip = value;
}
get { return do_rip; }
set { do_rip = value; }
}
public bool IsRipped {
get { return is_ripped; }
set { is_ripped = value; }
}
public override bool CanPlay {
get { return !disk.IsRipping || (disk.IsRipping && IsRipped); }
}
}
}
......@@ -150,6 +150,9 @@ namespace Banshee.Base
private void OnTrackFinished(AudioCdTrackInfo track, int trackNumber, Uri outputUri)
{
track.IsRipped = true;
track.Uri = outputUri;
AudioCdRipperTrackFinishedHandler handler = TrackFinished;
if(handler != null) {
AudioCdRipperTrackFinishedArgs args = new AudioCdRipperTrackFinishedArgs();
......@@ -272,6 +275,7 @@ namespace Banshee.Base
private PipelineProfile profile;
public event HaveTrackInfoHandler HaveTrackInfo;
public event EventHandler Finished;
private ActiveUserEvent user_event;
......@@ -378,15 +382,25 @@ namespace Banshee.Base
ripper.Dispose();
user_event.Dispose();
OnFinished();
}
private void OnRipperError(object o, EventArgs args)
{
ripper.Dispose();
user_event.Dispose();
OnFinished();
LogCore.Instance.PushError(Catalog.GetString("Cannot Import CD"), ripper.ErrorMessage);
}
private void OnFinished()
{
EventHandler handler = Finished;
if(handler != null) {
handler(this, new EventArgs());
}
}
private bool OnTimeout()
{
int diff = currentSeconds - lastPollSeconds;
......@@ -419,6 +433,7 @@ namespace Banshee.Base
}
user_event.Dispose();
OnFinished();
}
public int QueueSize {
......
/***************************************************************************
* Library.cs
*
* Copyright (C) 2005 Novell
* Written by Aaron Bockover (aaron@aaronbock.net)
* Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
......@@ -202,10 +202,10 @@ namespace Banshee.Base
}
}
private void Remove(Uri trackUri)
/*private void Remove(Uri trackUri)
{
Remove(TracksFnKeyed[MakeFilenameKey(trackUri)] as LibraryTrackInfo);
}
}*/
public void Remove(LibraryTrackInfo track)
{
......
......@@ -159,6 +159,10 @@ namespace Banshee.Base
public static void OpenPlay(TrackInfo track)
{
if(!track.CanPlay) {
return;
}
CheckPending();
active_engine.Open(track);
active_engine.Play();
......@@ -166,8 +170,8 @@ namespace Banshee.Base
public static void Close()
{
active_engine.Close();
active_engine.Reset();
active_engine.Close();
}
public static void Play()
......
......@@ -140,6 +140,13 @@ namespace Banshee.Sources
private void ImportDisk()
{
if(disk.IsRipping) {
Console.WriteLine("CD is already ripping");
return;
}
disk.IsRipping = true;
ArrayList list = new ArrayList();
foreach(AudioCdTrackInfo track in disk.Tracks) {
......@@ -150,10 +157,17 @@ namespace Banshee.Sources
if(list.Count > 0) {
AudioCdRipper ripper = new AudioCdRipper();
// ripper.HaveTrackInfo += OnAudioCdRipperTrackRipped;
ripper.Finished += OnRipperFinished;
ripper.HaveTrackInfo += OnRipperHaveTrackInfo;
foreach(AudioCdTrackInfo track in list) {
ripper.QueueTrack(track);
}
AudioCdTrackInfo playing_track = PlayerEngineCore.CurrentTrack as AudioCdTrackInfo;
if(playing_track != null && playing_track.Disk == disk) {
PlayerEngineCore.Close();
}
ripper.Start();
} else {
HigMessageDialog dialog = new HigMessageDialog(InterfaceElements.MainWindow, DialogFlags.Modal,
......@@ -163,9 +177,21 @@ namespace Banshee.Sources
);
dialog.Run();
dialog.Destroy();
disk.IsRipping = false;
}
}
private void OnRipperHaveTrackInfo(object o, HaveTrackInfoArgs args)
{
OnUpdated();
}
private void OnRipperFinished(object o, EventArgs args)
{
disk.IsRipping = false;
OnUpdated();
}
private void OnDiskUpdated(object o, EventArgs args)
{
ThreadAssist.ProxyToMain(delegate {
......
......@@ -37,7 +37,6 @@ namespace Banshee.Sources
public class LibrarySource : Source
{
private static LibrarySource instance;
private bool updating = false;
public static LibrarySource Instance {
get {
if(instance == null) {
......@@ -47,13 +46,6 @@ namespace Banshee.Sources
return instance;
}
}
private bool DelayedUpdateHandler()
{
OnUpdated();
updating = false;
return false;
}
private LibrarySource() : base(Catalog.GetString("Music Library"), 0)
{
......
......@@ -402,7 +402,7 @@ namespace Banshee.Base
}
}
public bool CanPlay {
public virtual bool CanPlay {
get {
return can_play;
}
......
/***************************************************************************
* TrackInfoHeader.cs
*
* Copyright (C) 2005 Novell
* Written by Aaron Bockover (aaron@aaronbock.net)
* Copyright (C) 2005-2006 Novell, Inc.
* Written by Aaron Bockover <aaron@abock.org>
****************************************************************************/
/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
......@@ -133,9 +132,7 @@ namespace Banshee.Widgets
}
public CoverArtThumbnail Cover {
get {
return cover;
}
get { return cover; }
}
public Gdk.Pixbuf DefaultCover {
......@@ -150,13 +147,12 @@ namespace Banshee.Widgets
}
public VBox VBox {
get {
return box;
}
get { return box; }
}
public void SetIdle()
{
box.Hide();
}
}
}
......@@ -104,7 +104,7 @@ namespace Banshee.MediaEngine.Helix
break;
case ContentState.Loading:
case ContentState.Contacting:
OnStateChanged(PlayerEngineState.Buffering);
OnEventChanged(PlayerEngineEvent.Buffering);
break;
default:
OnStateChanged(PlayerEngineState.Idle);
......
......@@ -223,8 +223,13 @@ namespace Banshee.Plugins.NotificationAreaIcon {
private void OnPlayerEngineEventChanged(object o, PlayerEngineEventArgs args) {
switch (args.Event) {
case PlayerEngineEvent.Iterate:
popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds;
popup.Position = PlayerEngineCore.Position;
if(PlayerEngineCore.CurrentTrack != null) {
popup.Duration = (uint)PlayerEngineCore.CurrentTrack.Duration.TotalSeconds;
popup.Position = PlayerEngineCore.Position;
} else {
popup.Duration = 0;
popup.Position = 0;
}
break;
case PlayerEngineEvent.StartOfStream:
FillPopup();
......
......@@ -38,6 +38,7 @@ using Pango;
using Banshee.Base;
using Banshee.Dap;
using Banshee.Sources;
namespace Banshee
{
......@@ -336,16 +337,16 @@ namespace Banshee
renderer.Foreground = null;
renderer.Sensitive = true;
TrackInfo ti = model.IterTrackInfo(iter);
if(ti == null) {
return;
}
if(ti.GetType() != typeof(DapTrackInfo))
return;
if((ti as DapTrackInfo).NeedSync)
renderer.Foreground = "blue";
if(ti is AudioCdTrackInfo) {
renderer.Sensitive = ti.CanPlay;
}
}
protected void TrackCellInd(TreeViewColumn tree_column,
......@@ -356,7 +357,7 @@ namespace Banshee
if(PlayerEngineCore.CurrentTrack == null) {
model.PlayingIter = TreeIter.Zero;
if(ti != null) {
if(ti != null && !(ti is AudioCdTrackInfo)) {
renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf;
} else {
renderer.Pixbuf = null;
......@@ -369,6 +370,8 @@ namespace Banshee
if(PlayerEngineCore.CurrentTrack != null && PlayerEngineCore.CurrentTrack.Equals(ti)) {
renderer.Pixbuf = nowPlayingPixbuf;
model.PlayingIter = iter;
} else if(ti is AudioCdTrackInfo) {
renderer.Pixbuf = null;
} else {
renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf;
}
......@@ -382,10 +385,14 @@ namespace Banshee
{
CellRendererToggle toggle = (CellRendererToggle)cell;
AudioCdTrackInfo ti = model.IterTrackInfo(iter) as AudioCdTrackInfo;
if (ti != null)
toggle.Active = ti.CanRip;
else
if(ti != null) {
toggle.Sensitive = ti.CanPlay && !ti.IsRipped;
toggle.Activatable = toggle.Sensitive;
toggle.Active = ti.CanRip && !ti.IsRipped;
} else {
toggle.Active = false;
}
}
protected void TrackCellTrack(TreeViewColumn tree_column,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment