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

CAS: use the generic dialogs to fetch a text input from the user or to let...

CAS: use the generic dialogs to fetch a text input from the user or to let him/her choose an item in a popup
parent 8db7da13
...@@ -111,6 +111,7 @@ EXTRA_DIST += \ ...@@ -111,6 +111,7 @@ EXTRA_DIST += \
extras/package/macosx/Resources/English.lproj/MediaInfo.xib \ extras/package/macosx/Resources/English.lproj/MediaInfo.xib \
extras/package/macosx/Resources/English.lproj/Open.xib \ extras/package/macosx/Resources/English.lproj/Open.xib \
extras/package/macosx/Resources/English.lproj/Preferences.xib \ extras/package/macosx/Resources/English.lproj/Preferences.xib \
extras/package/macosx/Resources/English.lproj/SharedDialogs.xib \
extras/package/macosx/Resources/English.lproj/SyncTracks.xib \ extras/package/macosx/Resources/English.lproj/SyncTracks.xib \
extras/package/macosx/Resources/English.lproj/VideoEffects.xib \ extras/package/macosx/Resources/English.lproj/VideoEffects.xib \
extras/package/macosx/Resources/English.lproj/Wizard.xib \ extras/package/macosx/Resources/English.lproj/Wizard.xib \
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "SharedDialogs.h"
@interface VLCConvertAndSave : NSObject @interface VLCConvertAndSave : NSObject
{ {
...@@ -91,20 +92,6 @@ ...@@ -91,20 +92,6 @@
IBOutlet id _customize_subs_pop; IBOutlet id _customize_subs_pop;
IBOutlet id _customize_subs_overlay_ckb; IBOutlet id _customize_subs_overlay_ckb;
IBOutlet id _addProfile_panel;
IBOutlet id _addProfile_title_lbl;
IBOutlet id _addProfile_subtitle_lbl;
IBOutlet id _addProfile_name_fld;
IBOutlet id _addProfile_cancel_btn;
IBOutlet id _addProfile_ok_btn;
IBOutlet id _deleteProfile_panel;
IBOutlet id _deleteProfile_title_lbl;
IBOutlet id _deleteProfile_subtitle_lbl;
IBOutlet id _deleteProfile_pop;
IBOutlet id _deleteProfile_cancel_btn;
IBOutlet id _deleteProfile_ok_btn;
IBOutlet id _stream_panel; IBOutlet id _stream_panel;
IBOutlet id _stream_ok_btn; IBOutlet id _stream_ok_btn;
IBOutlet id _stream_destination_lbl; IBOutlet id _stream_destination_lbl;
...@@ -152,7 +139,6 @@ ...@@ -152,7 +139,6 @@
- (IBAction)customizeProfile:(id)sender; - (IBAction)customizeProfile:(id)sender;
- (IBAction)closeCustomizationSheet:(id)sender; - (IBAction)closeCustomizationSheet:(id)sender;
- (IBAction)newProfileAction:(id)sender; - (IBAction)newProfileAction:(id)sender;
- (IBAction)deleteProfileAction:(id)sender;
- (IBAction)iWantAFile:(id)sender; - (IBAction)iWantAFile:(id)sender;
- (IBAction)iWantAStream:(id)sender; - (IBAction)iWantAStream:(id)sender;
- (IBAction)cancelDestination:(id)sender; - (IBAction)cancelDestination:(id)sender;
...@@ -162,6 +148,9 @@ ...@@ -162,6 +148,9 @@
- (IBAction)streamTypeToggle:(id)sender; - (IBAction)streamTypeToggle:(id)sender;
- (IBAction)streamAnnouncementToggle:(id)sender; - (IBAction)streamAnnouncementToggle:(id)sender;
- (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text;
- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item;
- (void)updateDropView; - (void)updateDropView;
@end @end
......
...@@ -185,14 +185,6 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -185,14 +185,6 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
[_customize_aud_samplerate_lbl setStringValue: _NS("Sample Rate")]; [_customize_aud_samplerate_lbl setStringValue: _NS("Sample Rate")];
[_customize_subs_ckb setTitle: _NS("Subtitles")]; [_customize_subs_ckb setTitle: _NS("Subtitles")];
[_customize_subs_overlay_ckb setTitle: _NS("Overlay subtitles on the video")]; [_customize_subs_overlay_ckb setTitle: _NS("Overlay subtitles on the video")];
[_addProfile_title_lbl setStringValue:_NS("Save as new profile")];
[_addProfile_subtitle_lbl setStringValue:_NS("Enter a name for the new profile:")];
[_addProfile_cancel_btn setTitle:_NS("Cancel")];
[_addProfile_ok_btn setTitle:_NS("Save")];
[_deleteProfile_title_lbl setStringValue:_NS("Remove a profile")];
[_deleteProfile_subtitle_lbl setStringValue:_NS("Select the profile you would like to remove:")];
[_deleteProfile_cancel_btn setTitle:_NS("Cancel")];
[_deleteProfile_ok_btn setTitle:_NS("Remove")];
[_stream_ok_btn setTitle:_NS("Close")]; [_stream_ok_btn setTitle:_NS("Close")];
[_stream_destination_lbl setStringValue:_NS("Stream Destination")]; [_stream_destination_lbl setStringValue:_NS("Stream Destination")];
[_stream_announcement_lbl setStringValue:_NS("Stream Announcement")]; [_stream_announcement_lbl setStringValue:_NS("Stream Announcement")];
...@@ -348,77 +340,29 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -348,77 +340,29 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
- (IBAction)newProfileAction:(id)sender - (IBAction)newProfileAction:(id)sender
{ {
if (sender == _customize_newProfile_btn) { /* show panel */
[_addProfile_name_fld setStringValue:@""]; VLCEnterTextPanel * panel = [VLCEnterTextPanel sharedInstance];
[NSApp beginSheet:_addProfile_panel modalForWindow:_customize_panel modalDelegate:self didEndSelector:NULL contextInfo:nil]; [panel setTitle: _NS("Save as new profile")];
} else { [panel setSubTitle: _NS("Enter a name for the new profile:")];
[_addProfile_panel orderOut:sender]; [panel setCancelButtonLabel: _NS("Cancel")];
[NSApp endSheet: _addProfile_panel]; [panel setOKButtonLabel: _NS("Save")];
[panel setTarget:self];
if (sender == _addProfile_ok_btn && [[_addProfile_name_fld stringValue] length] > 0) {
/* prepare current data */ [panel runModalForWindow:_customize_panel];
[self updateCurrentProfile];
/* add profile to arrays */
NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
[workArray addObject:[_addProfile_name_fld stringValue]];
[self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
[workArray addObject:[[[NSArray alloc] initWithArray:self.currentProfile] autorelease]];
[self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
/* update UI */
[self recreateProfilePopup];
[_profile_pop selectItemWithTitle:[_addProfile_name_fld stringValue]];
/* update internals */
[self switchProfile:sender];
[self storeProfilesOnDisk];
}
}
} }
- (IBAction)deleteProfileAction:(id)sender - (IBAction)deleteProfileAction:(id)sender
{ {
if (sender == _deleteProfile_cancel_btn) { /* show panel */
/* close panel */ VLCSelectItemInPopupPanel * panel = [VLCSelectItemInPopupPanel sharedInstance];
[_deleteProfile_panel orderOut:sender]; [panel setTitle:_NS("Remove a profile")];
[NSApp endSheet: _deleteProfile_panel]; [panel setSubTitle:_NS("Select the profile you would like to remove:")];
} else if (sender == _deleteProfile_ok_btn) { [panel setOKButtonLabel:_NS("Remove")];
/* close panel */ [panel setCancelButtonLabel:_NS("Cancel")];
[_deleteProfile_panel orderOut:sender]; [panel setPopupButtonContent:self.profileNames];
[NSApp endSheet: _deleteProfile_panel]; [panel setTarget:self];
/* remove requested profile from the arrays */ [panel runModalForWindow:_window];
NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
[workArray removeObjectAtIndex:[_deleteProfile_pop indexOfSelectedItem]];
[self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
[workArray removeObjectAtIndex:[_deleteProfile_pop indexOfSelectedItem]];
[self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
/* update UI */
[_profile_pop removeAllItems];
[_profile_pop addItemsWithTitles:self.profileNames];
[_profile_pop addItemWithTitle:_NS("Custom")];
[[_profile_pop menu] addItem:[NSMenuItem separatorItem]];
[_profile_pop addItemWithTitle:_NS("Organize Profiles")];
[[_profile_pop lastItem] setTarget: self];
[[_profile_pop lastItem] setAction: @selector(deleteProfileAction:)];
/* update internals */
[self switchProfile:sender];
[self storeProfilesOnDisk];
} else {
/* show panel */
[_deleteProfile_pop removeAllItems];
[_deleteProfile_pop addItemsWithTitles:self.profileNames];
[NSApp beginSheet:_deleteProfile_panel modalForWindow:_window modalDelegate:self didEndSelector:NULL contextInfo:nil];
}
} }
- (IBAction)iWantAFile:(id)sender - (IBAction)iWantAFile:(id)sender
...@@ -617,6 +561,62 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -617,6 +561,62 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
return NO; return NO;
} }
- (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text
{
if (value == NSOKButton) {
if ([text length] > 0) {
/* prepare current data */
[self updateCurrentProfile];
/* add profile to arrays */
NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
[workArray addObject:text];
[self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
[workArray addObject:[[[NSArray alloc] initWithArray:self.currentProfile] autorelease]];
[self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
/* update UI */
[self recreateProfilePopup];
[_profile_pop selectItemWithTitle:text];
/* update internals */
[self switchProfile:self];
[self storeProfilesOnDisk];
}
}
}
- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item
{
if (value == NSOKButton) {
/* remove requested profile from the arrays */
NSMutableArray * workArray = [[NSMutableArray alloc] initWithArray:self.profileNames];
[workArray removeObjectAtIndex:item];
[self setProfileNames:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
workArray = [[NSMutableArray alloc] initWithArray:self.profileValueList];
[workArray removeObjectAtIndex:item];
[self setProfileValueList:[[[NSArray alloc] initWithArray:workArray] autorelease]];
[workArray release];
/* update UI */
[_profile_pop removeAllItems];
[_profile_pop addItemsWithTitles:self.profileNames];
[_profile_pop addItemWithTitle:_NS("Custom")];
[[_profile_pop menu] addItem:[NSMenuItem separatorItem]];
[_profile_pop addItemWithTitle:_NS("Organize Profiles...")];
[[_profile_pop lastItem] setTarget: self];
[[_profile_pop lastItem] setAction: @selector(deleteProfileAction:)];
/* update internals */
[self switchProfile:self];
[self storeProfilesOnDisk];
}
}
# pragma mark - # pragma mark -
# pragma mark Private Functionality # pragma mark Private Functionality
- (void)updateDropView - (void)updateDropView
......
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