summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/common/fe.h1
-rw-r--r--src/fe-gtk/gtkutil.c7
-rw-r--r--src/fe-gtk/setup.c14
3 files changed, 16 insertions, 6 deletions
diff --git a/src/common/fe.h b/src/common/fe.h
index eee4ad0c..91bf0a5b 100644
--- a/src/common/fe.h
+++ b/src/common/fe.h
@@ -130,6 +130,7 @@ void fe_get_int (char *prompt, int def, void *callback, void *ud);
 #define FRF_FILTERISINITIAL 16	/* filter is initial directory */
 #define FRF_NOASKOVERWRITE 32	/* don't ask to overwrite existing files */
 #define FRF_EXTENSIONS 64		/* specify file extensions to be displayed */
+#define FRF_MIMETYPES 128		/* specify file mimetypes to be displayed */
 void fe_get_file (const char *title, char *initial,
 				 void (*callback) (void *userdata, char *file), void *userdata,
 				 int flags);
diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c
index 55ae2c76..985a2f78 100644
--- a/src/fe-gtk/gtkutil.c
+++ b/src/fe-gtk/gtkutil.c
@@ -214,7 +214,7 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 	if (flags & FRF_CHOOSEFOLDER)
 		gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
 
-	if (flags & FRF_EXTENSIONS && extensions != NULL)
+	if ((flags & FRF_EXTENSIONS || flags & FRF_MIMETYPES) && extensions != NULL)
 	{
 		filefilter = gtk_file_filter_new ();
 		tokenbuffer = g_strdup (extensions);
@@ -222,7 +222,10 @@ gtkutil_file_req (const char *title, void *callback, void *userdata, char *filte
 
 		while (token != NULL)
 		{
-			gtk_file_filter_add_pattern (filefilter, token);
+			if (flags & FRF_EXTENSIONS)
+				gtk_file_filter_add_pattern (filefilter, token);
+			else
+				gtk_file_filter_add_mime_type (filefilter, token);
 			token = strtok (NULL, ";");
 		}
 
diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c
index 9923f654..f86c1eaa 100644
--- a/src/fe-gtk/setup.c
+++ b/src/fe-gtk/setup.c
@@ -1061,7 +1061,7 @@ setup_browsefile_cb (GtkWidget *button, GtkWidget *entry)
 {
 	/* used for background image only */
 	gtkutil_file_req (_("Select an Image File"), setup_filereq_cb,
-					entry, NULL, "*.jpg;*.png;*.tif;*.gif", FRF_EXTENSIONS|FRF_RECENTLYUSED);
+					entry, NULL, "image/*", FRF_MIMETYPES|FRF_RECENTLYUSED);
 }
 
 static void
@@ -1661,12 +1661,18 @@ static void
 setup_snd_browse_cb (GtkWidget *button, GtkEntry *entry)
 {
 	char *sounds_dir = g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, NULL);
-	char *extensions = NULL;
+	char *filter = NULL;
+	int filter_type;
 #ifdef WIN32 /* win32 only supports wav, others could support anything */
-	extensions = "*.wav";
+	filter = "*.wav";
+	filter_type = FRF_EXTENSIONS;
+#else
+	filter = "audio/*";
+	filter_type = FRF_MIMETYPES;
 #endif
 
-	gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry, sounds_dir, extensions, FRF_FILTERISINITIAL|FRF_EXTENSIONS);
+	gtkutil_file_req (_("Select a sound file"), setup_snd_filereq_cb, entry,
+						sounds_dir, filter, FRF_FILTERISINITIAL|filter_type);
 	g_free (sounds_dir);
 }