Skip to content

Commit

Permalink
Fix problem 2: the "eject" context menu item in the music and picture…
Browse files Browse the repository at this point in the history
…s plugins doesn't work when the drive does not contain a disc.

The eject context menu item was trying to be too clever, closing the tray when it was open and opening the tray when it was closed. Actually, it's not possible (or very *very* difficult) to distinguish between "open tray" and "closed tray without disc". So, it's better to have the item simply open the tray as suggested by the item label.
  • Loading branch information
mm1352000 committed May 27, 2016
1 parent 78fc361 commit 17bf16d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 34 deletions.
18 changes: 3 additions & 15 deletions mediaportal/WindowPlugins/GUIMusic/GUIMusicFiles.cs
Expand Up @@ -578,8 +578,8 @@ public override void OnAction(Action action)
LoadDirectory(item.Path);
return;
}
}

}

base.OnAction(action);
}

Expand Down Expand Up @@ -1158,25 +1158,13 @@ protected override void OnShowContextMenu()
break;

case 654: // Eject
if (item != null && Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
if (item != null && item.Path != null)
{
var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));

if (!driveInfo.IsReady)
{
Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
}
}
LoadDirectory(string.Empty);
break;
Expand Down
22 changes: 5 additions & 17 deletions mediaportal/WindowPlugins/GUIPictures/GUIPictures.cs
Expand Up @@ -646,8 +646,8 @@ public override void OnAction(Action action)
OnDeleteItem(item);
}
}
}

}

base.OnAction(action);
}

Expand Down Expand Up @@ -1363,25 +1363,13 @@ protected override void OnShowContextMenu()
}
break;
case 654: // Eject
if (item != null && Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
else
{
if (item != null && item.Path != null)
{
var driveInfo = new DriveInfo(Path.GetPathRoot(item.Path));

if (!driveInfo.IsReady)
{
Util.Utils.CloseCDROM(Path.GetPathRoot(item.Path));
}
else
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
}
{
Util.Utils.EjectCDROM(Path.GetPathRoot(item.Path));
}
LoadDirectory(string.Empty);
break;
Expand Down
4 changes: 2 additions & 2 deletions mediaportal/WindowPlugins/GUIVideos/GUIVideoFiles.cs
Expand Up @@ -478,7 +478,7 @@ public override void OnAction(Action action)
if (action.wID == Action.ActionType.ACTION_PLAY || action.wID == Action.ActionType.ACTION_MUSIC_PLAY)
{
_playClicked = true;
}
}

base.OnAction(action);
}
Expand Down Expand Up @@ -1535,7 +1535,7 @@ protected override void OnShowContextMenu()
break;

case 654: // Eject
if (Util.Utils.getDriveType(item.Path) != 5)
if (item == null || item.Path == null || Util.Utils.getDriveType(item.Path) != 5)
{
Util.Utils.EjectCDROM();
}
Expand Down

0 comments on commit 17bf16d

Please sign in to comment.