From: Nicolas Boichat Date: Thu, 5 May 2005 13:50:31 +0000 (+0000) Subject: Add a workaround for a problem when displaying Unicode filenames with non-Unicode... X-Git-Tag: Release-1.38.0~504 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c9e56cc0d33796682fc2faa7b0082d16f963bbd3;p=bacula%2Fbacula Add a workaround for a problem when displaying Unicode filenames with non-Unicode wxWidgets. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1994 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 858f4cf864..6714262373 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,3 +1,7 @@ +05-05-2005 : + - Add a workaround for a problem when displaying Unicode filenames with + non-Unicode wxWidgets. + 04-05-2005 : - Remember the last window position and size. diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index 1159eb9d51..da875b1a96 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -692,7 +692,7 @@ void wxbMainFrame::Print(wxString str, int status) else { consoleCtrl->SetDefaultStyle(wxTextAttr(*wxBLACK)); } - consoleBuffer << str; + consoleBuffer << wxbUtils::ConvertToPrintable(str); if (status == CS_PROMPT) { if (lockedbyconsole) { EnableConsole(true); @@ -732,7 +732,7 @@ void wxbMainFrame::Send(wxString str) ct->Write((const char*)str); typeCtrl->SetValue(""); consoleCtrl->SetDefaultStyle(wxTextAttr(*wxRED)); - consoleCtrl->AppendText(str); + consoleCtrl->AppendText(wxbUtils::ConvertToPrintable(str)); consoleCtrl->ScrollLines(3); } diff --git a/bacula/src/wx-console/wxbrestorepanel.cpp b/bacula/src/wx-console/wxbrestorepanel.cpp index a08b606be9..edc6cad4ea 100644 --- a/bacula/src/wx-console/wxbrestorepanel.cpp +++ b/bacula/src/wx-console/wxbrestorepanel.cpp @@ -1425,7 +1425,7 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re bool updated = false; while (treeid.IsOk()) { - itemStr = tree->GetItemText(treeid); + itemStr = ((wxbTreeItemData*)tree->GetItemData(treeid))->GetName(); if (file[8] == itemStr) { int stat = wxbTreeItemData::GetMarkedStatus(file[6]); if (static_cast(tree->GetItemData(treeid))->GetMarked() != stat) { @@ -1444,7 +1444,7 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re if (!updated) { int img = wxbTreeItemData::GetMarkedStatus(file[6]); - treeid = tree->AppendItem(item, file[8], img, img, new wxbTreeItemData(file[7], file[8], file[6])); + treeid = tree->AppendItem(item, wxbUtils::ConvertToPrintable(file[8]), img, img, new wxbTreeItemData(file[7], file[8], file[6])); } } @@ -1453,7 +1453,7 @@ void wxbRestorePanel::UpdateTreeItem(wxTreeItemId item, bool updatelist, bool re wxbTreeItemData* data = new wxbTreeItemData(file[7], file[8], file[6], ind); data->SetId(treeid); list->SetItemData(ind, (long)data); - list->SetItem(ind, 1, file[8]); // filename + list->SetItem(ind, 1, wxbUtils::ConvertToPrintable(file[8])); // filename list->SetItem(ind, 2, file[4]); //Size list->SetItem(ind, 3, file[5]); //date list->SetItem(ind, 4, file[0]); //perm @@ -1491,7 +1491,7 @@ wxString* wxbRestorePanel::ParseList(wxString line) { ret[5] = line.Mid(42, 19).Trim(); ret[6] = line.Mid(62, 1); ret[7] = line.Mid(63).Trim(); - + if (ret[6] == " ") ret[6] = ""; if (ret[7].GetChar(ret[7].Length()-1) == '/') { @@ -1688,7 +1688,7 @@ void wxbRestorePanel::RefreshTree() { match = false; while (currentChild.IsOk()) { - if (tree->GetItemText(currentChild) == current[i]) { + if (((wxbTreeItemData*)tree->GetItemData(currentChild))->GetName() == current[i]) { item = currentChild; match = true; break; @@ -2177,7 +2177,7 @@ void wxbRestorePanel::OnListActivated(wxListEvent& event) { wxTreeItemId currentChild = tree->GetFirstChild(currentTreeItem, cookie); while (currentChild.IsOk()) { - wxString name2 = tree->GetItemText(currentChild); + wxString name2 = ((wxbTreeItemData*)tree->GetItemData(currentChild))->GetName(); if (name2 == name) { //tree->UnselectAll(); SetWorking(false); diff --git a/bacula/src/wx-console/wxbutils.cpp b/bacula/src/wx-console/wxbutils.cpp index 7a1c515d2b..4d1ce9bd5e 100644 --- a/bacula/src/wx-console/wxbutils.cpp +++ b/bacula/src/wx-console/wxbutils.cpp @@ -37,6 +37,23 @@ bool wxbUtils::inited = false; +wxString wxbUtils::ConvertToPrintable(wxString& str) { + /* FIXME : Unicode support should be added to fix this problem */ +#if wxUSE_UNICODE == 0 + wxString strnew(str); + /* Convert the string to something printable without unicode */ + for (unsigned int i = 0; i < strnew.Length(); i++) { + /* If the character is not ASCII, print a ? */ + if (((unsigned char)strnew[i] > (unsigned char)127)) { + strnew[i] = '?'; + } + } + return strnew; +#else + return str; +#endif +} + /* Sleeps during milliseconds (wrapper for wxUsleep (2.4) or wxMilliSleep (2.6)) */ void wxbUtils::MilliSleep(unsigned long milliseconds) { #if wxCHECK_VERSION(2, 6, 0) diff --git a/bacula/src/wx-console/wxbutils.h b/bacula/src/wx-console/wxbutils.h index 155b1a4368..f7cb4ed609 100644 --- a/bacula/src/wx-console/wxbutils.h +++ b/bacula/src/wx-console/wxbutils.h @@ -66,7 +66,9 @@ class wxbUtils /* Sleeps during milliseconds (wrapper for wxUsleep (2.4) or wxMilliSleep (2.6)) */ static void MilliSleep(unsigned long milliseconds); - + + static wxString ConvertToPrintable(wxString& str); + private: static bool inited; };