21#include <FL/Fl_File_Icon.H>
22#define FLTK_CHOOSER_SINGLE Fl_File_Chooser::SINGLE
23#define FLTK_CHOOSER_DIRECTORY Fl_File_Chooser::DIRECTORY
24#define FLTK_CHOOSER_MULTI Fl_File_Chooser::MULTI
25#define FLTK_CHOOSER_CREATE Fl_File_Chooser::CREATE
27#include "Fl_Native_File_Chooser_common.cxx"
28#include "Fl_Native_File_Chooser_GTK.cxx"
33int Fl_Native_File_Chooser::have_looked_for_GTK_libs = 0;
41#if FLTK_ABI_VERSION <= 10302
52 if (have_looked_for_GTK_libs == 0) {
54#if HAVE_DLSYM && HAVE_DLFCN_H
56 Fl_GTK_File_Chooser::probe_for_GTK_libs();
59 have_looked_for_GTK_libs = -1;
62 if (Fl_GTK_File_Chooser::did_find_GTK_libs) _gtk_file_chooser =
new Fl_GTK_File_Chooser(val);
71 delete _x11_file_chooser;
244Fl_FLTK_File_Chooser::Fl_FLTK_File_Chooser(
int val) {
262Fl_FLTK_File_Chooser::~Fl_FLTK_File_Chooser() {
263 delete _file_chooser;
264 _file_chooser = NULL;
265 _filter = strfree(_filter);
266 _parsedfilt = strfree(_parsedfilt);
267 _preset_file = strfree(_preset_file);
268 _prevvalue = strfree(_prevvalue);
269 _directory = strfree(_directory);
270 _errmsg = strfree(_errmsg);
275void Fl_FLTK_File_Chooser::errmsg(
const char *msg) {
276 _errmsg = strfree(_errmsg);
277 _errmsg = strnew(msg);
281int Fl_FLTK_File_Chooser::type_fl_file(
int val) {
284 return(Fl_File_Chooser::SINGLE);
286 return(Fl_File_Chooser::SINGLE | Fl_File_Chooser::DIRECTORY);
288 return(Fl_File_Chooser::MULTI);
290 return(Fl_File_Chooser::DIRECTORY | Fl_File_Chooser::MULTI);
292 return(Fl_File_Chooser::SINGLE | Fl_File_Chooser::CREATE);
294 return(Fl_File_Chooser::DIRECTORY | Fl_File_Chooser::MULTI | Fl_File_Chooser::CREATE);
296 return(Fl_File_Chooser::SINGLE);
300void Fl_FLTK_File_Chooser::type(
int val) {
302 _file_chooser->
type(type_fl_file(val));
305int Fl_FLTK_File_Chooser::type()
const {
309void Fl_FLTK_File_Chooser::options(
int val) {
313int Fl_FLTK_File_Chooser::options()
const {
317int Fl_FLTK_File_Chooser::show() {
321 _file_chooser->
filter(_parsedfilt);
330 if ( _directory && _directory[0] ) {
337 if ( _preset_file ) {
338 _file_chooser->
value(_preset_file);
346 _file_chooser->
type(_file_chooser->
type() | Fl_File_Chooser::CREATE);
349 _file_chooser->
show();
352 while ( _file_chooser->
shown() ) {
356 if ( _file_chooser->
value() && _file_chooser->
value()[0] ) {
357 _prevvalue = strfree(_prevvalue);
358 _prevvalue = strnew(_file_chooser->
value());
364 if ( stat(_file_chooser->
value(), &buf) != -1 ) {
365 if ( buf.st_mode & S_IFREG ) {
366 if ( exist_dialog() == 0 ) {
374 if ( _file_chooser->
count() )
return(0);
378const char *Fl_FLTK_File_Chooser::errmsg()
const {
379 return(_errmsg ? _errmsg :
"No error");
382const char* Fl_FLTK_File_Chooser::filename()
const {
383 if ( _file_chooser->
count() > 0 ) {
384 return(_file_chooser->
value());
389const char* Fl_FLTK_File_Chooser::filename(
int i)
const {
390 if ( i < _file_chooser->count() )
391 return(_file_chooser->
value(i+1));
395void Fl_FLTK_File_Chooser::title(
const char *val) {
396 _file_chooser->
label(val);
399const char *Fl_FLTK_File_Chooser::title()
const {
400 return(_file_chooser->
label());
403void Fl_FLTK_File_Chooser::filter(
const char *val) {
404 _filter = strfree(_filter);
405 _filter = strnew(val);
409const char *Fl_FLTK_File_Chooser::filter()
const {
413int Fl_FLTK_File_Chooser::filters()
const {
417void Fl_FLTK_File_Chooser::filter_value(
int val) {
421int Fl_FLTK_File_Chooser::filter_value()
const {
425int Fl_FLTK_File_Chooser::count()
const {
426 return _file_chooser->
count();
429void Fl_FLTK_File_Chooser::directory(
const char *val) {
430 _directory = strfree(_directory);
431 _directory = strnew(val);
434const char *Fl_FLTK_File_Chooser::directory()
const {
448void Fl_FLTK_File_Chooser::parse_filter() {
449 _parsedfilt = strfree(_parsedfilt);
454 int has_name = strchr(in,
'\t') ? 1 : 0;
456 char mode = has_name ?
'n' :
'w';
457 char wildcard[1024] =
"";
458 char name[1024] =
"";
470 if ( mode !=
'n' )
goto regchar;
485 sprintf(comp,
"%s%.511s(%.511s)", ((_parsedfilt)?
"\t":
""),
487 _parsedfilt = strapp(_parsedfilt, comp);
492 wildcard[0] = name[0] =
'\0';
493 mode = strchr(in,
'\t') ?
'n' :
'w';
495 if ( *in ==
'\0' )
return;
502 case 'n': chrcat(name, *in);
continue;
503 case 'w': chrcat(wildcard, *in);
continue;
511void Fl_FLTK_File_Chooser::preset_file(
const char* val) {
512 _preset_file = strfree(_preset_file);
513 _preset_file = strnew(val);
516const char* Fl_FLTK_File_Chooser::preset_file()
const {
520int Fl_FLTK_File_Chooser::exist_dialog() {
Fl_Native_File_Chooser widget.
Definition Fl_Native_File_Chooser.H:259
The Fl_File_Chooser widget displays a standard file selection dialog that supports various selection ...
Definition Fl_File_Chooser.H:48
int shown()
Returns non-zero if the file chooser main window show() has been called (but not hide() see Fl_Window...
Definition Fl_File_Chooser.cxx:390
void show()
Shows the Fl_File_Chooser window.
Definition Fl_File_Chooser2.cxx:1597
int filter_value()
Gets the current filename filter selection.
Definition Fl_File_Chooser.cxx:348
void directory(const char *d)
Sets the current directory.
Definition Fl_File_Chooser2.cxx:458
const char * value(int f=1)
Gets the current value of the selected file(s).
Definition Fl_File_Chooser2.cxx:1477
int count()
Returns the number of selected files.
Definition Fl_File_Chooser2.cxx:421
void filter(const char *p)
Sets or gets the current filename filter patterns.
Definition Fl_File_Chooser2.cxx:1010
void type(int t)
Sets the current type of Fl_File_Chooser.
Definition Fl_File_Chooser.cxx:418
void preview(int e)
Enable or disable the preview tile.
Definition Fl_File_Chooser2.cxx:1097
void label(const char *l)
Sets the title bar text for the Fl_File_Chooser.
Definition Fl_File_Chooser.cxx:369
Definition Fl_Native_File_Chooser.H:302
static const char * file_exists_message
Localizable message.
Definition Fl_Native_File_Chooser.H:129
int filter_value() const
Returns which filter value was last selected by the user.
Definition Fl_Native_File_Chooser_FLTK.cxx:213
const char * filter() const
Returns the filter string last set.
Definition Fl_Native_File_Chooser_FLTK.cxx:173
const char * errmsg() const
Returns a system dependent error message for the last method that failed.
Definition Fl_Native_File_Chooser_FLTK.cxx:233
~Fl_Native_File_Chooser()
Destructor.
Definition Fl_Native_File_Chooser_FLTK.cxx:70
const char * preset_file() const
Get the preset filename.
Definition Fl_Native_File_Chooser_FLTK.cxx:226
const char * filename() const
Return the filename the user chose.
Definition Fl_Native_File_Chooser_FLTK.cxx:126
Fl_Native_File_Chooser(int val=BROWSE_FILE)
The constructor.
Definition Fl_Native_File_Chooser_FLTK.cxx:40
int filters() const
Gets how many filters were available, not including "All Files".
Definition Fl_Native_File_Chooser_FLTK.cxx:198
@ BROWSE_DIRECTORY
browse directories (lets user choose one directory)
Definition Fl_Native_File_Chooser.H:115
@ BROWSE_MULTI_FILE
browse files (lets user choose multiple files)
Definition Fl_Native_File_Chooser.H:116
@ BROWSE_SAVE_FILE
browse to save a file
Definition Fl_Native_File_Chooser.H:118
@ BROWSE_SAVE_DIRECTORY
browse to save a directory
Definition Fl_Native_File_Chooser.H:119
@ BROWSE_MULTI_DIRECTORY
browse directories (lets user choose multiple directories)
Definition Fl_Native_File_Chooser.H:117
@ BROWSE_FILE
browse files (lets user choose one file)
Definition Fl_Native_File_Chooser.H:114
int show()
Post the chooser's dialog.
Definition Fl_Native_File_Chooser_FLTK.cxx:242
@ NEW_FOLDER
Show 'New Folder' icon (if supported)
Definition Fl_Native_File_Chooser.H:124
@ NO_OPTIONS
no options enabled
Definition Fl_Native_File_Chooser.H:122
@ PREVIEW
enable preview mode (if supported)
Definition Fl_Native_File_Chooser.H:125
@ SAVEAS_CONFIRM
Show native 'Save As' overwrite confirm dialog.
Definition Fl_Native_File_Chooser.H:123
const char * title() const
Get the title of the file chooser's dialog window.
Definition Fl_Native_File_Chooser_FLTK.cxx:167
const char * directory() const
Returns the current preset directory() value.
Definition Fl_Native_File_Chooser_FLTK.cxx:154
int options() const
Gets the platform specific Fl_Native_File_Chooser::Option flags.
Definition Fl_Native_File_Chooser_FLTK.cxx:103
int type() const
Gets the current Fl_Native_File_Chooser::Type of browser.
Definition Fl_Native_File_Chooser_FLTK.cxx:82
int count() const
Returns the number of filenames (or directory names) the user selected.
Definition Fl_Native_File_Chooser_FLTK.cxx:118
static int wait()
Waits until "something happens" and then returns.
Definition Fl.cxx:670
@ OPTION_FNFC_USES_GTK
When switched on (default), Fl_Native_File_Chooser runs GTK file dialogs if the GTK library is availa...
Definition Fl.H:231
static bool option(Fl_Option opt)
FLTK library options management.
Definition Fl.cxx:2186
FL_EXPORT const char * fl_ok
string pointer used in common dialogs, you can change it to another language
Definition fl_ask.cxx:279
FL_EXPORT const char * fl_cancel
string pointer used in common dialogs, you can change it to another language
Definition fl_ask.cxx:280