[gthumb] desktop background: allow to set an xcf image as background image
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] desktop background: allow to set an xcf image as background image
- Date: Thu, 14 Mar 2013 11:36:23 +0000 (UTC)
commit 0a18437462c8bc64a686228d34d309a6861eec22
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Mar 14 11:59:57 2013 +0100
desktop background: allow to set an xcf image as background image
convert the image to jpeg if the mime type is not supported by GdkPixbuf
extensions/desktop_background/actions.c | 18 ++++++++-------
gthumb/pixbuf-utils.c | 35 +++++++++++++++++++++++++++++++
gthumb/pixbuf-utils.h | 1 +
3 files changed, 46 insertions(+), 8 deletions(-)
---
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
index 6dbf7e3..5c90844 100644
--- a/extensions/desktop_background/actions.c
+++ b/extensions/desktop_background/actions.c
@@ -255,13 +255,21 @@ gth_browser_activate_action_tool_desktop_background (GtkAction *action,
{
WallpaperData *wdata;
gboolean saving_wallpaper = FALSE;
- GthFileData *file_data;
GList *items;
GList *file_list;
+ GthFileData *file_data;
+ const char *mime_type;
wdata = wallpaper_data_new (browser);
- if (gth_main_extension_is_active ("image_viewer") && gth_browser_get_file_modified (browser)) {
+ items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view
(browser)));
+ file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+ file_data = (file_list != NULL) ? file_list->data : NULL;
+ mime_type = (file_data != NULL) ? gth_file_data_get_mime_type (file_data) : NULL;
+
+ if (gth_main_extension_is_active ("image_viewer")
+ && (gth_browser_get_file_modified (browser) || ! _gdk_pixbuf_mime_type_is_readable (mime_type)))
+ {
GtkWidget *viewer_page;
viewer_page = gth_browser_get_viewer_page (browser);
@@ -291,12 +299,6 @@ gth_browser_activate_action_tool_desktop_background (GtkAction *action,
if (saving_wallpaper)
return;
- items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view
(browser)));
- file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
- if (file_list == NULL)
- return;
-
- file_data = file_list->data;
if (file_data == NULL)
return;
diff --git a/gthumb/pixbuf-utils.c b/gthumb/pixbuf-utils.c
index faadda0..311c567 100644
--- a/gthumb/pixbuf-utils.c
+++ b/gthumb/pixbuf-utils.c
@@ -196,3 +196,38 @@ _gdk_pixbuf_get_type_from_mime_type (const char *mime_type)
else
return g_strdup (mime_type);
}
+
+
+gboolean
+_gdk_pixbuf_mime_type_is_readable (const char *mime_type)
+{
+ GSList *formats;
+ GSList *scan;
+ gboolean result;
+
+ if (mime_type == NULL)
+ return FALSE;
+
+ result = FALSE;
+ formats = gdk_pixbuf_get_formats ();
+ for (scan = formats; ! result && scan; scan = scan->next) {
+ GdkPixbufFormat *format = scan->data;
+ char **mime_types;
+ int i;
+
+ if (gdk_pixbuf_format_is_disabled (format))
+ continue;
+
+ mime_types = gdk_pixbuf_format_get_mime_types (format);
+ for (i = 0; mime_types[i] != NULL; i++) {
+ if (strcmp (mime_type, mime_types[i]) == 0) {
+ result = TRUE;
+ break;
+ }
+ }
+ }
+
+ g_slist_free (formats);
+
+ return result;
+}
diff --git a/gthumb/pixbuf-utils.h b/gthumb/pixbuf-utils.h
index b51d76e..5f4a373 100644
--- a/gthumb/pixbuf-utils.h
+++ b/gthumb/pixbuf-utils.h
@@ -39,6 +39,7 @@ GdkPixbuf * _gdk_pixbuf_scale_simple_safe (const GdkPixbuf *src,
GdkPixbuf * _gdk_pixbuf_transform (GdkPixbuf *src,
GthTransform transform);
char * _gdk_pixbuf_get_type_from_mime_type (const char *mime_type);
+gboolean _gdk_pixbuf_mime_type_is_readable (const char *mime_type);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]