summaryrefslogtreecommitdiff
path: root/cocoa/BookmarksController.m
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa/BookmarksController.m')
-rw-r--r--cocoa/BookmarksController.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/cocoa/BookmarksController.m b/cocoa/BookmarksController.m
index 76ea5c299..360010242 100644
--- a/cocoa/BookmarksController.m
+++ b/cocoa/BookmarksController.m
@@ -27,6 +27,11 @@
#import "desktop/tree.h"
#import "desktop/tree_url_node.h"
+@interface BookmarksController ()
+- (void) noteAppWillTerminate: (NSNotification *) note;
+- (void) save;
+@end
+
@implementation BookmarksController
@synthesize defaultMenu;
@@ -46,9 +51,24 @@ static const char *cocoa_hotlist_path( void )
hotlist_initialise( [tree tree], cocoa_hotlist_path(), "" );
nodeForMenu = NSCreateMapTable( NSNonOwnedPointerMapKeyCallBacks, NSNonOwnedPointerMapValueCallBacks, 0 );
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector( noteAppWillTerminate: )
+ name:NSApplicationWillTerminateNotification
+ object:NSApp];
+
return self;
}
+- (void) noteAppWillTerminate: (NSNotification *) note;
+{
+ [self save];
+}
+
+- (void) save;
+{
+ hotlist_export( cocoa_hotlist_path() );
+}
+
- (void) dealloc;
{
[self setView: nil];
@@ -56,6 +76,8 @@ static const char *cocoa_hotlist_path( void )
hotlist_cleanup( cocoa_hotlist_path() );
[tree release];
+ [[NSNotificationCenter defaultCenter] removeObserver: self];
+
[super dealloc];
}