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
This commit is contained in:
parent
ee37965fad
commit
abfc8ee52f
@ -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)
|
||||
|
10
FL/Fl.H
10
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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
12
src/Fl.cxx
12
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;
|
||||
}
|
||||
|
@ -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 (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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user