]> granicus.if.org Git - transmission/commitdiff
Sort the Sort menu items on launch, since the main menu is now localized through...
authorMitchell Livingston <livings124@transmissionbt.com>
Mon, 30 Jan 2012 00:14:43 +0000 (00:14 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Mon, 30 Jan 2012 00:14:43 +0000 (00:14 +0000)
macosx/Controller.h
macosx/Controller.m
macosx/en.lproj/MainMenu.xib

index 682606f91eafc1b16867bbafedaaa39a3615f710..273bad03001cf9bbf6477dd0fdcb9fbf32987fb3 100644 (file)
@@ -79,6 +79,8 @@ typedef enum
                                 
     IBOutlet NSMenuItem             * fNextInfoTabItem, * fPrevInfoTabItem;
     
+    IBOutlet NSMenu                 * fSortMenu;
+    
     IBOutlet NSMenu                 * fActionMenu;
     
     IBOutlet NSMenu                 * fUploadMenu, * fDownloadMenu;
index 4cb4c27e737b5ea94634b3bfffa0b5529d34d42b..3f86261f561bd3d725ee9425b4f46066e9a6db5c 100644 (file)
@@ -403,6 +403,31 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     [fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]];
     [fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]];
     
+    //sort the sort menu items (localization is from strings file)
+    NSMutableArray * sortMenuItems = [NSMutableArray arrayWithCapacity: 7];
+    NSUInteger sortMenuIndex = 0;
+    BOOL foundSortItem = NO;
+    for (NSMenuItem * item in [fSortMenu itemArray])
+    {
+        if ([item action] == @selector(setSort:) && [item tag] != SORT_ORDER_TAG)
+        {
+            [sortMenuItems addObject: item];
+            [fSortMenu removeItemAtIndex: sortMenuIndex];
+            foundSortItem = YES;
+        }
+        else
+        {
+            if (foundSortItem)
+                break;
+            ++sortMenuIndex;
+        }
+    }
+    
+    [sortMenuItems sortUsingDescriptors: [NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey: @"title" ascending: YES selector: @selector(localizedCompare:)]]];
+    
+    for (NSMenuItem * item in sortMenuItems)
+        [fSortMenu insertItem: item atIndex: sortMenuIndex++];
+    
     //you would think this would be called later in this method from updateUI, but it's not reached in awakeFromNib
     //this must be called after showStatusBar:
     [fStatusBar updateWithDownload: 0.0 upload: 0.0];
index fc35f199e6a95543b5c09811a62d7adf230458a8..3626d713ce0f8d784e06eaa869f492f72abb9128 100644 (file)
                                                        <string key="NSFrame">{{118, 5}, {279, 14}}</string>
                                                        <reference key="NSSuperview" ref="303120456"/>
                                                        <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView"/>
                                                        <bool key="NSEnabled">YES</bool>
                                                        <object class="NSTextFieldCell" key="NSCell" id="696487414">
                                                                <int key="NSCellFlags">67239488</int>
                                                                                        <string key="NSFrameSize">{515, 224}</string>
                                                                                        <reference key="NSSuperview" ref="306237956"/>
                                                                                        <reference key="NSWindow"/>
-                                                                                       <reference key="NSNextKeyView" ref="1068338331"/>
+                                                                                       <reference key="NSNextKeyView" ref="365285506"/>
                                                                                        <bool key="NSEnabled">YES</bool>
                                                                                        <object class="_NSCornerView" key="NSCornerView">
                                                                                                <nil key="NSNextResponder"/>
@@ -667,7 +666,7 @@ AAAAAAAAAAA</bytes>
                                                        <string key="NSFrame">{{0, 24}, {515, 224}}</string>
                                                        <reference key="NSSuperview" ref="303120456"/>
                                                        <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView" ref="365285506"/>
+                                                       <reference key="NSNextKeyView" ref="306237956"/>
                                                        <int key="NSsFlags">133648</int>
                                                        <reference key="NSVScroller" ref="1068338331"/>
                                                        <reference key="NSHScroller" ref="365285506"/>
@@ -5731,6 +5730,7 @@ AAAAAAAAAAA</bytes>
                                                <string key="fOpenIgnoreDownloadFolder">NSMenuItem</string>
                                                <string key="fPrevInfoTabItem">NSMenuItem</string>
                                                <string key="fRatioStopMenu">NSMenu</string>
+                                               <string key="fSortMenu">NSMenu</string>
                                                <string key="fSpeedLimitButton">NSButton</string>
                                                <string key="fTableView">TorrentTableView</string>
                                                <string key="fTotalTorrentsField">NSTextField</string>
@@ -5800,6 +5800,10 @@ AAAAAAAAAAA</bytes>
                                                        <string key="name">fRatioStopMenu</string>
                                                        <string key="candidateClassName">NSMenu</string>
                                                </object>
+                                               <object class="IBToOneOutletInfo" key="fSortMenu">
+                                                       <string key="name">fSortMenu</string>
+                                                       <string key="candidateClassName">NSMenu</string>
+                                               </object>
                                                <object class="IBToOneOutletInfo" key="fSpeedLimitButton">
                                                        <string key="name">fSpeedLimitButton</string>
                                                        <string key="candidateClassName">NSButton</string>