diff --git a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib index 1e2d7aa6ff9..a06ff898b74 100644 --- a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib +++ b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/classes.nib @@ -36,9 +36,11 @@ mAskAboutCookies = NSButton; mAutoFillPasswords = NSButton; mCookieBehavior = NSMatrix; + mCookiesFilterField = SearchTextField; mCookiesPanel = id; mCookiesTable = ExtendedTableView; mPermissionColumn = NSTableColumn; + mPermissionFilterField = SearchTextField; mPermissionsPanel = id; mPermissionsTable = ExtendedTableView; mRemoveCookiesButton = NSButton; @@ -46,7 +48,13 @@ }; SUPERCLASS = PreferencePaneBase; }, - {CLASS = PreferencePaneBase; LANGUAGE = ObjC; SUPERCLASS = NSPreferencePane; } + {CLASS = PreferencePaneBase; LANGUAGE = ObjC; SUPERCLASS = NSPreferencePane; }, + { + ACTIONS = {selectText = id; }; + CLASS = SearchTextField; + LANGUAGE = ObjC; + SUPERCLASS = NSTextField; + } ); IBVersion = 1; } \ No newline at end of file diff --git a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib index 9b44d2ea3a8..ec3946e43de 100644 --- a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib +++ b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/info.nib @@ -3,9 +3,14 @@ IBDocumentLocation - 139 60 356 240 0 0 1600 1002 + 103 55 356 240 0 0 1280 938 IBFramework Version - 364.0 + 362.0 + IBOpenObjects + + 5 + 401 + IBSystem Version 7S215 diff --git a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/objects.nib b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/objects.nib index b28357259fe..a5bccb49aba 100644 Binary files a/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/objects.nib and b/camino/PreferencePanes/Privacy/English.lproj/Privacy.nib/objects.nib differ diff --git a/camino/PreferencePanes/Privacy/PrivacyPane.h b/camino/PreferencePanes/Privacy/PrivacyPane.h index 5c2a62047af..2978604d1ef 100644 --- a/camino/PreferencePanes/Privacy/PrivacyPane.h +++ b/camino/PreferencePanes/Privacy/PrivacyPane.h @@ -3,6 +3,7 @@ #import "PreferencePaneBase.h" #include "nsCOMArray.h" #import "ExtendedTableView.h" +#import "SearchTextField.h" class nsIPref; class nsIPermissionManager; @@ -27,7 +28,7 @@ class nsICookie; IBOutlet id mPermissionsPanel; IBOutlet ExtendedTableView* mPermissionsTable; IBOutlet NSTableColumn* mPermissionColumn; - + IBOutlet SearchTextField* mPermissionFilterField; nsIPermissionManager* mPermissionManager; // STRONG (should be nsCOMPtr) nsCOMArray* mCachedPermissions; // parallel list for speed, STRONG @@ -35,7 +36,7 @@ class nsICookie; IBOutlet id mCookiesPanel; IBOutlet ExtendedTableView* mCookiesTable; IBOutlet NSButton* mRemoveCookiesButton; - + IBOutlet SearchTextField* mCookiesFilterField; nsICookieManager* mCookieManager; nsCOMArray* mCachedCookies; } diff --git a/camino/PreferencePanes/Privacy/PrivacyPane.mm b/camino/PreferencePanes/Privacy/PrivacyPane.mm index 37d60e372e1..aa22da61432 100644 --- a/camino/PreferencePanes/Privacy/PrivacyPane.mm +++ b/camino/PreferencePanes/Privacy/PrivacyPane.mm @@ -13,6 +13,7 @@ #include "nsIURI.h" #include "nsNetUtil.h" #include "nsString.h" +#include "STFPopUpButtonCell.h" // we should really get this from "CHBrowserService.h", // but that requires linkage and extra search paths. @@ -262,6 +263,10 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, NSPopUpButtonCell *popupButtonCell = [mPermissionColumn dataCell]; [popupButtonCell setEditable:YES]; [popupButtonCell addItemsWithTitles:[NSArray arrayWithObjects:[self getLocalizedString:@"Allow"], [self getLocalizedString:@"Deny"], nil]]; + + //remove the popup from the filter input fields + [[mPermissionFilterField cell] setHasPopUpButton: NO]; + [[mCookiesFilterField cell] setHasPopUpButton: NO]; } -(void) mapCookiePrefToGUI: (int)pref @@ -325,6 +330,10 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, } } + //clear the filter field + // + [mCookiesFilterField setStringValue: @""]; + // we shouldn't need to do this, but the scrollbar won't enable unless we // force the table to reload its data. Oddly it gets the number of rows correct, // it just forgets to tell the scrollbar. *shrug* @@ -442,6 +451,10 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, if ([mPermissionsTable respondsToSelector:@selector(setUsesAlternatingRowBackgroundColors:)]) [mPermissionsTable setUsesAlternatingRowBackgroundColors:YES]; + //clear the filter field + // + [mPermissionFilterField setStringValue: @""]; + // we shouldn't need to do this, but the scrollbar won't enable unless we // force the table to reload its data. Oddly it gets the number of rows correct, // it just forgets to tell the scrollbar. *shrug* @@ -800,4 +813,44 @@ PR_STATIC_CALLBACK(int) compareValues(nsICookie* aCookie1, nsICookie* aCookie2, CFRelease(fileSystemURL); } } + +- (void)controlTextDidChange:(NSNotification *)aNotification +{ + NSString *filterString = [[aNotification object] stringValue]; + nsCAutoString host; + + // find out if we are filtering the permission or the cookies + if (([aNotification object] == mPermissionFilterField) && mCachedPermissions && mPermissionManager) { + // the user wants to filter down the list of cookies. Reinitialize the list of permission in case + // they deleted or replaced a letter. + [self populatePermissionCache]; + if ([filterString length]) { + for (int row = mCachedPermissions->Count() - 1; row >= 0; row--) { + mCachedPermissions->ObjectAt(row)->GetHost(host); + if ([[NSString stringWithUTF8String: host.get()] rangeOfString: filterString].location == NSNotFound) + // remove from cookie permissions list + mCachedPermissions->RemoveObjectAt(row); + } + } + [mPermissionsTable deselectAll: self]; // don't want any traces of previous selection + [mPermissionsTable reloadData]; + } + else if (([aNotification object] == mCookiesFilterField) && mCachedCookies && mCookieManager) { + // reinitialize the list of cookies in case user deleted a letter or replaced a letter + [self populateCookieCache]; + + if ([filterString length]) { + for (int row = mCachedCookies->Count() - 1; row >= 0; row--) { + // only search on the host + mCachedCookies->ObjectAt(row)->GetHost(host); + + if ([[NSString stringWithUTF8String: host.get()] rangeOfString: filterString].location == NSNotFound) + mCachedCookies->RemoveObjectAt(row); + } + } + [mCookiesTable deselectAll: self]; // don't want any traces of previous selection + [mCookiesTable reloadData]; + } +} + @end