adium 4627:95da8db60c71: A better fix for 281ad094f064 which cau...
commits at adium.im
commits at adium.im
Mon Jan 30 23:37:54 UTC 2012
details: http://hg.adium.im/adium/rev/95da8db60c71
revision: 4627:95da8db60c71
branch: PreferencesRedux
author: Frank Dowsett <wixardy at adium.im>
date: Mon Jan 30 14:34:59 2012 -0500
A better fix for 281ad094f064 which caused the search terms to be skipped.
Subject: adium 4628:d481cecc1857: Fix #15801 by defining a minimum width for the preferences window.
details: http://hg.adium.im/adium/rev/d481cecc1857
revision: 4628:d481cecc1857
branch: PreferencesRedux
author: Frank Dowsett <wixardy at adium.im>
date: Mon Jan 30 14:41:57 2012 -0500
Fix #15801 by defining a minimum width for the preferences window.
Subject: adium 4629:dd03cfd7c557: Rename 'Message Style' pane to 'Message View' fixing #15802.
details: http://hg.adium.im/adium/rev/dd03cfd7c557
revision: 4629:dd03cfd7c557
branch: PreferencesRedux
author: Frank Dowsett <wixardy at adium.im>
date: Mon Jan 30 14:45:06 2012 -0500
Rename 'Message Style' pane to 'Message View' fixing #15802.
Subject: adium 4630:525b4caa1484: Make use of the scores when searching in preferences and select the best match. Fixes #15796
details: http://hg.adium.im/adium/rev/525b4caa1484
revision: 4630:525b4caa1484
branch: PreferencesRedux
author: Frank Dowsett <wixardy at adium.im>
date: Mon Jan 30 18:35:48 2012 -0500
Make use of the scores when searching in preferences and select the best match. Fixes #15796
diffs (133 lines):
diff -r bb19311a49fc -r 525b4caa1484 Plugins/WebKit Message View/ESWebKitMessageViewPreferences.m
--- a/Plugins/WebKit Message View/ESWebKitMessageViewPreferences.m Fri Jan 27 10:46:04 2012 -0500
+++ b/Plugins/WebKit Message View/ESWebKitMessageViewPreferences.m Mon Jan 30 18:35:48 2012 -0500
@@ -80,7 +80,7 @@
return @"Messages";
}
- (NSString *)paneName{
- return AILocalizedString(@"Message Style", "Title of the messages preferences");
+ return AILocalizedString(@"Message View", "Title of the messages preferences");
}
- (NSString *)nibName{
return @"WebKitPreferencesView";
diff -r bb19311a49fc -r 525b4caa1484 Resources/en.lproj/SearchTerms.plist
--- a/Resources/en.lproj/SearchTerms.plist Fri Jan 27 10:46:04 2012 -0500
+++ b/Resources/en.lproj/SearchTerms.plist Mon Jan 30 18:35:48 2012 -0500
@@ -60,7 +60,7 @@
<array>
<dict>
<key>index</key>
- <string>dock, emoticon, menu, bar, service, status, icon</string>
+ <string>dock, emoticons, menu, bar, service, status</string>
<key>title</key>
<string></string>
</dict>
diff -r bb19311a49fc -r 525b4caa1484 Source/AIPreferenceWindowController.m
--- a/Source/AIPreferenceWindowController.m Fri Jan 27 10:46:04 2012 -0500
+++ b/Source/AIPreferenceWindowController.m Mon Jan 30 18:35:48 2012 -0500
@@ -30,6 +30,7 @@
#define SUGGESTION_ENTRY_HEIGHT 17
#define PREFERENCES_LAST_PANE_KEY @"Preferences Last Pane"
+#define PREFERENCES_MINIMUM_WIDTH 600
@interface AIPreferenceWindowController ()
- (void)showPreferencesWindow;
@@ -188,6 +189,8 @@
return;
}
+ __block NSMutableSet *skipSet = [[[NSMutableSet alloc] init] autorelease];
+
if (termsURL) {
NSDictionary *terms = [NSDictionary dictionaryWithContentsOfURL:termsURL];
//The file is laid out with each pane having an array of sections with each section having search terms
@@ -198,7 +201,7 @@
[(NSArray *)paneSection enumerateObjectsUsingBlock:^(id termDict, NSUInteger idx, BOOL *aStop) {
NSString *title = [termDict objectForKey:@"title"];
if ([title isEqualToString:@""])
- return;
+ [skipSet addObject:pane];
NSString *paneURL = [NSString stringWithFormat:@"%@/%@", pane, title];
SKDocumentRef doc = SKDocumentCreate((CFStringRef)@"file",
@@ -219,6 +222,9 @@
//Add each pane to the index
id _skPaneNames = ^(id obj, NSUInteger idx, BOOL *stop) {
NSString *paneName = [obj paneName];
+ if ([skipSet containsObject:paneName])
+ return;
+
NSString *paneURL = [NSString stringWithFormat:@"%@/", paneName];
SKDocumentRef doc = SKDocumentCreate((CFStringRef)@"file",
NULL,
@@ -349,7 +355,7 @@
NSRect contentFrame = [[self.window contentView] frame];
windowFrame.size.height = viewFrame.size.height + (windowFrame.size.height - contentFrame.size.height);
- windowFrame.size.width = viewFrame.size.width;
+ windowFrame.size.width = MAX(viewFrame.size.width, PREFERENCES_MINIMUM_WIDTH);
windowFrame.origin.y += (contentFrame.size.height - viewFrame.size.height);
[self.window setFrame:windowFrame display:YES animate:YES];
@@ -511,6 +517,20 @@
[suggestionsWindow setFrame:frame display:NO];
[window addChildWindow:suggestionsWindow ordered:NSWindowAbove];
+
+ //Select the best match
+ if ([entries count] == 1) {
+ //If there's only one entry, select it
+ [self setSelectedView:[[suggestionsWindow.contentView subviews] objectAtIndex:0]];
+ } else if ([entries count] < 5) {
+ //Only select one when there are fewer than five entries
+ float score1 = [(NSNumber *)[[entries objectAtIndex:0] objectForKey:@"score"] floatValue];
+ float score2 = [(NSNumber *)[[entries objectAtIndex:1] objectForKey:@"score"] floatValue];
+
+ //Make sure the score between the top two is at least 5 points
+ if ((score1 - score2) > 5)
+ [self setSelectedView:[[suggestionsWindow.contentView subviews] objectAtIndex:0]];
+ }
}
#pragma mark - Suggestions Mouse and Keyboard Tracking
@@ -574,6 +594,7 @@
int kSearchMax = 20;
CFURLRef foundURLs[kSearchMax];
SKDocumentID foundDocIDs[kSearchMax];
+ float foundScores[kSearchMax];
UInt32 totalCount = 0;
BOOL more = YES;
while (more) {
@@ -581,7 +602,7 @@
more = SKSearchFindMatches (search,
kSearchMax,
foundDocIDs,
- NULL,
+ foundScores,
1,
&foundCount);
//Display or accumulate results here
@@ -591,7 +612,7 @@
for (int i = 0; i < foundCount; i++) {
NSString *paneName = [[(NSURL *)foundURLs[i] pathComponents] objectAtIndex:1];
AIPreferencePane *pane = [panes objectForKey:paneName];
- [results addObject:[NSDictionary dictionaryWithObjectsAndKeys:[(NSURL *)foundURLs[i] lastPathComponent], @"title", pane, @"pane", nil]];
+ [results addObject:[NSDictionary dictionaryWithObjectsAndKeys:[(NSURL *)foundURLs[i] lastPathComponent], @"title", pane, @"pane", [NSNumber numberWithFloat:foundScores[i]], @"score", nil]];
[(NSURL *)foundURLs[i] release];
NSUInteger idx = [generalPaneArray indexOfObject:pane];
if (idx != NSNotFound)
@@ -614,9 +635,11 @@
[eventsCV setSelectionIndexes:eventsIndexes];
[advancedCV setSelectionIndexes:advancedIndexes];
- if (results.count > 0)
+ if (results.count > 0) {
+ //Sort by score
+ [results sortUsingDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"score" ascending:NO]]];
[self layoutEntries:results];
- else
+ } else
[self cancelSuggestions];
}
More information about the commits
mailing list