]> git.sesse.net Git - vlc/commitdiff
* additional interaction enhancements
authorFelix Paul Kühne <fkuehne@videolan.org>
Sun, 30 Jul 2006 22:00:44 +0000 (22:00 +0000)
committerFelix Paul Kühne <fkuehne@videolan.org>
Sun, 30 Jul 2006 22:00:44 +0000 (22:00 +0000)
    - 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.

Makefile.am
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/classes.nib [new file with mode: 0644]
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/info.nib [new file with mode: 0644]
extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/keyedobjects.nib [new file with mode: 0644]
extras/MacOSX/vlc.pbproj/project.pbxproj
include/vlc_interaction.h
modules/gui/macosx/interaction.h
modules/gui/macosx/interaction.m
modules/gui/wxwidgets/dialogs/interaction.cpp
modules/gui/wxwidgets/interface.cpp
src/interface/interaction.c

index 653e9fd1851edd7ee13726c3ab46429cb3f03bd0..b096ac0c8d4488c54071147b924fa5a945562f2a 100644 (file)
@@ -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 \
diff --git a/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/classes.nib b/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/classes.nib
new file mode 100644 (file)
index 0000000..da12b46
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    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
diff --git a/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/info.nib b/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/info.nib
new file mode 100644 (file)
index 0000000..ad5fd3f
--- /dev/null
@@ -0,0 +1,16 @@
+<?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>
diff --git a/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/keyedobjects.nib b/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/keyedobjects.nib
new file mode 100644 (file)
index 0000000..97c1249
Binary files /dev/null and b/extras/MacOSX/Resources/English.lproj/InteractionErrorPanel.nib/keyedobjects.nib differ
index 052574e572dfa43040e0b4ad5c905b74a63eb079..e23f63a64ffd10559d8e81001bb57d2e091913ee 100644 (file)
                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 */; };
                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; };
                        buildActionMask = 2147483647;
                        files = (
                                1058C7AFFEA557BF11CA2CBB /* Cocoa.framework in Frameworks */,
+                               CC3DC89C0A7CDB9600B53F32 /* ApplicationServices.framework in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
                        isa = PBXGroup;
                        children = (
+                               CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */,
                                1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */,
                        );
                        name = "Linked Frameworks";
                                CCF3C64A0923B99D00401862 /* SFilters.nib */,
                                CC26BF2A09A7A05000E94D62 /* Update.nib */,
                                CC1B4B4B09A8CF9E0078AD2E /* Interaction.nib */,
+                               CC1AC1BA0A7BDA41002478C3 /* InteractionErrorPanel.nib */,
                        );
                        name = nibs;
                        sourceTree = "<group>";
                                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;
                };
 /* 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 = (
index c8b29407239160c7185dddebf136b6e7049a8beb..82741f7e41983a66c947d6f49ad17c227354f6eb 100644 (file)
@@ -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 )
index 28978997ccb329b550066e09c785a8741b81f8f5..1fb5f00c32f41bac01104659983659f654720ea6 100644 (file)
 
 @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
index 789bfebe8613ca580b4e0927fc8edaa6c41c7578..dcb7d2c51fe29d1d40d121a3b49f279f9fe56095 100644 (file)
@@ -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;
     [o_interaction_list removeObject:o_interaction];
 }
 
+-(id)getErrorPanel
+{
+    return o_error_panel;
+}
+
 -(void)dealloc
 {
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [o_interaction_list release];
     [super dealloc];
 }
-
 @end
 
 /*****************************************************************************
         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 );
         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
 
 - (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 )
     {
 }
 
 @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
index 92dd5f4c521f8a652c6b9536a922e1a486931b69..1ae280e38811b438a9574d952aa439f502c65392 100644 (file)
@@ -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,
index 4bb35c30679fd875d610842710c32e8e5fe1b9d0..028365e3edd06c0f7bec5fe85a6599cad62c206c 100644 (file)
@@ -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,
index 6d79622bc400da43116a90896ae3db90290afc85..e0bf1b8adcdd7669cea45c74a3fa6d67a0607de6 100644 (file)
@@ -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 );
 
-    if( i_id > 0 )
-    {
-        p_new = intf_InteractionGetById( p_this, i_id );
-    }
-    if( !p_new )
-    {
-        INTERACT_INIT( p_new );
-        if( i_id > 0 ) p_new->i_id = i_id ;
-    }
+    va_start( args, psz_format );
+    vasprintf( &p_new->psz_description, psz_format, args );
+    va_end( args );
+
+    if( b_blocking )
+        p_new->i_flags = DIALOG_BLOCKING_ERROR;
     else
-    {
-        p_new->i_status = UPDATED_DIALOG;
-    }
+        p_new->i_flags = DIALOG_NONBLOCKING_ERROR;
 
-    p_new->i_flags |= DIALOG_REUSABLE;
+    intf_Interact( p_this, p_new );
+}
 
-    p_new->i_type = INTERACT_DIALOG_ONEWAY;
+/** Helper function to send an warning, which is always shown non-blocking
+ *  \param p_this     Parent vlc_object
+ *  \param psz_title  Title for the dialog
+ *  \param psz_format The message to display
+ *  */
+void __intf_UserWarn( vlc_object_t *p_this,
+                       const char *psz_title,
+                       const char *psz_format, ... )
+{
+    va_list args;
+    interaction_dialog_t *p_new = NULL;
+    
+    INTERACT_INIT( p_new );
+    
     p_new->psz_title = strdup( psz_title );
 
     va_start( args, psz_format );
     vasprintf( &p_new->psz_description, psz_format, args );
     va_end( args );
 
-    p_new->i_flags |= DIALOG_CLEAR_NOSHOW;
+    p_new->i_flags = DIALOG_WARNING;
 
     intf_Interact( p_this, p_new );
 }