Permalink
Browse files

Attempt to execute git-gui from the context menu.

There is still an issue with the current working directory.
Need to investigate how to set the current working directory to the
directory being displayed by Explorer.

Signed-off-by: Brian Hetro <whee@smaertness.net>
  • Loading branch information...
1 parent ee04808 commit ab190237cc9a4174fd972b2cd1ed7f4f18ba2c07 @whee whee committed Aug 5, 2007
Showing with 103 additions and 14 deletions.
  1. +1 −1 Makefile
  2. +2 −1 NOTES
  3. +0 −1 ext.h
  4. +5 −0 install.reg
  5. +45 −11 menu.c
  6. +39 −0 systeminfo.c
  7. +9 −0 systeminfo.h
  8. +2 −0 uninstall.reg
View
2 Makefile
@@ -1,4 +1,4 @@
-OBJECTS=ext.o debug.o dll.o factory.o menu.o
+OBJECTS=ext.o debug.o dll.o factory.o menu.o systeminfo.o
CFLAGS=-O -g
all: git_shell_ext.dll
View
3 NOTES
@@ -5,7 +5,8 @@
<2007-08-05 Sun>
** TODO Move context menu item up a bit. Sorting is off.
** TODO Generate registry installation/uninstallation entries during build.
- Need to not hard-code the dll path, at least.
+ Need to not hard-code the dll path, at least. PathToMsys also
+ needs to be determined.
* Mid-term tasks
** TODO Flesh out menu items provided to the user.
* Long-term tasks
View
1 ext.h
@@ -90,5 +90,4 @@ inline STDMETHODIMP initialize_git_data(struct git_data *this_,
LPCITEMIDLIST folder,
LPDATAOBJECT data, HKEY id);
-
#endif /* EXT_H */
View
5 install.reg
@@ -5,6 +5,11 @@ Windows Registry Editor Version 5.00
;
; This file is slated for being generated and not hard-coded.
+[HKEY_LOCAL_MACHINE\SOFTWARE\Git-Cheetah]
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Git-Cheetah]
+"PathToMsys"="C:\\msysGit"
+
[HKEY_CLASSES_ROOT\CLSID\{ca586c80-7c84-4b88-8537-726724df6929}]
[HKEY_CLASSES_ROOT\CLSID\{ca586c80-7c84-4b88-8537-726724df6929}]
View
56 menu.c
@@ -3,13 +3,16 @@
#include <tchar.h>
#include "menu.h"
#include "ext.h"
+#include "debug.h"
+#include "systeminfo.h"
/*
* These are the functions for handling the context menu.
*/
static STDMETHODIMP query_context_menu(void *p, HMENU menu,
- UINT index, UINT first_command, UINT last_command, UINT flags)
+ UINT index, UINT first_command,
+ UINT last_command, UINT flags)
{
struct git_menu *this_menu = p;
struct git_data *this_ = this_menu->git_data;
@@ -18,13 +21,13 @@ static STDMETHODIMP query_context_menu(void *p, HMENU menu,
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 0);
InsertMenu(menu, index, MF_STRING | MF_BYPOSITION,
- first_command, _T("SimpleShlExt Test Item"));
+ first_command, _T("Git Gui"));
return MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_NULL, 1);
}
static STDMETHODIMP invoke_command(void *p,
- LPCMINVOKECOMMANDINFO info)
+ LPCMINVOKECOMMANDINFO info)
{
struct git_menu *this_menu = p;
struct git_data *this_ = this_menu->git_data;
@@ -33,21 +36,52 @@ static STDMETHODIMP invoke_command(void *p,
if (HIWORD(info->lpVerb) != 0)
return E_INVALIDARG;
- if (command == 0) {
- TCHAR msg[MAX_PATH + 32];
-
- wsprintf(msg, _T("The selected file was:\n\n%s"), this_->name);
- MessageBox(info->hwnd, msg, _T("SimpleShlExt"),
- MB_ICONINFORMATION);
-
+ if (command == 0)
+ {
+ STARTUPINFO si = { sizeof(si) };
+ PROCESS_INFORMATION pi;
+
+ TCHAR * msysPath = msys_path();
+
+ if (msysPath)
+ {
+ TCHAR command[1024];
+ wsprintf(command, TEXT("sh.exe %s\\bin\\git-gui"),
+ msysPath);
+
+ if (CreateProcess(
+ NULL,
+ command,
+ NULL,
+ NULL,
+ FALSE,
+ 0, NULL, NULL, &si, &pi))
+ {
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+ }
+ else
+ {
+ debug_git("[ERROR] %s/%s:%d Could not create git gui process (%d)",
+ __FILE__, __FUNCTION__, __LINE__,
+ GetLastError());
+ }
+ }
+ else
+ {
+ debug_git("[ERROR] %s/%s:%d Could not find msysPath",
+ __FILE__, __FUNCTION__, __LINE__);
+ }
+
return S_OK;
}
return E_INVALIDARG;
}
static STDMETHODIMP get_command_string(void *p, UINT id,
- UINT flags, UINT *reserved, LPSTR name, UINT size)
+ UINT flags, UINT *reserved,
+ LPSTR name, UINT size)
{
struct git_menu *this_menu = p;
struct git_data *this_ = this_menu->git_data;
View
39 systeminfo.c
@@ -0,0 +1,39 @@
+#include <windows.h>
+#include "systeminfo.h"
+
+static TCHAR msysPath[MAX_PATH];
+
+TCHAR * msys_path(void)
+{
+ static int found_path = 0;
+ HKEY hKey;
+ LONG lRet;
+
+ /* Only bother to get it once. */
+ if (found_path)
+ return msysPath;
+
+ lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
+ TEXT(GIT_CHEETAH_REG_PATH),
+ 0, KEY_QUERY_VALUE, &hKey);
+
+ if (lRet == ERROR_SUCCESS)
+ {
+ DWORD msysPathLen = MAX_PATH * sizeof(TCHAR);
+
+ lRet = RegQueryValueEx(hKey,
+ TEXT(GIT_CHEETAH_REG_PATHTOMSYS),
+ NULL, NULL,
+ (LPBYTE)msysPath,
+ &msysPathLen);
+ RegCloseKey(hKey);
+
+ if (lRet == ERROR_SUCCESS)
+ {
+ found_path = 1;
+ return msysPath;
+ }
+ }
+
+ return NULL;
+}
View
9 systeminfo.h
@@ -0,0 +1,9 @@
+#ifndef SYSTEMINFO_H
+#define SYSTEMINFO_H
+
+#define GIT_CHEETAH_REG_PATH "SOFTWARE\\Git-Cheetah"
+#define GIT_CHEETAH_REG_PATHTOMSYS "PathToMsys"
+
+TCHAR * msys_path(void);
+
+#endif /* SYSTEMINFO_H */
View
2 uninstall.reg
@@ -5,6 +5,8 @@ Windows Registry Editor Version 5.00
;
; This file is slated for being generated and not hard-coded.
+[-HKEY_LOCAL_MACHINE\SOFTWARE\Git-Cheetah]
+
[-HKEY_CLASSES_ROOT\CLSID\{ca586c80-7c84-4b88-8537-726724df6929}]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]

0 comments on commit ab19023

Please sign in to comment.