On 06.01.2010 09:47, John Sparrow wrote:
> 
> Did the HG / Hg patch not make it into the stable branch for v0.9.2?

It's still 'HG' in the shell extension context menu in 0.9.2-1.

I started working on
http://bitbucket.org/tortoisehg/stable/issue/154/ctx-menu-appearing-twice
and changed HG to Hg for the cmenu en passant.

So the state of this is: "in queue".

Current state of my patch queue for the stable branch (not yet ready for
pushing) is:

<patch 1>
shellext: use 'Hg' ui string instead of 'HG' in cmenu


diff --git a/win32/shellext/CShellExtCMenu.cpp 
b/win32/shellext/CShellExtCMenu.cpp
--- a/win32/shellext/CShellExtCMenu.cpp
+++ b/win32/shellext/CShellExtCMenu.cpp
@@ -448,7 +448,7 @@ CShellExtCMenu::QueryContextMenu(
         {
             InsertMenuItemByName(
                 hMenu, menuDescList[idx].name, indexMenu++,
-                idCmd++, idCmdFirst, L"HG "
+                idCmd++, idCmdFirst, L"Hg "
             );
         }
     }
@@ -503,7 +503,7 @@ CShellExtCMenu::QueryContextMenu(

     TDEBUG_TRACE("  CShellExtCMenu::QueryContextMenu: adding main THG menu");
     InsertSubMenuItemWithIcon2(hMenu, hSubMenu, indexMenu++, idCmd++,
-            L"TortoiseHG", "hg.ico");
+            L"TortoiseHg", "hg.ico");

     InsertMenu(hMenu, indexMenu++, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);

</patch1>


<patch2>
shellext: detect if thg entries are already in cmenu

fixes #154


diff --git a/win32/shellext/CShellExtCMenu.cpp 
b/win32/shellext/CShellExtCMenu.cpp
--- a/win32/shellext/CShellExtCMenu.cpp
+++ b/win32/shellext/CShellExtCMenu.cpp
@@ -361,6 +361,59 @@ CShellExtCMenu::QueryContextMenu(
     if (!bAppendItems)
         return S_OK;

+    int count = ::GetMenuItemCount(hMenu);
+    if (count == -1)
+    {
+        TDEBUG_TRACE("CShellExtCMenu::QueryContextMenu: GetMenuItemCount 
returned -1");
+        return E_UNEXPECTED;
+    }
+
+    MENUITEMINFOW mii;
+    for (int i = 0; i < count; ++i)
+    {
+        memset(&mii, 0, sizeof(MENUITEMINFOW));
+        mii.cbSize = sizeof(MENUITEMINFOW);
+
+        // first GetMenuItemInfoW call: get size of menu item string
+        mii.fMask = MIIM_STRING;
+        BOOL res = ::GetMenuItemInfoW(hMenu, i, true, &mii);
+        if (res == 0) {
+            TDEBUG_TRACE("CShellExtCMenu::QueryContextMenu: "
+                << "first GetMenuItemInfo returned 0");
+            continue;
+        }
+
+        if (mii.dwTypeData != MFT_STRING)
+        {
+            // not a string
+            continue;
+        }
+
+        // allocate buffer for the string
+        std::vector<wchar_t> text(mii.cch + 1);
+
+        // second GetMenuItemInfoW call: get string into buffer
+        mii.dwTypeData = &text[0];
+        ++mii.cch; // size of buffer is one more than length of string
+        res = ::GetMenuItemInfoW(hMenu, i, true, &mii);
+        if (res == 0) {
+            TDEBUG_TRACE("CShellExtCMenu::QueryContextMenu: "
+                << "second GetMenuItemInfo returned 0");
+            continue;
+        }
+
+        const std::wstring menuitemtext(&text[0]);
+        TDEBUG_TRACEW(L"CShellExtCMenu::QueryContextMenu: "
+            << L"menuitemtext is '" << menuitemtext << L"'");
+
+        if (menuitemtext == L"TortoiseHg")
+        {
+            TDEBUG_TRACE("CShellExtCMenu::QueryContextMenu: "
+                << "TortoiseHg menu entry already in menu -> skipping");
+            return S_OK;
+        }
+    }
+
     const std::size_t sz = sizeof(menuDescList) / sizeof(MenuDescription);
     bool promoted[sz];
     memset(&promoted, 0, sizeof(promoted));
</patch2>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Tortoisehg-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-discuss

Reply via email to