picker controls improvements: fixes to valid paths recognition and event generation under GTK (patch 1510064)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-06-26 01:04:44 +00:00
parent 6be6127e66
commit 58772e4992
8 changed files with 146 additions and 57 deletions

View File

@@ -20,12 +20,10 @@
#if wxUSE_FILEPICKERCTRL && defined(__WXGTK26__)
#include "wx/filepicker.h"
#include "wx/tooltip.h"
#include <gtk/gtk.h>
#include <unistd.h> // chdir
// ============================================================================
@@ -129,6 +127,13 @@ void wxFileButton::OnDialogOK(wxCommandEvent& ev)
}
}
void wxFileButton::SetPath(const wxString &str)
{
m_path = str;
UpdateDialogPath(m_dialog);
}
#endif // wxUSE_FILEPICKERCTRL && defined(__WXGTK26__)
@@ -136,6 +141,8 @@ void wxFileButton::OnDialogOK(wxCommandEvent& ev)
#if wxUSE_DIRPICKERCTRL && defined(__WXGTK26__)
#include <unistd.h> // chdir
//-----------------------------------------------------------------------------
// "current-folder-changed"
//-----------------------------------------------------------------------------
@@ -145,6 +152,12 @@ static void gtk_dirbutton_currentfolderchanged_callback(GtkFileChooserButton *wi
wxDirButton *p)
{
// update the m_path member of the wxDirButtonGTK
// unless the path was changed by wxDirButton::SetPath()
if (p->m_bIgnoreNextChange)
{
p->m_bIgnoreNextChange=false;
return;
}
wxASSERT(p);
// NB: it's important to use gtk_file_chooser_get_filename instead of
@@ -202,6 +215,7 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
m_wildcard = wildcard;
if ((m_dialog = CreateDialog()) == NULL)
return false;
SetPath(path);
// little trick used to avoid problems when there are other GTK windows 'grabbed':
// GtkFileChooserDialog won't be responsive to user events if there is another
@@ -246,4 +260,18 @@ wxDirButton::~wxDirButton()
m_dialog->m_widget = NULL;
}
void wxDirButton::SetPath(const wxString &str)
{
m_path = str;
// wxDirButton uses the "current-folder-changed" signal which is triggered also
// when we set the path on the dialog associated with this button; thus we need
// to set the following flag to avoid sending a wxFileDirPickerEvent from this
// function (which would be inconsistent with wxFileButton's behaviour and in
// general with all wxWidgets control-manipulation functions which do not send events).
m_bIgnoreNextChange = true;
UpdateDialogPath(m_dialog);
}
#endif // wxUSE_DIRPICKERCTRL && defined(__WXGTK26__)