OSDN Git Service

BrowseRefs: Share property sheet for remote management
authorJohan t Hart <johanthart@gmail.com>
Mon, 27 Apr 2009 21:59:00 +0000 (23:59 +0200)
committerFrank Li <lznuaa@gmail.com>
Wed, 6 May 2009 07:45:38 +0000 (15:45 +0800)
src/TortoiseProc/BrowseRefsDlg.cpp
src/TortoiseProc/BrowseRefsDlg.h
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/Settings/SettingGitRemote.cpp
src/TortoiseProc/Settings/SettingGitRemote.h
src/TortoiseProc/Settings/Settings.cpp
src/TortoiseProc/SinglePropSheetDlg.cpp [new file with mode: 0644]
src/TortoiseProc/SinglePropSheetDlg.h [new file with mode: 0644]
src/TortoiseProc/TortoiseProc.vcproj

index 487f008..12a23d6 100644 (file)
@@ -7,14 +7,17 @@
 #include "LogDlg.h"\r
 #include "AddRemoteDlg.h"\r
 #include "CreateBranchTagDlg.h"\r
+#include "Settings\SettingGitRemote.h"\r
+#include "SinglePropSheetDlg.h"\r
 \r
 \r
 // CBrowseRefsDlg dialog\r
 \r
 IMPLEMENT_DYNAMIC(CBrowseRefsDlg, CResizableStandAloneDialog)\r
 \r
-CBrowseRefsDlg::CBrowseRefsDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CBrowseRefsDlg::IDD, pParent)\r
+CBrowseRefsDlg::CBrowseRefsDlg(CString cmdPath, CWnd* pParent /*=NULL*/)\r
+:      CResizableStandAloneDialog(CBrowseRefsDlg::IDD, pParent),\r
+       m_cmdPath(cmdPath)\r
 {\r
 \r
 }\r
@@ -328,7 +331,10 @@ void CBrowseRefsDlg::OnContextMenu_RefTreeCtrl(CPoint point)
                m_RefTreeCtrl.Select(hTreeItem,TVGN_CARET);\r
                CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreeItem);\r
                if(pTree->IsFrom(L"refs/remotes"))\r
-                       popupMenu.AppendMenu(MF_STRING,eCmd_AddRemote,L"Add Remote");\r
+               {\r
+//                     popupMenu.AppendMenu(MF_STRING,eCmd_AddRemote,L"Add Remote");\r
+                       popupMenu.AppendMenu(MF_STRING,eCmd_ManageRemotes,L"Manage Remotes");\r
+               }\r
                else if(pTree->IsFrom(L"refs/heads"))\r
                        popupMenu.AppendMenu(MF_STRING,eCmd_CreateBranch,L"Create Branch");\r
                else if(pTree->IsFrom(L"refs/tags"))\r
@@ -344,6 +350,13 @@ void CBrowseRefsDlg::OnContextMenu_RefTreeCtrl(CPoint point)
                        Refresh();\r
                }\r
                break;\r
+       case eCmd_ManageRemotes:\r
+               {\r
+                       CSinglePropSheetDlg(L"Git Remote Settings",new CSettingGitRemote(m_cmdPath),this).DoModal();\r
+//                     CSettingGitRemote W_Remotes(m_cmdPath);\r
+//                     W_Remotes.DoModal();\r
+               }\r
+               break;\r
        case eCmd_CreateBranch:\r
                {\r
                        CCreateBranchTagDlg dlg(this);\r
index 4606494..b66de68 100644 (file)
@@ -43,13 +43,14 @@ class CBrowseRefsDlg : public CResizableStandAloneDialog
        DECLARE_DYNAMIC(CBrowseRefsDlg)\r
 \r
 public:\r
-       CBrowseRefsDlg(CWnd* pParent = NULL);   // standard constructor\r
+       CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL);   // standard constructor\r
        virtual ~CBrowseRefsDlg();\r
 \r
        enum eCmd\r
        {\r
                eCmd_ViewLog = WM_APP,\r
                eCmd_AddRemote,\r
+               eCmd_ManageRemotes,\r
                eCmd_CreateBranch,\r
                eCmd_CreateTag\r
        };\r
@@ -76,6 +77,7 @@ public:
        bool                    SelectRef(CString refName);\r
 \r
 private:\r
+       CString                 m_cmdPath;\r
 \r
        CShadowTree             m_TreeRoot;\r
        CTreeCtrl               m_RefTreeCtrl;\r
index 7e30f8f..45043be 100644 (file)
@@ -262,7 +262,7 @@ class TestCommand : public Command
 {\r
        virtual bool Execute()\r
        {\r
-               CBrowseRefsDlg().DoModal();\r
+               CBrowseRefsDlg(orgCmdLinePath.GetWinPath()).DoModal();\r
                return true;\r
        }\r
 };\r
index 34c1c45..9c046a0 100644 (file)
 \r
 IMPLEMENT_DYNAMIC(CSettingGitRemote, ISettingsPropPage)\r
 \r
-CSettingGitRemote::CSettingGitRemote()\r
+CSettingGitRemote::CSettingGitRemote(CString cmdPath)\r
        : ISettingsPropPage(CSettingGitRemote::IDD)\r
     , m_strRemote(_T(""))\r
     , m_strUrl(_T(""))\r
     , m_strPuttyKeyfile(_T(""))\r
