Module: wine Branch: master Commit: 1226422a08a70084c3328bc713cae7930950b36b URL: http://source.winehq.org/git/wine.git/?a=commit;h=1226422a08a70084c3328bc713...
Author: Piotr Caban piotr@codeweavers.com Date: Sun Jul 3 14:42:26 2011 +0200
shell32: Implement folder renaming in SHBrowseForFolder.
---
dlls/shell32/brsfolder.c | 49 ++++++++++++++++++++++++++++++++++++++- dlls/shell32/tests/brsfolder.c | 4 +- 2 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/brsfolder.c b/dlls/shell32/brsfolder.c index 48e19cd..71d2d0b 100644 --- a/dlls/shell32/brsfolder.c +++ b/dlls/shell32/brsfolder.c @@ -574,6 +574,46 @@ static HRESULT BrsFolder_Treeview_Changed( browse_info *info, NMTREEVIEWW *pnmtv return 0; }
+static LRESULT BrsFolder_Treeview_Rename(browse_info *info, NMTVDISPINFOW *pnmtv) +{ + LPTV_ITEMDATA item_data; + WCHAR old_path[MAX_PATH], new_path[MAX_PATH], *p; + NMTREEVIEWW nmtv; + TVITEMW item; + + if(!pnmtv->item.pszText) + return 0; + + item.mask = TVIF_HANDLE|TVIF_PARAM; + item.hItem = (HTREEITEM)SendMessageW(info->hwndTreeView, TVM_GETNEXTITEM, TVGN_CARET, 0); + SendMessageW(info->hwndTreeView, TVM_GETITEMW, 0, (LPARAM)&item); + item_data = (LPTV_ITEMDATA)item.lParam; + + SHGetPathFromIDListW(item_data->lpifq, old_path); + if(!(p = strrchrW(old_path, '\'))) + return 0; + p = new_path+(p-old_path+1); + memcpy(new_path, old_path, (p-new_path)*sizeof(WCHAR)); + strcpyW(p, pnmtv->item.pszText); + + if(!MoveFileW(old_path, new_path)) + return 0; + + SHFree(item_data->lpifq); + SHFree(item_data->lpi); + item_data->lpifq = SHSimpleIDListFromPathW(new_path); + IShellFolder_ParseDisplayName(item_data->lpsfParent, NULL, NULL, + pnmtv->item.pszText, NULL, &item_data->lpi, NULL); + + item.mask = TVIF_HANDLE|TVIF_TEXT; + item.pszText = pnmtv->item.pszText; + SendMessageW(info->hwndTreeView, TVM_SETITEMW, 0, (LPARAM)&item); + + nmtv.itemNew.lParam = item.lParam; + BrsFolder_Treeview_Changed(info, &nmtv); + return 0; +} + static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh ) { NMTREEVIEWW *pnmtv = (NMTREEVIEWW *)lpnmh; @@ -597,6 +637,10 @@ static LRESULT BrsFolder_OnNotify( browse_info *info, UINT CtlID, LPNMHDR lpnmh case TVN_SELCHANGEDW: return BrsFolder_Treeview_Changed( info, pnmtv );
+ case TVN_ENDLABELEDITA: + case TVN_ENDLABELEDITW: + return BrsFolder_Treeview_Rename( info, (LPNMTVDISPINFOW)pnmtv ); + default: WARN("unhandled (%d)\n", pnmtv->hdr.code); break; @@ -680,8 +724,9 @@ static BOOL BrsFolder_OnCreate( HWND hWnd, browse_info *info )
static HRESULT BrsFolder_Rename(browse_info *info, HTREEITEM rename) { - FIXME("\n"); - return E_NOTIMPL; + SendMessageW(info->hwndTreeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)rename); + SendMessageW(info->hwndTreeView, TVM_EDITLABELW, 0, (LPARAM)rename); + return S_OK; }
static HRESULT BrsFolder_NewFolder(browse_info *info) diff --git a/dlls/shell32/tests/brsfolder.c b/dlls/shell32/tests/brsfolder.c index 03dff74..4dea03e 100644 --- a/dlls/shell32/tests/brsfolder.c +++ b/dlls/shell32/tests/brsfolder.c @@ -222,14 +222,14 @@ static void test_click_make_new_folder_button(void) /* There should be a new folder foo inside the test folder */ strcpy(new_folder_path, test_folder_path); strcat(new_folder_path, new_folder_name); - todo_wine ok(does_folder_or_file_exist(new_folder_path) + ok(does_folder_or_file_exist(new_folder_path) || broken(!does_folder_or_file_exist(new_folder_path)) /* W95, W98, XP, W2K3 */, "The new folder did not get the name %s\n", new_folder_name);
/* Dialog should return a pidl pointing to the new folder */ ok(SHGetPathFromIDListA(pidl, new_folder_pidl_path), "SHGetPathFromIDList failed for new folder.\n"); - todo_wine ok(strcmp(new_folder_path, new_folder_pidl_path) == 0 + ok(strcmp(new_folder_path, new_folder_pidl_path) == 0 || broken(strcmp(new_folder_path, new_folder_pidl_path) != 0) /* earlier than Vista */, "SHBrowseForFolder did not return the pidl for the new folder. " "Expected '%s' got '%s'\n", new_folder_path, new_folder_pidl_path);