summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/Fl_File_Chooser.H2
-rw-r--r--src/Fl_File_Chooser.cxx12
-rw-r--r--src/Fl_File_Chooser2.cxx22
3 files changed, 20 insertions, 16 deletions
diff --git a/FL/Fl_File_Chooser.H b/FL/Fl_File_Chooser.H
index 060ee13c7..6808c25b1 100644
--- a/FL/Fl_File_Chooser.H
+++ b/FL/Fl_File_Chooser.H
@@ -49,7 +49,7 @@ class FL_EXPORT Fl_File_Chooser {
public:
enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };
private:
- static Fl_Preferences prefs_;
+ static Fl_Preferences *prefs_;
void (*callback_)(Fl_File_Chooser*, void *);
void *data_;
char directory_[FL_PATH_MAX];
diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx
index a51c5c883..c5288e92a 100644
--- a/src/Fl_File_Chooser.cxx
+++ b/src/Fl_File_Chooser.cxx
@@ -27,6 +27,7 @@
#include "../FL/Fl_File_Chooser.H"
#include <FL/fl_draw.H>
+#include <FL/Fl_Bitmap.H>
void Fl_File_Chooser::cb_window_i(Fl_Double_Window*, void*) {
fileName->value("");
@@ -59,11 +60,9 @@ void Fl_File_Chooser::cb_newButton(Fl_Button* o, void* v) {
((Fl_File_Chooser*)(o->parent()->parent()->user_data()))->cb_newButton_i(o,v);
}
-#include <FL/Fl_Bitmap.H>
static const unsigned char idata_new[] =
{0,0,120,0,132,0,2,1,1,254,1,128,49,128,49,128,253,128,253,128,49,128,49,
128,1,128,1,128,255,255,0,0};
-static Fl_Bitmap image_new(idata_new, 16, 16);
void Fl_File_Chooser::cb__i(Fl_Tile*, void*) {
update_preview();
@@ -164,6 +163,11 @@ void Fl_File_Chooser::cb_favOkButton(Fl_Return_Button* o, void* v) {
}
Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char *title) {
+ static Fl_Bitmap *image_new = NULL;
+ if (!image_new) {
+ prefs_ = new Fl_Preferences(Fl_Preferences::USER, "fltk.org", "filechooser");
+ image_new = new Fl_Bitmap(idata_new, 16, 16);
+ }
Fl_Group *prev_current = Fl_Group::current();
{ window = new Fl_Double_Window(490, 380, "Choose File");
window->callback((Fl_Callback*)cb_window, (void*)(this));
@@ -305,7 +309,7 @@ Fl_File_Chooser::Fl_File_Chooser(const char *d, const char *p, int t, const char
value(d);
type(t);
int e;
- prefs_.get("preview", e, 1);
+ prefs_->get("preview", e, 1);
preview(e);
Fl_Group::current(prev_current);
ext_group=(Fl_Widget*)0;
@@ -369,7 +373,7 @@ const char * Fl_File_Chooser::label() {
}
void Fl_File_Chooser::ok_label(const char *l) {
- okButton->label(l);
+ if (l) okButton->label(l);
int w=0, h=0;
okButton->measure_label(w, h);
okButton->resize(cancelButton->x() - 50 - w, cancelButton->y(),
diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx
index e186c140b..6527a77dd 100644
--- a/src/Fl_File_Chooser2.cxx
+++ b/src/Fl_File_Chooser2.cxx
@@ -379,7 +379,7 @@
// File chooser label strings and sort function...
//
-Fl_Preferences Fl_File_Chooser::prefs_(Fl_Preferences::USER, "fltk.org", "filechooser");
+Fl_Preferences* Fl_File_Chooser::prefs_ = NULL;
const char *Fl_File_Chooser::add_favorites_label = "Add to Favorites";
const char *Fl_File_Chooser::all_files_label = "All Files (*)";
@@ -546,8 +546,8 @@ Fl_File_Chooser::favoritesButtonCB()
sprintf(menuname, "favorite%02d", v);
- prefs_.set(menuname, directory_);
- prefs_.flush();
+ prefs_->set(menuname, directory_);
+ prefs_->flush();
quote_pathname(menuname, directory_, sizeof(menuname));
favoritesButton->add(menuname);
@@ -590,7 +590,7 @@ Fl_File_Chooser::favoritesCB(Fl_Widget *w)
// Get favorite directory 0 to 99...
sprintf(name, "favorite%02d", i);
- prefs_.get(name, pathname, "", sizeof(pathname));
+ prefs_->get(name, pathname, "", sizeof(pathname));
// Stop on the first empty favorite...
if (!pathname[0]) break;
@@ -669,7 +669,7 @@ Fl_File_Chooser::favoritesCB(Fl_Widget *w)
// Set favorite directory 0 to 99...
sprintf(name, "favorite%02d", i);
- prefs_.set(name, favList->text(i + 1));
+ prefs_->set(name, favList->text(i + 1));
}
// Clear old entries as necessary...
@@ -677,14 +677,14 @@ Fl_File_Chooser::favoritesCB(Fl_Widget *w)
// Clear favorite directory 0 to 99...
sprintf(name, "favorite%02d", i);
- prefs_.get(name, pathname, "", sizeof(pathname));
+ prefs_->get(name, pathname, "", sizeof(pathname));
- if (pathname[0]) prefs_.set(name, "");
+ if (pathname[0]) prefs_->set(name, "");
else break;
}
update_favorites();
- prefs_.flush();
+ prefs_->flush();
favWindow->hide();
}
@@ -1097,8 +1097,8 @@ Fl_File_Chooser::newdir()
void Fl_File_Chooser::preview(int e)
{
previewButton->value(e);
- prefs_.set("preview", e);
- prefs_.flush();
+ prefs_->set("preview", e);
+ prefs_->flush();
Fl_Group *p = previewBox->parent();
if (e) {
@@ -1283,7 +1283,7 @@ Fl_File_Chooser::update_favorites()
for (i = 0; i < 100; i ++) {
sprintf(menuname, "favorite%02d", i);
- prefs_.get(menuname, pathname, "", sizeof(pathname));
+ prefs_->get(menuname, pathname, "", sizeof(pathname));
if (!pathname[0]) break;
quote_pathname(menuname, pathname, sizeof(menuname));