Commit 0a9dbda9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

* additional interaction enhancements

    - intf_UserFatal takes an addition bool-argument now to set whether the error message will be blocking in the interface or not (so TRUE = blocking)
    - intf_UserWarn is always non-blocking and is used to check important, localised warnings to the user
* wx: a compilation fix, but no update to the current API
* osx: complete implementation of the interaction framework using some Carbon (!) functions, because the needed icons aren't accessible through Cocoa. Regrettably, I had to add yet another nib-file to keep the code clean and readable.

The Error-dialogue is no longer re-usable (so the specific ID was removed). The interface needs to keep track of the reported errors and warnings. Thus, it may discard them as requested by the user and doesn't need to care about the core.
parent 87c7bdf0
......@@ -82,6 +82,9 @@ EXTRA_DIST += \
extras/MacOSX/Resources/English.lproj/Interaction.nib/classes.nib \
extras/MacOSX/Resources/English.lproj/Interaction.nib/info.nib \
extras/MacOSX/Resources/English.lproj/Interaction.nib/keyedobjects.nib \
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/classes.nib \
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/info.nib \
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/keyedobjects.nib \
extras/MacOSX/Resources/English.lproj/InfoPlist.strings \
extras/MacOSX/Resources/a52.icns \
extras/MacOSX/Resources/aac.icns \
......
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {cleanupTable = id; };
CLASS = VLCErrorInteractionPanel;
LANGUAGE = ObjC;
OUTLETS = {"o_cleanup_button" = id; "o_error_table" = id; "o_window" = id; };
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>69 66 356 240 0 0 1440 878 </string>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>5</integer>
</array>
<key>IBSystem Version</key>
<string>8J135</string>
</dict>
</plist>
......@@ -72,8 +72,10 @@
C2F2A707095AE51700018C74 /* play_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A703095AE51600018C74 /* play_embedded_blue.png */; };
C2F2A708095AE51700018C74 /* skip_forward_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A704095AE51600018C74 /* skip_forward_embedded_blue.png */; };
C2F2A709095AE51700018C74 /* skip_previous_embedded_blue.png in Resources */ = {isa = PBXBuildFile; fileRef = C2F2A705095AE51600018C74 /* skip_previous_embedded_blue.png */; };
CC1AC1BC0A7BDA41002478C3 /* InteractionErrorPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC1AC1BA0A7BDA41002478C3 /* InteractionErrorPanel.nib */; };
CC1B4B4D09A8CF9E0078AD2E /* Interaction.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC1B4B4B09A8CF9E0078AD2E /* Interaction.nib */; };
CC26BF2C09A7A05000E94D62 /* Update.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC26BF2A09A7A05000E94D62 /* Update.nib */; };
CC3DC89C0A7CDB9600B53F32 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */; };
CCF3C64C0923B99D00401862 /* SFilters.nib in Resources */ = {isa = PBXBuildFile; fileRef = CCF3C64A0923B99D00401862 /* SFilters.nib */; };
DC7F46ED08A183FC0027DB24 /* Extended.nib in Resources */ = {isa = PBXBuildFile; fileRef = DC7F46EB08A183FC0027DB24 /* Extended.nib */; };
DCA00AA9075F948800E6BF46 /* About.nib in Resources */ = {isa = PBXBuildFile; fileRef = DCA00AA7075F948800E6BF46 /* About.nib */; };
......@@ -904,12 +906,14 @@
C2F2A703095AE51600018C74 /* play_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = play_embedded_blue.png; path = Resources/play_embedded_blue.png; sourceTree = "<group>"; };
C2F2A704095AE51600018C74 /* skip_forward_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skip_forward_embedded_blue.png; path = Resources/skip_forward_embedded_blue.png; sourceTree = "<group>"; };
C2F2A705095AE51600018C74 /* skip_previous_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = skip_previous_embedded_blue.png; path = Resources/skip_previous_embedded_blue.png; sourceTree = "<group>"; };
CC1AC1BB0A7BDA41002478C3 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/InteractionErrorPanel.nib; sourceTree = "<group>"; };
CC1B4B4C09A8CF9E0078AD2E /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/Interaction.nib; sourceTree = "<group>"; };
CC1B4C1409A8EC690078AD2E /* interaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = interaction.h; path = ../../modules/gui/macosx/interaction.h; sourceTree = "<group>"; };
CC1B4C1509A8EC690078AD2E /* interaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = interaction.m; path = ../../modules/gui/macosx/interaction.m; sourceTree = "<group>"; };
CC26BF2B09A7A05000E94D62 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/Update.nib; sourceTree = "<group>"; };
CC26BF3109A7A08C00E94D62 /* update.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = update.h; path = ../../modules/gui/macosx/update.h; sourceTree = SOURCE_ROOT; };
CC26BF3209A7A08C00E94D62 /* update.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = update.m; path = ../../modules/gui/macosx/update.m; sourceTree = SOURCE_ROOT; };
CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
CCF3C64B0923B99D00401862 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/SFilters.nib; sourceTree = "<group>"; };
CCF3C6500923B9D100401862 /* sfilters.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = sfilters.h; path = ../../modules/gui/macosx/sfilters.h; sourceTree = SOURCE_ROOT; };
CCF3C6510923B9D100401862 /* sfilters.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = sfilters.m; path = ../../modules/gui/macosx/sfilters.m; sourceTree = SOURCE_ROOT; };
......@@ -943,6 +947,7 @@
buildActionMask = 2147483647;
files = (
1058C7AFFEA557BF11CA2CBB /* Cocoa.framework in Frameworks */,
CC3DC89C0A7CDB9600B53F32 /* ApplicationServices.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1039,6 +1044,7 @@
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */,
1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
);
name = "Linked Frameworks";
......@@ -1153,6 +1159,7 @@
CCF3C64A0923B99D00401862 /* SFilters.nib */,
CC26BF2A09A7A05000E94D62 /* Update.nib */,
CC1B4B4B09A8CF9E0078AD2E /* Interaction.nib */,
CC1AC1BA0A7BDA41002478C3 /* InteractionErrorPanel.nib */,
);
name = nibs;
sourceTree = "<group>";
......@@ -1261,6 +1268,7 @@
C2F2A709095AE51700018C74 /* skip_previous_embedded_blue.png in Resources */,
CC26BF2C09A7A05000E94D62 /* Update.nib in Resources */,
CC1B4B4D09A8CF9E0078AD2E /* Interaction.nib in Resources */,
CC1AC1BC0A7BDA41002478C3 /* InteractionErrorPanel.nib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1277,6 +1285,14 @@
/* End PBXRezBuildPhase section */
/* Begin PBXVariantGroup section */
CC1AC1BA0A7BDA41002478C3 /* InteractionErrorPanel.nib */ = {
isa = PBXVariantGroup;
children = (
CC1AC1BB0A7BDA41002478C3 /* English */,
);
name = InteractionErrorPanel.nib;
sourceTree = "<group>";
};
CC1B4B4B09A8CF9E0078AD2E /* Interaction.nib */ = {
isa = PBXVariantGroup;
children = (
......
......@@ -87,9 +87,12 @@ struct interaction_dialog_t
#define DIALOG_CLEAR_NOSHOW 0x08
#define DIALOG_GOT_ANSWER 0x10
#define DIALOG_LOGIN_PW_OK_CANCEL 0x20
#define DIALOG_BLOCKING_ERROR 0x24
#define DIALOG_NONBLOCKING_ERROR 0x200
#define DIALOG_USER_PROGRESS 0x40
#define DIALOG_PSZ_INPUT_OK_CANCEL 0x80
#define DIALOG_INTF_PROGRESS 0x100
#define DIALOG_WARNING 0x400
/**
* Possible return codes
......@@ -121,7 +124,6 @@ enum
*/
enum
{
INTERACT_PROGRESS, ///< Progress bar (in the main interface ?)
INTERACT_DIALOG_ONEWAY, ///< Dialog box without feedback
INTERACT_DIALOG_TWOWAY, ///< Dialog box with feedback
};
......@@ -132,14 +134,13 @@ enum
enum
{
DIALOG_FIRST,
DIALOG_ERRORS,
DIALOG_LAST_PREDEFINED,
};
/**
* This structure contains the active interaction dialogs, and is
* used by teh manager
* used by the manager
*/
struct interaction_t
{
......@@ -170,8 +171,10 @@ enum
#define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )
VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );
#define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),c,d, ## e )
VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) );
#define intf_UserFatal( a, b, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),b,c,d, ## e )
VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, vlc_bool_t, const char*, const char*, ...) );
#define intf_UserWarn( a, c, d, e... ) __intf_UserWarn( VLC_OBJECT(a),c,d, ## e )
VLC_EXPORT( void, __intf_UserWarn,( vlc_object_t*, const char*, const char*, ...) );
#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) );
#define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f )
......
......@@ -76,16 +76,41 @@
@end
@interface VLCErrorInteractionPanel : NSObject
{
IBOutlet id o_window;
IBOutlet id o_cleanup_button;
IBOutlet id o_error_table;
NSMutableArray * o_errors;
NSMutableArray * o_icons;
NSImage * warnIcon;
NSImage * errorIcon;
BOOL nib_interact_errpanel_loaded;
}
- (IBAction)cleanupTable:(id)sender;
-(void)showPanel;
-(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg;
-(void)addWarning: (NSString *)o_warning withMsg:(NSString *)o_msg;
@end
/*****************************************************************************
* VLCInteractionList interface
*****************************************************************************/
@interface VLCInteractionList : NSObject
{
NSMutableArray *o_interaction_list;
VLCErrorInteractionPanel *o_error_panel;
}
-(void)newInteractionEvent: (NSNotification *)o_notification;
-(void)addInteraction: (interaction_dialog_t *)p_dialog;
-(void)removeInteraction: (VLCInteraction *)p_interaction;
-(id)getErrorPanel;
@end
......@@ -25,6 +25,9 @@
#import "intf.h"
#import "interaction.h"
/* for the icons in our custom error panel */
#import <ApplicationServices/ApplicationServices.h>
/*****************************************************************************
* VLCInteractionList implementation
*****************************************************************************/
......@@ -39,6 +42,8 @@
name: @"VLCNewInteractionEventNotification"
object:self];
o_error_panel = [[VLCErrorInteractionPanel alloc] init];
return self;
}
......@@ -72,7 +77,6 @@
-(void)addInteraction: (interaction_dialog_t *)p_dialog
{
VLCInteraction *o_interaction = [[VLCInteraction alloc] initDialog: p_dialog];
p_dialog->p_private = (void *)o_interaction;
......@@ -85,6 +89,11 @@
[o_interaction_list removeObject:o_interaction];
}
-(id)getErrorPanel
{
return o_error_panel;
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
......@@ -92,7 +101,6 @@
[o_interaction_list release];
[super dealloc];
}
@end
/*****************************************************************************
......@@ -128,10 +136,10 @@
o_mainIntfPgbar = [[VLCMain sharedInstance] getMainIntfPgbar];
}
NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : "title"];
NSString *o_title = [NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : _("Error")];
NSString *o_description = [NSString stringWithUTF8String:p_dialog->psz_description ? p_dialog->psz_description : ""];
NSString *o_defaultButton = [NSString stringWithUTF8String:p_dialog->psz_defaultButton];
NSString *o_alternateButton = [NSString stringWithUTF8String:p_dialog->psz_alternateButton];
NSString *o_defaultButton = p_dialog->psz_defaultButton ? [NSString stringWithUTF8String:p_dialog->psz_defaultButton] : nil;
NSString *o_alternateButton = p_dialog->psz_alternateButton ? [NSString stringWithUTF8String:p_dialog->psz_alternateButton] : nil;
NSString *o_otherButton = p_dialog->psz_otherButton ? [NSString stringWithUTF8String:p_dialog->psz_otherButton] : nil;
vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
......@@ -154,81 +162,86 @@
o_window = [NSApp mainWindow];
}
#if 0
#if 0
msg_Dbg( p_intf, "Title: %s", [o_title UTF8String] );
msg_Dbg( p_intf, "Description: %s", [o_description UTF8String] );
#endif
msg_Dbg( p_intf, "Delivered flag: %i", p_dialog->i_flags );
#endif
if( p_dialog->i_id == DIALOG_ERRORS )
if( p_dialog->i_flags & DIALOG_BLOCKING_ERROR )
{
msg_Dbg( p_intf, "error panel requested" );
NSAlert * ourAlert = [NSAlert alertWithMessageText:
[NSString stringWithUTF8String:p_dialog->psz_title ? p_dialog->psz_title : _("Error")]
defaultButton: _NS("OK") alternateButton: nil otherButton: nil
informativeTextWithFormat:
[NSString stringWithUTF8String:p_dialog->psz_description]];
[ourAlert setAlertStyle: NSWarningAlertStyle];
[ourAlert runModal];
NSBeginInformationalAlertSheet( o_title, _NS("OK"), nil, nil,
o_window, self, @selector(sheetDidEnd: returnCode: contextInfo:),
NULL, nil, o_description );
}
else
else if( p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
{
if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
msg_Dbg( p_intf, "yes-no-cancel-dialog requested" );
NSBeginInformationalAlertSheet( o_title, o_defaultButton,
o_alternateButton, o_otherButton, o_window, self,
@selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
o_description );
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
msg_Dbg( p_intf, "dialog for login and pw requested" );
[o_auth_title setStringValue: o_title];
[o_auth_description setStringValue: o_description];
[o_auth_login_fld setStringValue: @""];
[o_auth_pw_fld setStringValue: @""];
[NSApp beginSheet: o_auth_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_auth_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
msg_Dbg( p_intf, "user progress dialog requested" );
[o_prog_title setStringValue: o_title];
[o_prog_description setStringValue: o_description];
[o_prog_bar setDoubleValue: (double)p_dialog->val.f_float];
if( p_dialog->i_timeToGo < 1 )
[o_prog_timeToGo setStringValue: @""];
else
[o_prog_timeToGo setStringValue: [NSString stringWithFormat:
_NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]];
[NSApp beginSheet: o_prog_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_prog_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
msg_Dbg( p_intf, "text input from user requested" );
[o_input_title setStringValue: o_title];
[o_input_description setStringValue: o_description];
[o_input_fld setStringValue: @""];
[NSApp beginSheet: o_input_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_input_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_INTF_PROGRESS )
{
msg_Dbg( p_intf, "progress-bar in main intf requested" );
[[VLCMain sharedInstance] setScrollField: o_description stopAfter: -1];
[o_mainIntfPgbar setDoubleValue: (double)p_dialog->val.f_float];
[o_mainIntfPgbar setHidden: NO];
[[[VLCMain sharedInstance] getControllerWindow] makeKeyWindow];
[o_mainIntfPgbar setIndeterminate: NO];
}
msg_Dbg( p_intf, "addition to non-blocking error panel received" );
[[[[VLCMain sharedInstance] getInteractionList] getErrorPanel]
addError: o_title withMsg: o_description];
}
else if( p_dialog->i_flags & DIALOG_WARNING )
{
msg_Dbg( p_intf, "addition to non-blocking warning panel received" );
[[[[VLCMain sharedInstance] getInteractionList] getErrorPanel]
addWarning: o_title withMsg: o_description];
}
else if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL )
{
msg_Dbg( p_intf, "yes-no-cancel-dialog requested" );
NSBeginInformationalAlertSheet( o_title, o_defaultButton,
o_alternateButton, o_otherButton, o_window, self,
@selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
o_description );
}
else if( p_dialog->i_flags & DIALOG_LOGIN_PW_OK_CANCEL )
{
msg_Dbg( p_intf, "dialog for login and pw requested" );
[o_auth_title setStringValue: o_title];
[o_auth_description setStringValue: o_description];
[o_auth_login_fld setStringValue: @""];
[o_auth_pw_fld setStringValue: @""];
[NSApp beginSheet: o_auth_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_auth_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
msg_Dbg( p_intf, "user progress dialog requested" );
[o_prog_title setStringValue: o_title];
[o_prog_description setStringValue: o_description];
[o_prog_bar setDoubleValue: (double)p_dialog->val.f_float];
if( p_dialog->i_timeToGo < 1 )
[o_prog_timeToGo setStringValue: @""];
else
msg_Err( p_intf, "requested dialog type unknown (%i)",
p_dialog->i_flags );
[o_prog_timeToGo setStringValue: [NSString stringWithFormat:
_NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]];
[NSApp beginSheet: o_prog_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_prog_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_PSZ_INPUT_OK_CANCEL )
{
msg_Dbg( p_intf, "text input from user requested" );
[o_input_title setStringValue: o_title];
[o_input_description setStringValue: o_description];
[o_input_fld setStringValue: @""];
[NSApp beginSheet: o_input_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_input_win makeKeyWindow];
}
else if( p_dialog->i_flags & DIALOG_INTF_PROGRESS )
{
msg_Dbg( p_intf, "progress-bar in main intf requested" );
[[VLCMain sharedInstance] setScrollField: o_description stopAfter: -1];
[o_mainIntfPgbar setDoubleValue: (double)p_dialog->val.f_float];
[o_mainIntfPgbar setHidden: NO];
[[[VLCMain sharedInstance] getControllerWindow] makeKeyWindow];
[o_mainIntfPgbar setIndeterminate: NO];
}
else
msg_Err( p_intf, "requested dialog type unknown (%i)", p_dialog->i_flags );
}
- (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return
......@@ -344,6 +357,7 @@
- (IBAction)okayAndClose:(id)sender
{
msg_Dbg( p_intf, "running okayAndClose" );
vlc_mutex_lock( &p_dialog->p_interaction->object_lock );
if( p_dialog->i_flags == DIALOG_LOGIN_PW_OK_CANCEL )
{
......@@ -359,3 +373,141 @@
}
@end
/*****************************************************************************
* VLCErrorInteractionPanel implementation
*****************************************************************************/
@implementation VLCErrorInteractionPanel
-(id)init
{
[super init];
nib_interact_errpanel_loaded = [NSBundle loadNibNamed:@"InteractionErrorPanel" owner:self];
[o_window setTitle: _NS("Errors and Warnings")];
[o_cleanup_button setTitle: _NS("Clean up")];
o_errors = [[NSMutableArray alloc] init];
o_icons = [[NSMutableArray alloc] init];
/* ugly Carbon stuff following...
* regrettably, you can't get the icons through clean Cocoa */
/* retrieve our error icon */
IconRef ourIconRef;
int returnValue;
returnValue = GetIconRef(kOnSystemDisk, 'macs', 'stop', &ourIconRef);
errorIcon = [[NSImage alloc] initWithSize:NSMakeSize(32,32)];
[errorIcon lockFocus];
CGRect rect = CGRectMake(0,0,32,32);
PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext]
graphicsPort],
&rect,
kAlignNone,
kTransformNone,
NULL /*inLabelColor*/,
kPlotIconRefNormalFlags,
(IconRef)ourIconRef);
[errorIcon unlockFocus];
returnValue = ReleaseIconRef(ourIconRef);
/* retrieve our caution icon */
returnValue = GetIconRef(kOnSystemDisk, 'macs', 'caut', &ourIconRef);
warnIcon = [[NSImage alloc] initWithSize:NSMakeSize(32,32)];
[warnIcon lockFocus];
PlotIconRefInContext((CGContextRef)[[NSGraphicsContext currentContext]
graphicsPort],
&rect,
kAlignNone,
kTransformNone,
NULL /*inLabelColor*/,
kPlotIconRefNormalFlags,
(IconRef)ourIconRef);
[warnIcon unlockFocus];
returnValue = ReleaseIconRef(ourIconRef);
return self;
}
-(void)dealloc
{
[errorIcon release];
[warnIcon release];
[o_errors release];
[o_icons release];
[super dealloc];
}
-(void)showPanel
{
[o_window makeKeyAndOrderFront: self];
}
-(void)addError: (NSString *)o_error withMsg:(NSString *)o_msg
{
/* format our string as desired */
NSMutableAttributedString * ourError;
ourError = [[NSMutableAttributedString alloc] initWithString:
[NSString stringWithFormat:@"%@\n%@", o_error, o_msg]
attributes:
[NSDictionary dictionaryWithObject: [NSFont systemFontOfSize:11] forKey: NSFontAttributeName]];
[ourError
addAttribute: NSFontAttributeName
value: [NSFont boldSystemFontOfSize:11]
range: NSMakeRange( 0, [o_error length])];
[o_errors addObject: ourError];
[ourError release];
[o_icons addObject: errorIcon];
[o_error_table reloadData];
[self showPanel];
}
-(void)addWarning: (NSString *)o_warning withMsg:(NSString *)o_msg
{
/* format our string as desired */
NSMutableAttributedString * ourWarning;
ourWarning = [[NSMutableAttributedString alloc] initWithString:
[NSString stringWithFormat:@"%@\n%@", o_warning, o_msg]
attributes:
[NSDictionary dictionaryWithObject: [NSFont systemFontOfSize:11] forKey: NSFontAttributeName]];
[ourWarning
addAttribute: NSFontAttributeName
value: [NSFont boldSystemFontOfSize:11]
range: NSMakeRange( 0, [o_warning length])];
[o_errors addObject: ourWarning];
[ourWarning release];
[o_icons addObject: warnIcon];
[o_error_table reloadData];
[self showPanel];
}
-(IBAction)cleanupTable:(id)sender
{
[o_errors removeAllObjects];
[o_icons removeAllObjects];
[o_error_table reloadData];
}
/*----------------------------------------------------------------------------
* data source methods
*---------------------------------------------------------------------------*/
- (int)numberOfRowsInTableView:(NSTableView *)theDataTable
{
return [o_errors count];
}
- (id)tableView:(NSTableView *)theDataTable objectValueForTableColumn:
(NSTableColumn *)theTableColumn row: (int)row
{
if( [[theTableColumn identifier] isEqualToString: @"error_msg"] )
return [o_errors objectAtIndex: row];
if( [[theTableColumn identifier] isEqualToString: @"icon"] )
return [o_icons objectAtIndex: row];
return @"unknown identifier";
}
@end
......@@ -109,7 +109,7 @@ void InteractionDialog::Render()
wxGauge *gauge;
if( p_dialog->i_id == DIALOG_ERRORS )
if( p_dialog->i_id == DIALOG_NONBLOCKING_ERRORS )
{
wxTextCtrl *errors ; // Special case
label = new wxStaticText( widgets_panel, -1,
......
......@@ -1239,15 +1239,9 @@ void Interface::OnInteraction( wxCommandEvent& event )
p_arg->p_dialog = p_dialog;
p_arg->p_intf = p_intf;
if( p_dialog->i_type == INTERACT_PROGRESS )
{
/// \todo Handle progress in the interface
}
else
{
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
p_intf->p_sys->pf_show_dialog( p_intf, INTF_DIALOG_INTERACTION,
0, p_arg );
}
}
static int InteractCallback( vlc_object_t *p_this,
......
......@@ -236,44 +236,57 @@ void intf_InteractionManage( playlist_t *p_playlist )
if( new->psz_title ) free( new->psz_title ); \
if( new->psz_description ) free( new->psz_description );
/** Helper function to send an error message
/** Helper function to send an error message, both in a blocking and non-blocking way
* \param p_this Parent vlc_object
* \param i_id A predefined ID, 0 if not applicable
* \param b_blocking Is this dialog blocking or not?
* \param psz_title Title for the dialog
* \param psz_format The message to display
* */
void __intf_UserFatal( vlc_object_t *p_this,
vlc_bool_t b_blocking,
const char *psz_title,
const char *psz_format, ... )
{
va_list args;
interaction_dialog_t *p_new = NULL;
int i_id = DIALOG_ERRORS;
INTERACT_INIT( p_new );
p_new->psz_title = strdup( psz_title );