macosx: rename coredialogs.x to VLCCoreDialogProvider.x
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 8 Aug 2016 13:52:13 +0000 (15:52 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Mon, 8 Aug 2016 16:47:29 +0000 (18:47 +0200)
extras/package/macosx/vlc.xcodeproj/project.pbxproj
modules/gui/macosx/ExtensionsDialogProvider.h
modules/gui/macosx/Makefile.am
modules/gui/macosx/VLCCoreDialogProvider.h [new file with mode: 0644]
modules/gui/macosx/VLCCoreDialogProvider.m [new file with mode: 0644]
modules/gui/macosx/coredialogs.h [deleted file]
modules/gui/macosx/coredialogs.m [deleted file]
modules/gui/macosx/intf.m

index 06ad34d..2db936c 100644 (file)
                1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */ = {isa = PBXBuildFile; fileRef = E0382C01160BA09E0031D7FF /* ControlsBar.m */; };
                1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */ = {isa = PBXBuildFile; fileRef = CC0663341566C34C003A411C /* ConvertAndSave.h */; };
                1CCB5F631A62A724004C3E90 /* ConvertAndSave.m in Sources */ = {isa = PBXBuildFile; fileRef = CC0663351566C34C003A411C /* ConvertAndSave.m */; };
-               1CCB5F641A62A724004C3E90 /* coredialogs.h in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33220F8CB017000FC4A7 /* coredialogs.h */; };
-               1CCB5F651A62A724004C3E90 /* coredialogs.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33210F8CB017000FC4A7 /* coredialogs.m */; };
+               1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */; };
+               1CCB5F651A62A724004C3E90 /* VLCCoreDialogProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */; };
                1CCB5F661A62A724004C3E90 /* CoreInteraction.h in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6013B68A0B009F72E0 /* CoreInteraction.h */; };
                1CCB5F671A62A724004C3E90 /* CoreInteraction.m in Sources */ = {isa = PBXBuildFile; fileRef = CC448A6113B68A0B009F72E0 /* CoreInteraction.m */; };
                1CCB5F681A62A724004C3E90 /* DebugMessageVisualizer.h in Sources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */; };
                CC448A6313B68A0B009F72E0 /* MainWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainWindow.m; path = ../../../modules/gui/macosx/MainWindow.m; sourceTree = SOURCE_ROOT; };
                CC461F6C160078340022423C /* SharedDialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = SharedDialogs.h; path = ../../../modules/gui/macosx/SharedDialogs.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
                CC461F6D160078340022423C /* SharedDialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharedDialogs.m; path = ../../../modules/gui/macosx/SharedDialogs.m; sourceTree = SOURCE_ROOT; };
-               CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
-               CC4A33220F8CB017000FC4A7 /* coredialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coredialogs.h; path = ../../../modules/gui/macosx/coredialogs.h; sourceTree = SOURCE_ROOT; };
+               CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCCoreDialogProvider.m; path = ../../../modules/gui/macosx/VLCCoreDialogProvider.m; sourceTree = SOURCE_ROOT; };
+               CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCCoreDialogProvider.h; path = ../../../modules/gui/macosx/VLCCoreDialogProvider.h; sourceTree = SOURCE_ROOT; };
                CC4D67F71348F601003FCC5B /* specific.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = specific.c; path = ../../../src/darwin/specific.c; sourceTree = "<group>"; };
                CC4EFC2C13E96BD00091D19A /* dropzone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dropzone.png; path = Resources/mainwindow/dropzone.png; sourceTree = "<group>"; };
                CC5560231365CDC700D54038 /* AudioEffects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AudioEffects.h; path = ../../../modules/gui/macosx/AudioEffects.h; sourceTree = SOURCE_ROOT; };
                                E0382C01160BA09E0031D7FF /* ControlsBar.m */,
                                CC0663341566C34C003A411C /* ConvertAndSave.h */,
                                CC0663351566C34C003A411C /* ConvertAndSave.m */,
