static HRESULT WINAPI ShellItem_Compare(IShellItem2 *iface, IShellItem *oth, SICHINTF hint, int *piOrder) { LPWSTR dispname, dispname_oth; HRESULT ret; TRACE("(%p,%p,%x,%p)\n", iface, oth, hint, piOrder); if(hint & (SICHINT_CANONICAL | SICHINT_ALLFIELDS)) FIXME("Unsupported flags 0x%08x\n", hint); ret = IShellItem2_GetDisplayName(iface, SIGDN_DESKTOPABSOLUTEEDITING, &dispname); if(SUCCEEDED(ret)) { ret = IShellItem_GetDisplayName(oth, SIGDN_DESKTOPABSOLUTEEDITING, &dispname_oth); if(SUCCEEDED(ret)) { *piOrder = lstrcmpiW(dispname, dispname_oth); CoTaskMemFree(dispname_oth); } CoTaskMemFree(dispname); } if(SUCCEEDED(ret) && *piOrder && (hint & SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL)) { LPWSTR dispname, dispname_oth; TRACE("Testing filesystem path.\n"); ret = IShellItem2_GetDisplayName(iface, SIGDN_FILESYSPATH, &dispname); if(SUCCEEDED(ret)) { ret = IShellItem_GetDisplayName(oth, SIGDN_FILESYSPATH, &dispname_oth); if(SUCCEEDED(ret)) { *piOrder = lstrcmpiW(dispname, dispname_oth); CoTaskMemFree(dispname_oth); } CoTaskMemFree(dispname); } } if(FAILED(ret)) return ret; if(*piOrder) return S_FALSE; else return S_OK; }
static GFile * get_file_for_shell_item (IShellItem *item) { HRESULT hr; PWSTR pathw = NULL; char *path; GFile *file; hr = IShellItem_GetDisplayName (item, SIGDN_FILESYSPATH, &pathw); if (SUCCEEDED (hr)) { path = g_utf16_to_utf8 (pathw, -1, NULL, NULL, NULL); CoTaskMemFree (pathw); if (path != NULL) { file = g_file_new_for_path (path); g_free (path); return file; } } /* TODO: also support URLs through SIGDN_URL, but Windows URLS are not * RFC 3986 compliant and we'd need to convert them first. */ return NULL; }
char *commonItemDialog(REFCLSID clsid, REFIID iid, FILEOPENDIALOGOPTIONS optsadd) { IFileDialog *d; FILEOPENDIALOGOPTIONS opts; HWND dialogHelper; IShellItem *result; WCHAR *wname; char *name; HRESULT hr; hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, iid, (LPVOID *) (&d)); if (hr != S_OK) logHRESULT("error creating common item dialog in commonItemDialog()", hr); hr = IFileDialog_GetOptions(d, &opts); if (hr != S_OK) logHRESULT("error getting current options in commonItemDialog()", hr); opts |= optsadd; hr = IFileDialog_SetOptions(d, opts); if (hr != S_OK) logHRESULT("error setting options in commonItemDialog()", hr); dialogHelper = beginDialogHelper(); hr = IFileDialog_Show(d, dialogHelper); endDialogHelper(dialogHelper); if (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED)) { IFileDialog_Release(d); return NULL; } if (hr != S_OK) logHRESULT("error showing dialog in commonItemDialog()", hr); hr = IFileDialog_GetResult(d, &result); if (hr != S_OK) logHRESULT("error getting dialog result in commonItemDialog()", hr); hr = IShellItem_GetDisplayName(result, SIGDN_FILESYSPATH, &wname); if (hr != S_OK) logHRESULT("error getting filename in commonItemDialog()", hr); name = toUTF8(wname); CoTaskMemFree(wname); IShellItem_Release(result); IFileDialog_Release(d); return name; }