summaryrefslogtreecommitdiff
path: root/UICaboodle
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2008-12-28 05:00:26 +0000
committerJay Freeman (saurik) <saurik@saurik.com>2010-09-30 07:09:22 +0000
commitaa5d0de7a71977eaf42728cfe4ab8ae31d1133a9 (patch)
tree5bc7f53cc3ee436e178ff0490d13ab0729e05e52 /UICaboodle
parent7594e0d2038278ab851fbb19521586a4a6fe6b97 (diff)
Doing another beta release.
Diffstat (limited to 'UICaboodle')
-rw-r--r--UICaboodle/BrowserView.m79
-rw-r--r--UICaboodle/RVBook.h21
-rw-r--r--UICaboodle/RVBook.mm38
3 files changed, 126 insertions, 12 deletions
diff --git a/UICaboodle/BrowserView.m b/UICaboodle/BrowserView.m
index 8734fe5..61a21c9 100644
--- a/UICaboodle/BrowserView.m
+++ b/UICaboodle/BrowserView.m
@@ -1,5 +1,46 @@
#include <BrowserView.h>
+/* Indirect Delegate {{{ */
+@interface IndirectDelegate : NSProxy {
+ _transient volatile id delegate_;
+}
+
+- (void) setDelegate:(id)delegate;
+- (id) initWithDelegate:(id)delegate;
+@end
+
+@implementation IndirectDelegate
+
+- (void) setDelegate:(id)delegate {
+ delegate_ = delegate;
+}
+
+- (id) initWithDelegate:(id)delegate {
+ delegate_ = delegate;
+ return self;
+}
+
+- (BOOL) respondsToSelector:(SEL)sel {
+ return delegate_ == nil ? FALSE : [delegate_ respondsToSelector:sel];
+}
+
+- (NSMethodSignature *) methodSignatureForSelector:(SEL)sel {
+ if (delegate_ != nil)
+ if (NSMethodSignature *sig = [delegate_ methodSignatureForSelector:sel])
+ return sig;
+ // XXX: I fucking hate Apple so very very bad
+ return [NSMethodSignature signatureWithObjCTypes:"v@:"];
+}
+
+- (void) forwardInvocation:(NSInvocation *)inv {
+ SEL sel = [inv selector];
+ if (delegate_ != nil && [delegate_ respondsToSelector:sel])
+ [inv invokeWithTarget:delegate_];
+}
+
+@end
+/* }}} */
+
@interface WebView (Cydia)
- (void) setScriptDebugDelegate:(id)delegate;
- (void) _setFormDelegate:(id)delegate;
@@ -309,8 +350,12 @@
}
/* }}} */
+- (void) webViewClose:(WebView *)sender {
+ [book_ close];
+}
+
- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
- [window setValue:self forKey:@"cydia"];
+ [window setValue:indirect_ forKey:@"cydia"];
}
- (void) webView:(WebView *)sender unableToImplementPolicyWithError:(NSError *)error frame:(WebFrame *)frame {
@@ -319,16 +364,30 @@
- (void) webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener {
if (NSURL *url = [request URL]) {
- if (name != nil && [name isEqualToString:@"_open"])
+ if (name == nil) unknown: {
+ NSLog(@"win:%@:%@", url, [action description]);
+ if (![self getSpecial:url]) {
+ NSString *scheme([[url scheme] lowercaseString]);
+ if ([scheme isEqualToString:@"mailto"])
+ [delegate_ openMailToURL:url];
+ else goto use;
+ }
+ } else if ([name isEqualToString:@"_open"])
[delegate_ openURL:url];
+ else if ([name isEqualToString:@"_popup"]) {
+ RVBook *book([[[RVPopUpBook alloc] initWithFrame:[delegate_ popUpBounds]] autorelease]);
+ [book setDelegate:self];
+
+ RVPage *page([delegate_ pageForURL:url hasTag:NULL]);
+ if (page == nil) {
+ BrowserView *browser([[[BrowserView alloc] initWithBook:book] autorelease]);
+ [browser loadURL:url];
+ page = browser;
+ }
- NSLog(@"win:%@:%@", url, [action description]);
- if (![self getSpecial:url]) {
- NSString *scheme([[url scheme] lowercaseString]);
- if ([scheme isEqualToString:@"mailto"])
- [delegate_ openMailToURL:url];
- else goto use;
- }
+ [book setPage:page];
+ [book_ pushBook:book];
+ } else goto unknown;
[listener ignore];
} else use:
@@ -359,7 +418,9 @@
if (request_ != nil)
[request_ autorelease];
request_ = [request retain];
+#if ForSaurik
NSLog(@"dpn:%@", request_);
+#endif
}
[listener use];
diff --git a/UICaboodle/RVBook.h b/UICaboodle/RVBook.h
index 88a5191..a7781e7 100644
--- a/UICaboodle/RVBook.h
+++ b/UICaboodle/RVBook.h
@@ -1,12 +1,18 @@
#import "UICaboodle.h"
-#import <UIKit/UIView.h>
+#import <UIKit/UIKit.h>
@class NSMutableArray;
+@class RVBook;
@class RVPage;
@class UINavigationBar;
@class UITransitionView;
+@interface UIView (PopUpView)
+- (void) popFromSuperviewAnimated:(BOOL)animated;
+- (void) popSubview:(UIView *)view;
+@end
+
@protocol RVNavigationBarDelegate
@end
@@ -14,6 +20,8 @@
- (void) setPageActive:(BOOL)active with:(id)object;
- (void) resetViewAnimated:(BOOL)animated with:(id)object;
- (void) reloadDataWith:(id)object;
+- (void) popUpBook:(RVBook *)book;
+- (CGRect) popUpBounds;
@end
@interface RVBook : UIView <
@@ -24,6 +32,7 @@
UITransitionView *transition_;
BOOL resetting_;
_transient id delegate_;
+ UIToolbar *toolbar_;
}
- (UINavigationBar *) navigationBar;
@@ -36,6 +45,8 @@
- (void) pushPage:(RVPage *)page;
- (void) popPages:(unsigned)pages;
+- (void) pushBook:(RVBook *)book;
+
- (void) resetViewAnimated:(BOOL)animated;
- (void) resetViewAnimated:(BOOL)animated toPage:(RVPage *)page;
@@ -47,5 +58,13 @@
- (void) reloadData;
- (CGRect) pageBounds;
+- (void) close;
+
+@end
+
+@interface RVPopUpBook : RVBook {
+ _transient RVBook *parent_;
+ bool cancel_;
+}
@end
diff --git a/UICaboodle/RVBook.mm b/UICaboodle/RVBook.mm
index a6f5318..b1bbce6 100644
--- a/UICaboodle/RVBook.mm
+++ b/UICaboodle/RVBook.mm
@@ -52,7 +52,6 @@
- (id) createButtonWithContents:(id)contents width:(float)width barStyle:(int)barStyle buttonStyle:(int)style isRight:(BOOL)right {
float adjust = [contents widthForButtonContents:width];
- NSLog(@"cc:%@:%g:%g", contents, width, adjust);
width = adjust;
return [super createButtonWithContents:contents width:width barStyle:barStyle buttonStyle:style isRight:right];
}
@@ -63,10 +62,14 @@
- (void) dealloc {
[navbar_ setDelegate:nil];
+ if (toolbar_ != nil)
+ [toolbar_ setDelegate:nil];
[pages_ release];
[navbar_ release];
[transition_ release];
+ if (toolbar_ != nil)
+ [toolbar_ release];
[super dealloc];
}
@@ -157,6 +160,10 @@
[navbar_ setAccessoryView:[page accessoryView] animate:animated removeOnPop:NO];
}
+- (void) pushBook:(RVBook *)book {
+ [delegate_ popUpBook:book];
+}
+
- (void) popPages:(unsigned)pages {
if (pages == 0)
return;
@@ -213,10 +220,14 @@
[navitem setTitle:title];
}
+- (NSString *) _leftButtonTitleForPage:(RVPage *)page {
+ return [page leftButtonTitle];
+}
+
- (void) reloadButtonsForPage:(RVPage *)page {
if ([pages_ count] == 0 || page != [pages_ lastObject])
return;
- NSString *leftButtonTitle([page leftButtonTitle]);
+ NSString *leftButtonTitle([self _leftButtonTitleForPage:page]);
UINavigationButtonStyle leftButtonStyle = [page leftButtonStyle];
UINavigationButtonStyle rightButtonStyle = [page rightButtonStyle];
//[navbar_ showButtonsWithLeftTitle:leftButtonTitle rightTitle:[page rightButtonTitle] leftBack:(leftButtonTitle == nil)];
@@ -244,4 +255,27 @@
return [transition_ bounds];
}
+- (void) close {
+}
+
+@end
+
+@implementation RVPopUpBook
+
+- (NSString *) _leftButtonTitleForPage:(RVPage *)page {
+ NSString *title([super _leftButtonTitleForPage:page]);
+ return (cancel_ = title == nil && [pages_ count] == 1) ? @"Cancel" : title;
+}
+
+- (void) navigationBar:(UINavigationBar *)navbar buttonClicked:(int)button {
+ if (button == 1 && cancel_)
+ [self close];
+ else
+ [super navigationBar:navbar buttonClicked:button];
+}
+
+- (void) close {
+ [self popFromSuperviewAnimated:YES];
+}
+
@end