Vincent Povirk : explorer: Hide empty folders in the start menu.
Alexandre Julliard
julliard at winehq.org
Tue Jun 7 11:08:16 CDT 2016
Module: wine
Branch: master
Commit: 8006fd41f0fe495ccbec69d33f6e36d580dcb70c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8006fd41f0fe495ccbec69d33f6e36d580dcb70c
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Mon Jun 6 13:53:38 2016 -0500
explorer: Hide empty folders in the start menu.
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/explorer/startmenu.c | 61 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 59 insertions(+), 2 deletions(-)
diff --git a/programs/explorer/startmenu.c b/programs/explorer/startmenu.c
index e9c651b..15bb7b5 100644
--- a/programs/explorer/startmenu.c
+++ b/programs/explorer/startmenu.c
@@ -131,6 +131,50 @@ static HRESULT pidl_to_shellfolder(LPITEMIDLIST pidl, LPWSTR *displayname, IShel
return hr;
}
+static BOOL shell_folder_is_empty(IShellFolder* folder)
+{
+ IEnumIDList* enumidl;
+ LPITEMIDLIST pidl=NULL;
+
+ if (IShellFolder_EnumObjects(folder, NULL, SHCONTF_NONFOLDERS, &enumidl) == S_OK)
+ {
+ if (IEnumIDList_Next(enumidl, 1, &pidl, NULL) == S_OK)
+ {
+ CoTaskMemFree(pidl);
+ IEnumIDList_Release(enumidl);
+ return FALSE;
+ }
+
+ IEnumIDList_Release(enumidl);
+ }
+
+ if (IShellFolder_EnumObjects(folder, NULL, SHCONTF_FOLDERS, &enumidl) == S_OK)
+ {
+ BOOL found = FALSE;
+ IShellFolder *child_folder;
+
+ while (!found && IEnumIDList_Next(enumidl, 1, &pidl, NULL) == S_OK)
+ {
+ if (IShellFolder_BindToObject(folder, pidl, NULL, &IID_IShellFolder, (void *)&child_folder) == S_OK)
+ {
+ if (!shell_folder_is_empty(child_folder))
+ found = TRUE;
+
+ IShellFolder_Release(child_folder);
+ }
+
+ CoTaskMemFree(pidl);
+ }
+
+ IEnumIDList_Release(enumidl);
+
+ if (found)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* add an individual file or folder to the menu, takes ownership of pidl */
static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST pidl)
{
@@ -161,6 +205,15 @@ static struct menu_item* add_shell_item(struct menu_item* parent, LPITEMIDLIST p
IShellFolder_BindToObject(parent->folder, pidl, NULL, &IID_IShellFolder, (void *)&item->folder);
}
+ if (item->folder && shell_folder_is_empty(item->folder))
+ {
+ IShellFolder_Release(item->folder);
+ HeapFree(GetProcessHeap(), 0, item->displayname);
+ HeapFree(GetProcessHeap(), 0, item);
+ CoTaskMemFree(pidl);
+ return NULL;
+ }
+
parent_menu = parent->menuhandle;
item->parent = parent;
@@ -411,9 +464,13 @@ void do_startmenu(HWND hwnd)
if (!public_startmenu.folder)
pidl_to_shellfolder(public_startmenu.pidl, NULL, &public_startmenu.folder);
- fill_menu(&user_startmenu);
+ if (!shell_folder_is_empty(user_startmenu.folder) ||
+ !shell_folder_is_empty(public_startmenu.folder))
+ {
+ fill_menu(&user_startmenu);
- AppendMenuW(root_menu.menuhandle, MF_SEPARATOR, 0, NULL);
+ AppendMenuW(root_menu.menuhandle, MF_SEPARATOR, 0, NULL);
+ }
if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl)))
add_shell_item(&root_menu, pidl);
More information about the wine-cvs
mailing list