diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2020-01-06 12:31:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-06 12:31:19 +0300 |
commit | e4e08f821ad5f75d9177f03dfe4b7a1e5df7f346 (patch) | |
tree | 2655c1b012fbcb076ee22b2fa2e11eea36d522f1 /main/src | |
parent | 8857b5200ad471c61f0975d1ceeca6eb40ec0eea (diff) | |
parent | 7f33c08e5ae480f0562fc070b45b816710579505 (diff) |
Merge pull request #9416 from mono/fix/947006-project-created-announce
[947006][NewProjectController] added announcement of project creation status
Diffstat (limited to 'main/src')
6 files changed, 49 insertions, 33 deletions
diff --git a/main/src/addins/MacPlatform/MacPlatform.cs b/main/src/addins/MacPlatform/MacPlatform.cs index 656634f242..0f79d87179 100644 --- a/main/src/addins/MacPlatform/MacPlatform.cs +++ b/main/src/addins/MacPlatform/MacPlatform.cs @@ -418,6 +418,14 @@ namespace MonoDevelop.MacIntegration } } + internal override void MakeAccessibilityAnnouncement (string text) + { + using var message = new NSString (text); + using var dictionary = new NSDictionary (NSAccessibilityNotificationUserInfoKeys.AnnouncementKey, message, + NSAccessibilityNotificationUserInfoKeys.PriorityKey, NSAccessibilityPriorityLevel.High); + NSAccessibility.PostNotification (NSApplication.SharedApplication.AccessibilityMainWindow, NSAccessibilityNotifications.AnnouncementRequestedNotification, dictionary); + } + protected override string OnGetMimeTypeForUri (string uri) { var ext = Path.GetExtension (uri); diff --git a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs index 1780680d9b..bbc28308a2 100644 --- a/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs +++ b/main/src/addins/MacPlatform/MainToolbar/StatusBar.cs @@ -931,20 +931,12 @@ namespace MonoDevelop.MacIntegration.MainToolbar if (changed) { ReconstructString (); // announce new status if vo/a11y is enabled - if (MonoDevelop.Ide.Desktop.PlatformService.AccessibilityInUse) { - MakeAccessibilityAnnouncement (text); + if (IdeServices.DesktopService.AccessibilityInUse) { + IdeServices.DesktopService.MakeAccessibilityAnnouncement (text); } } } - static void MakeAccessibilityAnnouncement (string text) - { - using var message = new NSString (text); - using var dictionary = new NSDictionary (NSAccessibilityNotificationUserInfoKeys.AnnouncementKey, message, - NSAccessibilityNotificationUserInfoKeys.PriorityKey, NSAccessibilityPriorityLevel.High); - NSAccessibility.PostNotification (NSApplication.SharedApplication.AccessibilityMainWindow, NSAccessibilityNotifications.AnnouncementRequestedNotification, dictionary); - } - bool LoadText (string message, bool isMarkup, MessageType statusType) { message = message ?? ""; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs index 2ecb25f055..47c7c983c9 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Desktop/PlatformService.cs @@ -513,6 +513,8 @@ namespace MonoDevelop.Ide.Desktop public static bool AccessibilityKeyboardFocusInUse { get; protected set; } + internal virtual void MakeAccessibilityAnnouncement (string text) { } + internal virtual string GetNativeRuntimeDescription () { return null; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/GtkNewProjectDialogBackend.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/GtkNewProjectDialogBackend.cs index 33c9d388a1..b4fa2f72b7 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/GtkNewProjectDialogBackend.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/GtkNewProjectDialogBackend.cs @@ -78,23 +78,7 @@ namespace MonoDevelop.Ide.Projects actionHandler.PerformShowMenu += PerformShowMenu;
} - void ProjectCreationFailed (object obj, EventArgs args) => ShowProjectCreationAccessibityNotification (true);
- void ProjectCreated(object obj, EventArgs args) => ShowProjectCreationAccessibityNotification (false);
async void NextButtonClicked (object sender, EventArgs e) => await MoveToNextPage ();
-
- void ShowProjectCreationAccessibityNotification (bool hasError)
- {
- var projectTemplate = controller.SelectedTemplate;
-
- string messageText; -
- if (hasError) - messageText = GettextCatalog.GetString ("{0} failed to create", projectTemplate.Name); - else - messageText = GettextCatalog.GetString ("{0} successfully created", projectTemplate.Name);
-
- this.Accessible.MakeAccessibilityAnnouncement (messageText); - }
public void ShowDialog ()
{
@@ -114,8 +98,6 @@ namespace MonoDevelop.Ide.Projects public void RegisterController (INewProjectDialogController controller)
{
this.controller = controller;
- controller.ProjectCreationFailed += ProjectCreationFailed;
- controller.ProjectCreated += ProjectCreated;
languageCellRenderer.SelectedLanguage = controller.SelectedLanguage;
topBannerLabel.Text = controller.BannerText;
LoadTemplates ();
@@ -299,9 +281,6 @@ namespace MonoDevelop.Ide.Projects if (!controller.IsLastPage)
projectConfigurationWidget.Destroy ();
- controller.ProjectCreationFailed -= ProjectCreationFailed;
- controller.ProjectCreated -= ProjectCreated;
-
base.OnDestroyed ();
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs index 455929c782..41705740a0 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Projects/NewProjectController.cs @@ -613,6 +613,8 @@ namespace MonoDevelop.Ide.Projects public async Task Create ()
{
+ Runtime.AssertMainThread (); + OnProjectCreating (); projectCreated = new TaskCompletionSource<bool> ();
if (wizardProvider.HasWizard)
@@ -620,7 +622,7 @@ namespace MonoDevelop.Ide.Projects if (!await CreateProject ()) { projectCreated.SetResult (false);
- ProjectCreationFailed?.Invoke (this, EventArgs.Empty);
+ OnProjectCreationFailed (); return;
}
@@ -714,13 +716,41 @@ namespace MonoDevelop.Ide.Projects UpdateDefaultSettings (); projectCreated.SetResult (true); - await Runtime.RunInMainThread (() => ProjectCreated?.Invoke (this, EventArgs.Empty)); + OnProjectCreated (); } catch (Exception ex) { projectCreated.SetException (ex); throw; }
} + void OnProjectCreating () + { + if (IdeServices.DesktopService.AccessibilityInUse) { + var announcement = GettextCatalog.GetString ("Creating project {0}", SelectedTemplate.Name); + IdeServices.DesktopService.MakeAccessibilityAnnouncement (announcement); + } + } + + void OnProjectCreationFailed () + { + ProjectCreationFailed?.Invoke (this, EventArgs.Empty); + + if (IdeServices.DesktopService.AccessibilityInUse) { + var announcement = GettextCatalog.GetString ("{0} failed to create", SelectedTemplate.Name); + IdeServices.DesktopService.MakeAccessibilityAnnouncement (announcement); + } + } + + void OnProjectCreated () + { + ProjectCreated?.Invoke (this, EventArgs.Empty); + + if (IdeServices.DesktopService.AccessibilityInUse) { + var announcement = GettextCatalog.GetString ("{0} successfully created", SelectedTemplate.Name); + IdeServices.DesktopService.MakeAccessibilityAnnouncement (announcement); + } + } + public Task<bool> ProjectCreation => projectCreated?.Task; TaskCompletionSource<bool> projectCreated;
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs index 37c4cd60c9..a44b14be25 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide/DesktopService.cs @@ -447,6 +447,11 @@ namespace MonoDevelop.Ide PlatformService.RestartIde (reopenWorkspace); } + public void MakeAccessibilityAnnouncement(string text) + { + PlatformService.MakeAccessibilityAnnouncement (text); + } + public bool AccessibilityInUse { get { return PlatformService.AccessibilityInUse; |