Hook up find window to search table
This commit is contained in:
parent
adda2aed3c
commit
6886cc5a8f
|
@ -37,7 +37,8 @@ struct browser_window;
|
|||
-(void)stopThrobber;
|
||||
-(void)setNavigationUrl: (NSString*)urlString;
|
||||
-(void)setTitle: (NSString*)title;
|
||||
-(void)findNext: (NSString*)needle matchCase: (BOOL)matchCase;
|
||||
-(void)findPrevious: (NSString*)needle matchCase: (BOOL)matchCase;
|
||||
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase;
|
||||
-(void)findNext: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender;
|
||||
-(void)findPrevious: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender;
|
||||
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender;
|
||||
|
||||
@end
|
||||
|
|
|
@ -139,28 +139,28 @@
|
|||
[[self window] setTitle: title];
|
||||
}
|
||||
|
||||
-(void)findNext: (NSString*)needle matchCase: (BOOL)matchCase {
|
||||
-(void)findNext: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender {
|
||||
search_flags_t flags = SEARCH_FLAG_FORWARDS;
|
||||
if (matchCase) {
|
||||
flags |= SEARCH_FLAG_CASE_SENSITIVE;
|
||||
}
|
||||
browser_window_search(browser, NULL, flags, [needle cString]);
|
||||
browser_window_search(browser, (void*)sender, flags, [needle cString]);
|
||||
}
|
||||
|
||||
-(void)findPrevious: (NSString*)needle matchCase: (BOOL)matchCase {
|
||||
-(void)findPrevious: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender {
|
||||
search_flags_t flags = SEARCH_FLAG_BACKWARDS;
|
||||
if (matchCase) {
|
||||
flags |= SEARCH_FLAG_CASE_SENSITIVE;
|
||||
}
|
||||
browser_window_search(browser, NULL, flags, [needle cString]);
|
||||
browser_window_search(browser, (void*)sender, flags, [needle cString]);
|
||||
}
|
||||
|
||||
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase {
|
||||
-(void)showAll: (NSString*)needle matchCase: (BOOL)matchCase sender: (id)sender {
|
||||
search_flags_t flags = SEARCH_FLAG_SHOWALL;
|
||||
if (matchCase) {
|
||||
flags |= SEARCH_FLAG_CASE_SENSITIVE;
|
||||
}
|
||||
browser_window_search(browser, NULL, flags, [needle cString]);
|
||||
browser_window_search(browser, (void*)sender, flags, [needle cString]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
id searchField;
|
||||
id showAllButton;
|
||||
id browserController;
|
||||
id noResultsLabel;
|
||||
}
|
||||
-(void)setBrowserController: (id)aBrowserController;
|
||||
-(void)findPrevious: (id)sender;
|
||||
|
@ -15,4 +16,8 @@
|
|||
-(void)updateSearch: (id)sender;
|
||||
-(void)toggleMatchCase: (id)sender;
|
||||
|
||||
// Interface for use by search.h table
|
||||
-(void)setFound: (BOOL)found;
|
||||
-(void)setCanFindNext: (BOOL)canFindNext;
|
||||
-(void)setCanFindPrevious: (BOOL)canFindPrevious;
|
||||
@end
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
}
|
||||
|
||||
-(void)awakeFromNib {
|
||||
[noResultsLabel setHidden: YES];
|
||||
[[self window] makeKeyAndOrderFront: self];
|
||||
[self windowBecameMain: [NSNotification notificationWithName: @""
|
||||
object: [NSApp mainWindow]]];
|
||||
|
@ -42,33 +43,33 @@
|
|||
|
||||
-(void)setBrowserController: (id)aBrowserController {
|
||||
browserController = aBrowserController;
|
||||
BOOL enabled = browserController != nil;
|
||||
[previousButton setEnabled: enabled];
|
||||
[nextButton setEnabled: enabled];
|
||||
[matchCaseButton setEnabled: enabled];
|
||||
[showAllButton setEnabled: enabled];
|
||||
[previousButton setEnabled: NO];
|
||||
[nextButton setEnabled: NO];
|
||||
[showAllButton setEnabled: NO];
|
||||
}
|
||||
|
||||
-(void)findPrevious: (id)sender {
|
||||
[browserController findPrevious: [searchField stringValue]
|
||||
matchCase: [matchCaseButton state] == NSOnState];
|
||||
matchCase: [matchCaseButton state] == NSOnState sender: self];
|
||||
}
|
||||
|
||||
|
||||
-(void)findNext: (id)sender {
|
||||
[browserController findNext: [searchField stringValue]
|
||||
matchCase: [matchCaseButton state] == NSOnState];
|
||||
matchCase: [matchCaseButton state] == NSOnState sender: self];
|
||||
}
|
||||
|
||||
|
||||
-(void)showAll: (id)sender {
|
||||
[browserController showAll: [searchField stringValue]
|
||||
matchCase: [matchCaseButton state] == NSOnState];
|
||||
matchCase: [matchCaseButton state] == NSOnState sender: self];
|
||||
}
|
||||
|
||||
|
||||
-(void)updateSearch: (id)sender {
|
||||
|
||||
if (browserController != nil) {
|
||||
[self findNext: sender];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,4 +77,17 @@
|
|||
|
||||
}
|
||||
|
||||
-(void)setFound: (BOOL)found {
|
||||
[noResultsLabel setHidden: found];
|
||||
[showAllButton setEnabled: found];
|
||||
}
|
||||
|
||||
-(void)setCanFindNext: (BOOL)canFindNext {
|
||||
[nextButton setEnabled: canFindNext];
|
||||
}
|
||||
|
||||
-(void)setCanFindPrevious: (BOOL)canFindPrevious {
|
||||
[previousButton setEnabled: canFindPrevious];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
nextButton,
|
||||
matchCaseButton,
|
||||
searchField,
|
||||
showAllButton
|
||||
showAllButton,
|
||||
noResultsLabel
|
||||
);
|
||||
Super = NSWindowController;
|
||||
};
|
||||
|
|
Binary file not shown.
|
@ -11,6 +11,7 @@
|
|||
// Change displayed search status found/notfound?
|
||||
static void gnustep_search_status(bool found, void *p) {
|
||||
NSLog(@"gnustep_search_status");
|
||||
[(id)p setFound: found ? YES : NO];
|
||||
}
|
||||
|
||||
// Show hourglass if active else stop hourglass
|
||||
|
@ -26,11 +27,13 @@ static void gnustep_search_add_recent(const char *string, void *p) {
|
|||
// Set the next match button to active/inactive
|
||||
static void gnustep_search_forward_state(bool active, void *p) {
|
||||
NSLog(@"gnustep_search_forward_state");
|
||||
[(id)p setCanFindNext: active ? YES : NO];
|
||||
}
|
||||
|
||||
// set the previous match button to active/inactive
|
||||
static void gnustep_search_back_state(bool active, void *p) {
|
||||
NSLog(@"gnustep_search_back_state");
|
||||
[(id)p setCanFindPrevious: active ? YES : NO];
|
||||
}
|
||||
|
||||
struct gui_search_table gnustep_search_table = {
|
||||
|
|
Loading…
Reference in New Issue