[frogr] Added new 'All' and 'Video' filters to the file chooser dialog
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Added new 'All' and 'Video' filters to the file chooser dialog
- Date: Sun, 4 Nov 2012 21:47:17 +0000 (UTC)
commit 0d8e9f7536ce4604fe724d190a9fd0ea268e39b4
Author: Mario Sanchez Prada <msanchez gnome org>
Date: Sat Nov 3 18:06:27 2012 +0100
Added new 'All' and 'Video' filters to the file chooser dialog
src/frogr-file-loader.c | 6 ++--
src/frogr-main-view.c | 54 ++++++++++++++++++++++++++++++++++++++--------
src/frogr-util.c | 34 +++++++++++++++++++++-------
src/frogr-util.h | 8 ++++++-
4 files changed, 79 insertions(+), 23 deletions(-)
---
diff --git a/src/frogr-file-loader.c b/src/frogr-file-loader.c
index b633df3..1b486b3 100644
--- a/src/frogr-file-loader.c
+++ b/src/frogr-file-loader.c
@@ -155,10 +155,10 @@ _load_next_file (FrogrFileLoader *self)
if (mime_type)
{
- const gchar * const *supported_files = frogr_util_get_supported_files ();
- for (i = 0; supported_files[i]; i++)
+ const gchar * const *supported_mimetypes = frogr_util_get_supported_mimetypes ();
+ for (i = 0; supported_mimetypes[i]; i++)
{
- if (g_str_equal (supported_files[i], mime_type))
+ if (g_str_equal (supported_mimetypes[i], mime_type))
{
valid_mime = TRUE;
break;
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 9dac16a..a7d12fa 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -930,10 +930,18 @@ _load_pictures_dialog (FrogrMainView *self)
{
FrogrMainViewPrivate *priv = FROGR_MAIN_VIEW_GET_PRIVATE (self);
GtkWidget *dialog;
- GtkFileFilter *filter;
- const gchar * const *supported_files;
+ GtkFileFilter *all_filter;
+ GtkFileFilter *image_filter;
+ GtkFileFilter *video_filter;
gint i;
+#ifdef MAC_INTEGRATION
+ const gchar * const *supported_images;
+ const gchar * const *supported_videos;
+#else
+ const gchar * const *supported_mimetypes;
+#endif
+
dialog = gtk_file_chooser_dialog_new (_("Select a Picture"),
GTK_WINDOW (priv->window),
GTK_FILE_CHOOSER_ACTION_OPEN,
@@ -942,22 +950,48 @@ _load_pictures_dialog (FrogrMainView *self)
NULL);
/* Set images filter */
- filter = gtk_file_filter_new ();
- supported_files = frogr_util_get_supported_files ();
+ all_filter = gtk_file_filter_new ();
+ image_filter = gtk_file_filter_new ();
+ video_filter = gtk_file_filter_new ();
#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) */
- for (i = 0; supported_files[i]; i++)
- gtk_file_filter_add_pattern (filter, supported_files[i]);
+ supported_images = frogr_util_get_supported_images ();
+ for (i = 0; supported_images[i]; i++)
+ {
+ gtk_file_filter_add_pattern (image_filter, supported_images[i]);
+ gtk_file_filter_add_pattern (all_filter, supported_images[i]);
+ }
+
+ supported_videos = frogr_util_get_supported_videos ();
+ for (i = 0; supported_videos[i]; i++)
+ {
+ gtk_file_filter_add_pattern (video_filter, supported_videos[i]);
+ gtk_file_filter_add_pattern (all_filter, supported_videos[i]);
+ }
#else
- for (i = 0; supported_files[i]; i++)
- gtk_file_filter_add_mime_type (filter, supported_files[i]);
+ supported_mimetypes = frogr_util_get_supported_mimetypes ();
+ for (i = 0; supported_mimetypes[i]; i++)
+ {
+ if (g_str_has_prefix (supported_mimetypes[i], "video"))
+ gtk_file_filter_add_mime_type (video_filter, supported_mimetypes[i]);
+ else
+ gtk_file_filter_add_mime_type (image_filter, supported_mimetypes[i]);
+
+ gtk_file_filter_add_mime_type (all_filter, supported_mimetypes[i]);
+ }
#endif
- gtk_file_filter_set_name (filter, _("images"));
+ gtk_file_filter_set_name (all_filter, _("All"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), all_filter);
+
+ gtk_file_filter_set_name (image_filter, _("Images"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), image_filter);
+
+ gtk_file_filter_set_name (video_filter, _("Videos"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), video_filter);
- gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), FALSE);
diff --git a/src/frogr-util.c b/src/frogr-util.c
index d05b7ba..3a2d9d3 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -561,18 +561,26 @@ frogr_util_get_datasize_string (gulong datasize)
return result;
}
+#ifdef MAC_INTEGRATION
const gchar * const *
-frogr_util_get_supported_files (void)
+frogr_util_get_supported_images (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[] = {
+ static const gchar *supported_images[] = {
"*.[jJ][pP][gG]",
"*.[jJ][pP][eE][gG]",
"*.[pP][nN][gG]",
"*.[bB][mM][pP]",
"*.[gG][iI][fF]",
+ NULL
+ };
+
+ return supported_images;
+}
+
+const gchar * const *
+frogr_util_get_supported_videos (void)
+{
+ static const gchar *supported_videos[] = {
"*.[mM][pP]4",
"*.[mM][oO][vV]",
"*.[qQ][tT]",
@@ -581,9 +589,17 @@ frogr_util_get_supported_files (void)
"*.[mM][pP][gG]",
"*.avi",
NULL
-};
+ };
+
+ return supported_images;
+}
+
#else
- static const gchar *frogr_supported_files[] = {
+
+const gchar * const *
+frogr_util_get_supported_mimetypes (void)
+{
+ static const gchar *supported_mimetypes[] = {
"image/jpg",
"image/jpeg",
"image/png",
@@ -595,7 +611,7 @@ frogr_util_get_supported_files (void)
"video/x-msvideo",
NULL
};
-#endif
- return frogr_supported_files;
+ return supported_mimetypes;
}
+#endif /* MAC_INTEGRATION */
diff --git a/src/frogr-util.h b/src/frogr-util.h
index 32b7ba4..048021b 100644
--- a/src/frogr-util.h
+++ b/src/frogr-util.h
@@ -47,7 +47,13 @@ GdkPixbuf *frogr_util_get_pixbuf_from_image_contents (const guchar *contents, gs
gchar *frogr_util_get_datasize_string (gulong datasize);
-const gchar * const *frogr_util_get_supported_files (void);
+#ifdef MAC_INTEGRATION
+const gchar * const *frogr_util_get_supported_images (void);
+
+const gchar * const *frogr_util_get_supported_videos (void);
+#else
+const gchar * const *frogr_util_get_supported_mimetypes (void);
+#endif
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]