]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/wx-console/wxbmainframe.cpp
Add version strings
[bacula/bacula] / bacula / src / wx-console / wxbmainframe.cpp
index 51d0e0e9042ef7180470e3b9222388dd0eeed04e..f37c9e714c180c4c62ed8a372ba58be0740185b6 100644 (file)
@@ -2,8 +2,9 @@
  *
  *   Main frame
  *
- *    Nicolas Boichat, April 2004
+ *    Nicolas Boichat, July 2004
  *
+ *    Version $Id$
  */
 /*
    Copyright (C) 2004 Kern Sibbald and John Walker
@@ -41,6 +42,8 @@
 
 #include <wx/filename.h>
 
+#undef Yield /* MinGW defines Yield */
+
 // ----------------------------------------------------------------------------
 // event tables and other macros for wxWindows
 // ----------------------------------------------------------------------------
@@ -262,7 +265,7 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi
    consoleSizer->AddGrowableCol(0);
    consoleSizer->AddGrowableRow(0);
 
-   typeCtrl = new wxTextCtrl(consolePanel,TypeText,"",wxDefaultPosition,wxSize(200,20), wxTE_PROCESS_ENTER);
+   typeCtrl = new wxbHistoryTextCtrl(consolePanel,TypeText,"",wxDefaultPosition,wxSize(200,20));
    sendButton = new wxButton(consolePanel, SendButton, "Send");
    
    wxFlexGridSizer *typeSizer = new wxFlexGridSizer(1, 3, 0, 0);
@@ -309,6 +312,8 @@ wxbMainFrame::wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSi
    lockedbyconsole = false;
    
    consoleBuffer = "";
+   
+   configfile = "";
 }
 
 /*
@@ -324,13 +329,12 @@ void wxbMainFrame::StartConsoleThread(const wxString& config) {
    if (ct != NULL) {
       ct->Delete();
       ct = NULL;
+      wxTheApp->Yield();
    }
    if (promptparser == NULL) {
       promptparser = new wxbPromptParser();      
    }
    
-   wxString configfile;
-
    if (config == "") {   
       if ((wxTheApp->argc == 3) && (wxString(wxTheApp->argv[1]) == "-c")) {
          configfile = wxTheApp->argv[2];
@@ -448,9 +452,11 @@ void wxbMainFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
    if (ct != NULL) {
       ct->Delete();
       ct = NULL;
+      wxTheApp->Yield();
    }
    console_thread::FreeLib();
    frame = NULL;
+   wxTheApp->Yield();
    Close(TRUE);
 }
 
@@ -474,6 +480,7 @@ void wxbMainFrame::OnChangeConfig(wxCommandEvent& event) {
                            wxYES_NO | wxICON_QUESTION, this);
          if (answer == wxYES) {
               wxConfigBase::Get()->Write("/ConfigFile", configfile);
+              wxConfigBase::Get()->Flush();
               StartConsoleThread("");
               return;
          }
@@ -493,23 +500,7 @@ void wxbMainFrame::OnEditConfig(wxCommandEvent& event) {
 }
 
 void wxbMainFrame::OnConnect(wxCommandEvent& event) {
-   menuFile->Enable(MenuConnect, false);
-   menuFile->Enable(MenuDisconnect, false);
-   menuFile->Enable(ChangeConfigFile, false);
-   menuFile->Enable(EditConfigFile, false);
-
-   if (ct != NULL) {
-      ct->Delete();
-      ct = NULL;
-   }
-   if (promptparser == NULL) {
-      promptparser = new wxbPromptParser();      
-   }
-
-   ct = new console_thread();
-   ct->Create();
-   ct->Run();
-   SetStatusText("Connecting to the director...");
+   StartConsoleThread(configfile);
 }
 
 void wxbMainFrame::OnDisconnect(wxCommandEvent& event) {
@@ -523,6 +514,7 @@ void wxbMainFrame::OnEnter(wxCommandEvent& WXUNUSED(event))
 {
    lockedbyconsole = true;
    DisablePanels();
+   typeCtrl->HistoryAdd(typeCtrl->GetValue());
    wxString str = typeCtrl->GetValue() + "\n";
    Send(str);
 }
@@ -549,6 +541,7 @@ void wxbMainFrame::Print(wxString str, int status)
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
       SetStatusText("Console thread terminated.");
+      consoleCtrl->ScrollLines(3);
       ct = NULL;
       DisablePanels();
       int answer = wxMessageBox("Connection to the director lost. Quit program?", "Connection lost",
@@ -572,7 +565,7 @@ void wxbMainFrame::Print(wxString str, int status)
       menuFile->Enable(MenuConnect, true);
       menuFile->SetLabel(MenuConnect, "Reconnect");
       menuFile->SetHelpString(MenuConnect, "Reconnect to the director");
-      menuFile->Enable(MenuDisconnect, false);
+      menuFile->Enable(MenuDisconnect, true);
       menuFile->Enable(ChangeConfigFile, true);
       menuFile->Enable(EditConfigFile, true);
       return;
@@ -580,6 +573,7 @@ void wxbMainFrame::Print(wxString str, int status)
    if (status == CS_DISCONNECTED) {
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
+      consoleCtrl->ScrollLines(3);
       SetStatusText("Disconnected of the director.");
       DisablePanels();
       return;
@@ -627,7 +621,12 @@ void wxbMainFrame::Print(wxString str, int status)
                Send("\n");
             }
             else {
-               Send(wxString() << numbers[res] << "\n");
+               if (promptparser->isNumericalChoice()) {
+                  Send(wxString() << numbers[res] << "\n");
+               }
+               else {
+                  Send(wxString() << choices[res] << "\n");
+               }
             }
          }
          else {
@@ -648,6 +647,7 @@ void wxbMainFrame::Print(wxString str, int status)
    if (status == CS_DEBUG) {
       consoleCtrl->AppendText(consoleBuffer);
       consoleBuffer = "";
+      consoleCtrl->ScrollLines(3);
       consoleCtrl->SetDefaultStyle(wxTextAttr(wxColour(0, 128, 0)));
    }
    else {
@@ -658,7 +658,7 @@ void wxbMainFrame::Print(wxString str, int status)
       if (lockedbyconsole) {
          EnableConsole(true);
       }
-      consoleBuffer << "<P>";
+      //consoleBuffer << "<P>";
    }
    
    if ((status == CS_END) || (status == CS_PROMPT) || (str.Find("\n") > -1)) {
@@ -771,4 +771,3 @@ void csprint(const char* str, int status)
       firePrintEvent("", status);
    }
 }
-