mirror of
https://github.com/rn10950/RetroZilla.git
synced 2024-11-14 11:40:13 +01:00
commit
d97cd8e7c9
@ -307,10 +307,12 @@ var gMainPane = {
|
|||||||
*/
|
*/
|
||||||
_folderToIndex: function (aFolder)
|
_folderToIndex: function (aFolder)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
if (!aFolder || aFolder.equals(this._getDownloadsFolder("Desktop")))
|
if (!aFolder || aFolder.equals(this._getDownloadsFolder("Desktop")))
|
||||||
return 0;
|
return 0;
|
||||||
else if (aFolder.equals(this._getDownloadsFolder("Downloads")))
|
else if (aFolder.equals(this._getDownloadsFolder("Downloads")))
|
||||||
return 1;
|
return 1;
|
||||||
|
} catch(e) {}
|
||||||
return 2;
|
return 2;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -326,8 +328,13 @@ var gMainPane = {
|
|||||||
{
|
{
|
||||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
.getService(Components.interfaces.nsIProperties);
|
.getService(Components.interfaces.nsIProperties);
|
||||||
var dir = fileLocator.get(this._getSpecialFolderKey(aFolder),
|
var dir;
|
||||||
|
try {
|
||||||
|
dir = fileLocator.get(this._getSpecialFolderKey(aFolder),
|
||||||
Components.interfaces.nsILocalFile);
|
Components.interfaces.nsILocalFile);
|
||||||
|
} catch(e) {
|
||||||
|
dir = aFolder;
|
||||||
|
}
|
||||||
if (aFolder != "Desktop")
|
if (aFolder != "Desktop")
|
||||||
dir.append("My Downloads"); // XXX l12y!
|
dir.append("My Downloads"); // XXX l12y!
|
||||||
|
|
||||||
|
@ -515,9 +515,11 @@ function getTargetFile(aFpP, aSkipPrompt)
|
|||||||
{
|
{
|
||||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
.getService(Components.interfaces.nsIProperties);
|
.getService(Components.interfaces.nsIProperties);
|
||||||
|
var dir;
|
||||||
var dir = fileLocator.get(getSpecialFolderKey(aFolder), Components.interfaces.nsILocalFile);
|
try {
|
||||||
|
dir = fileLocator.get(getSpecialFolderKey(aFolder), Components.interfaces.nsILocalFile);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
var bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||||
.getService(Components.interfaces.nsIStringBundleService);
|
.getService(Components.interfaces.nsIStringBundleService);
|
||||||
bundle = bundle.createBundle("chrome://mozapps/locale/downloads/unknownContentType.properties");
|
bundle = bundle.createBundle("chrome://mozapps/locale/downloads/unknownContentType.properties");
|
||||||
@ -544,6 +546,7 @@ function getTargetFile(aFpP, aSkipPrompt)
|
|||||||
if (!aSkipPrompt || !useDownloadDir || !dir) {
|
if (!aSkipPrompt || !useDownloadDir || !dir) {
|
||||||
// If we're asking the user where to save the file, root the Save As...
|
// If we're asking the user where to save the file, root the Save As...
|
||||||
// dialog on they place they last picked.
|
// dialog on they place they last picked.
|
||||||
|
if(!dir) {
|
||||||
try {
|
try {
|
||||||
dir = prefs.getComplexValue("lastDir", nsILocalFile);
|
dir = prefs.getComplexValue("lastDir", nsILocalFile);
|
||||||
}
|
}
|
||||||
@ -552,8 +555,15 @@ function getTargetFile(aFpP, aSkipPrompt)
|
|||||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||||
.getService(Components.interfaces.nsIProperties);
|
.getService(Components.interfaces.nsIProperties);
|
||||||
|
|
||||||
|
try {
|
||||||
dir = fileLocator.get(getSpecialFolderKey("Desktop"), nsILocalFile);
|
dir = fileLocator.get(getSpecialFolderKey("Desktop"), nsILocalFile);
|
||||||
}
|
}
|
||||||
|
catch (r) {
|
||||||
|
// no clue, try current dir
|
||||||
|
dir = '.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var fp = makeFilePicker();
|
var fp = makeFilePicker();
|
||||||
var titleKey = aFpP.fpTitleKey || "SaveLinkTitle";
|
var titleKey = aFpP.fpTitleKey || "SaveLinkTitle";
|
||||||
|
@ -89,6 +89,7 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 };
|
|||||||
nsFilePicker::nsFilePicker()
|
nsFilePicker::nsFilePicker()
|
||||||
{
|
{
|
||||||
mSelectedType = 1;
|
mSelectedType = 1;
|
||||||
|
mWinVer = GetVersion() & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
@ -153,7 +154,7 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
|||||||
|
|
||||||
#ifndef WINCE
|
#ifndef WINCE
|
||||||
|
|
||||||
if (mMode == modeGetFolder) {
|
if (mMode == modeGetFolder && mWinVer > 3) {
|
||||||
PRUnichar dirBuffer[MAX_PATH+1];
|
PRUnichar dirBuffer[MAX_PATH+1];
|
||||||
wcsncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
wcsncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
||||||
|
|
||||||
@ -244,13 +245,17 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
|||||||
#ifndef WINCE
|
#ifndef WINCE
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
if (mMode == modeOpen) {
|
if (mMode == modeOpen || mMode == modeGetFolder) {
|
||||||
// FILE MUST EXIST!
|
// FILE MUST EXIST!
|
||||||
ofn.Flags |= OFN_FILEMUSTEXIST;
|
if(mMode == modeOpen) ofn.Flags |= OFN_FILEMUSTEXIST;
|
||||||
|
else {
|
||||||
|
fileBuffer[0]='t'; fileBuffer[1]='h'; fileBuffer[2]='i'; fileBuffer[3]='s';
|
||||||
|
fileBuffer[4]='D'; fileBuffer[5]='i'; fileBuffer[6]='r';
|
||||||
|
}
|
||||||
result = nsToolkit::mGetOpenFileName(&ofn);
|
result = nsToolkit::mGetOpenFileName(&ofn);
|
||||||
}
|
}
|
||||||
else if (mMode == modeOpenMultiple) {
|
else if (mMode == modeOpenMultiple) {
|
||||||
ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
|
ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | (mWinVer > 3 ? OFN_EXPLORER : 0);
|
||||||
result = nsToolkit::mGetOpenFileName(&ofn);
|
result = nsToolkit::mGetOpenFileName(&ofn);
|
||||||
}
|
}
|
||||||
else if (mMode == modeSave) {
|
else if (mMode == modeSave) {
|
||||||
@ -345,6 +350,17 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// Get DirPath from Full Pathname
|
||||||
|
if(mMode == modeGetFolder) {
|
||||||
|
int cnt;
|
||||||
|
nsAutoString dirName(fileBuffer);
|
||||||
|
for(cnt=dirName.Length()-1;cnt > 1; cnt--) {
|
||||||
|
if (fileBuffer[cnt] == '\\') {
|
||||||
|
fileBuffer[cnt] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// I think it also needs a conversion here (to unicode since appending to nsString)
|
// I think it also needs a conversion here (to unicode since appending to nsString)
|
||||||
// but doing that generates garbage file name, weird.
|
// but doing that generates garbage file name, weird.
|
||||||
mUnicodeFile.Assign(fileBuffer);
|
mUnicodeFile.Assign(fileBuffer);
|
||||||
|
@ -97,6 +97,7 @@ protected:
|
|||||||
static char mLastUsedDirectory[];
|
static char mLastUsedDirectory[];
|
||||||
nsString mUnicodeFile;
|
nsString mUnicodeFile;
|
||||||
static nsString mLastUsedUnicodeDirectory;
|
static nsString mLastUsedUnicodeDirectory;
|
||||||
|
PRInt32 mWinVer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsFilePicker_h__
|
#endif // nsFilePicker_h__
|
||||||
|
Loading…
Reference in New Issue
Block a user