summaryrefslogtreecommitdiff
path: root/cocoa/BrowserWindowController.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-20 11:38:16 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-20 11:38:16 +0000
commitafbcd370c5ac3404b97fa19296514776a394aa30 (patch)
tree4e0c13eaafd0ccab1e4209b3a7057b9f35a63fa5 /cocoa/BrowserWindowController.m
parentae37542582765d9643865854336ab6e94bc2f24b (diff)
downloadnetsurf-afbcd370c5ac3404b97fa19296514776a394aa30.tar.gz
netsurf-afbcd370c5ac3404b97fa19296514776a394aa30.tar.bz2
Improved tabs (draggable, can close last one)
svn path=/trunk/netsurf/; revision=11415
Diffstat (limited to 'cocoa/BrowserWindowController.m')
-rw-r--r--cocoa/BrowserWindowController.m35
1 files changed, 35 insertions, 0 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