Add flag for displaying hidden files in the file dialog
Add wxFD_SHOW_HIDDEN and implement support for it for all the major ports. Closes https://github.com/wxWidgets/wxWidgets/pull/1413 Closes #9342.
This commit is contained in:
committed by
Vadim Zeitlin
parent
7e90def99a
commit
8748a476c3
@@ -48,7 +48,8 @@ enum
|
|||||||
wxFD_FILE_MUST_EXIST = 0x0010,
|
wxFD_FILE_MUST_EXIST = 0x0010,
|
||||||
wxFD_CHANGE_DIR = 0x0080,
|
wxFD_CHANGE_DIR = 0x0080,
|
||||||
wxFD_PREVIEW = 0x0100,
|
wxFD_PREVIEW = 0x0100,
|
||||||
wxFD_MULTIPLE = 0x0200
|
wxFD_MULTIPLE = 0x0200,
|
||||||
|
wxFD_SHOW_HIDDEN = 0x0400
|
||||||
};
|
};
|
||||||
|
|
||||||
#define wxFD_DEFAULT_STYLE wxFD_OPEN
|
#define wxFD_DEFAULT_STYLE wxFD_OPEN
|
||||||
|
@@ -413,5 +413,9 @@
|
|||||||
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef OFN_FORCESHOWHIDDEN
|
||||||
|
#define OFN_FORCESHOWHIDDEN 0x10000000
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_MISSING_H_
|
// _WX_MISSING_H_
|
||||||
|
@@ -14,7 +14,8 @@ enum
|
|||||||
wxFD_FILE_MUST_EXIST = 0x0010,
|
wxFD_FILE_MUST_EXIST = 0x0010,
|
||||||
wxFD_CHANGE_DIR = 0x0080,
|
wxFD_CHANGE_DIR = 0x0080,
|
||||||
wxFD_PREVIEW = 0x0100,
|
wxFD_PREVIEW = 0x0100,
|
||||||
wxFD_MULTIPLE = 0x0200
|
wxFD_MULTIPLE = 0x0200,
|
||||||
|
wxFD_SHOW_HIDDEN = 0x0400
|
||||||
};
|
};
|
||||||
|
|
||||||
#define wxFD_DEFAULT_STYLE wxFD_OPEN
|
#define wxFD_DEFAULT_STYLE wxFD_OPEN
|
||||||
@@ -141,6 +142,8 @@ const char wxFileSelectorDefaultWildcardStr[];
|
|||||||
@style{wxFD_PREVIEW}
|
@style{wxFD_PREVIEW}
|
||||||
Show the preview of the selected files (currently only supported by
|
Show the preview of the selected files (currently only supported by
|
||||||
wxGTK).
|
wxGTK).
|
||||||
|
@style{wxFD_SHOW_HIDDEN}
|
||||||
|
Show hidden files. This flag was added in wxWidgets 3.1.3
|
||||||
@endStyleTable
|
@endStyleTable
|
||||||
|
|
||||||
@library{wxcore}
|
@library{wxcore}
|
||||||
|
@@ -1616,7 +1616,7 @@ void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) )
|
|||||||
wxFileSelectorDefaultWildcardStr,
|
wxFileSelectorDefaultWildcardStr,
|
||||||
wxFileSelectorDefaultWildcardStr
|
wxFileSelectorDefaultWildcardStr
|
||||||
),
|
),
|
||||||
wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW|wxFD_NO_FOLLOW,
|
wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW|wxFD_NO_FOLLOW|wxFD_SHOW_HIDDEN,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -151,6 +151,21 @@ static void gtk_filedialog_update_preview_callback(GtkFileChooser *chooser,
|
|||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
static gboolean gtk_frame_map_callback( GtkFileChooser *file_chooser,
|
||||||
|
GdkEvent * WXUNUSED(event),
|
||||||
|
wxFileDialog *dlg )
|
||||||
|
{
|
||||||
|
/* if ( dlg->GetWindowStyle() & wxFD_SHOW_HIDDEN )
|
||||||
|
gtk_file_chooser_set_show_hidden( file_chooser, TRUE );
|
||||||
|
else
|
||||||
|
gtk_file_chooser_set_show_hidden( file_chooser, FALSE );*/
|
||||||
|
gtk_file_chooser_set_show_hidden(file_chooser, dlg->HasFlag(wxFD_SHOW_HIDDEN));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxFileDialog::AddChildGTK(wxWindowGTK* child)
|
void wxFileDialog::AddChildGTK(wxWindowGTK* child)
|
||||||
{
|
{
|
||||||
// allow dialog to be resized smaller horizontally
|
// allow dialog to be resized smaller horizontally
|
||||||
@@ -275,6 +290,8 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message,
|
|||||||
g_signal_connect (m_widget, "selection-changed",
|
g_signal_connect (m_widget, "selection-changed",
|
||||||
G_CALLBACK (gtk_filedialog_selchanged_callback), this);
|
G_CALLBACK (gtk_filedialog_selchanged_callback), this);
|
||||||
|
|
||||||
|
g_signal_connect (m_widget, "map_event",
|
||||||
|
G_CALLBACK (gtk_frame_map_callback), this);
|
||||||
// deal with extensions/filters
|
// deal with extensions/filters
|
||||||
SetWildcard(wildCard);
|
SetWildcard(wildCard);
|
||||||
|
|
||||||
|
@@ -443,6 +443,9 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if ( HasFdFlag(wxFD_FILE_MUST_EXIST) )
|
if ( HasFdFlag(wxFD_FILE_MUST_EXIST) )
|
||||||
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||||
|
|
||||||
|
if ( HasFlag(wxFD_SHOW_HIDDEN) )
|
||||||
|
msw_flags |= OFN_FORCESHOWHIDDEN;
|
||||||
/*
|
/*
|
||||||
If the window has been moved the programmer is probably
|
If the window has been moved the programmer is probably
|
||||||
trying to center or position it. Thus we set the callback
|
trying to center or position it. Thus we set the callback
|
||||||
|
@@ -340,6 +340,7 @@ void wxFileDialog::ShowWindowModal()
|
|||||||
modalForWindow: nativeParent modalDelegate: m_sheetDelegate
|
modalForWindow: nativeParent modalDelegate: m_sheetDelegate
|
||||||
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
||||||
contextInfo: nil];
|
contextInfo: nil];
|
||||||
|
[sPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -360,6 +361,7 @@ void wxFileDialog::ShowWindowModal()
|
|||||||
modalDelegate: m_sheetDelegate
|
modalDelegate: m_sheetDelegate
|
||||||
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
|
||||||
contextInfo: nil];
|
contextInfo: nil];
|
||||||
|
[oPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGCC_WARNING_RESTORE(deprecated-declarations)
|
wxGCC_WARNING_RESTORE(deprecated-declarations)
|
||||||
@@ -576,6 +578,7 @@ int wxFileDialog::ShowModal()
|
|||||||
[sPanel setCanSelectHiddenExtension:YES];
|
[sPanel setCanSelectHiddenExtension:YES];
|
||||||
[sPanel setAllowedFileTypes:types];
|
[sPanel setAllowedFileTypes:types];
|
||||||
[sPanel setAllowsOtherFileTypes:NO];
|
[sPanel setAllowsOtherFileTypes:NO];
|
||||||
|
[sPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||||
|
|
||||||
if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
|
if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
|
||||||
{
|
{
|
||||||
@@ -609,6 +612,7 @@ int wxFileDialog::ShowModal()
|
|||||||
[oPanel setCanChooseFiles:YES];
|
[oPanel setCanChooseFiles:YES];
|
||||||
[oPanel setMessage:cf.AsNSString()];
|
[oPanel setMessage:cf.AsNSString()];
|
||||||
[oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
|
[oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
|
||||||
|
[oPanel setShowsHiddenFiles: HasFlag(wxFD_SHOW_HIDDEN) ? YES : NO];
|
||||||
|
|
||||||
// Note that the test here is intentionally different from the one
|
// Note that the test here is intentionally different from the one
|
||||||
// above, in the wxFD_SAVE case: we need to call DoOnFilterSelected()
|
// above, in the wxFD_SAVE case: we need to call DoOnFilterSelected()
|
||||||
|
Reference in New Issue
Block a user