]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
use PL_**LOCK instead of vlc_mutex_lock
[vlc] / modules / gui / macosx / open.m
index 27138d99f2f886a306b67f8867ac464a7bd1da22..c5c47bc1be79c0df73ecb592fcdbfbf01171dbfc 100644 (file)
@@ -83,7 +83,7 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class )
     p_list = [NSMutableArray arrayWithCapacity: 1];
  
     next_media = IOIteratorNext( media_iterator );
-    if( next_media != nil )
+    if( next_media )
     {
         char psz_buf[0x32];
         size_t dev_path_length;
@@ -109,14 +109,14 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class )
                                     sizeof(psz_buf) - dev_path_length,
                                     kCFStringEncodingASCII ) )
             {
-                [p_list addObject: [NSString stringWithCString: psz_buf]];
+                [p_list addObject: [NSString stringWithUTF8String: psz_buf]];
             }
  
             CFRelease( str_bsd_path );
  
             IOObjectRelease( next_media );
  
-        } while( ( next_media = IOIteratorNext( media_iterator ) ) != nil );
+        } while( ( next_media = IOIteratorNext( media_iterator ) ) );
     }
  
     IOObjectRelease( media_iterator );
@@ -235,15 +235,20 @@ static VLCOpen *_o_sharedMainInstance = nil;
         name: NSControlTextDidChangeNotification
         object: o_net_http_url];
 
-    /* wake up with the correct GUI */
+    /* wake up with the correct EyeTV GUI */
     if( [[[VLCMain sharedInstance] getEyeTVController] isEyeTVrunning] == YES )
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
-    if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
     {
-        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"eyetvup"];
-        [self setupChannelInfo];
+        if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
+        {
+            [o_eyetv_tabView selectTabViewItemWithIdentifier:@"eyetvup"];
+            [self setupChannelInfo];
+        }
+        else 
+            [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
     }
+    else
+        [o_eyetv_tabView selectTabViewItemWithIdentifier:@"noeyetv"];
+
     [[NSDistributedNotificationCenter defaultCenter] addObserver: self
                                                         selector: @selector(eyetvChanged:)
                                                             name: NULL
@@ -289,12 +294,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
              i_index++ )
         {
             [o_file_sub_encoding_pop addItemWithTitle:
-                [NSString stringWithCString:
-                p_item->ppsz_list[i_index]]];
+                [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
         }
         [o_file_sub_encoding_pop selectItemWithTitle:
-                [NSString stringWithCString:
-                p_item->value.psz]];
+                [NSString stringWithUTF8String: p_item->value.psz]];
     }
 
     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
@@ -411,6 +414,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
     {
         [self openNetInfoChanged: nil];
     }
+    else if( [o_label isEqualToString: _NS("EyeTV")] )
+    {
+        [o_mrl setStringValue: @"eyetv://"];
+    }
 }
 
 - (void)openFileGeneric
@@ -436,7 +443,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     NSString *o_mrl_string;
     NSString *o_filename = [o_file_path stringValue];
     NSString *o_ext = [o_filename pathExtension];
-    vlc_bool_t b_stream = [o_file_stream state];
+    bool b_stream = [o_file_stream state];
     BOOL b_dir = NO;
  
     [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
@@ -797,12 +804,23 @@ static VLCOpen *_o_sharedMainInstance = nil;
 - (IBAction)eyetvSwitchChannel:(id)sender
 {
     if( sender == o_eyetv_nextProgram_btn )
-        [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: YES];
+    {
+        int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: YES];
+        [o_eyetv_channels_pop selectItemWithTag:chanNum];
+        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+    }
     else if( sender == o_eyetv_previousProgram_btn )
-        [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: NO];
+    {
+        int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: NO];
+        [o_eyetv_channels_pop selectItemWithTag:chanNum];
+        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+    }
     else if( sender == o_eyetv_channels_pop )
-        [[[VLCMain sharedInstance] getEyeTVController] selectChannel:
-            [sender indexOfSelectedItem]];
+    {
+        int chanNum = [[sender selectedItem] tag];
+        [[[VLCMain sharedInstance] getEyeTVController] selectChannel:chanNum];
+        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+    }
     else
         msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
 }
@@ -854,16 +872,28 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_chn_status_txt setHidden: NO];
  
     /* retrieve info */
-    int x = 0;
-    int channelCount = ( [[[VLCMain sharedInstance] getEyeTVController] getNumberOfChannels] + 1 );
-    while( x != channelCount )
-    {
-        /* we have to add items this way, because we accept duplicates
-         * additionally, we save a bit of time */
-        [[o_eyetv_channels_pop menu] addItemWithTitle: [[[VLCMain sharedInstance] getEyeTVController] getNameOfChannel: x]
+    NSEnumerator *channels = [[[VLCMain sharedInstance] getEyeTVController] allChannels];
+    int x = -2;
+    [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
+                                               action: nil
+                                        keyEquivalent: @""] setTag:x++];
+    [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
                                                action: nil
-                                        keyEquivalent: @""];
-        x += 1;
+                                        keyEquivalent: @""] setTag:x++];
+    if( channels ) 
+    {
+        NSString *channel;
+        [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
+        while( channel = [channels nextObject] )
+        {
+            /* we have to add items this way, because we accept duplicates
+             * additionally, we save a bit of time */
+            [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
+                                                   action: nil
+                                            keyEquivalent: @""] setTag:++x];
+        }
+        /* make Tuner the default */
+        [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] getEyeTVController] currentChannel]];
     }
  
     /* clean up GUI */