Update File Extension Judge

This commit is contained in:
daleclack 2021-06-28 15:52:14 +08:00
parent 8e7ac32d73
commit b14b420397
2 changed files with 18 additions and 7 deletions

View File

@ -42,18 +42,17 @@ void fileopen(GtkWidget *widget,GtkBuilder *builder){
And For Linux,just use the image/* mime type
*/
#ifdef G_OS_WIN32
int i;
for (i = 0; supported_globs != NULL && supported_globs[i] != NULL; i++)
if(mime_type_supported()){
gtk_file_filter_add_mime_type(filter,"image/*");
}else{
int i;
for (i = 0; supported_globs != NULL && supported_globs[i] != NULL; i++)
{
const char *glob = supported_globs[i];
gtk_file_filter_add_pattern (filter, glob);
}
#else
gtk_file_filter_add_mime_type(filter,"image/*");
#endif
}
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog),filter);
//Filter For All Files

View File

@ -1,3 +1,7 @@
#pragma once
#include <glib.h>
static const char * const supported_globs[]={
"*.bmp",
"*.cod",
@ -24,3 +28,11 @@ static const char * const supported_globs[]={
"*.xwd",
NULL
};
static inline gboolean mime_type_supported(){
#ifdef G_OS_WIN32
return FALSE;
#else
return TRUE;
#endif
}