[gnome-photos] utils: Add photos_utils_get_extension_from_mime_type



commit 37fe58c310bd146908747fb29d16ae3244cd5785
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon May 25 16:04:47 2015 +0200

    utils: Add photos_utils_get_extension_from_mime_type

 src/photos-utils.c |   37 ++++++++++++++++++++++++++++++++++++-
 src/photos-utils.h |    4 +++-
 2 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-utils.c b/src/photos-utils.c
index e99395b..8ec4303 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013, 2014 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -619,6 +619,41 @@ photos_utils_flash_on_quark (void)
 }
 
 
+gchar *
+photos_utils_get_extension_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 = photos_utils_get_pixbuf_common_suffix (format);
+              break;
+            }
+        }
+
+      g_strfreev (supported_mime_types);
+      if (ret_val != NULL)
+        break;
+    }
+
+  g_slist_free (formats);
+  return ret_val;
+}
+
+
 gint
 photos_utils_get_icon_size (void)
 {
diff --git a/src/photos-utils.h b/src/photos-utils.h
index d6726be..25af28a 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -1,6 +1,6 @@
 /*
  * Photos - access, organize and share your photos on GNOME
- * Copyright © 2012, 2013, 2014 Red Hat, Inc.
+ * Copyright © 2012, 2013, 2014, 2015 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -78,6 +78,8 @@ GQuark           photos_utils_flash_off_quark             (void);
 
 GQuark           photos_utils_flash_on_quark              (void);
 
+gchar           *photos_utils_get_extension_from_mime_type (const gchar *mime_type);
+
 gint             photos_utils_get_icon_size               (void);
 
 gint             photos_utils_get_icon_size_unscaled      (void);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]