[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-patches
Subject: Shell32 improvements
From: Chris Morgan <cmorgan () wpi ! edu>
Date: 2001-02-21 1:08:06
[Download RAW message or body]
ChangeLog entry:
*dlls/shell32/shres.rc, shresdef.h, shlfolder.c, shlfileop.c:
Chris Morgan <cmorgan@codeweavers.com>
Confirm file deletes. Make delete confirmation messages more consistent.
Improve trace messages on delete failure.
*dlls/shell32/shlview.c, shell32_main.h:
Chris Morgan <cmorgan@codeweavers.com>
Add shell support for deleting files using the Delete key.
["shell32.diff" (text/x-c)]
Index: dlls/shell32/shlview.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlview.c,v
retrieving revision 1.59
diff -u -r1.59 shlview.c
--- dlls/shell32/shlview.c 2001/02/13 02:20:35 1.59
+++ dlls/shell32/shlview.c 2001/02/21 00:53:15
@@ -38,6 +38,7 @@
#include "docobj.h"
#include "pidl.h"
#include "shell32_main.h"
+#include "shellfolder.h"
DEFAULT_DEBUG_CHANNEL(shell);
@@ -1288,10 +1289,51 @@
#if 0
TranslateAccelerator(This->hWnd, This->hAccel, &msg)
#endif
+ else if(plvKeyDown->wVKey == VK_DELETE)
+ {
+ int i, item_index;
+ LVITEMA item;
+ LPITEMIDLIST* pItems;
+ ISFHelper *psfhlp;
+
+ IShellFolder_QueryInterface(This->pSFParent, &IID_ISFHelper,
+ (LPVOID*)&psfhlp);
+
+ if(!(i = ListView_GetSelectedCount(This->hWndList)))
+ break;
+
+ /* allocate memory for the pidl array */
+ pItems = HeapAlloc(GetProcessHeap(), 0,
+ sizeof(LPITEMIDLIST) * i);
+
+ /* retrieve all selected items */
+ i = 0;
+ item_index = -1;
+ while(ListView_GetSelectedCount(This->hWndList) > i)
+ {
+ /* get selected item */
+ item_index = ListView_GetNextItem(This->hWndList,
+ item_index, LVNI_SELECTED);
+ item.iItem = item_index;
+ ListView_GetItemA(This->hWndList, &item);
+
+ /* get item pidl */
+ pItems[i] = (LPITEMIDLIST)item.lParam;
+
+ i++;
+ }
+
+ /* perform the item deletion */
+ ISFHelper_DeleteItems(psfhlp, i, pItems);
+
+ /* free pidl array memory */
+ HeapFree(GetProcessHeap(), 0, pItems);
+ }
else
- FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
+ FIXME("LVN_KEYDOWN key=0x%08x\n",plvKeyDown->wVKey);
}
break;
+
default:
TRACE("-- %p WM_COMMAND %x unhandled\n", This, lpnmh->code);
break;;
Index: dlls/shell32/shell32_main.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32_main.h,v
retrieving revision 1.39
diff -u -r1.39 shell32_main.h
--- dlls/shell32/shell32_main.h 2001/02/12 03:51:04 1.39
+++ dlls/shell32/shell32_main.h 2001/02/21 00:53:16
@@ -149,7 +149,13 @@
void FreeChangeNotifications(void);
/* file operation */
+#define ASK_DELETE_FILE 1
+#define ASK_DELETE_FOLDER 2
+#define ASK_DELETE_MULTIPLE_ITEM 3
+
BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI);
+BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI);
+BOOL SHELL_WarnItemDelete(int nKindOfDialog, LPCSTR szDir);
extern HINSTANCE SHELL_FindExecutable(LPCSTR,LPCSTR ,LPSTR);
Index: dlls/shell32/shlfileop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfileop.c,v
retrieving revision 1.9
diff -u -r1.9 shlfileop.c
--- dlls/shell32/shlfileop.c 2001/01/18 23:04:19 1.9
+++ dlls/shell32/shlfileop.c 2001/02/21 00:53:16
@@ -13,16 +13,39 @@
DEFAULT_DEBUG_CHANNEL(shell);
-#define ASK_DELETE_FILE 1
-#define ASK_DELETE_FOLDER 2
-#define ASK_DELETE_MULTIPLE_FILE 3
-
-static BOOL SHELL_WarnFolderDelete (int nKindOfDialog, LPCSTR szDir)
+BOOL SHELL_WarnItemDelete (int nKindOfDialog, LPCSTR szDir)
{
char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
+
+ if(nKindOfDialog == ASK_DELETE_FILE)
+ {
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
+ sizeof(szText));
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
+ szCaption, sizeof(szCaption));
+ }
+ else if(nKindOfDialog == ASK_DELETE_FOLDER)
+ {
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
+ sizeof(szText));
+ LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION,
+ szCaption, sizeof(szCaption));
+ }
+ else if(nKindOfDialog == ASK_DELETE_MULTIPLE_ITEM)
+ {
+ LoadStringA(shell32_hInstance, IDS_DELETEMULTIPLE_TEXT, szText,
+ sizeof(szText));
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
+ szCaption, sizeof(szCaption));
+ }
+ else {
+ FIXME("Called without a valid nKindOfDialog specified!");
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
+ sizeof(szText));
+ LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
+ szCaption, sizeof(szCaption));
+ }
- LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_TEXT, szText, sizeof(szText));
- LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, szCaption, sizeof(szCaption));
FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
@@ -46,7 +69,8 @@
PathAddBackslashA(szTemp);
strcat(szTemp, "*.*");
- if (bShowUI && !SHELL_WarnFolderDelete(ASK_DELETE_FOLDER, pszDir)) return FALSE;
+ if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir))
+ return FALSE;
if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
{
@@ -70,6 +94,18 @@
}
return ret;
+}
+
+/**************************************************************************
+ * SHELL_DeleteFileA()
+ */
+
+BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
+{
+ if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FILE, pszFile))
+ return FALSE;
+
+ return DeleteFileA(pszFile);
}
/*************************************************************************
Index: dlls/shell32/shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfolder.c,v
retrieving revision 1.54
diff -u -r1.54 shlfolder.c
--- dlls/shell32/shlfolder.c 2000/12/06 01:50:49 1.54
+++ dlls/shell32/shlfolder.c 2001/02/21 00:53:22
@@ -1489,9 +1489,20 @@
_ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
int i;
char szPath[MAX_PATH];
+ BOOL bConfirm = TRUE;
TRACE("(%p)(%u %p)\n", This, cidl, apidl);
+ /* deleting multiple items so give a slightly different warning */
+ if(cidl != 1)
+ {
+ char tmp[8];
+ snprintf(tmp, sizeof(tmp), "%d", cidl);
+ if(!SHELL_WarnItemDelete(ASK_DELETE_MULTIPLE_ITEM, tmp))
+ return E_FAIL;
+ bConfirm = FALSE;
+ }
+
for(i=0; i< cidl; i++)
{
strcpy(szPath, This->sMyPath);
@@ -1501,9 +1512,12 @@
if (_ILIsFolder(apidl[i]))
{
LPITEMIDLIST pidl;
-
- MESSAGE("delete %s\n", szPath);
- if (! SHELL_DeleteDirectoryA(szPath, TRUE)) return E_FAIL;
+ TRACE("delete %s\n", szPath);
+ if (! SHELL_DeleteDirectoryA(szPath, bConfirm))
+ {
+ TRACE("delete %s failed, bConfirm=%d", szPath, bConfirm);
+ return E_FAIL;
+ }
pidl = ILCombine(This->absPidl, apidl[i]);
SHChangeNotifyA(SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
SHFree(pidl);
@@ -1512,8 +1526,12 @@
{
LPITEMIDLIST pidl;
- MESSAGE("delete %s\n", szPath);
- if (! DeleteFileA(szPath)) return E_FAIL;
+ TRACE("delete %s\n", szPath);
+ if (! SHELL_DeleteFileA(szPath, bConfirm))
+ {
+ TRACE("delete %s failed, bConfirm=%d", szPath, bConfirm);
+ return E_FAIL;
+ }
pidl = ILCombine(This->absPidl, apidl[i]);
SHChangeNotifyA(SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
SHFree(pidl);
Index: dlls/shell32/shres.rc
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shres.rc,v
retrieving revision 1.18
diff -u -r1.18 shres.rc
--- dlls/shell32/shres.rc 2001/02/14 00:29:16 1.18
+++ dlls/shell32/shres.rc 2001/02/21 00:53:26
@@ -133,8 +133,10 @@
{
IDS_CREATEFOLDER_DENIED "Can not create new Folder: Permission denied."
IDS_CREATEFOLDER_CAPTION "Error during creating a new folder"
- IDS_DELETEFOLDER_TEXT "Are you sure you want to delete %1 and all it's subfolders?"
- IDS_DELETEFOLDER_CAPTION "Confirm file delete"
+ IDS_DELETEITEM_CAPTION "Confirm file delete"
+ IDS_DELETEFOLDER_CAPTION "Confirm folder delete"
+ IDS_DELETEITEM_TEXT "Are you sure you want to delete '%1'?"
+ IDS_DELETEMULTIPLE_TEXT "Are you sure you want to delete these %1 items?"
}
shv_accel ACCELERATORS
Index: dlls/shell32/shresdef.h
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shresdef.h,v
retrieving revision 1.6
diff -u -r1.6 shresdef.h
--- dlls/shell32/shresdef.h 2000/08/25 21:33:23 1.6
+++ dlls/shell32/shresdef.h 2001/02/21 00:53:26
@@ -24,8 +24,10 @@
#define IDS_CREATEFOLDER_DENIED 30
#define IDS_CREATEFOLDER_CAPTION 31
-#define IDS_DELETEFOLDER_TEXT 32
+#define IDS_DELETEITEM_CAPTION 32
#define IDS_DELETEFOLDER_CAPTION 33
+#define IDS_DELETEITEM_TEXT 34
+#define IDS_DELETEMULTIPLE_TEXT 35
/* browse for folder dialog box */
#define IDD_STATUS 97
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic