summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAscrod <32915892+Ascrod@users.noreply.github.com>2019-08-15 06:03:42 -0400
committerAscrod <32915892+Ascrod@users.noreply.github.com>2019-08-15 18:22:56 -0400
commitf7fced09da8e318f3c45f3cdc65674345460f918 (patch)
treedb0604e235a1b0bc8812b30f448da890780fa562
parent47c48dfcb87a574f6b96f3abf3ed14b9b08b2371 (diff)
downloadUXP-f7fced09da8e318f3c45f3cdc65674345460f918.tar
UXP-f7fced09da8e318f3c45f3cdc65674345460f918.tar.gz
UXP-f7fced09da8e318f3c45f3cdc65674345460f918.tar.lz
UXP-f7fced09da8e318f3c45f3cdc65674345460f918.tar.xz
UXP-f7fced09da8e318f3c45f3cdc65674345460f918.zip
Issue #999 - Disable native file picker by default.
-rw-r--r--modules/libpref/init/all.js6
-rw-r--r--widget/gtk/nsFilePicker.cpp10
-rw-r--r--widget/gtk/nsFilePicker.h1
3 files changed, 13 insertions, 4 deletions
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index cd4284a9e..e69a985ce 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4012,6 +4012,12 @@ pref("autocomplete.ungrab_during_mode_switch", true);
// toggling to use the XUL filepicker
pref("ui.allow_platform_file_picker", true);
+// Allow for using the native GTK file picker. If the application is not run
+// with GTK_USE_PORTAL=1 this pref has no effect.
+#ifdef MOZ_WIDGET_GTK
+pref("widget.allow-gtk-native-file-chooser", false);
+#endif
+
pref("helpers.global_mime_types_file", "/etc/mime.types");
pref("helpers.global_mailcap_file", "/etc/mailcap");
pref("helpers.private_mime_types_file", "~/.mime.types");
diff --git a/widget/gtk/nsFilePicker.cpp b/widget/gtk/nsFilePicker.cpp
index a2d2e1cff..05d8bb0f0 100644
--- a/widget/gtk/nsFilePicker.cpp
+++ b/widget/gtk/nsFilePicker.cpp
@@ -23,6 +23,7 @@
#include "nsNetUtil.h"
#include "nsReadableUtils.h"
#include "mozcontainer.h"
+#include "mozilla/Preferences.h"
#include "nsFilePicker.h"
@@ -175,6 +176,7 @@ nsFilePicker::nsFilePicker()
, mFileChooserDelegate(nullptr)
#endif
{
+ mUseNativeFileChooser = Preferences::GetBool("widget.allow-gtk-native-file-chooser", false);
}
nsFilePicker::~nsFilePicker()
@@ -613,7 +615,7 @@ nsFilePicker::GtkFileChooserNew(
GtkFileChooserAction,
const gchar *, const gchar *))
dlsym(RTLD_DEFAULT, "gtk_file_chooser_native_new");
- if (sGtkFileChooserNativeNewPtr != nullptr) {
+ if (mUseNativeFileChooser && sGtkFileChooserNativeNewPtr != nullptr) {
return (*sGtkFileChooserNativeNewPtr)(title, parent, action, accept_label, nullptr);
}
if (accept_label == nullptr) {
@@ -633,7 +635,7 @@ nsFilePicker::GtkFileChooserShow(void *file_chooser)
{
static auto sGtkNativeDialogShowPtr = (void (*)(void *))
dlsym(RTLD_DEFAULT, "gtk_native_dialog_show");
- if (sGtkNativeDialogShowPtr != nullptr) {
+ if (mUseNativeFileChooser && sGtkNativeDialogShowPtr != nullptr) {
(*sGtkNativeDialogShowPtr)(file_chooser);
} else {
g_signal_connect(file_chooser, "destroy", G_CALLBACK(OnDestroy), this);
@@ -646,7 +648,7 @@ nsFilePicker::GtkFileChooserDestroy(void *file_chooser)
{
static auto sGtkNativeDialogDestroyPtr = (void (*)(void *))
dlsym(RTLD_DEFAULT, "gtk_native_dialog_destroy");
- if (sGtkNativeDialogDestroyPtr != nullptr) {
+ if (mUseNativeFileChooser && sGtkNativeDialogDestroyPtr != nullptr) {
(*sGtkNativeDialogDestroyPtr)(file_chooser);
} else {
gtk_widget_destroy(GTK_WIDGET(file_chooser));
@@ -659,7 +661,7 @@ nsFilePicker::GtkFileChooserSetModal(void *file_chooser,
{
static auto sGtkNativeDialogSetModalPtr = (void (*)(void *, gboolean))
dlsym(RTLD_DEFAULT, "gtk_native_dialog_set_modal");
- if (sGtkNativeDialogSetModalPtr != nullptr) {
+ if (mUseNativeFileChooser && sGtkNativeDialogSetModalPtr != nullptr) {
(*sGtkNativeDialogSetModalPtr)(file_chooser, modal);
} else {
GtkWindow *window = GTK_WINDOW(file_chooser);
diff --git a/widget/gtk/nsFilePicker.h b/widget/gtk/nsFilePicker.h
index f462ca324..e0a1d541d 100644
--- a/widget/gtk/nsFilePicker.h
+++ b/widget/gtk/nsFilePicker.h
@@ -86,6 +86,7 @@ private:
#if (MOZ_WIDGET_GTK == 3)
GtkFileChooserWidget *mFileChooserDelegate;
#endif
+ bool mUseNativeFileChooser;
};
#endif