]> git.saurik.com Git - cydia.git/commitdiff
Untested (not even compiled), renamed to BrowserController and fixed buttons.
authorGrant Paul <chpwn@chpwn.com>
Thu, 23 Sep 2010 17:29:31 +0000 (10:29 -0700)
committerJay Freeman <saurik@Jay-Freemans-MacBook-Pro.local>
Mon, 4 Oct 2010 07:12:20 +0000 (00:12 -0700)
UICaboodle/BrowserView.mm

index 4523f91b37226c0269db9f31a3605fa95605609f..7855dcb30bf908c77d78e4258f6b09f9c8f4115e 100644 (file)
@@ -148,14 +148,14 @@ static Class $UIWebBrowserView;
 
 @end
 
-@interface BrowserViewActualView : UIView {
+@interface BrowserView : UIView {
 @private
     UIWebDocumentView *documentView;
 }
 @property (nonatomic, retain) UIWebDocumentView *documentView;
 @end
 
-@implementation BrowserViewActualView
+@implementation BrowserView
 
 @synthesize documentView;
 
@@ -177,7 +177,7 @@ static Class $UIWebBrowserView;
 
 #define lprintf(args...) fprintf(stderr, args)
 
-@implementation BrowserView
+@implementation BrowserController
 
 #if ShowInternals
 #include "UICaboodle/UCInternal.h"
@@ -207,7 +207,7 @@ static Class $UIWebBrowserView;
 
 - (void) dealloc {
 #if LogBrowser
-    NSLog(@"[BrowserView dealloc]");
+    NSLog(@"[BrowserController dealloc]");
 #endif
 
     if (challenge_ != nil)
@@ -555,7 +555,7 @@ static Class $UIWebBrowserView;
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
-       [self reloadButtons];
+       [self applyRightButton];
 }
 
 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function {
@@ -571,7 +571,7 @@ static Class $UIWebBrowserView;
         [function_ autorelease];
     function_ = function == nil ? nil : [function retain];
 
-       [self reloadButtons];
+       [self applyRightButton];
 }
 
 - (void) setFinishHook:(id)function {
@@ -645,7 +645,7 @@ static Class $UIWebBrowserView;
                 if (page == nil) {
                     /* XXX: call createWebViewWithRequest instead? */
 
-                    BrowserView *browser([[[class_ alloc] init] autorelease]);
+                    BrowserController *browser([[[class_ alloc] init] autorelease]);
                     [browser loadURL:url];
                     page = browser;
                 }
@@ -914,7 +914,7 @@ static Class $UIWebBrowserView;
     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_];
@@ -1031,10 +1031,37 @@ static Class $UIWebBrowserView;
         }
     }
 
-       [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]);
@@ -1045,7 +1072,7 @@ static Class $UIWebBrowserView;
     if (finish_ != nil)
         [self callFunction:finish_];
 
-       [self reloadButtons];
+       [self applyRightButton];
 }
 
 - (bool) isLoading {
@@ -1282,7 +1309,7 @@ static Class $UIWebBrowserView;
         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];
@@ -1502,18 +1529,18 @@ static Class $UIWebBrowserView;
         [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 {
@@ -1530,33 +1557,6 @@ static Class $UIWebBrowserView;
     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];