OSDN Git Service

Setting dialog, remote list work.
authorFrank Li <lznuaa@gmail.com>
Wed, 1 Apr 2009 09:47:40 +0000 (17:47 +0800)
committerFrank Li <lznuaa@gmail.com>
Wed, 1 Apr 2009 09:47:40 +0000 (17:47 +0800)
When click remote list, show url and puttykey file.

Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/Commands/SettingsCommand.cpp
src/TortoiseProc/Settings/SettingGitRemote.cpp
src/TortoiseProc/Settings/SettingGitRemote.h
src/TortoiseProc/Settings/Settings.cpp
src/TortoiseProc/Settings/Settings.h
src/TortoiseProc/TortoiseProc.vcproj

index db52fe3..8458a51 100644 (file)
 \r
 bool SettingsCommand::Execute()\r
 {\r
 \r
 bool SettingsCommand::Execute()\r
 {\r
-       CSettings dlg(IDS_PROC_SETTINGS_TITLE);\r
+       CSettings dlg(IDS_PROC_SETTINGS_TITLE,&orgCmdLinePath);\r
        dlg.SetTreeViewMode(TRUE, TRUE, TRUE);\r
        dlg.SetTreeWidth(220);\r
        dlg.SetTreeViewMode(TRUE, TRUE, TRUE);\r
        dlg.SetTreeWidth(220);\r
-       dlg.m_CmdPath = this->orgCmdLinePath ;\r
+       \r
        dlg.DoModal();\r
        dlg.HandleRestart();\r
        return true;\r
        dlg.DoModal();\r
        dlg.HandleRestart();\r
        return true;\r
index d71f45c..7c51ad8 100644 (file)
@@ -4,7 +4,10 @@
 #include "stdafx.h"\r
 #include "TortoiseProc.h"\r
 #include "SettingGitRemote.h"\r
 #include "stdafx.h"\r
 #include "TortoiseProc.h"\r
 #include "SettingGitRemote.h"\r
-\r
+#include "Settings.h"\r
+#include "GitAdminDir.h"\r
+#include "MessageBox.h"\r
+#include "git.h"\r
 \r
 // CSettingGitRemote dialog\r
 \r
 \r
 // CSettingGitRemote dialog\r
 \r
@@ -16,7 +19,7 @@ CSettingGitRemote::CSettingGitRemote()
     , m_strUrl(_T(""))\r
     , m_strPuttyKeyfile(_T(""))\r
 {\r
     , m_strUrl(_T(""))\r
     , m_strPuttyKeyfile(_T(""))\r
 {\r
-\r
+       m_bChanged=FALSE;\r
 }\r
 \r
 CSettingGitRemote::~CSettingGitRemote()\r
 }\r
 \r
 CSettingGitRemote::~CSettingGitRemote()\r
@@ -44,7 +47,38 @@ BEGIN_MESSAGE_MAP(CSettingGitRemote, CPropertyPage)
     ON_EN_CHANGE(IDC_EDIT_PUTTY_KEY, &CSettingGitRemote::OnEnChangeEditPuttyKey)\r
 END_MESSAGE_MAP()\r
 \r
     ON_EN_CHANGE(IDC_EDIT_PUTTY_KEY, &CSettingGitRemote::OnEnChangeEditPuttyKey)\r
 END_MESSAGE_MAP()\r
 \r
-\r
+BOOL CSettingGitRemote::OnInitDialog()\r
+{\r
+       ISettingsPropPage::OnInitDialog();\r
+\r
+       CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();\r
+       CString proj;\r
+       if(     g_GitAdminDir.HasAdminDir(str,&proj) )\r
+       {\r
+               this->SetWindowText(CString(_T("Config - "))+proj);\r
+       }\r
+\r
+       CString cmd,out;\r
+       cmd=_T("git.exe remote");\r
+       if(g_Git.Run(cmd,&out,CP_ACP))\r
+       {\r
+               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               return FALSE;\r
+       }\r
+       int start =0;\r
+       m_ctrlRemoteList.ResetContent();\r
+       do\r
+       {\r
+               CString one;\r
+               one=out.Tokenize(_T("\n"),start);\r
+               if(!one.IsEmpty())\r
+                       this->m_ctrlRemoteList.AddString(one);\r
+\r
+       }while(start>=0);\r
+               \r
+       this->UpdateData(FALSE);\r
+       return TRUE;\r
+}\r
 // CSettingGitRemote message handlers\r
 \r
 void CSettingGitRemote::OnBnClickedButtonBrowse()\r
 // CSettingGitRemote message handlers\r
 \r
 void CSettingGitRemote::OnBnClickedButtonBrowse()\r
@@ -60,6 +94,67 @@ void CSettingGitRemote::OnBnClickedButtonAdd()
 void CSettingGitRemote::OnLbnSelchangeListRemote()\r
 {\r
     // TODO: Add your control notification handler code here\r
 void CSettingGitRemote::OnLbnSelchangeListRemote()\r
 {\r
     // TODO: Add your control notification handler code here\r
+       if(m_bChanged)\r
+       {\r
+               if(CMessageBox::Show(NULL,_T("Remote Config Changed\nDo you want to save change now or discard change"),\r
+                                                                _T("TortoiseGit"),MB_YESNO) == IDYES)\r
+               {\r
+                       OnApply();\r
+               }\r
+       }\r
+       SetModified(FALSE);\r
+       \r
+       CString cmd,output;\r
+       int index;\r
+       index = this->m_ctrlRemoteList.GetCurSel();\r
+       if(index<0)\r
+               return;\r
+\r
+       CString remote;\r
+       m_ctrlRemoteList.GetText(index,remote);\r
+       this->m_strRemote=remote;\r
+\r
+       cmd.Format(_T("git.exe config remote.%s.url"),remote);\r
+       m_strUrl.Empty();\r
+       if( g_Git.Run(cmd,&m_strUrl,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+       \r
+       int start=0;\r
+       m_strUrl = m_strUrl.Tokenize(_T("\n"),start);\r
+\r
+\r
+       cmd.Format(_T("git.exe config remote.%s.puttykey"),remote);\r
+       this->m_strPuttyKeyfile.Empty();\r
+       if( g_Git.Run(cmd,&m_strPuttyKeyfile,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+       start=0;\r
+       m_strPuttyKeyfile = m_strPuttyKeyfile.Tokenize(_T("\n"),start);\r
+       \r
+\r
+       cmd.Format(_T("git.exe config remote.%s.puttykeyautoload"),remote);\r
+       CString autoload;\r
+       if( g_Git.Run(cmd,&autoload,CP_ACP) )\r
+       {\r
+               //CMessageBox::Show(NULL,output,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+               //return;\r
+       }\r
+\r
+       start=0;\r
+       autoload = autoload.Tokenize(_T("\n"),start);\r
+       m_bAutoLoad.SetCheck(false);\r
+       if( autoload == _T("true"))\r
+       {\r
+               m_bAutoLoad.SetCheck(true);\r
+       }\r
+       \r
+       this->UpdateData(FALSE);\r
+\r
 }\r
 \r
 void CSettingGitRemote::OnEnChangeEditRemote()\r
 }\r
 \r
 void CSettingGitRemote::OnEnChangeEditRemote()\r
@@ -96,3 +191,10 @@ void CSettingGitRemote::OnEnChangeEditPuttyKey()
 \r
     // TODO:  Add your control notification handler code here\r
 }\r
 \r
     // TODO:  Add your control notification handler code here\r
 }\r
+\r
+BOOL CSettingGitRemote::OnApply()\r
+{\r
+  \r
+    SetModified(FALSE);\r
+       return ISettingsPropPage::OnApply();\r
+}
\ No newline at end of file
index ba6c5cf..e4a7c62 100644 (file)
@@ -22,6 +22,12 @@ protected:
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
 \r
        DECLARE_MESSAGE_MAP()\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
 \r
        DECLARE_MESSAGE_MAP()\r
+\r
+       BOOL OnInitDialog();\r
+    BOOL OnApply();\r
+\r
+       BOOL m_bChanged;\r
+\r
 public:\r
     CListBox m_ctrlRemoteList;\r
     CString m_strRemote;\r
 public:\r
     CListBox m_ctrlRemoteList;\r
     CString m_strRemote;\r
index 1a08e0c..98c2a38 100644 (file)
 #include "MessageBox.h"\r
 #include "..\..\TGitCache\CacheInterface.h"\r
 #include "CommonResource.h"\r
 #include "MessageBox.h"\r
 #include "..\..\TGitCache\CacheInterface.h"\r
 #include "CommonResource.h"\r
-\r
+#include "GitAdminDir.h"\r
 \r
 IMPLEMENT_DYNAMIC(CSettings, CTreePropSheet)\r
 \r
 IMPLEMENT_DYNAMIC(CSettings, CTreePropSheet)\r
-CSettings::CSettings(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)\r
+CSettings::CSettings(UINT nIDCaption,CTGitPath *cmdPath, CWnd* pParentWnd, UINT iSelectPage)\r
        :CTreePropSheet(nIDCaption, pParentWnd, iSelectPage)\r
 {\r
        :CTreePropSheet(nIDCaption, pParentWnd, iSelectPage)\r
 {\r
+       if(cmdPath)\r
+               this->m_CmdPath=*cmdPath;\r
+\r
        m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);\r
        AddPropPages();\r
 }\r
        m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);\r
        AddPropPages();\r
 }\r
@@ -105,7 +108,11 @@ void CSettings::AddPropPages()
        AddPage(m_pSavedPage);\r
 \r
        AddPage(m_pGitConfig);\r
        AddPage(m_pSavedPage);\r
 \r
        AddPage(m_pGitConfig);\r
-       AddPage(m_pGitRemote);\r
+\r
+       if(     g_GitAdminDir.HasAdminDir(this->m_CmdPath.GetWinPath()) )\r
+       {\r
+               AddPage(m_pGitRemote);\r
+       }\r
 //     AddPage(m_pGitRemotem_pLogCachePage);\r
 //    AddPage(m_pLogCacheListPage);\r
 //     AddPage(m_pHooksPage);\r
 //     AddPage(m_pGitRemotem_pLogCachePage);\r
 //    AddPage(m_pLogCacheListPage);\r
 //     AddPage(m_pHooksPage);\r
index 812d672..d2551e6 100644 (file)
@@ -93,7 +93,7 @@ private:
 \r
        HICON                                   m_hIcon;\r
 public:\r
 \r
        HICON                                   m_hIcon;\r
 public:\r
-       CSettings(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);\r
+       CSettings(UINT nIDCaption,CTGitPath *CmdPath=NULL, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);\r
        virtual ~CSettings();\r
        CTGitPath m_CmdPath;\r
        /**\r
        virtual ~CSettings();\r
        CTGitPath m_CmdPath;\r
        /**\r
index 9b996e3..ced05cc 100644 (file)
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r