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: [PATCH] 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 --- CMake/options.cmake | 9 --------- FL/Fl.H | 10 +++++++--- FL/Fl_Native_File_Chooser.H | 13 ++++++------- FL/Fl_Printer.H | 3 --- README.CMake.txt | 6 ------ configh.cmake.in | 7 ------- configh.in | 7 ------- fltk-options/fltk-options.cxx | 16 +++++++++++----- src/CMakeLists.txt | 4 ---- src/Fl.cxx | 12 ++++++------ src/Fl_Native_File_Chooser_GTK.cxx | 18 ++++++++---------- 11 files changed, 38 insertions(+), 67 deletions(-) diff --git a/CMake/options.cmake b/CMake/options.cmake index 41ff93edd..6d5c8127a 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -1000,15 +1000,6 @@ if(FLTK_OPTION_FILESYSTEM_SUPPORT) endif(FLTK_OPTION_FILESYSTEM_SUPPORT) ####################################################################### -####################################################################### -option(FLTK_USE_KDIALOG "Fl_Native_File_Chooser may run kdialog" ON) -if(FLTK_USE_KDIALOG) - set(USE_KDIALOG 1) -else() - set(USE_KDIALOG 0) -endif() -####################################################################### - ####################################################################### option(CMAKE_SUPPRESS_REGENERATION "suppress rules to re-run CMake on rebuild" OFF) mark_as_advanced(CMAKE_SUPPRESS_REGENERATION) diff --git a/FL/Fl.H b/FL/Fl.H index 7860771ba..e1f69b506 100644 --- a/FL/Fl.H +++ b/FL/Fl.H @@ -266,6 +266,13 @@ public: /// if the GTK library is available on the platform (linux/unix only). /// When switched off, GTK file dialogs aren't used even if the GTK library is available. OPTION_FNFC_USES_GTK, + /// Meaningful for the Wayland/X11 platform only. When switched on, the library uses a Zenity-based file dialog. + /// When switched off (default), no zenity-based file dialog is used. + OPTION_FNFC_USES_ZENITY, + /// Meaningful for the Wayland/X11 platform only and for the KDE-Plasma desktop only. + /// When switched on, the library uses a kdialog-based file dialog if command 'kdialog' is available on the running system. + /// When switched off (default), no kdialog-based file dialog is used. + OPTION_FNFC_USES_KDIALOG, /// When switched on (default), Fl_Printer runs the GTK printer dialog /// if the GTK library is available on the platform (linux/unix only). /// When switched off, the GTK printer dialog isn't used even if the GTK library is available. @@ -274,9 +281,6 @@ public: /// value. /// When switched off, no such window gets displayed. OPTION_SHOW_SCALING, - /// Meaningful for the Wayland/X11 platform only. When switched on (default), the library uses a Zenity-based file dialog. - /// When switched off, the GTK file dialog is used instead. - OPTION_FNFC_USES_ZENITY, /// When switched on and when the keyboard in use has '+' in the shifted position of its key, /// pressing that key and ctrl triggers the zoom-in operation. /// When switched off (default), the zoom-in operation requires that also the shift key is pressed. diff --git a/FL/Fl_Native_File_Chooser.H b/FL/Fl_Native_File_Chooser.H index 92e21a98e..726a34636 100644 --- a/FL/Fl_Native_File_Chooser.H +++ b/FL/Fl_Native_File_Chooser.H @@ -105,11 +105,12 @@ class Fl_Native_File_Chooser_Driver; - Under X11/Wayland the dialog is chosen as follows: -# If command \p zenity is available at run-time and if \p Fl::option(OPTION_FNFC_USES_ZENITY) is - not turned off, the \p zenity -based dialog opens. This is expected to be more appropriate - than other dialog forms for sandboxed apps. - -# Else if the app runs under the KDE desktop and if command \p kdialog is available at run-time - and if the library was not built with cmake -D FLTK_USE_KDIALOG=OFF, the - \p kdialog -based dialog opens. + turned on, the \p zenity -based dialog opens. This is expected to be more appropriate + than other dialog forms for sandboxed apps, but member function filter_value() is not effective. + -# Else if the app runs under the KDE desktop + and if \p Fl::option(OPTION_FNFC_USES_KDIALOG) is turned on, + and if command \p kdialog is available at run-time, the \p kdialog -based dialog opens. + Member function filter_value() is not effective with this dialog. -# Else if the GTK library is available at run-time on the computer and if \p Fl::option(OPTION_FNFC_USES_GTK) is not turned off, the GTK-styled dialog opens. Call fl_register_images() to add a "Preview" button to this dialog. Use the static public attributes of class Fl_File_Chooser to localize the browser. @@ -119,8 +120,6 @@ class Fl_Native_File_Chooser_Driver; at the start of main(), to enable the nicer looking file browser widgets. Use the static public attributes of class Fl_File_Chooser to localize the browser. - \todo Improve documentation about selection of native file choosers on X11/Wayland.\n - - Some operating systems support certain OS specific options; see Fl_Native_File_Chooser::options() for a list. diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index 7da0f1da5..3efa5f74c 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -74,9 +74,6 @@ See class Fl_PostScript_File_Device for a description of how text and transparent images appear in print.
  • If the GTK library is available at run-time, class Fl_Printer runs GTK's printer dialog which allows to set printer, paper size and orientation. -
  • Under the KDE desktop, Fl_Printer runs the kdialog command to create KDE-styled file dialogs if - that command is available at run-time, unless FLTK was built with CMake and option FLTK_USE_KDIALOG turned off. - In that case, Fl_Printer attempts to run the GTK dialog.
  • If the GTK library is not available, or if Fl::option(Fl::OPTION_PRINTER_USES_GTK) has been turned off, class Fl_Printer runs FLTK's print dialog.