[frogr] Took the list of supported mimetypes/extensions out to frogr-util
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Took the list of supported mimetypes/extensions out to frogr-util
- Date: Sun, 4 Nov 2012 21:46:37 +0000 (UTC)
commit d621510fcb375895e20fc8bfa61b9bba3296e5e6
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sat Nov 3 10:51:33 2012 +0100
Took the list of supported mimetypes/extensions out to frogr-util
src/frogr-file-loader.c | 17 +++--------------
src/frogr-main-view.c | 18 +++++++-----------
src/frogr-util.c | 28 ++++++++++++++++++++++++++++
src/frogr-util.h | 2 ++
4 files changed, 40 insertions(+), 25 deletions(-)
---
diff --git a/src/frogr-file-loader.c b/src/frogr-file-loader.c
index 3fe626b..fd30ff8 100644
--- a/src/frogr-file-loader.c
+++ b/src/frogr-file-loader.c
@@ -83,18 +83,6 @@ enum {
static guint signals[N_SIGNALS] = { 0 };
-#ifndef MAC_INTEGRATION
-/* Don't use this in Mac OSX, where GNOME VFS daemon won't be running,
- so we couldn't reliably check mime types (will be text/plain) */
-static const gchar *valid_mimetypes[] = {
- "image/jpg",
- "image/jpeg",
- "image/png",
- "image/bmp",
- "image/gif",
- NULL};
-#endif
-
/* Prototypes */
static void _update_status_and_progress (FrogrFileLoader *self);
@@ -167,9 +155,10 @@ _load_next_file (FrogrFileLoader *self)
if (mime_type)
{
- for (i = 0; valid_mimetypes[i]; i++)
+ const gchar * const *supported_files = frogr_util_get_supported_files ();
+ for (i = 0; supported_files[i]; i++)
{
- if (g_str_equal (valid_mimetypes[i], mime_type))
+ if (g_str_equal (supported_files[i], mime_type))
{
valid_mime = TRUE;
break;
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 0d43967..acf0fa4 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -929,9 +929,10 @@ static void
_load_pictures_dialog (FrogrMainView *self)
{
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
-
GtkWidget *dialog;
GtkFileFilter *filter;
+ const gchar * const *supported_files;
+ gint i;
dialog = gtk_file_chooser_dialog_new (_("Select a Picture"),
GTK_WINDOW (priv->window),
@@ -942,21 +943,16 @@ _load_pictures_dialog (FrogrMainView *self)
/* Set images filter */
filter = gtk_file_filter_new ();
+ supported_files = frogr_util_get_supported_files ();
#ifdef MAC_INTEGRATION
/* Workaround for Mac OSX, where GNOME VFS daemon won't be running,
so we can't check filter by mime type (will be text/plain) */
- gtk_file_filter_add_pattern (filter, "*.[jJ][pP][gG]");
- gtk_file_filter_add_pattern (filter, "*.[jJ][pP][eE][gG]");
- gtk_file_filter_add_pattern (filter, "*.[pP][nN][gG]");
- gtk_file_filter_add_pattern (filter, "*.[bB][mM][pP]");
- gtk_file_filter_add_pattern (filter, "*.[gG][iI][fF]");
+ for (i = 0; supported_files[i]; i++)
+ gtk_file_filter_add_pattern (filter, supported_files[i]);
#else
- gtk_file_filter_add_mime_type (filter, "image/jpg");
- gtk_file_filter_add_mime_type (filter, "image/jpeg");
- gtk_file_filter_add_mime_type (filter, "image/png");
- gtk_file_filter_add_mime_type (filter, "image/bmp");
- gtk_file_filter_add_mime_type (filter, "image/gif");
+ for (i = 0; supported_files[i]; i++)
+ gtk_file_filter_add_mime_type (filter, supported_files[i]);
#endif
gtk_file_filter_set_name (filter, _("images"));
diff --git a/src/frogr-util.c b/src/frogr-util.c
index 8dac1d4..5d685a6 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -350,3 +350,31 @@ frogr_util_get_datasize_string (gulong datasize)
return result;
}
+
+const gchar * const *
+frogr_util_get_supported_files (void)
+{
+#ifdef MAC_INTEGRATION
+ /* Workaround for Mac OSX, where GNOME VFS daemon won't be running,
+ so we can't filter by mime type (will be text/plain) */
+ static const gchar *frogr_supported_files[] = {
+ "*.[jJ][pP][gG]",
+ "*.[jJ][pP][eE][gG]",
+ "*.[pP][nN][gG]",
+ "*.[bB][mM][pP]",
+ "*.[gG][iI][fF]",
+ NULL
+};
+#else
+ static const gchar *frogr_supported_files[] = {
+ "image/jpg",
+ "image/jpeg",
+ "image/png",
+ "image/bmp",
+ "image/gif",
+ NULL
+ };
+#endif
+
+ return frogr_supported_files;
+}
diff --git a/src/frogr-util.h b/src/frogr-util.h
index 6367cee..0c776e0 100644
--- a/src/frogr-util.h
+++ b/src/frogr-util.h
@@ -45,6 +45,8 @@ GdkPixbuf *frogr_util_get_corrected_pixbuf (GdkPixbuf *pixbuf, gint max_width, g
gchar *frogr_util_get_datasize_string (gulong datasize);
+const gchar * const *frogr_util_get_supported_files (void);
+
G_END_DECLS
#endif /* FROGR_UTIL_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]