]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/coredialogs.m
macosx: Ignore attachment:// in Art uri for now.
[vlc] / modules / gui / macosx / coredialogs.m
index f74ac963ff011efcc0cb0c82bf5b681e46487420..bccfe3e1e0c84ad0084d1b59c204129862137cc2 100644 (file)
@@ -26,7 +26,7 @@
 #import "coredialogs.h"
 #import "misc.h"
 
-/* for the icons in our custom error panel */
+/* for the icon in our custom error panel */
 #import <ApplicationServices/ApplicationServices.h>
 
 /*****************************************************************************
@@ -52,8 +52,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
                                                  selector:@selector(performDialogEvent:)
                                                      name: @"VLCNewCoreDialogEventNotification"
                                                    object:self];
-        
         o_error_panel = [[VLCErrorPanel alloc] init];
+        b_progress_cancelled = NO;
     }
     
     return _o_sharedInstance;
@@ -81,6 +81,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
         [self showQuestionDialog: o_value];
     else if( [o_type isEqualToString: @"dialog-login"] )
         [self showLoginDialog: o_value];
+    else if( [o_type isEqualToString: @"dialog-progress-bar"] )
+        [self showProgressDialog: o_value];
     else
         msg_Err( VLCIntf, "unhandled dialog type: '%s'", [o_type UTF8String] );
 }
@@ -162,7 +164,57 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
         [NSApp stopModalWithCode: 0];
 }
 
--(id)getErrorPanel
+-(void)showProgressDialog: (NSValue *)o_value
+{
+    dialog_progress_bar_t *p_dialog = [o_value pointerValue];
+
+    if( p_dialog->title != NULL )
+    {
+        [o_prog_win setTitle: [NSString stringWithUTF8String: p_dialog->title]];
+        [o_prog_title_txt setStringValue: [NSString stringWithUTF8String: p_dialog->title]];
+    }
+    else
+    {
+        [o_prog_win setTitle: @""];
+        [o_prog_title_txt setStringValue: @""];
+    }
+    if( p_dialog->cancel != NULL )
+        [o_prog_cancel_btn setTitle: [NSString stringWithUTF8String: p_dialog->cancel]];
+    else
+        [o_prog_cancel_btn setTitle: _NS("Cancel")];
+    if( p_dialog->message != NULL )
+        [o_prog_description_txt setStringValue: [NSString stringWithUTF8String: p_dialog->message]];
+    else
+        [o_prog_description_txt setStringValue: @""];
+    [o_prog_bar setDoubleValue: 0];
+    [o_prog_bar startAnimation: self];
+
+    [o_prog_win makeKeyAndOrderFront: self];
+}
+
+-(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number
+{
+    [o_prog_description_txt setStringValue: string];
+    [o_prog_bar setDoubleValue: d_number];
+}
+
+-(void)destroyProgressPanel
+{
+    [o_prog_bar stopAnimation: self];
+    [o_prog_win close];
+}
+
+-(IBAction)progDialogAction:(id)sender
+{
+    b_progress_cancelled = YES;
+}
+
+-(BOOL)progressCancelled
+{
+    return b_progress_cancelled;
+}
+
+-(id)errorPanel
 {
     return o_error_panel;
 }
@@ -174,47 +226,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
 }
 @end
 
-#if 0
-    dialog_progress_bar_t
-    {
-        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];
-    }
--(void)updateDialog
-{
-    if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
-    {
-        [o_prog_description setStringValue:
-            [NSString stringWithUTF8String: p_dialog->psz_description]];
-        [o_prog_bar setDoubleValue: (double)p_dialog->val.f_float];
-
-        if( [o_prog_bar doubleValue] == 100.0 )
-        {
-            /* we are done, let's hide */
-            [self hideDialog];
-        }
-
-        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]];
-
-        return;
-    }
-}
-#endif
-
 /*****************************************************************************
  * VLCErrorPanel implementation
  *****************************************************************************/
@@ -223,12 +234,15 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
 {
     [super init];
 
-    nib_loaded = [NSBundle loadNibNamed:@"InteractionErrorPanel" owner:self];
-
-    /* init strings */
-    [o_window setTitle: _NS("Errors and Warnings")];
-    [o_cleanup_button setTitle: _NS("Clean up")];
-    [o_messages_btn setTitle: _NS("Show Details")];
+    if( !b_nib_loaded )
+    {
+        b_nib_loaded = [NSBundle loadNibNamed:@"ErrorPanel" owner:self];
+    
+        /* init strings */
+        [o_window setTitle: _NS("Errors and Warnings")];
+        [o_cleanup_button setTitle: _NS("Clean up")];
+        [o_messages_btn setTitle: _NS("Show Details")];
+    }
 
     /* init data sources */
     o_errors = [[NSMutableArray alloc] init];