]> git.sur5r.net Git - bacula/bacula/commitdiff
Add a workaround for a problem when displaying Unicode filenames with non-Unicode...
authorNicolas Boichat <nicolas@boichat.ch>
Thu, 5 May 2005 13:50:31 +0000 (13:50 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Thu, 5 May 2005 13:50:31 +0000 (13:50 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1994 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/wxbmainframe.cpp
bacula/src/wx-console/wxbrestorepanel.cpp
bacula/src/wx-console/wxbutils.cpp
bacula/src/wx-console/wxbutils.h

index 858f4cf864a501e7fc73c321797fad207b1567c1..6714262373916ba0bca84cb07acaf94035853bee 100644 (file)
@@ -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.
 
index 1159eb9d516caab56b2748e1ad73a14688210760..da875b1a963be6d61c77c191fcde18e8a4d850dc 100644 (file)
@@ -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);
    }
    
index a08b606be95a487e1bd5fe82438fec98ec0eed64..edc6cad4ea0e8b7057b49903fadb6ef7a7802ce1 100644 (file)
@@ -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<wxbTreeItemData*>(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);
index 7a1c515d2b9d6d3845a3929a87a4281f9b1b0d47..4d1ce9bd5e89ef6358cbd8ac2b98ec2e074d289e 100644 (file)
 
 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)
index 155b1a4368d0e434892b07a6ad87ee6ccab45f79..f7cb4ed60919b66542f5dd5201de64e687565b00 100644 (file)
@@ -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;
 };