+       , m_cmdPath(cmdPath)\r
 {\r
 \r
        m_ChangedMask = 0;\r
@@ -50,9 +51,9 @@ BOOL CSettingGitRemote::OnInitDialog()
 {\r
        ISettingsPropPage::OnInitDialog();\r
 \r
-       CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();\r
+       //CString str=((CSettings*)GetParent())->m_CmdPath.GetWinPath();\r
        CString proj;\r
-       if(     g_GitAdminDir.HasAdminDir(str,&proj) )\r
+       if(     g_GitAdminDir.HasAdminDir(m_cmdPath,&proj) )\r
        {\r
                this->SetWindowText(CString(_T("Config - "))+proj);\r
        }\r
index 5890346..e8c20d1 100644 (file)
@@ -17,7 +17,7 @@ public:
                REMOTE_URL              =0x2,\r
                REMOTE_PUTTYKEY =0x4,\r
        };\r
-       CSettingGitRemote();\r
+       CSettingGitRemote(CString cmdPath);\r
        virtual ~CSettingGitRemote();\r
        UINT GetIconID() {return IDI_GITREMOTE;}\r
 // Dialog Data\r
@@ -38,7 +38,9 @@ protected:
        int      m_ChangedMask;\r
 \r
 public:\r
-    CListBox m_ctrlRemoteList;\r
+       CString m_cmdPath;\r
+\r
+       CListBox m_ctrlRemoteList;\r
     CString m_strRemote;\r
     CString m_strUrl;\r
     \r
index 98c2a38..7c54b0a 100644 (file)
@@ -63,7 +63,7 @@ void CSettings::AddPropPages()
        m_pBugTraqPage = new CSetBugTraq();\r
        m_pTBlamePage = new CSettingsTBlame();\r
        m_pGitConfig = new CSettingGitConfig();\r
-       m_pGitRemote = new CSettingGitRemote();\r
+       m_pGitRemote = new CSettingGitRemote(m_CmdPath.GetWinPath());\r
 \r
 \r
        SetPageIcon(m_pMainPage, m_pMainPage->GetIconID());\r
diff --git a/src/TortoiseProc/SinglePropSheetDlg.cpp b/src/TortoiseProc/SinglePropSheetDlg.cpp
new file mode 100644 (file)
index 0000000..c33427a
--- /dev/null
@@ -0,0 +1,63 @@
+// SinglePropSheetDlg.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "TortoiseProc.h"\r
+#include "SinglePropSheetDlg.h"\r
+\r
+\r
+// CSinglePropSheetDlg dialog\r
+using namespace TreePropSheet;\r
+\r
+IMPLEMENT_DYNAMIC(CSinglePropSheetDlg, CTreePropSheet)\r
+\r
+CSinglePropSheetDlg::CSinglePropSheetDlg(const TCHAR* szCaption, ISettingsPropPage* pThePropPage, CWnd* pParent /*=NULL*/)\r
+:      CTreePropSheet(szCaption,pParent),// CSinglePropSheetDlg::IDD, pParent),\r
+       m_pThePropPage(pThePropPage)\r
+{\r
+       AddPropPages();\r
+}\r
+\r
+CSinglePropSheetDlg::~CSinglePropSheetDlg()\r
+{\r
+       RemovePropPages();\r
+}\r
+\r
+void CSinglePropSheetDlg::AddPropPages()\r
+{\r
+       SetPageIcon(m_pThePropPage, m_pThePropPage->GetIconID());\r
+       AddPage(m_pThePropPage);\r
+}\r
+\r
+void CSinglePropSheetDlg::RemovePropPages()\r
+{\r
+       delete m_pThePropPage;\r
+}\r
+\r
+void CSinglePropSheetDlg::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       CTreePropSheet::DoDataExchange(pDX);\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CSinglePropSheetDlg, CTreePropSheet)\r
+END_MESSAGE_MAP()\r
+\r
+\r
+// CSinglePropSheetDlg message handlers\r
+\r
+BOOL CSinglePropSheetDlg::OnInitDialog()\r
+{\r
+       BOOL bReturn = CTreePropSheet::OnInitDialog();\r
+       \r
+//     CRect clientRect;\r
+//     GetClientRect(&clientRect);\r
+//     clientRect.DeflateRect(10,10,10,10);\r
+//     m_pThePropPage->Create(m_pThePropPage->m_lpszTemplateName,this);\r
+//     m_pThePropPage->MoveWindow(clientRect);\r
+\r
+\r
+       CenterWindow(CWnd::FromHandle(hWndExplorer));\r
+\r
+       return bReturn;\r
+}\r
diff --git a/src/TortoiseProc/SinglePropSheetDlg.h b/src/TortoiseProc/SinglePropSheetDlg.h
new file mode 100644 (file)
index 0000000..c76a844
--- /dev/null
@@ -0,0 +1,27 @@
+#pragma once\r
+\r
+#include "Settings/SettingsPropPage.h"\r
+#include "TreePropSheet/TreePropSheet.h"\r
+\r
+class CSinglePropSheetDlg : public TreePropSheet::CTreePropSheet\r
+{\r
+       DECLARE_DYNAMIC(CSinglePropSheetDlg)\r
+\r
+public:\r
+       CSinglePropSheetDlg(const TCHAR* szCaption, ISettingsPropPage* pThePropPage, CWnd* pParent = NULL);   // standard constructor\r
+       virtual ~CSinglePropSheetDlg();\r
+\r
+       void AddPropPages();\r
+       void RemovePropPages();\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+\r
+       DECLARE_MESSAGE_MAP()\r
+\r
+private:\r
+       ISettingsPropPage*      m_pThePropPage;\r
+\r
+public:\r
+       virtual BOOL OnInitDialog();\r
+};\r
index eef9e2a..3c9f927 100644 (file)
                                RelativePath="..\TortoiseShell\resource.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath=".\SinglePropSheetDlg.cpp"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath=".\SinglePropSheetDlg.h"\r
+                               >\r
+                       </File>\r
                        <Filter\r
                                Name="General"\r
                                >\r