mirror of
https://github.com/fltk/fltk.git
synced 2026-09-28 15:55:22 +08:00
Added "Show hidden files" check button to the file chooser panel.
This had been previously done in r.8282 and r.8286 without accounting for
the existence of the Fl_File_Chooser.fl file. With this commit, files
Fl_File_Chooser.{cxx, H} are properly generated by Fl_File_Chooser.fl
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8785 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+13
-10
@@ -95,6 +95,11 @@ public:
|
||||
private:
|
||||
void cb_previewButton_i(Fl_Check_Button*, void*);
|
||||
static void cb_previewButton(Fl_Check_Button*, void*);
|
||||
public:
|
||||
Fl_Check_Button *showHiddenButton;
|
||||
private:
|
||||
void cb_showHiddenButton_i(Fl_Check_Button*, void*);
|
||||
static void cb_showHiddenButton(Fl_Check_Button*, void*);
|
||||
Fl_File_Input *fileName;
|
||||
void cb_fileName_i(Fl_File_Input*, void*);
|
||||
static void cb_fileName(Fl_File_Input*, void*);
|
||||
@@ -123,11 +128,6 @@ private:
|
||||
Fl_Return_Button *favOkButton;
|
||||
void cb_favOkButton_i(Fl_Return_Button*, void*);
|
||||
static void cb_favOkButton(Fl_Return_Button*, void*);
|
||||
#ifndef WIN32
|
||||
Fl_Check_Button *show_hidden;
|
||||
static void show_hidden_cb(Fl_Check_Button*, void*);
|
||||
void remove_hidden_files();
|
||||
#endif
|
||||
public:
|
||||
~Fl_File_Chooser();
|
||||
void callback(void (*cb)(Fl_File_Chooser *, void *), void *d = 0);
|
||||
@@ -149,9 +149,13 @@ public:
|
||||
const char * ok_label();
|
||||
void preview(int e);
|
||||
int preview() const { return previewButton->value(); };
|
||||
private:
|
||||
void showHidden(int e);
|
||||
void remove_hidden_files();
|
||||
public:
|
||||
void rescan();
|
||||
void rescan_keep_filename();
|
||||
void show();
|
||||
void show();
|
||||
int shown();
|
||||
void textcolor(Fl_Color c);
|
||||
Fl_Color textcolor();
|
||||
@@ -218,10 +222,10 @@ public:
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *show_label;
|
||||
/**
|
||||
/**
|
||||
[standard text may be customized at run-time]
|
||||
*/
|
||||
static const char *hidden_label;
|
||||
*/
|
||||
static const char *hidden_label;
|
||||
/**
|
||||
the sort function that is used when loading
|
||||
the contents of a directory.
|
||||
@@ -231,7 +235,6 @@ private:
|
||||
Fl_Widget* ext_group;
|
||||
public:
|
||||
Fl_Widget* add_extra(Fl_Widget* gr);
|
||||
Fl_File_Browser *browser(void) {return fileList; };
|
||||
};
|
||||
FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0);
|
||||
FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0);
|
||||
|
||||
+58
-85
File diff suppressed because it is too large
Load Diff
+16
-11
@@ -40,8 +40,8 @@ class FL_EXPORT Fl_File_Chooser {open
|
||||
decl {static Fl_Preferences prefs_;} {}
|
||||
decl {void (*callback_)(Fl_File_Chooser*, void *);} {}
|
||||
decl {void *data_;} {}
|
||||
decl {char directory_[1024];} {}
|
||||
decl {char pattern_[1024];} {}
|
||||
decl {char directory_[FL_PATH_MAX];} {}
|
||||
decl {char pattern_[FL_PATH_MAX];} {}
|
||||
decl {char preview_text_[2048];} {}
|
||||
decl {int type_;} {}
|
||||
decl {void favoritesButtonCB();} {}
|
||||
@@ -115,6 +115,12 @@ window->hide();} open
|
||||
xywh {10 275 73 20} down_box DOWN_BOX shortcut 0x80070 value 1
|
||||
code0 {previewButton->label(preview_label);}
|
||||
}
|
||||
Fl_Check_Button showHiddenButton {
|
||||
label {Show hidden files}
|
||||
callback {showHidden(showHiddenButton->value());}
|
||||
xywh {115 275 165 20} down_box DOWN_BOX
|
||||
code0 {showHiddenButton->label(hidden_label);}
|
||||
}
|
||||
Fl_Box {} {
|
||||
private xywh {115 275 365 20} resizable
|
||||
}
|
||||
@@ -301,19 +307,15 @@ okButton->parent()->init_sizes();} {}
|
||||
}
|
||||
decl {int preview() const { return previewButton->value(); }} {public
|
||||
}
|
||||
decl {void showHidden(int e);} {private
|
||||
}
|
||||
decl {void remove_hidden_files();} {private
|
||||
}
|
||||
decl {void rescan();} {public
|
||||
}
|
||||
decl {void rescan_keep_filename();} {public
|
||||
}
|
||||
Function {show()} {open return_type void
|
||||
} {
|
||||
code {window->hotspot(fileList);
|
||||
window->show();
|
||||
Fl::flush();
|
||||
fl_cursor(FL_CURSOR_WAIT);
|
||||
rescan_keep_filename();
|
||||
fl_cursor(FL_CURSOR_DEFAULT);
|
||||
fileName->take_focus();} {}
|
||||
decl {void show();} {public
|
||||
}
|
||||
Function {shown()} {return_type int
|
||||
} {
|
||||
@@ -418,6 +420,9 @@ else
|
||||
decl {static const char *show_label;} {
|
||||
comment {[standard text may be customized at run-time]} public
|
||||
}
|
||||
decl {static const char *hidden_label;} {
|
||||
comment {[standard text may be customized at run-time]} public
|
||||
}
|
||||
decl {static Fl_File_Sort_F *sort;} {
|
||||
comment {the sort function that is used when loading
|
||||
the contents of a directory.} public
|
||||
|
||||
@@ -347,6 +347,7 @@
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/x.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/fl_draw.H>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -1151,7 +1152,7 @@ Fl_File_Chooser::rescan()
|
||||
// Build the file list...
|
||||
fileList->load(directory_, sort);
|
||||
#ifndef WIN32
|
||||
if (!show_hidden->value()) remove_hidden_files();
|
||||
if (!showHiddenButton->value()) remove_hidden_files();
|
||||
#endif
|
||||
// Update the preview box...
|
||||
update_preview();
|
||||
@@ -1178,7 +1179,7 @@ void Fl_File_Chooser::rescan_keep_filename()
|
||||
// Build the file list...
|
||||
fileList->load(directory_, sort);
|
||||
#ifndef WIN32
|
||||
if (!show_hidden->value()) remove_hidden_files();
|
||||
if (!showHiddenButton->value()) remove_hidden_files();
|
||||
#endif
|
||||
// Update the preview box...
|
||||
update_preview();
|
||||
@@ -1576,8 +1577,42 @@ Fl_File_Chooser::value(const char *filename)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::show()
|
||||
{
|
||||
window->hotspot(fileList);
|
||||
window->show();
|
||||
Fl::flush();
|
||||
fl_cursor(FL_CURSOR_WAIT);
|
||||
rescan_keep_filename();
|
||||
fl_cursor(FL_CURSOR_DEFAULT);
|
||||
fileName->take_focus();
|
||||
#ifdef WIN32
|
||||
showHiddenButton->hide();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::showHidden(int value)
|
||||
{
|
||||
if (value) {
|
||||
fileList->load(directory());
|
||||
} else {
|
||||
remove_hidden_files();
|
||||
fileList->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Fl_File_Chooser::remove_hidden_files()
|
||||
{
|
||||
int count = fileList->size();
|
||||
for(int num = count; num >= 1; num--) {
|
||||
const char *p = fileList->text(num);
|
||||
if (*p == '.' && strcmp(p, "../") != 0) fileList->remove(num);
|
||||
}
|
||||
fileList->topline(1);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'compare_dirnames()' - Compare two directory names.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user