Author: akhaldi
Date: Thu Dec 19 11:44:30 2013
New Revision: 61293
URL:
http://svn.reactos.org/svn/reactos?rev=61293&view=rev
Log:
[SHELL32]
* Make the Recycle Bin icon reflect whether the bin is empty or not. Brought to you by Huw
Campbell.
CORE-3712 #resolve #comment Committed in r61293. Cheers ;)
Modified:
trunk/reactos/dll/win32/shell32/classes.cpp
trunk/reactos/dll/win32/shell32/folders.cpp
trunk/reactos/dll/win32/shell32/res/rgs/recyclebin.rgs
trunk/reactos/dll/win32/shell32/shell32_main.cpp
trunk/reactos/dll/win32/shell32/shell32_main.h
Modified: trunk/reactos/dll/win32/shell32/classes.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/classes.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/classes.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/classes.cpp [iso-8859-1] Thu Dec 19 11:44:30 2013
@@ -188,11 +188,6 @@
return ret;
}
-/***************************************************************************************
-* HCR_GetDefaultIcon [internal]
-*
-* Gets the icon for a filetype
-*/
static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
{
WCHAR xriid[50];
@@ -206,13 +201,18 @@
return (RegOpenKeyExW(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey) ==
ERROR_SUCCESS);
}
-static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, int* picon_idx)
+/***************************************************************************************
+* HCR_GetIcon [internal]
+*
+* Gets the icon for a filetype, szName can be NULL, in which case the default icon is
loaded
+*/
+static BOOL HCR_RegGetIconW(HKEY hkey, LPWSTR szDest, LPWSTR szName, DWORD len, int*
picon_idx)
{
DWORD dwType;
WCHAR sTemp[MAX_PATH];
WCHAR sNum[7];
- if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
+ if (!RegQueryValueExW(hkey, szName, 0, &dwType, (LPBYTE)szDest, &len))
{
if (dwType == REG_EXPAND_SZ)
{
@@ -230,13 +230,13 @@
return FALSE;
}
-static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, int* picon_idx)
+static BOOL HCR_RegGetIconA(HKEY hkey, LPSTR szDest, LPSTR szName, DWORD len, int*
picon_idx)
{
DWORD dwType;
char sTemp[MAX_PATH];
char sNum[5];
- if (!RegQueryValueExA(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
+ if (!RegQueryValueExA(hkey, szName, 0, &dwType, (LPBYTE)szDest, &len))
{
if (dwType == REG_EXPAND_SZ)
{
@@ -254,7 +254,7 @@
return FALSE;
}
-BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx)
+BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPWSTR szName, DWORD len, int*
picon_idx)
{
static const WCHAR swDefaultIcon[] = L"\\DefaultIcon";
HKEY hKey;
@@ -268,7 +268,7 @@
if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hKey))
{
- ret = HCR_RegGetDefaultIconW(hKey, szDest, len, picon_idx);
+ ret = HCR_RegGetIconW(hKey, szDest, szName, len, picon_idx);
RegCloseKey(hKey);
}
@@ -280,7 +280,7 @@
return ret;
}
-BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx)
+BOOL HCR_GetIconA(LPCSTR szClass, LPSTR szDest, LPSTR szName, DWORD len, int* picon_idx)
{
HKEY hKey;
char sTemp[MAX_PATH];
@@ -292,21 +292,21 @@
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hKey))
{
- ret = HCR_RegGetDefaultIconA(hKey, szDest, len, picon_idx);
+ ret = HCR_RegGetIconA(hKey, szDest, szName, len, picon_idx);
RegCloseKey(hKey);
}
TRACE("-- %s %i\n", szDest, *picon_idx);
return ret;
}
-BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx)
+BOOL HCR_GetIconFromGUIDW(REFIID riid, LPWSTR szDest, LPWSTR szName, DWORD len, int*
picon_idx)
{
HKEY hKey;
BOOL ret = FALSE;
if (HCR_RegOpenClassIDKey(riid, &hKey))
{
- ret = HCR_RegGetDefaultIconW(hKey, szDest, len, picon_idx);
+ ret = HCR_RegGetIconW(hKey, szDest, szName, len, picon_idx);
RegCloseKey(hKey);
}
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
Modified: trunk/reactos/dll/win32/shell32/folders.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/folders.…
==============================================================================
--- trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/folders.cpp [iso-8859-1] Thu Dec 19 11:44:30 2013
@@ -48,13 +48,13 @@
}
else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid,
wszCLSIDValue, CHARS_IN_GUID) &&
- HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx))
+ HCR_GetIconW(wszCLSIDValue, szIconFile, NULL, cchMax, &icon_idx))
{
*piIndex = icon_idx;
}
else if (SHELL32_GetCustomFolderAttribute(pidl, shellClassInfo, clsid2,
wszCLSIDValue, CHARS_IN_GUID) &&
- HCR_GetDefaultIconW(wszCLSIDValue, szIconFile, cchMax, &icon_idx))
+ HCR_GetIconW(wszCLSIDValue, szIconFile, NULL, cchMax, &icon_idx))
{
*piIndex = icon_idx;
}
@@ -62,7 +62,7 @@
{
static const WCHAR folder[] = { 'F', 'o', 'l',
'd', 'e', 'r', 0 };
- if (!HCR_GetDefaultIconW(folder, szIconFile, cchMax, &icon_idx))
+ if (!HCR_GetIconW(folder, szIconFile, NULL, cchMax, &icon_idx))
{
lstrcpynW(szIconFile, swShell32Name, cchMax);
icon_idx = -IDI_SHELL_FOLDER;
@@ -224,7 +224,40 @@
riid->Data4[0], riid->Data4[1], riid->Data4[2],
riid->Data4[3],
riid->Data4[4], riid->Data4[5], riid->Data4[6],
riid->Data4[7]);
- if (HCR_GetDefaultIconW(xriid, wTemp, MAX_PATH, &icon_idx))
+ WCHAR* iconname = NULL;
+ if (_ILIsBitBucket(pSimplePidl))
+ {
+ IEnumIDList *EnumIDList = NULL;
+ CoInitialize(NULL);
+
+ IShellFolder2 *psfRecycleBin = NULL;
+ IShellFolder *psfDesktop = NULL;
+ hr = SHGetDesktopFolder(&psfDesktop);
+
+ if (SUCCEEDED(hr))
+ hr = psfDesktop->BindToObject(pSimplePidl, NULL, IID_IShellFolder2,
(void**) &psfRecycleBin);
+ if (SUCCEEDED(hr))
+ hr = psfRecycleBin->EnumObjects(NULL, SHCONTF_FOLDERS |
SHCONTF_NONFOLDERS, &EnumIDList);
+
+ ULONG itemcount;
+ LPITEMIDLIST pidl = NULL;
+ if (SUCCEEDED(hr) && (hr = EnumIDList->Next(1, &pidl,
&itemcount)) == S_OK)
+ {
+ CoTaskMemFree(pidl);
+ iconname = L"Full";
+ } else {
+ iconname = L"Empty";
+ }
+
+ if (psfDesktop)
+ psfDesktop->Release();
+ if (psfRecycleBin)
+ psfRecycleBin->Release();
+ if (EnumIDList)
+ EnumIDList->Release();
+ }
+
+ if (HCR_GetIconW(xriid, wTemp, iconname, MAX_PATH, &icon_idx))
{
initIcon->SetNormalIcon(wTemp, icon_idx);
}
@@ -274,7 +307,7 @@
}
else
{
- if (HCR_GetDefaultIconW(drive, wTemp, MAX_PATH, &icon_idx))
+ if (HCR_GetIconW(drive, wTemp, NULL, MAX_PATH, &icon_idx))
initIcon->SetNormalIcon(wTemp, icon_idx);
else
initIcon->SetNormalIcon(swShell32Name, -IDI_SHELL_DRIVE);
@@ -324,7 +357,7 @@
else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
{
if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE)
- && HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH,
&icon_idx))
+ && HCR_GetIconA(sTemp, sTemp, NULL, MAX_PATH,
&icon_idx))
{
if (!lstrcmpA("%1", sTemp)) /* icon is in the file */
{
Modified: trunk/reactos/dll/win32/shell32/res/rgs/recyclebin.rgs
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/res/rgs/…
==============================================================================
--- trunk/reactos/dll/win32/shell32/res/rgs/recyclebin.rgs [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/res/rgs/recyclebin.rgs [iso-8859-1] Thu Dec 19
11:44:30 2013
@@ -6,14 +6,14 @@
{
val 'InfoTip' = e '(a)%%SystemRoot%%\system32\SHELL32.dll,-22915'
val 'IntroText' = e '(a)%%SystemRoot%%\system32\SHELL32.dll,-31748'
- val 'LocalizedString' = e
'(a)%%SystemRoot%%\system32\SHELL32.dll,-8964'
- DefaultIcon = e '%%SystemRoot%%\System32\shell32.dll,31'
- {
- val Empty = e '%%SystemRoot%%\System32\shell32.dll,31'
- val Full = e '%%SystemRoot%%\System32\shell32.dll,32'
- }
- InprocServer32 = s '%MODULE%'
- {
+ val 'LocalizedString' = e
'(a)%%SystemRoot%%\system32\SHELL32.dll,-8964'
+ DefaultIcon = e '%%SystemRoot%%\System32\shell32.dll,31'
+ {
+ val Empty = e '%%SystemRoot%%\System32\shell32.dll,30'
+ val Full = e '%%SystemRoot%%\System32\shell32.dll,31'
+ }
+ InprocServer32 = s '%MODULE%'
+ {
val ThreadingModel = s 'Apartment'
}
'ShellFolder'
Modified: trunk/reactos/dll/win32/shell32/shell32_main.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32_…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shell32_main.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shell32_main.cpp [iso-8859-1] Thu Dec 19 11:44:30
2013
@@ -584,7 +584,7 @@
TRACE("szExt=%s\n", debugstr_w(szExt));
if ( szExt &&
HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
- HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &psfi->iIcon))
+ HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &psfi->iIcon))
{
if (lstrcmpW(p1W, sTemp))
wcscpy(psfi->szDisplayName, sTemp);
@@ -640,7 +640,7 @@
szExt = PathFindExtensionW(sTemp);
if ( szExt &&
HCR_MapTypeToValueW(szExt, sTemp, MAX_PATH, TRUE) &&
- HCR_GetDefaultIconW(sTemp, sTemp, MAX_PATH, &icon_idx))
+ HCR_GetIconW(sTemp, sTemp, NULL, MAX_PATH, &icon_idx))
{
if (!lstrcmpW(p1W,sTemp)) /* icon is in the file */
wcscpy(sTemp, szFullPath);
Modified: trunk/reactos/dll/win32/shell32/shell32_main.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/shell32_…
==============================================================================
--- trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/shell32_main.h [iso-8859-1] Thu Dec 19 11:44:30 2013
@@ -46,17 +46,16 @@
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL
bPrependDot);
BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len );
BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR
szDest, DWORD len );
-BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx);
-BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx);
+BOOL HCR_GetIconW(LPCWSTR szClass, LPWSTR szDest, LPWSTR szName, DWORD len, int*
picon_idx);
+BOOL HCR_GetIconFromGUIDW(REFIID riid, LPWSTR szDest, LPWSTR szName, DWORD len, int*
picon_idx);
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len);
/* ANSI versions of above functions, supposed to go away as soon as they are not used
anymore */
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL
bPrependDot);
-BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx);
+BOOL HCR_GetIconA(LPCSTR szClass, LPSTR szDest, LPSTR sName, DWORD len, int* picon_idx);
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len);
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD dwAttributes);
-
INT_PTR CALLBACK AboutDlgProc(HWND,UINT,WPARAM,LPARAM);
DWORD WINAPI ParseFieldA(LPCSTR src, DWORD nField, LPSTR dst, DWORD len);
DWORD WINAPI ParseFieldW(LPCWSTR src, DWORD nField, LPWSTR dst, DWORD len);