From 6603907dea3324a55ea99608ee69e3b65634fe73 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 17 May 2001 15:51:09 +0000 Subject: [PATCH] don't annoy the user by repeating the question which had been already answered (and also make the question a bit more clear) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/fontmap.cpp | 63 ++++++++++++++++++++++++++++++------------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 13b7090082..c63b9af1c4 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -58,8 +58,11 @@ static const wxChar* FONTMAPPER_ROOT_PATH = wxT("/wxWindows/FontMapper"); static const wxChar* FONTMAPPER_CHARSET_PATH = wxT("Charsets"); static const wxChar* FONTMAPPER_CHARSET_ALIAS_PATH = wxT("Aliases"); + +// we only ask questions in GUI mode #if wxUSE_GUI static const wxChar* FONTMAPPER_FONT_FROM_ENCODING_PATH = wxT("Encodings"); + static const wxChar* FONTMAPPER_FONT_DONT_ASK = wxT("none"); #endif // wxUSE_GUI // encodings supported by GetEncodingDescription @@ -692,29 +695,41 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, RestorePath(pathOld); - if ( !!fontinfo && !!facename ) + // this special value means that we don't know of fonts for this + // encoding but, moreover, have already asked the user as well and he + // didn't specify any font neither + if ( fontinfo == FONTMAPPER_FONT_DONT_ASK ) { - // we tried to find a match with facename - now try without it - fontinfo = config->Read(encName); + interactive = FALSE; } - - if ( !!fontinfo ) + else // use the info entered the last time { - if ( info->FromString(fontinfo) ) + if ( !!fontinfo && !!facename ) { - if ( wxTestFontEncoding(*info) ) - { - // ok, got something - return TRUE; - } - //else: no such fonts, look for something else + // we tried to find a match with facename - now try without it + fontinfo = config->Read(encName); } - else + + if ( !!fontinfo ) { - wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"), fontinfo.c_str()); + if ( info->FromString(fontinfo) ) + { + if ( wxTestFontEncoding(*info) ) + { + // ok, got something + return TRUE; + } + //else: no such fonts, look for something else + // (should we erase the outdated value?) + } + else + { + wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"), + fontinfo.c_str()); + } } + //else: there is no information in config about this encoding } - //else: there is no information in config about this encoding } #endif // wxUSE_CONFIG @@ -727,7 +742,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, // the message wxString msg; - msg.Printf(_("The encoding '%s' is unknown.\nWould you like to select a font to be used for this encoding\n(otherwise the text in this encoding will not be shown correctly)?"), + msg.Printf(_("No font for displaying text in encoding '%s' found.\nWould you like to select a font to be used for this encoding\n(otherwise the text in this encoding will not be shown correctly)?"), GetEncodingDescription(encoding).c_str()); wxWindow *parent = m_windowParent; @@ -750,7 +765,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, info -> encoding = retData.GetEncoding(); #if wxUSE_CONFIG - // remember this in the config + // remember this in the config if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) ) { GetConfig()->Write(configEntry, info->ToString()); @@ -763,7 +778,19 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, } //else: the user canceled the font selection dialog } - //else: the user doesn't want to select a font + else + { + // the user doesn't want to select a font for this encoding, + // remember it to avoid asking the same question again later +#if wxUSE_CONFIG + if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) ) + { + GetConfig()->Write(configEntry, FONTMAPPER_FONT_DONT_ASK); + + RestorePath(pathOld); + } +#endif // wxUSE_CONFIG + } } //else: we're in non-interactive mode -- 2.47.2