@end
-@interface BrowserViewActualView : UIView {
+@interface BrowserView : UIView {
@private
UIWebDocumentView *documentView;
}
@property (nonatomic, retain) UIWebDocumentView *documentView;
@end
-@implementation BrowserViewActualView
+@implementation BrowserView
@synthesize documentView;
#define lprintf(args...) fprintf(stderr, args)
-@implementation BrowserView
+@implementation BrowserController
#if ShowInternals
#include "UICaboodle/UCInternal.h"
- (void) dealloc {
#if LogBrowser
- NSLog(@"[BrowserView dealloc]");
+ NSLog(@"[BrowserController dealloc]");
#endif
if (challenge_ != nil)
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
- [self reloadButtons];
+ [self applyRightButton];
}
- (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
[function_ autorelease];
function_ = function == nil ? nil : [function retain];
- [self reloadButtons];
+ [self applyRightButton];
}
- (void) setFinishHook:(id)function {
if (page == nil) {
/* XXX: call createWebViewWithRequest instead? */
- BrowserView *browser([[[class_ alloc] init] autorelease]);
+ BrowserController *browser([[[class_ alloc] init] autorelease]);
[browser loadURL:url];
page = browser;
}
UCNavigationController *navigation(!popup_ ? [self navigationController] : [[[UCNavigationController alloc] init] autorelease]);
/* XXX: deal with cydia:// pages */
- BrowserView *browser([[[class_ alloc] initWithWidth:width] autorelease]);
+ BrowserController *browser([[[class_ alloc] initWithWidth:width] autorelease]);
if (features != nil && popup_) {
[navigation setDelegate:delegate_];
}
}
- [self reloadButtons];
+ [self _startLoading];
}
-- (void) didFinishLoading { }
+- (void) applyRightButton {
+ if ([self isLoading]) {
+ UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
+ initWithTitle:@" "
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(reloadButtonClicked)
+ ];
+ [[self navigationItem] setRightBarButtonItem:reloadItem];
+ [[reloadItem view] addSubview:indicator_];
+ [[self navigationItem] setTitle:UCLocalize("LOADING")];
+ [reloadItem release];
+ } else {
+ UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
+ initWithTitle:button_ ?: UCLocalize("RELOAD")
+ style:[self rightButtonStyle]
+ target:self
+ action:button_ ? @selector(customButtonClicked) : @selector(reloadButtonClicked)
+ ];
+ [[self navigationItem] setRightBarButtonItem:reloadItem animated:YES];
+ [[self navigationItem] setTitle:title_];
+ [reloadItem release];
+ }
+}
+
+- (void) _startLoading {
+ [self applyRightButton];
+}
- (void) _finishLoading {
size_t count([loading_ count]);
if (finish_ != nil)
[self callFunction:finish_];
- [self reloadButtons];
+ [self applyRightButton];
}
- (bool) isLoading {
loading_ = [[NSMutableSet alloc] initWithCapacity:3];
popup_ = false;
- BrowserViewActualView *actualView = [[BrowserViewActualView alloc] initWithFrame:CGRectZero];
+ BrowserView *actualView = [[BrowserView alloc] initWithFrame:CGRectZero];
[self setView:actualView];
struct CGRect bounds = [[self view] bounds];
[self callFunction:closer_];
}
-- (void) __rightButtonClicked {
+- (void) reloadButtonClicked {
reloading_ = true;
[self reloadURL];
}
-- (void) _rightButtonClicked {
+- (void) customButtonClicked {
#if !AlwaysReload
if (function_ != nil)
[self callFunction:function_];
else
#endif
- [self __rightButtonClicked];
+ [self reloadButtonClicked];
}
- (UINavigationButtonStyle) rightButtonStyle {
else goto normal;
}
-- (void) reloadButtons {
- if ([self isLoading]) {
- UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
- initWithTitle:@" "
- style:UIBarButtonItemStylePlain
- target:self
- action:@selector(_rightButtonClicked)
- ];
- [[self navigationItem] setRightBarButtonItem:reloadItem];
- [[reloadItem view] addSubview:indicator_];
- [[self navigationItem] setTitle:UCLocalize("LOADING")];
- [reloadItem release];
- } else {
- UIBarButtonItem *reloadItem = [[UIBarButtonItem alloc]
- initWithTitle:button_ ?: UCLocalize("RELOAD")
- style:[self rightButtonStyle]
- target:self
- action:@selector(_rightButtonClicked)
- ];
- [[self navigationItem] setRightBarButtonItem:reloadItem animated:YES];
- [[self navigationItem] setTitle:title_];
- [reloadItem release];
-
- if (function_ == nil) [self didFinishLoading];
- }
-}
-
- (void) setPageActive:(BOOL)active {
if (!active)
[indicator_ removeFromSuperview];