summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cydia.mm7
-rw-r--r--UICaboodle/BrowserView.h9
-rw-r--r--UICaboodle/BrowserView.mm82
3 files changed, 60 insertions, 38 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 36d65ed..02c2ae9 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -5258,11 +5258,14 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) {
}
- (void) actionButtonClicked {
- // Never reload, that's bad. However, do nothing unless we are loaded.
- // (Because free packages are never loading, their button will always work.)
+ // Wait until it's done loading.
if (![self isLoading])
[self _actionButtonClicked];
}
+
+- (void) reloadButtonClicked {
+ // You don't reload a package view by clicking the button.
+}
#endif
- (id) initWithDatabase:(Database *)database {
diff --git a/UICaboodle/BrowserView.h b/UICaboodle/BrowserView.h
index 69d0bfc..69fd35c 100644
--- a/UICaboodle/BrowserView.h
+++ b/UICaboodle/BrowserView.h
@@ -39,11 +39,11 @@
- (id) objectAtIndex:(unsigned)index;
@end
-@protocol BrowserViewDelegate
+@protocol BrowserControllerDelegate
- (UCViewController *) pageForURL:(NSURL *)url hasTag:(int *)tag;
@end
-@interface BrowserView : UCViewController {
+@interface BrowserController : UCViewController {
UIScroller *scroller_;
UIWebDocumentView *document_;
UIProgressIndicator *indicator_;
@@ -76,6 +76,9 @@
bool editing_;
Class class_;
+
+ id reloaditem_;
+ id loadingitem_;
}
+ (void) _initialize;
@@ -114,8 +117,6 @@
- (void) setFinishHook:(id)function;
- (void) setPopupHook:(id)function;
-- (id) _rightButtonTitle;
-
- (bool) promptForSensitive:(NSString *)name;
- (bool) allowSensitiveRequests;
diff --git a/UICaboodle/BrowserView.mm b/UICaboodle/BrowserView.mm
index 1adf247..793fe5d 100644
--- a/UICaboodle/BrowserView.mm
+++ b/UICaboodle/BrowserView.mm
@@ -279,6 +279,11 @@ static Class $UIWebBrowserView;
[sensitive_ release];
if (title_ != nil)
[title_ release];
+ if (reloaditem_ != nil)
+ [reloaditem_ release];
+ if (loadingitem_ != nil)
+ [loadingitem_ release];
+
[super dealloc];
}
@@ -1034,27 +1039,39 @@ static Class $UIWebBrowserView;
[self _startLoading];
}
+- (UINavigationButtonStyle) rightButtonStyle {
+ if (style_ == nil) normal:
+ return UINavigationButtonStyleNormal;
+ else if ([style_ isEqualToString:@"Normal"])
+ return UINavigationButtonStyleNormal;
+ else if ([style_ isEqualToString:@"Back"])
+ return UINavigationButtonStyleBack;
+ else if ([style_ isEqualToString:@"Highlighted"])
+ return UINavigationButtonStyleHighlighted;
+ else if ([style_ isEqualToString:@"Destructive"])
+ return UINavigationButtonStyleDestructive;
+ else goto normal;
+}
+
+- (UIBarButtonItem *) customButton {
+ UIBarButtonItem *customItem = [[UIBarButtonItem alloc]
+ initWithTitle:button_
+ style:[self rightButtonStyle]
+ target:self
+ action:@selector(customButtonClicked)
+ ];
+
+ return [customItem autorelease];
+}
+
- (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];
+ [[self navigationItem] setRightBarButtonItem:loadingitem_ animated:YES];
+ [[self navigationItem] setTitle:UCLocalize("LOADING")];
+ } else if (button_) {
+ [[self navigationItem] setRightBarButtonItem:[self customButton] animated:YES];
} 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];
- [reloadItem release];
+ [[self navigationItem] setRightBarButtonItem:reloaditem_ animated:YES];
}
}
@@ -1465,6 +1482,21 @@ static Class $UIWebBrowserView;
indicator_ = [[UIProgressIndicator alloc] initWithFrame:CGRectMake(15, 5, indsize.width, indsize.height)];
[indicator_ setStyle:UIProgressIndicatorStyleMediumWhite];
[indicator_ startAnimation];
+
+ reloaditem_ = [[UIBarButtonItem alloc]
+ initWithTitle:UCLocalize("RELOAD")
+ style:[self rightButtonStyle]
+ target:self
+ action:@selector(reloadButtonClicked)
+ ];
+
+ loadingitem_ = [[UIBarButtonItem alloc]
+ initWithTitle:@" "
+ style:UIBarButtonItemStylePlain
+ target:self
+ action:@selector(reloadButtonClicked)
+ ];
+ [[loadingitem_ view] addSubview:indicator_];
[scroller_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[indicator_ setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
@@ -1543,20 +1575,6 @@ static Class $UIWebBrowserView;
[self reloadButtonClicked];
}
-- (UINavigationButtonStyle) rightButtonStyle {
- if (style_ == nil) normal:
- return UINavigationButtonStyleNormal;
- else if ([style_ isEqualToString:@"Normal"])
- return UINavigationButtonStyleNormal;
- else if ([style_ isEqualToString:@"Back"])
- return UINavigationButtonStyleBack;
- else if ([style_ isEqualToString:@"Highlighted"])
- return UINavigationButtonStyleHighlighted;
- else if ([style_ isEqualToString:@"Destructive"])
- return UINavigationButtonStyleDestructive;
- else goto normal;
-}
-
- (void) setPageActive:(BOOL)active {
if (!active)
[indicator_ removeFromSuperview];