Currently only used to display the question, login, error and critical core dialogs whenever VLC runs with a GUI on a Mac.
Disabled by default. The login dialog's layout will need some more love.
if test "x${enable_macosx}" = "xyes"
then
VLC_ADD_LDFLAGS([access_eyetv], [-Wl,-framework,Foundation])
- VLC_ADD_LDFLAGS([macosx minimal_macosx opengllayer qtcapture],[-Wl,-framework,Cocoa])
+ VLC_ADD_LDFLAGS([macosx minimal_macosx macosx_dialog_provider opengllayer qtcapture],[-Wl,-framework,Cocoa])
VLC_ADD_LDFLAGS([macosx minimal_macosx opengllayer],[-Wl,-framework,OpenGL])
VLC_ADD_LDFLAGS([macosx minimal_macosx], [-Wl,-framework,Carbon])
VLC_ADD_LDFLAGS([macosx minimal_macosx], [-Wl,-framework,CoreServices])
VLC_ADD_PLUGIN([macosx])
VLC_ADD_PLUGIN([minimal_macosx])
VLC_ADD_PLUGIN([opengllayer])
+ VLC_ADD_PLUGIN([macosx_dialog_provider])
fi
dnl
[ --enable-macosx-minimal minimal Mac OS X support (default disabled)])
if test "x${enable_macosx_minimal}" = "xyes"
then
- VLC_ADD_LDFLAGS([vout_macosx qtcapture],[-Wl,-framework,Cocoa])
+ VLC_ADD_LDFLAGS([vout_macosx qtcapture macosx_dialog_provider],[-Wl,-framework,Cocoa])
VLC_ADD_LDFLAGS([vout_macosx], [-Wl,-framework,OpenGL])
VLC_ADD_LDFLAGS([qtcapture], [-Wl,-framework,QTKit])
VLC_ADD_LDFLAGS([qtcapture], [-Wl,-framework,CoreAudio])
- VLC_ADD_LDFLAGS([qtcapture], [-Wl,-framework,QuartzCore])
+ VLC_ADD_LDFLAGS([opengllayer qtcapture], [-Wl,-framework,QuartzCore])
VLC_ADD_LDFLAGS([qtcapture], [-Wl,-framework,CoreVideo])
VLC_ADD_OBJCFLAGS([vout_macosx], [-fobjc-exceptions] )
VLC_ADD_PLUGIN([qtcapture])
- VLC_ADD_PLUGIN([vout_macosx])
+ VLC_ADD_PLUGIN([minimal_macosx])
+ VLC_ADD_PLUGIN([opengllayer])
+ VLC_ADD_PLUGIN([macosx_dialog_provider])
fi
dnl
modules/gui/macosx/Makefile
modules/gui/hildon/Makefile
modules/gui/minimal_macosx/Makefile
+ modules/gui/macosx_dialog_provider/Makefile
modules/gui/qnx/Makefile
modules/gui/qt4/Makefile
modules/gui/skins2/Makefile
CC0FB34B0F8BED1100F057F7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/CoreDialogs.nib; sourceTree = "<group>"; };
CC1941240B9C1F8400635F6B /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
CC1C41D00D9BAD7F002728FA /* noart.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = noart.png; path = Resources/noart.png; sourceTree = "<group>"; };
- CC26BF3109A7A08C00E94D62 /* update.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = update.h; path = ../../../modules/gui/macosx/update.h; sourceTree = SOURCE_ROOT; };
- CC26BF3209A7A08C00E94D62 /* update.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = update.m; path = ../../../modules/gui/macosx/update.m; sourceTree = SOURCE_ROOT; };
CC33C2200D2572DE008C4683 /* pause_embedded_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = pause_embedded_graphite.png; path = Resources/pause_embedded_graphite.png; sourceTree = "<group>"; };
CC33C2210D2572DE008C4683 /* play_embedded_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = play_embedded_graphite.png; path = Resources/play_embedded_graphite.png; sourceTree = "<group>"; };
CC33C2400D2578F5008C4683 /* add_embedded_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_embedded_graphite.png; path = Resources/add_embedded_graphite.png; sourceTree = "<group>"; };
CCCB86D80ACFDFB300CF1E10 /* fs_stop_highlight.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fs_stop_highlight.png; path = Resources/fs_stop_highlight.png; sourceTree = "<group>"; };
CCCB86D90ACFDFB300CF1E10 /* fs_stop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fs_stop.png; path = Resources/fs_stop.png; sourceTree = "<group>"; };
CCCB86DA0ACFDFB300CF1E10 /* fs_background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fs_background.png; path = Resources/fs_background.png; sourceTree = "<group>"; };
+ CCD590F010E5B73200D39094 /* dialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dialogProvider.h; path = ../../../modules/gui/macosx_dialog_provider/dialogProvider.h; sourceTree = SOURCE_ROOT; };
+ CCD590F110E5B73200D39094 /* dialogProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = dialogProvider.m; path = ../../../modules/gui/macosx_dialog_provider/dialogProvider.m; sourceTree = SOURCE_ROOT; };
+ CCD590F210E5B76300D39094 /* VLCLoginPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCLoginPanel.h; path = ../../../modules/gui/macosx_dialog_provider/VLCLoginPanel.h; sourceTree = SOURCE_ROOT; };
+ CCD590F310E5B76300D39094 /* VLCLoginPanel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCLoginPanel.m; path = ../../../modules/gui/macosx_dialog_provider/VLCLoginPanel.m; sourceTree = SOURCE_ROOT; };
CCD90F4B0E87C86D0034564A /* add_schedule.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_schedule.png; path = Resources/add_schedule.png; sourceTree = "<group>"; };
CCD90F4C0E87C86D0034564A /* add_vod.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_vod.png; path = Resources/add_vod.png; sourceTree = "<group>"; };
CCD90F4D0E87C86D0034564A /* add_broadcast.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_broadcast.png; path = Resources/add_broadcast.png; sourceTree = "<group>"; };
089C166AFE841209C02AAC07 /* vlc */ = {
isa = PBXGroup;
children = (
+ CCD590EF10E5B71300D39094 /* Minimal Dialog Provider */,
CC6C01A40DDF3E7800C7D754 /* Minimal Mac OS X Classes */,
CCC8957F0D9A8A61005AE59C /* OSX-specific source files */,
08FB77AFFE84173DC02AAC07 /* Classes */,
DC7F46F108A187F60027DB24 /* extended.m */,
DCE7BD0708A5724D007B10AE /* bookmarks.h */,
DCE7BD0608A5724D007B10AE /* bookmarks.m */,
- CC26BF3109A7A08C00E94D62 /* update.h */,
- CC26BF3209A7A08C00E94D62 /* update.m */,
CC6D8D9C0A878DED006F2BBE /* AppleRemote.h */,
CC6D8D9D0A878DED006F2BBE /* AppleRemote.m */,
CCC593780AB4A9FB0004FF52 /* embeddedwindow.h */,
name = "Native FSPanel icons";
sourceTree = "<group>";
};
+ CCD590EF10E5B71300D39094 /* Minimal Dialog Provider */ = {
+ isa = PBXGroup;
+ children = (
+ CCD590F010E5B73200D39094 /* dialogProvider.h */,
+ CCD590F110E5B73200D39094 /* dialogProvider.m */,
+ CCD590F210E5B76300D39094 /* VLCLoginPanel.h */,
+ CCD590F310E5B76300D39094 /* VLCLoginPanel.m */,
+ );
+ name = "Minimal Dialog Provider";
+ sourceTree = "<group>";
+ };
CCD90F4A0E87C82D0034564A /* VLM */ = {
isa = PBXGroup;
children = (
-DIST_SUBDIRS = beos macosx hildon minimal_macosx qnx qt4 skins2
+DIST_SUBDIRS = beos macosx hildon minimal_macosx qnx qt4 skins2 macosx_dialog_provider
SUBDIRS =
if HAVE_BEOS
SUBDIRS += beos
endif
if HAVE_DARWIN
-SUBDIRS += macosx minimal_macosx
+SUBDIRS += macosx minimal_macosx macosx_dialog_provider
endif
if BUILD_HILDON
SUBDIRS += hildon
NSArray * o_mpga;
NSArray * o_mp3;
-// NSArray * o_mp4a;
+ NSArray * o_mp4a;
NSArray * o_a52;
NSArray * o_vorb;
NSArray * o_flac;
_NS("MPEG Audio Layer 3 (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG "
"and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG",
@"MUX_RAW", @"-1", @"-1", @"-1", nil];
-/* o_mp4a = [NSArray arrayWithObjects: @"MPEG 4 Audio", @"mp4a",
+ o_mp4a = [NSArray arrayWithObjects: @"MPEG 4 Audio", @"mp4a",
_NS("Audio format for MPEG4 (useable with MPEG TS and MPEG4)"), @"MUX_TS",
- @"MUX_MP4", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil]; */
+ @"MUX_MP4", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", @"-1", nil];
o_a52 = [NSArray arrayWithObjects: @"A/52", @"a52",
_NS("DVD audio format (useable with MPEG PS, MPEG TS, MPEG1, ASF, OGG "
"and RAW)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_OGG",
_NS("Dummy codec (do not transcode, useable with all encapsulation "
"formats)"), @"MUX_PS", @"MUX_TS", @"MUX_MPEG", @"MUX_ASF", @"MUX_MP4",
@"MUX_OGG", @"MUX_RAW", @"MUX_MOV", @"MUX_WAV", nil];
- o_audioCodecs = [[NSArray alloc] initWithObjects: o_mpga, o_mp3, //o_mp4a,
+ o_audioCodecs = [[NSArray alloc] initWithObjects: o_mpga, o_mp3, o_mp4a,
o_a52, o_vorb, o_flac, o_spx, o_s16l, o_fl32, o_dummyAud, nil];
--- /dev/null
+# Automake forgets to add a proper tag to libtool with Objective-C files.
+# Moreocer Libtool should default tag to CC when none is specified but
+# obviously does not. Here is a fix for that.
+LIBTOOL=@LIBTOOL@ --tag=CC
+
+SOURCES_macosx_dialog_provider = \
+ VLCLoginPanel.m \
+ dialogProvider.m \
+ $(NULL)
+
+noinst_HEADERS = \
+ VLCLoginPanel.h
--- /dev/null
+/*****************************************************************************
+ * VLCLoginPanel.h: A Generic Login Panel created for VLC
+ *****************************************************************************
+ * Copyright (C) 2009-2010 the VideoLAN team
+ * $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>
+
+
+@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
--- /dev/null
+/*****************************************************************************
+ * VLCLoginPanel.m: A Generic Login Panel created for VLC
+ *****************************************************************************
+ * Copyright (C) 2009-2010 the VideoLAN team
+ * $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 "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];
+}
+
+#define addButton( theButton, ox, oy, title, action ) \
+s_rc.origin.x = ox; \
+s_rc.origin.y = oy; \
+s_rc.size.height = 32; \
+s_rc.size.width = 108; \
+theButton = [[NSButton alloc] initWithFrame:s_rc]; \
+[theButton setButtonType:NSMomentaryLightButton]; \
+[theButton setTitle:title]; \
+[theButton setBordered:NO]; \
+[theButton setTarget:self]; \
+[theButton setAction:@selector(action:)]; \
+[ourContentView addSubview:theButton]
+
+- (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:)];
+ [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:)];
+ [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:@"User Name"];
+ [_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
--- /dev/null
+//
+// dialogProvider.h
+//
+//
+// Created by Felix Paul Kühne on 26.12.09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface dialogProvider : NSObject {
+
+}
+
+@end
--- /dev/null
+/*****************************************************************************
+ * dialogProvider.m: Minimal Dialog Provider for Mac OS X
+ *****************************************************************************
+ * Copyright (C) 2009-2010 the VideoLAN team
+ * $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.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * 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_interface.h>
+
+#import <Cocoa/Cocoa.h>
+#import "VLCLoginPanel.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 * );
+
+struct intf_sys_t
+{
+ vlc_mutex_t lock;
+ vlc_cond_t wait;
+};
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+
+vlc_module_begin()
+/* Minimal interface. see intf.m */
+set_shortname("Mac OS X Dialogs")
+add_shortcut("macosx_dialog_provider")
+add_shortcut("miosx")
+set_description("Minimal Mac OS X Dialog Provider")
+set_capability("interface", 50)
+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->b_should_run_on_first_thread = true;
+ p_intf->pf_run = Run;
+
+ msg_Dbg(p_intf,"Opening Mac OS X dialog provider");
+ return VLC_SUCCESS;
+}
+
+/*****************************************************************************
+ * Run: waiting for the death
+ *****************************************************************************/
+static void Run( intf_thread_t *p_intf )
+{
+ /* subscribe to various interactive dialogues */
+ 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);
+ dialog_Register(p_intf);
+
+ msg_Dbg(p_intf,"Mac OS X dialog provider initialised");
+
+ /* idle */
+ while(vlc_object_alive(p_intf))
+ {
+ sleep( 100000 );
+ }
+
+ /* unsubscribe from the interactive dialogues */
+ dialog_Unregister(p_intf );
+ 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);
+}
+/*****************************************************************************
+ * CloseIntf: destroy interface
+ *****************************************************************************/
+void CloseIntf(vlc_object_t *p_this)
+{
+ intf_thread_t *p_intf = (intf_thread_t*) p_this;
+
+ 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)
+{
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ dialog_fatal_t *p_dialog = (dialog_fatal_t *)value.p_address;
+ NSRunInformationalAlertPanel([NSString stringWithUTF8String:p_dialog->title],
+ [NSString stringWithUTF8String:p_dialog->message],
+ @"OK", nil, nil);
+ [o_pool release];
+}
+
+static int DisplayCritical(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
+{
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ dialog_fatal_t *p_dialog = (dialog_fatal_t *)value.p_address;
+ NSRunCriticalAlertPanel([NSString stringWithUTF8String:p_dialog->title],
+ [NSString stringWithUTF8String:p_dialog->message],
+ @"OK", nil, nil);
+ [o_pool release];
+}
+
+static int DisplayQuestion(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
+{
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ dialog_question_t *p_dialog = (dialog_question_t *)value.p_address;
+ NSAlert *o_alert;
+ NSString *o_yes, *o_no, *o_cancel;
+ NSInteger i_returnValue = 0;
+
+ if (p_dialog->yes != NULL)
+ o_yes = [NSString stringWithUTF8String:p_dialog->yes];
+ if (p_dialog->no != NULL)
+ o_no = [NSString stringWithUTF8String:p_dialog->no];
+ if (p_dialog->cancel != NULL)
+ o_cancel = [NSString stringWithUTF8String:p_dialog->cancel];
+
+ o_alert = [NSAlert alertWithMessageText:[NSString stringWithUTF8String:p_dialog->title]
+ defaultButton:o_yes
+ alternateButton:o_no
+ otherButton:o_cancel
+ informativeTextWithFormat:[NSString stringWithUTF8String:p_dialog->message]];
+ [o_alert setAlertStyle:NSInformationalAlertStyle];
+ i_returnValue = [o_alert runModal];
+
+ if (i_returnValue == NSAlertDefaultReturn)
+ p_dialog->answer = 1;
+ if (i_returnValue == NSAlertAlternateReturn)
+ p_dialog->answer = 2;
+ if (i_returnValue == NSAlertOtherReturn)
+ p_dialog->answer = 3;
+ [o_pool release];
+}
+
+static int DisplayLogin(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
+{
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+ dialog_login_t *p_dialog = (dialog_login_t *)value.p_address;
+ NSInteger i_returnValue = 0;
+ VLCLoginPanel *thePanel = [[VLCLoginPanel alloc] init];
+ [thePanel createContentView];
+ [thePanel setDialogTitle:[NSString stringWithUTF8String:p_dialog->title]];
+ [thePanel setDialogMessage:[NSString stringWithUTF8String:p_dialog->message]];
+ [thePanel center];
+ i_returnValue = [NSApp runModalForWindow: thePanel];
+ [thePanel close];
+ if( i_returnValue )
+ {
+ *p_dialog->username = strdup( [[thePanel userName] UTF8String] );
+ *p_dialog->password = strdup( [[thePanel password] UTF8String] );
+ }
+ else
+ {
+ *p_dialog->username = *p_dialog->password = NULL;
+ }
+ [o_pool release];
+}