OSDN Git Service

Add Ext menu config at setting dialog to set menu item to external
authorFrank Li <lznuaa@gmail.com>
Sat, 23 Jan 2010 07:55:03 +0000 (15:55 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 23 Jan 2010 07:55:03 +0000 (15:55 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/Settings/SetExtMenu.h [new file with mode: 0644]
src/TortoiseProc/Settings/SetLookAndFeelPage.cpp
src/TortoiseProc/Settings/SetLookAndFeelPage.h
src/TortoiseProc/Settings/Settings.cpp
src/TortoiseProc/Settings/Settings.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseShell/ShellCache.h

index 01d8be1..e3d5d63 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
diff --git a/src/TortoiseProc/Settings/SetExtMenu.h b/src/TortoiseProc/Settings/SetExtMenu.h
new file mode 100644 (file)
index 0000000..649ca7f
--- /dev/null
@@ -0,0 +1,84 @@
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2008 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+#include "resource.h"\r
+#include "StandAloneDlg.h"\r
+\r
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2008 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+#include "resource.h"\r
+#include "StandAloneDlg.h"\r
+\r
+class CSetExtMenu : public ISettingsPropPage\r
+{\r
+       DECLARE_DYNAMIC(CSetExtMenu)\r
+\r
+public:\r
+       CSetExtMenu();\r
+       virtual ~CSetExtMenu();\r
+\r
+       UINT GetIconID() {return IDI_MISC;}\r
+\r
+// Dialog Data\r
+       enum { IDD = IDD_SETTINGSEXTMENU };\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+       virtual BOOL PreTranslateMessage(MSG* pMsg);\r
+       virtual BOOL OnApply();\r
+       afx_msg void OnBnClickedOnlyexplorer();\r
+       afx_msg void OnLvnItemchangedMenulist(NMHDR *pNMHDR, LRESULT *pResult);\r
+       afx_msg void OnChange();\r
+       afx_msg void OnEnChangeNocontextpaths();\r
+\r
+       DECLARE_MESSAGE_MAP()\r
+public:\r
+       virtual BOOL OnInitDialog();\r
+\r
+private:\r
+\r
+       CToolTips                       m_tooltips;\r
+       CRegStdWORD                     m_regExtmenu;\r
+       CRegStdWORD                     m_regExtmenuhigh;\r
+       \r
+       unsigned __int64        m_extmenu;\r
+\r
+       CImageList                      m_imgList;\r
+       CListCtrl                       m_cMenuList;\r
+       BOOL                            m_bModified;\r
+       bool                            m_bBlock;\r
+       \r
+};\r
index a090387..588cf88 100644 (file)
@@ -26,6 +26,7 @@
 #include "MessageBox.h"\r
 #include "XPTheme.h"\r
 #include "MenuInfo.h"\r
+#include "ShellCache.h"\r
 \r
 extern MenuInfo menuInfo[];\r
 \r
@@ -88,8 +89,9 @@ CSetLookAndFeelPage::CSetLookAndFeelPage()
        : ISettingsPropPage(CSetLookAndFeelPage::IDD)\r
        , m_bBlock(false)\r
 {\r
-       m_regTopmenu = CRegDWORD(_T("Software\\TortoiseGit\\ContextMenuEntries"), MENUSYNC|MENUCREATEREPOS|MENUCLONE|MENUCOMMIT);\r
-       m_regTopmenuhigh = CRegDWORD(_T("Software\\TortoiseGit\\ContextMenuEntrieshigh"), (MENUSYNC|MENUCREATEREPOS|MENUCLONE|MENUCOMMIT)>>32);\r
+       ShellCache cache;\r
+       m_regTopmenu = cache.menulayoutlow;\r
+       m_regTopmenuhigh = cache.menulayouthigh;\r
 \r
        m_topmenu = unsigned __int64(DWORD(m_regTopmenuhigh))<<32;\r
        m_topmenu |= unsigned __int64(DWORD(m_regTopmenu));\r
@@ -173,9 +175,11 @@ BOOL CSetLookAndFeelPage::PreTranslateMessage(MSG* pMsg)
 BOOL CSetLookAndFeelPage::OnApply()\r
 {\r
        UpdateData();\r
-    Store ((DWORD)(m_topmenu & 0xFFFFFFFF),    m_regTopmenu);\r
-    Store ((DWORD)(m_topmenu >> 32), m_regTopmenuhigh);\r
 \r
+       m_regTopmenu = m_topmenu & 0xFFFFFFFF;\r
+       m_regTopmenuhigh = (m_topmenu >> 32);\r
+       \r
+       m_regTopmenu.getErrorString();\r
        m_sNoContextPaths.Replace(_T("\r"), _T(""));\r
        if (m_sNoContextPaths.Right(1).Compare(_T("\n"))!=0)\r
                m_sNoContextPaths += _T("\n");\r
@@ -186,20 +190,6 @@ BOOL CSetLookAndFeelPage::OnApply()
        return ISettingsPropPage::OnApply();\r
 }\r
 \r
-void CSetLookAndFeelPage::InsertItem(UINT nTextID, UINT nIconID, unsigned __int64 dwFlags)\r
-{\r
-       HICON hIcon = reinterpret_cast<HICON>(::LoadImage(AfxGetResourceHandle(),\r
-               MAKEINTRESOURCE(nIconID),\r
-               IMAGE_ICON, 16, 16, LR_LOADTRANSPARENT ));\r
-       int nImage = m_imgList.Add(hIcon);\r
-       CString temp;\r
-       temp.LoadString(nTextID);\r
-       CStringUtils::RemoveAccelerators(temp);\r
-       int nIndex = m_cMenuList.GetItemCount();\r
-       m_cMenuList.InsertItem(nIndex, temp, nImage);\r
-       m_cMenuList.SetCheck(nIndex, !!(m_topmenu & dwFlags));\r
-}\r
-\r
 void CSetLookAndFeelPage::OnLvnItemchangedMenulist(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
 {\r
        if (m_bBlock)\r
@@ -222,3 +212,119 @@ void CSetLookAndFeelPage::OnEnChangeNocontextpaths()
        SetModified();\r
 }\r
 \r
+\r
+\r
+// Set Extmenu class\r
+#include "SetExtMenu.h"\r
+\r
+IMPLEMENT_DYNAMIC(CSetExtMenu, ISettingsPropPage)\r
+CSetExtMenu::CSetExtMenu()\r
+       : ISettingsPropPage(CSetExtMenu::IDD)\r
+{\r
+       ShellCache shell;\r
+\r
+       m_regExtmenu = shell.menuextlow;\r
+       m_regExtmenuhigh = shell.menuexthigh;\r
+\r
+       m_extmenu = unsigned __int64(DWORD(m_regExtmenuhigh))<<32;\r
+       m_extmenu |= unsigned __int64(DWORD(m_regExtmenu));\r
+\r
+}\r
+\r
+CSetExtMenu::~CSetExtMenu()\r
+{\r
+}\r
+\r
+void CSetExtMenu::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       ISettingsPropPage::DoDataExchange(pDX);\r
+       DDX_Control(pDX, IDC_MENULIST, m_cMenuList);\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CSetExtMenu, ISettingsPropPage)\r
+       ON_NOTIFY(LVN_ITEMCHANGED, IDC_MENULIST, OnLvnItemchangedMenulist)\r
+       ON_BN_CLICKED(IDC_GETLOCKTOP, OnChange)\r
+END_MESSAGE_MAP()\r
+\r
+\r
+BOOL CSetExtMenu::OnInitDialog()\r
+{\r
+       ISettingsPropPage::OnInitDialog();\r
+\r
+       m_tooltips.Create(this);\r
+       m_tooltips.AddTool(IDC_MENULIST, IDS_SETTINGS_MENULAYOUT_TT);\r
+       //m_tooltips.AddTool(IDC_GETLOCKTOP, IDS_SETTINGS_GETLOCKTOP_TT);\r
+       //m_tooltips.AddTool(IDC_NOCONTEXTPATHS, IDS_SETTINGS_EXCLUDECONTEXTLIST_TT);\r
+\r
+       m_cMenuList.SetExtendedStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);\r
+\r
+       m_cMenuList.DeleteAllItems();\r
+       int c = ((CHeaderCtrl*)(m_cMenuList.GetDlgItem(0)))->GetItemCount()-1;\r
+       while (c>=0)\r
+               m_cMenuList.DeleteColumn(c--);\r
+       m_cMenuList.InsertColumn(0, _T(""));\r
+\r
+       CXPTheme theme;\r
+       theme.SetWindowTheme(m_cMenuList.GetSafeHwnd(), L"Explorer", NULL);\r
+\r
+       m_cMenuList.SetRedraw(false);\r
+\r
+       m_imgList.Create(16, 16, ILC_COLOR16 | ILC_MASK, 4, 1);\r
+\r
+       m_bBlock = true;\r
+\r
+       InsertMenuItemToList(&m_cMenuList,&m_imgList);\r
+       SetMenuItemCheck(&m_cMenuList,m_extmenu);\r
+\r
+       m_bBlock = false;\r
+\r
+       m_cMenuList.SetImageList(&m_imgList, LVSIL_SMALL);\r
+       int mincol = 0;\r
+       int maxcol = ((CHeaderCtrl*)(m_cMenuList.GetDlgItem(0)))->GetItemCount()-1;\r
+       int col;\r
+       for (col = mincol; col <= maxcol; col++)\r
+       {\r
+               m_cMenuList.SetColumnWidth(col,LVSCW_AUTOSIZE_USEHEADER);\r
+       }\r
+       m_cMenuList.SetRedraw(true);\r
+\r
+       UpdateData(FALSE);\r
+\r
+       return TRUE;\r
+}\r
+\r
+BOOL CSetExtMenu::PreTranslateMessage(MSG* pMsg)\r
+{\r
+       m_tooltips.RelayEvent(pMsg);\r
+       return ISettingsPropPage::PreTranslateMessage(pMsg);\r
+}\r
+\r
+BOOL CSetExtMenu::OnApply()\r
+{\r
+       UpdateData();\r
+\r
+       m_regExtmenu = (DWORD)(m_extmenu & 0xFFFFFFFF);\r
+       m_regExtmenuhigh = (DWORD)(m_extmenu >> 32);\r
+\r
+       SetModified(FALSE);\r
+       return ISettingsPropPage::OnApply();\r
+}\r
+\r
+void CSetExtMenu::OnLvnItemchangedMenulist(NMHDR * /*pNMHDR*/, LRESULT *pResult)\r
+{\r
+       if( m_bBlock )\r
+               return;\r
+\r
+       SetModified(TRUE);\r
+       if (m_cMenuList.GetItemCount() > 0)\r
+       {\r
+               m_extmenu = GetMenuListMask(&m_cMenuList);\r
+       }\r
+       *pResult = 0;\r
+}\r
+\r
+void CSetExtMenu::OnChange()\r
+{\r
+       SetModified();\r
+}\r
index 022f625..34cff8e 100644 (file)
@@ -53,11 +53,10 @@ public:
        virtual BOOL OnInitDialog();\r
 \r
 private:\r
-       void InsertItem(UINT nTextID, UINT nIconID, unsigned __int64 dwFlags);\r
 \r
        CToolTips                       m_tooltips;\r
-       CRegDWORD                       m_regTopmenu;\r
-       CRegDWORD                       m_regTopmenuhigh;\r
+       CRegStdWORD                     m_regTopmenu;\r
+       CRegStdWORD                     m_regTopmenuhigh;\r
 \r
        CImageList                      m_imgList;\r
        CListCtrl                       m_cMenuList;\r
index 8ec5c95..bd99c7f 100644 (file)
@@ -50,6 +50,9 @@ void CSettings::AddPropPages()
        m_pProgsMergePage = new CSettingsProgsMerge();\r
        m_pProgsUniDiffPage = new CSettingsProgsUniDiff();\r
        m_pLookAndFeelPage = new CSetLookAndFeelPage();\r
+       \r
+       m_pExtMenu      = new CSetExtMenu();\r
+\r
        m_pDialogsPage = new CSetDialogs();\r
        m_pMiscPage = new CSetMisc();\r
        m_pRevisionGraphPage = new CSettingsRevisionGraph();\r
@@ -67,6 +70,8 @@ void CSettings::AddPropPages()
        m_pBugtraqConfig = new CSettingsBugtraqConfig(m_CmdPath.GetWinPath());\r
 \r
 \r
+       SetPageIcon(m_pExtMenu,m_pExtMenu->GetIconID());\r
+\r
        SetPageIcon(m_pMainPage, m_pMainPage->GetIconID());\r
        SetPageIcon(m_pOverlayPage, m_pOverlayPage->GetIconID());\r
        SetPageIcon(m_pOverlaysPage, m_pOverlaysPage->GetIconID());\r
@@ -101,6 +106,7 @@ void CSettings::AddPropPages()
        AddPage(m_pProgsMergePage);\r
        AddPage(m_pProgsUniDiffPage);\r
        AddPage(m_pLookAndFeelPage);\r
+       AddPage(m_pExtMenu);\r
        AddPage(m_pDialogsPage);\r
        AddPage(m_pMiscPage);\r
        AddPage(m_pRevisionGraphPage);\r
@@ -152,6 +158,7 @@ void CSettings::RemovePropPages()
        delete m_pGitConfig;\r
        delete m_pGitRemote;\r
        delete m_pBugtraqConfig;\r
+       delete m_pExtMenu;\r
 \r
 }\r
 \r
@@ -182,6 +189,7 @@ void CSettings::HandleRestart()
        restart |= m_pGitConfig->GetRestart();\r
        restart |= m_pGitRemote->GetRestart();\r
        restart |= m_pBugTraqPage->GetRestart();\r
+       restart |= m_pExtMenu->GetRestart();\r
 \r
        if (restart & ISettingsPropPage::Restart_System)\r
        {\r
index 5f723ea..2c6b642 100644 (file)
@@ -43,6 +43,7 @@
 #include "SettingGitConfig.h"\r
 #include "SettingGitRemote.h"\r
 #include "SettingsBugtraqConfig.h"\r
+#include "SetExtMenu.h"\r
 \r
 using namespace TreePropSheet;\r
 \r
@@ -93,6 +94,8 @@ private:
        CSettingGitRemote *             m_pGitRemote;\r
        CSettingsBugtraqConfig * m_pBugtraqConfig;\r
 \r
+       CSetExtMenu     *                       m_pExtMenu;\r
+\r
        HICON                                   m_hIcon;\r
 public:\r
        CSettings(UINT nIDCaption,CTGitPath *CmdPath=NULL, CWnd* pParentWnd = NULL, UINT iSelectPage = 0);\r
index 8bc5cbb..6891a7d 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath=".\Commands\SetExtMenu.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\Settings\SetLookAndFeelPage.cpp"\r
                                        >\r
                                </File>\r
index f21884f..aef24ed 100644 (file)
@@ -608,7 +608,7 @@ private:
                BOOL bHasAdminDir;\r
                stdstring sProjectRoot;\r
        };\r
-\r
+public:\r
        CRegStdWORD cachetype;\r
        CRegStdWORD blockstatus;\r
        CRegStdWORD langid;\r