From abfc8ee52f5e7b7e9022dd0bb6fd370a0e9c32af Mon Sep 17 00:00:00 2001
From: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
Date: Mon, 22 Apr 2024 16:34:08 +0200
Subject: Fix: Fl_Native_File_Chooser::filter_value() [Kdialog] always returns
0 (#899)
- remove build option FLTK_USE_KDIALOG replaced by an Fl::option() option
- new run-time option OPTION_FNFC_USES_KDIALOG
- make options OPTION_FNFC_USES_KDIALOG and OPTION_FNFC_USES_ZENITY
false by default
- add mention of new program fltk-options in the doc of Fl::option()
- change logic of choice of the native file chooser under X11/Wayland:
the zenity and kdialog choosers are opt-in; otherwise the GTK file chooser
is used, unless opted out with OPTION_FNFC_USES_GTK
- document that zenity may be interesting for sandboxed apps
- document that both zenity and kdialog make member functions
Fl_Native_File_Chooser::filter_value() inoperable
---
src/CMakeLists.txt | 4 ----
src/Fl.cxx | 12 ++++++------
src/Fl_Native_File_Chooser_GTK.cxx | 18 ++++++++----------
3 files changed, 14 insertions(+), 20 deletions(-)
(limited to 'src')
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 74f401182..acb00ec3b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -237,11 +237,9 @@ if(FLTK_USE_X11 AND NOT FLTK_BACKEND_WAYLAND)
Fl_get_key.cxx
)
- if(FLTK_USE_KDIALOG)
list(APPEND DRIVER_FILES
Fl_Native_File_Chooser_Kdialog.cxx
Fl_Native_File_Chooser_Zenity.cxx)
- endif(FLTK_USE_KDIALOG)
if(FLTK_USE_CAIRO)
list(APPEND DRIVER_FILES
@@ -312,11 +310,9 @@ elseif(FLTK_BACKEND_WAYLAND)
Fl_Native_File_Chooser_GTK.cxx
)
- if(FLTK_USE_KDIALOG)
list(APPEND DRIVER_FILES
Fl_Native_File_Chooser_Kdialog.cxx
Fl_Native_File_Chooser_Zenity.cxx)
- endif(FLTK_USE_KDIALOG)
if(FLTK_USE_X11)
list(APPEND DRIVER_FILES
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 16672cfcc..43517ee20 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -1961,9 +1961,6 @@ void Fl::clear_widget_pointer(Fl_Widget const *w)
There should be a command line option interface.
- There should be an application that manages options system wide, per user, and
- per application.
-
Example:
\code
if ( Fl::option(Fl::OPTION_ARROW_FOCUS) )
@@ -1972,8 +1969,7 @@ void Fl::clear_widget_pointer(Fl_Widget const *w)
{ ..off.. }
\endcode
- \note As of FLTK 1.3.0, options can be managed within fluid, using the menu
- Edit/Global FLTK Settings.
+ \note Options can be managed with the \c fltk-options program, new in FLTK 1.4.0.
\param opt which option
\return true or false
@@ -2008,8 +2004,10 @@ bool Fl::option(Fl_Option opt)
opt_prefs.get("ShowZoomFactor", tmp, 1); // default: on
options_[OPTION_SHOW_SCALING] = tmp;
- opt_prefs.get("UseZenity", tmp, 1); // default: on
+ opt_prefs.get("UseZenity", tmp, 0); // default: off
options_[OPTION_FNFC_USES_ZENITY] = tmp;
+ opt_prefs.get("UseKdialog", tmp, 0); // default: off
+ options_[OPTION_FNFC_USES_KDIALOG] = tmp;
opt_prefs.get("SimpleZoomShortcut", tmp, 0); // default: off
options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
}
@@ -2038,6 +2036,8 @@ bool Fl::option(Fl_Option opt)
if (tmp >= 0) options_[OPTION_SHOW_SCALING] = tmp;
opt_prefs.get("UseZenity", tmp, -1);
if (tmp >= 0) options_[OPTION_FNFC_USES_ZENITY] = tmp;
+ opt_prefs.get("UseKdialog", tmp, -1);
+ if (tmp >= 0) options_[OPTION_FNFC_USES_KDIALOG] = tmp;
opt_prefs.get("SimpleZoomShortcut", tmp, -1);
if (tmp >= 0) options_[OPTION_SIMPLE_ZOOM_SHORTCUT] = tmp;
}
diff --git a/src/Fl_Native_File_Chooser_GTK.cxx b/src/Fl_Native_File_Chooser_GTK.cxx
index 28363aeda..263acfad7 100644
--- a/src/Fl_Native_File_Chooser_GTK.cxx
+++ b/src/Fl_Native_File_Chooser_GTK.cxx
@@ -17,10 +17,8 @@
#include
#include
-#if USE_KDIALOG
-# include "Fl_Native_File_Chooser_Zenity.H"
-# include "Fl_Native_File_Chooser_Kdialog.H"
-#endif
+#include "Fl_Native_File_Chooser_Zenity.H"
+#include "Fl_Native_File_Chooser_Kdialog.H"
#if HAVE_DLSYM && HAVE_DLFCN_H
#include
@@ -931,8 +929,6 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
// otherwise, use FLTK file chooser.
platform_fnfc = NULL;
fl_open_display();
- if (Fl::option(Fl::OPTION_FNFC_USES_GTK)) {
-#if USE_KDIALOG
if (Fl::option(Fl::OPTION_FNFC_USES_ZENITY)&& val != BROWSE_MULTI_DIRECTORY) {
if (!Fl_Zenity_Native_File_Chooser_Driver::have_looked_for_zenity) {
// First Time here, try to find zenity
@@ -949,7 +945,8 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
if (Fl_Zenity_Native_File_Chooser_Driver::did_find_zenity) platform_fnfc = new Fl_Zenity_Native_File_Chooser_Driver(val);
}
const char *desktop = getenv("XDG_CURRENT_DESKTOP");
- if (!platform_fnfc && desktop && strcmp(desktop, "KDE") == 0 && val != BROWSE_MULTI_DIRECTORY) {
+ if (!platform_fnfc && Fl::option(Fl::OPTION_FNFC_USES_KDIALOG) && desktop &&
+ strcmp(desktop, "KDE") == 0 && val != BROWSE_MULTI_DIRECTORY) {
if (!Fl_Kdialog_Native_File_Chooser_Driver::have_looked_for_kdialog) {
// First Time here, try to find kdialog
FILE *pipe = popen("kdialog -v 2> /dev/null", "r");
@@ -964,9 +961,9 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
// if we found kdialog, we will use the Fl_Kdialog_Native_File_Chooser_Driver
if (Fl_Kdialog_Native_File_Chooser_Driver::did_find_kdialog) platform_fnfc = new Fl_Kdialog_Native_File_Chooser_Driver(val);
}
-#endif // USE_KDIALOG
#if HAVE_DLSYM && HAVE_DLFCN_H
- if (!platform_fnfc) {
+ if (!platform_fnfc) {
+ if (Fl::option(Fl::OPTION_FNFC_USES_GTK)) {
if ( Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs == 0) {
// First Time here, try to find the GTK libs if they are installed
Fl_GTK_Native_File_Chooser_Driver::probe_for_GTK_libs();
@@ -975,7 +972,8 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
// if we found all the GTK functions we need, we will use the GtkFileChooserDialog
if (Fl_GTK_Native_File_Chooser_Driver::did_find_GTK_libs) platform_fnfc = new Fl_GTK_Native_File_Chooser_Driver(val);
}
-#endif // HAVE_DLSYM && HAVE_DLFCN_H
}
+#endif // HAVE_DLSYM && HAVE_DLFCN_H
+
if (!platform_fnfc) platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val);
}
--
cgit v1.2.3