2727using System ;
2828using System . Collections . Generic ;
2929using System . Linq ;
30+ using MonoDevelop . Components . AtkCocoaHelper ;
3031using MonoDevelop . Core ;
3132using MonoDevelop . Ide ;
3233using MonoDevelop . Projects ;
@@ -90,7 +91,6 @@ public ManagePackagesDialog (
9091 consolidateLabel . Visible = viewModel . IsManagingSolution ;
9192 UpdateDialogTitle ( ) ;
9293 UpdatePackageSearchEntryWithInitialText ( initialSearch ) ;
93- UpdatePackageResultsPageLabels ( ) ;
9494
9595 InitializeListView ( ) ;
9696 UpdateAddPackagesButton ( ) ;
@@ -113,6 +113,33 @@ public ManagePackagesDialog (
113113 updatesLabel . KeyPressed += UpdatesLabelKeyPressed ;
114114 consolidateLabel . ButtonPressed += ConsolidateLabelButtonPressed ;
115115 consolidateLabel . KeyPressed += ConsolidateLabelKeyPressed ;
116+ UpdateTabAccessibility ( ) ;
117+ UpdatePackageResultsPageLabels ( ) ;
118+ }
119+
120+ void UpdateTabAccessibility ( )
121+ {
122+ if ( tabGroup . Surface . ToolkitEngine . Type == ToolkitType . Gtk ) {
123+ if ( consolidateLabel . Parent . Surface . NativeWidget is Gtk . Container a11yGroup ) {
124+ a11yGroup . Accessible . SetRole ( AtkCocoa . Roles . AXTabGroup ) ;
125+ var children = a11yGroup . Children ;
126+ var tabs = new List < Atk . Object > ( children . Length ) ;
127+ foreach ( var child in children ) {
128+ if ( ! child . Visible )
129+ continue ;
130+ if ( child is Gtk . EventBox box && box . Child is Gtk . Label ) {
131+ box . Accessible . SetTitleUIElement ( box . Child . Accessible ) ;
132+ box . Child . Accessible . SetShouldIgnore ( true ) ;
133+ }
134+ var tab = child . Accessible ;
135+ tab . SetRole ( AtkCocoa . Roles . AXRadioButton ) ;
136+ tab . SetSubRole ( AtkCocoa . SubRoles . AXTabButton ) ;
137+ tab . SetValue ( false ) ;
138+ tabs . Add ( tab ) ;
139+ }
140+ a11yGroup . Accessible . SetTabs ( tabs . ToArray ( ) ) ;
141+ }
142+ }
116143 }
117144
118145 public bool ShowPreferencesForPackageSources { get ; private set ; }
@@ -1110,12 +1137,26 @@ void UpdatePackageResultsLabel (ManagePackagesPage page, Label label)
11101137 {
11111138 string text = ( string ) label . Tag ;
11121139 if ( page == viewModel . PageSelected ) {
1140+ UpdatePackageResultsLabelA11y ( label , true ) ;
11131141 label . Markup = string . Format ( "<b><u>{0}</u></b>" , text ) ;
11141142 } else {
1143+ UpdatePackageResultsLabelA11y ( label , false ) ;
11151144 label . Markup = text ;
11161145 }
11171146 }
11181147
1148+ static void UpdatePackageResultsLabelA11y ( Label label , bool active )
1149+ {
1150+ if ( label . Surface . ToolkitEngine . Type == ToolkitType . Gtk ) {
1151+ var widget = label . Surface . NativeWidget as Gtk . Widget ;
1152+ if ( widget != null ) {
1153+ widget . Accessible . SetValue ( active ) ;
1154+ // FIXME: Accessible.SetValue has no effect, so set the role description instead
1155+ widget . Accessible . SetRole ( AtkCocoa . Roles . AXRadioButton , active ? "selected tab" : "tab" ) ;
1156+ }
1157+ }
1158+ }
1159+
11191160 void UpdatePackageResultsLabel ( ManagePackagesPage page , Button label )
11201161 {
11211162 string text = ( string ) label . Tag ;
0 commit comments