diff options
author | iain holmes <iain@xamarin.com> | 2017-04-28 20:59:27 +0300 |
---|---|---|
committer | iain holmes <iain@xamarin.com> | 2017-08-01 22:05:41 +0300 |
commit | 59fd7acf980b3bb418b7698ecd1e18f125edf877 (patch) | |
tree | 4c530b3655bce9407c677820bd73cc81e38078d9 /main/src | |
parent | f4ead6d7fcb0c93c8e345151f65692339ec6ab6f (diff) |
[A11y] Add option to disable accessibility
Can be set through the UI or through defaults
defaults write MonoDevelop com.monodevelop.AccessibilityEnabled true
Diffstat (limited to 'main/src')
4 files changed, 150 insertions, 3 deletions
diff --git a/main/src/core/MonoDevelop.Ide/ExtensionModel/GlobalOptionsDialog.addin.xml b/main/src/core/MonoDevelop.Ide/ExtensionModel/GlobalOptionsDialog.addin.xml index 732fe600ca..60beb40d2b 100644 --- a/main/src/core/MonoDevelop.Ide/ExtensionModel/GlobalOptionsDialog.addin.xml +++ b/main/src/core/MonoDevelop.Ide/ExtensionModel/GlobalOptionsDialog.addin.xml @@ -1,4 +1,4 @@ -<ExtensionModel> +<ExtensionModel> <ExtensionPoint path = "/MonoDevelop/Ide/GlobalOptionsDialog" name = "Global options panels"> <Description>Dialog panels for global MonoDevelop options.</Description> @@ -47,6 +47,9 @@ <Section id = "LogAgent" _label = "Feedback" class = "MonoDevelop.Ide.Gui.OptionPanels.LogAgentOptionsPanel" icon="md-prefs-feedback" fill="true" /> <Section id = "MonoDevelopMaintenance" _label = "MonoDevelop Maintenance" class = "MonoDevelop.Ide.Gui.OptionPanels.MaintenanceOptionsPanel" icon="md-prefs-maintenance" /> </Condition> + <Condition id="Platform" value="mac"> + <Section id = "Accessibility" _label = "Accessibility" class = "MonoDevelop.Ide.Gui.OptionPanels.D152AccessibilityPanel" fill="true" /> + </Condition> </Section> </Extension> </ExtensionModel> diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs index 3f685d732b..583cc8eec5 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components/IdeTheme.cs @@ -67,15 +67,23 @@ namespace MonoDevelop.Components if (!Platform.IsLinux) UpdateGtkTheme (); - if (Platform.IsMac) { +#if MAC + // Early init Cocoa through xwt + var path = Path.GetDirectoryName (typeof (IdeTheme).Assembly.Location); + System.Reflection.Assembly.LoadFrom (Path.Combine (path, "Xwt.XamMac.dll")); + var loaded = Xwt.Toolkit.Load (Xwt.ToolkitType.XamMac); + + if (Platform.IsMac && NSUserDefaults.StandardUserDefaults.BoolForKey ("com.monodevelop.AccessibilityEnabled")) { // Load a private version of AtkCocoa stored in the XS app directory var appDir = Directory.GetParent (AppDomain.CurrentDomain.BaseDirectory); var gtkPath = $"{appDir.Parent.FullName}/lib/gtk-2.0"; LoggingService.LogInfo ($"Loading modules from {gtkPath}"); Environment.SetEnvironmentVariable ("GTK_MODULES", $"{gtkPath}/libatkcocoa.so"); + } else { + LoggingService.LogInfo ("Accessibility disabled"); } - +#endif Gtk.Application.Init (BrandingService.ApplicationName, ref args); // Reset our environment after initialization on Mac diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/D152AccessibilityPanel.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/D152AccessibilityPanel.cs new file mode 100644 index 0000000000..4b1a784029 --- /dev/null +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.OptionPanels/D152AccessibilityPanel.cs @@ -0,0 +1,135 @@ +// +// D152AccessibilityPanel.cs +// +// Author: +// iain <> +// +// Copyright (c) 2017 +// +// 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. + +#if MAC +using System; +using MonoDevelop.Components; +using MonoDevelop.Projects; +using MonoDevelop.Ide.Projects; +using MonoDevelop.Ide.Gui.Dialogs; +using MonoDevelop.Core; + +using Gtk; + +using Foundation; + +namespace MonoDevelop.Ide.Gui.OptionPanels +{ + public class D152AccessibilityPanel : OptionsPanel + { + D152AccessibilityPanelWidget widget; + + public override Control CreatePanelWidget () + { + return widget = new D152AccessibilityPanelWidget (); + } + + public override void ApplyChanges () + { + widget.Save (); + } + } + + class D152AccessibilityPanelWidget : VBox + { + bool originalSetting; + CheckButton enabled; + + HSeparator separatorRestart; + Table tableRestart; + Button btnRestart; + ImageView imageRestart; + Label labelRestart; + + static string EnabledKey = "com.monodevelop.AccessibilityEnabled"; + + public D152AccessibilityPanelWidget () : base (false, 6) + { + NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; + + enabled = new CheckButton ("Enable Accessibility"); + enabled.Active = originalSetting = defaults.BoolForKey (EnabledKey); + enabled.Visible = true; + + enabled.Toggled += ShowQuitOption; + PackStart (enabled, false, false, 0); + + separatorRestart = new HSeparator (); + PackStart (this.separatorRestart, false, false, 0); + + tableRestart = new Table (2, 3, false); + tableRestart.RowSpacing = 6; + tableRestart.ColumnSpacing = 6; + + btnRestart = new Button (); + btnRestart.CanFocus = true; + btnRestart.UseUnderline = true; + btnRestart.Clicked += RestartClicked; + + tableRestart.Attach (btnRestart, 1, 2, 1, 2, AttachOptions.Fill, AttachOptions.Fill, 0, 0); + + imageRestart = new global::MonoDevelop.Components.ImageView (); + imageRestart.IconId = "md-information"; + imageRestart.IconSize = ((global::Gtk.IconSize)(1)); + + tableRestart.Attach (imageRestart, 0, 1, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0); + labelRestart = new global::Gtk.Label (); + tableRestart.Attach (labelRestart, 1, 3, 0, 1, AttachOptions.Fill, AttachOptions.Fill, 0, 0); + + PackStart (tableRestart, false, false, 0); + + labelRestart.LabelProp = GettextCatalog.GetString ("These preferences will take effect next time you start {0}", BrandingService.ApplicationName); + btnRestart.Label = GettextCatalog.GetString ("Restart {0}", BrandingService.ApplicationName); + + Visible = true; + } + + public void Save () + { + NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults; + defaults.SetBool (enabled.Active, EnabledKey); + } + + void ShowQuitOption (object sender, EventArgs args) + { + if (enabled.Active != originalSetting) { + tableRestart.ShowAll (); + separatorRestart.Show (); + } else { + tableRestart.Hide (); + separatorRestart.Hide (); + } + } + + void RestartClicked (object sender, System.EventArgs e) + { + Save (); + IdeApp.Restart (true); + } + } +} + +#endif diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj index 46070369fe..0f0b3d528b 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.csproj @@ -9437,6 +9437,7 @@ <Compile Include="MonoDevelop.Ide.Editor.Highlighting\RoslynClassificationHighlighting.cs" /> <Compile Include="MonoDevelop.Ide.Projects\LanguageCellRenderer.cs" /> <Compile Include="MonoDevelop.Components\RestartPanel.cs" /> + <Compile Include="MonoDevelop.Ide.Gui.OptionPanels\D152AccessibilityPanel.cs" /> </ItemGroup> <ItemGroup> <None Include="Makefile.am" /> |