diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2019-11-11 14:54:05 +0300 |
---|---|---|
committer | Vsevolod Kukol <sevoku@microsoft.com> | 2019-11-11 14:54:05 +0300 |
commit | 13fdf7ffd699d2337c4b4cc8969403587015268a (patch) | |
tree | e27e587bbbbcc220b7b6a5c7fa1312e9912196a7 /main/src/addins/MonoDevelop.PackageManagement | |
parent | 669bdd8eb786b570c2cf9d2dea38a21801f6b1ff (diff) |
[NuGet] Make package selection list view accessible
Fixes VSTS #750376
Diffstat (limited to 'main/src/addins/MonoDevelop.PackageManagement')
3 files changed, 58 insertions, 3 deletions
diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AccessibleSpacerCellView.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AccessibleSpacerCellView.cs new file mode 100644 index 0000000000..2b7dffa826 --- /dev/null +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/AccessibleSpacerCellView.cs @@ -0,0 +1,39 @@ +// +// AccessibleSpacerCellView.cs +// +// Author: +// Vsevolod Kukol <sevoku@microsoft.com> +// +// Copyright (c) 2019 +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using Xwt; + +namespace MonoDevelop.PackageManagement +{ + class AccessibleSpacerCellView : CanvasCellView + { + static Size size = new Size (5, 5); + + protected override Size OnGetRequiredSize (SizeConstraint widthConstraint) + { + return size; + } + } +} diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs index 361becc59e..603de55a95 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.Gui/ManagePackagesDialog.cs @@ -45,6 +45,8 @@ namespace MonoDevelop.PackageManagement DataField<ManagePackagesSearchResultViewModel> packageViewModelField = new DataField<ManagePackagesSearchResultViewModel> (); DataField<Image> packageImageField = new DataField<Image> (); DataField<bool> packageCheckBoxField = new DataField<bool> (); + DataField<string> packageCheckA11yField = new DataField<string> (); + DataField<string> packageDescriptionA11yField = new DataField<string> (); ListStore packageStore; ManagePackagesCellView packageCellView; CheckBoxCellView packageCheckView; @@ -153,7 +155,7 @@ namespace MonoDevelop.PackageManagement void InitializeListView () { - packageStore = new ListStore (packageImageField, packageViewModelField, packageCheckBoxField); + packageStore = new ListStore (packageImageField, packageViewModelField, packageCheckBoxField, packageCheckA11yField, packageDescriptionA11yField); packagesListView.DataSource = packageStore; AddCellViewsToListView (); @@ -177,10 +179,13 @@ namespace MonoDevelop.PackageManagement var checkColumn = new ListViewColumn (GettextCatalog.GetString ("Add Package")); packageCheckView = new CheckBoxCellView (packageCheckBoxField) { Editable = true }; + packageCheckView.AccessibleFields.Label = packageCheckA11yField; packageCheckView.Toggled += PackageCheckCellViewPackageChecked; // HACK: Xwt has no custom cell padding, so we need to add an empty label for spacing - checkColumn.Views.Add (new TextCellView (" ")); + var spaceText = new AccessibleSpacerCellView (); + spaceText.AccessibleFields.Label = packageCheckA11yField; + checkColumn.Views.Add (spaceText); checkColumn.Views.Add (packageCheckView); packagesListView.Columns.Add (checkColumn); @@ -189,6 +194,7 @@ namespace MonoDevelop.PackageManagement ImageField = packageImageField, CellWidth = 446 }; + packageCellView.AccessibleFields.Label = packageDescriptionA11yField; var textColumn = new ListViewColumn ("Package", packageCellView); packagesListView.Columns.Add (textColumn); @@ -592,7 +598,16 @@ namespace MonoDevelop.PackageManagement void AppendPackageToListView (ManagePackagesSearchResultViewModel packageViewModel) { int row = packageStore.AddRow (); - packageStore.SetValue (row, packageViewModelField, packageViewModel); + var accessibleDescription = StringBuilderCache.Allocate (packageViewModel.Id); + if (packageViewModel.HasDownloadCount) + accessibleDescription.Append (", ").Append (packageViewModel.GetDownloadCountDisplayText ()).Append (" ").Append (GettextCatalog.GetString ("Downloads")); + if (!string.IsNullOrEmpty (packageViewModel.Summary)) + accessibleDescription.Append (", ").Append (packageViewModel.Summary); + packageStore.SetValues (row, + packageViewModelField, packageViewModel, + packageCheckBoxField, packageViewModel.IsChecked, + packageCheckA11yField, packageViewModel.Name, + packageDescriptionA11yField, StringBuilderCache.ReturnAndFree (accessibleDescription)); } void LoadPackageImage (int row, ManagePackagesSearchResultViewModel packageViewModel) diff --git a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj index 4ea333473e..1065766e15 100644 --- a/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj +++ b/main/src/addins/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.csproj @@ -348,6 +348,7 @@ </Compile> <Compile Include="MonoDevelop.PackageManagement.Gui\ManagePackagesCellView.cs" /> <Compile Include="MonoDevelop.PackageManagement.Gui\ManagePackagesCellViewEventArgs.cs" /> + <Compile Include="MonoDevelop.PackageManagement.Gui\AccessibleSpacerCellView.cs" /> <Compile Include="MonoDevelop.PackageManagement\ManagedPackagesSearchResultViewModelComparer.cs" /> <Compile Include="MonoDevelop.PackageManagement\ManagePackagesPage.cs" /> <Compile Include="MonoDevelop.PackageManagement\ManagePackagesProjectInfo.cs" /> |