aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-avatar-chooser.c
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-11-11 23:27:45 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-11-11 23:27:45 +0800
commitba9555296ba39b0425c70faaa8c02d28a8ce52af (patch)
treee07ff3c7697a5227f2d7e6787be33976a965f28a /libempathy-gtk/empathy-avatar-chooser.c
parentab3a47aacad985b6dd6816884a20fc5ce039d07d (diff)
downloadgsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar.gz
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar.bz2
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar.lz
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar.xz
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.tar.zst
gsoc2013-empathy-ba9555296ba39b0425c70faaa8c02d28a8ce52af.zip
Prefer png or jpeg if possible when converting avatars
svn path=/trunk/; revision=1702
Diffstat (limited to 'libempathy-gtk/empathy-avatar-chooser.c')
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index 3684fb0be..d1a3fb96c 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -309,9 +309,6 @@ can_satisfy_mime_type_requirements (gchar **accepted_mime_types,
gchar **satisfactory_format_name,
gchar **satisfactory_mime_type)
{
- GSList *formats;
- GSList *l;
- gchar **strv;
gchar *name = NULL,
*type = NULL;
gboolean done = FALSE;
@@ -323,29 +320,46 @@ can_satisfy_mime_type_requirements (gchar **accepted_mime_types,
g_assert (satisfactory_format_name != NULL);
g_assert (satisfactory_mime_type != NULL);
- formats = gdk_pixbuf_get_formats ();
+ /* Special-case png and jpeg to avoid accidentally saving to something
+ * uncompressed like bmp. This assumes that we can write image/png and
+ * image/jpeg; if this isn't true then something's really wrong with
+ * GdkPixbuf.
+ */
+ if (str_in_strv ("image/png", accepted_mime_types)) {
+ name = g_strdup ("png");
+ type = g_strdup ("image/png");
+ done = TRUE;
+ } else if (str_in_strv ("image/jpeg", accepted_mime_types)) {
+ name = g_strdup ("jpeg");
+ type = g_strdup ("image/jpeg");
+ done = TRUE;
+ } else {
+ GSList *formats = gdk_pixbuf_get_formats ();
+ GSList *l;
+ gchar **strv;
- for (l = formats; !done && l != NULL; l = l->next) {
- GdkPixbufFormat *format = l->data;
- gchar **format_mime_types;
+ for (l = formats; !done && l != NULL; l = l->next) {
+ GdkPixbufFormat *format = l->data;
+ gchar **format_mime_types;
- if (!gdk_pixbuf_format_is_writable (format)) {
- continue;
- }
+ if (!gdk_pixbuf_format_is_writable (format)) {
+ continue;
+ }
- format_mime_types = gdk_pixbuf_format_get_mime_types (format);
- for (strv = format_mime_types; *strv != NULL; strv++) {
- if (str_in_strv (*strv, accepted_mime_types)) {
- name = gdk_pixbuf_format_get_name (format);
- type = g_strdup (*strv);
- done = TRUE;
- break;
+ format_mime_types = gdk_pixbuf_format_get_mime_types (format);
+ for (strv = format_mime_types; *strv != NULL; strv++) {
+ if (str_in_strv (*strv, accepted_mime_types)) {
+ name = gdk_pixbuf_format_get_name (format);
+ type = g_strdup (*strv);
+ done = TRUE;
+ break;
+ }
}
+ g_strfreev (format_mime_types);
}
- g_strfreev (format_mime_types);
- }
- g_slist_free (formats);
+ g_slist_free (formats);
+ }
if (done) {
if (satisfactory_format_name != NULL) {