]> git.saurik.com Git - cydia.git/blobdiff - CyteKit/TabBarController.mm
Swap awkward va_list hack for awkward switch hack.
[cydia.git] / CyteKit / TabBarController.mm
index 27a8000f0deee6016e14d115ffaa998b553219f7..a6cd088bd452a0179d7d5d0469ffd05d6aec9350 100644 (file)
 #include "CyteKit/TabBarController.h"
 
 #include "iPhonePrivate.h"
+#include <Menes/ObjectHandle.h>
 
-@implementation UITabBarController (Cydia)
+@implementation CyteTabBarController {
+    _transient UIViewController *transient_;
+    _H<UIViewController> remembered_;
+}
 
-@end
+- (NSArray *) navigationURLCollection {
+    NSMutableArray *items([NSMutableArray array]);
+
+    // XXX: Should this deal with transient view controllers?
+    for (id navigation in [self viewControllers]) {
+        NSArray *stack = [navigation performSelector:@selector(navigationURLCollection)];
+        if (stack != nil)
+            [items addObject:stack];
+    }
+
+    return items;
+}
+
+- (void) addViewControllers:(id)no, ... {
+    va_list args;
+    va_start(args, no);
+
+    NSMutableArray *controllers([NSMutableArray array]);
 
-@implementation CyteTabBarController
+    for (;;) {
+        auto title(va_arg(args, NSString *));
+        if (title == nil)
+            break;
+
+        UINavigationController *controller([[[UINavigationController alloc] init] autorelease]);
+        [controllers addObject:controller];
+
+        auto legacy(va_arg(args, NSString *));
+        auto normal(va_arg(args, NSString *));
+        auto select(va_arg(args, NSString *));
+
+        if (kCFCoreFoundationVersionNumber < 800)
+            [controller setTabBarItem:[[[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:legacy] tag:0] autorelease]];
+        else
+            [controller setTabBarItem:[[[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:normal] selectedImage:[UIImage imageNamed:select]] autorelease]];
+    }
+
+    va_end(args);
+
+    [self setViewControllers:controllers];
+}
 
 - (void) didReceiveMemoryWarning {
     [super didReceiveMemoryWarning];