Changeset 1d22d47e0bc5…
Parent 1cccc26df039…
by
Changes to 4 files · Browse files at 1d22d47e0bc5 Showing diff from parent 1cccc26df039 Diff from another changeset...
|
|
@@ -1,61 +1,73 @@ #include "stdafx.h"
#include "ShellExt.h"
#include "TortoiseUtils.h"
-
-#define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
-typedef STDMETHODIMP (CShellExt::*MenuAction)
- (HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam,
- int iShowCmd);
+#include "StringUtils.h"
typedef struct {
std::string name;
std::string menuText;
std::string helpText;
std::string iconName;
- MenuAction action;
int idCmd;
- ULONG flags;
} MenuDescription;
+MenuDescription menuDescList[] = {
+ {"commit", "HG Commit...",
+ "Commit changes in repository",
+ "menucommit.ico", 0},
+ {"status", "View File Status",
+ "Repository status & changes",
+ "menushowchanged.ico", 0},
+ {"shelve", "Shelve Changes",
+ "Shelve or unshelve file changes",
+ "shelve.ico", 0},
+ {"add", "Add Files",
+ "Add files to version control",
+ "menuadd.ico", 0},
+ {"revert", "Revert Files",
+ "Revert file changes",
+ "menurevert.ico", 0},
+ {"remove", "Remove Files",
+ "Remove files from version control",
+ "menudelete.ico", 0},
+ {"log", "View Changelog",
+ "View change history in repository",
+ "menulog.ico", 0},
+ {"synch", "Synchronize",
+ "Synchronize with remote repository",
+ "menusynch.ico", 0},
+ {"serve", "Web Server",
+ "Start web server for this repository",
+ "proxy.ico", 0},
+ {"update", "Update To Revision",
+ "Update working directory",
+ "menucheckout.ico", 0},
+ {"recover", "Recovery...",
+ "General repair and recovery of repository",
+ "general.ico", 0},
+ {"thgstatus", "Update Icons",
+ "Update icons for this repository",
+ "", 0},
+ {"userconf", "Global Settings",
+ "Configure user wide settings",
+ "settings_user.ico", 0},
+ {"repoconf", "Repository Settings",
+ "Configure repository settings",
+ "settings_repo.ico", 0},
+ {"about", "About...",
+ "Show About Dialog",
+ "menuabout.ico", 0},
+
+ // template
+ {"", "", "", ".ico", 0},
+};
+
typedef std::map<std::string, MenuDescription> MenuDescriptionMap;
typedef std::map<int, MenuDescription> MenuIdCmdMap;
-
-MenuDescription menuDescList[] = {
- {"commit", "HG Commit...", "Commit changes in repository",
- "menucommit.ico", &CShellExt::CM_Commit, 0, 0},
- {"status", "View File Status", "Repository status & changes",
- "menushowchanged.ico", &CShellExt::CM_Status, 0, 0},
- {"log", "View Changelog", "View change history in repository",
- "menulog.ico", &CShellExt::CM_Log, 0, 0},
- {"synch", "Synchronize", "Synchronize with remote repository",
- "menusynch.ico", &CShellExt::CM_Synch, 0, 0},
- {"serve", "Web Server", "Start web server for this repository",
- "proxy.ico", &CShellExt::CM_Serve, 0, 0},
- {"update", "Update To Revision", "Update working directory",
- "menucheckout.ico", &CShellExt::CM_Update, 0, 0},
- {"recover", "Recovery...", "General repair and recovery of repositor",
- "general.ico", &CShellExt::CM_Recover, 0, 0},
- {"thgstatus", "Update Icons", "Update icons for this repository",
- "", &CShellExt::CM_thgstatus, 0, 0},
- {"userconf", "Global Settings", "Configure user wide settings",
- "settings_user.ico", &CShellExt::CM_Userconf, 0, 0},
- {"repoconf", "Repository Settings", "Configure settings local to this repository",
- "settings_repo.ico", &CShellExt::CM_Repoconf, 0, 0},
- {"about", "About...", "Show About Dialog",
- "menuabout.ico", &CShellExt::CM_About, 0, 0},
-
- // template
- {"", "", "",
- ".ico", NULL, 0, 0},
-};
-
MenuDescriptionMap MenuDescMap;
MenuIdCmdMap MenuIdMap;
-extern HMENU hSubMenu;
-extern HINSTANCE g_hmodThisDll;
-
void AddMenuList(int idCmd, std::string name)
{
TDEBUG_TRACE("AddMenuList: idCmd = " << idCmd << " name = " << name);
@@ -190,39 +202,42 @@ InsertMenuItemByName(hMenu, "commit", indexMenu++, idCmd++, idCmdFirst);
TDEBUG_TRACE(" CShellExt::QueryContextMenu: adding sub menus");
+
HMENU hSubMenu = CreatePopupMenu();
- int indexSubMenu = 0;
- if(hSubMenu)
+ if (hSubMenu)
{
+ int indexSubMenu = 0;
if (isHgrepo)
{
- InsertMenuItemByName(hSubMenu, "status", indexSubMenu++, idCmd++, idCmdFirst);
+ if (myFiles.empty())
+ {
+ InsertMenuItemByName(hSubMenu, "status", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "shelve", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
+ InsertMenuItemByName(hSubMenu, "log", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
+ InsertMenuItemByName(hSubMenu, "update", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
+ InsertMenuItemByName(hSubMenu, "synch", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "recover", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "serve", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "thgstatus", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
+ }
+ else
+ {
+ InsertMenuItemByName(hSubMenu, "log", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "add", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "revert", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "rename", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenuItemByName(hSubMenu, "remove", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
+ }
+ InsertMenuItemByName(hSubMenu, "repoconf", indexSubMenu++, idCmd++, idCmdFirst);
+ }
- InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION,
- 0, NULL);
- InsertMenuItemByName(hSubMenu, "log", indexSubMenu++, idCmd++, idCmdFirst);
-
- InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION,
- 0, NULL);
- InsertMenuItemByName(hSubMenu, "update", indexSubMenu++, idCmd++, idCmdFirst);
-
- InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION,
- 0, NULL);
- InsertMenuItemByName(hSubMenu, "synch", indexSubMenu++, idCmd++, idCmdFirst);
- InsertMenuItemByName(hSubMenu, "recover", indexSubMenu++, idCmd++, idCmdFirst);
- InsertMenuItemByName(hSubMenu, "serve", indexSubMenu++, idCmd++, idCmdFirst);
- InsertMenuItemByName(hSubMenu, "thgstatus", indexSubMenu++, idCmd++, idCmdFirst);
-
- InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION,
- 0, NULL);
- InsertMenuItemByName(hSubMenu, "userconf", indexSubMenu++, idCmd++, idCmdFirst);
- }
-
- InsertMenuItemByName(hSubMenu, "repoconf", indexSubMenu++, idCmd++, idCmdFirst);
-
- InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION,
- 0, NULL);
-
+ InsertMenuItemByName(hSubMenu, "userconf", indexSubMenu++, idCmd++, idCmdFirst);
+ InsertMenu(hSubMenu, indexSubMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);
InsertMenuItemByName(hSubMenu, "about", indexSubMenu++, idCmd++, idCmdFirst);
}
@@ -248,9 +263,8 @@ MenuIdCmdMap::iterator iter = MenuIdMap.find(idCmd);
if(iter != MenuIdMap.end())
{
- MenuAction action = MenuIdMap[idCmd].action;
- hr = CALL_MEMBER_FN(*this, action)(lpcmi->hwnd, lpcmi->lpDirectory,
- lpcmi->lpVerb, lpcmi->lpParameters, lpcmi->nShow);
+ DoHgtk(MenuIdMap[idCmd].name);
+ hr = NOERROR;
}
else
{
@@ -335,3 +349,52 @@
return NOERROR;
}
+
+void CShellExt::DoHgtk(const std::string &cmd)
+{
+ std::string dir = GetTHgProgRoot();
+ if (dir.empty())
+ {
+ TDEBUG_TRACE("DoHgtk: THG root is empty");
+ return;
+ }
+ std::string hgcmd = Quote(dir + "\\hgtk.exe") + " " + cmd;
+
+ std::string cwd;
+ if (!myFolder.empty())
+ {
+ cwd = myFolder;
+ }
+ else if (!myFiles.empty())
+ {
+ cwd = IsDirectory(myFiles[0])? myFiles[0] : DirName(myFiles[0]);
+
+ std::string tempfile = GetTemporaryFile();
+ SECURITY_ATTRIBUTES sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.nLength = sizeof(sa);
+ sa.bInheritHandle = TRUE;
+
+ TDEBUG_TRACE("DoHgtk: temp file = " << tempfile);
+ HANDLE tempfileHandle = CreateFileA(tempfile.c_str(), GENERIC_WRITE,
+ FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
+
+ for (int i=0; i<myFiles.size(); i++)
+ {
+ DWORD dwWritten;
+ TDEBUG_TRACE("DoHgtk: temp file adding " << myFiles[i]);
+ WriteFile(tempfileHandle, myFiles[i].c_str(),
+ static_cast<DWORD>(myFiles[i].size()), &dwWritten, 0);
+ WriteFile(tempfileHandle, "\n", 1, &dwWritten, 0);
+ }
+ CloseHandle(tempfileHandle);
+ hgcmd += " --listfile " + Quote(tempfile);
+ }
+ else
+ {
+ TDEBUG_TRACE("DoHgtk: can't get cwd");
+ return;
+ }
+
+ LaunchCommand(hgcmd, cwd);
+}
|
@@ -7,7 +7,6 @@ OBJECTS_THGSGELL = $(OBJECTS_DIRSTATE) \
ContextMenu.o \
IconOverlay.o \
- MenuActions.o \
ShellExt.o \
PipeUtils.o \
ShellUtils2.o \
|
|
|
@@ -1,145 +0,0 @@ - #include "stdafx.h"
-#include "ShellExt.h"
-#include "TortoiseUtils.h"
-#include "StringUtils.h"
-
-#include <stdio.h>
-#include <vector>
-
-void CShellExt::DoHgProc(const std::string &cmd)
-{
- std::string dir = GetTHgProgRoot();
- TDEBUG_TRACE("DoHgProc: THG root = " << dir);
- if (dir.empty())
- {
- TDEBUG_TRACE("DoHgProc: THG root is empty");
- return;
- }
- std::string hgcmd = Quote(dir + "\\hgtk.exe") + " " + cmd;
-
- std::string cwd;
- if (!myFolder.empty())
- {
- cwd = myFolder;
- }
- else if (!myFiles.empty())
- {
- cwd = IsDirectory(myFiles[0])? myFiles[0] : DirName(myFiles[0]);
-
- std::string tempfile = GetTemporaryFile();
- SECURITY_ATTRIBUTES sa;
- memset(&sa, 0, sizeof(sa));
- sa.nLength = sizeof(sa);
- sa.bInheritHandle = TRUE;
-
- TDEBUG_TRACE("DoHgProc: temp file = " << tempfile);
- HANDLE tempfileHandle = CreateFileA(tempfile.c_str(), GENERIC_WRITE,
- FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
-
- for (int i=0; i<myFiles.size(); i++)
- {
- DWORD dwWritten;
- TDEBUG_TRACE("DoHgProc: temp file adding " << myFiles[i]);
- WriteFile(tempfileHandle, myFiles[i].c_str(),
- static_cast<DWORD>(myFiles[i].size()), &dwWritten, 0);
- WriteFile(tempfileHandle, "\n", 1, &dwWritten, 0);
- }
- CloseHandle(tempfileHandle);
- hgcmd += " --listfile " + Quote(tempfile);
- }
- else
- {
- TDEBUG_TRACE("DoHgProc: can't get cwd");
- return;
- }
-
- LaunchCommand(hgcmd, cwd);
-}
-
-STDMETHODIMP
-CShellExt::CM_Commit(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("commit");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Status(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("status");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Log(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("log");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_About(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("about");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Synch(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("synch");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Serve(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("serve");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Update(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("update");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Recover(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("recovery");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Userconf(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("userconfig");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_Repoconf(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("repoconfig");
- return NOERROR;
-}
-
-STDMETHODIMP
-CShellExt::CM_thgstatus(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd,
- LPCSTR pszParam, int iShowCmd)
-{
- DoHgProc("thgstatus");
- return NOERROR;
-}
|
@@ -65,25 +65,9 @@ LPTSTR *m_ppszFileUserClickedOn; // [MAX_PATH]
std::vector<std::string> myFiles;
std::string myFolder;
-
- protected:
- void CShellExt::DoHgProc(const std::string &);
+ void CShellExt::DoHgtk(const std::string &);
public:
- // context menu actions
- STDMETHODIMP CM_Commit(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Status(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Log(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_About(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Serve(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Synch(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Update(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Recover(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Userconf(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_Repoconf(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
- STDMETHODIMP CM_thgstatus(HWND hParent, LPCSTR pszWorkingDir, LPCSTR pszCmd, LPCSTR pszParam, int iShowCmd);
-
- public:
CShellExt(TortoiseOLEClass);
~CShellExt();
|
Loading...