Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 78 lines (69 sloc) 2.43 kb
76d2a5b @mstroeck
mstroeck authored
1 //
2 // SearchPanel.m
3 // Vienna
4 //
5 // Created by Steve on Sat Jul 14 2007.
6 // Copyright (c) 2004-2007 Steve Palmer. All rights reserved.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 // See the License for the specific language governing permissions and
18 // limitations under the License.
19 //
20
21 #import "SearchPanel.h"
22 #import "BrowserPane.h"
23 #import "AppController.h"
24 #import "StringExtensions.h"
25
26 // Pull in the private functions we need from the delegate
27 @interface AppController (Private)
28 -(NSMenu *)searchFieldMenu;
29 -(void)searchArticlesWithString:(NSString *)searchString;
30 @end
31
32 @implementation SearchPanel
33
34 /* runSearchPanel
35 * Show the search panel.
36 */
37 -(void)runSearchPanel:(NSWindow *)window
38 {
39 if (!searchPanelWindow)
40 {
41 [NSBundle loadNibNamed:@"SearchPanel" owner:self];
42 [[searchField cell] setSearchMenuTemplate:[[NSApp delegate] searchFieldMenu]];
43 }
44 [searchLabel setStringValue:NSLocalizedString(@"Search all articles or the current web page", nil)];
45 [NSApp beginSheet:searchPanelWindow modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil];
46 }
47
48 /* newSearchString
49 * Change the search string displayed in the search field.
50 */
51 -(void)setSearchString:(NSString *)newSearchString
52 {
53 [searchField setStringValue:newSearchString];
54 }
55
56 /* searchStringChanged
57 * This function is called when the user hits the Enter or Cancel key in the search
58 * field. (Cancel blanks the searchField string value so searchArticlesWithString ends
59 * up doing nothing.)
60 */
61 -(IBAction)searchStringChanged:(id)sender;
62 {
63 [[NSApp delegate] setSearchString:[searchField stringValue]];
64
65 NSView<BaseView> * theView = [[[NSApp delegate] browserView] activeTabItemView];
66 if ([theView isKindOfClass:[BrowserPane class]])
67 {
68 [theView performFindPanelAction:NSFindPanelActionSetFindString];
69 [[NSApp delegate] setFocusToSearchField:self];
70 }
71 else
72 [[NSApp delegate] searchArticlesWithString:[searchField stringValue]];
73
74 [NSApp endSheet:searchPanelWindow];
75 [searchPanelWindow orderOut:self];
76 }
77 @end
Something went wrong with that request. Please try again.