Made wxConvBrokenFileNames public.
Made use of it from GTK+'s wxApp. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33162 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
#include "wx/strconv.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
@@ -68,6 +69,11 @@ public:
|
|||||||
// or the XVisualInfo* for SGI.
|
// or the XVisualInfo* for SGI.
|
||||||
GdkVisual *GetGdkVisual();
|
GdkVisual *GetGdkVisual();
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
wxConvBrokenFileNames *m_convBrokenFileNames;
|
||||||
|
wxMBConv *m_oldConvFileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// true if we're inside an assert modal dialog
|
// true if we're inside an assert modal dialog
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
#include "wx/strconv.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
@@ -68,6 +69,11 @@ public:
|
|||||||
// or the XVisualInfo* for SGI.
|
// or the XVisualInfo* for SGI.
|
||||||
GdkVisual *GetGdkVisual();
|
GdkVisual *GetGdkVisual();
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
wxConvBrokenFileNames *m_convBrokenFileNames;
|
||||||
|
wxMBConv *m_oldConvFileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// true if we're inside an assert modal dialog
|
// true if we're inside an assert modal dialog
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
@@ -360,29 +360,12 @@ size_t wxMBConvLibc::WC2MB(char *buf, const wchar_t *psz, size_t n) const
|
|||||||
return wxWC2MB(buf, psz, n);
|
return wxWC2MB(buf, psz, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __UNIX__
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxConvBrokenFileNames is made for GTK2 in Unicode mode when
|
// wxConvBrokenFileNames
|
||||||
// files are accidentally written in an encoding which is not
|
|
||||||
// the system encoding. Typically, the system encoding will be
|
|
||||||
// UTF8 but there might be files stored in ISO8859-1 on disk.
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxConvBrokenFileNames : public wxMBConv
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxConvBrokenFileNames();
|
|
||||||
virtual ~wxConvBrokenFileNames() { delete m_conv; }
|
|
||||||
|
|
||||||
virtual size_t MB2WC(wchar_t *outputBuf, const char *psz, size_t outputSize) const;
|
|
||||||
virtual size_t WC2MB(char *outputBuf, const wchar_t *psz, size_t outputSize) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// the conversion object we forward to
|
|
||||||
wxMBConv *m_conv;
|
|
||||||
};
|
|
||||||
|
|
||||||
wxConvBrokenFileNames::wxConvBrokenFileNames()
|
wxConvBrokenFileNames::wxConvBrokenFileNames()
|
||||||
{
|
{
|
||||||
// decide which conversion to use for the file names
|
// decide which conversion to use for the file names
|
||||||
@@ -429,7 +412,7 @@ wxConvBrokenFileNames::WC2MB(char *outputBuf,
|
|||||||
return m_conv->WC2MB( outputBuf, psz, outputSize );
|
return m_conv->WC2MB( outputBuf, psz, outputSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __WXGTK20__
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// UTF-7
|
// UTF-7
|
||||||
@@ -2764,10 +2747,6 @@ static wxCSConv wxConvISO8859_1Obj(wxFONTENCODING_ISO8859_1);
|
|||||||
static wxMBConvUTF7 wxConvUTF7Obj;
|
static wxMBConvUTF7 wxConvUTF7Obj;
|
||||||
static wxMBConvUTF8 wxConvUTF8Obj;
|
static wxMBConvUTF8 wxConvUTF8Obj;
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
|
||||||
static wxConvBrokenFileNames wxConvBrokenFileNamesObj;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WXDLLIMPEXP_DATA_BASE(wxMBConv&) wxConvLibc = wxConvLibcObj;
|
WXDLLIMPEXP_DATA_BASE(wxMBConv&) wxConvLibc = wxConvLibcObj;
|
||||||
WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal = wxConvLocalObj;
|
WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvLocal = wxConvLocalObj;
|
||||||
WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvISO8859_1 = wxConvISO8859_1Obj;
|
WXDLLIMPEXP_DATA_BASE(wxCSConv&) wxConvISO8859_1 = wxConvISO8859_1Obj;
|
||||||
@@ -2777,8 +2756,6 @@ WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvCurrent = &wxConvLibcObj;
|
|||||||
WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = &
|
WXDLLIMPEXP_DATA_BASE(wxMBConv *) wxConvFileName = &
|
||||||
#ifdef __WXOSX__
|
#ifdef __WXOSX__
|
||||||
wxConvUTF8Obj;
|
wxConvUTF8Obj;
|
||||||
#elif __WXGTK20__
|
|
||||||
wxConvBrokenFileNamesObj;
|
|
||||||
#else
|
#else
|
||||||
wxConvLibcObj;
|
wxConvLibcObj;
|
||||||
#endif
|
#endif
|
||||||
|
@@ -606,6 +606,12 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
wxConvCurrent = (wxMBConv*) NULL;
|
wxConvCurrent = (wxMBConv*) NULL;
|
||||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
m_convBrokenFileNames = new wxConvBrokenFileNames;
|
||||||
|
m_oldConvFileName = wxConvFileName;
|
||||||
|
wxConvFileName = m_convBrokenFileNames;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||||
int i;
|
int i;
|
||||||
@@ -680,6 +686,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
delete m_convBrokenFileNames;
|
||||||
|
wxConvFileName = m_oldConvFileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
wxAppBase::CleanUp();
|
wxAppBase::CleanUp();
|
||||||
|
@@ -606,6 +606,12 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
wxConvCurrent = (wxMBConv*) NULL;
|
wxConvCurrent = (wxMBConv*) NULL;
|
||||||
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T/!wxUSE_WCHAR_T
|
||||||
|
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
m_convBrokenFileNames = new wxConvBrokenFileNames;
|
||||||
|
m_oldConvFileName = wxConvFileName;
|
||||||
|
wxConvFileName = m_convBrokenFileNames;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// gtk_init() wants UTF-8, not wchar_t, so convert
|
// gtk_init() wants UTF-8, not wchar_t, so convert
|
||||||
int i;
|
int i;
|
||||||
@@ -680,6 +686,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
|
|||||||
|
|
||||||
void wxApp::CleanUp()
|
void wxApp::CleanUp()
|
||||||
{
|
{
|
||||||
|
#ifdef __WXGTK20__
|
||||||
|
delete m_convBrokenFileNames;
|
||||||
|
wxConvFileName = m_oldConvFileName;
|
||||||
|
#endif
|
||||||
|
|
||||||
gdk_threads_leave();
|
gdk_threads_leave();
|
||||||
|
|
||||||
wxAppBase::CleanUp();
|
wxAppBase::CleanUp();
|
||||||
|
Reference in New Issue
Block a user