Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

options for revealing notes; remember bookmarks window visibility

  • Loading branch information...
commit 72bc59a288e381a56f84a4868d65ee8a53cbd9aa 1 parent 2f20a76
Zachary Schneirov authored
View
2  AlienNoteImporter.m
@@ -60,7 +60,7 @@ + (void)importBlorOrHelpFilesIfNecessaryIntoNotation:(NotationController*)notati
NSArray *helpNotes = [[[[AlienNoteImporter alloc] initWithStoragePaths:paths] autorelease] importedNotes];
if ([helpNotes count] > 0) {
[notation addNotes:helpNotes];
- [[notation delegate] notation:notation revealNote:[helpNotes lastObject]];
+ [[notation delegate] notation:notation revealNote:[helpNotes lastObject] options:NVEditNoteToReveal];
}
}
[prefsController setBlorImportAttempted:YES];
View
16 AppController.m
@@ -133,6 +133,7 @@ void outletObjectAwoke(id sender) {
- (void)runDelayedUIActionsAfterLaunch {
[[prefsController bookmarksController] setDelegate:self];
+ [[prefsController bookmarksController] restoreWindowFromSave];
[[prefsController bookmarksController] updateBookmarksUI];
[self updateNoteMenus];
[prefsController registerAppActivationKeystrokeWithTarget:self selector:@selector(toggleNVActivation:)];
@@ -240,7 +241,7 @@ - (void)applicationDidFinishLaunching:(NSNotification*)aNote {
@selector(setTableColumnsShowPreview:sender:), //when to tell notationcontroller to generate or disable note-body previews
@selector(setConfirmNoteDeletion:sender:),nil]; //whether "delete note" should have an ellipsis
- [self performSelector:@selector(runDelayedUIActionsAfterLaunch) withObject:nil afterDelay:0.1];
+ [self performSelector:@selector(runDelayedUIActionsAfterLaunch) withObject:nil afterDelay:0.0];
return;
terminateApp:
@@ -1194,7 +1195,7 @@ - (NoteObject*)createNoteIfNecessary {
return currentNote;
}
-- (void)notation:(NotationController*)notation revealNote:(NoteObject*)note {
+- (void)notation:(NotationController*)notation revealNote:(NoteObject*)note options:(NSUInteger)opts {
if (note) {
NSUInteger selectedNoteIndex = [notation indexInFilteredListForNoteIdenticalTo:note];
@@ -1206,7 +1207,16 @@ - (void)notation:(NotationController*)notation revealNote:(NoteObject*)note {
}
if (selectedNoteIndex != NSNotFound) {
- [notesTableView selectRowAndScroll:selectedNoteIndex];
+ if (opts & NVDoNotChangeScrollPosition) { //select the note only
+ [notesTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:selectedNoteIndex] byExtendingSelection:NO];
+ } else {
+ [notesTableView selectRowAndScroll:selectedNoteIndex];
+ }
+ }
+
+ if (opts & NVEditNoteToReveal) [window makeFirstResponder:textView];
+ if ((opts & NVOrderFrontWindow) && ![window isKeyWindow]) {
+ [window makeKeyAndOrderFront:nil];
}
} else {
[notesTableView deselectAll:self];
View
22 BookmarksController.h
@@ -59,8 +59,7 @@
NSArray *notes;
//for notifications
- id delegate, revealTarget;
- SEL revealAction;
+ id delegate, revealDelegate;
BOOL isRestoringSearch, isSelectingProgrammatically;
GlobalPrefs *prefsController;
@@ -71,6 +70,8 @@
IBOutlet NSPanel *window;
NSMenuItem *showHideBookmarksItem;
+
+ NoteBookmark *currentBookmark;
}
- (id)initWithBookmarks:(NSArray*)array;
@@ -82,21 +83,32 @@
- (void)selectBookmarkInTableView:(NoteBookmark*)bookmark;
-- (BOOL)restoreNoteBookmark:(NoteBookmark*)bookmark;
+- (BOOL)restoreNoteBookmark:(NoteBookmark*)bookmark inBackground:(BOOL)inBG;
- (void)restoreBookmark:(id)sender;
- (void)clearAllBookmarks:(id)sender;
- (void)hideBookmarks:(id)sender;
- (void)showBookmarks:(id)sender;
+- (void)restoreWindowFromSave;
+- (void)loadWindowIfNecessary;
+
- (void)addBookmark:(id)sender;
- (void)removeBookmark:(id)sender;
-- (void)setBookmarksMenu;
+- (void)regenerateBookmarksMenu;
+
+- (BOOL)isVisible;
- (void)updateBookmarksUI;
-- (void)setRevealTarget:(id)target selector:(SEL)selector;
+- (void)setRevealDelegate:(id)aDelegate;
- (id)delegate;
- (void)setDelegate:(id)aDelegate;
@end
+
+@interface NSObject (BookmarksControllerRevealDelegate)
+
+- (void)bookmarksController:(BookmarksController*)controller restoreNoteBookmark:(NoteBookmark*)aBookmark inBackground:(BOOL)inBG;
+
+@end
View
74 BookmarksController.m
@@ -140,6 +140,8 @@ - (void)awakeFromNib {
// [window setFloatingPanel:YES];
[window setDelegate:self];
[bookmarksTableView setDelegate:self];
+ [bookmarksTableView setTarget:self];
+ [bookmarksTableView setDoubleAction:@selector(doubleClicked:)];
[bookmarksTableView registerForDraggedTypes:[NSArray arrayWithObjects:MovedBookmarksType, nil]];
}
@@ -203,7 +205,7 @@ - (void)removeBookmarkForNote:(NoteObject*)aNote {
}
-- (void)setBookmarksMenu {
+- (void)regenerateBookmarksMenu {
NSMenu *menu = [NSApp mainMenu];
NSMenu *bookmarksMenu = [[menu itemWithTag:103] submenu];
@@ -246,7 +248,7 @@ - (void)updateBookmarksUI {
[prefsController saveCurrentBookmarksFromSender:self];
- [self setBookmarksMenu];
+ [self regenerateBookmarksMenu];
[bookmarksTableView reloadData];
}
@@ -276,28 +278,30 @@ - (BOOL)validateMenuItem:(NSMenuItem*)menuItem {
return YES;
}
-- (BOOL)restoreNoteBookmark:(NoteBookmark*)bookmark {
+- (BOOL)restoreNoteBookmark:(NoteBookmark*)bookmark inBackground:(BOOL)inBG{
if (bookmark) {
- //communicate with revealer here--tell it to search for this string and highlight note
- if ([revealTarget respondsToSelector:revealAction]) {
- isRestoringSearch = YES;
-
- [revealTarget performSelector:revealAction withObject:bookmark];
- [self selectBookmarkInTableView:bookmark];
-
- isRestoringSearch = NO;
- } else {
- NSLog(@"reveal target %@ doesn't respond to %s!", revealTarget, revealAction);
- return NO;
+ if (currentBookmark != bookmark) {
+ [currentBookmark autorelease];
+ currentBookmark = [bookmark retain];
}
+
+ //communicate with revealer here--tell it to search for this string and highlight note
+ isRestoringSearch = YES;
+
+ //BOOL inBG = ([[window currentEvent] modifierFlags] & NSCommandKeyMask) == 0;
+ [revealDelegate bookmarksController:self restoreNoteBookmark:bookmark inBackground:inBG];
+ [self selectBookmarkInTableView:bookmark];
+
+ isRestoringSearch = NO;
+
return YES;
}
return NO;
}
- (void)restoreBookmark:(id)sender {
- [self restoreNoteBookmark:[sender representedObject]];
+ [self restoreNoteBookmark:[sender representedObject] inBackground:NO];
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
@@ -322,17 +326,26 @@ - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColu
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
- return [bookmarks count];
+ return notes ? [bookmarks count] : 0;
}
- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex {
return NO;
}
+- (void)doubleClicked:(id)sender {
+ int row = [bookmarksTableView selectedRow];
+ if (row > -1) [self restoreNoteBookmark:[bookmarks objectAtIndex:row] inBackground:NO];
+}
+
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification {
if (!isRestoringSearch && !isSelectingProgrammatically) {
int row = [bookmarksTableView selectedRow];
- if (row > -1) [self restoreNoteBookmark:[bookmarks objectAtIndex:row]];
+ if (row > -1) {
+ if ([bookmarks objectAtIndex:row] != currentBookmark) {
+ [self restoreNoteBookmark:[bookmarks objectAtIndex:row] inBackground:YES];
+ }
+ }
[removeBookmarkButton setEnabled: row > -1];
}
@@ -419,12 +432,23 @@ - (void)windowWillClose:(NSNotification *)notification {
[showHideBookmarksItem setTitle:NSLocalizedString(@"Show Bookmarks",@"menu item title")];
}
+- (BOOL)isVisible {
+ return [window isVisible];
+}
+
- (void)hideBookmarks:(id)sender {
[window close];
}
-- (void)showBookmarks:(id)sender {
+- (void)restoreWindowFromSave {
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:@"BookmarksVisible"]) {
+ [self loadWindowIfNecessary];
+ [window orderBack:nil];
+ }
+}
+
+- (void)loadWindowIfNecessary {
if (!window) {
if (![NSBundle loadNibNamed:@"SavedSearches" owner:self]) {
NSLog(@"Failed to load SavedSearches.nib");
@@ -432,7 +456,12 @@ - (void)showBookmarks:(id)sender {
return;
}
[bookmarksTableView setDataSource:self];
- }
+ [bookmarksTableView reloadData];
+ }
+}
+
+- (void)showBookmarks:(id)sender {
+ [self loadWindowIfNecessary];
[bookmarksTableView reloadData];
[window makeKeyAndOrderFront:self];
@@ -499,9 +528,10 @@ - (void)removeBookmark:(id)sender {
}
}
-- (void)setRevealTarget:(id)target selector:(SEL)selector {
- revealTarget = target;
- revealAction = selector;
+- (void)setRevealDelegate:(id)aDelegate {
+ NSAssert([aDelegate respondsToSelector:@selector(bookmarksController:restoreNoteBookmark:inBackground:)], @"delegate must listen!");
+
+ revealDelegate = aDelegate;
}
- (id)delegate {
View
3  English.lproj/Preferences.nib/info.nib
@@ -10,8 +10,9 @@
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
- <integer>250</integer>
<integer>155</integer>
+ <integer>268</integer>
+ <integer>250</integer>
</array>
<key>IBSystem Version</key>
<string>9L31a</string>
View
BIN  English.lproj/Preferences.nib/keyedobjects.nib
Binary file not shown
View
5 GlobalPrefs.m
@@ -606,7 +606,10 @@ - (CFUUIDBytes)UUIDBytesOfLastSelectedNote {
- (void)saveCurrentBookmarksFromSender:(id)sender {
//run this during quit and when saved searches change?
NSArray *bookmarks = [bookmarksController dictionaryReps];
- if (bookmarks) [defaults setObject:bookmarks forKey:BookmarksKey];
+ if (bookmarks) {
+ [defaults setObject:bookmarks forKey:BookmarksKey];
+ [defaults setBool:[bookmarksController isVisible] forKey:@"BookmarksVisible"];
+ }
SEND_CALLBACKS();
}
View
2  Notation.freqorder
@@ -168,7 +168,7 @@ _hoursFromAbsoluteTime
-[PTHotKeyCenter init]
-[RBSplitView setDivider]
-[NotationController currentNoteStorageFormat]
--[BookmarksController setBookmarksMenu]
+-[BookmarksController regenerateBookmarksMenu]
-[NotationController databaseSettingsChangedFromOldFormat]
-[NotesTableView windowDidBecomeKey]
-[GlobalPrefs setNotationPrefssender]
View
2  Notation.launchorder
@@ -376,7 +376,7 @@ _dateCreatedStringOfNote
-[BookmarksController dictionaryReps]
-[NoteBookmark dictionaryRep]
+[NSString(NV) uuidStringWithBytes]
--[BookmarksController setBookmarksMenu]
+-[BookmarksController regenerateBookmarksMenu]
-[NoteBookmark description]
-[NoteBookmark noteObject]
-[BookmarksController noteWithUUIDBytes]
View
7 NotationController.h
@@ -140,8 +140,6 @@ void NotesDirFNSubscriptionProc(FNMessage message, OptionBits flags, void * refc
- (NoteObject*)addNote:(NSAttributedString*)attributedContents withTitle:(NSString*)title;
- (NoteObject*)addNoteFromCatalogEntry:(NoteCatalogEntry*)catEntry;
-- (void)restoreNoteBookmark:(NoteBookmark*)bookmark;
-
- (void)note:(NoteObject*)note didAddLabelSet:(NSSet*)labelSet;
- (void)note:(NoteObject*)note didRemoveLabelSet:(NSSet*)labelSet;
@@ -180,15 +178,18 @@ void NotesDirFNSubscriptionProc(FNMessage message, OptionBits flags, void * refc
@end
+enum { NVDefaultReveal = 0, NVDoNotChangeScrollPosition = 1, NVOrderFrontWindow = 2, NVEditNoteToReveal = 4 };
+
@interface NSObject (NotationControllerDelegate)
- (BOOL)notationListShouldChange:(NotationController*)someNotation;
- (void)notationListMightChange:(NotationController*)someNotation;
- (void)notationListDidChange:(NotationController*)someNotation;
- (void)notation:(NotationController*)notation wantsToSearchForString:(NSString*)string;
-- (void)notation:(NotationController*)notation revealNote:(NoteObject*)note;
+- (void)notation:(NotationController*)notation revealNote:(NoteObject*)note options:(NSUInteger)opts;
- (void)notation:(NotationController*)notation revealNotes:(NSArray*)notes;
- (void)contentsUpdatedForNote:(NoteObject*)aNoteObject;
- (void)titleUpdatedForNote:(NoteObject*)aNoteObject;
- (void)rowShouldUpdate:(NSInteger)affectedRow;
+
@end
View
18 NotationController.m
@@ -174,7 +174,7 @@ - (void)setDelegate:(id)theDelegate {
CFUUIDBytes bytes = [prefsController UUIDBytesOfLastSelectedNote];
NSUInteger noteIndex = [allNotes indexOfNoteWithUUIDBytes:&bytes];
if (noteIndex != NSNotFound)
- [delegate notation:self revealNote:[allNotes objectAtIndex:noteIndex]];
+ [delegate notation:self revealNote:[allNotes objectAtIndex:noteIndex] options:NVDoNotChangeScrollPosition];
}
- (void)upgradeDatabaseIfNecessary {
@@ -322,7 +322,7 @@ - (OSStatus)_readAndInitializeSerializedNotes {
//allow resolution of UUIDs to NoteObjects from saved searches
BookmarksController *ssController = [prefsController bookmarksController];
[ssController setNotes:allNotes];
- [ssController setRevealTarget:self selector:@selector(restoreNoteBookmark:)];
+ [ssController setRevealDelegate:self];
[prefsController setNotationPrefs:notationPrefs sender:self];
@@ -1139,7 +1139,7 @@ - (void)addNewNote:(NoteObject*)note {
[self resortAllNotes];
[self refilterNotes];
- [delegate notation:self revealNote:note];
+ [delegate notation:self revealNote:note options:NVEditNoteToReveal | NVOrderFrontWindow];
}
//do not update the view here (why not?)
@@ -1213,7 +1213,7 @@ - (void)addNotes:(NSArray*)noteArray {
if ([noteArray count] > 1)
[delegate notation:self revealNotes:noteArray];
else
- [delegate notation:self revealNote:[noteArray lastObject]];
+ [delegate notation:self revealNote:[noteArray lastObject] options:NVOrderFrontWindow];
}
- (void)note:(NoteObject*)note attributeChanged:(NSString*)attribute {
@@ -1441,11 +1441,11 @@ - (void)restyleAllNotes {
}
//used by BookmarksController
-- (void)restoreNoteBookmark:(NoteBookmark*)bookmark {
- if (bookmark) {
- [delegate notation:self wantsToSearchForString:[bookmark searchString]];
- [delegate notation:self revealNote:[bookmark noteObject]];
- //if selectedNote is non-nil, should focus be moved to data entry field?
+- (void)bookmarksController:(BookmarksController*)controller restoreNoteBookmark:(NoteBookmark*)aBookmark inBackground:(BOOL)inBG {
+ if (aBookmark) {
+ [delegate notation:self wantsToSearchForString:[aBookmark searchString]];
+ [delegate notation:self revealNote:[aBookmark noteObject] options: !inBG ? NVOrderFrontWindow : 0 ];
+ //if selectedNote is non-nil, should focus be moved to data entry field?, probably not; it can be dangerous to accidentally overwrite text
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.