Fix for issue #278 - continued : add CMake OPTION_USE_KDIALOG

Use of the kdialog command by class Fl_Naive_File_Chooser can now be turned off
at build-time through CMake OPTION_USE_KDIALOG.

If building via configure + make, set #define USE_KDIALOG to 0 in config.h before make.
This commit is contained in:
ManoloFLTK 2021-12-08 09:40:57 +01:00
parent 630517049f
commit 4bc25f7f9d
5 changed files with 31 additions and 2 deletions

View File

@ -609,6 +609,15 @@ if (OPTION_FILESYSTEM_SUPPORT)
endif (OPTION_FILESYSTEM_SUPPORT)
#######################################################################
#######################################################################
option (OPTION_USE_KDIALOG "Fl_Native_File_Chooser may run kdialog" ON)
if (OPTION_USE_KDIALOG)
set (USE_KDIALOG 1)
else ()
set (USE_KDIALOG 0)
endif (OPTION_USE_KDIALOG)
#######################################################################
#######################################################################
option (OPTION_CREATE_ANDROID_STUDIO_IDE "create files needed to compile FLTK for Android" OFF)
#######################################################################

View File

@ -369,3 +369,9 @@
*/
#cmakedefine FL_CFG_NO_FILESYSTEM_SUPPORT 1
/*
* Do we want class Fl_Native_File_Chooser to run kdialog when desktop is KDE?
*/
#cmakedefine01 USE_KDIALOG

View File

@ -370,3 +370,9 @@
*/
#undef FL_CFG_NO_FILESYSTEM_SUPPORT
/*
* Do we want class Fl_Native_File_Chooser to run kdialog when desktop is KDE?
*/
#define USE_KDIALOG 1

View File

@ -213,9 +213,13 @@ if (USE_X11)
fl_dnd_x.cxx
Fl_Native_File_Chooser_FLTK.cxx
Fl_Native_File_Chooser_GTK.cxx
Fl_Native_File_Chooser_Kdialog.cxx
Fl_get_key.cxx
)
if (OPTION_USE_KDIALOG)
set (DRIVER_FILES ${DRIVER_FILES} Fl_Native_File_Chooser_Kdialog.cxx)
endif (OPTION_USE_KDIALOG)
if (USE_XFT)
set (DRIVER_FILES ${DRIVER_FILES}
drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx

View File

@ -17,7 +17,9 @@
#include <config.h>
#include <FL/Fl_Native_File_Chooser.H>
#include "Fl_Native_File_Chooser_Kdialog.H"
#if USE_KDIALOG
# include "Fl_Native_File_Chooser_Kdialog.H"
#endif
#if HAVE_DLSYM && HAVE_DLFCN_H
#include <FL/platform.H>
@ -913,6 +915,7 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
// otherwise, use FLTK file chooser.
platform_fnfc = NULL;
if (Fl::option(Fl::OPTION_FNFC_USES_GTK)) {
#if USE_KDIALOG
const char *desktop = getenv("XDG_CURRENT_DESKTOP");
if (desktop && strcmp(desktop, "KDE") == 0 && val != BROWSE_MULTI_DIRECTORY) {
if (!Fl_Kdialog_Native_File_Chooser_Driver::have_looked_for_kdialog) {
@ -929,6 +932,7 @@ 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_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs == 0) {