[vlc-commits] macosx: Add missing files for VLCPopupPanelController.h

David Fuhrmann git at videolan.org
Sun Sep 4 10:51:13 CEST 2016


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Sep  4 10:51:04 2016 +0200| [6133b2bba7ffc0f1e4ab7f8543d5169d25dab603] | committer: David Fuhrmann

macosx: Add missing files for VLCPopupPanelController.h

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

 modules/gui/macosx/VLCPopupPanelController.h | 56 +++++++++++++++++++++++
 modules/gui/macosx/VLCPopupPanelController.m | 67 ++++++++++++++++++++++++++++
 2 files changed, 123 insertions(+)

diff --git a/modules/gui/macosx/VLCPopupPanelController.h b/modules/gui/macosx/VLCPopupPanelController.h
new file mode 100644
index 0000000..cc631f3
--- /dev/null
+++ b/modules/gui/macosx/VLCPopupPanelController.h
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * VLCPopupPanelController.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012 Felix Paul Kühne
+ * $Id$
+ *
+ * Authors: 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 <Cocoa/Cocoa.h>
+
+ at interface VLCPopupPanelController : NSWindowController
+
+ at property (weak) IBOutlet NSTextField *titleLabel;
+ at property (weak) IBOutlet NSTextField *subtitleLabel;
+ at property (weak) IBOutlet NSPopUpButton *popupButton;
+ at property (weak) IBOutlet NSButton *cancelButton;
+ at property (weak) IBOutlet NSButton *okButton;
+
+ at property (readwrite, assign) NSString *titleString;
+ at property (readwrite, assign) NSString *subTitleString;
+ at property (readwrite, assign) NSString *okButtonString;
+ at property (readwrite, assign) NSString *cancelButtonString;
+ at property (readwrite, assign) NSArray *popupButtonContent;
+
+/**
+ * Completion handler for popup panel
+ * \param returnCode Result from panel. Can be NSOKButton or NSCancelButton.
+ * \param selectedIndex Selected index of the popup in panel.
+ */
+typedef void(^PopupPanelCompletionBlock)(NSInteger returnCode, NSInteger selectedIndex);
+
+/**
+ * Shows the panel as a modal dialog with window as its owner.
+ * \param window Parent window for the dialog.
+ * \param handler Completion block.
+ */
+- (void)runModalForWindow:(NSWindow *)window completionHandler:(PopupPanelCompletionBlock)handler;
+
+- (IBAction)windowElementAction:(id)sender;
+
+ at end
diff --git a/modules/gui/macosx/VLCPopupPanelController.m b/modules/gui/macosx/VLCPopupPanelController.m
new file mode 100644
index 0000000..37b67c6
--- /dev/null
+++ b/modules/gui/macosx/VLCPopupPanelController.m
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * VLCPopupPanelController.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2012 Felix Paul Kühne
+ * $Id$
+ *
+ * Authors: 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 "VLCPopupPanelController.h"
+
+ at interface VLCPopupPanelController()
+{
+    PopupPanelCompletionBlock _completionBlock;
+}
+ at end
+
+ at implementation VLCPopupPanelController
+
+- (id)init
+{
+    self = [super initWithWindowNibName:@"PopupPanel"];
+
+    return self;
+}
+
+- (IBAction)windowElementAction:(id)sender
+{
+    [self.window orderOut:sender];
+    [NSApp endSheet: self.window];
+
+    if (_completionBlock)
+        _completionBlock(sender == _okButton ? NSOKButton : NSCancelButton, [_popupButton indexOfSelectedItem]);
+}
+
+- (void)runModalForWindow:(NSWindow *)window completionHandler:(PopupPanelCompletionBlock)handler;
+{
+    [self window];
+
+    [_titleLabel setStringValue:self.titleString];
+    [_subtitleLabel setStringValue:self.subTitleString];
+    [_cancelButton setTitle:self.cancelButtonString];
+    [_okButton setTitle:self.okButtonString];
+    [_popupButton removeAllItems];
+    for (NSString *value in self.popupButtonContent)
+        [[_popupButton menu] addItemWithTitle:value action:nil keyEquivalent:@""];
+
+    _completionBlock = [handler copy];
+
+    [NSApp beginSheet:self.window modalForWindow:window modalDelegate:self didEndSelector:NULL contextInfo:nil];
+}
+
+ at end



More information about the vlc-commits mailing list