From 297566744d63fffb6f2023cd58de7d4b0300a95f Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 2 Mar 2011 08:46:28 -0800 Subject: [PATCH] Fit ManageController to CyteWebViewController {custom,right}Button API. --- CyteKit/WebViewController.h | 1 + CyteKit/WebViewController.mm | 17 +++++++++++++---- MobileCydia.mm | 33 +++++++++------------------------ 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/CyteKit/WebViewController.h b/CyteKit/WebViewController.h index d2f9fb5a..db40a1c1 100644 --- a/CyteKit/WebViewController.h +++ b/CyteKit/WebViewController.h @@ -125,6 +125,7 @@ - (void) customButtonClicked; - (void) applyRightButton; +- (UIBarButtonItem *) customButton; - (UIBarButtonItem *) rightButton; - (void) _didStartLoading; diff --git a/CyteKit/WebViewController.mm b/CyteKit/WebViewController.mm index b954b8ea..b59d8302 100644 --- a/CyteKit/WebViewController.mm +++ b/CyteKit/WebViewController.mm @@ -598,7 +598,12 @@ float CYScrollViewDecelerationRateNormal; } - (UIBarButtonItem *) customButton { - return custom_ == [NSNull null] ? nil : [[[UIBarButtonItem alloc] + if (custom_ == nil) + return nil; + else if (custom_ == [NSNull null]) + return (UIBarButtonItem *) [NSNull null]; + + return [[[UIBarButtonItem alloc] initWithTitle:static_cast(custom_.operator NSObject *()) style:[self rightButtonStyle] target:self @@ -629,9 +634,13 @@ float CYScrollViewDecelerationRateNormal; } else { [indicator_ stopAnimating]; - [[self navigationItem] setRightBarButtonItem:( - custom_ != nil ? [self customButton] : [self rightButton] - ) animated:YES]; + UIBarButtonItem *button([self customButton]); + if (button == nil) + button = [self rightButton]; + else if (button == (UIBarButtonItem *) [NSNull null]) + button = nil; + + [[self navigationItem] setRightBarButtonItem:button]; } } diff --git a/MobileCydia.mm b/MobileCydia.mm index 52081b21..2257a19c 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -6459,46 +6459,31 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { target:self action:@selector(settingsButtonClicked) ] autorelease]]; - - [self queueStatusDidChange]; } - (void) settingsButtonClicked { [delegate_ showSettings]; } -#if !AlwaysReload - (void) queueButtonClicked { [delegate_ queue]; } -- (void) applyLoadingTitle { - // Disable "Loading" title. -} - -- (void) applyRightButton { - // Disable right button. +- (UIBarButtonItem *) customButton { + return Queuing_ ? [[[UIBarButtonItem alloc] + initWithTitle:UCLocalize("QUEUE") + style:UIBarButtonItemStyleDone + target:self + action:@selector(queueButtonClicked) + ] autorelease] : [super customButton]; } -#endif - (void) queueStatusDidChange { -#if !AlwaysReload - if (!IsWildcat_ && Queuing_) { - [[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc] - initWithTitle:UCLocalize("QUEUE") - style:UIBarButtonItemStyleDone - target:self - action:@selector(queueButtonClicked) - ] autorelease]]; - } else { - [[self navigationItem] setRightBarButtonItem:nil]; - } -#endif + [self applyRightButton]; } - (bool) isLoading { - // Never show as loading. - return false; + return !Queuing_ && [super isLoading]; } @end -- 2.45.2