]> git.sesse.net Git - vlc/commitdiff
Implements sorting of the current node from context menu
authorBenjamin Pracht <bigben@videolan.org>
Mon, 13 Dec 2004 21:48:06 +0000 (21:48 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Mon, 13 Dec 2004 21:48:06 +0000 (21:48 +0000)
extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index e8b5c3dbfc06735656f7544532597b481fdd3b9d..c98b5d757ad5d9530915743ab9e236c675665bb6 100644 (file)
                 playItem = id; 
                 searchItem = id; 
                 selectAll = id; 
+                sortNodeByAuthor = id; 
+                sortNodeByName = id; 
             }; 
             CLASS = VLCPlaylist; 
             LANGUAGE = ObjC; 
                 "o_mi_play" = id; 
                 "o_mi_save_playlist" = id; 
                 "o_mi_selectall" = id; 
+                "o_mi_sort_author" = id; 
+                "o_mi_sort_name" = id; 
                 "o_outline_view" = id; 
                 "o_random_ckb" = id; 
                 "o_search_field" = id; 
index 1825eb9736c8970af1bf513a09ba2d6e12eec9e9..cb8865df03981f23c1908163c367c9a804880162 100644 (file)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>94 104 505 517 0 0 1024 746 </string>
+       <string>230 -84 505 517 0 0 1024 746 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>1617</key>
@@ -13,7 +13,7 @@
                <key>29</key>
                <string>84 667 419 44 0 0 1024 746 </string>
                <key>915</key>
-               <string>620 326 100 130 0 0 1024 746 </string>
+               <string>731 416 165 180 0 0 1024 746 </string>
        </dict>
        <key>IBFramework Version</key>
        <string>364.0</string>
index 006e3b3acc2f1e23fd2b6fad4a7a5cc55b399ee3..49cd0d9a39fb6c61a6f3f8ca2a8837d4dba9687f 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ
index 735f922bcb0c132c8473d2d1048331b14d414f21..1049166da09f0443c238882327c67af586b3723e 100644 (file)
@@ -52,6 +52,8 @@
     IBOutlet id o_mi_delete;
     IBOutlet id o_mi_info;
     IBOutlet id o_mi_selectall;
+    IBOutlet id o_mi_sort_name;
+    IBOutlet id o_mi_sort_author;
 
     NSImage *o_descendingSortingImage;
     NSImage *o_ascendingSortingImage;
 - (NSMenu *)menuForEvent:(NSEvent *)o_event;
 
 - (void)playlistUpdated;
+- (void)sortNode:(int)i_mode;
 
 - (IBAction)playItem:(id)sender;
 - (IBAction)deleteItem:(id)sender;
 - (IBAction)selectAll:(id)sender;
+- (IBAction)sortNodeByName:(id)sender;
+- (IBAction)sortNodeByAuthor:(id)sender;
 
 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
 
index 618194db1b52db46401e8404c6725955397ca637..b825ec3fad1c9fc4855a77d76f8132d042529f28 100644 (file)
@@ -152,6 +152,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     [o_mi_delete setTitle: _NS("Delete")];
     [o_mi_selectall setTitle: _NS("Select All")];
     [o_mi_info setTitle: _NS("Properties")];
+    [o_mi_sort_name setTitle: _NS("Sort Node by Name")];
+    [o_mi_sort_author setTitle: _NS("Sort Node by Author")];
     [[o_tc_name headerCell] setStringValue:_NS("Name")];
     [[o_tc_author headerCell] setStringValue:_NS("Author")];
     [[o_tc_duration headerCell] setStringValue:_NS("Duration")];
@@ -318,6 +320,65 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     }
 }
 
+- (IBAction)sortNodeByName:(id)sender
+{
+    [self sortNode: SORT_TITLE];
+}
+
+- (IBAction)sortNodeByAuthor:(id)sender
+{
+    [self sortNode: SORT_AUTHOR];
+}
+
+- (void)sortNode:(int)i_mode
+{
+    playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
+                                          FIND_ANYWHERE );
+    playlist_item_t * p_item;
+
+    if (p_playlist == NULL)
+    {
+        return;
+    }
+
+    if ([o_outline_view selectedRow] > -1)
+    {
+        p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
+                                                                pointerValue];
+    }
+    else
+    /*If no item is selected, sort the whole playlist*/
+    {
+        playlist_view_t * p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
+        p_item = p_view->p_root;
+    }
+
+    if (p_item->i_children > -1)
+    {
+        vlc_mutex_lock(&p_playlist->object_lock );
+        playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
+        vlc_mutex_unlock(&p_playlist->object_lock );
+    }
+    else
+    {
+        int i;
+
+        for (i = 0 ; i < p_item->i_parents ; i++)
+        {
+            if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
+            {
+                vlc_mutex_lock(&p_playlist->object_lock );
+                playlist_RecursiveNodeSort( p_playlist,
+                        p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
+                vlc_mutex_unlock(&p_playlist->object_lock );
+                break;
+            }
+        }
+    }
+    vlc_object_release(p_playlist);
+    [self playlistUpdated];
+}
+
 - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
 {
     int i_item;