Browse Source

Rename to MountedDrives

pull/2777/head
Jumar Macato 7 years ago
parent
commit
3a798f7441
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 2
      src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs
  2. 2
      src/Avalonia.Dialogs/ManagedFileChooserSources.cs
  3. 22
      src/Avalonia.X11/Dbus/LinuxMountedDriveInfoProvider.cs

2
src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs

@ -16,6 +16,6 @@ namespace Avalonia.Controls.Platform
/// <summary>
/// Observable list of currently-mounted drives.
/// </summary>
ObservableCollection<MountedDriveInfo> CurrentDrives { get; }
ObservableCollection<MountedDriveInfo> MountedDrives { get; }
}
}

2
src/Avalonia.Dialogs/ManagedFileChooserSources.cs

@ -72,7 +72,7 @@ namespace Avalonia.Dialogs
{
var drivesInfos = AvaloniaLocator.CurrentMutable
.GetService<IMountedDriveInfoProvider>()
.CurrentDrives;
.MountedDrives;
return drivesInfos
.Where(x => !x.MountPath.StartsWith("/boot"))

22
src/Avalonia.X11/Dbus/LinuxMountedDriveInfoProvider.cs

@ -18,6 +18,7 @@ namespace Avalonia.X11.Dbus
public LinuxMountedDriveInfoProvider()
{
this._sysDbus = Connection.System;
this.udisk2Manager = _sysDbus.CreateProxy<IObjectManager>("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2");
Start();
@ -32,7 +33,8 @@ namespace Avalonia.X11.Dbus
Poll();
}
public ObservableCollection<MountedDriveInfo> CurrentDrives { get; } = new ObservableCollection<MountedDriveInfo>();
public ObservableCollection<MountedDriveInfo> MountedDrives { get; } = new ObservableCollection<MountedDriveInfo>();
private async void Poll()
{
var newDriveList = new List<MountedDriveInfo>();
@ -55,8 +57,6 @@ namespace Avalonia.X11.Dbus
{
try
{
var iblock = _sysDbus.CreateProxy<IBlock>("org.freedesktop.UDisks2", block.Key);
var iblockProps = await iblock.GetAllAsync();
@ -107,7 +107,7 @@ namespace Avalonia.X11.Dbus
private void UpdateCollection(IEnumerable<MountedDriveInfo> newCollection)
{
var newCollectionEnumerator = newCollection.GetEnumerator();
var collectionEnumerator = CurrentDrives.GetEnumerator();
var collectionEnumerator = MountedDrives.GetEnumerator();
var itemsToDelete = new Collection<MountedDriveInfo>();
while (collectionEnumerator.MoveNext())
@ -124,7 +124,7 @@ namespace Avalonia.X11.Dbus
// Handle item to delete.
foreach (var itemToDelete in itemsToDelete)
{
CurrentDrives.Remove(itemToDelete);
MountedDrives.Remove(itemToDelete);
}
var i = 0;
@ -133,16 +133,16 @@ namespace Avalonia.X11.Dbus
var item = newCollectionEnumerator.Current;
// Handle new item.
if (!CurrentDrives.Contains(item))
if (!MountedDrives.Contains(item))
{
CurrentDrives.Insert(i, item);
MountedDrives.Insert(i, item);
}
// Handle existing item, move at the good index.
if (CurrentDrives.Contains(item))
if (MountedDrives.Contains(item))
{
int oldIndex = CurrentDrives.IndexOf(item);
CurrentDrives.Move(oldIndex, i);
int oldIndex = MountedDrives.IndexOf(item);
MountedDrives.Move(oldIndex, i);
}
i++;
}
@ -159,7 +159,7 @@ namespace Avalonia.X11.Dbus
foreach (var Disposable in Disposables)
Disposable.Dispose();
CurrentDrives?.Clear();
MountedDrives?.Clear();
}
disposedValue = true;

Loading…
Cancel
Save