From e3853d645a2323b2bda297d525747ca5d98028e1 Mon Sep 17 00:00:00 2001 From: "pinkerton%aol.net" Date: Tue, 27 Jan 2004 20:52:18 +0000 Subject: [PATCH] remove references to system internet prefs since they no longer exist on panther. first stab at choosing download folder (display works, setting it does not) --- .../English.lproj/Navigation.nib/classes.nib | 5 +- .../English.lproj/Navigation.nib/info.nib | 4 +- .../English.lproj/Navigation.nib/objects.nib | Bin 10092 -> 0 bytes .../PreferencePanes/Navigation/Navigation.h | 15 +- .../PreferencePanes/Navigation/Navigation.mm | 182 ++++++++++++------ 5 files changed, 129 insertions(+), 77 deletions(-) diff --git a/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/classes.nib b/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/classes.nib index 6edde0c73f8..58772eb36a2 100644 --- a/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/classes.nib +++ b/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/classes.nib @@ -17,10 +17,10 @@ checkboxClicked = id; checkboxStartPageClicked = id; checkboxUseSystemHomePageClicked = id; + chooseDownloadFolder = id; clearDiskCache = id; clearGlobalHistory = id; historyDaysModified = id; - openSystemInternetPanel = id; }; CLASS = OrgMozillaChimeraPreferenceNavigation; LANGUAGE = ObjC; @@ -29,13 +29,12 @@ checkboxNewTabBlank = NSButton; checkboxNewWindowBlank = NSButton; checkboxUseSystemHomePage = NSButton; - mDownloadFolder = NSTextField; + mDownloadFolder = NSPopUpButton; mEnableHelperApps = NSButton; radioOpenForAE = id; radioOpenTabsForCommand = id; textFieldHistoryDays = NSTextField; textFieldHomePage = NSTextField; - textFieldSearchPage = NSTextField; }; SUPERCLASS = PreferencePaneBase; }, diff --git a/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/info.nib b/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/info.nib index be395de9096..9fe796d82fe 100644 --- a/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/info.nib +++ b/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/info.nib @@ -5,7 +5,7 @@ IBDocumentLocation 140 56 522 320 0 0 1280 1002 IBFramework Version - 291.0 + 349.0 IBGroupedObjects 5 @@ -22,6 +22,6 @@ 5 IBSystem Version - 6I32 + 7D24 diff --git a/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/objects.nib b/camino/PreferencePanes/Navigation/English.lproj/Navigation.nib/objects.nib index a4ba18024549cc2aa207eab6144aa286fa2f89fd..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 GIT binary patch literal 0 HcmV?d00001 literal 10092 zcmbtadw3L8mcKVI2;r4rKo~}fejvIo_k*R+;h+Eth`85z3K}`LaL`uWS-M`sjlmT7gfzKtE_%h^+q1_L_C6> z)b;+0s;n9ojawk)4dIAZXI0+WqGyy+SAbPTLjGVaZ_)YG36-JRh1%cx0|8I@8h@P{ z@+=OiHEKu=deudqb^cmU#IFTo(U{KtKQYifZ&B4!b$z75uLgW0bv<`cRk;?7gtWk& zx}LMB>S4dyh!UWdsNs4o=u<U@5K|`?5$}*bwnl2h=&Ckf(|1dcQ?g zR>tEfm8D z;I0C!7PhpG*Ry|Be4lq^4r6Q-?rRCQfHg2L^D`gwu%ELKo#$V7gy``l@JGd^_0vaUMo}*`4#N<>pg(GTR40H|jS`wBpG5wYHOg*Ef z=84%;+F#)@`p((56<|YcFj7wnbUOn~46@=gqcOKg1-l^FhOxsL8#~+)=<_7Y7dJPz zJa%o4l+8=P%VJxi(N`qNJGb)WaKj=Pr_AGBTN~0EfIo?i+h(ws%pf)PUOhJ)_WQ|dN(KA#NZuT4E=^cA zXxpJ+*X=s(3wKJlCpfeOU2o^?ul~R-@E})W;gsU?k9#wDCr@+O~5o zs5EH}A!Usxg5^P|<=k zW7G&n_hC4#PIj3ejHscY8YzlF5aYMp%EWm&FC_}w{0_L4{)Su818<<{w|XgdsHNBk z!JJY~5=v?H&@PuQNoSVg-X%S>l0(g2R8^*}pYk-uZ5{yqwdv2ba&m1Qwv)=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e^kG38iL@cBY_m*5*|zNpIis7KY)&CS z`ZCSJtBBKW)7-f?Ro;6jRW6<@*uUB^b7!UMHO8rnn^Rw( zvYA3O4-V0J3~gsBw9uTn$*!cA5y>_Z4%+RrDEUj5R-c|x>Ypa~NK>#E;7RcM55cFH zIfC~$TLrspzA(l-C)ii!sYlTEJX`}_@8F2rti0X4Pw=7U>W5MDXTd(e>v#Ca>xAHU z<8@f@33zQ2Y=?RJZ%}$q@Nwo;!EZMw3O?Lia=*EU0FDYi)x0Wr4$6lFA8VEgew*1N z_yF^=VBey45B|+U!TXtm1lrvp z^8vy0QSK7F*xblb`ZvM<%B;;sX`f*GP0%{VoGW;tc~-D*OwckKO~5)g3X;dO7J{X z{HNe|;dNT@872(;0Lp*Bp4D8r45haOd)quF_>av61I@h^X0c%1=0(B2MjOr{C*jo& zX_`C7n+F7Y7oYzq*sEq|e{;0pS!Q=GYW`WUKjHPM;M2_l!L!Y-e&&jYQ1c;9waw-8 z&DnwvGiM22V1l?Gp#i84n$v%b(pJH? +#import #import "Navigation.h" #import "NSString+Utils.h" @@ -39,6 +40,10 @@ const int kDefaultExpireDays = 9; - (NSString*)getInternetConfigString:(ConstStr255Param)icPref; - (NSString*)getDownloadFolderDescription; +- (void)setupDownloadMenuWithPath:(NSString*)inDLPath; +- (NSString*)getSystemHomePage; +- (NSString*)getCurrentHomePage; +- (void)setDownloadFolder:(NSString*)inNewFolder; @end @@ -80,29 +85,24 @@ const int kDefaultExpireDays = 9; [radioOpenTabsForCommand selectCellWithTag:[self getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:&gotPref]]; [radioOpenForAE selectCellWithTag:[self getIntPref:"browser.reuse_window" withSuccess:&gotPref]]; -// [checkboxOpenTabs setState:[self getBooleanPref:"browser.tabs.opentabfor.middleclick" withSuccess:&gotPref]]; -// [checkboxOpenTabsForAEs setState:[self getBooleanPref:"browser.always_reuse_window" withSuccess:&gotPref]]; - [checkboxLoadTabsInBackground setState:[self getBooleanPref:"browser.tabs.loadInBackground" withSuccess:&gotPref]]; BOOL useSystemHomePage = [self getBooleanPref:"chimera.use_system_home_page" withSuccess:&gotPref] && gotPref; if (useSystemHomePage) - { [textFieldHomePage setEnabled:NO]; - [textFieldSearchPage setEnabled:NO]; - } [checkboxUseSystemHomePage setState:useSystemHomePage]; [textFieldHomePage setStringValue: [self getCurrentHomePage]]; - [textFieldSearchPage setStringValue: [self getCurrentSearchPage]]; [mEnableHelperApps setState:[self getBooleanPref:"browser.download.autoDispatch" withSuccess:&gotPref]]; NSString* downloadFolderDesc = [self getDownloadFolderDescription]; if ([downloadFolderDesc length] == 0) downloadFolderDesc = [self getLocalizedString:@"MissingDlFolder"]; - - [mDownloadFolder setStringValue:[self getDownloadFolderDescription]]; + + [self setupDownloadMenuWithPath:downloadFolderDesc]; + +// [mDownloadFolder setStringValue:[self getDownloadFolderDescription]]; } - (void) didUnselect @@ -112,24 +112,13 @@ const int kDefaultExpireDays = 9; // only save the home page pref if it's not the system one if (![checkboxUseSystemHomePage state]) - { [self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]]; - [self setPref: "chimera.search_page" toString: [textFieldSearchPage stringValue]]; - } // ensure that the prefs exist [self setPref:"browser.startup.page" toInt: [checkboxNewWindowBlank state] ? 1 : 0]; [self setPref:"browser.tabs.startPage" toInt: [checkboxNewTabBlank state] ? 1 : 0]; } -- (IBAction)openSystemInternetPanel:(id)sender -{ - if ([[NSWorkspace sharedWorkspace] openFile:@"/System/Library/PreferencePanes/Internet.prefPane"] == NO) { - // XXXw. pop up a dialog warning that System Preferences couldn't be launched? - NSLog(@"Failed to launch System Preferences."); - } -} - - (IBAction)checkboxClicked:(id)sender { if (!mPrefService) @@ -159,17 +148,12 @@ const int kDefaultExpireDays = 9; // save the mozilla pref if (useSystemHomePage) - { [self setPref: "browser.startup.homepage" toString: [textFieldHomePage stringValue]]; - [self setPref: "chimera.search_page" toString: [textFieldSearchPage stringValue]]; - } [self setPref:"chimera.use_system_home_page" toBoolean: useSystemHomePage]; [textFieldHomePage setStringValue: [self getCurrentHomePage]]; - [textFieldSearchPage setStringValue: [self getCurrentSearchPage]]; [textFieldHomePage setEnabled:!useSystemHomePage]; - [textFieldSearchPage setEnabled:!useSystemHomePage]; } - (IBAction)checkboxStartPageClicked:(id)sender @@ -237,34 +221,69 @@ const int kDefaultExpireDays = 9; nsresult rv = macDir->GetFSRef(&folderRef); if (NS_FAILED(rv)) return downloadStr; - - FSCatalogInfo catInfo; - HFSUniStr255 fileName; - OSErr err = FSGetCatalogInfo(&folderRef, kFSCatInfoVolume, &catInfo, &fileName, NULL, NULL); - if (err != noErr) - return downloadStr; - - HFSUniStr255 volName; - err = FSGetVolumeInfo(catInfo.volume, 0, NULL, kFSVolInfoNone, NULL, &volName, NULL); - if (err != noErr) - return downloadStr; - - NSString* fileNameStr = [NSString stringWithCharacters:fileName.unicode length:fileName.length]; - NSString* volumeNameStr = [NSString stringWithCharacters:volName.unicode length:volName.length]; - - return [NSString stringWithFormat:[self getLocalizedString:@"DownloadFolderDesc"], fileNameStr, volumeNameStr]; + UInt8 utf8path[MAXPATHLEN+1]; + ::FSRefMakePath(&folderRef, utf8path, MAXPATHLEN); + return [NSString stringWithUTF8String:(const char*)utf8path]; } +// +// -setDownloadFolder: +// +// Sets the IC download pref to the given path +// NOTE: THIS DOES NOT WORK. +// +- (void)setDownloadFolder:(NSString*)inNewFolder +{ + if (!inNewFolder) + return; + + // it would be nice to use PreferenceManager, but I don't want to drag + // all that code into the plugin + ICInstance icInstance = nil; + OSStatus error = ::ICStart(&icInstance, 'CHIM'); + if (error != noErr) + return; + + // make a ICFileSpec out of our path and shove it into IC + NSMutableString* carbonPath = [NSMutableString stringWithString:inNewFolder]; + [carbonPath replaceOccurrencesOfString:@"/" withString:@":" options:0 range:NSMakeRange(0, [carbonPath length])]; +NSLog(@"carbon path is %@", carbonPath); +// const char* utf8str = [inNewFolder UTF8String]; + const char* utf8str = "Vespa:Users:pink:Desktop:"; + unsigned len = strlen(utf8str); + if (len > 255) + len = 255; + + char buff[256]; + strncpy(&buff[1], utf8str, len); + buff[0] = len; + FSSpec downloadSpec; + FSMakeFSSpec(0, 0, (unsigned char*)buff, &downloadSpec); + + long prefSize = sizeof(ICFileSpec); + AliasHandle alias = nil; + error = ::NewAlias(nil, &downloadSpec, &alias); + NSLog(@"alias is %ld error is %d", alias, error); + + long aliasSize = ::GetHandleSize((Handle)alias); + ICFileSpec* realbuffer = (ICFileSpec*) new char[sizeof(ICFileSpec) + aliasSize]; + realbuffer->fss = downloadSpec; + memcpy(&realbuffer->alias, *alias, aliasSize); + + error = ::ICSetPref(icInstance, kICDownloadFolder, kICAttrNoChange, (const void*)realbuffer, prefSize); + NSLog(@"error is %d", error); + + ::ICStop(icInstance); +} - (NSString*)getInternetConfigString:(ConstStr255Param)icPref { NSString* resultString = @""; ICInstance icInstance = NULL; - OSStatus error; // it would be nice to use PreferenceManager, but I don't want to drag // all that code into the plugin - error = ICStart(&icInstance, 'CHIM'); + OSStatus error = ICStart(&icInstance, 'CHIM'); if (error != noErr) { NSLog(@"Error from ICStart"); return resultString; @@ -299,21 +318,6 @@ const int kDefaultExpireDays = 9; return [self getStringPref: "browser.startup.homepage" withSuccess:&gotPref]; } -- (NSString*)getSystemSearchPage -{ - return [self getInternetConfigString:kICWebSearchPagePrefs]; -} - -- (NSString*)getCurrentSearchPage -{ - BOOL gotPref; - - if ([self getBooleanPref:"chimera.use_system_home_page" withSuccess:&gotPref] && gotPref) - return [self getSystemSearchPage]; - - return [self getStringPref: "chimera.search_page" withSuccess:&gotPref]; -} - // // clearDiskCache: @@ -327,9 +331,67 @@ const int kDefaultExpireDays = 9; cacheServ->EvictEntries(nsICache::STORE_ON_DISK); } - -- (IBAction)checkboxEnableHelperApps:(id)sender +// +// -setupDownloadMenuWithPath: +// +// Given a full path to the d/l dir, display the leaf name and the finder icon associated +// with that folder in the first item of the download folder popup. +// +- (void)setupDownloadMenuWithPath:(NSString*)inDLPath { + NSMenuItem* placeholder = [mDownloadFolder itemAtIndex:0]; + if (!placeholder) + return; + + // get the finder icon and scale it down to 16x16 + NSImage* icon = [[NSWorkspace sharedWorkspace] iconForFile:inDLPath]; + [icon setScalesWhenResized:YES]; + [icon setSize:NSMakeSize(16.0, 16.0)]; + // set the title to the leaf name and the icon to what we gathered above + [placeholder setTitle:[inDLPath lastPathComponent]]; + [placeholder setImage:icon]; + + // ensure first item is selected + [mDownloadFolder selectItemAtIndex:0]; +} + +// +// -chooseDownloadFolder: +// +// display a file picker sheet allowing the user to set their new download folder +// +- (IBAction)chooseDownloadFolder:(id)sender +{ + NSString* oldDLFolder = [self getDownloadFolderDescription]; + NSOpenPanel* panel = [NSOpenPanel openPanel]; + [panel setCanChooseFiles:NO]; + [panel setCanChooseDirectories:YES]; + [panel setAllowsMultipleSelection:NO]; + + [panel beginSheetForDirectory:oldDLFolder file:nil types:nil modalForWindow:[mDownloadFolder window] + modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) + contextInfo:nil]; +} + +// +// -openPanelDidEnd:returnCode:contextInfo: +// +// called when the user closes the open panel sheet for selecting a new d/l folder. +// if they clicked ok, change the IC pref and re-display the new choice in the +// popup menu +// +- (void)openPanelDidEnd:(NSOpenPanel*)sheet returnCode:(int)returnCode contextInfo:(void*)contextInfo +{ + if (returnCode == NSOKButton) { + // stuff path into pref + NSString* newPath = [[sheet filenames] objectAtIndex:0]; + [self setDownloadFolder:newPath]; + + // update the menu + [self setupDownloadMenuWithPath:newPath]; + } + else + [mDownloadFolder selectItemAtIndex:0]; } @end