-                               CC4A33220F8CB017000FC4A7 /* coredialogs.h */,
-                               CC4A33210F8CB017000FC4A7 /* coredialogs.m */,
+                               CC4A33220F8CB017000FC4A7 /* VLCCoreDialogProvider.h */,
+                               CC4A33210F8CB017000FC4A7 /* VLCCoreDialogProvider.m */,
                                CC448A6013B68A0B009F72E0 /* CoreInteraction.h */,
                                CC448A6113B68A0B009F72E0 /* CoreInteraction.m */,
                                7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */,
                                1CCB5F611A62A724004C3E90 /* ControlsBar.m in Sources */,
                                1CCB5F621A62A724004C3E90 /* ConvertAndSave.h in Sources */,
                                1CCB5F631A62A724004C3E90 /* ConvertAndSave.m in Sources */,
-                               1CCB5F641A62A724004C3E90 /* coredialogs.h in Sources */,
-                               1CCB5F651A62A724004C3E90 /* coredialogs.m in Sources */,
+                               1CCB5F641A62A724004C3E90 /* VLCCoreDialogProvider.h in Sources */,
+                               1CCB5F651A62A724004C3E90 /* VLCCoreDialogProvider.m in Sources */,
                                1CCB5F661A62A724004C3E90 /* CoreInteraction.h in Sources */,
                                6BBBB8AA1D108A17001BD9BA /* VLCRendererDialog.m in Sources */,
                                1CCB5F671A62A724004C3E90 /* CoreInteraction.m in Sources */,
index 987a1b3..ac72faf 100644 (file)
@@ -23,7 +23,6 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#import "coredialogs.h"
 #import "intf.h"
 #import "VLCUIWidgets.h"
 
index 231656e..0cd8123 100644 (file)
@@ -32,7 +32,6 @@ libmacosx_plugin_la_SOURCES = \
        CompatibilityFixes.h \
        ControlsBar.m ControlsBar.h \
        ConvertAndSave.h ConvertAndSave.m \
-       coredialogs.h coredialogs.m \
        CoreInteraction.h CoreInteraction.m \
        DebugMessageVisualizer.h DebugMessageVisualizer.m \
        ExtensionsDialogProvider.h ExtensionsDialogProvider.m \
@@ -78,6 +77,7 @@ libmacosx_plugin_la_SOURCES = \
        VLCStatusBarIcon.h VLCStatusBarIcon.m \
        VLCVoutWindowController.h VLCVoutWindowController.m \
        Windows.h Windows.m \
+       VLCCoreDialogProvider.h VLCCoreDialogProvider.m \
        VLCHUDSliderCell.h VLCHUDSliderCell.m \
        VLCHUDButtonCell.h VLCHUDButtonCell.m \
        VLCHUDCheckboxCell.h VLCHUDCheckboxCell.m \
