From afbcd370c5ac3404b97fa19296514776a394aa30 Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Thu, 20 Jan 2011 11:38:16 +0000 Subject: Improved tabs (draggable, can close last one) svn path=/trunk/netsurf/; revision=11415 --- cocoa/BrowserWindowController.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'cocoa/BrowserWindowController.m') diff --git a/cocoa/BrowserWindowController.m b/cocoa/BrowserWindowController.m index 84be95c56..ff40bf094 100644 --- a/cocoa/BrowserWindowController.m +++ b/cocoa/BrowserWindowController.m @@ -48,6 +48,8 @@ - (void) awakeFromNib; { [tabBar setShowAddTabButton: YES]; + [tabBar setTearOffStyle: PSMTabBarTearOffMiniwindow]; + [tabBar setCanCloseOnlyTab: YES]; NSButton *b = [tabBar addTabButton]; [b setTarget: self]; @@ -79,6 +81,13 @@ } } +- (void) windowWillClose: (NSNotification *)notification; +{ + for (NSTabViewItem *tab in [tabView tabViewItems]) { + [tabView removeTabViewItem: tab]; + } +} + extern NSString * const kHomepageURL; - (IBAction) newTab: (id) sender; { @@ -101,4 +110,30 @@ extern NSString * const kHomepageURL; [self setActiveBrowser: [tabViewItem identifier]]; } +- (BOOL)tabView:(NSTabView*)aTabView shouldDragTabViewItem:(NSTabViewItem *)tabViewItem fromTabBar:(PSMTabBarControl *)tabBarControl +{ + return YES; +} + +- (BOOL)tabView:(NSTabView*)aTabView shouldDropTabViewItem:(NSTabViewItem *)tabViewItem inTabBar:(PSMTabBarControl *)tabBarControl +{ + [[tabViewItem identifier] setWindowController: self]; + return YES; +} + +- (PSMTabBarControl *)tabView:(NSTabView *)aTabView newTabBarForDraggedTabViewItem:(NSTabViewItem *)tabViewItem atPoint:(NSPoint)point; +{ + BrowserWindowController *newWindow = [[[BrowserWindowController alloc] init] autorelease]; + [[tabViewItem identifier] setWindowController: newWindow]; + [[newWindow window] setFrameOrigin: point]; + return newWindow->tabBar; +} + +- (void) tabView: (NSTabView *)aTabView didCloseTabViewItem: (NSTabViewItem *)tabViewItem; +{ + [tabViewItem unbind: @"label"]; + browser_window_destroy( [[tabViewItem identifier] browser] ); + [self setActiveBrowser: nil]; +} + @end -- cgit v1.2.3