]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
macosx: Repack module_config_t.
[vlc] / modules / gui / macosx / open.m
index d3f37b804870e7b51093b7a2d00a360e89213052..6f7d4b84b4d085e02f81b1105332b0916bf6420d 100644 (file)
@@ -54,7 +54,7 @@ NSArray *qtkvideoDevices;
 NSArray *qtkaudioDevices;
 #define setEyeTVUnconnected \
 [o_capture_lbl setStringValue: _NS("No device is selected")]; \
-[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu\n.")]; \
+[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu.\n")]; \
 [o_capture_lbl displayIfNeeded]; \
 [o_capture_long_lbl displayIfNeeded]; \
 [self showCaptureView: o_capture_label_view]
@@ -70,6 +70,9 @@ struct display_info_t
  *****************************************************************************/
 @implementation VLCOpen
 
+#pragma mark -
+#pragma mark Init
+
 static VLCOpen *_o_sharedMainInstance = nil;
 
 + (VLCOpen *)sharedInstance
@@ -140,6 +143,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_file_slave_icon_well setImage: NULL];
     [o_file_subtitles_filename_lbl setStringValue: @""];
     [o_file_subtitles_icon_well setImage: NULL];
+    [o_file_custom_timing_ckb setTitle: _NS("Custom playback")];
+    [o_file_starttime_lbl setStringValue: _NS("Start time")];
+    [o_file_starttime_fld setStringValue: @""];
+    [o_file_stoptime_lbl setStringValue: _NS("Stop time")];
+    [o_file_stoptime_fld setStringValue: @""];
 
     [o_disc_selector_pop removeAllItems];
     [o_disc_selector_pop setHidden: NO];
