OSDN Git Service

Fix Issue 24, Commit results not in window with scroll bars
authorColin Law <colin@clanlaw.org.uk>
Fri, 13 Feb 2009 17:07:24 +0000 (17:07 +0000)
committerFrank Li <lznuaa@gmail.com>
Sat, 14 Feb 2009 02:30:08 +0000 (10:30 +0800)
Use the Progress dialog to handle commit

src/TortoiseProc/CommitDlg.cpp
src/TortoiseProc/ProgressDlg.cpp
src/TortoiseProc/ProgressDlg.h

index 8a5c182..da34bf9 100644 (file)
@@ -32,6 +32,7 @@
 #include "Hooks.h"\r
 #include "CommonResource.h"\r
 #include "UnicodeUtils.h"\r
+#include "ProgressDlg.h"\r
 \r
 #ifdef _DEBUG\r
 #define new DEBUG_NEW\r
@@ -475,11 +476,14 @@ void CCommitDlg::OnOK()
                        amend=_T("--amend");\r
                }\r
                cmd.Format(_T("git.exe commit %s -F \"%s\""),amend, tempfile);\r
-               g_Git.Run(cmd,&out,CP_OEMCP);\r
+               \r
+               CProgressDlg progress;\r
+               progress.m_GitCmd=cmd;\r
+               progress.m_bShowCommand = FALSE;        // don't show the commit command\r
+               progress.m_PreText = out;                       // show any output already generated in log window\r
+               progress.DoModal();\r
        \r
                CFile::Remove(tempfile);\r
-\r
-               CMessageBox::Show(this->m_hWnd, out, _T("Commit Finish"), MB_OK | MB_ICONINFORMATION);\r
        }else\r
                CMessageBox::Show(this->m_hWnd, _T("Nothing Commit"), _T("Commit Finish"), MB_OK | MB_ICONINFORMATION);\r
 #if 0\r
index b7e8514..83dfd50 100644 (file)
@@ -11,7 +11,7 @@
 IMPLEMENT_DYNAMIC(CProgressDlg, CResizableStandAloneDialog)\r
 \r
 CProgressDlg::CProgressDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CProgressDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CProgressDlg::IDD, pParent), m_bShowCommand(true)\r
 {\r
 \r
 }\r
@@ -50,7 +50,16 @@ BOOL CProgressDlg::OnInitDialog()
 \r
        m_Animate.Open(IDR_DOWNLOAD);\r
        \r
-       m_Log.SetWindowTextW(this->m_GitCmd+_T("\r\n\r\n"));\r
+       CString InitialText;\r
+       if ( !m_PreText.IsEmpty() )\r
+       {\r
+               InitialText = m_PreText + _T("\r\n");\r
+       }\r
+       if (m_bShowCommand)\r
+       {\r
+               InitialText += m_GitCmd+_T("\r\n\r\n");\r
+       }\r
+       m_Log.SetWindowTextW(InitialText);\r
        m_CurrentWork.SetWindowTextW(_T(""));\r
 \r
        m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);\r
index e2c0f0d..5a94665 100644 (file)
@@ -25,6 +25,8 @@ public:
        CWinThread*                             m_pThread;      \r
        volatile LONG                   m_bThreadRunning;\r
        DWORD                     m_GitStatus;\r
+       BOOL              m_bShowCommand;       // whether to display the command in the log window (default true)\r
+       CString           m_PreText;            // optional text to show in log window before running command\r
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        static UINT ProgressThreadEntry(LPVOID pVoid);\r