Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
0b2f47e8
Commit
0b2f47e8
authored
Aug 11, 2015
by
David Fuhrmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx: popup panel: switch from delegate to completion block
Also fixes behaviour for eq profile list
parent
2609901e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
129 deletions
+118
-129
modules/gui/macosx/AudioEffects.m
modules/gui/macosx/AudioEffects.m
+50
-57
modules/gui/macosx/ConvertAndSave.h
modules/gui/macosx/ConvertAndSave.h
+0
-2
modules/gui/macosx/ConvertAndSave.m
modules/gui/macosx/ConvertAndSave.m
+21
-23
modules/gui/macosx/SharedDialogs.h
modules/gui/macosx/SharedDialogs.h
+13
-8
modules/gui/macosx/SharedDialogs.m
modules/gui/macosx/SharedDialogs.m
+11
-14
modules/gui/macosx/VideoEffects.m
modules/gui/macosx/VideoEffects.m
+23
-25
No files found.
modules/gui/macosx/AudioEffects.m
View file @
0b2f47e8
...
...
@@ -38,7 +38,6 @@
@interface
VLCAudioEffects
()
{
BOOL
b_genericAudioProfileInInteraction
;
NSInteger
i_old_profile_index
;
}
-
(
void
)
resetProfileSelector
;
...
...
@@ -420,10 +419,31 @@
[
_popupPanel
setOKButtonLabel
:
_NS
(
"Remove"
)];
[
_popupPanel
setCancelButtonLabel
:
_NS
(
"Cancel"
)];
[
_popupPanel
setPopupButtonContent
:[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"AudioEffectProfileNames"
]];
[
_popupPanel
setTarget
:
self
];
b_genericAudioProfileInInteraction
=
YES
;
[
_popupPanel
runModalForWindow
:
self
.
window
];
__weak
typeof
(
self
)
_self
=
self
;
[
_popupPanel
runModalForWindow
:
self
.
window
completionHandler
:
^
(
NSInteger
returnCode
,
NSInteger
selectedIndex
)
{
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
if
(
returnCode
!=
NSOKButton
)
{
[
_profilePopup
selectItemAtIndex
:[
defaults
integerForKey
:
@"AudioEffectSelectedProfile"
]];
return
;
}
/* remove selected profile from settings */
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"AudioEffectProfiles"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"AudioEffectProfiles"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"AudioEffectProfileNames"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"AudioEffectProfileNames"
];
if
(
i_old_profile_index
>=
selectedIndex
)
[
defaults
setInteger
:
i_old_profile_index
-
1
forKey
:
@"AudioEffectSelectedProfile"
];
/* save defaults */
[
defaults
synchronize
];
[
_self
resetProfileSelector
];
}];
}
#pragma mark -
...
...
@@ -684,64 +704,37 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
-
(
IBAction
)
deletePresetAction
:(
id
)
sender
{
VLCPopupPanelController
*
panel
=
[[
VLCPopupPanelController
alloc
]
init
];
[
panel
setTitle
:
_NS
(
"Remove a preset"
)];
[
panel
setSubTitle
:
_NS
(
"Select the preset you would like to remove:"
)];
[
panel
setOKButtonLabel
:
_NS
(
"Remove"
)];
[
panel
setCancelButtonLabel
:
_NS
(
"Cancel"
)];
[
panel
setPopupButtonContent
:[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"EQTitles"
]];
[
panel
setTarget
:
self
];
b_genericAudioProfileInInteraction
=
NO
;
[
panel
runModalForWindow
:
self
.
window
];
}
-
(
void
)
panel
:(
VLCPopupPanelController
*
)
panel
returnValue
:(
NSUInteger
)
value
item
:(
NSUInteger
)
item
{
if
(
!
b_genericAudioProfileInInteraction
)
{
if
(
value
==
NSOKButton
)
{
/* remove requested profile from the arrays */
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQValues"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQValues"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQTitles"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQTitles"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQPreampValues"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQPreampValues"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQNames"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQNames"
];
[
defaults
synchronize
];
}
[
_popupPanel
setTitle
:
_NS
(
"Remove a preset"
)];
[
_popupPanel
setSubTitle
:
_NS
(
"Select the preset you would like to remove:"
)];
[
_popupPanel
setOKButtonLabel
:
_NS
(
"Remove"
)];
[
_popupPanel
setCancelButtonLabel
:
_NS
(
"Cancel"
)];
[
_popupPanel
setPopupButtonContent
:[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"EQTitles"
]];
/* update UI */
[
self
updatePresetSelector
];
}
else
{
__weak
typeof
(
self
)
_self
=
self
;
[
_popupPanel
runModalForWindow
:
self
.
window
completionHandler
:
^
(
NSInteger
returnCode
,
NSInteger
selectedIndex
)
{
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
if
(
value
!=
NSOKButton
)
{
[
_profilePopup
selectItemAtIndex
:[
defaults
integerForKey
:
@"AudioEffectSelectedProfile"
]];
if
(
returnCode
!=
NSOKButton
)
return
;
}
/* remove selected profile from settings */
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"AudioEffectProfiles"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"AudioEffectProfiles"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"AudioEffectProfileNames"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"AudioEffectProfileNames"
];
if
(
i_old_profile_index
>=
item
)
[
defaults
setInteger
:
i_old_profile_index
-
1
forKey
:
@"AudioEffectSelectedProfile"
];
/* save defaults */
/* remove requested profile from the arrays */
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQValues"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQValues"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQTitles"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQTitles"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQPreampValues"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQPreampValues"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:[
defaults
objectForKey
:
@"EQNames"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"EQNames"
];
[
defaults
synchronize
];
[
self
resetProfileSelector
];
}
/* update UI */
[
_self
updatePresetSelector
];
}];
}
#pragma mark -
...
...
modules/gui/macosx/ConvertAndSave.h
View file @
0b2f47e8
...
...
@@ -166,6 +166,4 @@
-
(
IBAction
)
streamAnnouncementToggle
:(
id
)
sender
;
-
(
IBAction
)
sdpFileLocationSelector
:(
id
)
sender
;
-
(
void
)
panel
:(
VLCPopupPanelController
*
)
panel
returnValue
:(
NSUInteger
)
value
item
:(
NSUInteger
)
item
;
@end
modules/gui/macosx/ConvertAndSave.m
View file @
0b2f47e8
...
...
@@ -326,7 +326,6 @@
[
self
resetCustomizationSheetBasedOnProfile
:[
self
.
profileValueList
objectAtIndex
:
index
]];
}
-
(
IBAction
)
deleteProfileAction
:(
id
)
sender
{
/* show panel */
...
...
@@ -335,9 +334,28 @@
[
_popupPanel
setOKButtonLabel
:
_NS
(
"Remove"
)];
[
_popupPanel
setCancelButtonLabel
:
_NS
(
"Cancel"
)];
[
_popupPanel
setPopupButtonContent
:
self
.
profileNames
];
[
_popupPanel
setTarget
:
self
];
[
_popupPanel
runModalForWindow
:
self
.
window
];
__weak
typeof
(
self
)
_self
=
self
;
[
_popupPanel
runModalForWindow
:
self
.
window
completionHandler
:
^
(
NSInteger
returnCode
,
NSInteger
selectedIndex
)
{
if
(
returnCode
!=
NSOKButton
)
return
;
/* remove requested profile from the arrays */
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
_self
.
profileNames
];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
_self
setProfileNames
:[[
NSArray
alloc
]
initWithArray
:
workArray
]];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
_self
.
profileValueList
];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
_self
setProfileValueList
:[[
NSArray
alloc
]
initWithArray
:
workArray
]];
/* update UI */
[
_self
recreateProfilePopup
];
/* update internals */
[
_self
switchProfile
:
_self
];
[
_self
storeProfilesOnDisk
];
}];
}
-
(
IBAction
)
iWantAFile
:(
id
)
sender
...
...
@@ -628,26 +646,6 @@
return
NO
;
}
-
(
void
)
panel
:(
VLCPopupPanelController
*
)
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
]];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
self
.
profileValueList
];
[
workArray
removeObjectAtIndex
:
item
];
[
self
setProfileValueList
:[[
NSArray
alloc
]
initWithArray
:
workArray
]];
/* update UI */
[
self
recreateProfilePopup
];
/* update internals */
[
self
switchProfile
:
self
];
[
self
storeProfilesOnDisk
];
}
}
# pragma mark -
# pragma mark Private Functionality
...
...
modules/gui/macosx/SharedDialogs.h
View file @
0b2f47e8
...
...
@@ -68,16 +68,21 @@ typedef void(^TextfieldPanelCompletionBlock)(NSInteger returnCode, NSString *res
@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
;
/**
* Completion handler for popup panel
* \param returnCode Result from panel. Can be NSOKButton or NSCancelButton.
* \param selectedIndex Selected index of the popup in panel.
*/
typedef
void
(
^
PopupPanelCompletionBlock
)(
NSInteger
returnCode
,
NSInteger
selectedIndex
);
-
(
IBAction
)
windowElementAction
:(
id
)
sender
;
/**
* Shows the panel as a modal dialog with window as its owner.
* \param window Parent window for the dialog.
* \param handler Completion block.
*/
-
(
void
)
runModalForWindow
:(
NSWindow
*
)
window
completionHandler
:(
PopupPanelCompletionBlock
)
handler
;
@end
-
(
IBAction
)
windowElementAction
:(
id
)
sender
;
@protocol
VLCPopupPanelController
<
NSObject
>
@optional
-
(
void
)
panel
:(
VLCPopupPanelController
*
)
panel
returnValue
:(
NSUInteger
)
value
item
:(
NSUInteger
)
item
;
@end
modules/gui/macosx/SharedDialogs.m
View file @
0b2f47e8
...
...
@@ -66,6 +66,12 @@
@end
@interface
VLCPopupPanelController
()
{
PopupPanelCompletionBlock
_completionBlock
;
}
@end
@implementation
VLCPopupPanelController
-
(
id
)
init
...
...
@@ -80,17 +86,11 @@
[
self
.
window
orderOut
:
sender
];
[
NSApp
endSheet
:
self
.
window
];
if
(
self
.
target
)
{
if
([
self
.
target
respondsToSelector
:
@selector
(
panel
:
returnValue
:
item
:
)])
{
if
(
sender
==
_cancelButton
)
[
self
.
target
panel
:
self
returnValue
:
NSCancelButton
item
:
0
];
else
[
self
.
target
panel
:
self
returnValue
:
NSOKButton
item
:
self
.
currentItem
];
}
}
if
(
_completionBlock
)
_completionBlock
(
sender
==
_okButton
?
NSOKButton
:
NSCancelButton
,
[
_popupButton
indexOfSelectedItem
]);
}
-
(
void
)
runModalForWindow
:(
NSWindow
*
)
window
-
(
void
)
runModalForWindow
:(
NSWindow
*
)
window
completionHandler
:(
PopupPanelCompletionBlock
)
handler
;
{
[
self
window
];
...
...
@@ -102,12 +102,9 @@
for
(
NSString
*
value
in
self
.
popupButtonContent
)
[[
_popupButton
menu
]
addItemWithTitle
:
value
action
:
nil
keyEquivalent
:
@""
];
[
NSApp
beginSheet
:
self
.
window
modalForWindow
:
window
modalDelegate
:
self
didEndSelector
:
NULL
contextInfo
:
nil
];
}
_completionBlock
=
[
handler
copy
];
-
(
NSUInteger
)
currentItem
{
return
[
_popupButton
indexOfSelectedItem
];
[
NSApp
beginSheet
:
self
.
window
modalForWindow
:
window
modalDelegate
:
self
didEndSelector
:
NULL
contextInfo
:
nil
];
}
@end
modules/gui/macosx/VideoEffects.m
View file @
0b2f47e8
...
...
@@ -732,39 +732,37 @@
[
_popupPanel
setOKButtonLabel
:
_NS
(
"Remove"
)];
[
_popupPanel
setCancelButtonLabel
:
_NS
(
"Cancel"
)];
[
_popupPanel
setPopupButtonContent
:[[
NSUserDefaults
standardUserDefaults
]
objectForKey
:
@"VideoEffectProfileNames"
]];
[
_popupPanel
setTarget
:
self
];
[
_popupPanel
runModalForWindow
:
self
.
window
]
;
}
__weak
typeof
(
self
)
_self
=
self
;
[
_popupPanel
runModalForWindow
:
self
.
window
completionHandler
:
^
(
NSInteger
returnCode
,
NSInteger
selectedIndex
)
{
-
(
void
)
panel
:(
VLCPopupPanelController
*
)
panel
returnValue
:(
NSUInteger
)
value
item
:(
NSUInteger
)
item
{
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
NSUserDefaults
*
defaults
=
[
NSUserDefaults
standardUserDefaults
];
if
(
valu
e
!=
NSOKButton
)
{
[
_profilePopup
selectItemAtIndex
:[
defaults
integerForKey
:
@"VideoEffectSelectedProfile"
]];
return
;
}
if
(
returnCod
e
!=
NSOKButton
)
{
[
_profilePopup
selectItemAtIndex
:[
defaults
integerForKey
:
@"VideoEffectSelectedProfile"
]];
return
;
}
/* remove selected profile from settings */
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
[
defaults
objectForKey
:
@"VideoEffectProfiles"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"VideoEffectProfiles"
];
/* remove selected profile from settings */
NSMutableArray
*
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
[
defaults
objectForKey
:
@"VideoEffectProfiles"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"VideoEffectProfiles"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
[
defaults
objectForKey
:
@"VideoEffectProfileNames"
]];
[
workArray
removeObjectAtIndex
:
item
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"VideoEffectProfileNames"
];
workArray
=
[[
NSMutableArray
alloc
]
initWithArray
:
[
defaults
objectForKey
:
@"VideoEffectProfileNames"
]];
[
workArray
removeObjectAtIndex
:
selectedIndex
];
[
defaults
setObject
:[
NSArray
arrayWithArray
:
workArray
]
forKey
:
@"VideoEffectProfileNames"
];
if
(
i_old_profile_index
>=
item
)
[
defaults
setInteger
:
i_old_profile_index
-
1
forKey
:
@"VideoEffectSelectedProfile"
];
if
(
i_old_profile_index
>=
selectedIndex
)
[
defaults
setInteger
:
i_old_profile_index
-
1
forKey
:
@"VideoEffectSelectedProfile"
];
/* save defaults */
[
defaults
synchronize
];
/* save defaults */
[
defaults
synchronize
];
/* do not save deleted profile */
i_old_profile_index
=
-
1
;
/* refresh UI */
[
self
resetProfileSelector
];
/* do not save deleted profile */
i_old_profile_index
=
-
1
;
/* refresh UI */
[
_self
resetProfileSelector
];
}];
}
#pragma mark -
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment