Add initial skeleton for bookmarks window based on history window

This commit is contained in:
anthony 2021-01-04 19:58:24 +00:00
parent 6b6ffdab45
commit 87ed8db872
10 changed files with 112 additions and 5 deletions

View File

@ -30,11 +30,13 @@ NSMutableArray *recentHistory;
id downloadsWindowController;
id findPanelController;
id historyWindowController;
id bookmarksWindowController;
}
-(void)showFindPanel: (id)sender;
-(void)showDownloadsWindow: (id)sender;
-(void)showHistoryWindowController: (id)sender;
-(void)showHistoryWindow: (id)sender;
-(void)showBookmarksWindow: (id)sender;
-(NSURL*)requestDownloadDestination;
-(void)openWebsite: (Website*)aWebsite;

View File

@ -14,6 +14,7 @@
#import "FindPanelController.h"
#import "HistoryWindowController.h"
#import "Website.h"
#import "BookmarksWindowController.h"
#define MAX_RECENT_HISTORY 10
@ -108,7 +109,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
}
}
-(void)showHistoryWindowController: (id)sender {
-(void)showHistoryWindow: (id)sender {
NSLog(@"Showing history ...");
if (!historyWindowController) {
historyWindowController = [[HistoryWindowController alloc] init];
@ -118,6 +119,16 @@ static nserror set_defaults(struct nsoption_s *defaults)
}
}
-(void)showBookmarksWindow: (id)sender {
NSLog(@"Showing bookmarks...");
if (!bookmarksWindowController) {
bookmarksWindowController = [[BookmarksWindowController alloc] init];
[bookmarksWindowController loadWindow];
} else {
[bookmarksWindowController showWindow: self];
}
}
-(NSURL*)requestDownloadDestination {
NSSavePanel *savePanel = [NSOpenPanel savePanel];
[savePanel setDirectory: NSHomeDirectory()];

View File

@ -0,0 +1,11 @@
#include <AppKit/AppKit.h>
#include "BookmarkFolder.h"
@interface BookmarksWindowController: NSWindowController {
id outlineView;
id searchBar;
NSArray *topLevelFolders;
}
-(void)search: (id)sender;
-(void)clearSearch: (id)sender;
@end

View File

@ -0,0 +1,58 @@
#include <AppKit/AppKit.h>
#include "BookmarksWindowController.h"
#include "BookmarkFolder.h"
@implementation BookmarksWindowController
-(id)init {
if ((self = [super initWithWindowNibName: @"Bookmarks"])) {
// ...
}
return self;
}
-(void)onWindowAppeared {
topLevelFolders = [[BookmarkFolder rootBookmarkFolder] children];
}
-(void)awakeFromNib {
[[self window] makeKeyAndOrderFront: self];
[self onWindowAppeared];
}
-(void)showWindow: (id)sender {
[self onWindowAppeared];
[super showWindow: sender];
}
-(void)search: (id)sender {
NSLog(@"search bookmarks");
}
-(void)clearSearch: (id)sender {
NSLog(@"Clear bookmarks search");
}
-(id)outlineView: (NSOutlineView*)outlineView child: (NSInteger)index ofItem: (id)item {
return nil;
}
-(BOOL)outlineView: (NSOutlineView*)outlineView isItemExpandable: (id)item {
return NO;
}
-(NSInteger)outlineView: (NSOutlineView*)outlineView numberOfChildrenOfItem: (id)item {
if (item == nil) {
return [topLevelFolders count];
} else {
return [item count];
}
}
-(id)outlineView: (NSOutlineView*)outlineView objectValueForTableColumn: (NSTableColumn*)tableColumn byItem: (id)item {
return nil;
}
@end

View File

@ -47,6 +47,7 @@ S_FRONTEND := \
ProgressBarCell.m \
FindPanelController.m \
HistoryWindowController.m \
BookmarksWindowController.m \
Website.m \
BookmarkFolder.m \
tables/misc.m \
@ -76,6 +77,7 @@ R_RESOURCES := \
Downloads.gorm \
Find.gorm \
History.gorm \
Bookmarks.gorm \
R_RESOURCES := $(addprefix $(FRONTEND_RESOURCES_DIR)/,$(R_RESOURCES))

View File

@ -0,0 +1,21 @@
{
"## Comment" = "Do NOT change this file, Gorm maintains it";
BookmarksWindowController = {
Actions = (
"search:",
"clearSearch:"
);
Outlets = (
outlineView,
searchBar
);
Super = NSWindowController;
};
FirstResponder = {
Actions = (
"clearSearch:",
"search:"
);
Super = NSObject;
};
}

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,8 @@
"didTapNewWindow:",
"showDownloadsWindow:",
"showFindPanel:",
"showHistoryWindowController:"
"showHistoryWindow:",
"showBookmarksWindow:"
);
Outlets = (
);
@ -16,12 +17,13 @@
"didTapNewWindow:",
"findNext:",
"findPrevious:",
"showHistoryWindowController:",
"showBookmarksWindow:",
"remove:",
"removeAll:",
"showAll:",
"showDownloadsWindow:",
"showFindPanel:"
"showFindPanel:",
"showHistoryWindow:"
);
Super = NSObject;
};