FLTK logo

[master] abfc8ee - Fix: Fl_Native_File_Chooser::filter_value() [Kdialog] always returns 0 (#899)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] abfc8ee - Fix: Fl_Native_File_Chooser::filter_value() [Kdialog] always returns 0 (#899) "ManoloFLTK" 07:47 Apr 22  
 
commit abfc8ee52f5e7b7e9022dd0bb6fd370a0e9c32af
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon Apr 22 16:34:08 2024 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon Apr 22 16:34:08 2024 +0200

     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 CMake/options.cmake CMake/options.cmake
index 41ff93e..6d5c812 100644
--- CMake/options.cmake
+++ CMake/options.cmake
@@ -1001,15 +1001,6 @@ 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 FL/Fl.H FL/Fl.H
index 7860771..e1f69b5 100644
--- FL/Fl.H
+++ 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 FL/Fl_Native_File_Chooser.H FL/Fl_Native_File_Chooser.H
index 92e21a9..726a346 100644
--- FL/Fl_Native_File_Chooser.H
+++ 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 <tt>cmake -D FLTK_USE_KDIALOG=OFF</tt>, 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 FL/Fl_Printer.H FL/Fl_Printer.H
index 7da0f1d..3efa5f7 100644
--- FL/Fl_Printer.H
+++ 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.
  <li>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.
- <li>Under the KDE desktop, Fl_Printer runs the <tt>kdialog</tt> 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.
  <li>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.
  <ul>
diff --git README.CMake.txt README.CMake.txt
index 03325a9..0d63fa8 100644
--- README.CMake.txt
+++ README.CMake.txt
@@ -255,12 +255,6 @@ FLTK_OPTION_SVG - default ON
     FLTK has a built-in SVG library and can create (write) SVG image files.
     Turning this option off disables SVG (read and write) support.
 
-FLTK_USE_KDIALOG - default ON
-    Under the KDE desktop, allows class Fl_Native_File_Chooser to use the
-    kdialog utility program to construct its file dialog windows, when that
-    utility is available at run time on the system. This option makes sense
-    only under X11 or Wayland.
-
 FLTK_USE_LIBDECOR_GTK - default ON (Wayland only).
     Allow to use libdecor's GTK plugin to draw window titlebars. Otherwise
     FLTK does not use GTK and apps will not need linking to GTK. This feature
diff --git configh.cmake.in configh.cmake.in
index 1bd719b..b01d4fb 100644
--- configh.cmake.in
+++ configh.cmake.in
@@ -340,10 +340,3 @@
  */
 
 #cmakedefine FL_CFG_NO_FILESYSTEM_SUPPORT 1
-
-/*
- * Do we want class Fl_Native_File_Chooser to run kdialog when zenity is
- * unavailable and desktop is KDE?
- */
-
-#cmakedefine01 USE_KDIALOG
diff --git configh.in configh.in
index 49ba71e..73a28fa 100644
--- configh.in
+++ configh.in
@@ -340,10 +340,3 @@
  */
 
 #undef FL_CFG_NO_FILESYSTEM_SUPPORT
-
-/*
- * Do we want class Fl_Native_File_Chooser to run kdialog when zenity is
- * unavailable and desktop is KDE?
- */
-
-#define USE_KDIALOG 1
diff --git fltk-options/fltk-options.cxx fltk-options/fltk-options.cxx
index b1dec34..50dbc61 100644
--- fltk-options/fltk-options.cxx
+++ fltk-options/fltk-options.cxx
@@ -136,11 +136,17 @@ Fo_Option_Descr g_option_list[] = {
     "platfom. If disabled, the Fl_Native_File_Chooser class always uses FLTK's "
     "own file dialog (i.e., Fl_File_Chooser) even if GTK is available." },
   { FO_OPTION_BOOL, "Native File Chooser uses Zenity:",
-    Fl::OPTION_FNFC_USES_ZENITY, "OPTION_FNFC_USES_ZENITY", "UseZenity", true,
-    "Use Zenity file chooser instead of FLTK if available.",
-    "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." },
+    Fl::OPTION_FNFC_USES_ZENITY, "OPTION_FNFC_USES_ZENITY", "UseZenity", false,
+    "Fl_Native_File_Chooser uses the 'zenity' command if possible.",
+    "Meaningful for the Wayland/X11 platform only. When switched on, "
+    "the library uses a Zenity-based file dialog if command 'zenity' is available. "
+    "When switched off (default), command 'zenity' is not used."},
+  { FO_OPTION_BOOL, "Native File Chooser uses Kdialog:",
+    Fl::OPTION_FNFC_USES_KDIALOG, "OPTION_FNFC_USES_KDIALOG", "UseKdialog", false,
+    "Fl_Native_File_Chooser uses the 'kdialog' command if possible.",
+    "Meaningful for the Wayland/X11 platform and the KDE-Plasma desktop only. "
+    "When switched on, the library uses a kdialog-based file dialog if command 'kdialog' is "
+    "available. When switched off (default), command 'kdialog' is not used." },
   { FO_HEADLINE, "Print dialog Options" },
   { FO_OPTION_BOOL, "Print dialog uses GTK:",
     Fl::OPTION_PRINTER_USES_GTK, "OPTION_PRINTER_USES_GTK", "PrintUsesGTK", true,
diff --git src/CMakeLists.txt src/CMakeLists.txt
index 74f4011..acb00ec 100644
--- src/CMakeLists.txt
+++ 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 src/Fl.cxx src/Fl.cxx
index 16672cf..43517ee 100644
--- src/Fl.cxx
+++ 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
- <i>Edit/Global FLTK Settings</i>.
+ \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 src/Fl_Native_File_Chooser_GTK.cxx src/Fl_Native_File_Chooser_GTK.cxx
index 28363ae..263acfa 100644
--- src/Fl_Native_File_Chooser_GTK.cxx
+++ src/Fl_Native_File_Chooser_GTK.cxx
@@ -17,10 +17,8 @@
 
 #include <config.h>
 #include <FL/Fl_Native_File_Chooser.H>
-#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 <FL/platform.H>
@@ -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);
 }
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.