>From 2fa6c620ed5173578a9a8210e30cad233f50b399 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Wed, 11 Jan 2012 03:51:14 +0300
Subject: [PATCH 2/6] Get rid of menu enabling helper

---
 dlls/shell32/shlview_cmenu.c |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c
index 3bcf701..3c3f369 100644
--- a/dlls/shell32/shlview_cmenu.c
+++ b/dlls/shell32/shlview_cmenu.c
@@ -66,20 +66,6 @@ static inline ContextMenu *impl_from_IContextMenu2(IContextMenu2 *iface)
     return CONTAINING_RECORD(iface, ContextMenu, IContextMenu2_iface);
 }
 
-static BOOL ItemMenu_CanRenameItems(ContextMenu *This)
-{
-    DWORD attr;
-
-    TRACE("(%p)\n", This);
-
-    /* can't rename more than one item at a time*/
-    if (!This->apidl || This->cidl > 1) return FALSE;
-
-    attr = SFGAO_CANRENAME;
-    IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
-    return attr & SFGAO_CANRENAME;
-}
-
 static HRESULT WINAPI ItemMenu_QueryInterface(IContextMenu2 *iface, REFIID riid, LPVOID *ppvObj)
 {
     ContextMenu *This = impl_from_IContextMenu2(iface);
@@ -189,7 +175,22 @@ static HRESULT WINAPI ItemMenu_QueryContextMenu(
         if(uFlags & ~CMF_CANRENAME)
             RemoveMenu(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND);
         else
-            EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, MF_BYCOMMAND | ItemMenu_CanRenameItems(This) ? MFS_ENABLED : MFS_DISABLED);
+        {
+            UINT enable = MF_BYCOMMAND;
+
+            /* can't rename more than one item at a time*/
+            if (!This->apidl || This->cidl > 1)
+                enable |= MFS_DISABLED;
+            else
+            {
+                DWORD attr = SFGAO_CANRENAME;
+
+                IShellFolder_GetAttributesOf(This->parent, 1, (LPCITEMIDLIST*)This->apidl, &attr);
+                enable |= (attr & SFGAO_CANRENAME) ? MFS_ENABLED : MFS_DISABLED;
+            }
+
+            EnableMenuItem(hmenu, FCIDM_SHVIEW_RENAME, enable);
+        }
 
         return MAKE_HRESULT(SEVERITY_SUCCESS, 0, uIDMax-idCmdFirst);
     }
-- 
1.5.6.5


