mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 15:22:11 +02:00
clapper-app: Fix missing media in file dialog on Windows
Windows does not support mime-types file filters, so use file extensions instead
This commit is contained in:
@@ -80,8 +80,15 @@ _dialog_add_mime_types (GtkFileDialog *dialog, const gchar *filter_name,
|
||||
GtkFileFilter *filter = gtk_file_filter_new ();
|
||||
guint i;
|
||||
|
||||
for (i = 0; mime_types[i]; ++i)
|
||||
/* XXX: Windows does not support mime-types file
|
||||
* filters, so use file extensions instead */
|
||||
for (i = 0; mime_types[i]; ++i) {
|
||||
#ifndef G_OS_WIN32
|
||||
gtk_file_filter_add_mime_type (filter, mime_types[i]);
|
||||
#else
|
||||
gtk_file_filter_add_suffix (filter, mime_types[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
gtk_file_filter_set_name (filter, filter_name);
|
||||
g_list_store_append (filters, filter);
|
||||
@@ -99,7 +106,11 @@ clapper_app_file_dialog_open_files (GtkApplication *gtk_app)
|
||||
GtkFileDialog *dialog = gtk_file_dialog_new ();
|
||||
|
||||
_dialog_add_mime_types (dialog, "Media Files",
|
||||
#ifndef G_OS_WIN32
|
||||
clapper_app_utils_get_mime_types ());
|
||||
#else
|
||||
clapper_app_utils_get_extensions ());
|
||||
#endif
|
||||
|
||||
gtk_file_dialog_set_modal (dialog, TRUE);
|
||||
gtk_file_dialog_set_title (dialog, "Add Files");
|
||||
@@ -118,7 +129,11 @@ clapper_app_file_dialog_open_subtitles (GtkApplication *gtk_app, ClapperMediaIte
|
||||
GtkFileDialog *dialog = gtk_file_dialog_new ();
|
||||
|
||||
_dialog_add_mime_types (dialog, "Subtitles",
|
||||
#ifndef G_OS_WIN32
|
||||
clapper_app_utils_get_subtitles_mime_types ());
|
||||
#else
|
||||
clapper_app_utils_get_subtitles_extensions ());
|
||||
#endif
|
||||
|
||||
gtk_file_dialog_set_modal (dialog, TRUE);
|
||||
gtk_file_dialog_set_title (dialog, "Open Subtitles");
|
||||
|
@@ -23,6 +23,30 @@
|
||||
#include "clapper-app-utils.h"
|
||||
#include "clapper-app-media-item-box.h"
|
||||
|
||||
/* Useful only on Windows */
|
||||
#ifdef G_OS_WIN32
|
||||
const gchar *const *
|
||||
clapper_app_utils_get_extensions (void)
|
||||
{
|
||||
static const gchar *const all_extensions[] = {
|
||||
"avi", "claps", "m2ts", "mkv", "mov",
|
||||
"mp4", "webm", "wmv", NULL
|
||||
};
|
||||
|
||||
return all_extensions;
|
||||
}
|
||||
|
||||
const gchar *const *
|
||||
clapper_app_utils_get_subtitles_extensions (void)
|
||||
{
|
||||
static const gchar *const subs_extensions[] = {
|
||||
"srt", "vtt", NULL
|
||||
};
|
||||
|
||||
return subs_extensions;
|
||||
}
|
||||
#endif
|
||||
|
||||
const gchar *const *
|
||||
clapper_app_utils_get_mime_types (void)
|
||||
{
|
||||
|
@@ -26,6 +26,14 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef void (* ClapperAppUtilsIterRanks) (const gchar *feature_name, GstRank rank, gboolean from_env, gpointer user_data);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
G_GNUC_INTERNAL
|
||||
const gchar *const * clapper_app_utils_get_extensions (void);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const gchar *const * clapper_app_utils_get_subtitles_extensions (void);
|
||||
#endif
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
const gchar *const * clapper_app_utils_get_mime_types (void);
|
||||
|
||||
|
Reference in New Issue
Block a user