mirror of
https://github.com/videolan/vlc.git
synced 2024-12-05 07:46:32 +08:00
Mac OS X dialog provider: completely removed
Use VLCKit to implement dialogs properly in external apps
This commit is contained in:
parent
34e88dc736
commit
ac8d744520
1
NEWS
1
NEWS
@ -209,6 +209,7 @@ Removed modules
|
||||
* Win32 GDI text renderer module (use Freetype instead)
|
||||
* Growl notification (replaced by osx_notifications)
|
||||
* VCDX "extended" Video CD access module (use the normal VCD module)
|
||||
* Mac OS X Dialog Provider (use VLCKit instead)
|
||||
|
||||
|
||||
Changes between 2.2.0 and 2.2.1:
|
||||
|
11
configure.ac
11
configure.ac
@ -3920,17 +3920,6 @@ then
|
||||
VLC_ADD_PLUGIN([minimal_macosx])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl MacOS X dialog provider
|
||||
dnl
|
||||
AC_ARG_ENABLE(macosx-dialog-provider,
|
||||
[ --enable-macosx-dialog-provider Mac OS X dialog module (default enabled on Mac OS X)])
|
||||
if test "x${enable_macosx_dialog_provider}" != "xno" &&
|
||||
(test "${SYS}" = "darwin" || test "${enable_macosx_dialog_provider}" = "yes")
|
||||
then
|
||||
VLC_ADD_PLUGIN([macosx_dialog_provider])
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl VideoToolbox plugins
|
||||
AC_CHECK_HEADERS(VideoToolbox/VideoToolbox.h, [
|
||||
|
@ -218,7 +218,6 @@ $Id$
|
||||
* lpcm: LPCM decoder
|
||||
* lua: Lua scripting inteface
|
||||
* macosx: Video output, and interface module for Mac OS X
|
||||
* macosx_dialog_provider: Minimal Dialog Provider for Mac OS X
|
||||
* mad: MPEG-1 & 2 audio layer I,II,III audio decoder using MAD
|
||||
* magnify: zoom video filter
|
||||
* marq: Overlays a marquee on the video
|
||||
|
@ -22,18 +22,6 @@ endif
|
||||
|
||||
EXTRA_DIST += gui/eject.c
|
||||
|
||||
|
||||
libmacosx_dialog_provider_plugin_la_SOURCES = \
|
||||
gui/macosx_dialog_provider/VLCLoginPanel.h gui/macosx_dialog_provider/VLCLoginPanel.m \
|
||||
gui/macosx_dialog_provider/VLCProgressPanel.h gui/macosx_dialog_provider/VLCProgressPanel.m \
|
||||
gui/macosx_dialog_provider/VLCUIWidgets.h gui/macosx_dialog_provider/VLCUIWidgets.m \
|
||||
gui/macosx_dialog_provider/dialogProvider.h gui/macosx_dialog_provider/dialogProvider.m
|
||||
libmacosx_dialog_provider_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(guidir)' -Wl,-framework,Cocoa
|
||||
|
||||
EXTRA_LTLIBRARIES += libmacosx_dialog_provider_plugin.la
|
||||
gui_LTLIBRARIES += $(LTLIBmacosx_dialog_provider)
|
||||
|
||||
|
||||
libminimal_macosx_plugin_la_SOURCES = \
|
||||
gui/minimal_macosx/intf.h gui/minimal_macosx/intf.m \
|
||||
gui/minimal_macosx/misc.h gui/minimal_macosx/misc.m \
|
||||
|
@ -1,48 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCLoginPanel.h: A Generic Login Panel created for VLC
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $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 Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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>
|
||||
|
||||
|
||||
@interface VLCLoginPanel : NSPanel {
|
||||
IBOutlet NSButton * _cancelButton;
|
||||
IBOutlet NSButton * _okayButton;
|
||||
IBOutlet NSTextField * _userNameLabel;
|
||||
IBOutlet NSTextField * _userNameField;
|
||||
IBOutlet NSTextField * _passwordLabel;
|
||||
IBOutlet NSSecureTextField * _passwordField;
|
||||
IBOutlet NSTextField * _titleField;
|
||||
IBOutlet NSTextField * _informativeTextField;
|
||||
IBOutlet NSImageView * _iconView;
|
||||
}
|
||||
|
||||
- (IBAction)buttonAction:(id)sender;
|
||||
- (void)createContentView;
|
||||
|
||||
- (void)setDialogTitle:(NSString *)title;
|
||||
- (void)setDialogMessage:(NSString *)message;
|
||||
|
||||
- (NSString *)userName;
|
||||
- (NSString *)password;
|
||||
|
||||
@end
|
@ -1,183 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCLoginPanel.m: A Generic Login Panel created for VLC
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $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 Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 "VLCLoginPanel.h"
|
||||
|
||||
|
||||
@implementation VLCLoginPanel
|
||||
|
||||
- (id)init
|
||||
{
|
||||
NSRect windowRect;
|
||||
windowRect.size.height = 278;
|
||||
windowRect.size.width = 505;
|
||||
windowRect.origin.x = windowRect.origin.y = 0;
|
||||
|
||||
return [super initWithContentRect:windowRect
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
}
|
||||
|
||||
- (void)createContentView
|
||||
{
|
||||
NSRect s_rc = [self frame];
|
||||
id ourContentView = [self contentView];
|
||||
|
||||
s_rc.origin.x = 275;
|
||||
s_rc.origin.y = 44;
|
||||
s_rc.size.height = 32;
|
||||
s_rc.size.width = 108;
|
||||
_cancelButton = [[NSButton alloc] initWithFrame:s_rc];
|
||||
[_cancelButton setButtonType:NSMomentaryLightButton];
|
||||
[_cancelButton setTitle:@"Cancel"];
|
||||
[_cancelButton setBezelStyle:NSRoundedBezelStyle];
|
||||
[_cancelButton setBordered:YES];
|
||||
[_cancelButton setTarget:self];
|
||||
[_cancelButton setAction:@selector(buttonAction:)];
|
||||
[_cancelButton setKeyEquivalent:@"\e"] ; // escape key
|
||||
[ourContentView addSubview:_cancelButton];
|
||||
|
||||
s_rc.origin.x = 383;
|
||||
s_rc.origin.y = 44;
|
||||
s_rc.size.height = 32;
|
||||
s_rc.size.width = 108;
|
||||
_okayButton = [[NSButton alloc] initWithFrame:s_rc];
|
||||
[_okayButton setButtonType:NSMomentaryLightButton];
|
||||
[_okayButton setTitle:@"OK"];
|
||||
[_okayButton setBezelStyle:NSRoundedBezelStyle];
|
||||
[_okayButton setBordered:YES];
|
||||
[_okayButton setTarget:self];
|
||||
[_okayButton setAction:@selector(buttonAction:)];
|
||||
[_okayButton setKeyEquivalent:@"\r"] ; // enter key
|
||||
[ourContentView addSubview:_okayButton];
|
||||
|
||||
s_rc.origin.x = 94;
|
||||
s_rc.origin.y = 170;
|
||||
s_rc.size.height = 14;
|
||||
s_rc.size.width = 129;
|
||||
_userNameLabel = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_userNameLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
[_userNameLabel setStringValue:@"Username"];
|
||||
[_userNameLabel setBezeled:NO];
|
||||
[_userNameLabel setEditable:NO];
|
||||
[_userNameLabel setSelectable:NO];
|
||||
[_userNameLabel setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_userNameLabel];
|
||||
|
||||
s_rc.origin.x = 97;
|
||||
s_rc.origin.y = 148;
|
||||
s_rc.size.height = 22;
|
||||
s_rc.size.width = 310;
|
||||
_userNameField = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_userNameField setBezeled:YES];
|
||||
[_userNameField setEditable:YES];
|
||||
[_userNameField setImportsGraphics:NO];
|
||||
[ourContentView addSubview:_userNameField];
|
||||
|
||||
s_rc.origin.x = 94;
|
||||
s_rc.origin.y = 116;
|
||||
s_rc.size.height = 14;
|
||||
s_rc.size.width = 129;
|
||||
_passwordLabel = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_passwordLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
[_passwordLabel setStringValue:@"Password"];
|
||||
[_passwordLabel setBezeled:NO];
|
||||
[_passwordLabel setEditable:NO];
|
||||
[_passwordLabel setSelectable:NO];
|
||||
[_passwordLabel setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_passwordLabel];
|
||||
|
||||
s_rc.origin.x = 97;
|
||||
s_rc.origin.y = 94;
|
||||
s_rc.size.height = 22;
|
||||
s_rc.size.width = 310;
|
||||
_passwordField = [[NSSecureTextField alloc] initWithFrame:s_rc];
|
||||
[_passwordField setBezeled:YES];
|
||||
[_passwordField setEditable:YES];
|
||||
[_passwordField setImportsGraphics:NO];
|
||||
[ourContentView addSubview:_passwordField];
|
||||
|
||||
s_rc.origin.x = 94;
|
||||
s_rc.origin.y = 238;
|
||||
s_rc.size.height = 17;
|
||||
s_rc.size.width = 316;
|
||||
_titleField = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_titleField setFont:[NSFont boldSystemFontOfSize:0]];
|
||||
[_titleField setBezeled:NO];
|
||||
[_titleField setEditable:NO];
|
||||
[_titleField setSelectable:YES];
|
||||
[_titleField setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_titleField];
|
||||
|
||||
s_rc.origin.x = 94;
|
||||
s_rc.origin.y = 183;
|
||||
s_rc.size.height = 44;
|
||||
s_rc.size.width = 394;
|
||||
_informativeTextField = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_informativeTextField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
[_informativeTextField setBezeled:NO];
|
||||
[_informativeTextField setEditable:NO];
|
||||
[_informativeTextField setSelectable:YES];
|
||||
[_informativeTextField setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_informativeTextField];
|
||||
|
||||
s_rc.origin.x = 20;
|
||||
s_rc.origin.y = 188;
|
||||
s_rc.size.height = s_rc.size.width = 64;
|
||||
_iconView = [[NSImageView alloc] initWithFrame:s_rc];
|
||||
[_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
|
||||
[_iconView setEditable:NO];
|
||||
[_iconView setAllowsCutCopyPaste:NO];
|
||||
[ourContentView addSubview:_iconView];
|
||||
}
|
||||
|
||||
- (IBAction)buttonAction:(id)sender
|
||||
{
|
||||
if (sender == _okayButton)
|
||||
[NSApp stopModalWithCode: 1];
|
||||
else
|
||||
[NSApp stopModalWithCode: 0];
|
||||
}
|
||||
|
||||
- (void)setDialogTitle:(NSString *)title
|
||||
{
|
||||
[_titleField setStringValue:title];
|
||||
[self setTitle:title];
|
||||
}
|
||||
- (void)setDialogMessage:(NSString *)message
|
||||
{
|
||||
[_informativeTextField setStringValue:message];
|
||||
}
|
||||
|
||||
- (NSString *)userName
|
||||
{
|
||||
return [_userNameField stringValue];
|
||||
}
|
||||
|
||||
- (NSString *)password
|
||||
{
|
||||
return [_passwordField stringValue];
|
||||
}
|
||||
|
||||
@end
|
@ -1,46 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCProgressPanel.h: A Generic Progress Indicator Panel created for VLC
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $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 Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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>
|
||||
|
||||
|
||||
@interface VLCProgressPanel : NSPanel {
|
||||
BOOL _isCancelled;
|
||||
|
||||
IBOutlet NSProgressIndicator * _progressBar;
|
||||
IBOutlet NSTextField *_titleField;
|
||||
IBOutlet NSTextField *_messageField;
|
||||
IBOutlet NSButton *_cancelButton;
|
||||
IBOutlet NSImageView *_iconView;
|
||||
}
|
||||
- (void)createContentView;
|
||||
|
||||
- (void)setDialogTitle:(NSString *)title;
|
||||
- (void)setDialogMessage:(NSString *)message;
|
||||
- (void)setCancelButtonLabel:(NSString *)cancelLabel;
|
||||
- (void)setProgressAsDouble:(double)value;
|
||||
- (BOOL)isCancelled;
|
||||
|
||||
- (IBAction)cancelDialog:(id)sender;
|
||||
|
||||
@end
|
@ -1,142 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCProgressPanel.m: A Generic Progress Indicator Panel created for VLC
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $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 Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 "VLCProgressPanel.h"
|
||||
|
||||
|
||||
@implementation VLCProgressPanel
|
||||
|
||||
- (id)init
|
||||
{
|
||||
NSRect windowRect;
|
||||
windowRect.size.height = 182;
|
||||
windowRect.size.width = 520;
|
||||
windowRect.origin.x = windowRect.origin.y = 0;
|
||||
|
||||
return [super initWithContentRect:windowRect
|
||||
styleMask:NSTitledWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:YES];
|
||||
}
|
||||
|
||||
- (void)createContentView
|
||||
{
|
||||
NSRect s_rc = [self frame];
|
||||
id ourContentView = [self contentView];
|
||||
|
||||
s_rc.origin.x = 398;
|
||||
s_rc.origin.y = 28;
|
||||
s_rc.size.height = 32;
|
||||
s_rc.size.width = 108;
|
||||
_cancelButton = [[NSButton alloc] initWithFrame:s_rc];
|
||||
[_cancelButton setButtonType:NSMomentaryLightButton];
|
||||
[_cancelButton setTitle:@"Cancel"];
|
||||
[_cancelButton setBezelStyle:NSRoundedBezelStyle];
|
||||
[_cancelButton setBordered:YES];
|
||||
[_cancelButton setTarget:self];
|
||||
[_cancelButton setAction:@selector(cancelDialog:)];
|
||||
[_cancelButton setKeyEquivalent:@"\e"] ; // escape key
|
||||
[ourContentView addSubview:_cancelButton];
|
||||
|
||||
s_rc.origin.x = 89;
|
||||
s_rc.origin.y = 153;
|
||||
s_rc.size.height = 17;
|
||||
s_rc.size.width = 414;
|
||||
_titleField = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_titleField setFont:[NSFont boldSystemFontOfSize:0]];
|
||||
[_titleField setBezeled:NO];
|
||||
[_titleField setEditable:NO];
|
||||
[_titleField setSelectable:YES];
|
||||
[_titleField setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_titleField];
|
||||
|
||||
s_rc.origin.x = 89;
|
||||
s_rc.origin.y = 116;
|
||||
s_rc.size.height = 42;
|
||||
s_rc.size.width = 414;
|
||||
_messageField = [[NSTextField alloc] initWithFrame:s_rc];
|
||||
[_messageField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
|
||||
[_messageField setBezeled:NO];
|
||||
[_messageField setEditable:NO];
|
||||
[_messageField setSelectable:YES];
|
||||
[_messageField setDrawsBackground:NO];
|
||||
[ourContentView addSubview:_messageField];
|
||||
|
||||
s_rc.origin.x = 90;
|
||||
s_rc.origin.y = 66;
|
||||
s_rc.size.height = 20;
|
||||
s_rc.size.width = 412;
|
||||
_progressBar = [[NSProgressIndicator alloc] initWithFrame:s_rc];
|
||||
[_progressBar setMaxValue:1000.0];
|
||||
[_progressBar setUsesThreadedAnimation:YES];
|
||||
[_progressBar setStyle:NSProgressIndicatorBarStyle];
|
||||
[_progressBar setDisplayedWhenStopped:YES];
|
||||
[_progressBar setControlSize:NSRegularControlSize];
|
||||
[_progressBar setIndeterminate:NO];
|
||||
[ourContentView addSubview:_progressBar];
|
||||
[_progressBar startAnimation:nil];
|
||||
|
||||
s_rc.origin.x = 20;
|
||||
s_rc.origin.y = 110;
|
||||
s_rc.size.height = s_rc.size.width = 64;
|
||||
_iconView = [[NSImageView alloc] initWithFrame:s_rc];
|
||||
[_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
|
||||
[_iconView setEditable:NO];
|
||||
[_iconView setAllowsCutCopyPaste:NO];
|
||||
[ourContentView addSubview:_iconView];
|
||||
}
|
||||
|
||||
- (void)setDialogTitle:(NSString *)title
|
||||
{
|
||||
[_titleField setStringValue:title];
|
||||
[self setTitle:title];
|
||||
}
|
||||
|
||||
- (void)setDialogMessage:(NSString *)message
|
||||
{
|
||||
[_messageField setStringValue:message];
|
||||
}
|
||||
|
||||
- (void)setCancelButtonLabel:(NSString *)cancelLabel
|
||||
{
|
||||
[_cancelButton setTitle:cancelLabel];
|
||||
}
|
||||
|
||||
- (void)setProgressAsDouble:(double)value
|
||||
{
|
||||
[_progressBar setDoubleValue:value];
|
||||
}
|
||||
|
||||
- (BOOL)isCancelled
|
||||
{
|
||||
return _isCancelled;
|
||||
}
|
||||
|
||||
- (IBAction)cancelDialog:(id)sender
|
||||
{
|
||||
_isCancelled = YES;
|
||||
[_progressBar setIndeterminate:YES];
|
||||
[_progressBar startAnimation:self];
|
||||
}
|
||||
|
||||
@end
|
@ -1,77 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCUIWidgets.h: Widgets for VLC's Minimal Dialog Provider for Mac OS X
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
*
|
||||
* Authors: Pierre d'Herbemont <pdherbemont # videolan dot>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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>
|
||||
#import <vlc_extensions.h>
|
||||
|
||||
@interface VLCDialogButton : NSButton
|
||||
{
|
||||
extension_widget_t *widget;
|
||||
}
|
||||
@property (readwrite) extension_widget_t *widget;
|
||||
@end
|
||||
|
||||
|
||||
@interface VLCDialogPopUpButton : NSPopUpButton
|
||||
{
|
||||
extension_widget_t *widget;
|
||||
}
|
||||
@property (readwrite) extension_widget_t *widget;
|
||||
@end
|
||||
|
||||
|
||||
@interface VLCDialogTextField : NSTextField
|
||||
{
|
||||
extension_widget_t *widget;
|
||||
}
|
||||
@property (readwrite) extension_widget_t *widget;
|
||||
@end
|
||||
|
||||
|
||||
@interface VLCDialogWindow : NSWindow
|
||||
{
|
||||
extension_dialog_t *dialog;
|
||||
}
|
||||
@property (readwrite) extension_dialog_t *dialog;
|
||||
@end
|
||||
|
||||
|
||||
@interface VLCDialogList : NSTableView <NSTableViewDataSource>
|
||||
{
|
||||
extension_widget_t *widget;
|
||||
NSMutableArray *contentArray;
|
||||
}
|
||||
@property (readwrite) extension_widget_t *widget;
|
||||
@property (readwrite, retain) NSMutableArray *contentArray;
|
||||
@end
|
||||
|
||||
|
||||
@interface VLCDialogGridView : NSView {
|
||||
NSUInteger _rowCount, _colCount;
|
||||
NSMutableArray *_gridedViews;
|
||||
}
|
||||
|
||||
- (void)addSubview:(NSView *)view atRow:(NSUInteger)row column:(NSUInteger)column rowSpan:(NSUInteger)rowSpan colSpan:(NSUInteger)colSpan;
|
||||
- (NSSize)flexSize:(NSSize)size;
|
||||
- (void)removeSubview:(NSView *)view;
|
||||
@end
|
@ -1,378 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* VLCUIWidgets.m: Widgets for VLC's Minimal Dialog Provider for Mac OS X
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
*
|
||||
* Authors: Pierre d'Herbemont <pdherbemont # videolan dot>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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 "VLCUIWidgets.h"
|
||||
|
||||
@implementation VLCDialogButton
|
||||
@synthesize widget;
|
||||
@end
|
||||
|
||||
|
||||
@implementation VLCDialogPopUpButton
|
||||
@synthesize widget;
|
||||
@end
|
||||
|
||||
|
||||
@implementation VLCDialogTextField
|
||||
@synthesize widget;
|
||||
@end
|
||||
|
||||
|
||||
@implementation VLCDialogWindow
|
||||
@synthesize dialog;
|
||||
@end
|
||||
|
||||
|
||||
@implementation VLCDialogList
|
||||
@synthesize widget;
|
||||
@synthesize contentArray;
|
||||
|
||||
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
|
||||
{
|
||||
return [contentArray count];
|
||||
}
|
||||
|
||||
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
|
||||
{
|
||||
return [[contentArray objectAtIndex:rowIndex] objectForKey:@"text"];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation VLCDialogGridView
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[_gridedViews release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)recomputeCount
|
||||
{
|
||||
_colCount = 0;
|
||||
_rowCount = 0;
|
||||
for (NSDictionary *obj in _gridedViews)
|
||||
{
|
||||
NSUInteger row = [[obj objectForKey:@"row"] intValue];
|
||||
NSUInteger col = [[obj objectForKey:@"col"] intValue];
|
||||
if (col + 1 > _colCount)
|
||||
_colCount = col + 1;
|
||||
if (row + 1 > _rowCount)
|
||||
_rowCount = row + 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)recomputeWindowSize
|
||||
{
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(recomputeWindowSize) object:nil];
|
||||
|
||||
NSWindow *window = [self window];
|
||||
NSRect frame = [window frame];
|
||||
NSRect contentRect = [window contentRectForFrameRect:frame];
|
||||
contentRect.size = [self flexSize:frame.size];
|
||||
NSRect newFrame = [window frameRectForContentRect:contentRect];
|
||||
newFrame.origin.y -= newFrame.size.height - frame.size.height;
|
||||
newFrame.origin.x -= (newFrame.size.width - frame.size.width) / 2;
|
||||
[window setFrame:newFrame display:YES animate:YES];
|
||||
}
|
||||
|
||||
- (NSSize)objectSizeToFit:(NSView *)view
|
||||
{
|
||||
if ([view isKindOfClass:[NSControl class]]) {
|
||||
NSControl *control = (NSControl *)view;
|
||||
return [[control cell] cellSize];
|
||||
}
|
||||
return [view frame].size;
|
||||
}
|
||||
|
||||
- (CGFloat)marginX
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
- (CGFloat)marginY
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
- (CGFloat)constrainedHeightOfRow:(NSUInteger)targetRow
|
||||
{
|
||||
CGFloat height = 0;
|
||||
for(NSDictionary *obj in _gridedViews) {
|
||||
NSUInteger row = [[obj objectForKey:@"row"] intValue];
|
||||
if (row != targetRow)
|
||||
continue;
|
||||
NSUInteger rowSpan = [[obj objectForKey:@"rowSpan"] intValue];
|
||||
if (rowSpan != 1)
|
||||
continue;
|
||||
NSView *view = [obj objectForKey:@"view"];
|
||||
if ([view autoresizingMask] & NSViewHeightSizable)
|
||||
continue;
|
||||
NSSize sizeToFit = [self objectSizeToFit:view];
|
||||
if (height < sizeToFit.height)
|
||||
height = sizeToFit.height;
|
||||
}
|
||||
return height;
|
||||
}
|
||||
|
||||
- (CGFloat)remainingRowsHeight
|
||||
{
|
||||
NSUInteger height = [self marginY];
|
||||
if (!_rowCount)
|
||||
return 0;
|
||||
NSUInteger autosizedRows = 0;
|
||||
for (NSUInteger i = 0; i < _rowCount; i++) {
|
||||
CGFloat constrainedHeight = [self constrainedHeightOfRow:i];
|
||||
if (!constrainedHeight)
|
||||
autosizedRows++;
|
||||
height += constrainedHeight + [self marginY];
|
||||
}
|
||||
CGFloat remaining = 0;
|
||||
if (height < self.bounds.size.height && autosizedRows)
|
||||
remaining = (self.bounds.size.height - height) / autosizedRows;
|
||||
if (remaining < 0)
|
||||
remaining = 0;
|
||||
|
||||
return remaining;
|
||||
}
|
||||
|
||||
- (CGFloat)heightOfRow:(NSUInteger)targetRow
|
||||
{
|
||||
NSAssert(targetRow < _rowCount, @"accessing a non existing row");
|
||||
CGFloat height = [self constrainedHeightOfRow:targetRow];
|
||||
if (!height)
|
||||
height = [self remainingRowsHeight];
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
- (CGFloat)topOfRow:(NSUInteger)targetRow
|
||||
{
|
||||
CGFloat top = [self marginY];
|
||||
for (NSUInteger i = 1; i < _rowCount - targetRow; i++)
|
||||
{
|
||||
top += [self heightOfRow:_rowCount - i] + [self marginY];
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
- (CGFloat)constrainedWidthOfColumn:(NSUInteger)targetColumn
|
||||
{
|
||||
CGFloat width = 0;
|
||||
for(NSDictionary *obj in _gridedViews) {
|
||||
NSUInteger col = [[obj objectForKey:@"col"] intValue];
|
||||
if (col != targetColumn)
|
||||
continue;
|
||||
NSUInteger colSpan = [[obj objectForKey:@"colSpan"] intValue];
|
||||
if (colSpan != 1)
|
||||
continue;
|
||||
NSView *view = [obj objectForKey:@"view"];
|
||||
if ([view autoresizingMask] & NSViewWidthSizable)
|
||||
return 0;
|
||||
NSSize sizeToFit = [self objectSizeToFit:view];
|
||||
if (width < sizeToFit.width)
|
||||
width = sizeToFit.width;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
- (CGFloat)remainingColumnWidth
|
||||
{
|
||||
NSUInteger width = [self marginX];
|
||||
if (!_colCount)
|
||||
return 0;
|
||||
NSUInteger autosizedCol = 0;
|
||||
for (NSUInteger i = 0; i < _colCount; i++) {
|
||||
CGFloat constrainedWidth = [self constrainedWidthOfColumn:i];
|
||||
if (!constrainedWidth)
|
||||
autosizedCol++;
|
||||
width += constrainedWidth + [self marginX];
|
||||
|
||||
}
|
||||
CGFloat remaining = 0;
|
||||
if (width < self.bounds.size.width && autosizedCol)
|
||||
remaining = (self.bounds.size.width - width) / autosizedCol;
|
||||
if (remaining < 0)
|
||||
remaining = 0;
|
||||
return remaining;
|
||||
}
|
||||
|
||||
- (CGFloat)widthOfColumn:(NSUInteger)targetColumn
|
||||
{
|
||||
CGFloat width = [self constrainedWidthOfColumn:targetColumn];
|
||||
if (!width)
|
||||
width = [self remainingColumnWidth];
|
||||
return width;
|
||||
}
|
||||
|
||||
|
||||
- (CGFloat)leftOfColumn:(NSUInteger)targetColumn
|
||||
{
|
||||
CGFloat left = [self marginX];
|
||||
for (NSUInteger i = 0; i < targetColumn; i++)
|
||||
{
|
||||
left += [self widthOfColumn:i] + [self marginX];
|
||||
|
||||
}
|
||||
return left;
|
||||
}
|
||||
|
||||
- (void)relayout
|
||||
{
|
||||
for(NSDictionary *obj in _gridedViews) {
|
||||
NSUInteger row = [[obj objectForKey:@"row"] intValue];
|
||||
NSUInteger col = [[obj objectForKey:@"col"] intValue];
|
||||
NSUInteger rowSpan = [[obj objectForKey:@"rowSpan"] intValue];
|
||||
NSUInteger colSpan = [[obj objectForKey:@"colSpan"] intValue];
|
||||
NSView *view = [obj objectForKey:@"view"];
|
||||
NSRect rect;
|
||||
|
||||
// Get the height
|
||||
if ([view autoresizingMask] & NSViewHeightSizable || rowSpan > 1) {
|
||||
CGFloat height = 0;
|
||||
for (NSUInteger r = 0; r < rowSpan; r++) {
|
||||
if (row + r >= _rowCount)
|
||||
break;
|
||||
height += [self heightOfRow:row + r] + [self marginY];
|
||||
}
|
||||
rect.size.height = height - [self marginY];
|
||||
}
|
||||
else
|
||||
rect.size.height = [self objectSizeToFit:view].height;
|
||||
|
||||
// Get the width
|
||||
if ([view autoresizingMask] & NSViewWidthSizable) {
|
||||
CGFloat width = 0;
|
||||
for (NSUInteger c = 0; c < colSpan; c++)
|
||||
width += [self widthOfColumn:col + c] + [self marginX];
|
||||
rect.size.width = width - [self marginX];
|
||||
}
|
||||
else
|
||||
rect.size.width = [self objectSizeToFit:view].width;
|
||||
|
||||
// Top corner
|
||||
rect.origin.y = [self topOfRow:row] + ([self heightOfRow:row] - rect.size.height) / 2;
|
||||
rect.origin.x = [self leftOfColumn:col];
|
||||
|
||||
[view setFrame:rect];
|
||||
[view setNeedsDisplay:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)objectForView:(NSView *)view
|
||||
{
|
||||
for (NSMutableDictionary *dict in _gridedViews)
|
||||
{
|
||||
if ([dict objectForKey:@"view"] == view)
|
||||
return dict;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)addSubview:(NSView *)view atRow:(NSUInteger)row column:(NSUInteger)column rowSpan:(NSUInteger)rowSpan colSpan:(NSUInteger)colSpan
|
||||
{
|
||||
if (row + 1 > _rowCount)
|
||||
_rowCount = row + 1;
|
||||
if (column + 1 > _colCount)
|
||||
_colCount = column + 1;
|
||||
|
||||
if (!_gridedViews)
|
||||
_gridedViews = [[NSMutableArray alloc] init];
|
||||
|
||||
NSMutableDictionary *dict = [self objectForView:view];
|
||||
if (!dict) {
|
||||
dict = [NSMutableDictionary dictionary];
|
||||
[dict setObject:view forKey:@"view"];
|
||||
[_gridedViews addObject:dict];
|
||||
}
|
||||
[dict setObject:[NSNumber numberWithInt:rowSpan] forKey:@"rowSpan"];
|
||||
[dict setObject:[NSNumber numberWithInt:colSpan] forKey:@"colSpan"];
|
||||
[dict setObject:[NSNumber numberWithInt:row] forKey:@"row"];
|
||||
[dict setObject:[NSNumber numberWithInt:column] forKey:@"col"];
|
||||
|
||||
|
||||
[self addSubview:view];
|
||||
[self relayout];
|
||||
|
||||
// Recompute the size of the window after making sure we won't see anymore update
|
||||
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(recomputeWindowSize) object:nil];
|
||||
[self performSelector:@selector(recomputeWindowSize) withObject:nil afterDelay:0.1];
|
||||
}
|
||||
|
||||
- (void)removeSubview:(NSView *)view
|
||||
{
|
||||
NSDictionary *dict = [self objectForView:view];
|
||||
if (dict)
|
||||
[_gridedViews removeObject:dict];
|
||||
[view removeFromSuperview];
|
||||
|
||||
[self recomputeCount];
|
||||
[self recomputeWindowSize];
|
||||
|
||||
[self relayout];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)frameRect
|
||||
{
|
||||
[super setFrame:frameRect];
|
||||
[self relayout];
|
||||
}
|
||||
|
||||
- (NSSize)flexSize:(NSSize)size
|
||||
{
|
||||
if (!_rowCount || !_colCount)
|
||||
return size;
|
||||
|
||||
CGFloat minHeight = [self marginY];
|
||||
BOOL canFlexHeight = NO;
|
||||
for (NSUInteger i = 0; i < _rowCount; i++) {
|
||||
CGFloat constrained = [self constrainedHeightOfRow:i];
|
||||
if (!constrained) {
|
||||
canFlexHeight = YES;
|
||||
constrained = 128;
|
||||
}
|
||||
minHeight += constrained + [self marginY];
|
||||
}
|
||||
|
||||
CGFloat minWidth = [self marginX];
|
||||
BOOL canFlexWidth = NO;
|
||||
for (NSUInteger i = 0; i < _colCount; i++) {
|
||||
CGFloat constrained = [self constrainedWidthOfColumn:i];
|
||||
if (!constrained) {
|
||||
canFlexWidth = YES;
|
||||
constrained = 128;
|
||||
}
|
||||
minWidth += constrained + [self marginX];
|
||||
}
|
||||
if (size.width < minWidth)
|
||||
size.width = minWidth;
|
||||
if (size.height < minHeight)
|
||||
size.height = minHeight;
|
||||
if (!canFlexHeight)
|
||||
size.height = minHeight;
|
||||
if (!canFlexWidth)
|
||||
size.width = minWidth;
|
||||
return size;
|
||||
}
|
||||
|
||||
@end
|
@ -1,56 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* dialogProvider.h: Minimal Dialog Provider for Mac OS X
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2010 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
*
|
||||
* Authors: Felix Paul Kühne <fkuehne at videolan dot org>
|
||||
* Pierre d'Herbemont <pdherbemont # videolan dot>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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>
|
||||
|
||||
#import <vlc_interface.h>
|
||||
|
||||
#import "VLCLoginPanel.h"
|
||||
#import "VLCProgressPanel.h"
|
||||
|
||||
@interface VLCDialogDisplayer : NSObject
|
||||
{
|
||||
intf_thread_t *p_intf;
|
||||
VLCProgressPanel *_currentProgressBarPanel;
|
||||
}
|
||||
- (intf_thread_t *)intf;
|
||||
- (void)setIntf:(intf_thread_t *)p_mainintf;
|
||||
- (void)globalNotificationReceived: (NSNotification *)theNotification;
|
||||
|
||||
+ (NSDictionary *)dictionaryForDialog:(const char *)title :(const char *)message :(const char *)yes :(const char *)no :(const char *)cancel;
|
||||
|
||||
- (void)displayError:(NSDictionary *)dialog;
|
||||
- (void)displayCritical:(NSDictionary *)dialog;
|
||||
- (NSNumber *)displayQuestion:(NSDictionary *)dialog;
|
||||
- (NSDictionary *)displayLogin:(NSDictionary *)dialog;
|
||||
|
||||
- (void)displayProgressBar:(NSDictionary *)dict;
|
||||
- (void)updateProgressPanel:(NSDictionary *)dict;
|
||||
- (void)destroyProgressPanel;
|
||||
- (NSNumber *)checkProgressPanel;
|
||||
|
||||
- (void)updateExtensionDialog:(NSValue *)extensionDialog;
|
||||
|
||||
- (id)resultFromSelectorOnMainThread:(SEL)sel withObject:(id)object;
|
||||
@end
|
@ -1,936 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* dialogProvider.m: Minimal Dialog Provider for Mac OS X
|
||||
*****************************************************************************
|
||||
* Copyright (C) 2009-2011 VLC authors and VideoLAN
|
||||
* $Id$
|
||||
*
|
||||
* Authors: Felix Paul Kühne <fkuehne at videolan dot org>
|
||||
* Pierre d'Herbemont <pdherbemont # videolan dot>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser 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.
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* Preamble
|
||||
*****************************************************************************/
|
||||
#import <stdlib.h> /* malloc(), free() */
|
||||
#import <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# import "config.h"
|
||||
#endif
|
||||
|
||||
#import <vlc_common.h>
|
||||
#import <vlc_plugin.h>
|
||||
#import <vlc_dialog.h>
|
||||
#import <vlc_extensions.h>
|
||||
#import <vlc_modules.h>
|
||||
|
||||
#import "dialogProvider.h"
|
||||
#import "VLCUIWidgets.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* Prototypes
|
||||
*****************************************************************************/
|
||||
static int OpenIntf(vlc_object_t *);
|
||||
static void CloseIntf(vlc_object_t *);
|
||||
static void Run(intf_thread_t * );
|
||||
|
||||
static int DisplayError(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
static int DisplayCritical(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
static int DisplayQuestion(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
static int DisplayLogin(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
static int DisplayProgressPanelAction(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
static int DisplayExtension(vlc_object_t *,const char *,vlc_value_t,vlc_value_t,void * );
|
||||
|
||||
static void updateProgressPanel (void *, const char *, float);
|
||||
static bool checkProgressPanel (void *);
|
||||
static void destroyProgressPanel (void *);
|
||||
|
||||
|
||||
static inline NSDictionary *DictFromDialogFatal(dialog_fatal_t *dialog) {
|
||||
return [VLCDialogDisplayer dictionaryForDialog:dialog->title :dialog->message :NULL :NULL :NULL];
|
||||
}
|
||||
static inline NSDictionary *DictFromDialogLogin(dialog_login_t *dialog) {
|
||||
return [VLCDialogDisplayer dictionaryForDialog:dialog->title :dialog->message :NULL :NULL :NULL];
|
||||
}
|
||||
static inline NSDictionary *DictFromDialogQuestion(dialog_question_t *dialog) {
|
||||
return [VLCDialogDisplayer dictionaryForDialog:dialog->title :dialog->message :dialog->yes :dialog->no :dialog->cancel];
|
||||
}
|
||||
static inline NSDictionary *DictFromDialogProgressBar(dialog_progress_bar_t *dialog) {
|
||||
return [VLCDialogDisplayer dictionaryForDialog:dialog->title :dialog->message :NULL :NULL :dialog->cancel];
|
||||
}
|
||||
|
||||
struct intf_sys_t
|
||||
{
|
||||
VLCDialogDisplayer *displayer;
|
||||
|
||||
vlc_mutex_t lock;
|
||||
vlc_cond_t wait;
|
||||
bool is_hiding_noaction_dialogs;
|
||||
};
|
||||
|
||||
|
||||
#define T_HIDE_NOACTION N_("Hide no user action dialogs")
|
||||
#define LT_HIDE_NOACTION N_("Don't display dialogs that don't require user action (Critical and error panel).")
|
||||
|
||||
#define prefix "macosx-dialog-provider"
|
||||
/*****************************************************************************
|
||||
* Module descriptor
|
||||
*****************************************************************************/
|
||||
|
||||
vlc_module_begin()
|
||||
/* Minimal interface. see intf.m */
|
||||
set_shortname("Mac OS X Dialogs")
|
||||
add_shortcut("macosx_dialog_provider")
|
||||
set_description("Mac OS X Dialog Provider")
|
||||
set_capability("interface", 0)
|
||||
|
||||
/* This setting is interesting, because when used with a libvlc app
|
||||
* it's almost certain that the client program will display error by
|
||||
* itself. Moreover certain action might end up in an error, but
|
||||
* the client wants to ignored them completely. */
|
||||
add_bool(prefix "hide-no-user-action-dialogs", true, T_HIDE_NOACTION, LT_HIDE_NOACTION, false)
|
||||
|
||||
set_callbacks(OpenIntf, CloseIntf)
|
||||
set_category(CAT_INTERFACE)
|
||||
set_subcategory(SUBCAT_INTERFACE_MAIN)
|
||||
vlc_module_end()
|
||||
|
||||
/*****************************************************************************
|
||||
* OpenIntf: initialize interface
|
||||
*****************************************************************************/
|
||||
int OpenIntf(vlc_object_t *p_this)
|
||||
{
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
|
||||
p_intf->p_sys = malloc(sizeof(intf_sys_t));
|
||||
if(!p_intf->p_sys)
|
||||
return VLC_ENOMEM;
|
||||
|
||||
memset(p_intf->p_sys,0,sizeof(*p_intf->p_sys));
|
||||
|
||||
p_intf->p_sys->displayer = [[VLCDialogDisplayer alloc] init];
|
||||
[p_intf->p_sys->displayer setIntf:p_intf];
|
||||
|
||||
bool hide = var_CreateGetBool(p_intf, prefix "hide-no-user-action-dialogs");
|
||||
p_intf->p_sys->is_hiding_noaction_dialogs = hide;
|
||||
|
||||
/* subscribe to various interactive dialogues */
|
||||
|
||||
if (!hide)
|
||||
{
|
||||
var_Create(p_intf,"dialog-error",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-error",DisplayError,p_intf);
|
||||
var_Create(p_intf,"dialog-critical",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-critical",DisplayCritical,p_intf);
|
||||
}
|
||||
var_Create(p_intf,"dialog-login",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-login",DisplayLogin,p_intf);
|
||||
var_Create(p_intf,"dialog-question",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-question",DisplayQuestion,p_intf);
|
||||
var_Create(p_intf,"dialog-progress-bar",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-progress-bar",DisplayProgressPanelAction,p_intf);
|
||||
var_Create(p_intf,"dialog-extension",VLC_VAR_ADDRESS);
|
||||
var_AddCallback(p_intf,"dialog-extension",DisplayExtension,p_intf);
|
||||
dialog_Register(p_intf);
|
||||
|
||||
/* subscribe to our last.fm announcements */
|
||||
[[NSDistributedNotificationCenter defaultCenter] addObserver:p_intf->p_sys->displayer
|
||||
selector:@selector(globalNotificationReceived:)
|
||||
name:NULL
|
||||
object:@"VLCLastFMSupport"
|
||||
suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
|
||||
|
||||
msg_Dbg(p_intf,"Mac OS X dialog provider initialised");
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* CloseIntf: destroy interface
|
||||
*****************************************************************************/
|
||||
void CloseIntf(vlc_object_t *p_this)
|
||||
{
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
|
||||
/* unsubscribe from the interactive dialogues */
|
||||
dialog_Unregister(p_intf);
|
||||
|
||||
if (!p_intf->p_sys->is_hiding_noaction_dialogs)
|
||||
{
|
||||
var_DelCallback(p_intf,"dialog-error",DisplayError,p_intf);
|
||||
var_DelCallback(p_intf,"dialog-critical",DisplayCritical,p_intf);
|
||||
}
|
||||
var_DelCallback(p_intf,"dialog-login",DisplayLogin,p_intf);
|
||||
var_DelCallback(p_intf,"dialog-question",DisplayQuestion,p_intf);
|
||||
var_DelCallback(p_intf,"dialog-progress-bar",DisplayProgressPanelAction,p_intf);
|
||||
var_DelCallback(p_intf,"dialog-extension",DisplayExtension,p_intf);
|
||||
|
||||
[p_intf->p_sys->displayer release];
|
||||
|
||||
msg_Dbg(p_intf,"Mac OS X dialog provider closed");
|
||||
free(p_intf->p_sys);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
* Callbacks triggered by the "dialog-*" variables
|
||||
*****************************************************************************/
|
||||
static int DisplayError(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
dialog_fatal_t *dialog = value.p_address;
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
[sys->displayer performSelectorOnMainThread:@selector(displayError:)
|
||||
withObject:DictFromDialogFatal(dialog)
|
||||
waitUntilDone:NO];
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int DisplayCritical(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
dialog_fatal_t *dialog = value.p_address;
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
[sys->displayer performSelectorOnMainThread:@selector(displayCritical:)
|
||||
withObject:DictFromDialogFatal(dialog)
|
||||
waitUntilDone:NO];
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int DisplayQuestion(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
dialog_question_t *dialog = value.p_address;
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
dialog->answer = [[sys->displayer resultFromSelectorOnMainThread:@selector(displayQuestion:)
|
||||
withObject:DictFromDialogQuestion(dialog)] intValue];
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int DisplayLogin(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
dialog_login_t *dialog = value.p_address;
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
NSDictionary *dict = [sys->displayer resultFromSelectorOnMainThread:@selector(displayLogin:)
|
||||
withObject:DictFromDialogLogin(dialog)];
|
||||
if (dict) {
|
||||
*dialog->username = strdup([[dict objectForKey:@"username"] UTF8String]);
|
||||
*dialog->password = strdup([[dict objectForKey:@"password"] UTF8String]);
|
||||
}
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int DisplayProgressPanelAction(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
dialog_progress_bar_t *dialog = value.p_address;
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
|
||||
[sys->displayer performSelectorOnMainThread:@selector(displayProgressBar:)
|
||||
withObject:DictFromDialogProgressBar(dialog)
|
||||
waitUntilDone:YES];
|
||||
|
||||
dialog->pf_update = updateProgressPanel;
|
||||
dialog->pf_check = checkProgressPanel;
|
||||
dialog->pf_destroy = destroyProgressPanel;
|
||||
dialog->p_sys = p_intf->p_sys;
|
||||
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
static int DisplayExtension(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
|
||||
{
|
||||
@autoreleasepool {
|
||||
intf_thread_t *p_intf = (intf_thread_t*) p_this;
|
||||
intf_sys_t *sys = p_intf->p_sys;
|
||||
extension_dialog_t *dialog = value.p_address;
|
||||
|
||||
// -updateExtensionDialog: Open its own runloop, so be sure to run on DefaultRunLoop.
|
||||
[sys->displayer performSelectorOnMainThread:@selector(updateExtensionDialog:)
|
||||
withObject:[NSValue valueWithPointer:dialog]
|
||||
waitUntilDone:YES];
|
||||
return VLC_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void updateProgressPanel (void *priv, const char *text, float value)
|
||||
{
|
||||
@autoreleasepool {
|
||||
intf_sys_t *sys = (intf_sys_t *)priv;
|
||||
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@(value), @"value",
|
||||
text ? @(text) : nil, @"text",
|
||||
nil];
|
||||
|
||||
[sys->displayer performSelectorOnMainThread:@selector(updateProgressPanel:)
|
||||
withObject:dict
|
||||
waitUntilDone:YES];
|
||||
}
|
||||
}
|
||||
|
||||
void destroyProgressPanel (void *priv)
|
||||
{
|
||||
@autoreleasepool {
|
||||
intf_sys_t *sys = (intf_sys_t *)priv;
|
||||
[sys->displayer performSelectorOnMainThread:@selector(destroyProgressPanel)
|
||||
withObject:nil
|
||||
waitUntilDone:YES];
|
||||
}
|
||||
}
|
||||
|
||||
bool checkProgressPanel (void *priv)
|
||||
{
|
||||
@autoreleasepool {
|
||||
intf_sys_t *sys = (intf_sys_t *)priv;
|
||||
return [[sys->displayer resultFromSelectorOnMainThread:@selector(checkProgressPanel)
|
||||
withObject:nil] boolValue];
|
||||
}
|
||||
}
|
||||
|
||||
@interface VLCDialogDisplayer() <NSWindowDelegate>
|
||||
@end
|
||||
|
||||
@implementation VLCDialogDisplayer
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
|
||||
assert(!_currentProgressBarPanel); // This has to be closed on main thread.
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)setIntf: (intf_thread_t *)p_mainintf
|
||||
{
|
||||
p_intf = p_mainintf;
|
||||
}
|
||||
|
||||
- (intf_thread_t *)intf
|
||||
{
|
||||
return p_intf;
|
||||
}
|
||||
|
||||
+ (NSDictionary *)dictionaryForDialog:(const char *)title :(const char *)message :(const char *)yes :(const char *)no :(const char *)cancel
|
||||
{
|
||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||
if (title)
|
||||
[dict setObject:@(title) forKey:@"title"];
|
||||
if (message)
|
||||
[dict setObject:@(message) forKey:@"message"];
|
||||
if (yes)
|
||||
[dict setObject:@(yes) forKey:@"yes"];
|
||||
if (no)
|
||||
[dict setObject:@(no) forKey:@"no"];
|
||||
if (cancel)
|
||||
[dict setObject:@(cancel) forKey:@"cancel"];
|
||||
|
||||
return dict;
|
||||
}
|
||||
#define VLCAssertIsMainThread() assert([NSThread isMainThread])
|
||||
|
||||
- (void)displayError:(NSDictionary *)dialog
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
NSRunInformationalAlertPanel([dialog objectForKey:@"title"],
|
||||
[dialog objectForKey:@"message"],
|
||||
@"OK", nil, nil);
|
||||
}
|
||||
|
||||
- (void)displayCritical:(NSDictionary *)dialog
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
NSRunCriticalAlertPanel([dialog objectForKey:@"title"],
|
||||
[dialog objectForKey:@"message"],
|
||||
@"OK", nil, nil);
|
||||
}
|
||||
|
||||
- (NSNumber *)displayQuestion:(NSDictionary *)dialog
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
NSInteger alertRet = 0;
|
||||
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:[dialog objectForKey:@"title"]
|
||||
defaultButton:[dialog objectForKey:@"yes"]
|
||||
alternateButton:[dialog objectForKey:@"no"]
|
||||
otherButton:[dialog objectForKey:@"cancel"]
|
||||
informativeTextWithFormat:@"%@", [dialog objectForKey:@"message"]];
|
||||
[alert setAlertStyle:NSInformationalAlertStyle];
|
||||
alertRet = [alert runModal];
|
||||
|
||||
int ret;
|
||||
switch (alertRet) {
|
||||
case NSAlertDefaultReturn:
|
||||
ret = 1;
|
||||
break;
|
||||
case NSAlertAlternateReturn:
|
||||
ret = 2;
|
||||
break;
|
||||
case NSAlertOtherReturn:
|
||||
ret = 3;
|
||||
break;
|
||||
default:
|
||||
vlc_assert_unreachable();
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return @(ret);
|
||||
}
|
||||
|
||||
- (NSDictionary *)displayLogin:(NSDictionary *)dialog
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
VLCLoginPanel *panel = [[VLCLoginPanel alloc] init];
|
||||
[panel createContentView];
|
||||
[panel setDialogTitle:[dialog objectForKey:@"title"]];
|
||||
[panel setDialogMessage:[dialog objectForKey:@"message"]];
|
||||
[panel center];
|
||||
NSInteger ret = [NSApp runModalForWindow:panel];
|
||||
[panel close];
|
||||
|
||||
if (!ret)
|
||||
return nil;
|
||||
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[panel userName], @"username",
|
||||
[panel password], @"password",
|
||||
nil];
|
||||
}
|
||||
|
||||
- (void)displayProgressBar:(NSDictionary *)dialog
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
if(_currentProgressBarPanel)
|
||||
[self destroyProgressPanel];
|
||||
|
||||
assert(!_currentProgressBarPanel);
|
||||
_currentProgressBarPanel = [[VLCProgressPanel alloc] init];
|
||||
[_currentProgressBarPanel createContentView];
|
||||
[_currentProgressBarPanel setDialogTitle:[dialog objectForKey:@"title"]];
|
||||
[_currentProgressBarPanel setDialogMessage:[dialog objectForKey:@"message"] ?: @""];
|
||||
[_currentProgressBarPanel setCancelButtonLabel:[dialog objectForKey:@"cancel"]];
|
||||
|
||||
[_currentProgressBarPanel center];
|
||||
[_currentProgressBarPanel makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
- (void)updateProgressPanel:(NSDictionary *)dict
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
assert(_currentProgressBarPanel);
|
||||
[_currentProgressBarPanel setDialogMessage:[dict objectForKey:@"text"] ?: @""];
|
||||
[_currentProgressBarPanel setProgressAsDouble:[[dict objectForKey:@"value"] doubleValue] * 1000.];
|
||||
}
|
||||
|
||||
- (void)destroyProgressPanel
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
[_currentProgressBarPanel close];
|
||||
[_currentProgressBarPanel release];
|
||||
_currentProgressBarPanel = nil;
|
||||
}
|
||||
|
||||
- (NSNumber *)checkProgressPanel
|
||||
{
|
||||
VLCAssertIsMainThread();
|
||||
|
||||
return @([_currentProgressBarPanel isCancelled]);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Last.FM support
|
||||
- (void)globalNotificationReceived: (NSNotification *)theNotification
|
||||
{
|
||||
NSDictionary *userData = [theNotification userInfo];
|
||||
BOOL lastFMEnabled = [[userData objectForKey:@"enabled"] intValue];
|
||||
NSString *lastFMUsername = [userData objectForKey:@"username"];
|
||||
NSString *lastFMPassword = [userData objectForKey:@"password"];
|
||||
|
||||
if (module_exists("audioscrobbler")) {
|
||||
if (lastFMEnabled)
|
||||
config_AddIntf(p_intf, "audioscrobbler");
|
||||
else
|
||||
config_RemoveIntf(p_intf, "audioscrobbler");
|
||||
|
||||
config_PutPsz(p_intf, "lastfm-username", [lastFMUsername UTF8String]);
|
||||
config_PutPsz(p_intf, "lastfm-password", [lastFMPassword UTF8String]);
|
||||
}
|
||||
else
|
||||
msg_Err(p_intf,"Last.FM module not found, no action");
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Extensions Dialog
|
||||
|
||||
- (void)triggerClick:(id)sender
|
||||
{
|
||||
assert([sender isKindOfClass:[VLCDialogButton class]]);
|
||||
VLCDialogButton *button = sender;
|
||||
extension_widget_t *widget = [button widget];
|
||||
|
||||
vlc_mutex_lock(&widget->p_dialog->lock);
|
||||
extension_WidgetClicked(widget->p_dialog, widget);
|
||||
vlc_mutex_unlock(&widget->p_dialog->lock);
|
||||
}
|
||||
|
||||
- (void)syncTextField:(NSNotification *)notifcation
|
||||
{
|
||||
id sender = [notifcation object];
|
||||
assert([sender isKindOfClass:[VLCDialogTextField class]]);
|
||||
VLCDialogTextField *field = sender;
|
||||
extension_widget_t *widget = [field widget];
|
||||
|
||||
vlc_mutex_lock(&widget->p_dialog->lock);
|
||||
free(widget->psz_text);
|
||||
widget->psz_text = strdup([[field stringValue] UTF8String]);
|
||||
vlc_mutex_unlock(&widget->p_dialog->lock);
|
||||
}
|
||||
|
||||
- (void)tableViewSelectionDidChange:(NSNotification *)notifcation
|
||||
{
|
||||
id sender = [notifcation object];
|
||||
assert(sender && [sender isKindOfClass:[VLCDialogList class]]);
|
||||
VLCDialogList *list = sender;
|
||||
|
||||
struct extension_widget_value_t *value;
|
||||
unsigned i = 0;
|
||||
for(value = [list widget]->p_values; value != NULL; value = value->p_next, i++)
|
||||
value->b_selected = (i == [list selectedRow]);
|
||||
}
|
||||
|
||||
- (void)popUpSelectionChanged:(id)sender
|
||||
{
|
||||
assert([sender isKindOfClass:[VLCDialogPopUpButton class]]);
|
||||
VLCDialogPopUpButton *popup = sender;
|
||||
struct extension_widget_value_t *value;
|
||||
unsigned i = 0;
|
||||
for(value = [popup widget]->p_values; value != NULL; value = value->p_next, i++)
|
||||
value->b_selected = (i == [popup indexOfSelectedItem]);
|
||||
|
||||
}
|
||||
|
||||
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize
|
||||
{
|
||||
NSView *contentView = [sender contentView];
|
||||
assert([contentView isKindOfClass:[VLCDialogGridView class]]);
|
||||
VLCDialogGridView *gridView = (VLCDialogGridView *)contentView;
|
||||
|
||||
NSRect rect = NSMakeRect(0, 0, 0, 0);
|
||||
rect.size = frameSize;
|
||||
rect = [sender contentRectForFrameRect:rect];
|
||||
rect.size = [gridView flexSize:rect.size];
|
||||
rect = [sender frameRectForContentRect:rect];
|
||||
return rect.size;
|
||||
}
|
||||
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
assert([sender isKindOfClass:[VLCDialogWindow class]]);
|
||||
VLCDialogWindow *window = sender;
|
||||
extension_dialog_t *dialog = [window dialog];
|
||||
extension_DialogClosed(dialog);
|
||||
dialog->p_sys_intf = NULL;
|
||||
return YES;
|
||||
}
|
||||
|
||||
static NSView *createControlFromWidget(extension_widget_t *widget, id self)
|
||||
{
|
||||
assert(!widget->p_sys_intf);
|
||||
|
||||
switch (widget->type)
|
||||
{
|
||||
case EXTENSION_WIDGET_HTML:
|
||||
{
|
||||
// NSScrollView *scrollView = [[NSScrollView alloc] init];
|
||||
// [scrollView setHasVerticalScroller:YES];
|
||||
// NSTextView *field = [[NSTextView alloc] init];
|
||||
// [scrollView setDocumentView:field];
|
||||
// [scrollView setAutoresizesSubviews:YES];
|
||||
// [scrollView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
|
||||
// [field release];
|
||||
// return scrollView;
|
||||
NSTextView *field = [[NSTextView alloc] init];
|
||||
[field setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
|
||||
[field setDrawsBackground:NO];
|
||||
return field;
|
||||
}
|
||||
case EXTENSION_WIDGET_LABEL:
|
||||
{
|
||||
NSTextField *field = [[NSTextField alloc] init];
|
||||
[field setEditable:NO];
|
||||
[field setBordered:NO];
|
||||
[field setDrawsBackground:NO];
|
||||
[field setFont:[NSFont systemFontOfSize:0]];
|
||||
[[field cell] setControlSize:NSRegularControlSize];
|
||||
[field setAutoresizingMask:NSViewNotSizable];
|
||||
return field;
|
||||
}
|
||||
case EXTENSION_WIDGET_TEXT_FIELD:
|
||||
{
|
||||
VLCDialogTextField *field = [[VLCDialogTextField alloc] init];
|
||||
[field setWidget:widget];
|
||||
[field setAutoresizingMask:NSViewWidthSizable];
|
||||
[field setFont:[NSFont systemFontOfSize:0]];
|
||||
[[field cell] setControlSize:NSRegularControlSize];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(syncTextField:) name:NSControlTextDidChangeNotification object:field];
|
||||
return field;
|
||||
}
|
||||
case EXTENSION_WIDGET_CHECK_BOX:
|
||||
{
|
||||
VLCDialogButton *button = [[VLCDialogButton alloc] init];
|
||||
[button setButtonType:NSSwitchButton];
|
||||
[button setWidget:widget];
|
||||
[button setAction:@selector(triggerClick:)];
|
||||
[button setTarget:self];
|
||||
[[button cell] setControlSize:NSRegularControlSize];
|
||||
[button setAutoresizingMask:NSViewWidthSizable];
|
||||
return button;
|
||||
}
|
||||
case EXTENSION_WIDGET_BUTTON:
|
||||
{
|
||||
VLCDialogButton *button = [[VLCDialogButton alloc] init];
|
||||
[button setBezelStyle:NSRoundedBezelStyle];
|
||||
[button setWidget:widget];
|
||||
[button setAction:@selector(triggerClick:)];
|
||||
[button setTarget:self];
|
||||
[[button cell] setControlSize:NSRegularControlSize];
|
||||
[button setAutoresizingMask:NSViewNotSizable];
|
||||
return button;
|
||||
}
|
||||
case EXTENSION_WIDGET_DROPDOWN:
|
||||
{
|
||||
VLCDialogPopUpButton *popup = [[VLCDialogPopUpButton alloc] init];
|
||||
[popup setAction:@selector(popUpSelectionChanged:)];
|
||||
[popup setTarget:self];
|
||||
[popup setWidget:widget];
|
||||
return popup;
|
||||
}
|
||||
case EXTENSION_WIDGET_LIST:
|
||||
{
|
||||
NSScrollView *scrollView = [[NSScrollView alloc] init];
|
||||
[scrollView setHasVerticalScroller:YES];
|
||||
VLCDialogList *list = [[VLCDialogList alloc] init];
|
||||
[list setUsesAlternatingRowBackgroundColors:YES];
|
||||
[list setHeaderView:nil];
|
||||
[scrollView setDocumentView:list];
|
||||
[scrollView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
|
||||
|
||||
NSTableColumn *column = [[NSTableColumn alloc] init];
|
||||
[list addTableColumn:column];
|
||||
[column release];
|
||||
[list setDataSource:list];
|
||||
[list setDelegate:self];
|
||||
[list setWidget:widget];
|
||||
[list release];
|
||||
return scrollView;
|
||||
}
|
||||
case EXTENSION_WIDGET_IMAGE:
|
||||
{
|
||||
NSImageView *imageView = [[NSImageView alloc] init];
|
||||
[imageView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
|
||||
[imageView setImageFrameStyle:NSImageFramePhoto];
|
||||
[imageView setImageScaling:NSImageScaleProportionallyUpOrDown];
|
||||
return imageView;
|
||||
}
|
||||
case EXTENSION_WIDGET_SPIN_ICON:
|
||||
{
|
||||
NSProgressIndicator *spinner = [[NSProgressIndicator alloc] init];
|
||||
[spinner setUsesThreadedAnimation:YES];
|
||||
[spinner setStyle:NSProgressIndicatorSpinningStyle];
|
||||
[spinner setDisplayedWhenStopped:YES];
|
||||
[spinner startAnimation:self];
|
||||
return spinner;
|
||||
}
|
||||
default:
|
||||
vlc_assert_unreachable();
|
||||
return nil;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void updateControlFromWidget(NSView *control, extension_widget_t *widget, id self)
|
||||
{
|
||||
switch (widget->type)
|
||||
{
|
||||
case EXTENSION_WIDGET_HTML:
|
||||
// {
|
||||
// // Get the scroll view
|
||||
// assert([control isKindOfClass:[NSScrollView class]]);
|
||||
// NSScrollView *scrollView = (NSScrollView *)control;
|
||||
// control = [scrollView documentView];
|
||||
//
|
||||
// assert([control isKindOfClass:[NSTextView class]]);
|
||||
// NSTextView *textView = (NSTextView *)control;
|
||||
// NSString *string = @(widget->psz_text);
|
||||
// NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTML:[string dataUsingEncoding:NSISOLatin1StringEncoding] documentAttributes:NULL];
|
||||
// [[textView textStorage] setAttributedString:[[NSAttributedString alloc] initWithString:@"Hello"]];
|
||||
// [textView setNeedsDisplay:YES];
|
||||
// [textView scrollRangeToVisible:NSMakeRange(0, 0)];
|
||||
// [attrString release];
|
||||
// break;
|
||||
//
|
||||
// }
|
||||
{
|
||||
assert([control isKindOfClass:[NSTextView class]]);
|
||||
NSTextView *textView = (NSTextView *)control;
|
||||
NSString *string = @(widget->psz_text);
|
||||
NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTML:[string dataUsingEncoding:NSISOLatin1StringEncoding] documentAttributes:NULL];
|
||||
[[textView textStorage] setAttributedString:attrString];
|
||||
[textView setNeedsDisplay:YES];
|
||||
[textView scrollRangeToVisible:NSMakeRange(0, 0)];
|
||||
[attrString release];
|
||||
break;
|
||||
|
||||
}
|
||||
case EXTENSION_WIDGET_LABEL:
|
||||
case EXTENSION_WIDGET_PASSWORD:
|
||||
case EXTENSION_WIDGET_TEXT_FIELD:
|
||||
{
|
||||
if (!widget->psz_text)
|
||||
break;
|
||||
assert([control isKindOfClass:[NSControl class]]);
|
||||
NSControl *field = (NSControl *)control;
|
||||
NSString *string = @(widget->psz_text);
|
||||
NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTML:[string dataUsingEncoding:NSISOLatin1StringEncoding] documentAttributes:NULL];
|
||||
[field setAttributedStringValue:attrString];
|
||||
[attrString release];
|
||||
break;
|
||||
}
|
||||
case EXTENSION_WIDGET_CHECK_BOX:
|
||||
case EXTENSION_WIDGET_BUTTON:
|
||||
{
|
||||
assert([control isKindOfClass:[NSButton class]]);
|
||||
NSButton *button = (NSButton *)control;
|
||||
if (!widget->psz_text)
|
||||
break;
|
||||
[button setTitle:@(widget->psz_text)];
|
||||
break;
|
||||
}
|
||||
case EXTENSION_WIDGET_DROPDOWN:
|
||||
{
|
||||
assert([control isKindOfClass:[NSPopUpButton class]]);
|
||||
NSPopUpButton *popup = (NSPopUpButton *)control;
|
||||
[popup removeAllItems];
|
||||
struct extension_widget_value_t *value;
|
||||
for(value = widget->p_values; value != NULL; value = value->p_next)
|
||||
{
|
||||
[popup addItemWithTitle:@(value->psz_text)];
|
||||
}
|
||||
[popup synchronizeTitleAndSelectedItem];
|
||||
[self popUpSelectionChanged:popup];
|
||||
break;
|
||||
}
|
||||
|
||||
case EXTENSION_WIDGET_LIST:
|
||||
{
|
||||
assert([control isKindOfClass:[NSScrollView class]]);
|
||||
NSScrollView *scrollView = (NSScrollView *)control;
|
||||
assert([[scrollView documentView] isKindOfClass:[VLCDialogList class]]);
|
||||
VLCDialogList *list = (VLCDialogList *)[scrollView documentView];
|
||||
|
||||
NSMutableArray *contentArray = [NSMutableArray array];
|
||||
struct extension_widget_value_t *value;
|
||||
for(value = widget->p_values; value != NULL; value = value->p_next)
|
||||
{
|
||||
NSDictionary *entry = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@(value->i_id), @"id",
|
||||
@(value->psz_text), @"text",
|
||||
nil];
|
||||
[contentArray addObject:entry];
|
||||
}
|
||||
list.contentArray = contentArray;
|
||||
[list reloadData];
|
||||
break;
|
||||
}
|
||||
case EXTENSION_WIDGET_IMAGE:
|
||||
{
|
||||
assert([control isKindOfClass:[NSImageView class]]);
|
||||
NSImageView *imageView = (NSImageView *)control;
|
||||
NSString *string = widget->psz_text ? @(widget->psz_text) : nil;
|
||||
NSImage *image = nil;
|
||||
if (string)
|
||||
image = [[NSImage alloc] initWithContentsOfURL:[NSURL fileURLWithPath:string]];
|
||||
[imageView setImage:image];
|
||||
[image release];
|
||||
break;
|
||||
}
|
||||
case EXTENSION_WIDGET_SPIN_ICON:
|
||||
{
|
||||
assert([control isKindOfClass:[NSProgressIndicator class]]);
|
||||
NSProgressIndicator *progressIndicator = (NSProgressIndicator *)control;
|
||||
if( widget->i_spin_loops != 0 )
|
||||
[progressIndicator startAnimation:self];
|
||||
else
|
||||
[progressIndicator stopAnimation:self];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)updateWidgets:(extension_dialog_t *)dialog
|
||||
{
|
||||
extension_widget_t *widget;
|
||||
NSWindow *window = dialog->p_sys_intf;
|
||||
FOREACH_ARRAY(widget, dialog->widgets)
|
||||
{
|
||||
if (!widget)
|
||||
continue; /* Some widgets may be NULL at this point */
|
||||
|
||||
BOOL shouldDestroy = widget->b_kill;
|
||||
NSView *control = widget->p_sys_intf;
|
||||
BOOL update = widget->b_update;
|
||||
|
||||
|
||||
if (!control && !shouldDestroy)
|
||||
{
|
||||
control = createControlFromWidget(widget, self);
|
||||
updateControlFromWidget(control, widget, self);
|
||||
widget->p_sys_intf = control;
|
||||
update = YES; // Force update and repositionning
|
||||
[control setHidden:widget->b_hide];
|
||||
}
|
||||
|
||||
if (update && !shouldDestroy)
|
||||
{
|
||||
updateControlFromWidget(control, widget, self);
|
||||
[control setHidden:widget->b_hide];
|
||||
|
||||
int row = widget->i_row - 1;
|
||||
int col = widget->i_column - 1;
|
||||
int hsp = __MAX( 1, widget->i_horiz_span );
|
||||
int vsp = __MAX( 1, widget->i_vert_span );
|
||||
if( row < 0 )
|
||||
{
|
||||
row = 4;
|
||||
col = 0;
|
||||
}
|
||||
|
||||
VLCDialogGridView *gridView = (VLCDialogGridView *)[window contentView];
|
||||
[gridView addSubview:control atRow:row column:col rowSpan:vsp colSpan:hsp];
|
||||
|
||||
//this->resize( sizeHint() );
|
||||
widget->b_update = false;
|
||||
}
|
||||
|
||||
if (shouldDestroy)
|
||||
{
|
||||
VLCDialogGridView *gridView = (VLCDialogGridView *)[window contentView];
|
||||
[gridView removeSubview:control];
|
||||
[control release];
|
||||
widget->p_sys_intf = NULL;
|
||||
}
|
||||
}
|
||||
FOREACH_END()
|
||||
}
|
||||
|
||||
- (void)updateExtensionDialog:(NSValue *)extensionDialog
|
||||
{
|
||||
extension_dialog_t *dialog = [extensionDialog pointerValue];
|
||||
|
||||
vlc_mutex_lock(&dialog->lock);
|
||||
|
||||
NSSize size = NSMakeSize(dialog->i_width, dialog->i_height);
|
||||
|
||||
BOOL shouldDestroy = dialog->b_kill;
|
||||
|
||||
if (!dialog->i_width || !dialog->i_height)
|
||||
size = NSMakeSize(640, 480);
|
||||
|
||||
VLCDialogWindow *window = dialog->p_sys_intf;
|
||||
if (!window && !shouldDestroy)
|
||||
{
|
||||
NSRect content = NSMakeRect(0, 0, 1, 1);
|
||||
window = [[VLCDialogWindow alloc] initWithContentRect:content styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask backing:NSBackingStoreBuffered defer:NO];
|
||||
[window setDelegate:self];
|
||||
[window setDialog:dialog];
|
||||
[window setTitle:@(dialog->psz_title)];
|
||||
VLCDialogGridView *gridView = [[VLCDialogGridView alloc] init];
|
||||
[gridView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable];
|
||||
[window setContentView:gridView];
|
||||
[gridView release];
|
||||
dialog->p_sys_intf = window;
|
||||
}
|
||||
|
||||
[self updateWidgets:dialog];
|
||||
|
||||
if (shouldDestroy)
|
||||
{
|
||||
[window setDelegate:nil];
|
||||
[window close];
|
||||
dialog->p_sys_intf = NULL;
|
||||
window = nil;
|
||||
}
|
||||
|
||||
if (![window isVisible]) {
|
||||
[window center];
|
||||
[window makeKeyAndOrderFront:self];
|
||||
}
|
||||
|
||||
vlc_cond_signal(&dialog->cond);
|
||||
vlc_mutex_unlock(&dialog->lock);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to execute a function on main thread and get its return value.
|
||||
*/
|
||||
- (void)execute:(NSDictionary *)dict
|
||||
{
|
||||
SEL sel = [[dict objectForKey:@"sel"] pointerValue];
|
||||
id *result = [[dict objectForKey:@"result"] pointerValue];
|
||||
id object = [dict objectForKey:@"object"];
|
||||
|
||||
NSAssert(sel, @"Try to execute a NULL selector");
|
||||
|
||||
*result = [self performSelector:sel withObject:object];
|
||||
[*result retain]; // Balanced in -resultFromSelectorOnMainThread
|
||||
}
|
||||
|
||||
- (id)resultFromSelectorOnMainThread:(SEL)sel withObject:(id)object
|
||||
{
|
||||
id result = nil;
|
||||
NSAssert(sel, @"Try to execute a NULL selector");
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSValue valueWithPointer:sel], @"sel",
|
||||
[NSValue valueWithPointer:&result], @"result",
|
||||
object, @"object", nil];
|
||||
[self performSelectorOnMainThread:@selector(execute:) withObject:dict waitUntilDone:YES];
|
||||
return [result autorelease];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
|
@ -555,11 +555,6 @@ modules/gui/macosx/coredialogs.h
|
||||
modules/gui/macosx/coredialogs.m
|
||||
modules/gui/macosx/CoreInteraction.h
|
||||
modules/gui/macosx/CoreInteraction.m
|
||||
modules/gui/macosx_dialog_provider/dialogProvider.m
|
||||
modules/gui/macosx_dialog_provider/VLCLoginPanel.h
|
||||
modules/gui/macosx_dialog_provider/VLCLoginPanel.m
|
||||
modules/gui/macosx_dialog_provider/VLCProgressPanel.h
|
||||
modules/gui/macosx_dialog_provider/VLCProgressPanel.m
|
||||
modules/gui/macosx/ExtensionsDialogProvider.h
|
||||
modules/gui/macosx/ExtensionsDialogProvider.m
|
||||
modules/gui/macosx/ExtensionsManager.h
|
||||
|
Loading…
Reference in New Issue
Block a user