diff --git a/modules/gui/macosx/VLCCoreDialogProvider.h b/modules/gui/macosx/VLCCoreDialogProvider.h
new file mode 100644 (file)
index 0000000..d074c08
--- /dev/null
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * VLCCoreDialogProvider.h: Mac OS X Core Dialogs
+ *****************************************************************************
+ * Copyright (C) 2005-2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Derk-Jan Hartman <hartman at videolan dot org>
+ *          Felix Paul Kühne <fkuehne at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import <vlc_common.h>
+#import <vlc_dialog.h>
+#import <Cocoa/Cocoa.h>
+
+/*****************************************************************************
+ * VLCCoreDialogProvider interface
+ *****************************************************************************/
+
+@interface VLCCoreDialogProvider : NSObject
+{
+    /* authentication dialog */
+    IBOutlet NSButton *authenticationCancelButton;
+    IBOutlet NSTextField *authenticationDescriptionLabel;
+    IBOutlet NSTextField *authenticationLoginTextField;
+    IBOutlet NSTextField *authenticationLoginLabel;
+    IBOutlet NSButton *authenticationOkButton;
+    IBOutlet NSTextField *authenticationPasswordTextField;
+    IBOutlet NSTextField *authenticationPasswordLabel;
+    IBOutlet NSTextField *authenticationTitleLabel;
+    IBOutlet NSButton *authenticationStorePasswordCheckbox;
+    IBOutlet NSWindow *authenticationWindow;
+
+    /* progress dialog */
+    IBOutlet NSProgressIndicator *progressIndicator;
+    IBOutlet NSButton *progressCancelButton;
+    IBOutlet NSTextField *progressDescriptionLabel;
+    IBOutlet NSTextField *progressTitleLabel;
+    IBOutlet NSWindow *progressWindow;
+}
+
+@property (atomic,readwrite) BOOL progressCancelled;
+
+- (IBAction)authenticationDialogAction:(id)sender;
+
+- (IBAction)progressDialogAction:(id)sender;
+
+@end
diff --git a/modules/gui/macosx/VLCCoreDialogProvider.m b/modules/gui/macosx/VLCCoreDialogProvider.m
new file mode 100644 (file)
index 0000000..0e59290
--- /dev/null
@@ -0,0 +1,318 @@
+/*****************************************************************************
+ * VLCCoreDialogProvider.m: Mac OS X Core Dialogs
+ *****************************************************************************
+ * Copyright (C) 2005-2016 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Derk-Jan Hartman <hartman at videolan dot org>
+ *          Felix Paul Kühne <fkuehne at videolan dot org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "intf.h"
+#import "VLCCoreDialogProvider.h"
+#import "misc.h"
+
+/* for the icon in our custom error panel */
+#import <ApplicationServices/ApplicationServices.h>
+
+@interface VLCCoreDialogProvider ()
+
+- (void)displayError:(NSArray *)dialogData;
+
+- (void)displayLoginDialog:(NSArray *)dialogData;
+
+- (void)displayQuestion:(NSArray *)dialogData;
+
+- (void)displayProgressDialog:(NSArray *)dialogData;
+
+- (void)updateDisplayedProgressDialog:(NSArray *)dialogData;
+
+@end
+
+
+static void displayErrorCallback(void *p_data,
+                                 const char *psz_title,
+                                 const char *psz_text)
+{
+    @autoreleasepool {
+        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
+        [dialogProvider performSelectorOnMainThread:@selector(displayError:)
+                                         withObject:@[toNSStr(psz_title),
+                                                      toNSStr(psz_text)]
+                                      waitUntilDone:NO];
+    }
+}
+
+static void displayLoginCallback(void *p_data,
+                                 vlc_dialog_id *p_id,
+                                 const char *psz_title,
+                                 const char *psz_text,
+                                 const char *psz_default_username,
+                                 bool b_ask_store)
+{
+    @autoreleasepool {
+        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
+        [dialogProvider performSelectorOnMainThread:@selector(displayLoginDialog:)
+                                         withObject:@[[NSValue valueWithPointer:p_id],
+                                                      toNSStr(psz_title),
+                                                      toNSStr(psz_text),
+                                                      toNSStr(psz_default_username),
+                                                      @(b_ask_store)]
+                                      waitUntilDone:NO];
+    }
+}
+
+static void displayQuestionCallback(void *p_data,
+                                    vlc_dialog_id *p_id,
+                                    const char *psz_title,
+                                    const char *psz_text,
+                                    vlc_dialog_question_type i_type,
+                                    const char *psz_cancel,
+                                    const char *psz_action1,
+                                    const char *psz_action2)
+{
+    @autoreleasepool {
+        VLCCoreDialogProvider *dialogProvider = (__bridge  VLCCoreDialogProvider *)p_data;
+        [dialogProvider performSelectorOnMainThread:@selector(displayQuestion:)
+                                         withObject:@[[NSValue valueWithPointer:p_id],
+                                                      toNSStr(psz_title),
+                                                      toNSStr(psz_text),
+                                                      @(i_type),
+                                                      toNSStr(psz_cancel),
+                                                      toNSStr(psz_action1),
+                                                      toNSStr(psz_action2)]
+                                      waitUntilDone:NO];
+    }
+}
+
+static void displayProgressCallback(void *p_data,
+                                    vlc_dialog_id *p_id,
+                                    const char *psz_title,
+                                    const char *psz_text,
+                                    bool b_indeterminate,
+                                    float f_position,
+                                    const char *psz_cancel)
+{
+    @autoreleasepool {
+        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
+        [dialogProvider performSelectorOnMainThread:@selector(displayProgressDialog:)
+                                         withObject:@[[NSValue valueWithPointer:p_id],
+                                                      toNSStr(psz_title),
+                                                      toNSStr(psz_text),
+                                                      @(b_indeterminate),
+                                                      @(f_position),
+                                                      toNSStr(psz_cancel)]
+                                      waitUntilDone:NO];
+    }
+}
+
+static void cancelCallback(void *p_data,
+                           vlc_dialog_id *p_id)
+{
+    @autoreleasepool {
+        [NSApp stopModalWithCode: 0];
+    }
+}
+
+static void updateProgressCallback(void *p_data,
+                                   vlc_dialog_id *p_id,
+                                   float f_value,
+                                   const char *psz_text)
+{
+    @autoreleasepool {
+        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
+        [dialogProvider performSelectorOnMainThread:@selector(updateDisplayedProgressDialog:)
+                                         withObject:@[[NSValue valueWithPointer:p_id],
+                                                      @(f_value),
+                                                      toNSStr(psz_text)]
+                                      waitUntilDone:NO];
+    }
+}
+
+@implementation VLCCoreDialogProvider
+
+- (instancetype)init
+{
+    self = [super init];
+
+    if (self) {
+        msg_Dbg(getIntf(), "Register dialog provider");
+        [NSBundle loadNibNamed:@"CoreDialogs" owner: self];
+
+        intf_thread_t *p_intf = getIntf();
+        /* subscribe to various interactive dialogues */
+
+        const vlc_dialog_cbs cbs = {
+            displayErrorCallback,
+            displayLoginCallback,
+            displayQuestionCallback,
+            displayProgressCallback,
+            cancelCallback,
+            updateProgressCallback
+        };
+
+        vlc_dialog_provider_set_callbacks(p_intf, &cbs, (__bridge void *)self);
+    }
+
+    return self;
+}
+
+- (void)dealloc
+{
+    msg_Dbg(getIntf(), "Deinitializing dialog provider");
+
+    intf_thread_t *p_intf = getIntf();
+    vlc_dialog_provider_set_callbacks(p_intf, NULL, NULL);
+}
+
+-(void)awakeFromNib
+{
+    _progressCancelled = NO;
+    [authenticationLoginLabel setStringValue: _NS("Username")];
+    [authenticationPasswordLabel setStringValue: _NS("Password")];
+    [authenticationCancelButton setTitle: _NS("Cancel")];
+    [authenticationOkButton setTitle: _NS("OK")];
+    [authenticationStorePasswordCheckbox setTitle:_NS("Remember")];
+
+    [progressCancelButton setTitle: _NS("Cancel")];
+    [progressIndicator setUsesThreadedAnimation: YES];
+}
+
+- (void)displayError:(NSArray *)dialogData
+{
+    NSAlert *alert = [NSAlert alertWithMessageText:dialogData[0]
+                                     defaultButton:_NS("OK")
+                                   alternateButton:nil
+                                       otherButton:nil
+                         informativeTextWithFormat:@"%@", dialogData[1]];
+    [alert setAlertStyle:NSCriticalAlertStyle];
+    [alert runModal];
+}
+
+- (void)displayLoginDialog:(NSArray *)dialogData
+{
+    [authenticationTitleLabel setStringValue:dialogData[1]];
+    authenticationWindow.title = dialogData[1];
+    [authenticationDescriptionLabel setStringValue:dialogData[2]];
+
+    [authenticationLoginTextField setStringValue:dialogData[3]];
+    [authenticationPasswordTextField setStringValue:@""];
+
+    authenticationStorePasswordCheckbox.hidden = ![dialogData[4] boolValue];
+    authenticationStorePasswordCheckbox.state = NSOffState;
+
+    [authenticationWindow center];
+    NSInteger returnValue = [NSApp runModalForWindow:authenticationWindow];
+    [authenticationWindow close];
+
+    NSString *username = authenticationLoginTextField.stringValue;
+    NSString *password = authenticationPasswordTextField.stringValue;
+
+    vlc_dialog_id_post_login([dialogData[0] pointerValue],
+                             username ? [username UTF8String] : NULL,
+                             password ? [password UTF8String] : NULL,
+                             authenticationStorePasswordCheckbox.state == NSOnState);
+}
+
+- (IBAction)authenticationDialogAction:(id)sender
+{
+    if ([[sender title] isEqualToString: _NS("OK")])
+        [NSApp stopModalWithCode: 1];
+    else
+        [NSApp stopModalWithCode: 0];
+}
+
+- (void)displayQuestion:(NSArray *)dialogData
+{
+    NSAlert *alert = [NSAlert alertWithMessageText:dialogData[1]
+                                     defaultButton:dialogData[5]
+                                   alternateButton:dialogData[6]
+                                       otherButton:dialogData[4]
+                         informativeTextWithFormat:@"%@", dialogData[2]];
+
+    switch ([dialogData[3] intValue]) {
+        case VLC_DIALOG_QUESTION_WARNING:
+            [alert setAlertStyle:NSWarningAlertStyle];
+            break;
+        case VLC_DIALOG_QUESTION_CRITICAL:
+            [alert setAlertStyle:NSCriticalAlertStyle];
+            break;
+        default:
+            [alert setAlertStyle:NSInformationalAlertStyle];
+            break;
+    }
+
+    NSInteger returnValue = [alert runModal];
+    switch (returnValue) {
+        case NSAlertAlternateReturn:
+            vlc_dialog_id_post_action([dialogData[0] pointerValue], 2);
+            break;
+
+        case NSAlertOtherReturn:
+            vlc_dialog_id_post_action([dialogData[0] pointerValue], 3);
+            break;
+
+        default:
+            vlc_dialog_id_post_action([dialogData[0] pointerValue], 1);
+            break;
+    }
+
+}
+
+- (void)displayProgressDialog:(NSArray *)dialogData
+{
+    progressTitleLabel.stringValue = dialogData[1];
+    progressWindow.title = dialogData[1];
+
+    progressDescriptionLabel.stringValue = dialogData[2];
+
+    progressIndicator.indeterminate = [dialogData[3] boolValue];
+    progressIndicator.doubleValue = [dialogData[4] doubleValue];
+
+    if ([dialogData[5] length] > 0) {
+        progressCancelButton.title = dialogData[5];
+    } else {
+        progressCancelButton.title = _NS("Cancel");
+    }
+
+    [progressIndicator startAnimation:self];
+
+    [progressWindow center];
+    NSInteger returnValue = [NSApp runModalForWindow:progressWindow];
+    [progressWindow close];
+
+    [progressIndicator stopAnimation:self];
+
+    if (returnValue == -1)
+        vlc_dialog_id_dismiss([dialogData[0] pointerValue]);
+}
+
+- (void)updateDisplayedProgressDialog:(NSArray *)dialogData
+
+{
+    if (!progressIndicator.indeterminate) {
+        progressIndicator.doubleValue = [dialogData[1] doubleValue];
+        progressDescriptionLabel.stringValue = dialogData[2];
+    }
+}
+
+- (IBAction)progressDialogAction:(id)sender
+{
+    [NSApp stopModalWithCode: -1];
+}
+
+@end
diff --git a/modules/gui/macosx/coredialogs.h b/modules/gui/macosx/coredialogs.h
deleted file mode 100644 (file)
index 6c9097f..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * coredialogs.h: Mac OS X Core Dialogs
- *****************************************************************************
- * Copyright (C) 2005-2016 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Derk-Jan Hartman <hartman at videolan dot org>
- *          Felix Paul Kühne <fkuehne at videolan dot org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#import <vlc_common.h>
-#import <vlc_dialog.h>
-#import <Cocoa/Cocoa.h>
-
-/*****************************************************************************
- * VLCCoreDialogProvider interface
- *****************************************************************************/
-
-@interface VLCCoreDialogProvider : NSObject
-{
-    /* authentication dialog */
-    IBOutlet NSButton *authenticationCancelButton;
-    IBOutlet NSTextField *authenticationDescriptionLabel;
-    IBOutlet NSTextField *authenticationLoginTextField;
-    IBOutlet NSTextField *authenticationLoginLabel;
-    IBOutlet NSButton *authenticationOkButton;
-    IBOutlet NSTextField *authenticationPasswordTextField;
-    IBOutlet NSTextField *authenticationPasswordLabel;
-    IBOutlet NSTextField *authenticationTitleLabel;
-    IBOutlet NSButton *authenticationStorePasswordCheckbox;
-    IBOutlet NSWindow *authenticationWindow;
-
-    /* progress dialog */
-    IBOutlet NSProgressIndicator *progressIndicator;
-    IBOutlet NSButton *progressCancelButton;
-    IBOutlet NSTextField *progressDescriptionLabel;
-    IBOutlet NSTextField *progressTitleLabel;
-    IBOutlet NSWindow *progressWindow;
-}
-
-@property (atomic,readwrite) BOOL progressCancelled;
-
-- (IBAction)authenticationDialogAction:(id)sender;
-
-- (IBAction)progressDialogAction:(id)sender;
-
-@end
diff --git a/modules/gui/macosx/coredialogs.m b/modules/gui/macosx/coredialogs.m
deleted file mode 100644 (file)
index e93dc99..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/*****************************************************************************
- * coredialogs.m: Mac OS X Core Dialogs
- *****************************************************************************
- * Copyright (C) 2005-2016 VLC authors and VideoLAN
- * $Id$
- *
- * Authors: Derk-Jan Hartman <hartman at videolan dot org>
- *          Felix Paul Kühne <fkuehne at videolan dot org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#import "intf.h"
-#import "coredialogs.h"
-#import "misc.h"
-
-/* for the icon in our custom error panel */
-#import <ApplicationServices/ApplicationServices.h>
-
-@interface VLCCoreDialogProvider ()
-
-- (void)displayError:(NSArray *)dialogData;
-
-- (void)displayLoginDialog:(NSArray *)dialogData;
-
-- (void)displayQuestion:(NSArray *)dialogData;
-
-- (void)displayProgressDialog:(NSArray *)dialogData;
-
-- (void)updateDisplayedProgressDialog:(NSArray *)dialogData;
-
-@end
-
-
-static void displayErrorCallback(void *p_data,
-                                 const char *psz_title,
-                                 const char *psz_text)
-{
-    @autoreleasepool {
-        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
-        [dialogProvider performSelectorOnMainThread:@selector(displayError:)
-                                         withObject:@[toNSStr(psz_title),
-                                                      toNSStr(psz_text)]
-                                      waitUntilDone:NO];
-    }
-}
-
-static void displayLoginCallback(void *p_data,
-                                 vlc_dialog_id *p_id,
-                                 const char *psz_title,
-                                 const char *psz_text,
-                                 const char *psz_default_username,
-                                 bool b_ask_store)
-{
-    @autoreleasepool {
-        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
-        [dialogProvider performSelectorOnMainThread:@selector(displayLoginDialog:)
-                                         withObject:@[[NSValue valueWithPointer:p_id],
-                                                      toNSStr(psz_title),
-                                                      toNSStr(psz_text),
-                                                      toNSStr(psz_default_username),
-                                                      @(b_ask_store)]
-                                      waitUntilDone:NO];
-    }
-}
-
-static void displayQuestionCallback(void *p_data,
-                                    vlc_dialog_id *p_id,
-                                    const char *psz_title,
-                                    const char *psz_text,
-                                    vlc_dialog_question_type i_type,
-                                    const char *psz_cancel,
-                                    const char *psz_action1,
-                                    const char *psz_action2)
-{
-    @autoreleasepool {
-        VLCCoreDialogProvider *dialogProvider = (__bridge  VLCCoreDialogProvider *)p_data;
-        [dialogProvider performSelectorOnMainThread:@selector(displayQuestion:)
-                                         withObject:@[[NSValue valueWithPointer:p_id],
-                                                      toNSStr(psz_title),
-                                                      toNSStr(psz_text),
-                                                      @(i_type),
-                                                      toNSStr(psz_cancel),
-                                                      toNSStr(psz_action1),
-                                                      toNSStr(psz_action2)]
-                                      waitUntilDone:NO];
-    }
-}
-
-static void displayProgressCallback(void *p_data,
-                                    vlc_dialog_id *p_id,
-                                    const char *psz_title,
-                                    const char *psz_text,
-                                    bool b_indeterminate,
-                                    float f_position,
-                                    const char *psz_cancel)
-{
-    @autoreleasepool {
-        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
-        [dialogProvider performSelectorOnMainThread:@selector(displayProgressDialog:)
-                                         withObject:@[[NSValue valueWithPointer:p_id],
-                                                      toNSStr(psz_title),
-                                                      toNSStr(psz_text),
-                                                      @(b_indeterminate),
-                                                      @(f_position),
-                                                      toNSStr(psz_cancel)]
-                                      waitUntilDone:NO];
-    }
-}
-
-static void cancelCallback(void *p_data,
-                           vlc_dialog_id *p_id)
-{
-    @autoreleasepool {
-        [NSApp stopModalWithCode: 0];
-    }
-}
-
-static void updateProgressCallback(void *p_data,
-                                   vlc_dialog_id *p_id,
-                                   float f_value,
-                                   const char *psz_text)
-{
-    @autoreleasepool {
-        VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)p_data;
-        [dialogProvider performSelectorOnMainThread:@selector(updateDisplayedProgressDialog:)
-                                         withObject:@[[NSValue valueWithPointer:p_id],
-                                                      @(f_value),
-                                                      toNSStr(psz_text)]
-                                      waitUntilDone:NO];
-    }
-}
-
-@implementation VLCCoreDialogProvider
-
-- (instancetype)init
-{
-    self = [super init];
-
-    if (self) {
-        msg_Dbg(getIntf(), "Register dialog provider");
-        [NSBundle loadNibNamed:@"CoreDialogs" owner: self];
-
-        intf_thread_t *p_intf = getIntf();
-        /* subscribe to various interactive dialogues */
-
-        const vlc_dialog_cbs cbs = {
-            displayErrorCallback,
-            displayLoginCallback,
-            displayQuestionCallback,
-            displayProgressCallback,
-            cancelCallback,
-            updateProgressCallback
-        };
-
-        vlc_dialog_provider_set_callbacks(p_intf, &cbs, (__bridge void *)self);
-    }
-
-    return self;
-}
-
-- (void)dealloc
-{
-    msg_Dbg(getIntf(), "Deinitializing dialog provider");
-
-    intf_thread_t *p_intf = getIntf();
-    vlc_dialog_provider_set_callbacks(p_intf, NULL, NULL);
-}
-
--(void)awakeFromNib
-{
-    _progressCancelled = NO;
-    [authenticationLoginLabel setStringValue: _NS("Username")];
-    [authenticationPasswordLabel setStringValue: _NS("Password")];
-    [authenticationCancelButton setTitle: _NS("Cancel")];
-    [authenticationOkButton setTitle: _NS("OK")];
-    [authenticationStorePasswordCheckbox setTitle:_NS("Remember")];
-
-    [progressCancelButton setTitle: _NS("Cancel")];
-    [progressIndicator setUsesThreadedAnimation: YES];
-}
-
-- (void)displayError:(NSArray *)dialogData
-{
-    NSAlert *alert = [NSAlert alertWithMessageText:dialogData[0]
-                                     defaultButton:_NS("OK")
-                                   alternateButton:nil
-                                       otherButton:nil
-                         informativeTextWithFormat:@"%@", dialogData[1]];
-    [alert setAlertStyle:NSCriticalAlertStyle];
-    [alert runModal];
-}
-
-- (void)displayLoginDialog:(NSArray *)dialogData
-{
-    [authenticationTitleLabel setStringValue:dialogData[1]];
-    authenticationWindow.title = dialogData[1];
-    [authenticationDescriptionLabel setStringValue:dialogData[2]];
-
-    [authenticationLoginTextField setStringValue:dialogData[3]];
-    [authenticationPasswordTextField setStringValue:@""];
-
-    authenticationStorePasswordCheckbox.hidden = ![dialogData[4] boolValue];
-    authenticationStorePasswordCheckbox.state = NSOffState;
-
-    [authenticationWindow center];
-    NSInteger returnValue = [NSApp runModalForWindow:authenticationWindow];
-    [authenticationWindow close];
-
-    NSString *username = authenticationLoginTextField.stringValue;
-    NSString *password = authenticationPasswordTextField.stringValue;
-
-    vlc_dialog_id_post_login([dialogData[0] pointerValue],
-                             username ? [username UTF8String] : NULL,
-                             password ? [password UTF8String] : NULL,
-                             authenticationStorePasswordCheckbox.state == NSOnState);
-}
-
-- (IBAction)authenticationDialogAction:(id)sender
-{
-    if ([[sender title] isEqualToString: _NS("OK")])
-        [NSApp stopModalWithCode: 1];
-    else
-        [NSApp stopModalWithCode: 0];
-}
-
-- (void)displayQuestion:(NSArray *)dialogData
-{
-    NSAlert *alert = [NSAlert alertWithMessageText:dialogData[1]
-                                     defaultButton:dialogData[5]
-                                   alternateButton:dialogData[6]
-                                       otherButton:dialogData[4]
-                         informativeTextWithFormat:@"%@", dialogData[2]];
-
-    switch ([dialogData[3] intValue]) {
-        case VLC_DIALOG_QUESTION_WARNING:
-            [alert setAlertStyle:NSWarningAlertStyle];
-            break;
-        case VLC_DIALOG_QUESTION_CRITICAL:
-            [alert setAlertStyle:NSCriticalAlertStyle];
-            break;
-        default:
-            [alert setAlertStyle:NSInformationalAlertStyle];
-            break;
-    }
-
-    NSInteger returnValue = [alert runModal];
-    switch (returnValue) {
-        case NSAlertAlternateReturn:
-            vlc_dialog_id_post_action([dialogData[0] pointerValue], 2);
-            break;
-
-        case NSAlertOtherReturn:
-            vlc_dialog_id_post_action([dialogData[0] pointerValue], 3);
-            break;
-
-        default:
-            vlc_dialog_id_post_action([dialogData[0] pointerValue], 1);
-            break;
-    }
-
-}
-
-- (void)displayProgressDialog:(NSArray *)dialogData
-{
-    progressTitleLabel.stringValue = dialogData[1];
-    progressWindow.title = dialogData[1];
-
-    progressDescriptionLabel.stringValue = dialogData[2];
-
-    progressIndicator.indeterminate = [dialogData[3] boolValue];
-    progressIndicator.doubleValue = [dialogData[4] doubleValue];
-
-    if ([dialogData[5] length] > 0) {
-        progressCancelButton.title = dialogData[5];
-    } else {
-        progressCancelButton.title = _NS("Cancel");
-    }
-
-    [progressIndicator startAnimation:self];
-
-    [progressWindow center];
-    NSInteger returnValue = [NSApp runModalForWindow:progressWindow];
-    [progressWindow close];
-
-    [progressIndicator stopAnimation:self];
-
-    if (returnValue == -1)
-        vlc_dialog_id_dismiss([dialogData[0] pointerValue]);
-}
-
-- (void)updateDisplayedProgressDialog:(NSArray *)dialogData
-
-{
-    if (!progressIndicator.indeterminate) {
-        progressIndicator.doubleValue = [dialogData[1] doubleValue];
-        progressDescriptionLabel.stringValue = dialogData[2];
-    }
-}
-
-- (IBAction)progressDialogAction:(id)sender
-{
-    [NSApp stopModalWithCode: -1];
-}
-
-@end
index 5c97883..79b22b7 100644 (file)
@@ -52,7 +52,7 @@
 #import "VLCPlaylistInfo.h"
 #import "open.h"
 #import "bookmarks.h"
-#import "coredialogs.h"
+#import "VLCCoreDialogProvider.h"
 #import "simple_prefs.h"
 #import "CoreInteraction.h"
 #import "TrackSynchronization.h"