fixed subtle SetDirectory bug re-introduced by latest changes (explained in comment in UpdateDialog); reintroduced UpdateDialog so that fixes like this are kept in single place and affect all ways of setting the patch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30806 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,8 +43,11 @@ public:
|
|||||||
virtual void SetFilename(const wxString& name);
|
virtual void SetFilename(const wxString& name);
|
||||||
virtual void SetWildcard(const wxString& wildCard);
|
virtual void SetWildcard(const wxString& wildCard);
|
||||||
virtual void SetFilterIndex(int filterIndex);
|
virtual void SetFilterIndex(int filterIndex);
|
||||||
void UpdateFromDialog();
|
|
||||||
|
void UpdateFromDialog();
|
||||||
private:
|
private:
|
||||||
|
void UpdateDialog();
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxFileDialog)
|
DECLARE_DYNAMIC_CLASS(wxFileDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -43,8 +43,11 @@ public:
|
|||||||
virtual void SetFilename(const wxString& name);
|
virtual void SetFilename(const wxString& name);
|
||||||
virtual void SetWildcard(const wxString& wildCard);
|
virtual void SetWildcard(const wxString& wildCard);
|
||||||
virtual void SetFilterIndex(int filterIndex);
|
virtual void SetFilterIndex(int filterIndex);
|
||||||
void UpdateFromDialog();
|
|
||||||
|
void UpdateFromDialog();
|
||||||
private:
|
private:
|
||||||
|
void UpdateDialog();
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxFileDialog)
|
DECLARE_DYNAMIC_CLASS(wxFileDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -239,21 +239,7 @@ void wxFileDialog::SetPath(const wxString& path)
|
|||||||
m_path = fn.GetFullPath();
|
m_path = fn.GetFullPath();
|
||||||
m_dir = fn.GetPath();
|
m_dir = fn.GetPath();
|
||||||
m_fileName = fn.GetFullName();
|
m_fileName = fn.GetFullName();
|
||||||
|
UpdateDialog();
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_dir));
|
|
||||||
|
|
||||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_path));
|
|
||||||
|
|
||||||
// pre-fill the filename when saving, too (there's no text entry
|
|
||||||
// control when opening a file, so it doesn't make sense to
|
|
||||||
// do this in when opening files):
|
|
||||||
if (GetWindowStyle() & wxSAVE)
|
|
||||||
{
|
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_fileName));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDialog::SetDirectory(const wxString& dir)
|
void wxFileDialog::SetDirectory(const wxString& dir)
|
||||||
@@ -261,29 +247,56 @@ void wxFileDialog::SetDirectory(const wxString& dir)
|
|||||||
if (wxDirExists(dir))
|
if (wxDirExists(dir))
|
||||||
{
|
{
|
||||||
m_dir = dir;
|
m_dir = dir;
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
|
||||||
wxGTK_CONV(m_dir));
|
UpdateDialog();
|
||||||
wxFileName fn(m_dir,m_fileName);
|
|
||||||
m_path = fn.GetFullPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDialog::SetFilename(const wxString& name)
|
void wxFileDialog::SetFilename(const wxString& name)
|
||||||
{
|
{
|
||||||
m_fileName = name;
|
m_fileName = name;
|
||||||
wxFileName fn(m_dir,m_fileName);
|
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
|
||||||
m_path = fn.GetFullPath();
|
UpdateDialog();
|
||||||
|
}
|
||||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_path));
|
|
||||||
|
|
||||||
// pre-fill the filename when saving, too (there's no text entry
|
void wxFileDialog::UpdateDialog()
|
||||||
// control when opening a file, so it doesn't make sense to
|
{
|
||||||
// do this in when opening files):
|
// set currently selected directory to match the path:
|
||||||
if (GetWindowStyle() & wxSAVE)
|
if (!m_dir.empty() && wxDirExists(m_dir))
|
||||||
{
|
{
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
// NB: This is important -- if we set directory only and not the path,
|
||||||
|
// then dialog will still remember old path set using previous
|
||||||
|
// call to gtk_chooser_set_filename. If the previous directory
|
||||||
|
// was a subdirectory of the directory we want to select now,
|
||||||
|
// the dialog would still contain directory selector controls
|
||||||
|
// for the subdirectory (with the parent directory selected),
|
||||||
|
// instead of showing only the parent directory as expected.
|
||||||
|
// This way, we force GtkFileChooser to really change the
|
||||||
|
// directory. Finally, it doesn't have to be done if filename
|
||||||
|
// is not empty because of the code that sets the filename below.
|
||||||
|
if (m_fileName.empty())
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_dir));
|
||||||
|
|
||||||
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the user set only the directory (e.g. by calling SetDirectory)
|
||||||
|
// and not the default filename, then we don't want to set the filename:
|
||||||
|
if (!m_fileName.empty())
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_path));
|
||||||
|
|
||||||
|
// pre-fill the filename when saving, too (there's no text entry
|
||||||
|
// control when opening a file, so it doesn't make sense to
|
||||||
|
// do this when opening files):
|
||||||
|
if (GetWindowStyle() & wxSAVE)
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
||||||
wxGTK_CONV(m_fileName));
|
wxGTK_CONV(m_fileName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -239,21 +239,7 @@ void wxFileDialog::SetPath(const wxString& path)
|
|||||||
m_path = fn.GetFullPath();
|
m_path = fn.GetFullPath();
|
||||||
m_dir = fn.GetPath();
|
m_dir = fn.GetPath();
|
||||||
m_fileName = fn.GetFullName();
|
m_fileName = fn.GetFullName();
|
||||||
|
UpdateDialog();
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_dir));
|
|
||||||
|
|
||||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_path));
|
|
||||||
|
|
||||||
// pre-fill the filename when saving, too (there's no text entry
|
|
||||||
// control when opening a file, so it doesn't make sense to
|
|
||||||
// do this in when opening files):
|
|
||||||
if (GetWindowStyle() & wxSAVE)
|
|
||||||
{
|
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_fileName));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDialog::SetDirectory(const wxString& dir)
|
void wxFileDialog::SetDirectory(const wxString& dir)
|
||||||
@@ -261,29 +247,56 @@ void wxFileDialog::SetDirectory(const wxString& dir)
|
|||||||
if (wxDirExists(dir))
|
if (wxDirExists(dir))
|
||||||
{
|
{
|
||||||
m_dir = dir;
|
m_dir = dir;
|
||||||
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
|
||||||
wxGTK_CONV(m_dir));
|
UpdateDialog();
|
||||||
wxFileName fn(m_dir,m_fileName);
|
|
||||||
m_path = fn.GetFullPath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileDialog::SetFilename(const wxString& name)
|
void wxFileDialog::SetFilename(const wxString& name)
|
||||||
{
|
{
|
||||||
m_fileName = name;
|
m_fileName = name;
|
||||||
wxFileName fn(m_dir,m_fileName);
|
m_path = wxFileName(m_dir, m_fileName).GetFullPath();
|
||||||
m_path = fn.GetFullPath();
|
UpdateDialog();
|
||||||
|
}
|
||||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
|
||||||
wxGTK_CONV(m_path));
|
|
||||||
|
|
||||||
// pre-fill the filename when saving, too (there's no text entry
|
void wxFileDialog::UpdateDialog()
|
||||||
// control when opening a file, so it doesn't make sense to
|
{
|
||||||
// do this in when opening files):
|
// set currently selected directory to match the path:
|
||||||
if (GetWindowStyle() & wxSAVE)
|
if (!m_dir.empty() && wxDirExists(m_dir))
|
||||||
{
|
{
|
||||||
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
// NB: This is important -- if we set directory only and not the path,
|
||||||
|
// then dialog will still remember old path set using previous
|
||||||
|
// call to gtk_chooser_set_filename. If the previous directory
|
||||||
|
// was a subdirectory of the directory we want to select now,
|
||||||
|
// the dialog would still contain directory selector controls
|
||||||
|
// for the subdirectory (with the parent directory selected),
|
||||||
|
// instead of showing only the parent directory as expected.
|
||||||
|
// This way, we force GtkFileChooser to really change the
|
||||||
|
// directory. Finally, it doesn't have to be done if filename
|
||||||
|
// is not empty because of the code that sets the filename below.
|
||||||
|
if (m_fileName.empty())
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_dir));
|
||||||
|
|
||||||
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_dir));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the user set only the directory (e.g. by calling SetDirectory)
|
||||||
|
// and not the default filename, then we don't want to set the filename:
|
||||||
|
if (!m_fileName.empty())
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
|
||||||
|
wxGTK_CONV(m_path));
|
||||||
|
|
||||||
|
// pre-fill the filename when saving, too (there's no text entry
|
||||||
|
// control when opening a file, so it doesn't make sense to
|
||||||
|
// do this when opening files):
|
||||||
|
if (GetWindowStyle() & wxSAVE)
|
||||||
|
{
|
||||||
|
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(m_widget),
|
||||||
wxGTK_CONV(m_fileName));
|
wxGTK_CONV(m_fileName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user