Changeset 7b0b3f373832…
Parent 6cd590e11b58…
by
Changes to 2 files · Browse files at 7b0b3f373832 Showing diff from parent 6cd590e11b58 Diff from another changeset...
|
|
@@ -12,24 +12,12 @@
#include "Msi.h"
-#include <map>
-
#include "CShellExtCMenu.h"
-
-struct MenuDescription
-{
- std::string name;
- std::wstring menuText;
- std::wstring helpText;
- std::string iconName;
- UINT idCmd;
-};
-
// According to http://msdn.microsoft.com/en-us/library/bb776094%28VS.85%29.aspx
// the help texts for the commands should be reasonably short (under 40 characters)
-MenuDescription menuDescList[] =
+static MenuDescription CMenuMenuDescList[] =
{
{"commit", L"Commit...",
L"Commit changes in repository",
@@ -110,7 +98,7 @@ //{"", L"", L"", ".ico", 0},
};
-const char* const RepoNoFilesMenu =
+static const char* const RepoNoFilesMenu =
"commit status shelve vdiff sep"
" add revert rename forget remove sep"
" workbench update grep sep"
@@ -120,31 +108,29 @@ " about"
;
-const char* const RepoFilesMenu =
+static const char* const RepoFilesMenu =
"commit status vdiff sep"
" add revert rename forget remove sep"
" log sep"
" about"
;
-const char* const NoRepoMenu =
+static const char* const NoRepoMenu =
"clone init shellconf userconf thgstatus sep"
" workbench sep"
" about"
;
-typedef std::map<std::string, MenuDescription> MenuDescriptionMap;
typedef std::map<UINT, MenuDescription> MenuIdCmdMap;
-MenuDescriptionMap MenuDescMap;
-MenuIdCmdMap MenuIdMap;
+static MenuDescriptionMap CMenuMenuDescMap;
+static MenuIdCmdMap MenuIdMap;
-
-void AddMenuList(UINT idCmd, const std::string& name)
+void AddMenuList(UINT idCmd, const std::string& name, MenuDescriptionMap& menuDescMap)
{
TDEBUG_TRACE("AddMenuList: idCmd = " << idCmd << " name = " << name);
- MenuIdMap[idCmd] = MenuDescMap[name];
+ MenuIdMap[idCmd] = menuDescMap[name];
}
@@ -183,18 +169,22 @@ RegCloseKey(hkey);
}
+MenuDescriptionMap& CShellExtCMenu::GetMenuDescriptionMap()
+{
+ return CMenuMenuDescMap;
+}
-void InitMenuMaps()
+void CShellExtCMenu::InitMenuMaps(MenuDescription *menuDescs, std::size_t sz)
{
- if (MenuDescMap.empty())
+ MenuDescriptionMap& menuDescMap = GetMenuDescriptionMap();
+ if (menuDescMap.empty())
{
std::string lang;
GetRegistryConfig("CMenuLang", lang);
- std::size_t sz = sizeof(menuDescList) / sizeof(MenuDescription);
for (std::size_t i = 0; i < sz; i++)
{
- MenuDescription md = menuDescList[i];
+ MenuDescription md = menuDescs[i];
if (md.name.empty())
{
@@ -208,8 +198,9 @@ if (!lang.empty())
GetCMenuTranslation(lang, md.name, md.menuText, md.helpText);
- MenuDescMap[md.name] = md;
+ menuDescMap[md.name] = md;
}
+
}
MenuIdMap.clear();
@@ -314,19 +305,23 @@}
-void InsertMenuItemByName(
+void CShellExtCMenu::InsertMenuItemByName(
HMENU hMenu, const std::string& name, UINT indexMenu,
UINT idCmd, UINT idCmdFirst, const std::wstring& prefix)
{
- MenuDescriptionMap::iterator iter = MenuDescMap.find(name);
- if (iter == MenuDescMap.end())
+
+ MenuDescriptionMap& menuDescMap = GetMenuDescriptionMap();
+
+ MenuDescriptionMap::iterator iter = menuDescMap.find(name);
+ if (iter == menuDescMap.end())
{
TDEBUG_TRACE("***** InsertMenuItemByName: can't find menu info for " << name);
return;
}
+
MenuDescription md = iter->second;
- AddMenuList(idCmd - idCmdFirst, name);
+ AddMenuList(idCmd - idCmdFirst, name, menuDescMap);
InsertMenuItemWithIcon1(
hMenu, indexMenu, idCmd, prefix + md.menuText, md.iconName);
}
@@ -442,7 +437,7 @@ return S_OK;
}
- InitMenuMaps();
+ InitMenuMaps(CMenuMenuDescList, sizeof(CMenuMenuDescList) / sizeof(MenuDescription));
typedef std::vector<std::string> entriesT;
typedef entriesT::const_iterator entriesIter;
@@ -883,12 +878,8 @@ InitStatus::check();
}
-
-STDMETHODIMP CShellExtCMenu::Initialize(
- LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey)
+void CShellExtCMenu::PrintDebugHeader(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj)
{
- TCHAR name[MAX_PATH+1];
-
TDEBUG_TRACE("CShellExtCMenu::Initialize");
// get installed MSI product id (for debugging purposes for now)
@@ -923,6 +914,14 @@
TDEBUG_TRACE(" pIDFolder: " << pIDFolder);
TDEBUG_TRACE(" pDataObj: " << pDataObj);
+}
+
+STDMETHODIMP CShellExtCMenu::Initialize(
+ LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hRegKey)
+{
+ TCHAR name[MAX_PATH+1];
+
+ PrintDebugHeader(pIDFolder, pDataObj);
myFolder.clear();
myFiles.clear();
@@ -984,8 +983,7 @@}
-CShellExtCMenu::CShellExtCMenu(char dummy) :
- m_ppszFileUserClickedOn(0)
+CShellExtCMenu::CShellExtCMenu(const char dummy)
{
m_cRef = 0L;
CShellExt::IncDllRef();
|
@@ -3,21 +3,39 @@
#include <vector>
#include <string>
+#include <map>
+struct MenuDescription
+{
+ std::string name;
+ std::wstring menuText;
+ std::wstring helpText;
+ std::string iconName;
+ UINT idCmd;
+};
+
+typedef std::map<std::string, MenuDescription> MenuDescriptionMap;
class CShellExtCMenu: public IContextMenu3, IShellExtInit
{
+
+protected:
ULONG m_cRef;
-
- LPTSTR* m_ppszFileUserClickedOn; // [MAX_PATH]
std::vector<std::string> myFiles;
std::string myFolder;
- void RunDialog(const std::string&);
+ virtual void RunDialog(const std::string&);
+ virtual MenuDescriptionMap& GetMenuDescriptionMap();
+
void TweakMenuForVista(HMENU menu);
+ void PrintDebugHeader(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj);
+ void InitMenuMaps(MenuDescription *menuDescs, std::size_t sz);
+ void InsertMenuItemByName(
+ HMENU hMenu, const std::string& name, UINT indexMenu,
+ UINT idCmd, UINT idCmdFirst, const std::wstring& prefix);
public:
- explicit CShellExtCMenu(char dummy);
+ explicit CShellExtCMenu(const char dummy);
~CShellExtCMenu();
// IUnknown
|
Loading...