@@ -365,11 +373,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if( p_item )
     {
-        for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
+        for( i_index = 0; p_item->list.psz && p_item->list.psz[i_index];
              i_index++ )
         {
             [o_file_sub_encoding_pop addItemWithTitle:
-                [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
+                [NSString stringWithUTF8String: p_item->list.psz[i_index]]];
         }
         [o_file_sub_encoding_pop selectItemWithTitle:
                 [NSString stringWithUTF8String: p_item->value.psz]];
@@ -379,10 +387,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if ( p_item )
     {
-        for ( i_index = 0; i_index < p_item->i_list; i_index++ )
+        for ( i_index = 0; i_index < p_item->list_count; i_index++ )
         {
             [o_file_sub_align_pop addItemWithTitle:
-             _NS(p_item->ppsz_list_text[i_index])];
+             _NS(p_item->list_text[i_index])];
         }
         [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
     }
@@ -391,10 +399,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if ( p_item )
     {
-        for ( i_index = 0; i_index < p_item->i_list; i_index++ )
+        for ( i_index = 0; i_index < p_item->list_count; i_index++ )
         {
-            [o_file_sub_size_pop addItemWithTitle: _NS(p_item->ppsz_list_text[i_index])];
-            if ( p_item->value.i == p_item->pi_list[i_index] )
+            [o_file_sub_size_pop addItemWithTitle: _NS(p_item->list_text[i_index])];
+            if ( p_item->value.i == p_item->list.i[i_index] )
             {
                 [o_file_sub_size_pop selectItemAtIndex: i_index];
             }
@@ -444,9 +452,30 @@ static VLCOpen *_o_sharedMainInstance = nil;
             {
                 [o_options addObject: [NSString stringWithFormat:
                     @"freetype-rel-fontsize=%i",
-                    p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
+                    p_item->list.i[[o_file_sub_size_pop indexOfSelectedItem]]]];
             }
         }
+        NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
+        NSUInteger componentCount = [components count];
+        NSInteger tempValue;
+        if( componentCount == 1 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] );
+        else if( componentCount == 2 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue] );
+        else if( componentCount == 3 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue] );
+        if (tempValue > 0)
+            [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
+        components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
+        componentCount = [components count];
+        if( componentCount == 1 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] );
+        else if( componentCount == 2 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue] );
+        else if( componentCount == 3 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue] );
+        if (tempValue > 0)
+            [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
         if( [o_output_ckbox state] == NSOnState )
         {
             NSUInteger count = [[o_sout_options mrl] count];
@@ -532,6 +561,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
 }
 
+#pragma mark -
+#pragma mark Main Actions
+
 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
 {
     NSString *o_label = [o_tvi label];
@@ -587,36 +619,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
         [[o_panel contentView] addSubview: o_mrl_view];
 }
 
-- (IBAction)inputSlaveAction:(id)sender
-{
-    if( sender == o_file_slave_ckbox )
-        [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
-    else
-    {
-        NSOpenPanel *o_open_panel;
-        o_open_panel = [NSOpenPanel openPanel];
-        [o_open_panel setCanChooseFiles: YES];
-        [o_open_panel setCanChooseDirectories: NO];
-        if( [o_open_panel runModal] == NSOKButton )
-        {
-            if( o_file_slave_path )
-                [o_file_slave_path release];
-            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
-            [o_file_slave_path retain];
-        }
-    }
-    if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
-    {
-        [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
-        [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
-    }
-    else
-    {
-        [o_file_slave_filename_lbl setStringValue: @""];
-        [o_file_slave_icon_well setImage: NULL];
-    }
-}
-
 - (void)openFileGeneric
 {
     [self openFilePathChanged: nil];
@@ -643,6 +645,51 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [self openTarget: 3];
 }
 
+- (void)openFile
+{
+    NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+    b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
+
+    [o_open_panel setAllowsMultipleSelection: YES];
+    [o_open_panel setCanChooseDirectories: YES];
+    [o_open_panel setTitle: _NS("Open File")];
+    [o_open_panel setPrompt: _NS("Open")];
+
+    if( [o_open_panel runModal] == NSOKButton )
+    {
+        NSArray * o_urls = [o_open_panel URLs];
+        NSUInteger count = [o_urls count];
+        NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
+        NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
+        for( NSUInteger i = 0; i < count; i++ )
+        {
+            [o_values addObject: [[o_urls objectAtIndex: i] path]];
+        }
+        [o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
+
+        for( NSUInteger i = 0; i < count; i++ )
+        {
+            NSDictionary *o_dic;
+            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], "file");
+            if( !psz_uri )
+                continue;
+
+            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
+
+            free( psz_uri );
+
+            [o_array addObject: o_dic];
+        }
+        if( b_autoplay )
+            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
+        else
+            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
+    }
+}
+
+#pragma mark -
+#pragma mark File Panel
+
 - (void)openFilePathChanged:(NSNotification *)o_notification
 {
     if ( o_file_path && [o_file_path length] > 0 )
@@ -718,6 +765,48 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [self openFilePathChanged: nil];
 }
 
+- (IBAction)inputSlaveAction:(id)sender
+{
+    if( sender == o_file_slave_ckbox )
+        [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
+    else
+    {
+        NSOpenPanel *o_open_panel;
+        o_open_panel = [NSOpenPanel openPanel];
+        [o_open_panel setCanChooseFiles: YES];
+        [o_open_panel setCanChooseDirectories: NO];
+        if( [o_open_panel runModal] == NSOKButton )
+        {
+            if( o_file_slave_path )
+                [o_file_slave_path release];
+            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+            [o_file_slave_path retain];
+        }
+    }
+    if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
+    {
+        [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
+        [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
+    }
+    else
+    {
+        [o_file_slave_filename_lbl setStringValue: @""];
+        [o_file_slave_icon_well setImage: NULL];
+    }
+}
+
+- (IBAction)fileTimeCustomization:(id)sender
+{
+    BOOL b_value = [o_file_custom_timing_ckb state];
+    [o_file_starttime_fld setEnabled: b_value];
+    [o_file_starttime_lbl setEnabled: b_value];
+    [o_file_stoptime_fld setEnabled: b_value];
+    [o_file_stoptime_lbl setEnabled: b_value];
+}
+
+#pragma mark -
+#pragma mark Optical Media Panel
+
 - (void)showOpticalMediaView: theView withIcon:(NSImage *)icon
 {
     NSRect o_view_rect;
@@ -778,13 +867,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     GetVolParmsInfoBuffer volumeParms;
     err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
-    if ( noErr != err ) {
-        msg_Err( p_intf, "error retrieving volume params, bailing out" );
-        return @"";
+    if ( noErr == err )
+    {
+        NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
+        return [NSString stringWithFormat:@"/dev/r%@", bsdName];
     }
 
-    NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
-    return [NSString stringWithFormat:@"/dev/r%@", bsdName];
+    return @"";
 }
 
 - (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
@@ -837,21 +926,41 @@ static VLCOpen *_o_sharedMainInstance = nil;
             {
                 // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
                 NSFileManager * fm = [[NSFileManager alloc] init];
-                NSArray * topLevelItems;
-                topLevelItems = [fm subpathsOfDirectoryAtPath: mountPath error: NULL];
-                [fm release];
 
-                NSUInteger itemCount = [topLevelItems count];
-                for (int i = 0; i < itemCount; i++) {
-                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
-                        returnValue = kVLCMediaSVCD;
-                        break;
-                    }
-                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
-                        returnValue = kVLCMediaVCD;
-                        break;
+                NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
+                for (int i = 0; i < [dirContents count]; i++)
+                {
+                    NSString *currentFile = [dirContents objectAtIndex:i];
+                    NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
+
+                    BOOL isDir;
+                    if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
+                    {
+                        if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaSVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaBDMVFolder;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVideoTSFolder;
+                            break;
+                        }
                     }
                 }
+
+                [fm release];
+
                 if(!returnValue)
                     returnValue = kVLCMediaVideoTSFolder;
             }
@@ -1030,6 +1139,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
 }
 
+#pragma mark -
+#pragma mark Network Panel
+
 - (void)textFieldWasClicked:(NSNotification *)o_notification
 {
     if( [o_notification object] == o_net_udp_port )
@@ -1185,47 +1297,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
 }
 
-- (void)openFile
-{
-    NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
-    b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
-
-    [o_open_panel setAllowsMultipleSelection: YES];
-    [o_open_panel setCanChooseDirectories: YES];
-    [o_open_panel setTitle: _NS("Open File")];
-    [o_open_panel setPrompt: _NS("Open")];
-
-    if( [o_open_panel runModal] == NSOKButton )
-    {
-        NSArray * o_urls = [o_open_panel URLs];
-        NSUInteger count = [o_urls count];
-        NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
-        NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
-        for( NSUInteger i = 0; i < count; i++ )
-        {
-            [o_values addObject: [[o_urls objectAtIndex: i] path]];
-        }
-        [o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
-
-        for( NSUInteger i = 0; i < count; i++ )
-        {
-            NSDictionary *o_dic;
-            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], "file");
-            if( !psz_uri )
-                continue;
-
-            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
-
-            free( psz_uri );
-
-            [o_array addObject: o_dic];
-        }
-        if( b_autoplay )
-            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
-        else
-            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
-    }
-}
+#pragma mark -
+#pragma mark Capture Panel
 
 - (void)showCaptureView: theView
 {
@@ -1454,6 +1527,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_chn_status_txt setHidden: YES];
 }
 
+#pragma mark -
+#pragma mark Subtitle Settings
+
 - (IBAction)subsChanged:(id)sender
 {
     if ([o_file_sub_ckbox state] == NSOnState)
@@ -1535,6 +1611,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
 }
 
+#pragma mark -
+#pragma mark Miscellaneous
+
 - (IBAction)panelCancel:(id)sender
 {
     [NSApp stopModalWithCode: 0];