Bug 528755 Move filepicker file types into toolkit/content/filepicker.properties r=gavin

This commit is contained in:
Neil Rashbrook 2010-02-20 15:26:41 +00:00
parent 003d545f7b
commit 2f47da2fcb
5 changed files with 50 additions and 39 deletions

View File

@ -72,13 +72,16 @@ const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem;
const nsIBaseWindow = Components.interfaces.nsIBaseWindow;
var bundle = null;
var titleBundle = null;
var filterBundle = null;
var lastDirectory = null;
function nsFilePicker()
{
if (!bundle)
bundle = srGetStrBundle("chrome://global/locale/filepicker.properties");
if (!titleBundle)
titleBundle = srGetStrBundle("chrome://global/locale/filepicker.properties");
if (!filterBundle)
filterBundle = srGetStrBundle("chrome://global/content/filepicker.properties");
/* attributes */
this.mDefaultString = "";
@ -156,34 +159,34 @@ nsFilePicker.prototype = {
appendFilters: function(filterMask) {
if (filterMask & nsIFilePicker.filterHTML) {
this.appendFilter(bundle.GetStringFromName("htmlTitle"),
bundle.GetStringFromName("htmlFilter"));
this.appendFilter(titleBundle.GetStringFromName("htmlTitle"),
filterBundle.GetStringFromName("htmlFilter"));
}
if (filterMask & nsIFilePicker.filterText) {
this.appendFilter(bundle.GetStringFromName("textTitle"),
bundle.GetStringFromName("textFilter"));
this.appendFilter(titleBundle.GetStringFromName("textTitle"),
filterBundle.GetStringFromName("textFilter"));
}
if (filterMask & nsIFilePicker.filterImages) {
this.appendFilter(bundle.GetStringFromName("imageTitle"),
"*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico"); // XXX 528755
this.appendFilter(titleBundle.GetStringFromName("imageTitle"),
filterBundle.GetStringFromName("imageFilter"));
}
if (filterMask & nsIFilePicker.filterXML) {
this.appendFilter(bundle.GetStringFromName("xmlTitle"),
bundle.GetStringFromName("xmlFilter"));
this.appendFilter(titleBundle.GetStringFromName("xmlTitle"),
filterBundle.GetStringFromName("xmlFilter"));
}
if (filterMask & nsIFilePicker.filterXUL) {
this.appendFilter(bundle.GetStringFromName("xulTitle"),
bundle.GetStringFromName("xulFilter"));
this.appendFilter(titleBundle.GetStringFromName("xulTitle"),
filterBundle.GetStringFromName("xulFilter"));
}
this.mAllowURLs = !!(filterMask & nsIFilePicker.filterAllowURLs);
if (filterMask & nsIFilePicker.filterApps) {
// We use "..apps" as a special filter for executable files
this.appendFilter(bundle.GetStringFromName("appsTitle"),
this.appendFilter(titleBundle.GetStringFromName("appsTitle"),
"..apps");
}
if (filterMask & nsIFilePicker.filterAll) {
this.appendFilter(bundle.GetStringFromName("allTitle"),
bundle.GetStringFromName("allFilter"));
this.appendFilter(titleBundle.GetStringFromName("allTitle"),
filterBundle.GetStringFromName("allFilter"));
}
},

View File

@ -0,0 +1,6 @@
allFilter=*
htmlFilter=*.html; *.htm; *.shtml; *.xhtml
textFilter=*.txt; *.text
imageFilter=*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico
xmlFilter=*.xml
xulFilter=*.xul

View File

@ -34,6 +34,7 @@ toolkit.jar:
*+ content/global/finddialog.js (finddialog.js)
*+ content/global/finddialog.xul (finddialog.xul)
*+ content/global/findUtils.js (findUtils.js)
content/global/filepicker.properties (filepicker.properties)
*+ content/global/globalOverlay.js (globalOverlay.js)
+ content/global/mozilla.xhtml (mozilla.xhtml)
*+ content/global/nsDragAndDrop.js (nsDragAndDrop.js)

View File

@ -1,16 +1,11 @@
# LOCALIZATION NOTE FILE
# --do not localize the extensions, only the titles
# LOCALIZATION NOTE: The extensions to which these descriptions refer
# now live in toolkit/content/filepicker.properties
allTitle=All Files
allFilter=*
htmlTitle=HTML Files
htmlFilter=*.html; *.htm; *.shtml; *.xhtml
textTitle=Text Files
textFilter=*.txt; *.text
imageTitle=Image Files
xmlTitle=XML Files
xmlFilter=*.xml
xulTitle=XUL Files
xulFilter=*.xul
appsTitle=Applications
dirTextInputLabel=Directory name:

View File

@ -57,7 +57,8 @@
#include "nsBaseFilePicker.h"
#define FILEPICKER_PROPERTIES "chrome://global/locale/filepicker.properties"
#define FILEPICKER_TITLES "chrome://global/locale/filepicker.properties"
#define FILEPICKER_FILTERS "chrome://global/content/filepicker.properties"
nsBaseFilePicker::nsBaseFilePicker()
{
@ -127,9 +128,13 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
nsCOMPtr<nsIStringBundleService> stringService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> stringBundle;
nsCOMPtr<nsIStringBundle> titleBundle, filterBundle;
rv = stringService->CreateBundle(FILEPICKER_PROPERTIES, getter_AddRefs(stringBundle));
rv = stringService->CreateBundle(FILEPICKER_TITLES, getter_AddRefs(titleBundle));
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
rv = stringService->CreateBundle(FILEPICKER_FILTERS, getter_AddRefs(filterBundle));
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
@ -137,36 +142,37 @@ nsBaseFilePicker::AppendFilters(PRInt32 aFilterMask)
nsXPIDLString filter;
if (aFilterMask & filterAll) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("allTitle").get(), getter_Copies(title));
stringBundle->GetStringFromName(NS_LITERAL_STRING("allFilter").get(), getter_Copies(filter));
titleBundle->GetStringFromName(NS_LITERAL_STRING("allTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("allFilter").get(), getter_Copies(filter));
AppendFilter(title,filter);
}
if (aFilterMask & filterHTML) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("htmlTitle").get(), getter_Copies(title));
stringBundle->GetStringFromName(NS_LITERAL_STRING("htmlFilter").get(), getter_Copies(filter));
titleBundle->GetStringFromName(NS_LITERAL_STRING("htmlTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("htmlFilter").get(), getter_Copies(filter));
AppendFilter(title,filter);
}
if (aFilterMask & filterText) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("textTitle").get(), getter_Copies(title));
stringBundle->GetStringFromName(NS_LITERAL_STRING("textFilter").get(), getter_Copies(filter));
titleBundle->GetStringFromName(NS_LITERAL_STRING("textTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("textFilter").get(), getter_Copies(filter));
AppendFilter(title,filter);
}
if (aFilterMask & filterImages) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("imageTitle").get(), getter_Copies(title));
AppendFilter(title,NS_LITERAL_STRING("*.jpg; *.jpeg; *.gif; *.png; *.bmp; *.ico"));
titleBundle->GetStringFromName(NS_LITERAL_STRING("imageTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("imageFilter").get(), getter_Copies(filter));
AppendFilter(title,filter);
}
if (aFilterMask & filterXML) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("xmlTitle").get(), getter_Copies(title));
stringBundle->GetStringFromName(NS_LITERAL_STRING("xmlFilter").get(), getter_Copies(filter));
titleBundle->GetStringFromName(NS_LITERAL_STRING("xmlTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("xmlFilter").get(), getter_Copies(filter));
AppendFilter(title,filter);
}
if (aFilterMask & filterXUL) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("xulTitle").get(), getter_Copies(title));
stringBundle->GetStringFromName(NS_LITERAL_STRING("xulFilter").get(), getter_Copies(filter));
titleBundle->GetStringFromName(NS_LITERAL_STRING("xulTitle").get(), getter_Copies(title));
filterBundle->GetStringFromName(NS_LITERAL_STRING("xulFilter").get(), getter_Copies(filter));
AppendFilter(title, filter);
}
if (aFilterMask & filterApps) {
stringBundle->GetStringFromName(NS_LITERAL_STRING("appsTitle").get(), getter_Copies(title));
titleBundle->GetStringFromName(NS_LITERAL_STRING("appsTitle").get(), getter_Copies(title));
// Pass the magic string "..apps" to the platform filepicker, which it
// should recognize and do the correct platform behavior for.
AppendFilter(title, NS_LITERAL_STRING("..apps"));