fltk  1.3.5-source
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X.
  Fossies Dox: fltk-1.3.5-source.tar.bz2  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_File_Chooser2.cxx
Go to the documentation of this file.
1 //
2 // "$Id$"
3 //
4 // More Fl_File_Chooser routines.
5 //
6 // Copyright 1999-2011 by Michael Sweet.
7 //
8 // This library is free software. Distribution and use rights are outlined in
9 // the file "COPYING" which should have been included with this file. If this
10 // file is missing or damaged, see the license at:
11 //
12 // http://www.fltk.org/COPYING.php
13 //
14 // Please report all bugs and problems on the following page:
15 //
16 // http://www.fltk.org/str.php
17 //
18 
19 // fabien: ATTENTION: Only Out Of Source Gen. because cxx/H files are autogenerated by fluid.
315 // *** END OF OUT OF SOURCE DOC ***
316 
317 // Contents:
318 //
319 // Fl_File_Chooser::count() - Return the number of selected files.
320 // Fl_File_Chooser::directory() - Set the directory in the file chooser.
321 // Fl_File_Chooser::filter() - Set the filter(s) for the chooser.
322 // Fl_File_Chooser::newdir() - Make a new directory.
323 // Fl_File_Chooser::value() - Return a selected filename.
324 // Fl_File_Chooser::rescan() - Rescan the current directory.
325 // Fl_File_Chooser::favoritesButtonCB() - Handle favorites selections.
326 // Fl_File_Chooser::fileListCB() - Handle clicks (and double-clicks)
327 // in the Fl_File_Browser.
328 // Fl_File_Chooser::fileNameCB() - Handle text entry in the FileBrowser.
329 // Fl_File_Chooser::showChoiceCB() - Handle show selections.
330 // compare_dirnames() - Compare two directory names.
331 // quote_pathname() - Quote a pathname for a menu.
332 // unquote_pathname() - Unquote a pathname from a menu.
333 //
334 // Fl_File_Chooser::add_extra() - add extra widget at the bottom, return pointer
335 // to previous extra widget or NULL if none,
336 // If argument is NULL extra widget removed.
337 // NOTE! file chooser does't delete extra widget in
338 // destructor! To prevent memory leakage don't forget
339 // delete unused extra widgets by yourself.
340 //
341 
342 //
343 // Include necessary headers.
344 //
345 
346 #include <FL/Fl_File_Chooser.H>
347 #include <FL/filename.H>
348 #include <FL/fl_ask.H>
349 #include <FL/x.H>
350 #include <FL/Fl_Shared_Image.H>
351 #include <FL/fl_draw.H>
352 
353 #include <stdio.h>
354 #include <stdlib.h>
355 #include "flstring.h"
356 #include <errno.h>
357 #include <sys/types.h>
358 #include <sys/stat.h>
359 
360 #if defined(WIN32) && ! defined (__CYGWIN__)
361 # include <direct.h>
362 # include <io.h>
363 // Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
364 // on Windows, which is supposed to be POSIX compliant...
365 # define access _access
366 # define mkdir _mkdir
367 // Apparently Borland C++ defines DIRECTORY in <direct.h>, which
368 // interfers with the Fl_File_Icon enumeration of the same name.
369 # ifdef DIRECTORY
370 # undef DIRECTORY
371 # endif // DIRECTORY
372 #else
373 # include <unistd.h>
374 # include <pwd.h>
375 #endif /* WIN32 */
376 
377 
378 //
379 // File chooser label strings and sort function...
380 //
381 
383 
384 const char *Fl_File_Chooser::add_favorites_label = "Add to Favorites";
385 const char *Fl_File_Chooser::all_files_label = "All Files (*)";
386 const char *Fl_File_Chooser::custom_filter_label = "Custom Filter";
387 const char *Fl_File_Chooser::existing_file_label = "Please choose an existing file!";
388 const char *Fl_File_Chooser::favorites_label = "Favorites";
389 const char *Fl_File_Chooser::filename_label = "Filename:";
390 #ifdef WIN32
391 const char *Fl_File_Chooser::filesystems_label = "My Computer";
392 #else
393 const char *Fl_File_Chooser::filesystems_label = "File Systems";
394 #endif // WIN32
395 const char *Fl_File_Chooser::manage_favorites_label = "Manage Favorites";
396 const char *Fl_File_Chooser::new_directory_label = "New Directory?";
397 const char *Fl_File_Chooser::new_directory_tooltip = "Create a new directory.";
398 const char *Fl_File_Chooser::preview_label = "Preview";
399 const char *Fl_File_Chooser::save_label = "Save";
400 const char *Fl_File_Chooser::show_label = "Show:";
401 const char *Fl_File_Chooser::hidden_label = "Show hidden files";
403 
404 
405 //
406 // Local functions...
407 //
408 
409 static int compare_dirnames(const char *a, const char *b);
410 static void quote_pathname(char *, const char *, int);
411 static void unquote_pathname(char *, const char *, int);
412 
413 // use platform dependent getenv() to get the home directory (STR #3166)
414 static const char* get_homedir();
415 
416 //
417 // 'Fl_File_Chooser::count()' - Return the number of selected files.
418 //
419 
420 int // O - Number of selected files
422  int i; // Looping var
423  int fcount; // Number of selected files
424  const char *filename; // Filename in input field or list
425 
426 
427  filename = fileName->value();
428 
429  if (!(type_ & MULTI)) {
430  // Check to see if the file name input field is blank...
431  if (!filename || !filename[0]) return 0;
432  else return 1;
433  }
434 
435  for (i = 1, fcount = 0; i <= fileList->size(); i ++)
436  if (fileList->selected(i)) {
437  // See if this file is a directory...
438  // matt: why would we do that? It is perfectly legal to select multiple
439  // directories in a DIR chooser. They are visually selected and value(i)
440  // returns all of them as expected
441  //filename = (char *)fileList->text(i);
442 
443  //if (filename[strlen(filename) - 1] != '/')
444  fcount ++;
445  }
446 
447  if (fcount) return fcount;
448  else if (!filename || !filename[0]) return 0;
449  else return 1;
450 }
451 
452 
453 //
454 // 'Fl_File_Chooser::directory()' - Set the directory in the file chooser.
455 //
456 
457 void
458 Fl_File_Chooser::directory(const char *d)// I - Directory to change to
459 {
460  char *dirptr; // Pointer into directory
461 
462 
463 // printf("Fl_File_Chooser::directory(\"%s\")\n", d == NULL ? "(null)" : d);
464 
465  // NULL == current directory
466  if (d == NULL)
467  d = ".";
468 
469 #ifdef WIN32
470  // See if the filename contains backslashes...
471  char *slash; // Pointer to slashes
472  char fixpath[FL_PATH_MAX]; // Path with slashes converted
473  if (strchr(d, '\\')) {
474  // Convert backslashes to slashes...
475  strlcpy(fixpath, d, sizeof(fixpath));
476 
477  for (slash = strchr(fixpath, '\\'); slash; slash = strchr(slash + 1, '\\'))
478  *slash = '/';
479 
480  d = fixpath;
481  }
482 #endif // WIN32
483 
484  if (d[0] != '\0')
485  {
486  // Make the directory absolute...
487 #if (defined(WIN32) && ! defined(__CYGWIN__))|| defined(__EMX__)
488  if (d[0] != '/' && d[0] != '\\' && d[1] != ':')
489 #else
490  if (d[0] != '/' && d[0] != '\\')
491 #endif /* WIN32 || __EMX__ */
493  else
494  strlcpy(directory_, d, sizeof(directory_));
495 
496  // Strip any trailing slash...
497  dirptr = directory_ + strlen(directory_) - 1;
498  if ((*dirptr == '/' || *dirptr == '\\') && dirptr > directory_)
499  *dirptr = '\0';
500 
501  // See if we have a trailing .. or . in the filename...
502  dirptr = directory_ + strlen(directory_) - 3;
503  if (dirptr >= directory_ && strcmp(dirptr, "/..") == 0) {
504  // Yes, we have "..", so strip the trailing path...
505  *dirptr = '\0';
506  while (dirptr > directory_) {
507  if (*dirptr == '/') break;
508  dirptr --;
509  }
510 
511  if (dirptr >= directory_ && *dirptr == '/')
512  *dirptr = '\0';
513  } else if ((dirptr + 1) >= directory_ && strcmp(dirptr + 1, "/.") == 0) {
514  // Strip trailing "."...
515  dirptr[1] = '\0';
516  }
517  }
518  else
519  directory_[0] = '\0';
520 
521  if (shown()) {
522  // Rescan the directory...
523  rescan();
524  }
525 }
526 
527 
528 //
529 // 'Fl_File_Chooser::favoritesButtonCB()' - Handle favorites selections.
530 //
531 
532 void
534 {
535  int v; // Current selection
536  char pathname[FL_PATH_MAX], // Pathname
537  menuname[FL_PATH_MAX]; // Menu name
538 
539 
540  v = favoritesButton->value();
541 
542  if (!v) {
543  // Add current directory to favorites...
544  if (get_homedir()) v = favoritesButton->size() - 5;
545  else v = favoritesButton->size() - 4;
546 
547  sprintf(menuname, "favorite%02d", v);
548 
549  prefs_->set(menuname, directory_);
550  prefs_->flush();
551 
552  quote_pathname(menuname, directory_, sizeof(menuname));
553  favoritesButton->add(menuname);
554 
555  if (favoritesButton->size() > 104) {
556  ((Fl_Menu_Item *)favoritesButton->menu())[0].deactivate();
557  }
558  } else if (v == 1) {
559  // Manage favorites...
560  favoritesCB(0);
561  } else if (v == 2) {
562  // Filesystems/My Computer
563  directory("");
564  } else {
565  unquote_pathname(pathname, favoritesButton->text(v), sizeof(pathname));
566  directory(pathname);
567  }
568 }
569 
570 
571 //
572 // 'Fl_File_Chooser::favoritesCB()' - Handle favorites dialog.
573 //
574 
575 void
577  // I - Widget
578 {
579  int i; // Looping var
580  char name[32], // Preference name
581  pathname[1024]; // Directory in list
582 
583 
584  if (!w) {
585  // Load the favorites list...
586  favList->clear();
587  favList->deselect();
588 
589  for (i = 0; i < 100; i ++) {
590  // Get favorite directory 0 to 99...
591  sprintf(name, "favorite%02d", i);
592 
593  prefs_->get(name, pathname, "", sizeof(pathname));
594 
595  // Stop on the first empty favorite...
596  if (!pathname[0]) break;
597 
598  // Add the favorite to the list...
599  favList->add(pathname,
601  }
602 
607 
609  favWindow->show();
610  } else if (w == favList) {
611  i = favList->value();
612  if (i) {
613  if (i > 1) favUpButton->activate();
614  else favUpButton->deactivate();
615 
617 
618  if (i < favList->size()) favDownButton->activate();
619  else favDownButton->deactivate();
620  } else {
624  }
625  } else if (w == favUpButton) {
626  i = favList->value();
627 
628  favList->insert(i - 1, favList->text(i), favList->data(i));
629  favList->remove(i + 1);
630  favList->select(i - 1);
631 
632  if (i == 2) favUpButton->deactivate();
633 
635 
637  } else if (w == favDeleteButton) {
638  i = favList->value();
639 
640  favList->remove(i);
641 
642  if (i > favList->size()) i --;
643  favList->select(i);
644 
645  if (i < favList->size()) favDownButton->activate();
646  else favDownButton->deactivate();
647 
648  if (i > 1) favUpButton->activate();
649  else favUpButton->deactivate();
650 
651  if (!i) favDeleteButton->deactivate();
652 
654  } else if (w == favDownButton) {
655  i = favList->value();
656 
657  favList->insert(i + 2, favList->text(i), favList->data(i));
658  favList->remove(i);
659  favList->select(i + 1);
660 
661  if ((i + 1) == favList->size()) favDownButton->deactivate();
662 
664 
666  } else if (w == favOkButton) {
667  // Copy the new list over...
668  for (i = 0; i < favList->size(); i ++) {
669  // Set favorite directory 0 to 99...
670  sprintf(name, "favorite%02d", i);
671 
672  prefs_->set(name, favList->text(i + 1));
673  }
674 
675  // Clear old entries as necessary...
676  for (; i < 100; i ++) {
677  // Clear favorite directory 0 to 99...
678  sprintf(name, "favorite%02d", i);
679 
680  prefs_->get(name, pathname, "", sizeof(pathname));
681 
682  if (pathname[0]) prefs_->set(name, "");
683  else break;
684  }
685 
687  prefs_->flush();
688 
689  favWindow->hide();
690  }
691 }
692 
693 
694 //
695 // 'Fl_File_Chooser::fileListCB()' - Handle clicks (and double-clicks) in the
696 // Fl_File_Browser.
697 //
698 
699 void
701 {
702  char *filename, // New filename
703  pathname[FL_PATH_MAX]; // Full pathname to file
704 
705 
706  filename = (char *)fileList->text(fileList->value());
707  if (!filename)
708  return;
709 
710  if (!directory_[0]) {
711  strlcpy(pathname, filename, sizeof(pathname));
712  } else if (strcmp(directory_, "/") == 0) {
713  snprintf(pathname, sizeof(pathname), "/%s", filename);
714  } else {
715  snprintf(pathname, sizeof(pathname), "%s/%s", directory_, filename);
716  }
717 
718  if (Fl::event_clicks()) {
719 #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
720  if ((strlen(pathname) == 2 && pathname[1] == ':') ||
721  _fl_filename_isdir_quick(pathname))
722 #else
723  if (_fl_filename_isdir_quick(pathname))
724 #endif /* WIN32 || __EMX__ */
725  {
726  // Change directories...
727  directory(pathname);
728 
729  // Reset the click count so that a click in the same spot won't
730  // be treated as a triple-click. We use a value of -1 because
731  // the next click will increment click count to 0, which is what
732  // we really want...
733  Fl::event_clicks(-1);
734  }
735  else
736  {
737  // Hide the window - picked the file...
738  window->hide();
739  if (callback_) (*callback_)(this, data_);
740  }
741  }
742  else
743  {
744  // Check if the user clicks on a directory when picking files;
745  // if so, make sure only that item is selected...
746  filename = pathname + strlen(pathname) - 1;
747 
748  if ((type_ & MULTI) && !(type_ & DIRECTORY)) {
749  if (*filename == '/') {
750  // Clicked on a directory, deselect everything else...
751  int i = fileList->value();
752  fileList->deselect();
753  fileList->select(i);
754  } else {
755  // Clicked on a file - see if there are other directories selected...
756  int i;
757  const char *temp;
758  for (i = 1; i <= fileList->size(); i ++) {
759  if (i != fileList->value() && fileList->selected(i)) {
760  temp = fileList->text(i);
761  temp += strlen(temp) - 1;
762  if (*temp == '/') break; // Yes, selected directory
763  }
764  }
765 
766  if (i <= fileList->size()) {
767  i = fileList->value();
768  fileList->deselect();
769  fileList->select(i);
770  }
771  }
772  }
773  // Strip any trailing slash from the directory name...
774  if (*filename == '/') *filename = '\0';
775 
776 // puts("Setting fileName from fileListCB...");
777  fileName->value(pathname);
778 
779  // Update the preview box...
782 
783  // Do any callback that is registered...
784  if (callback_) (*callback_)(this, data_);
785 
786  // Activate the OK button as needed...
787  if (!_fl_filename_isdir_quick(pathname) || (type_ & DIRECTORY))
788  okButton->activate();
789  else
790  okButton->deactivate();
791  }
792 }
793 
794 
795 //
796 // 'Fl_File_Chooser::fileNameCB()' - Handle text entry in the FileBrowser.
797 //
798 
799 void
801 {
802  char *filename, // New filename
803  *slash, // Pointer to trailing slash
804  pathname[FL_PATH_MAX], // Full pathname to file
805  matchname[FL_PATH_MAX]; // Matching filename
806  int i, // Looping var
807  min_match, // Minimum number of matching chars
808  max_match, // Maximum number of matching chars
809  num_files, // Number of files in directory
810  first_line; // First matching line
811  const char *file; // File from directory
812 
813 // puts("fileNameCB()");
814 // printf("Event: %s\n", fl_eventnames[Fl::event()]);
815 
816  // Get the filename from the text field...
817  filename = (char *)fileName->value();
818 
819  if (!filename || !filename[0]) {
820  okButton->deactivate();
821  return;
822  }
823 
824  // Expand ~ and $ variables as needed...
825  if (strchr(filename, '~') || strchr(filename, '$')) {
826  fl_filename_expand(pathname, sizeof(pathname), filename);
827  filename = pathname;
828  value(pathname);
829  }
830 
831  // Make sure we have an absolute path...
832 #if (defined(WIN32) && !defined(__CYGWIN__)) || defined(__EMX__)
833  if (directory_[0] != '\0' && filename[0] != '/' &&
834  filename[0] != '\\' &&
835  !(isalpha(filename[0] & 255) && (!filename[1] || filename[1] == ':'))) {
836 #else
837  if (directory_[0] != '\0' && filename[0] != '/') {
838 #endif /* WIN32 || __EMX__ */
839  fl_filename_absolute(pathname, sizeof(pathname), filename);
840  value(pathname);
841  fileName->mark(fileName->position()); // no selection after expansion
842  } else if (filename != pathname) {
843  // Finally, make sure that we have a writable copy...
844  strlcpy(pathname, filename, sizeof(pathname));
845  }
846 
847  filename = pathname;
848 
849  // Now process things according to the key pressed...
850  if (Fl::event_key() == FL_Enter || Fl::event_key() == FL_KP_Enter) {
851  // Enter pressed - select or change directory...
852 #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
853  if ((isalpha(pathname[0] & 255) && pathname[1] == ':' && !pathname[2]) ||
854  (_fl_filename_isdir_quick(pathname) &&
855  compare_dirnames(pathname, directory_))) {
856 #else
857  if (_fl_filename_isdir_quick(pathname) &&
858  compare_dirnames(pathname, directory_)) {
859 #endif /* WIN32 || __EMX__ */
860  directory(pathname);
861  } else if ((type_ & CREATE) || access(pathname, 0) == 0) {
862  if (!_fl_filename_isdir_quick(pathname) || (type_ & DIRECTORY)) {
863  // Update the preview box...
864  update_preview();
865 
866  // Do any callback that is registered...
867  if (callback_) (*callback_)(this, data_);
868 
869  // Hide the window to signal things are done...
870  window->hide();
871  }
872  } else {
873  // File doesn't exist, so beep at and alert the user...
875  }
876  }
877  else if (Fl::event_key() != FL_Delete &&
879  // Check to see if the user has entered a directory...
880  if ((slash = strrchr(pathname, '/')) == NULL)
881  slash = strrchr(pathname, '\\');
882 
883  if (!slash) return;
884 
885  // Yes, change directories if necessary...
886  *slash++ = '\0';
887  filename = slash;
888 
889 #if defined(WIN32) || defined(__EMX__)
890  if (strcasecmp(pathname, directory_) &&
891  (pathname[0] || strcmp("/", directory_))) {
892 #else
893  if (strcmp(pathname, directory_) &&
894  (pathname[0] || strcmp("/", directory_))) {
895 #endif // WIN32 || __EMX__
896  int p = fileName->position();
897  int m = fileName->mark();
898 
899  directory(pathname);
900 
901  if (filename[0]) {
902  char tempname[FL_PATH_MAX];
903 
904  snprintf(tempname, sizeof(tempname), "%s/%s", directory_, filename);
905  fileName->value(tempname);
906  strlcpy(pathname, tempname, sizeof(pathname));
907  }
908 
909  fileName->position(p, m);
910  }
911 
912  // Other key pressed - do filename completion as possible...
913  num_files = fileList->size();
914  min_match = (int) strlen(filename);
915  max_match = min_match + 1;
916  first_line = 0;
917 
918  for (i = 1; i <= num_files && max_match > min_match; i ++) {
919  file = fileList->text(i);
920 
921 #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
922  if (strncasecmp(filename, file, min_match) == 0) {
923 #else
924  if (strncmp(filename, file, min_match) == 0) {
925 #endif // WIN32 || __EMX__
926  // OK, this one matches; check against the previous match
927  if (!first_line) {
928  // First match; copy stuff over...
929  strlcpy(matchname, file, sizeof(matchname));
930  max_match = (int) strlen(matchname);
931 
932  // Strip trailing /, if any...
933  if (matchname[max_match - 1] == '/') {
934  max_match --;
935  matchname[max_match] = '\0';
936  }
937 
938  // And then make sure that the item is visible
939  fileList->topline(i);
940  first_line = i;
941  } else {
942  // Succeeding match; compare to find maximum string match...
943  while (max_match > min_match)
944 #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__)
945  if (strncasecmp(file, matchname, max_match) == 0)
946 #else
947  if (strncmp(file, matchname, max_match) == 0)
948 #endif // WIN32 || __EMX__
949  break;
950  else
951  max_match --;
952 
953  // Truncate the string as needed...
954  matchname[max_match] = '\0';
955  }
956  }
957  }
958 
959  // If we have any matches, add them to the input field...
960  if (first_line > 0 && min_match == max_match &&
961  max_match == (int)strlen(fileList->text(first_line))) {
962  // This is the only possible match...
963  fileList->deselect(0);
964  fileList->select(first_line);
965  fileList->redraw();
966  } else if (max_match > min_match && first_line) {
967  // Add the matching portion...
968  fileName->replace(
969  (int) (filename - pathname),
970  (int) (filename - pathname + min_match),
971  matchname);
972 
973  // Highlight it with the cursor at the end of the selection so
974  // s/he can press the right arrow to accept the selection
975  // (Tab and End also do this for both cases.)
977  (int) (filename - pathname + max_match),
978  (int) (filename - pathname + min_match));
979  } else if (max_match == 0) {
980  fileList->deselect(0);
981  fileList->redraw();
982  }
983 
984  // See if we need to enable the OK button...
985  if (((type_ & CREATE) || !access(fileName->value(), 0)) &&
987  okButton->activate();
988  } else {
989  okButton->deactivate();
990  }
991  } else {
992  // FL_Delete or FL_BackSpace
993  fileList->deselect(0);
994  fileList->redraw();
995  if (((type_ & CREATE) || !access(fileName->value(), 0)) &&
997  okButton->activate();
998  } else {
999  okButton->deactivate();
1000  }
1001  }
1002 }
1003 
1004 
1005 //
1006 // 'Fl_File_Chooser::filter()' - Set the filter(s) for the chooser.
1007 //
1008 
1009 void
1010 Fl_File_Chooser::filter(const char *p) // I - Pattern(s)
1011 {
1012  char *copyp, // Copy of pattern
1013  *start, // Start of pattern
1014  *end; // End of pattern
1015  int allfiles; // Do we have a "*" pattern?
1016  char temp[FL_PATH_MAX]; // Temporary pattern string
1017 
1018 
1019  // Make sure we have a pattern...
1020  if (!p || !*p) p = "*";
1021 
1022  // Copy the pattern string...
1023  copyp = strdup(p);
1024 
1025  // Separate the pattern string as necessary...
1026  showChoice->clear();
1027 
1028  for (start = copyp, allfiles = 0; start && *start; start = end) {
1029  end = strchr(start, '\t');
1030  if (end) *end++ = '\0';
1031 
1032  if (strcmp(start, "*") == 0) {
1034  allfiles = 1;
1035  } else {
1036  quote_pathname(temp, start, sizeof(temp));
1037  showChoice->add(temp);
1038  if (strstr(start, "(*)") != NULL) allfiles = 1;
1039  }
1040  }
1041 
1042  free(copyp);
1043 
1044  if (!allfiles) showChoice->add(all_files_label);
1045 
1047 
1048  showChoice->value(0);
1049  showChoiceCB();
1050 }
1051 
1052 
1053 //
1054 // 'Fl_File_Chooser::newdir()' - Make a new directory.
1055 //
1056 
1057 void
1059 {
1060  const char *dir; // New directory name
1061  char pathname[FL_PATH_MAX]; // Full path of directory
1062 
1063 
1064  // Get a directory name from the user
1065  if ((dir = fl_input("%s", NULL, new_directory_label)) == NULL)
1066  return;
1067 
1068  // Make it relative to the current directory as needed...
1069 #if (defined(WIN32) && ! defined (__CYGWIN__)) || defined(__EMX__)
1070  if (dir[0] != '/' && dir[0] != '\\' && dir[1] != ':')
1071 #else
1072  if (dir[0] != '/' && dir[0] != '\\')
1073 #endif /* WIN32 || __EMX__ */
1074  snprintf(pathname, sizeof(pathname), "%s/%s", directory_, dir);
1075  else
1076  strlcpy(pathname, dir, sizeof(pathname));
1077 
1078  // Create the directory; ignore EEXIST errors...
1079 #if defined(WIN32) && ! defined (__CYGWIN__)
1080  if (mkdir(pathname))
1081 #else
1082  if (mkdir(pathname, 0777))
1083 #endif /* WIN32 */
1084  if (errno != EEXIST)
1085  {
1086  fl_alert("%s", strerror(errno));
1087  return;
1088  }
1089 
1090  // Show the new directory...
1091  directory(pathname);
1092 }
1093 
1094 
1095 
1098 {
1099  previewButton->value(e);
1100  prefs_->set("preview", e);
1101  prefs_->flush();
1102 
1103  Fl_Group *p = previewBox->parent();
1104  if (e) {
1105  int w = p->w() * 2 / 3;
1106  fileList->resize(fileList->x(), fileList->y(),
1107  w, fileList->h());
1108  previewBox->resize(fileList->x()+w, previewBox->y(),
1109  p->w()-w, previewBox->h());
1110  previewBox->show();
1111  update_preview();
1112  } else {
1113  fileList->resize(fileList->x(), fileList->y(),
1114  p->w(), fileList->h());
1115  previewBox->resize(p->x()+p->w(), previewBox->y(),
1116  0, previewBox->h());
1117  previewBox->hide();
1118  }
1119  p->init_sizes();
1120 
1121  fileList->parent()->redraw();
1122 }
1123 
1124 
1125 //
1126 // 'Fl_File_Chooser::previewCB()' - Timeout handler for the preview box.
1127 //
1128 
1129 void
1131  fc->update_preview();
1132 }
1133 
1134 
1135 //
1136 // 'Fl_File_Chooser::rescan()' - Rescan the current directory.
1137 //
1138 
1139 void
1141 {
1142  char pathname[FL_PATH_MAX]; // New pathname for filename field
1143 
1144 
1145  // Clear the current filename
1146  strlcpy(pathname, directory_, sizeof(pathname));
1147  if (pathname[0] && pathname[strlen(pathname) - 1] != '/') {
1148  strlcat(pathname, "/", sizeof(pathname));
1149  }
1150 // puts("Setting fileName in rescan()");
1151  fileName->value(pathname);
1152 
1153  if (type_ & DIRECTORY)
1154  okButton->activate();
1155  else
1156  okButton->deactivate();
1157 
1158  // Build the file list...
1160 #ifndef WIN32
1162 #endif
1163  // Update the preview box...
1164  update_preview();
1165 }
1166 
1167 //
1173 {
1174  // if no filename was set, this is likely a diretory browser
1175  const char *fn = fileName->value();
1176  if (!fn || !*fn || fn[strlen(fn) - 1]=='/') {
1177  rescan();
1178  return;
1179  }
1180 
1181  int i;
1182  char pathname[FL_PATH_MAX]; // New pathname for filename field
1183  strlcpy(pathname, fn, sizeof(pathname));
1184 
1185  // Build the file list...
1187 #ifndef WIN32
1189 #endif
1190  // Update the preview box...
1191  update_preview();
1192 
1193  // and select the chosen file
1194  char found = 0;
1195  char *slash = strrchr(pathname, '/');
1196  if (slash)
1197  slash++;
1198  else
1199  slash = pathname;
1200  for (i = 1; i <= fileList->size(); i ++)
1201 #if defined(WIN32) || defined(__EMX__)
1202  if (strcasecmp(fileList->text(i), slash) == 0) {
1203 #else
1204  if (strcmp(fileList->text(i), slash) == 0) {
1205 #endif // WIN32 || __EMX__
1206  fileList->topline(i);
1207  fileList->select(i);
1208  found = 1;
1209  break;
1210  }
1211 
1212  // update OK button activity
1213  if (found || type_ & CREATE)
1214  okButton->activate();
1215  else
1216  okButton->deactivate();
1217 }
1218 
1219 
1220 //
1221 // 'Fl_File_Chooser::showChoiceCB()' - Handle show selections.
1222 //
1223 
1224 void
1226 {
1227  const char *item, // Selected item
1228  *patstart; // Start of pattern
1229  char *patend; // End of pattern
1230  char temp[FL_PATH_MAX]; // Temporary string for pattern
1231 
1232 
1233  item = showChoice->text(showChoice->value());
1234 
1235  if (strcmp(item, custom_filter_label) == 0) {
1236  if ((item = fl_input("%s", pattern_, custom_filter_label)) != NULL) {
1237  strlcpy(pattern_, item, sizeof(pattern_));
1238 
1239  quote_pathname(temp, item, sizeof(temp));
1240  showChoice->add(temp);
1241  showChoice->value(showChoice->size() - 2);
1242  }
1243  } else if ((patstart = strchr(item, '(')) == NULL) {
1244  strlcpy(pattern_, item, sizeof(pattern_));
1245  } else {
1246  strlcpy(pattern_, patstart + 1, sizeof(pattern_));
1247  if ((patend = strrchr(pattern_, ')')) != NULL) *patend = '\0';
1248  }
1249 
1251 
1252  if (shown()) {
1253  // Rescan the directory...
1255  }
1256 }
1257 
1258 
1259 //
1260 // 'Fl_File_Chooser::update_favorites()' - Update the favorites menu.
1261 //
1262 
1263 void
1265 {
1266  int i; // Looping var
1267  char pathname[FL_PATH_MAX], // Pathname
1268  menuname[2048]; // Menu name
1269  const char *home; // Home directory
1270 
1271 
1273  favoritesButton->add("bla");
1278 
1279  if ((home = get_homedir()) != NULL) {
1280  quote_pathname(menuname, home, sizeof(menuname));
1281  favoritesButton->add(menuname, FL_ALT + 'h', 0);
1282  }
1283 
1284  for (i = 0; i < 100; i ++) {
1285  sprintf(menuname, "favorite%02d", i);
1286  prefs_->get(menuname, pathname, "", sizeof(pathname));
1287  if (!pathname[0]) break;
1288 
1289  quote_pathname(menuname, pathname, sizeof(menuname));
1290 
1291  if (i < 10) favoritesButton->add(menuname, FL_ALT + '0' + i, 0);
1292  else favoritesButton->add(menuname);
1293  }
1294 
1295  if (i == 100) ((Fl_Menu_Item *)favoritesButton->menu())[0].deactivate();
1296 }
1297 
1298 
1299 //
1300 // 'Fl_File_Chooser::update_preview()' - Update the preview box...
1301 //
1302 
1303 void
1305 {
1306  const char *filename; // Current filename
1307  const char *newlabel = 0; // New label text
1308  Fl_Shared_Image *image = 0, // New image
1309  *oldimage; // Old image
1310  int pbw, pbh; // Width and height of preview box
1311  int w, h; // Width and height of preview image
1312  int set = 0; // Set this flag as soon as a decent preview is found
1313 
1314  if (!previewButton->value()) return;
1315 
1316  filename = value();
1317  if (filename == NULL) {
1318  // no file name at all, so we have an empty preview
1319  set = 1;
1320  } else if (fl_filename_isdir(filename)) {
1321  // filename is a directory, show a folder icon
1322  newlabel = "@fileopen";
1323  set = 1;
1324  } else {
1325  struct stat s;
1326  if (fl_stat(filename, &s)==0) {
1327  if ((s.st_mode&S_IFMT)!=S_IFREG) {
1328  // this is no regular file, probably some kind of device
1329  newlabel = "@-3refresh"; // a cross
1330  set = 1;
1331  } else if (s.st_size==0) {
1332  // this file is emty
1333  newlabel = "<empty file>";
1334  set = 1;
1335  } else {
1336  // if this file is an image, try to load it
1338  Fl::check();
1339 
1340  image = Fl_Shared_Image::get(filename);
1341 
1342  if (image) {
1344  Fl::check();
1345  set = 1;
1346  }
1347  }
1348  }
1349  }
1350 
1351  oldimage = (Fl_Shared_Image *)previewBox->image();
1352 
1353  if (oldimage) oldimage->release();
1354 
1355  previewBox->image(0);
1356 
1357  if (!set) {
1358  FILE *fp;
1359  int bytes;
1360  char *ptr;
1361 
1362  if (filename) fp = fl_fopen(filename, "rb");
1363  else fp = NULL;
1364 
1365  if (fp != NULL) {
1366  // Try reading the first 1k of data for a label...
1367  bytes = (int) fread(preview_text_, 1, sizeof(preview_text_) - 1, fp);
1368  preview_text_[bytes] = '\0';
1369  fclose(fp);
1370  } else {
1371  // Assume we can't read any data...
1372  preview_text_[0] = '\0';
1373  }
1374 
1376  Fl::check();
1377 
1378  // Scan the buffer for printable UTF8 chars...
1379  for (ptr = preview_text_; *ptr; ptr++) {
1380  uchar c = uchar(*ptr);
1381  if ( (c&0x80)==0 ) {
1382  if (!isprint(c&255) && !isspace(c&255)) break;
1383  } else if ( (c&0xe0)==0xc0 ) {
1384  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1385  ptr++;
1386  } else if ( (c&0xf0)==0xe0 ) {
1387  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1388  ptr++;
1389  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1390  ptr++;
1391  } else if ( (c&0xf8)==0xf0 ) {
1392  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1393  ptr++;
1394  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1395  ptr++;
1396  if (ptr[1] && (ptr[1]&0xc0)!=0x80) break;
1397  ptr++;
1398  }
1399  }
1400 // *ptr && (isprint(*ptr & 255) || isspace(*ptr & 255));
1401 // ptr ++);
1402 
1403  // Scan the buffer for printable characters in 8 bit
1404  if (*ptr || ptr == preview_text_) {
1405  for (ptr = preview_text_;
1406  *ptr && (isprint(*ptr & 255) || isspace(*ptr & 255));
1407  ptr ++) {/*empty*/}
1408  }
1409 
1410  if (*ptr || ptr == preview_text_) {
1411  // Non-printable file, just show a big ?...
1412  previewBox->label(filename ? "?" : 0);
1414  previewBox->labelsize(75);
1416  } else {
1417  // Show the first 1k of text...
1418  int size = previewBox->h() / 20;
1419  if (size < 6) size = 6;
1420  else if (size > FL_NORMAL_SIZE) size = FL_NORMAL_SIZE;
1421 
1425  previewBox->labelsize(size);
1427  }
1428  } else if (image && ( (image->w() <= 0) ||
1429  (image->h() <= 0) ||
1430  (image->d() < 0) ||
1431  (image->count() <= 0))) {
1432  // Image has errors? Show big 'X'
1433  previewBox->label("X");
1435  previewBox->labelsize(70);
1437  previewBox->redraw();
1438  } else if (image) {
1439  pbw = previewBox->w() - 20;
1440  pbh = previewBox->h() - 20;
1441 
1442  if (image->w() > pbw || image->h() > pbh) {
1443  w = pbw;
1444  h = w * image->h() / image->w();
1445 
1446  if (h > pbh) {
1447  h = pbh;
1448  w = h * image->w() / image->h();
1449  }
1450 
1451  oldimage = (Fl_Shared_Image *)image->copy(w, h);
1452  previewBox->image((Fl_Image *)oldimage);
1453 
1454  image->release();
1455  } else {
1456  previewBox->image((Fl_Image *)image);
1457  }
1458 
1460  previewBox->label(0);
1461  } else if (newlabel) {
1462  previewBox->label(newlabel);
1464  previewBox->labelsize(newlabel[0]=='@'?75:12);
1466  }
1467 
1468  previewBox->redraw();
1469 }
1470 
1471 
1472 //
1473 // 'Fl_File_Chooser::value()' - Return a selected filename.
1474 //
1475 
1476 const char * // O - Filename or NULL
1477 Fl_File_Chooser::value(int f) // I - File number
1478 {
1479  int i; // Looping var
1480  int fcount; // Number of selected files
1481  const char *name; // Current filename
1482  static char pathname[FL_PATH_MAX]; // Filename + directory
1483 
1484 
1485  name = fileName->value();
1486 
1487  if (!(type_ & MULTI)) {
1488  // Return the filename in the filename field...
1489  if (!name || !name[0]) return NULL;
1490  else return name;
1491  }
1492 
1493  // Return a filename from the list...
1494  for (i = 1, fcount = 0; i <= fileList->size(); i ++)
1495  if (fileList->selected(i)) {
1496  // See if this file is a selected file/directory...
1497  name = fileList->text(i);
1498 
1499  fcount ++;
1500 
1501  if (fcount == f) {
1502  if (directory_[0]) {
1503  snprintf(pathname, sizeof(pathname), "%s/%s", directory_, name);
1504  } else {
1505  strlcpy(pathname, name, sizeof(pathname));
1506  }
1507 
1508  return pathname;
1509  }
1510  }
1511 
1512  // If nothing is selected, use the filename field...
1513  if (!name || !name[0]) return NULL;
1514  else return name;
1515 }
1516 
1517 
1518 //
1519 // 'Fl_File_Chooser::value()' - Set the current filename.
1520 //
1521 
1522 void
1524  // I - Filename + directory
1525 {
1526  int i, // Looping var
1527  fcount; // Number of items in list
1528  char *slash; // Directory separator
1529  char pathname[FL_PATH_MAX]; // Local copy of filename
1530 
1531 
1532 // printf("Fl_File_Chooser::value(\"%s\")\n", filename == NULL ? "(null)" : filename);
1533 
1534  // See if the filename is the "My System" directory...
1535  if (filename == NULL || !filename[0]) {
1536  // Yes, just change the current directory...
1538  fileName->value("");
1539  okButton->deactivate();
1540  return;
1541  }
1542 
1543 #ifdef WIN32
1544  // See if the filename contains backslashes...
1545  char fixpath[FL_PATH_MAX]; // Path with slashes converted
1546  if (strchr(filename, '\\')) {
1547  // Convert backslashes to slashes...
1548  strlcpy(fixpath, filename, sizeof(fixpath));
1549 
1550  for (slash = strchr(fixpath, '\\'); slash; slash = strchr(slash + 1, '\\'))
1551  *slash = '/';
1552 
1553  filename = fixpath;
1554  }
1555 #endif // WIN32
1556 
1557  // See if there is a directory in there...
1558  fl_filename_absolute(pathname, sizeof(pathname), filename);
1559 
1560  if ((slash = strrchr(pathname, '/')) != NULL) {
1561  // Yes, change the display to the directory...
1562  if (!fl_filename_isdir(pathname)) *slash++ = '\0';
1563 
1564  directory(pathname);
1565  if (*slash == '/') slash = pathname;
1566  } else {
1567  directory(".");
1568  slash = pathname;
1569  }
1570 
1571  // Set the input field to the absolute path...
1572  if (slash > pathname) slash[-1] = '/';
1573 
1574  fileName->value(pathname);
1575  fileName->position(0, (int) strlen(pathname));
1576  okButton->activate();
1577 
1578  // Then find the file in the file list and select it...
1579  fcount = fileList->size();
1580 
1581  fileList->deselect(0);
1582  fileList->redraw();
1583 
1584  for (i = 1; i <= fcount; i ++)
1585 #if defined(WIN32) || defined(__EMX__)
1586  if (strcasecmp(fileList->text(i), slash) == 0) {
1587 #else
1588  if (strcmp(fileList->text(i), slash) == 0) {
1589 #endif // WIN32 || __EMX__
1590 // printf("Selecting line %d...\n", i);
1591  fileList->topline(i);
1592  fileList->select(i);
1593  break;
1594  }
1595 }
1596 
1598 {
1600  window->show();
1601  Fl::flush();
1605  fileName->take_focus();
1606 #ifdef WIN32
1608 #endif
1609 }
1610 
1612 {
1613  if (value) {
1614  fileList->load(directory());
1615  } else {
1617  fileList->redraw();
1618  }
1619 }
1620 
1622 {
1623  int count = fileList->size();
1624  for(int num = count; num >= 1; num--) {
1625  const char *p = fileList->text(num);
1626  if (*p == '.' && strcmp(p, "../") != 0) fileList->remove(num);
1627  }
1628  fileList->topline(1);
1629 }
1630 
1631 
1632 //
1633 // 'compare_dirnames()' - Compare two directory names.
1634 //
1635 
1636 static int
1637 compare_dirnames(const char *a, const char *b) {
1638  int alen, blen;
1639 
1640  // Get length of each string...
1641  alen = (int) (strlen(a) - 1);
1642  blen = (int) (strlen(b) - 1);
1643 
1644  if (alen < 0 || blen < 0) return alen - blen;
1645 
1646  // Check for trailing slashes...
1647  if (a[alen] != '/') alen ++;
1648  if (b[blen] != '/') blen ++;
1649 
1650  // If the lengths aren't the same, then return the difference...
1651  if (alen != blen) return alen - blen;
1652 
1653  // Do a comparison of the first N chars (alen == blen at this point)...
1654 #ifdef WIN32
1655  return strncasecmp(a, b, alen);
1656 #else
1657  return strncmp(a, b, alen);
1658 #endif // WIN32
1659 }
1660 
1661 
1662 //
1663 // 'quote_pathname()' - Quote a pathname for a menu.
1664 //
1665 
1666 static void
1667 quote_pathname(char *dst, // O - Destination string
1668  const char *src, // I - Source string
1669  int dstsize) // I - Size of destination string
1670 {
1671  dstsize--; // prepare for trailing zero
1672 
1673  while (*src && dstsize > 1) {
1674  if (*src == '\\') {
1675  // Convert backslash to forward slash...
1676  *dst++ = '\\';
1677  *dst++ = '/';
1678  dstsize -= 2;
1679  src ++;
1680  } else {
1681  if (*src == '/') {
1682  *dst++ = '\\';
1683  dstsize--;
1684  }
1685  *dst++ = *src++;
1686  dstsize--;
1687  }
1688  }
1689 
1690  *dst = '\0';
1691 }
1692 
1693 
1694 //
1695 // 'unquote_pathname()' - Unquote a pathname from a menu.
1696 //
1697 
1698 static void
1699 unquote_pathname(char *dst, // O - Destination string
1700  const char *src, // I - Source string
1701  int dstsize) // I - Size of destination string
1702 {
1703  dstsize--; // prepare for trailing zero
1704 
1705  while (*src && dstsize > 0) {
1706  if (*src == '\\') src++;
1707  *dst++ = *src++;
1708  dstsize--;
1709  }
1710 
1711  *dst = '\0';
1712 }
1713 
1714 //
1715 // 'get_homedir()' - Try to find the home directory (platform dependent).
1716 
1717 static const char*
1719 
1720  const char *home = fl_getenv("HOME");
1721 
1722 #ifdef WIN32
1723 
1724  if (!home) home = fl_getenv("UserProfile");
1725 
1726 #endif // WIN32
1727 
1728  return home;
1729 }
1730 
1731 
1732 //
1733 // End of "$Id$".
1734 //
Fl_File_Chooser::filesystems_label
static const char * filesystems_label
Definition: Fl_File_Chooser.H:198
Fl_Image::d
void d(int D)
Definition: Fl_Image.H:84
Fl_File_Chooser::sort
static Fl_File_Sort_F * sort
Definition: Fl_File_Chooser.H:231
Fl_File_Chooser::rescan_keep_filename
void rescan_keep_filename()
Definition: Fl_File_Chooser2.cxx:1172
FL_ALIGN_LEFT
const Fl_Align FL_ALIGN_LEFT
Definition: Enumerations.H:839
FL_Enter
#define FL_Enter
The enter key.
Definition: Enumerations.H:471
Fl_Widget::activate
void activate()
Definition: Fl_Widget.cxx:241
Fl_Widget::align
Fl_Align align() const
Definition: Fl_Widget.H:348
Fl_File_Chooser::showChoice
Fl_Choice * showChoice
Definition: Fl_File_Chooser.H:74
Fl_Button::value
int value(int v)
Definition: Fl_Button.cxx:41
FL_BackSpace
#define FL_BackSpace
The backspace key.
Definition: Enumerations.H:468
Fl_File_Chooser::all_files_label
static const char * all_files_label
Definition: Fl_File_Chooser.H:178
Fl_File_Chooser::preview
int preview() const
Definition: Fl_File_Chooser.H:149
Fl_File_Chooser::directory_
char directory_[2048]
Definition: Fl_File_Chooser.H:55
Fl_Menu_::menu
const Fl_Menu_Item * menu() const
Definition: Fl_Menu_.H:110
Fl_File_Chooser::custom_filter_label
static const char * custom_filter_label
Definition: Fl_File_Chooser.H:182
Fl_File_Chooser::favDeleteButton
Fl_Button * favDeleteButton
Definition: Fl_File_Chooser.H:117
compare_dirnames
static int compare_dirnames(const char *a, const char *b)
Definition: Fl_File_Chooser2.cxx:1637
Fl_File_Chooser::fileName
Fl_File_Input * fileName
Definition: Fl_File_Chooser.H:101
Fl_Image::h
void h(int H)
Definition: Fl_Image.H:80
Fl_Widget::show
virtual void show()
Definition: Fl_Widget.cxx:271
Fl_Image
Base class for image caching and drawing.
Definition: Fl_Image.H:55
Fl_Window::hotspot
void hotspot(int x, int y, int offscreen=0)
Definition: Fl_Window_hotspot.cxx:24
Fl_Shared_Image::copy
virtual Fl_Image * copy(int W, int H)
Definition: Fl_Shared_Image.cxx:316
Fl_File_Chooser::CREATE
Definition: Fl_File_Chooser.H:50
FL_CURSOR_DEFAULT
Definition: Enumerations.H:1049
fl_ask.H
Fl_Menu_::add
int add(const char *, int shortcut, Fl_Callback *, void *=0, int=0)
Definition: Fl_Menu_add.cxx:332
Fl_Image::count
int count() const
Definition: Fl_Image.H:133
Fl_File_Chooser::hidden_label
static const char * hidden_label
Definition: Fl_File_Chooser.H:226
fc
static Fl_File_Chooser * fc
Definition: fl_file_dir.cxx:25
Fl_Widget::labelfont
Fl_Font labelfont() const
Definition: Fl_Widget.H:487
x.H
Fl_File_Chooser::favoritesButtonCB
void favoritesButtonCB()
Definition: Fl_File_Chooser2.cxx:533
filename.H
Fl_Browser::insert
void insert(int line, FL_BLINE *item)
Definition: Fl_Browser.cxx:243
Fl_File_Chooser::show
void show()
Definition: Fl_File_Chooser2.cxx:1597
free
void free()
Fl_File_Chooser::favoritesCB
void favoritesCB(Fl_Widget *w)
Definition: Fl_File_Chooser2.cxx:576
FL_KP_Enter
#define FL_KP_Enter
The enter key on the keypad, same as Fl_KP+'\r'.
Definition: Enumerations.H:493
Fl_Browser::value
int value() const
Definition: Fl_Browser.cxx:826
NULL
#define NULL
Definition: forms.H:34
FL_COURIER
const Fl_Font FL_COURIER
Courier normal.
Definition: Enumerations.H:883
Fl_File_Chooser::filter
const char * filter()
Definition: Fl_File_Chooser.cxx:344
Fl_Browser::remove
void remove(int line)
Definition: Fl_Browser.cxx:229
fl_filename_isdir
int fl_filename_isdir(const char *name)
Definition: filename_isdir.cxx:52
Fl_File_Input::value
int value(const char *str)
Definition: Fl_File_Input.cxx:153
Fl_File_Chooser::value
const char * value(int f=1)
Definition: Fl_File_Chooser2.cxx:1477
Fl::event_key
static int event_key()
Definition: Fl.H:723
Fl_Image::w
void w(int W)
Definition: Fl_Image.H:76
fl_fopen
FILE * fl_fopen(const char *f, const char *mode)
Definition: fl_utf8.cxx:498
b
long b
Definition: jpegint.h:397
snprintf
#define snprintf
Definition: flstring.h:64
Fl_File_Chooser::fileNameCB
void fileNameCB()
Definition: Fl_File_Chooser2.cxx:800
Fl_File_Chooser::remove_hidden_files
void remove_hidden_files()
Definition: Fl_File_Chooser2.cxx:1621
Fl_File_Chooser::new_directory_tooltip
static const char * new_directory_tooltip
Definition: Fl_File_Chooser.H:210
Fl_Browser_::deselect
int deselect(int docallbacks=0)
Definition: Fl_Browser_.cxx:650
Fl_File_Icon::find
static Fl_File_Icon * find(const char *filename, int filetype=ANY)
Definition: Fl_File_Icon.cxx:181
FL_ALIGN_INSIDE
const Fl_Align FL_ALIGN_INSIDE
Definition: Enumerations.H:843
Fl_Browser::topline
int topline() const
Definition: Fl_Browser.cxx:649
Fl_File_Chooser::save_label
static const char * save_label
Definition: Fl_File_Chooser.H:218
Fl::check
static int check()
Definition: Fl.cxx:688
fl_numericsort
int fl_numericsort(struct dirent **, struct dirent **)
Fl_Browser::text
const char * text(int line) const
Definition: Fl_Browser.cxx:722
p
static menustate * p
Definition: Fl_Menu.cxx:606
Fl_Widget::w
void w(int v)
Definition: Fl_Widget.H:143
Fl_File_Chooser::favDownButton
Fl_Button * favDownButton
Definition: Fl_File_Chooser.H:120
dir
static int dir
Definition: fl_draw_image.cxx:67
Fl_Widget::x
void x(int v)
Definition: Fl_Widget.H:139
Fl_File_Chooser::previewButton
Fl_Check_Button * previewButton
Definition: Fl_File_Chooser.H:92
fl_input
const char * fl_input(const char *label, const char *deflt=0,...)
Definition: fl_ask.cxx:505
FL_ALT
#define FL_ALT
One of the alt keys is down.
Definition: Enumerations.H:560
Fl_File_Chooser::favWindow
Fl_Double_Window * favWindow
Definition: Fl_File_Chooser.H:110
FL_CURSOR_WAIT
Definition: Enumerations.H:1052
Fl_File_Chooser::add_favorites_label
static const char * add_favorites_label
Definition: Fl_File_Chooser.H:174
FL_PATH_MAX
#define FL_PATH_MAX
Definition: filename.H:38
Fl_File_Chooser::favoritesButton
Fl_Menu_Button * favoritesButton
Definition: Fl_File_Chooser.H:77
get_homedir
static const char * get_homedir()
Definition: Fl_File_Chooser2.cxx:1718
fl_draw.H
utility header to pull drawing functions together
filename
static const char * filename
Definition: fluid.cxx:119
FL_HELVETICA
const Fl_Font FL_HELVETICA
Helvetica (or Arial) normal (0)
Definition: Enumerations.H:879
Fl_Browser::selected
int selected(int line) const
Definition: Fl_Browser.cxx:759
Fl_File_Chooser::preview_text_
char preview_text_[2048]
Definition: Fl_File_Chooser.H:57
Fl_File_Chooser::rescan
void rescan()
Definition: Fl_File_Chooser2.cxx:1140
strlcpy
#define strlcpy
Definition: flstring.h:84
Fl_File_Chooser::update_preview
void update_preview()
Definition: Fl_File_Chooser2.cxx:1304
Fl_Preferences::get
char get(const char *entry, int &value, int defaultValue)
Definition: Fl_Preferences.cxx:509
fl_cursor
FL_EXPORT void fl_cursor(Fl_Cursor)
Definition: fl_cursor.cxx:42
Fl_Preferences::set
char set(const char *entry, int value)
Definition: Fl_Preferences.cxx:525
Fl_File_Chooser::shown
int shown()
Definition: Fl_File_Chooser.cxx:390
Fl_Choice::value
int value() const
Definition: Fl_Choice.H:95
fl_filename_absolute
int fl_filename_absolute(char *to, int tolen, const char *from)
Definition: filename_absolute.cxx:56
Fl_Double_Window::hide
void hide()
Definition: Fl_Double_Window.cxx:505
Fl_Widget::hide
virtual void hide()
Definition: Fl_Widget.cxx:283
Fl_File_Chooser.H
fl_stat
int fl_stat(const char *path, struct stat *buffer)
Definition: fl_utf8.cxx:669
Fl_File_Chooser::pattern_
char pattern_[2048]
Definition: Fl_File_Chooser.H:56
quote_pathname
static void quote_pathname(char *, const char *, int)
Definition: Fl_File_Chooser2.cxx:1667
Fl_Input_::position
int position() const
Definition: Fl_Input_.H:283
Fl::remove_timeout
static void remove_timeout(Fl_Timeout_Handler, void *=0)
Definition: Fl.cxx:368
fl_getenv
char * fl_getenv(const char *name)
Definition: fl_utf8.cxx:421
Fl_Widget::redraw
void redraw()
Definition: Fl.cxx:1782
FL_NORMAL_SIZE
Fl_Fontsize FL_NORMAL_SIZE
normal font size
Definition: Fl_Widget.cxx:117
Fl_Widget
Definition: Fl_Widget.H:101
Fl_Widget::deactivate
void deactivate()
Definition: Fl_Widget.cxx:253
Fl_Group
Definition: Fl_Group.H:41
Fl_File_Icon::DIRECTORY
Definition: Fl_File_Icon.H:66
Fl_File_Chooser::type_
int type_
Definition: Fl_File_Chooser.H:58
Fl_File_Chooser::count
int count()
Definition: Fl_File_Chooser2.cxx:421
Fl_File_Chooser::DIRECTORY
Definition: Fl_File_Chooser.H:50
Fl_File_Chooser::callback_
void(* callback_)(Fl_File_Chooser *, void *)
Definition: Fl_File_Chooser.H:53
_fl_filename_isdir_quick
int _fl_filename_isdir_quick(const char *n)
Definition: filename_isdir.cxx:35
Fl_Widget::h
void h(int v)
Definition: Fl_Widget.H:145
Fl_File_Chooser::update_favorites
void update_favorites()
Definition: Fl_File_Chooser2.cxx:1264
Fl_Shared_Image.H
Fl_Widget::label
const char * label() const
Definition: Fl_Widget.H:421
unquote_pathname
static void unquote_pathname(char *, const char *, int)
Definition: Fl_File_Chooser2.cxx:1699
Fl_Menu_::text
const char * text() const
Definition: Fl_Menu_.H:150
Fl_Menu_::value
int value() const
Definition: Fl_Menu_.H:140
Fl_File_Browser::load
int load(const char *directory, Fl_File_Sort_F *sort=fl_numericsort)
Definition: Fl_File_Browser.cxx:431
Fl_File_Chooser::favList
Fl_File_Browser * favList
Definition: Fl_File_Chooser.H:111
Fl_File_Chooser::window
Fl_Double_Window * window
Definition: Fl_File_Chooser.H:71
Fl_File_Chooser
Definition: Fl_File_Chooser.H:48
Fl_File_Chooser::previewBox
Fl_Box * previewBox
Definition: Fl_File_Chooser.H:90
Fl_Widget::y
void y(int v)
Definition: Fl_Widget.H:141
Fl_File_Sort_F
int() Fl_File_Sort_F(struct dirent **, struct dirent **)
Definition: filename.H:116
FL_MENU_DIVIDER
Creates divider line below this item. Also ends a group of radio buttons.
Definition: Fl_Menu_Item.H:40
Fl::event_clicks
static int event_clicks()
Definition: Fl.H:645
Fl_Window::cursor
void cursor(Fl_Cursor)
Definition: fl_cursor.cxx:111
Fl_Shared_Image::get
static Fl_Shared_Image * get(const char *name, int W=0, int H=0)
Definition: Fl_Shared_Image.cxx:541
Fl_File_Chooser::data_
void * data_
Definition: Fl_File_Chooser.H:54
Fl::flush
static void flush()
Definition: Fl.cxx:797
Fl_Browser::add
void add(const char *newtext, void *d=0)
Definition: Fl_Browser.cxx:710
FL_ALIGN_TOP
const Fl_Align FL_ALIGN_TOP
Definition: Enumerations.H:833
Fl_File_Chooser::previewCB
static void previewCB(Fl_File_Chooser *fc)
Definition: Fl_File_Chooser2.cxx:1130
Fl::add_timeout
static void add_timeout(double t, Fl_Timeout_Handler, void *=0)
Definition: Fl.cxx:329
Fl_Menu_Item
Definition: Fl_Menu_Item.H:112
Fl_Preferences::flush
void flush()
Definition: Fl_Preferences.cxx:896
Fl_File_Chooser::filename_label
static const char * filename_label
Definition: Fl_File_Chooser.H:194
Fl_Preferences
Fl_Preferences provides methods to store user settings between application starts.
Definition: Fl_Preferences.H:60
set
int set
Definition: fl_boxtype.cxx:287
Fl_File_Chooser::new_directory_label
static const char * new_directory_label
Definition: Fl_File_Chooser.H:206
Fl_File_Chooser::showChoiceCB
void showChoiceCB()
Definition: Fl_File_Chooser2.cxx:1225
Fl_Browser_::resize
void resize(int X, int Y, int W, int H)
Definition: Fl_Browser_.cxx:105
Fl_File_Chooser::existing_file_label
static const char * existing_file_label
Definition: Fl_File_Chooser.H:186
Fl_File_Chooser::okButton
Fl_Return_Button * okButton
Definition: Fl_File_Chooser.H:104
f
Fl_Box_Draw_F * f
Definition: fl_boxtype.cxx:285
Fl_Widget::parent
Fl_Group * parent() const
Definition: Fl_Widget.H:254
Fl_Timeout_Handler
void(* Fl_Timeout_Handler)(void *data)
Definition: Fl.H:92
Fl_File_Browser::filter
void filter(const char *pattern)
Definition: Fl_File_Browser.cxx:723
Fl_Input_::mark
int mark() const
Definition: Fl_Input_.H:287
flstring.h
Fl_Double_Window::show
void show()
Definition: Fl_Double_Window.cxx:79
Fl_File_Chooser::newdir
void newdir()
Definition: Fl_File_Chooser2.cxx:1058
Fl_File_Chooser::prefs_
static Fl_Preferences * prefs_
Definition: Fl_File_Chooser.H:52
Fl_Browser::clear
void clear()
Definition: Fl_Browser.cxx:685
Fl_Browser::data
void * data(int line) const
Definition: Fl_Browser.cxx:735
Fl_Widget::resize
virtual void resize(int x, int y, int w, int h)
Definition: Fl_Widget.cxx:150
strlcat
#define strlcat
Definition: flstring.h:79
Fl_File_Chooser::manage_favorites_label
static const char * manage_favorites_label
Definition: Fl_File_Chooser.H:202
Fl_File_Chooser::MULTI
Definition: Fl_File_Chooser.H:50
Fl_Widget::take_focus
int take_focus()
Definition: Fl_Widget.cxx:162
Fl_Widget::labelsize
Fl_Fontsize labelsize() const
Definition: Fl_Widget.H:502
Fl_Browser::select
int select(int line, int val=1)
Definition: Fl_Browser.cxx:748
Fl_Align
unsigned Fl_Align
Definition: Enumerations.H:828
start
static int start(Fl_RGB_Image *img, int XP, int YP, int WP, int HP, int w, int h, int &cx, int &cy, int &X, int &Y, int &W, int &H)
Definition: Fl_Image.cxx:655
Fl_File_Chooser::preview_label
static const char * preview_label
Definition: Fl_File_Chooser.H:214
Fl_File_Chooser::fileList
Fl_File_Browser * fileList
Definition: Fl_File_Chooser.H:87
uchar
unsigned char uchar
Definition: fl_types.h:30
fl_filename_expand
int fl_filename_expand(char *to, int tolen, const char *from)
Definition: filename_expand.cxx:63
Fl_File_Chooser::show_label
static const char * show_label
Definition: Fl_File_Chooser.H:222
Fl_Menu_::clear
void clear()
Definition: Fl_Menu_.cxx:457
Fl_Browser::size
int size() const
Definition: Fl_Browser.H:141
name
static const char * name
Definition: Fl_arg.cxx:53
fl_alert
void fl_alert(const char *,...)
Definition: fl_ask.cxx:361
FL_Delete
#define FL_Delete
The delete key.
Definition: Enumerations.H:506
Fl_File_Chooser::showHidden
void showHidden(int e)
Definition: Fl_File_Chooser2.cxx:1611
Fl_Shared_Image
Definition: Fl_Shared_Image.H:50
Fl_File_Chooser::favorites_label
static const char * favorites_label
Definition: Fl_File_Chooser.H:190
Fl_File_Chooser::fileListCB
void fileListCB()
Definition: Fl_File_Chooser2.cxx:700
Fl_File_Chooser::showHiddenButton
Fl_Check_Button * showHiddenButton
Definition: Fl_File_Chooser.H:97
Fl_Shared_Image::release
void release()
Definition: Fl_Shared_Image.cxx:230
Fl_Input_::replace
int replace(int b, int e, const char *text, int ilen=0)
Definition: Fl_Input_.cxx:803
Fl_File_Chooser::favUpButton
Fl_Button * favUpButton
Definition: Fl_File_Chooser.H:114
Fl_Widget::image
Fl_Image * image()
Definition: Fl_Widget.H:514
FL_ALIGN_CLIP
const Fl_Align FL_ALIGN_CLIP
Definition: Enumerations.H:849
Fl_Menu_::size
int size() const
Definition: Fl_Menu_.cxx:407
Fl_File_Chooser::directory
char * directory()
Definition: Fl_File_Chooser.cxx:340
Fl_File_Chooser::favOkButton
Fl_Return_Button * favOkButton
Definition: Fl_File_Chooser.H:126