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
5c4d7d51
Commit
5c4d7d51
authored
Feb 04, 2016
by
Felix Paul Kühne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
macosx/coredialogs: re-write using new API
parent
173a3df6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
225 additions
and
28 deletions
+225
-28
modules/gui/macosx/coredialogs.h
modules/gui/macosx/coredialogs.h
+14
-14
modules/gui/macosx/coredialogs.m
modules/gui/macosx/coredialogs.m
+211
-14
No files found.
modules/gui/macosx/coredialogs.h
View file @
5c4d7d51
...
...
@@ -33,22 +33,22 @@
@interface
VLCCoreDialogProvider
:
NSObject
{
/* authentication dialog */
IBOutlet
id
authenticationCancelButton
;
IBOutlet
id
authenticationDescriptionLabel
;
IBOutlet
id
authenticationLoginTextField
;
IBOutlet
id
authenticationLoginLabel
;
IBOutlet
id
authenticationOkButton
;
IBOutlet
id
authenticationPasswordTextField
;
IBOutlet
id
authenticationPasswordLabel
;
IBOutlet
id
authenticationTitleLabel
;
IBOutlet
id
authenticationWindow
;
IBOutlet
NSButton
*
authenticationCancelButton
;
IBOutlet
NSTextField
*
authenticationDescriptionLabel
;
IBOutlet
NSTextField
*
authenticationLoginTextField
;
IBOutlet
NSTextField
*
authenticationLoginLabel
;
IBOutlet
NSButton
*
authenticationOkButton
;
IBOutlet
NSTextField
*
authenticationPasswordTextField
;
IBOutlet
NSTextField
*
authenticationPasswordLabel
;
IBOutlet
NSTextField
*
authenticationTitleLabel
;
IBOutlet
NSWindow
*
authenticationWindow
;
/* progress dialog */
IBOutlet
NSProgressIndicator
*
progressIndicator
;
IBOutlet
id
progressCancelButton
;
IBOutlet
id
progressDescriptionLabel
;
IBOutlet
id
progressTitleLabel
;
IBOutlet
id
progressWindow
;
IBOutlet
NSProgressIndicator
*
progressIndicator
;
IBOutlet
NSButton
*
progressCancelButton
;
IBOutlet
NSTextField
*
progressDescriptionLabel
;
IBOutlet
NSTextField
*
progressTitleLabel
;
IBOutlet
NSWindow
*
progressWindow
;
}
@property
(
atomic
,
readwrite
)
BOOL
progressCancelled
;
...
...
modules/gui/macosx/coredialogs.m
View file @
5c4d7d51
...
...
@@ -29,16 +29,145 @@
/* for the icon in our custom error panel */
#import <ApplicationServices/ApplicationServices.h>
static
void
displayErrorCallback
(
const
char
*
psz_title
,
const
char
*
psz_text
,
void
*
p_data
)
@interface
VLCCoreDialogProvider
()
-
(
void
)
displayLoginDialogWithID
:(
vlc_dialog_id
*
)
p_id
title
:(
const
char
*
)
psz_title
description
:(
const
char
*
)
psz_text
defaultUserName
:(
const
char
*
)
psz_default_username
askToStore
:(
bool
)
b_ask_store
;
-
(
void
)
displayProgressDialogWithID
:(
vlc_dialog_id
*
)
p_id
title
:(
const
char
*
)
psz_title
description
:(
const
char
*
)
psz_text
isIndeterminate
:(
bool
)
b_indeterminate
position
:(
float
)
f_position
cancelTitle
:(
const
char
*
)
psz_cancel
;
-
(
void
)
updateDisplayedProgressDialogWithID
:(
vlc_dialog_id
*
)
p_id
value
:(
float
)
f_value
description
:(
const
char
*
)
psz_text
;
@end
static
void
displayErrorCallback
(
const
char
*
psz_title
,
const
char
*
psz_text
,
void
*
p_data
)
{
@autoreleasepool
{
VLCCoreDialogProvider
*
dialogProvider
=
(
__bridge
VLCCoreDialogProvider
*
)
p_data
;
NSAlert
*
alert
=
[
NSAlert
alertWithMessageText
:
toNSStr
(
psz_title
)
defaultButton
:
_NS
(
"OK"
)
alternateButton
:
nil
otherButton
:
nil
informativeTextWithFormat
:
@"%@"
,
toNSStr
(
psz_text
)];
[
alert
setAlertStyle
:
NSCriticalAlertStyle
];
NSAlert
*
alert
=
[
NSAlert
alertWithMessageText
:
toNSStr
(
psz_title
)
defaultButton:
_NS
(
"OK"
)
alternateButton:
nil
otherButton:
nil
informativeTextWithFormat:
@"%@"
,
toNSStr
(
psz_text
)];
[
alert
setAlertStyle
:
NSCriticalAlertStyle
];
[
alert
runModal
];
}
}
static
void
displayLoginCallback
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
const
char
*
psz_default_username
,
bool
b_ask_store
,
void
*
p_data
)
{
@autoreleasepool
{
VLCCoreDialogProvider
*
dialogProvider
=
(
__bridge
VLCCoreDialogProvider
*
)
p_data
;
[
dialogProvider
displayLoginDialogWithID
:
p_id
title:
psz_title
description:
psz_text
defaultUserName:
psz_default_username
askToStore:
b_ask_store
];
}
}
static
void
displayQuestionCallback
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
vlc_dialog_question_type
i_type
,
const
char
*
psz_cancel
,
const
char
*
psz_action1
,
const
char
*
psz_action2
,
void
*
p_data
)
{
@autoreleasepool
{
NSAlert
*
alert
=
[
NSAlert
alertWithMessageText
:
toNSStr
(
psz_title
)
defaultButton:
toNSStr
(
psz_action1
)
alternateButton:
toNSStr
(
psz_action2
)
otherButton:
toNSStr
(
psz_cancel
)
informativeTextWithFormat:
@"%@"
,
toNSStr
(
psz_text
)];
switch
(
i_type
)
{
case
VLC_DIALOG_QUESTION_WARNING
:
[
alert
setAlertStyle
:
NSWarningAlertStyle
];
break
;
case
VLC_DIALOG_QUESTION_CRITICAL
:
[
alert
setAlertStyle
:
NSCriticalAlertStyle
];
break
;
default:
[
alert
setAlertStyle
:
NSInformationalAlertStyle
];
break
;
}
NSInteger
returnValue
=
[
alert
runModal
];
switch
(
returnValue
)
{
case
NSAlertAlternateReturn
:
vlc_dialog_id_post_action
(
p_id
,
2
);
break
;
case
NSAlertOtherReturn
:
vlc_dialog_id_post_action
(
p_id
,
3
);
break
;
default:
vlc_dialog_id_post_action
(
p_id
,
1
);
break
;
}
}
}
static
void
displayProgressCallback
(
vlc_dialog_id
*
p_id
,
const
char
*
psz_title
,
const
char
*
psz_text
,
bool
b_indeterminate
,
float
f_position
,
const
char
*
psz_cancel
,
void
*
p_data
)
{
@autoreleasepool
{
VLCCoreDialogProvider
*
dialogProvider
=
(
__bridge
VLCCoreDialogProvider
*
)
p_data
;
[
dialogProvider
displayProgressDialogWithID
:
p_id
title:
psz_title
description:
psz_text
isIndeterminate:
b_indeterminate
position:
f_position
cancelTitle:
psz_cancel
];
}
}
static
void
cancelCallback
(
vlc_dialog_id
*
p_id
,
void
*
p_data
)
{
@autoreleasepool
{
[
NSApp
stopModalWithCode
:
0
];
}
}
static
void
updateProgressCallback
(
vlc_dialog_id
*
p_id
,
float
f_value
,
const
char
*
psz_text
,
void
*
p_data
)
{
@autoreleasepool
{
VLCCoreDialogProvider
*
dialogProvider
=
(
__bridge
VLCCoreDialogProvider
*
)
p_data
;
[
dialogProvider
updateDisplayedProgressDialogWithID
:
p_id
value:
f_value
description:
psz_text
];
}
}
@implementation
VLCCoreDialogProvider
-
(
instancetype
)
init
...
...
@@ -52,22 +181,13 @@ static void displayErrorCallback(const char *psz_title, const char *psz_text, vo
intf_thread_t
*
p_intf
=
getIntf
();
/* subscribe to various interactive dialogues */
/*
const vlc_dialog_cbs cbs = {
const
vlc_dialog_cbs
cbs
=
{
displayErrorCallback
,
displayLoginCallback
,
displayQuestionCallback
,
displayProgressCallback
,
cancelCallback
,
updateProgressCallback
};*/
const
vlc_dialog_cbs
cbs
=
{
displayErrorCallback
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
};
vlc_dialog_provider_set_callbacks
(
p_intf
,
&
cbs
,
(
__bridge
void
*
)
self
);
...
...
@@ -96,12 +216,89 @@ static void displayErrorCallback(const char *psz_title, const char *psz_text, vo
[
progressIndicator
setUsesThreadedAnimation
:
YES
];
}
-
(
void
)
displayLoginDialogWithID
:(
vlc_dialog_id
*
)
p_id
title
:(
const
char
*
)
psz_title
description
:(
const
char
*
)
psz_text
defaultUserName
:(
const
char
*
)
psz_default_username
askToStore
:(
bool
)
b_ask_store
{
// FIXME: add support for b_ask_store
[
authenticationTitleLabel
setStringValue
:
toNSStr
(
psz_title
)];
authenticationWindow
.
title
=
authenticationTitleLabel
.
stringValue
;
[
authenticationDescriptionLabel
setStringValue
:
toNSStr
(
psz_text
)];
[
authenticationLoginTextField
setStringValue
:
toNSStr
(
psz_default_username
)];
[
authenticationPasswordTextField
setStringValue
:
@""
];
[
authenticationWindow
center
];
NSInteger
returnValue
=
[
NSApp
runModalForWindow
:
authenticationWindow
];
[
authenticationWindow
close
];
NSString
*
username
=
authenticationLoginTextField
.
stringValue
;
NSString
*
password
=
authenticationPasswordTextField
.
stringValue
;
vlc_dialog_id_post_login
(
p_id
,
username
?
[
username
UTF8String
]
:
NULL
,
password
?
[
password
UTF8String
]
:
NULL
,
false
);
}
-
(
IBAction
)
authenticationDialogAction
:(
id
)
sender
{
if
([[
sender
title
]
isEqualToString
:
_NS
(
"OK"
)])
[
NSApp
stopModalWithCode
:
1
];
else
[
NSApp
stopModalWithCode
:
0
];
}
-
(
void
)
displayProgressDialogWithID
:(
vlc_dialog_id
*
)
p_id
title
:(
const
char
*
)
psz_title
description
:(
const
char
*
)
psz_text
isIndeterminate
:(
bool
)
b_indeterminate
position
:(
float
)
f_position
cancelTitle
:(
const
char
*
)
psz_cancel
{
progressTitleLabel
.
stringValue
=
toNSStr
(
psz_title
);
progressWindow
.
title
=
progressTitleLabel
.
stringValue
;
progressDescriptionLabel
.
stringValue
=
toNSStr
(
psz_text
);
progressIndicator
.
indeterminate
=
b_indeterminate
;
progressIndicator
.
doubleValue
=
f_position
;
if
(
psz_cancel
)
{
progressCancelButton
.
title
=
toNSStr
(
psz_cancel
);
}
else
{
progressCancelButton
.
title
=
_NS
(
"Cancel"
);
}
[
progressIndicator
startAnimation
:
self
];
[
progressWindow
center
];
[
NSApp
runModalForWindow
:
progressWindow
];
[
progressWindow
close
];
if
(
p_id
!=
NULL
)
{
vlc_dialog_id_dismiss
(
p_id
);
}
p_id
=
NULL
;
}
-
(
void
)
updateDisplayedProgressDialogWithID
:(
vlc_dialog_id
*
)
p_id
value
:(
float
)
f_value
description
:(
const
char
*
)
psz_text
{
if
(
!
progressIndicator
.
indeterminate
)
{
progressIndicator
.
doubleValue
=
f_value
;
progressDescriptionLabel
.
stringValue
=
toNSStr
(
psz_text
);
}
}
-
(
IBAction
)
progressDialogAction
:(
id
)
sender
{
[
NSApp
stopModalWithCode
:
0
];
}
@end
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