summaryrefslogtreecommitdiff
path: root/cocoa
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
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')
-rw-r--r--cocoa/BrowserWindowController.m35
-rw-r--r--cocoa/res/BrowserWindow.xib24
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 @@
<string key="NSToolbarItemPaletteLabel">URL</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSTextField" key="NSToolbarItemView" id="77748234">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{0, 14}, {96, 22}}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1053649244">
<int key="NSCellFlags">-1804468671</int>
@@ -581,6 +579,14 @@
</object>
<int key="connectionID">67</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="1005"/>
+ <reference key="destination" ref="1001"/>
+ </object>
+ <int key="connectionID">68</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -838,14 +844,14 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">67</int>
+ <int key="maxID">68</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">BrowserView</string>
- <string key="superclassName">NSView</string>
+ <string key="superclassName">ScrollableView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">BrowserView.h</string>
@@ -1089,6 +1095,14 @@
<string key="minorKey">PSMTabBarControl/PSMTabStyle.h</string>
</object>
</object>
+ <object class="IBPartialClassDescription">
+ <string key="className">ScrollableView</string>
+ <string key="superclassName">NSView</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">ScrollableView.h</string>
+ </object>
+ </object>
</object>
<object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
<bool key="EncodedWithXMLCoder">YES</bool>