[gnome-photos/wip/rishi/edit-mode: 30/33] utils: Add photos_utils_get_pixbuf_type_from_mime_type
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/edit-mode: 30/33] utils: Add photos_utils_get_pixbuf_type_from_mime_type
- Date: Wed, 11 Nov 2015 18:44:24 +0000 (UTC)
commit 13bcff4070bce5bf6eb006262f38d1fded790806
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Nov 11 16:42:10 2015 +0100
utils: Add photos_utils_get_pixbuf_type_from_mime_type
We need it to get the GdkPixbuf type when saving a BaseItem.
src/photos-utils.c | 35 +++++++++++++++++++++++++++++++++++
src/photos-utils.h | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index 34fa99c..909ab67 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -832,6 +832,41 @@ photos_utils_get_pixbuf_common_suffix (GdkPixbufFormat *format)
}
+gchar *
+photos_utils_get_pixbuf_type_from_mime_type (const gchar *mime_type)
+{
+ GSList *formats;
+ GSList *l;
+ gchar *ret_val = NULL;
+
+ formats = gdk_pixbuf_get_formats ();
+
+ for (l = formats; l != NULL; l = l->next)
+ {
+ GdkPixbufFormat *format = (GdkPixbufFormat*) l->data;
+ gchar **supported_mime_types;
+ guint i;
+
+ supported_mime_types = gdk_pixbuf_format_get_mime_types (format);
+ for (i = 0; supported_mime_types[i] != NULL; i++)
+ {
+ if (g_strcmp0 (mime_type, supported_mime_types[i]) == 0)
+ {
+ ret_val = gdk_pixbuf_format_get_name (format);
+ break;
+ }
+ }
+
+ g_strfreev (supported_mime_types);
+ if (ret_val != NULL)
+ break;
+ }
+
+ g_slist_free (formats);
+ return ret_val;
+}
+
+
const gchar *
photos_utils_get_provider_name (PhotosBaseManager *src_mngr, PhotosBaseItem *item)
{
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 2592436..776e9f2 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -112,6 +112,8 @@ gint photos_utils_get_icon_size_unscaled (void);
char* photos_utils_get_pixbuf_common_suffix (GdkPixbufFormat *format);
+gchar *photos_utils_get_pixbuf_type_from_mime_type (const gchar *mime_type);
+
const gchar *photos_utils_get_provider_name (PhotosBaseManager *src_mngr, PhotosBaseItem
*item);
GtkBorder *photos_utils_get_thumbnail_frame_border (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]