remove mime type stuff for now
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
Windows's built in function for getting mime type sucks, and I don't want to have to vendor in libmagic. We'll leave this as something the user can handle themselves.
This commit is contained in:
parent
9dd96d9cec
commit
e20684f89b
5 changed files with 3 additions and 49 deletions
|
|
@ -39,7 +39,6 @@ struct _MwLLCommon {
|
||||||
int type;
|
int type;
|
||||||
int coordinate_type;
|
int coordinate_type;
|
||||||
MwBool supports_transparency;
|
MwBool supports_transparency;
|
||||||
const char** known_mime_types;
|
|
||||||
|
|
||||||
MwLLHandler handler;
|
MwLLHandler handler;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@
|
||||||
#define MwNforeground "Sforeground"
|
#define MwNforeground "Sforeground"
|
||||||
#define MwNsubForeground "SsubForeground"
|
#define MwNsubForeground "SsubForeground"
|
||||||
#define MwNtitleForeground "StitleForeground"
|
#define MwNtitleForeground "StitleForeground"
|
||||||
#define MwNacceptedMimeType "SacceptedMimeType"
|
|
||||||
|
|
||||||
|
|
||||||
#define MwNvulkanExtension "SEvulkanExtension"
|
#define MwNvulkanExtension "SEvulkanExtension"
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,6 @@ static struct symtbl {
|
||||||
|
|
||||||
UINT(WINAPI* DragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
|
UINT(WINAPI* DragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
|
||||||
UINT(WINAPI* DragQueryFileA)(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch);
|
UINT(WINAPI* DragQueryFileA)(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch);
|
||||||
HRESULT(WINAPI* FindMimeFromData)(
|
|
||||||
LPBC pBC,
|
|
||||||
LPCWSTR pwzUrl,
|
|
||||||
LPVOID pBuffer,
|
|
||||||
DWORD cbSize,
|
|
||||||
LPCWSTR pwzMimeProposed,
|
|
||||||
DWORD dwMimeFlags,
|
|
||||||
LPWSTR* ppwzMimeOut,
|
|
||||||
DWORD dwReserved);
|
|
||||||
void (*DragAcceptFiles)(HWND hWnd, BOOL fAccept);
|
void (*DragAcceptFiles)(HWND hWnd, BOOL fAccept);
|
||||||
void (*DragFinish)(HDROP hDrop);
|
void (*DragFinish)(HDROP hDrop);
|
||||||
} wsymtbl;
|
} wsymtbl;
|
||||||
|
|
@ -188,36 +179,9 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||||
count = wsymtbl.DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
|
count = wsymtbl.DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0);
|
||||||
|
|
||||||
for(i = 0; i < count; i++) {
|
for(i = 0; i < count; i++) {
|
||||||
wchar_t path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
char path_normal[MAX_PATH];
|
wsymtbl.DragQueryFileA(hDrop, i, path, MAX_PATH);
|
||||||
char* mime_type_normal;
|
MwLLDispatch(u->ll, drag_and_drop, path);
|
||||||
wchar_t* mime_type = NULL;
|
|
||||||
int mime_type_size;
|
|
||||||
HRESULT hr;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
wsymtbl.DragQueryFileW(hDrop, i, path, MAX_PATH);
|
|
||||||
wsymtbl.DragQueryFileA(hDrop, i, path_normal, MAX_PATH);
|
|
||||||
hr = wsymtbl.FindMimeFromData(NULL, path, NULL, 0,
|
|
||||||
NULL, 0, &mime_type, 0x0);
|
|
||||||
|
|
||||||
mime_type_size = WideCharToMultiByte(CP_ACP, 0, mime_type, -1, NULL, 0, NULL, FALSE);
|
|
||||||
mime_type_normal = malloc(sizeof(mime_type_size));
|
|
||||||
WideCharToMultiByte(CP_ACP, 0, mime_type, -1, mime_type_normal, mime_type_size, NULL, FALSE);
|
|
||||||
|
|
||||||
if(mime_type_size == 0) {
|
|
||||||
printf("Error converting mime type to multi-byte: %ld\n", GetLastError());
|
|
||||||
} else {
|
|
||||||
if(u->ll->common.known_mime_types) {
|
|
||||||
for(n = 0; n < arrlen(u->ll->common.known_mime_types); n++) {
|
|
||||||
if(strcmp(mime_type_normal, u->ll->common.known_mime_types[n]) == 0) {
|
|
||||||
MwLLDispatch(u->ll, drag_and_drop, path_normal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MwLLDispatch(u->ll, drag_and_drop, path_normal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
wsymtbl.DragFinish(hDrop);
|
wsymtbl.DragFinish(hDrop);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1106,7 +1070,6 @@ static int MwLLGDICallInitImpl(void) {
|
||||||
SHELL32_FUNC(DragQueryFileA);
|
SHELL32_FUNC(DragQueryFileA);
|
||||||
SHELL32_FUNC(DragAcceptFiles);
|
SHELL32_FUNC(DragAcceptFiles);
|
||||||
SHELL32_FUNC(DragFinish);
|
SHELL32_FUNC(DragFinish);
|
||||||
URLMON_FUNC(FindMimeFromData);
|
|
||||||
|
|
||||||
wsymtbl.has_drag_and_drop = MwTRUE;
|
wsymtbl.has_drag_and_drop = MwTRUE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -707,12 +707,6 @@ void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||||
if(strcmp(key, MwNbackground) == 0 || strcmp(key, MwNforeground) == 0 || strcmp(key, MwNsubBackground) == 0 || strcmp(key, MwNsubForeground) == 0) {
|
if(strcmp(key, MwNbackground) == 0 || strcmp(key, MwNforeground) == 0 || strcmp(key, MwNsubBackground) == 0 || strcmp(key, MwNsubForeground) == 0) {
|
||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strcmp(key, MwNacceptedMimeType) == 0) {
|
|
||||||
if(handle->lowlevel != NULL) {
|
|
||||||
arrput(handle->lowlevel->common.known_mime_types, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,6 @@ void MwLLCreateCommon(MwLL handle) {
|
||||||
memset(handle->common.handler, 0, sizeof(*handle->common.handler));
|
memset(handle->common.handler, 0, sizeof(*handle->common.handler));
|
||||||
|
|
||||||
handle->common.supports_transparency = 0;
|
handle->common.supports_transparency = 0;
|
||||||
handle->common.known_mime_types = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLDestroyCommon(MwLL handle) {
|
void MwLLDestroyCommon(MwLL handle) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue