[vlc-commits] macosx: modernize API use for sheet dialogs

Felix Paul Kühne git at videolan.org
Sat Jun 9 18:53:15 CEST 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Jun  9 18:39:11 2018 +0200| [aef351f054a520e812d929293494d27ff1a2de21] | committer: Felix Paul Kühne

macosx: modernize API use for sheet dialogs

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=aef351f054a520e812d929293494d27ff1a2de21
---

 modules/gui/macosx/VLCAudioEffectsWindowController.m   |  5 +----
 modules/gui/macosx/VLCBookmarksWindowController.m      | 14 ++++++++++++--
 modules/gui/macosx/VLCConvertAndSaveWindowController.m | 11 +++++++----
 modules/gui/macosx/VLCCoreDialogProvider.m             | 17 +++++++++--------
 modules/gui/macosx/VLCMainWindow.m                     |  9 +++++++--
 modules/gui/macosx/VLCOpenWindowController.m           |  6 +-----
 modules/gui/macosx/VLCVideoEffectsWindowController.m   |  5 +----
 7 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/modules/gui/macosx/VLCAudioEffectsWindowController.m b/modules/gui/macosx/VLCAudioEffectsWindowController.m
index be46755158..a1ad903aa1 100644
--- a/modules/gui/macosx/VLCAudioEffectsWindowController.m
+++ b/modules/gui/macosx/VLCAudioEffectsWindowController.m
@@ -531,11 +531,8 @@
             [alert setAlertStyle:NSCriticalAlertStyle];
             [alert setMessageText:_NS("Please enter a unique name for the new profile.")];
             [alert setInformativeText:_NS("Multiple profiles with the same name are not allowed.")];
-
             [alert beginSheetModalForWindow:_self.window
-                              modalDelegate:nil
-                             didEndSelector:nil
-                                contextInfo:nil];
+                          completionHandler:nil];
             return;
         }
 
diff --git a/modules/gui/macosx/VLCBookmarksWindowController.m b/modules/gui/macosx/VLCBookmarksWindowController.m
index 8035cbbe4f..ff2229860a 100644
--- a/modules/gui/macosx/VLCBookmarksWindowController.m
+++ b/modules/gui/macosx/VLCBookmarksWindowController.m
@@ -208,11 +208,21 @@
     input_thread_t * p_input = pl_CurrentInput(getIntf());
 
     if (!p_input) {
-        NSBeginCriticalAlertSheet(_NS("No input"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("No input found. A stream must be playing or paused for bookmarks to work."));
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert setAlertStyle:NSCriticalAlertStyle];
+        [alert setMessageText:_NS("No input")];
+        [alert setInformativeText:_NS("No input found. A stream must be playing or paused for bookmarks to work.")];
+        [alert beginSheetModalForWindow:self.window
+                      completionHandler:nil];
         return;
     }
     if (p_old_input != p_input) {
-        NSBeginCriticalAlertSheet(_NS("Input has changed"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("Input has changed, unable to save bookmark. Suspending playback with \"Pause\" while editing bookmarks to ensure to keep the same input."));
+        NSAlert *alert = [[NSAlert alloc] init];
+        [alert setAlertStyle:NSCriticalAlertStyle];
+        [alert setMessageText:_NS("Input has changed")];
+        [alert setInformativeText:_NS("Input has changed, unable to save bookmark. Suspending playback with \"Pause\" while editing bookmarks to ensure to keep the same input.")];
+        [alert beginSheetModalForWindow:self.window
+                      completionHandler:nil];
         vlc_object_release(p_input);
         return;
     }
diff --git a/modules/gui/macosx/VLCConvertAndSaveWindowController.m b/modules/gui/macosx/VLCConvertAndSaveWindowController.m
index b0efac7584..1389ac8b99 100644
--- a/modules/gui/macosx/VLCConvertAndSaveWindowController.m
+++ b/modules/gui/macosx/VLCConvertAndSaveWindowController.m
@@ -267,10 +267,13 @@
         if ([[[_streamTypePopup selectedItem] title] isEqualToString:@"HTTP"]) {
             NSString *muxformat = [self.currentProfile firstObject];
             if ([muxformat isEqualToString:@"wav"] || [muxformat isEqualToString:@"mov"] || [muxformat isEqualToString:@"mp4"] || [muxformat isEqualToString:@"mkv"]) {
-                NSBeginInformationalAlertSheet(_NS("Invalid container format for HTTP streaming"), _NS("OK"), @"", @"", self.window,
-                                               nil, nil, nil, nil,
-                                               _NS("Media encapsulated as %@ cannot be streamed through the HTTP protocol for technical reasons."),
-                                               [[self currentEncapsulationFormatAsFileExtension:YES] uppercaseString]);
+                NSAlert *alert = [[NSAlert alloc] init];
+                [alert setAlertStyle:NSInformationalAlertStyle];
+                [alert setMessageText:_NS("Invalid container format for HTTP streaming")];
+                [alert setInformativeText:[NSString stringWithFormat:_NS("Media encapsulated as %@ cannot be streamed through the HTTP protocol for technical reasons."),
+                                           [[self currentEncapsulationFormatAsFileExtension:YES] uppercaseString]]];
+                [alert beginSheetModalForWindow:self.window
+                              completionHandler:nil];
                 return;
             }
         }
diff --git a/modules/gui/macosx/VLCCoreDialogProvider.m b/modules/gui/macosx/VLCCoreDialogProvider.m
index edc9e92091..990402cc25 100644
--- a/modules/gui/macosx/VLCCoreDialogProvider.m
+++ b/modules/gui/macosx/VLCCoreDialogProvider.m
@@ -241,11 +241,12 @@ static void updateProgressCallback(void *p_data,
 
 - (void)displayQuestion:(NSArray *)dialogData
 {
-    NSAlert *alert = [NSAlert alertWithMessageText:[dialogData objectAtIndex:1]
-                                     defaultButton:[dialogData objectAtIndex:5]
-                                   alternateButton:[dialogData objectAtIndex:6]
-                                       otherButton:[dialogData objectAtIndex:4]
-                         informativeTextWithFormat:@"%@", [dialogData objectAtIndex:2]];
+    NSAlert *alert = [[NSAlert alloc] init];
+    [alert setMessageText:[dialogData objectAtIndex:1]];
+    [alert setInformativeText:[dialogData objectAtIndex:2]];
+    [alert addButtonWithTitle:[dialogData objectAtIndex:5]];
+    [alert addButtonWithTitle:[dialogData objectAtIndex:6]];
+    [alert addButtonWithTitle:[dialogData objectAtIndex:4]];
 
     switch ([[dialogData objectAtIndex:3] intValue]) {
         case VLC_DIALOG_QUESTION_WARNING:
@@ -261,15 +262,15 @@ static void updateProgressCallback(void *p_data,
 
     NSInteger returnValue = [alert runModal];
     switch (returnValue) {
-        case NSAlertDefaultReturn:
+        case NSAlertFirstButtonReturn:
             vlc_dialog_id_post_action([[dialogData objectAtIndex:0] pointerValue], 1);
             break;
 
-        case NSAlertAlternateReturn:
+        case NSAlertSecondButtonReturn:
             vlc_dialog_id_post_action([[dialogData objectAtIndex:0] pointerValue], 2);
             break;
 
-        case NSAlertOtherReturn:
+        case NSAlertThirdButtonReturn:
         default:
             vlc_dialog_id_dismiss([[dialogData objectAtIndex:0] pointerValue]);
     }
diff --git a/modules/gui/macosx/VLCMainWindow.m b/modules/gui/macosx/VLCMainWindow.m
index b181271267..1cc9bcb8d6 100644
--- a/modules/gui/macosx/VLCMainWindow.m
+++ b/modules/gui/macosx/VLCMainWindow.m
@@ -224,9 +224,14 @@ static const float f_min_window_height = 307.;
 
         [_sidebarView expandItem:nil expandChildren:YES];
 
-        NSAlert *albumArtAlert = [NSAlert alertWithMessageText:_NS("Check for album art and metadata?") defaultButton:_NS("Enable Metadata Retrieval") alternateButton:_NS("No, Thanks") otherButton:nil informativeTextWithFormat:@"%@",_NS("VLC can check online for album art and metadata to enrich your playback experience, e.g. by providing track information when playing Audio CDs. To provide this functionality, VLC will send information about your contents to trusted services in an anonymized form.")];
+        NSAlert *albumArtAlert = [[NSAlert alloc] init];
+        [albumArtAlert setMessageText:_NS("Check for album art and metadata?")];
+        [albumArtAlert setInformativeText:_NS("VLC can check online for album art and metadata to enrich your playback experience, e.g. by providing track information when playing Audio CDs. To provide this functionality, VLC will send information about your contents to trusted services in an anonymized form.")];
+        [albumArtAlert addButtonWithTitle:_NS("Enable Metadata Retrieval")];
+        [albumArtAlert addButtonWithTitle:_NS("No, Thanks")];
+
         NSInteger returnValue = [albumArtAlert runModal];
-        config_PutInt("metadata-network-access", returnValue == NSAlertDefaultReturn);
+        config_PutInt("metadata-network-access", returnValue == NSAlertFirstButtonReturn);
     }
 
     [_playlistScrollView setBorderType:NSNoBorder];
diff --git a/modules/gui/macosx/VLCOpenWindowController.m b/modules/gui/macosx/VLCOpenWindowController.m
index 570fce8212..584f448046 100644
--- a/modules/gui/macosx/VLCOpenWindowController.m
+++ b/modules/gui/macosx/VLCOpenWindowController.m
@@ -613,11 +613,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     if (!b_outputNibLoaded)
         b_outputNibLoaded = [NSBundle loadNibNamed:@"StreamOutput" owner:_output];
 
-    [NSApp beginSheet:_output.outputSheet
-       modalForWindow:self.window
-        modalDelegate:self
-       didEndSelector:NULL
-          contextInfo:nil];
+    [self.window beginSheet:_output.outputSheet completionHandler:nil];
 }
 
 #pragma mark -
diff --git a/modules/gui/macosx/VLCVideoEffectsWindowController.m b/modules/gui/macosx/VLCVideoEffectsWindowController.m
index 886302afd7..c7f7a368c5 100644
--- a/modules/gui/macosx/VLCVideoEffectsWindowController.m
+++ b/modules/gui/macosx/VLCVideoEffectsWindowController.m
@@ -809,11 +809,8 @@
             [alert setAlertStyle:NSCriticalAlertStyle];
             [alert setMessageText:_NS("Please enter a unique name for the new profile.")];
             [alert setInformativeText:_NS("Multiple profiles with the same name are not allowed.")];
-
             [alert beginSheetModalForWindow:_self.window
-                              modalDelegate:nil
-                             didEndSelector:nil
-                                contextInfo:nil];
+                          completionHandler:nil];
             return;
         }
 



More information about the vlc-commits mailing list