]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/playlist.m
Merge [11470],[11471],[11474] and [11475] - Closes: #205
[vlc] / modules / gui / macosx / playlist.m
index 0214c731bc8dc02e1b771d70f9d33b3c2a8a6008..8674a4300346fc923503a81dd4ebf98c649a0c2a 100644 (file)
             [[self delegate] deleteItem:self];
             break;
 
+        case NSEnterCharacter:
+        case NSCarriageReturnCharacter:
+            [(VLCPlaylist *)[[VLCMain sharedInstance] getPlaylist]
+                                                            playItem:self];
+            break;
+
         default:
             [super keyDown: o_event];
             break;
@@ -155,7 +161,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
         {
             /* create the menu entries used in the playlist menu */
             o_lmi = [[o_mi_services submenu] addItemWithTitle:
-                     [NSString stringWithCString:
+                     [NSString stringWithUTF8String:
                      p_parser->psz_longname ? p_parser->psz_longname :
                      ( p_parser->psz_shortname ? p_parser->psz_shortname:
                      p_parser->psz_object_name)]
@@ -170,7 +176,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
                 
             /* create the menu entries for the main menu */
             o_lmi = [[o_mm_mi_services submenu] addItemWithTitle:
-                     [NSString stringWithCString:
+                     [NSString stringWithUTF8String:
                      p_parser->psz_longname ? p_parser->psz_longname :
                      ( p_parser->psz_shortname ? p_parser->psz_shortname:
                      p_parser->psz_object_name)]
@@ -187,10 +193,36 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     vlc_list_release( p_list );
     vlc_object_release( p_playlist );
 
+    /* Change the simple textfield into a searchField if we can... */
+#if 0
+    if( MACOS_VERSION >= 10.3 )
+    {
+        NSView *o_parentview = [o_status_field superview];
+        NSSearchField *o_better_search_field = [[NSSearchField alloc]initWithFrame:[o_search_field frame]];
+        [o_better_search_field setRecentsAutosaveName:@"VLC media player search"];
+        [o_better_search_field setDelegate:self];
+        [[NSNotificationCenter defaultCenter] addObserver: self
+            selector: @selector(searchfieldChanged:)
+            name: NSControlTextDidChangeNotification
+            object: o_better_search_field];
+
+        [o_better_search_field setTarget:self];
+        [o_better_search_field setAction:@selector(searchItem:)];
+
+        [o_better_search_field setAutoresizingMask:NSViewMinXMargin];
+        [o_parentview addSubview:o_better_search_field];
+        [o_search_field setHidden:YES];
+    }
+#endif
     [self initStrings];
     //[self playlistUpdated];
 }
 
+- (void)searchfieldChanged:(NSNotification *)o_notification
+{
+    [o_search_field setStringValue:[[o_notification object] stringValue]];
+}
+
 - (void)initStrings
 {
     [o_mi_save_playlist setTitle: _NS("Save Playlist...")];
@@ -211,6 +243,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 #if 0
     [o_search_button setTitle: _NS("Search")];
 #endif
+    [o_search_field setToolTip: _NS("Search in Playlist")];
     [[o_loop_popup itemAtIndex:0] setTitle: _NS("Standard Play")];
     [[o_loop_popup itemAtIndex:1] setTitle: _NS("Repeat One")];
     [[o_loop_popup itemAtIndex:2] setTitle: _NS("Repeat All")];
@@ -303,9 +336,11 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     for (j = 0 ; j < [o_array count] - 1 ; j++)
     {
-        [o_outline_view expandItem: [o_outline_dict objectForKey:
+        id o_item;
+        if( ( o_item = [o_outline_dict objectForKey:
                             [NSString stringWithFormat: @"%p",
-                            [[o_array objectAtIndex:j] pointerValue]]]];
+                            [[o_array objectAtIndex:j] pointerValue]]] ) != nil )
+            [o_outline_view expandItem: o_item];
 
     }
 
@@ -332,6 +367,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     if ( p_temp_item )
     {
+        vlc_mutex_lock( &p_playlist->object_lock );
         while( p_temp_item->i_parents > 0 )
         {
             int i;
@@ -342,6 +378,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
                     if( p_temp_item->pp_parents[i]->p_parent == p_node )
                     {
                         vlc_object_release( p_playlist );
+                        vlc_mutex_unlock( &p_playlist->object_lock );
                         return YES;
                     }
                     else
@@ -352,12 +389,31 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
                 }
             }
         }
+        vlc_mutex_unlock( &p_playlist->object_lock );
     }
 
     vlc_object_release( p_playlist );
     return NO;
 }
 
+- (IBAction)savePlaylist:(id)sender
+{
+    intf_thread_t * p_intf = VLCIntf;
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+
+    NSSavePanel *o_save_panel = [NSSavePanel savePanel];
+    NSString * o_name = [NSString stringWithFormat: @"%@.m3u", _NS("Untitled")];
+    [o_save_panel setTitle: _NS("Save Playlist")];
+    [o_save_panel setPrompt: _NS("Save")];
+
+    if( [o_save_panel runModalForDirectory: nil
+            file: o_name] == NSOKButton )
+    {
+        playlist_Export( p_playlist, [[o_save_panel filename] fileSystemRepresentation], "export-m3u" );
+    }
+}
+
 
 /* When called retrieves the selected outlineview row and plays that node or item */
 - (IBAction)playItem:(id)sender
@@ -836,7 +892,6 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
     if( p_playlist == NULL )
         return;
-
     p_view = playlist_ViewFind( p_playlist, i_current_view );
 
     if( p_view )