Add a pref to force the XUL filepicker. Bug 333653, r+sr=roc

git-svn-id: svn://10.0.0.236/trunk@194199 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu 2006-04-12 00:49:46 +00:00
parent 372a6826be
commit f3f3ba1e7e
2 changed files with 19 additions and 2 deletions

View File

@ -1840,6 +1840,10 @@ pref("autocomplete.ungrab_during_mode_switch", true);
// turn off scrollbar snapping
pref("slider.snapMultiplier", 0);
// Default to using the system filepicker if possible, but allow
// toggling to use the XUL filepicker
pref("ui.allow_platform_file_picker", true);
pref("helpers.global_mime_types_file", "/etc/mime.types");
pref("helpers.global_mailcap_file", "/etc/mailcap");
pref("helpers.private_mime_types_file", "~/.mime.types");

View File

@ -56,6 +56,8 @@
#include "nsPrintSession.h"
#include "nsDeviceContextSpecG.h"
#include "nsDeviceContextSpecFactoryG.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h"
@ -103,9 +105,20 @@ nsFilePickerConstructor(nsISupports *aOuter, REFNSIID aIID,
return NS_ERROR_NO_AGGREGATION;
}
PRBool allowPlatformPicker = PR_TRUE;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
PRBool prefAllow;
nsresult rv = prefs->GetBoolPref("ui.allow_platform_file_picker",
&prefAllow);
if (NS_SUCCEEDED(rv)) {
allowPlatformPicker = prefAllow;
}
}
nsCOMPtr<nsIFilePicker> picker;
if (gtk_check_version(2,4,0) == NULL) {
picker = new nsFilePicker;
if (allowPlatformPicker && gtk_check_version(2,4,0) == NULL) {
picker = new nsFilePicker;
} else {
picker = do_CreateInstance(kXULFilePickerCID);
}