]> git.saurik.com Git - cydia.git/blobdiff - UICaboodle/BrowserView.mm
Changed the package preferences controller to use UITableView rather than the private...
[cydia.git] / UICaboodle / BrowserView.mm
index 1adf247b24333fd73e612d8a3eecea8951459df8..7c123f9796cd49851c166b7ba29b1bc3f6ca8e06 100644 (file)
@@ -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,44 @@ 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) applyLoadingTitle {
+    [[self navigationItem] setTitle:UCLocalize("LOADING")];
+}
+
 - (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];
+           [[loadingitem_ view] addSubview:indicator_];
+        [self applyLoadingTitle];
+    } 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 +1487,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 +1580,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];