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> /// <summary>
/// Observable list of currently-mounted drives. /// Observable list of currently-mounted drives.
/// </summary> /// </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 var drivesInfos = AvaloniaLocator.CurrentMutable
.GetService<IMountedDriveInfoProvider>() .GetService<IMountedDriveInfoProvider>()
.CurrentDrives; .MountedDrives;
return drivesInfos return drivesInfos
.Where(x => !x.MountPath.StartsWith("/boot")) .Where(x => !x.MountPath.StartsWith("/boot"))

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

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

Loading…
Cancel
Save