Update of /cvsroot/audacity/lib-src/FileDialog
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv26460
Modified Files:
FileDialog.cpp FileDialog.h
Log Message:
Standardize on the generic file dialog under GTK.
Index: FileDialog.h
===================================================================
RCS file: /cvsroot/audacity/lib-src/FileDialog/FileDialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FileDialog.h 9 Apr 2007 01:47:30 -0000 1.2
+++ FileDialog.h 10 Apr 2007 02:22:20 -0000 1.3
@@ -32,4 +32,35 @@
#include "generic/FileDialog.h"
#endif
+/////////////////////////////////////////////////////////////////////////////
+// Name: filedlg.h
+// Purpose: wxFileDialog base header
+// Author: Robert Roebling
+// Modified by: Leland Lucius
+// Created: 8/17/99
+// Copyright: (c) Robert Roebling
+// RCS-ID: $Id$
+// Licence: wxWindows licence
+//
+// Modified for Audacity to support an additional button on Save dialogs
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------
+// wxFileDialog convenience functions
+//----------------------------------------------------------------------------
+
+// File selector - backward compatibility
+WXDLLEXPORT wxString
+FileSelector(const wxChar *message = wxFileSelectorPromptStr,
+ const wxChar *default_path = NULL,
+ const wxChar *default_filename = NULL,
+ const wxChar *default_extension = NULL,
+ const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
+ int flags = 0,
+ wxWindow *parent = NULL,
+ wxString label = wxEmptyString,
+ fdCallback cb = NULL,
+ void *cbdata = NULL);
+
#endif
Index: FileDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/lib-src/FileDialog/FileDialog.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FileDialog.cpp 9 Apr 2007 01:47:30 -0000 1.2
+++ FileDialog.cpp 10 Apr 2007 02:22:20 -0000 1.3
@@ -41,6 +41,97 @@
}
}
+/////////////////////////////////////////////////////////////////////////////
+// Name: common/fldlgcmn.cpp
+// Purpose: wxFileDialog common functions
+// Author: John Labenski
+// Modified by: Leland Lucius
+// Created: 14.06.03 (extracted from src/*/filedlg.cpp)
+// RCS-ID: $Id$
+// Copyright: (c) Robert Roebling
+// Licence: wxWindows licence
+//
+// Modified for Audacity to support an additional button on Save dialogs
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//----------------------------------------------------------------------------
+// FileDialog convenience functions
+//----------------------------------------------------------------------------
+
+wxString FileSelector(const wxChar *title,
+ const wxChar *defaultDir,
+ const wxChar *defaultFileName,
+ const wxChar *defaultExtension,
+ const wxChar *filter,
+ int flags,
+ wxWindow *parent,
+ wxString label, fdCallback cb, void *cbdata)
+{
+ // The defaultExtension, if non-NULL, is
+ // appended to the filename if the user fails to type an extension. The new
+ // implementation (taken from wxFileSelectorEx) appends the extension
+ // automatically, by looking at the filter specification. In fact this
+ // should be better than the native Microsoft implementation because
+ // Windows only allows *one* default extension, whereas here we do the
+ // right thing depending on the filter the user has chosen.
+
+ // If there's a default extension specified but no filter, we create a
+ // suitable filter.
+
+ wxString filter2;
+ if ( defaultExtension && !filter )
+ filter2 = wxString(wxT("*.")) + defaultExtension;
+ else if ( filter )
+ filter2 = filter;
+
+ wxString defaultDirString;
+ if (defaultDir)
+ defaultDirString = defaultDir;
+
+ wxString defaultFilenameString;
+ if (defaultFileName)
+ defaultFilenameString = defaultFileName;
+
+ FileDialog fileDialog(parent, title, defaultDirString,
+ defaultFilenameString, filter2,
+ flags);
+
+ // Enable the extra button if desired
+ if ((flags & wxSAVE) && (cb != NULL)) {
+ fileDialog.EnableButton(label, cb, cbdata);
+ }
+
+ // if filter is of form "All files (*)|*|..." set correct filter index
+ if((wxStrlen(defaultExtension) != 0) && (filter2.Find(wxT('|')) !=
wxNOT_FOUND))
+ {
+ int filterIndex = 0;
+
+ wxArrayString descriptions, filters;
+ // don't care about errors, handled already by FileDialog
+ (void)wxParseCommonDialogsFilter(filter2, descriptions, filters);
+ for (size_t n=0; n<filters.GetCount(); n++)
+ {
+ if (filters[n].Contains(defaultExtension))
+ {
+ filterIndex = n;
+ break;
+ }
+ }
+
+ if (filterIndex > 0)
+ fileDialog.SetFilterIndex(filterIndex);
+ }
+
+ wxString filename;
+ if ( fileDialog.ShowModal() == wxID_OK )
+ {
+ filename = fileDialog.GetPath();
+ }
+
+ return filename;
+}
+
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs