2001-03-07 14:25:31 +00:00
|
|
|
/**
|
|
|
|
* \file FormFiledialog.C
|
|
|
|
* Read the file COPYING
|
1999-10-02 16:21:10 +00:00
|
|
|
*
|
2001-03-07 14:25:31 +00:00
|
|
|
* \author unknown
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-07 14:25:31 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <unistd.h>
|
1999-10-02 16:21:10 +00:00
|
|
|
#include <cstdlib>
|
1999-09-27 18:44:28 +00:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <grp.h>
|
1999-11-22 16:19:48 +00:00
|
|
|
#include <map>
|
2002-07-17 19:22:51 +00:00
|
|
|
#include <algorithm>
|
2000-09-14 17:53:12 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
using std::map;
|
2000-11-14 13:46:01 +00:00
|
|
|
using std::max;
|
1999-11-22 16:19:48 +00:00
|
|
|
using std::sort;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-11-26 10:19:58 +00:00
|
|
|
#include "frontends/Alert.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/FileInfo.h"
|
2000-11-08 09:39:46 +00:00
|
|
|
#include "support/lyxlib.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
#include "support/lstrings.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "gettext.h"
|
2000-11-28 06:46:06 +00:00
|
|
|
#include "frontends/Dialogs.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms_gettext.h"
|
2002-01-13 15:01:25 +00:00
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
#include <boost/bind.hpp>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
//#ifdef HAVE_ERRNO_H
|
|
|
|
//#include <cerrno>
|
|
|
|
//#endif
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#if HAVE_DIRENT_H
|
|
|
|
# include <dirent.h>
|
|
|
|
#else
|
|
|
|
# define dirent direct
|
|
|
|
# if HAVE_SYS_NDIR_H
|
|
|
|
# include <sys/ndir.h>
|
|
|
|
# endif
|
|
|
|
# if HAVE_SYS_DIR_H
|
|
|
|
# include <sys/dir.h>
|
|
|
|
# endif
|
|
|
|
# if HAVE_NDIR_H
|
|
|
|
# include <ndir.h>
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "support/filetools.h"
|
2001-03-07 14:25:31 +00:00
|
|
|
#include "FormFiledialog.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
#include "forms/form_filedialog.h"
|
|
|
|
#include FORMS_H_LOCATION
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
namespace {
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
// six months, in seconds
|
2001-03-20 01:22:46 +00:00
|
|
|
long const SIX_MONTH_SEC = 6L * 30L * 24L * 60L * 60L;
|
|
|
|
//static
|
|
|
|
long const ONE_HOUR_SEC = 60L * 60L;
|
|
|
|
|
2001-09-09 22:02:19 +00:00
|
|
|
extern "C" {
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-09 22:02:19 +00:00
|
|
|
static
|
|
|
|
int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev)
|
|
|
|
{
|
|
|
|
return FileDialog::Private::CancelCB(fl, xev);
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-09-09 22:02:19 +00:00
|
|
|
static
|
|
|
|
void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data)
|
|
|
|
{
|
|
|
|
FileDialog::Private::DoubleClickCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static
|
|
|
|
void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data)
|
|
|
|
{
|
|
|
|
FileDialog::Private::FileDlgCB(ob, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// *** User cache class implementation
|
1999-11-22 16:19:48 +00:00
|
|
|
/// User cache class definition
|
|
|
|
class UserCache {
|
|
|
|
public:
|
|
|
|
/// seeks user name from group ID
|
|
|
|
string const & find(uid_t ID) const {
|
2000-11-21 23:05:19 +00:00
|
|
|
Users::const_iterator cit = users.find(ID);
|
1999-11-22 16:19:48 +00:00
|
|
|
if (cit == users.end()) {
|
|
|
|
add(ID);
|
|
|
|
return users[ID];
|
|
|
|
}
|
2001-07-12 11:11:10 +00:00
|
|
|
return cit->second;
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void add(uid_t ID) const;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
|
|
|
typedef map<uid_t, string> Users;
|
|
|
|
///
|
|
|
|
mutable Users users;
|
|
|
|
};
|
|
|
|
|
2000-11-15 03:22:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
void UserCache::add(uid_t ID) const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
struct passwd const * entry = getpwuid(ID);
|
|
|
|
users[ID] = entry ? entry->pw_name : tostr(ID);
|
2002-03-21 21:21:28 +00:00
|
|
|
}
|
2000-04-04 00:19:15 +00:00
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
|
|
/// Group cache class definition
|
|
|
|
class GroupCache {
|
|
|
|
public:
|
|
|
|
/// seeks group name from group ID
|
2000-10-12 10:46:06 +00:00
|
|
|
string const & find(gid_t ID) const ;
|
1999-11-22 16:19:48 +00:00
|
|
|
private:
|
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
void add(gid_t ID) const;
|
1999-11-22 16:19:48 +00:00
|
|
|
///
|
|
|
|
typedef map<gid_t, string> Groups;
|
|
|
|
///
|
|
|
|
mutable Groups groups;
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2000-11-15 03:22:08 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
string const & GroupCache::find(gid_t ID) const
|
2000-11-15 03:22:08 +00:00
|
|
|
{
|
2000-11-21 23:05:19 +00:00
|
|
|
Groups::const_iterator cit = groups.find(ID);
|
2000-11-15 03:22:08 +00:00
|
|
|
if (cit == groups.end()) {
|
|
|
|
add(ID);
|
|
|
|
return groups[ID];
|
2000-10-12 10:46:06 +00:00
|
|
|
}
|
2001-07-12 11:11:10 +00:00
|
|
|
return cit->second;
|
2000-11-15 03:22:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
void GroupCache::add(gid_t ID) const
|
2000-04-04 00:19:15 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
struct group const * entry = getgrgid(ID);
|
|
|
|
groups[ID] = entry ? entry->gr_name : tostr(ID);
|
2000-04-04 00:19:15 +00:00
|
|
|
}
|
2000-11-15 03:22:08 +00:00
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
// local instances
|
|
|
|
UserCache lyxUserCache;
|
|
|
|
GroupCache lyxGroupCache;
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
// compares two LyXDirEntry objects content (used for sort)
|
|
|
|
class comp_direntry {
|
|
|
|
public:
|
2002-07-16 08:31:21 +00:00
|
|
|
bool operator()(DirEntry const & r1, DirEntry const & r2) const
|
|
|
|
{
|
|
|
|
bool const r1d = suffixIs(r1.name_, '/');
|
|
|
|
bool const r2d = suffixIs(r2.name_, '/');
|
|
|
|
if (r1d && !r2d)
|
|
|
|
return true;
|
|
|
|
if (!r1d && r2d)
|
|
|
|
return false;
|
|
|
|
return r1.name_ < r2.name_;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-07-16 08:31:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-25 14:18:30 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
// *** FileDialog::Private class implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// static members
|
2002-07-16 08:31:21 +00:00
|
|
|
FD_filedialog * FileDialog::Private::file_dlg_form_ = 0;
|
|
|
|
FileDialog::Private * FileDialog::Private::current_dlg_ = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Reread: updates dialog list to match class directory
|
2001-03-07 14:25:31 +00:00
|
|
|
void FileDialog::Private::Reread()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// Opens directory
|
2002-07-16 08:31:21 +00:00
|
|
|
DIR * dir = ::opendir(directory_.c_str());
|
|
|
|
if (!dir) {
|
2001-11-26 10:19:58 +00:00
|
|
|
Alert::err_alert(_("Warning! Couldn't open directory."),
|
2002-07-16 13:00:12 +00:00
|
|
|
directory_);
|
2002-07-16 08:31:21 +00:00
|
|
|
directory_ = lyx::getcwd();
|
|
|
|
dir = ::opendir(directory_.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the present namelist
|
2002-07-16 08:31:21 +00:00
|
|
|
dir_entries_.clear();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Updates display
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_hide_object(file_dlg_form_->List);
|
|
|
|
fl_clear_browser(file_dlg_form_->List);
|
|
|
|
fl_set_input(file_dlg_form_->DirBox, directory_.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Splits complete directory name into directories and compute depth
|
2002-07-16 08:31:21 +00:00
|
|
|
depth_ = 0;
|
1999-10-02 16:21:10 +00:00
|
|
|
string line, Temp;
|
2002-07-16 13:00:12 +00:00
|
|
|
string mode;
|
2002-07-16 08:31:21 +00:00
|
|
|
string File = directory_;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (File != "/") {
|
1999-10-02 16:21:10 +00:00
|
|
|
File = split(File, Temp, '/');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
while (!File.empty() || !Temp.empty()) {
|
2002-07-16 13:00:12 +00:00
|
|
|
string dline = "@b" + line + Temp + '/';
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_add_browser_line(file_dlg_form_->List, dline.c_str());
|
1999-10-02 16:21:10 +00:00
|
|
|
File = split(File, Temp, '/');
|
1999-09-27 18:44:28 +00:00
|
|
|
line += ' ';
|
2002-07-16 08:31:21 +00:00
|
|
|
++depth_;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parses all entries of the given subdirectory
|
1999-10-02 16:21:10 +00:00
|
|
|
time_t curTime = time(0);
|
2002-07-16 08:31:21 +00:00
|
|
|
rewinddir(dir);
|
2002-07-16 13:00:12 +00:00
|
|
|
while (dirent * entry = readdir(dir)) {
|
1999-09-27 18:44:28 +00:00
|
|
|
bool isLink = false, isDir = false;
|
|
|
|
|
|
|
|
// If the pattern doesn't start with a dot, skip hidden files
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!mask_.empty() && mask_[0] != '.' &&
|
2002-07-16 13:00:12 +00:00
|
|
|
entry->d_name[0] == '.')
|
2002-03-21 21:21:28 +00:00
|
|
|
continue;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Gets filename
|
2002-07-16 13:00:12 +00:00
|
|
|
string fname = entry->d_name;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Under all circumstances, "." and ".." are not wanted
|
|
|
|
if (fname == "." || fname == "..")
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// gets file status
|
2002-07-16 08:31:21 +00:00
|
|
|
File = AddName(directory_, fname);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-01-07 10:17:44 +00:00
|
|
|
FileInfo fileInfo(File, true);
|
2002-01-13 23:00:15 +00:00
|
|
|
|
|
|
|
// can this really happen?
|
|
|
|
if (!fileInfo.isOK())
|
|
|
|
continue;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-07-16 13:00:12 +00:00
|
|
|
mode = fileInfo.modeString();
|
|
|
|
unsigned int const nlink = fileInfo.getNumberOfLinks();
|
|
|
|
string const user = lyxUserCache.find(fileInfo.getUid());
|
|
|
|
string const group = lyxGroupCache.find(fileInfo.getGid());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
time_t modtime = fileInfo.getModificationTime();
|
1999-11-22 16:19:48 +00:00
|
|
|
string Time = ctime(&modtime);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-07 17:57:21 +00:00
|
|
|
if (curTime > modtime + SIX_MONTH_SEC
|
|
|
|
|| curTime < modtime + ONE_HOUR_SEC) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// The file is fairly old or in the future. POSIX says
|
|
|
|
// the cutoff is 6 months old. Allow a 1 hour slop
|
|
|
|
// factor for what is considered "the future", to
|
|
|
|
// allow for NFS server/client clock disagreement.
|
|
|
|
// Show the year instead of the time of day.
|
1999-10-02 16:21:10 +00:00
|
|
|
Time.erase(10, 9);
|
1999-10-07 18:44:17 +00:00
|
|
|
Time.erase(15, string::npos);
|
|
|
|
} else {
|
|
|
|
Time.erase(16, string::npos);
|
1999-10-02 16:21:10 +00:00
|
|
|
}
|
|
|
|
|
2002-07-16 13:00:12 +00:00
|
|
|
string buffer = mode + ' ' +
|
1999-10-07 18:44:17 +00:00
|
|
|
tostr(nlink) + ' ' +
|
1999-10-02 16:21:10 +00:00
|
|
|
user + ' ' +
|
|
|
|
group + ' ' +
|
|
|
|
Time.substr(4, string::npos) + ' ';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 13:00:12 +00:00
|
|
|
buffer += entry->d_name;
|
|
|
|
buffer += fileInfo.typeIndicator();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 13:00:12 +00:00
|
|
|
isLink = fileInfo.isLink();
|
|
|
|
if (isLink) {
|
1999-11-22 16:19:48 +00:00
|
|
|
string Link;
|
|
|
|
|
|
|
|
if (LyXReadLink(File, Link)) {
|
2002-07-16 13:00:12 +00:00
|
|
|
buffer += " -> ";
|
|
|
|
buffer += Link;
|
1999-11-22 16:19:48 +00:00
|
|
|
|
|
|
|
// This gives the FileType of the file that
|
|
|
|
// is really pointed too after resolving all
|
|
|
|
// symlinks. This is not necessarily the same
|
|
|
|
// as the type of Link (which could again be a
|
|
|
|
// link). Is that intended?
|
|
|
|
// JV 199902
|
|
|
|
fileInfo.newFile(File);
|
2002-01-13 23:00:15 +00:00
|
|
|
if (fileInfo.isOK())
|
2002-07-16 13:00:12 +00:00
|
|
|
buffer += fileInfo.typeIndicator();
|
2002-01-13 23:00:15 +00:00
|
|
|
else
|
|
|
|
continue;
|
1999-11-22 16:19:48 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// filters files according to pattern and type
|
|
|
|
if (fileInfo.isRegular()
|
|
|
|
|| fileInfo.isChar()
|
|
|
|
|| fileInfo.isBlock()
|
|
|
|
|| fileInfo.isFifo()) {
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!regexMatch(fname, mask_))
|
1999-09-27 18:44:28 +00:00
|
|
|
continue;
|
|
|
|
} else if (!(isDir = fileInfo.isDir()))
|
|
|
|
continue;
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
DirEntry tmp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
// Note ls_entry_ is an string!
|
2002-07-16 13:00:12 +00:00
|
|
|
tmp.ls_entry_ = buffer;
|
1999-09-27 18:44:28 +00:00
|
|
|
// creates used name
|
1999-10-02 16:21:10 +00:00
|
|
|
string temp = fname;
|
2002-07-16 14:13:11 +00:00
|
|
|
if (isDir)
|
|
|
|
temp += '/';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
tmp.name_ = temp;
|
1999-09-27 18:44:28 +00:00
|
|
|
// creates displayed name
|
2002-07-16 13:00:12 +00:00
|
|
|
temp = entry->d_name;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (isLink)
|
|
|
|
temp += '@';
|
|
|
|
else
|
|
|
|
temp += fileInfo.typeIndicator();
|
2002-07-16 08:31:21 +00:00
|
|
|
tmp.displayed_ = temp;
|
1999-11-22 16:19:48 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
dir_entries_.push_back(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
closedir(dir);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// Sort the names
|
2002-07-16 08:31:21 +00:00
|
|
|
sort(dir_entries_.begin(), dir_entries_.end(), comp_direntry());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Add them to directory box
|
2002-07-16 08:31:21 +00:00
|
|
|
for (DirEntries::const_iterator cit = dir_entries_.begin();
|
|
|
|
cit != dir_entries_.end(); ++cit) {
|
|
|
|
string const temp = line + cit->displayed_;
|
|
|
|
fl_add_browser_line(file_dlg_form_->List, temp.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_browser_topline(file_dlg_form_->List, depth_);
|
|
|
|
fl_show_object(file_dlg_form_->List);
|
|
|
|
last_sel_ = -1;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetDirectory: sets dialog current directory
|
2002-07-16 08:31:21 +00:00
|
|
|
void FileDialog::Private::SetDirectory(string const & path)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-11-12 16:12:48 +00:00
|
|
|
string tmp;
|
2002-07-16 08:31:21 +00:00
|
|
|
if (path.empty())
|
2002-01-10 10:05:45 +00:00
|
|
|
tmp = lyx::getcwd();
|
|
|
|
else
|
2002-07-16 08:31:21 +00:00
|
|
|
tmp = MakeAbsPath(ExpandPath(path), directory_);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-11-12 16:12:48 +00:00
|
|
|
// must check the directory exists
|
2002-07-16 08:31:21 +00:00
|
|
|
DIR * dir = ::opendir(tmp.c_str());
|
|
|
|
if (!dir) {
|
2001-11-26 10:19:58 +00:00
|
|
|
Alert::err_alert(_("Warning! Couldn't open directory."), tmp);
|
2001-11-12 16:12:48 +00:00
|
|
|
} else {
|
2002-07-16 08:31:21 +00:00
|
|
|
::closedir(dir);
|
|
|
|
directory_ = tmp;
|
2001-11-12 16:12:48 +00:00
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetMask: sets dialog file mask
|
2002-07-16 08:31:21 +00:00
|
|
|
void FileDialog::Private::SetMask(string const & newmask)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
mask_ = newmask;
|
|
|
|
fl_set_input(file_dlg_form_->PatBox, mask_.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetInfoLine: sets dialog information line
|
2002-07-16 08:31:21 +00:00
|
|
|
void FileDialog::Private::SetInfoLine(string const & line)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
info_line_ = line;
|
|
|
|
fl_set_object_label(file_dlg_form_->FileInfo, info_line_.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-02 19:23:10 +00:00
|
|
|
FileDialog::Private::Private(Dialogs & dia)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
directory_ = MakeAbsPath(string("."));
|
|
|
|
mask_ = '*';
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
// Creates form if necessary.
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!file_dlg_form_) {
|
|
|
|
file_dlg_form_ = build_filedialog(this);
|
1999-09-27 18:44:28 +00:00
|
|
|
// Set callbacks. This means that we don't need a patch file
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->DirBox,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 0);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->PatBox,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 1);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->List,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 2);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->Filename,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 3);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->Rescan,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 10);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->Home,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 11);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->User1,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 12);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_object_callback(file_dlg_form_->User2,
|
1999-11-15 12:01:38 +00:00
|
|
|
C_LyXFileDlg_FileDlgCB, 13);
|
2002-03-11 18:24:31 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Make sure pressing the close box doesn't crash LyX. (RvdK)
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_form_atclose(file_dlg_form_->form,
|
1999-10-25 14:18:30 +00:00
|
|
|
C_LyXFileDlg_CancelCB, 0);
|
2002-03-21 21:21:28 +00:00
|
|
|
// Register doubleclick callback
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_browser_dblclick_callback(file_dlg_form_->List,
|
1999-11-22 16:19:48 +00:00
|
|
|
C_LyXFileDlg_DoubleClickCB,
|
|
|
|
0);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_hide_object(file_dlg_form_->User1);
|
|
|
|
fl_hide_object(file_dlg_form_->User2);
|
2000-11-28 06:46:06 +00:00
|
|
|
|
2002-08-15 17:48:53 +00:00
|
|
|
r_ = dia.redrawGUI().connect(boost::bind(&FileDialog::Private::redraw, this));
|
2000-11-28 06:46:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
FileDialog::Private::~Private()
|
2000-11-28 06:46:06 +00:00
|
|
|
{
|
|
|
|
r_.disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-07 14:25:31 +00:00
|
|
|
void FileDialog::Private::redraw()
|
2000-11-28 06:46:06 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
if (file_dlg_form_->form && file_dlg_form_->form->visible)
|
|
|
|
fl_redraw_form(file_dlg_form_->form);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SetButton: sets file selector user button action
|
2002-07-16 14:13:11 +00:00
|
|
|
void FileDialog::Private::SetButton(int index, string const & name,
|
|
|
|
string const & path)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
FL_OBJECT * ob;
|
2002-07-16 14:13:11 +00:00
|
|
|
string * tmp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 14:13:11 +00:00
|
|
|
if (index == 0) {
|
2002-07-16 08:31:21 +00:00
|
|
|
ob = file_dlg_form_->User1;
|
2002-07-16 14:13:11 +00:00
|
|
|
tmp = &user_path1_;
|
|
|
|
} else if (index == 1) {
|
2002-07-16 08:31:21 +00:00
|
|
|
ob = file_dlg_form_->User2;
|
2002-07-16 14:13:11 +00:00
|
|
|
tmp = &user_path2_;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 14:13:11 +00:00
|
|
|
if (!name.empty()) {
|
|
|
|
fl_set_object_label(ob, idex(name.c_str()));
|
|
|
|
fl_set_button_shortcut(ob, scex(name.c_str()), 1);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_show_object(ob);
|
2002-07-16 14:13:11 +00:00
|
|
|
*tmp = path;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_hide_object(ob);
|
2002-07-16 14:13:11 +00:00
|
|
|
tmp->erase();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// GetDirectory: gets last dialog directory
|
2001-03-07 14:25:31 +00:00
|
|
|
string const FileDialog::Private::GetDirectory() const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!directory_.empty())
|
|
|
|
return directory_;
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
1999-10-02 16:21:10 +00:00
|
|
|
return string(".");
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2002-02-28 14:36:23 +00:00
|
|
|
namespace {
|
2002-03-21 21:21:28 +00:00
|
|
|
bool x_sync_kludge(bool ret)
|
2002-02-28 14:36:23 +00:00
|
|
|
{
|
|
|
|
XSync(fl_get_display(), false);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
} // namespace anon
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// RunDialog: handle dialog during file selection
|
2001-03-07 14:25:31 +00:00
|
|
|
bool FileDialog::Private::RunDialog()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
force_cancel_ = false;
|
|
|
|
force_ok_ = false;
|
2002-02-28 14:36:23 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
// event loop
|
|
|
|
while (true) {
|
2002-07-16 08:31:21 +00:00
|
|
|
FL_OBJECT * ob = fl_do_forms();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
if (ob == file_dlg_form_->Ready) {
|
1999-09-27 18:44:28 +00:00
|
|
|
if (HandleOK())
|
2002-02-28 14:36:23 +00:00
|
|
|
return x_sync_kludge(true);
|
|
|
|
|
2002-07-16 14:13:11 +00:00
|
|
|
} else if (ob == file_dlg_form_->Cancel || force_cancel_)
|
2002-02-28 14:36:23 +00:00
|
|
|
return x_sync_kludge(false);
|
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
else if (force_ok_)
|
2002-02-28 14:36:23 +00:00
|
|
|
return x_sync_kludge(true);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// XForms objects callback (static)
|
2002-07-16 08:31:21 +00:00
|
|
|
void FileDialog::Private::FileDlgCB(FL_OBJECT *, long arg)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!current_dlg_)
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
switch (arg) {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
case 0: // get directory
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetDirectory(fl_get_input(file_dlg_form_->DirBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // get mask
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // list
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->HandleListHit();
|
2002-03-21 21:21:28 +00:00
|
|
|
break;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
case 10: // rescan
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetDirectory(fl_get_input(file_dlg_form_->DirBox));
|
|
|
|
current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 11: // home
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetDirectory(GetEnvPath("HOME"));
|
|
|
|
current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 12: // user button 1
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetDirectory(current_dlg_->user_path1_);
|
|
|
|
current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 13: // user button 2
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->SetDirectory(current_dlg_->user_path2_);
|
|
|
|
current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
|
|
|
|
current_dlg_->Reread();
|
1999-09-27 18:44:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-19 19:46:23 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Handle callback from list
|
2001-03-07 14:25:31 +00:00
|
|
|
void FileDialog::Private::HandleListHit()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// set info line
|
2002-07-16 08:31:21 +00:00
|
|
|
int const select_ = fl_get_browser(file_dlg_form_->List);
|
|
|
|
if (select_ > depth_)
|
|
|
|
SetInfoLine(dir_entries_[select_ - depth_ - 1].ls_entry_);
|
|
|
|
else
|
1999-10-02 16:21:10 +00:00
|
|
|
SetInfoLine(string());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Callback for double click in list
|
2001-03-07 14:25:31 +00:00
|
|
|
void FileDialog::Private::DoubleClickCB(FL_OBJECT *, long)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
// Simulate click on OK button
|
|
|
|
if (current_dlg_->HandleDoubleClick())
|
|
|
|
current_dlg_->Force(false);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
2000-11-15 03:22:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Handle double click from list
|
2001-03-07 14:25:31 +00:00
|
|
|
bool FileDialog::Private::HandleDoubleClick()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-07-16 08:31:21 +00:00
|
|
|
string tmp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// set info line
|
1999-11-22 16:19:48 +00:00
|
|
|
bool isDir = true;
|
2002-07-16 08:31:21 +00:00
|
|
|
int const select_ = fl_get_browser(file_dlg_form_->List);
|
2002-07-16 14:13:11 +00:00
|
|
|
if (select_ > depth_) {
|
2002-07-16 08:31:21 +00:00
|
|
|
tmp = dir_entries_[select_ - depth_ - 1].name_;
|
|
|
|
SetInfoLine(dir_entries_[select_ - depth_ - 1].ls_entry_);
|
|
|
|
if (!suffixIs(tmp, '/')) {
|
1999-09-27 18:44:28 +00:00
|
|
|
isDir = false;
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_input(file_dlg_form_->Filename, tmp.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-07-16 08:31:21 +00:00
|
|
|
} else if (select_ != 0) {
|
1999-10-02 16:21:10 +00:00
|
|
|
SetInfoLine(string());
|
1999-09-27 18:44:28 +00:00
|
|
|
} else
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// executes action
|
|
|
|
if (isDir) {
|
1999-10-02 16:21:10 +00:00
|
|
|
string Temp;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// builds new directory name
|
2002-07-16 08:31:21 +00:00
|
|
|
if (select_ > depth_) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// Directory deeper down
|
|
|
|
// First, get directory with trailing /
|
2002-07-16 08:31:21 +00:00
|
|
|
Temp = fl_get_input(file_dlg_form_->DirBox);
|
1999-10-02 16:21:10 +00:00
|
|
|
if (!suffixIs(Temp, '/'))
|
1999-09-27 18:44:28 +00:00
|
|
|
Temp += '/';
|
2002-07-16 08:31:21 +00:00
|
|
|
Temp += tmp;
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
|
|
|
// Directory higher up
|
2000-05-04 10:57:00 +00:00
|
|
|
Temp.erase();
|
2002-07-16 08:31:21 +00:00
|
|
|
for (int i = 0; i < select_; ++i) {
|
|
|
|
string piece = fl_get_browser_line(file_dlg_form_->List, i+1);
|
1999-09-27 18:44:28 +00:00
|
|
|
// The '+2' is here to count the '@b' (JMarc)
|
1999-10-02 16:21:10 +00:00
|
|
|
Temp += piece.substr(i + 2);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// assigns it
|
|
|
|
SetDirectory(Temp);
|
|
|
|
Reread();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Handle OK button call
|
2001-03-07 14:25:31 +00:00
|
|
|
bool FileDialog::Private::HandleOK()
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// mask was changed
|
2002-07-16 08:31:21 +00:00
|
|
|
string tmp = fl_get_input(file_dlg_form_->PatBox);
|
|
|
|
if (tmp != mask_) {
|
|
|
|
SetMask(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
Reread();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// directory was changed
|
2002-07-16 08:31:21 +00:00
|
|
|
tmp = fl_get_input(file_dlg_form_->DirBox);
|
|
|
|
if (tmp != directory_) {
|
|
|
|
SetDirectory(tmp);
|
1999-09-27 18:44:28 +00:00
|
|
|
Reread();
|
|
|
|
return false;
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Handle return from list
|
2002-07-16 08:31:21 +00:00
|
|
|
int const select = fl_get_browser(file_dlg_form_->List);
|
|
|
|
if (select > depth_) {
|
|
|
|
string const temp = dir_entries_[select - depth_ - 1].name_;
|
1999-10-02 16:21:10 +00:00
|
|
|
if (!suffixIs(temp, '/')) {
|
1999-09-27 18:44:28 +00:00
|
|
|
// If user didn't type anything, use browser
|
2002-07-16 08:31:21 +00:00
|
|
|
string const name = fl_get_input(file_dlg_form_->Filename);
|
|
|
|
if (name.empty())
|
|
|
|
fl_set_input(file_dlg_form_->Filename, temp.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2000-11-14 13:46:01 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Emulate a doubleclick
|
|
|
|
return HandleDoubleClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Handle Cancel CB from WM close
|
2001-03-07 14:25:31 +00:00
|
|
|
int FileDialog::Private::CancelCB(FL_FORM *, void *)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// Simulate a click on the cancel button
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_->Force(true);
|
2002-03-21 21:21:28 +00:00
|
|
|
return FL_IGNORE;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
// Simulates a click on OK/Cancel
|
2001-03-07 14:25:31 +00:00
|
|
|
void FileDialog::Private::Force(bool cancel)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (cancel) {
|
2002-07-16 08:31:21 +00:00
|
|
|
force_cancel_ = true;
|
|
|
|
fl_set_button(file_dlg_form_->Cancel, 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
} else {
|
2002-07-16 08:31:21 +00:00
|
|
|
force_ok_ = true;
|
|
|
|
fl_set_button(file_dlg_form_->Ready, 1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
// Start timer to break fl_do_forms loop soon
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_timer(file_dlg_form_->timer, 0.1);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Select: launches dialog and returns selected file
|
2002-01-10 10:05:45 +00:00
|
|
|
string const FileDialog::Private::Select(string const & title,
|
|
|
|
string const & path,
|
|
|
|
string const & mask,
|
|
|
|
string const & suggested)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
// handles new mask and path
|
1999-11-22 16:19:48 +00:00
|
|
|
bool isOk = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (!mask.empty()) {
|
|
|
|
SetMask(mask);
|
|
|
|
isOk = false;
|
|
|
|
}
|
|
|
|
if (!path.empty()) {
|
|
|
|
SetDirectory(path);
|
|
|
|
isOk = false;
|
|
|
|
}
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!isOk)
|
|
|
|
Reread();
|
2000-11-14 13:46:01 +00:00
|
|
|
|
|
|
|
// highlight the suggested file in the browser, if it exists.
|
|
|
|
int sel = 0;
|
2000-11-15 03:22:08 +00:00
|
|
|
string const filename = OnlyFilename(suggested);
|
|
|
|
if (!filename.empty()) {
|
2002-07-16 08:31:21 +00:00
|
|
|
for (int i = 0; i < fl_get_browser_maxline(file_dlg_form_->List); ++i) {
|
|
|
|
string s = fl_get_browser_line(file_dlg_form_->List, i + 1);
|
2002-07-28 22:50:13 +00:00
|
|
|
s = trim(s);
|
2000-11-15 03:22:08 +00:00
|
|
|
if (s == filename) {
|
|
|
|
sel = i + 1;
|
2000-11-14 13:46:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-07-16 14:13:11 +00:00
|
|
|
if (sel != 0)
|
|
|
|
fl_select_browser_line(file_dlg_form_->List, sel);
|
2000-11-15 03:22:08 +00:00
|
|
|
int const top = max(sel - 5, 1);
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_browser_topline(file_dlg_form_->List, top);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// checks whether dialog can be started
|
2002-07-16 08:31:21 +00:00
|
|
|
if (current_dlg_)
|
|
|
|
return string();
|
|
|
|
current_dlg_ = this;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
// runs dialog
|
2000-11-15 03:22:08 +00:00
|
|
|
SetInfoLine(string());
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_set_input(file_dlg_form_->Filename, suggested.c_str());
|
|
|
|
fl_set_button(file_dlg_form_->Cancel, 0);
|
|
|
|
fl_set_button(file_dlg_form_->Ready, 0);
|
|
|
|
fl_set_focus_object(file_dlg_form_->form, file_dlg_form_->Filename);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_deactivate_all_forms();
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_show_form(file_dlg_form_->form,
|
2001-03-07 14:25:31 +00:00
|
|
|
FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
|
2000-11-08 09:39:46 +00:00
|
|
|
title.c_str());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
isOk = RunDialog();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
fl_hide_form(file_dlg_form_->form);
|
1999-09-27 18:44:28 +00:00
|
|
|
fl_activate_all_forms();
|
2002-07-16 08:31:21 +00:00
|
|
|
current_dlg_ = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
// Returns filename or string() if no valid selection was made
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!isOk || !fl_get_input(file_dlg_form_->Filename)[0])
|
|
|
|
return string();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
file_name_ = fl_get_input(file_dlg_form_->Filename);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-07-16 08:31:21 +00:00
|
|
|
if (!AbsolutePath(file_name_))
|
|
|
|
file_name_ = AddName(fl_get_input(file_dlg_form_->DirBox), file_name_);
|
|
|
|
return file_name_;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|