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 +++++++++++++++++++++++++++++++++++ cocoa/res/BrowserWindow.xib | 24 +++++++++++++++++++----- 2 files changed, 54 insertions(+), 5 deletions(-) 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 diff --git a/cocoa/res/BrowserWindow.xib b/cocoa/res/BrowserWindow.xib index 1e8a6d437..9bb667d6f 100644 --- a/cocoa/res/BrowserWindow.xib +++ b/cocoa/res/BrowserWindow.xib @@ -145,11 +145,9 @@ URL - + 268 {{0, 14}, {96, 22}} - - YES -1804468671 @@ -581,6 +579,14 @@ 67 + + + delegate + + + + 68 + @@ -838,14 +844,14 @@ - 67 + 68 YES BrowserView - NSView + ScrollableView IBProjectSource BrowserView.h @@ -1089,6 +1095,14 @@ PSMTabBarControl/PSMTabStyle.h + + ScrollableView + NSView + + IBProjectSource + ScrollableView.h + + YES -- cgit v1.2.3