Commit 8db7da13 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: added 2 new classes for generic dialogs to enter text or to select stuff in a popup

parent 86486412
......@@ -258,6 +258,7 @@
CC402F440E00ABBB006A4BA4 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC962E2C0CC7992800A56695 /* WebKit.framework */; };
CC426FD11020D44F00A32659 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC426FD01020D44F00A32659 /* Sparkle.framework */; };
CC426FD71020D47100A32659 /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = CC426FD01020D44F00A32659 /* Sparkle.framework */; };
CC461F75160084A10022423C /* SharedDialogs.xib in Resources */ = {isa = PBXBuildFile; fileRef = CC461F73160084A10022423C /* SharedDialogs.xib */; };
CC4EFC2D13E96BD00091D19A /* dropzone.png in Resources */ = {isa = PBXBuildFile; fileRef = CC4EFC2C13E96BD00091D19A /* dropzone.png */; };
CC5800F51423A80400166912 /* bottombar-mini.png in Resources */ = {isa = PBXBuildFile; fileRef = CC5800F41423A80400166912 /* bottombar-mini.png */; };
CC5800F71423A81500166912 /* bottombar-mini.png in Resources */ = {isa = PBXBuildFile; fileRef = CC5800F61423A81500166912 /* bottombar-mini.png */; };
......@@ -745,6 +746,9 @@
CC448A6113B68A0B009F72E0 /* CoreInteraction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CoreInteraction.m; path = ../../../modules/gui/macosx/CoreInteraction.m; sourceTree = "<group>"; };
CC448A6213B68A0B009F72E0 /* MainWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MainWindow.h; path = ../../../modules/gui/macosx/MainWindow.h; sourceTree = "<group>"; };
CC448A6313B68A0B009F72E0 /* MainWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = MainWindow.m; path = ../../../modules/gui/macosx/MainWindow.m; sourceTree = "<group>"; };
CC461F6C160078340022423C /* SharedDialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharedDialogs.h; path = ../../../modules/gui/macosx/SharedDialogs.h; sourceTree = "<group>"; };
CC461F6D160078340022423C /* SharedDialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SharedDialogs.m; path = ../../../modules/gui/macosx/SharedDialogs.m; sourceTree = "<group>"; };
CC461F74160084A10022423C /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/SharedDialogs.xib; sourceTree = "<group>"; };
CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
CC4A33220F8CB017000FC4A7 /* coredialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coredialogs.h; path = ../../../modules/gui/macosx/coredialogs.h; sourceTree = SOURCE_ROOT; };
CC4D67F71348F601003FCC5B /* darwin_specific.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = darwin_specific.c; path = ../../../src/posix/darwin_specific.c; sourceTree = "<group>"; };
......@@ -1094,6 +1098,8 @@
CC0663351566C34C003A411C /* ConvertAndSave.m */,
CC269A4615E7947F00F2FDC9 /* StringUtility.h */,
CC269A4715E7947F00F2FDC9 /* StringUtility.m */,
CC461F6C160078340022423C /* SharedDialogs.h */,
CC461F6D160078340022423C /* SharedDialogs.m */,
CC017A0E14A4C8B600C09A4F /* custom UI code */,
CC0CD0E513DE0FC600B0D90D /* Imported Code */,
);
......@@ -1718,6 +1724,7 @@
CCD83E4213FEA143004F1652 /* Wizard.xib */,
CCD83E2B13FE9B90004F1652 /* MainMenu.xib */,
CC0663371566CD5A003A411C /* ConvertAndSave.xib */,
CC461F73160084A10022423C /* SharedDialogs.xib */,
);
name = xibs;
sourceTree = "<group>";
......@@ -2187,6 +2194,7 @@
CC16700215F5178B0088201B /* forward-6btns-dark-pressed@2x.png in Resources */,
CC16700315F5178B0088201B /* forward-6btns-dark.png in Resources */,
CC16700415F5178B0088201B /* forward-6btns-dark@2x.png in Resources */,
CC461F75160084A10022423C /* SharedDialogs.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -2201,6 +2209,14 @@
name = ConvertAndSave.xib;
sourceTree = "<group>";
};
CC461F73160084A10022423C /* SharedDialogs.xib */ = {
isa = PBXVariantGroup;
children = (
CC461F74160084A10022423C /* English */,
);
name = SharedDialogs.xib;
sourceTree = "<group>";
};
CCD83E2B13FE9B90004F1652 /* MainMenu.xib */ = {
isa = PBXVariantGroup;
children = (
......
......@@ -78,5 +78,6 @@ SOURCES_macosx = \
MainWindowTitle.m \
ConvertAndSave.h \
ConvertAndSave.m \
SharedDialogs.h \
SharedDialogs.m \
$(NULL)
/*****************************************************************************
* SharedDialogs.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2012 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
@interface VLCEnterTextPanel : NSObject
{
IBOutlet id _panel;
IBOutlet id _title_lbl;
IBOutlet id _subtitle_lbl;
IBOutlet id _text_fld;
IBOutlet id _cancel_btn;
IBOutlet id _ok_btn;
NSString * _title;
NSString * _subtitle;
NSString * _okTitle;
NSString * _cancelTitle;
id _target;
}
+ (VLCEnterTextPanel *)sharedInstance;
@property (readwrite, assign) NSString *title;
@property (readwrite, assign) NSString *subTitle;
@property (readwrite, assign) NSString *OKButtonLabel;
@property (readwrite, assign) NSString *CancelButtonLabel;
@property (readwrite, assign) id target;
@property (readonly) NSString *enteredText;
- (void)runModalForWindow:(NSWindow *)window;
- (IBAction)windowElementAction:(id)sender;
@end
@protocol VLCEnterTextPanel <NSObject>
@optional
- (void)panel:(VLCEnterTextPanel *)view returnValue:(NSUInteger)value text:(NSString *)text;
@end
@interface VLCSelectItemInPopupPanel : NSObject
{
IBOutlet id _panel;
IBOutlet id _title_lbl;
IBOutlet id _subtitle_lbl;
IBOutlet id _pop;
IBOutlet id _cancel_btn;
IBOutlet id _ok_btn;
NSString * _title;
NSString * _subtitle;
NSString * _okTitle;
NSString * _cancelTitle;
NSArray * _popData;
id _target;
}
+ (VLCSelectItemInPopupPanel *)sharedInstance;
@property (readwrite, assign) NSString *title;
@property (readwrite, assign) NSString *subTitle;
@property (readwrite, assign) NSString *OKButtonLabel;
@property (readwrite, assign) NSString *CancelButtonLabel;
@property (readwrite, assign) NSArray *popupButtonContent;
@property (readwrite, assign) id target;
@property (readonly) NSUInteger currentItem;
- (void)runModalForWindow:(NSWindow *)window;
- (IBAction)windowElementAction:(id)sender;
@end
@protocol VLCSelectItemInPopupPanel <NSObject>
@optional
- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item;
@end
/*****************************************************************************
* SharedDialogs.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2012 Felix Paul Kühne
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "SharedDialogs.h"
static VLCEnterTextPanel *_textPanelInstance = nil;
static VLCSelectItemInPopupPanel *_selectItemPanelInstance = nil;
@implementation VLCEnterTextPanel
+ (VLCEnterTextPanel *)sharedInstance
{
return _textPanelInstance ? _textPanelInstance : [[self alloc] init];
}
- (id)init
{
if (_textPanelInstance)
[self dealloc];
else
_textPanelInstance = [super init];
return _textPanelInstance;
}
@synthesize title=_title, subTitle=_subtitle, OKButtonLabel=_okTitle, CancelButtonLabel=_cancelTitle, target=_target;
- (IBAction)windowElementAction:(id)sender
{
[_panel orderOut:sender];
[NSApp endSheet: _panel];
if (self.target) {
if ([self.target respondsToSelector:@selector(panel:returnValue:text:)]) {
if (sender == _cancel_btn)
[self.target panel:self returnValue:NSCancelButton text:NULL];
else
[self.target panel:self returnValue:NSOKButton text:self.enteredText];
}
}
}
- (void)runModalForWindow:(NSWindow *)window
{
[_title_lbl setStringValue:self.title];
[_subtitle_lbl setStringValue:self.subTitle];
[_cancel_btn setTitle:self.CancelButtonLabel];
[_ok_btn setTitle:self.OKButtonLabel];
[_text_fld setStringValue:@""];
[NSApp beginSheet:_panel modalForWindow:window modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
- (NSString *)enteredText
{
return [_text_fld stringValue];
}
@end
@implementation VLCSelectItemInPopupPanel
@synthesize title=_title, subTitle=_subtitle, OKButtonLabel=_okTitle, CancelButtonLabel=_cancelTitle, popupButtonContent=_popData, target=_target;
+ (VLCSelectItemInPopupPanel *)sharedInstance
{
return _selectItemPanelInstance ? _selectItemPanelInstance : [[self alloc] init];
}
- (id)init
{
if (_selectItemPanelInstance)
[self dealloc];
else
_selectItemPanelInstance = [super init];
return _selectItemPanelInstance;
}
- (IBAction)windowElementAction:(id)sender
{
[_panel orderOut:sender];
[NSApp endSheet: _panel];
if (self.target) {
if ([self.target respondsToSelector:@selector(panel:returnValue:item:)]) {
if (sender == _cancel_btn)
[self.target panel:self returnValue:NSCancelButton item:0];
else
[self.target panel:self returnValue:NSOKButton item:self.currentItem];
}
}
}
- (void)runModalForWindow:(NSWindow *)window
{
[_title_lbl setStringValue:self.title];
[_subtitle_lbl setStringValue:self.subTitle];
[_cancel_btn setTitle:self.CancelButtonLabel];
[_ok_btn setTitle:self.OKButtonLabel];
[_pop removeAllItems];
[_pop addItemsWithTitles:self.popupButtonContent];
[NSApp beginSheet:_panel modalForWindow:window modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
- (NSUInteger)currentItem
{
return [_pop indexOfSelectedItem];
}
@end
......@@ -593,8 +593,9 @@ static VLCMain *_o_sharedMainInstance = nil;
var_SetBool(p_playlist, "fullscreen", YES);
}
/* load our Core Dialogs nib */
/* load our Core and Shared Dialogs nibs */
nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
[NSBundle loadNibNamed:@"SharedDialogs" owner: NSApp];
/* subscribe to various interactive dialogues */
var_Create(p_intf, "dialog-error", VLC_VAR_ADDRESS);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment