summaryrefslogtreecommitdiff
path: root/cocoa
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-02-27 09:46:54 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-02-27 09:46:54 +0000
commite1901889698454018150bfc58f469708837dfd7a (patch)
tree68cbf63380769e92d56f9adfbe522087766c5f27 /cocoa
parent1842be491dffdbc0b0d2dc8e3891d13369824887 (diff)
downloadnetsurf-e1901889698454018150bfc58f469708837dfd7a.tar.gz
netsurf-e1901889698454018150bfc58f469708837dfd7a.tar.bz2
Local history view now is responsible for hiding itself after selecting a web page. Also gets redrawn when selecting other pages using the back/forward buttons.
svn path=/trunk/netsurf/; revision=11837
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/BrowserView.h1
-rw-r--r--cocoa/BrowserView.m7
-rw-r--r--cocoa/BrowserViewController.h1
-rw-r--r--cocoa/BrowserViewController.m6
-rw-r--r--cocoa/HistoryView.h4
-rw-r--r--cocoa/HistoryView.m17
-rw-r--r--cocoa/LocalHistoryController.h8
-rw-r--r--cocoa/LocalHistoryController.m7
8 files changed, 34 insertions, 17 deletions
diff --git a/cocoa/BrowserView.h b/cocoa/BrowserView.h
index ceccab47c..5b3d3b577 100644
--- a/cocoa/BrowserView.h
+++ b/cocoa/BrowserView.h
@@ -46,5 +46,6 @@
- (void) addCaretAt: (NSPoint) point height: (CGFloat) height;
- (void) reformat;
+- (void) updateHistory;
@end
diff --git a/cocoa/BrowserView.m b/cocoa/BrowserView.m
index 131499d2c..990f42732 100644
--- a/cocoa/BrowserView.m
+++ b/cocoa/BrowserView.m
@@ -76,6 +76,11 @@ static NSMutableArray *cocoa_reformat_pending = nil;
}
}
+- (void) updateHistory;
+{
+ [history redraw];
+}
+
static inline NSRect cocoa_get_caret_rect( BrowserView *view )
{
NSRect caretRect = {
@@ -413,7 +418,7 @@ static browser_mouse_state cocoa_mouse_flags_for_event( NSEvent *evt )
historyVisible = newVisible;
if (historyVisible) {
- if (nil == history) history = [[LocalHistoryController alloc] initWithBrowser: browser];
+ if (nil == history) history = [[LocalHistoryController alloc] initWithBrowser: self];
[history attachToView: [(BrowserWindowController *)[[self window] windowController] historyButton]];
} else {
[history detach];
diff --git a/cocoa/BrowserViewController.h b/cocoa/BrowserViewController.h
index 6f409b395..f9085e44d 100644
--- a/cocoa/BrowserViewController.h
+++ b/cocoa/BrowserViewController.h
@@ -34,7 +34,6 @@ struct browser_window;
NSImage *favicon;
BOOL canGoBack;
BOOL canGoForward;
- BOOL navigatedUsingBackForwards;
}
@property (readwrite, assign, nonatomic) struct browser_window *browser;
diff --git a/cocoa/BrowserViewController.m b/cocoa/BrowserViewController.m
index 8a2bbf043..8f903c839 100644
--- a/cocoa/BrowserViewController.m
+++ b/cocoa/BrowserViewController.m
@@ -97,7 +97,6 @@
- (IBAction) goBack: (id) sender;
{
if (browser && history_back_available( browser->history )) {
- navigatedUsingBackForwards = YES;
history_back(browser, browser->history);
[self updateBackForward];
}
@@ -106,7 +105,6 @@
- (IBAction) goForward: (id) sender;
{
if (browser && history_forward_available( browser->history )) {
- navigatedUsingBackForwards = YES;
history_forward(browser, browser->history);
[self updateBackForward];
}
@@ -174,14 +172,14 @@ static inline bool compare_float( float a, float b )
- (void) updateBackForward;
{
+ [browserView updateHistory];
[self setCanGoBack: browser != NULL && history_back_available( browser->history )];
[self setCanGoForward: browser != NULL && history_forward_available( browser->history )];
}
- (void) contentUpdated;
{
- if (!navigatedUsingBackForwards) [browserView setHistoryVisible: NO];
- navigatedUsingBackForwards = NO;
+ [browserView updateHistory];
}
@end
diff --git a/cocoa/HistoryView.h b/cocoa/HistoryView.h
index 20806363f..d3062b6f1 100644
--- a/cocoa/HistoryView.h
+++ b/cocoa/HistoryView.h
@@ -19,12 +19,14 @@
#import <Cocoa/Cocoa.h>
@class HistoryView;
+@class BrowserView;
@interface HistoryView : NSView {
struct browser_window *browser;
+ BrowserView *browserView;
}
-@property (readwrite, assign, nonatomic) struct browser_window *browser;
+@property (readwrite, assign, nonatomic) BrowserView *browser;
- (void) updateHistory;
- (NSSize) size;
diff --git a/cocoa/HistoryView.m b/cocoa/HistoryView.m
index 49982b393..bf38b7716 100644
--- a/cocoa/HistoryView.m
+++ b/cocoa/HistoryView.m
@@ -20,6 +20,8 @@
#import "cocoa/font.h"
#import "cocoa/coordinates.h"
#import "cocoa/plotter.h"
+#import "cocoa/LocalHistoryController.h"
+#import "cocoa/BrowserView.h"
#import "desktop/browser.h"
#import "desktop/history_core.h"
@@ -27,11 +29,12 @@
@implementation HistoryView
-@synthesize browser;
+@synthesize browser = browserView;
-- (void) setBrowser: (struct browser_window *) bw;
+- (void) setBrowser: (BrowserView *) bw;
{
- browser = bw;
+ browserView = bw;
+ browser = [bw browser];
[self updateHistory];
}
@@ -63,9 +66,11 @@
{
const NSPoint location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
const bool newWindow = [theEvent modifierFlags] & NSCommandKeyMask;
- history_click( browser, browser->history,
- cocoa_pt_to_px( location.x ), cocoa_pt_to_px( location.y ),
- newWindow );
+ if (history_click( browser, browser->history,
+ cocoa_pt_to_px( location.x ), cocoa_pt_to_px( location.y ),
+ newWindow )) {
+ [browserView setHistoryVisible: NO];
+ }
}
- (BOOL) isFlipped;
diff --git a/cocoa/LocalHistoryController.h b/cocoa/LocalHistoryController.h
index d84ab8317..14a9abcdb 100644
--- a/cocoa/LocalHistoryController.h
+++ b/cocoa/LocalHistoryController.h
@@ -19,18 +19,20 @@
#import <Cocoa/Cocoa.h>
@class HistoryView;
+@class BrowserView;
@interface LocalHistoryController : NSWindowController {
HistoryView *history;
- struct browser_window *browser;
+ BrowserView *browser;
}
-@property (readwrite, assign, nonatomic) struct browser_window *browser;
+@property (readwrite, assign, nonatomic) BrowserView *browser;
@property (readwrite, assign, nonatomic) IBOutlet HistoryView *history;
-- initWithBrowser: (struct browser_window *) bw;
+- initWithBrowser: (BrowserView *) bw;
- (void) attachToView: (NSView *) view;
- (void) detach;
+- (void) redraw;
@end
diff --git a/cocoa/LocalHistoryController.m b/cocoa/LocalHistoryController.m
index 0e90b92c0..94d70d34e 100644
--- a/cocoa/LocalHistoryController.m
+++ b/cocoa/LocalHistoryController.m
@@ -26,7 +26,7 @@
@synthesize browser;
@synthesize history;
-- initWithBrowser: (struct browser_window *) bw;
+- initWithBrowser: (BrowserView *) bw;
{
if ((self = [super initWithWindowNibName: @"LocalHistoryPanel"]) == nil) return nil;
@@ -102,4 +102,9 @@
[history setBrowser: browser];
}
+- (void) redraw;
+{
+ [history setNeedsDisplay: YES];
+}
+
@end