This commit is contained in:
Kovid Goyal 2023-01-04 21:25:45 +05:30
parent 630c24407c
commit 8059813337
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1111,7 +1111,8 @@ get_icon_at_index(int shilsize, int index) {
IImageListPtr spiml; IImageListPtr spiml;
HRESULT hr = SHGetImageList(shilsize, IID_PPV_ARGS(&spiml)); HRESULT hr = SHGetImageList(shilsize, IID_PPV_ARGS(&spiml));
HICON hico = NULL; HICON hico = NULL;
if (SUCCEEDED(hr)) spiml->GetIcon(index, ILD_TRANSPARENT, &hico); if (SUCCEEDED(hr)) spiml->GetIcon(index, ILD_TRANSPARENT | ILD_IMAGE, &hico);
spiml->Release();
return hico; return hico;
} }
@ -1130,14 +1131,14 @@ get_icon_for_file(PyObject *self, PyObject *args) {
HICON icon; HICON icon;
#define R(shil) { \ #define R(shil) { \
Py_BEGIN_ALLOW_THREADS \ Py_BEGIN_ALLOW_THREADS \
icon = get_icon_at_index(SHIL_JUMBO, fi.iIcon); \ icon = get_icon_at_index(shil, fi.iIcon); \
Py_END_ALLOW_THREADS \ Py_END_ALLOW_THREADS \
if (icon) return (PyObject*)Handle_create(icon, IconHandle); \ if (icon) return (PyObject*)Handle_create(icon, IconHandle); \
} }
R(SHIL_JUMBO); R(SHIL_EXTRALARGE); R(SHIL_LARGE); R(SHIL_SYSSMALL); R(SHIL_SMALL); R(SHIL_JUMBO); R(SHIL_EXTRALARGE); R(SHIL_LARGE); R(SHIL_SYSSMALL); R(SHIL_SMALL);
#undef R #undef R
return PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, ERROR_RESOURCE_TYPE_NOT_FOUND, PyTuple_GET_ITEM(args, 0)); return PyErr_SetExcFromWindowsErrWithFilenameObject(PyExc_OSError, ERROR_RESOURCE_TYPE_NOT_FOUND, PyTuple_GET_ITEM(args, 0));
} // }}} }
static PyObject* static PyObject*
@ -1165,7 +1166,7 @@ get_bitmap_for_file(PyObject *self, PyObject *args) {
return error_from_hresult(hr, "Failed to get image from shell item"); return error_from_hresult(hr, "Failed to get image from shell item");
} }
return (PyObject*)Handle_create(hbmp, BitmapHandle); return (PyObject*)Handle_create(hbmp, BitmapHandle);
} } // }}}
// Boilerplate {{{ // Boilerplate {{{
static const char winutil_doc[] = "Defines utility methods to interface with windows."; static const char winutil_doc[] = "Defines utility methods to interface with windows.";