[goffice] GOImage: make fallback work for non-GUI case.



commit 141eb5c427e49caaccb4d54c7a8fd77c2e02b133
Author: Morten Welinder <terra gnome org>
Date:   Tue Mar 6 12:53:56 2012 -0500

    GOImage: make fallback work for non-GUI case.

 ChangeLog                |    5 +++++
 NEWS                     |    3 +++
 goffice/utils/go-image.c |   20 ++++++++++++++------
 3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7e64036..74eb51d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-06  Morten Welinder  <terra gnome org>
+
+	* goffice/utils/go-image.c (go_image_new_from_data): Make fallback
+	work even in the non-GUI case.
+
 2012-03-03  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/app/go-cmd-context-impl.h: fixed for nested structs introspection.
diff --git a/NEWS b/NEWS
index e8a0ec4..0880f23 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 goffice 0.9.3:
 
+Morten:
+	* Fix GOImage fallback for non-GUI case.
+
 --------------------------------------------------------------------------
 goffice 0.9.2:
 
diff --git a/goffice/utils/go-image.c b/goffice/utils/go-image.c
index d983612..14ceb11 100644
--- a/goffice/utils/go-image.c
+++ b/goffice/utils/go-image.c
@@ -491,18 +491,26 @@ go_image_new_from_data (char const *type, guint8 const *data, gsize length, char
 		}
 	}
 	if (image == NULL) {
-		GtkIconTheme *theme = gtk_icon_theme_get_default ();
+		GdkScreen *screen = gdk_screen_get_default ();
+		GtkIconTheme *theme = screen
+			? gtk_icon_theme_get_default()
+			: gtk_icon_theme_new();
 		GdkPixbuf *placeholder;
+		const char *icon_name;
+
 		if (gtk_icon_theme_has_icon (theme,"unknown_image"))
-			placeholder = gtk_icon_theme_load_icon (theme, "unknown_image", 100, 0, NULL);
+			icon_name = "unknown_image";
 		else if (gtk_icon_theme_has_icon (theme,"unknown"))
-			placeholder = gtk_icon_theme_load_icon (theme, "unknown", 100, 0, NULL);
+			icon_name = "unknown";
 		else
-			placeholder = gtk_icon_theme_load_icon (theme,
-			                                        gtk_icon_theme_get_example_icon_name (theme),
-			                                        100, 0, NULL);
+			icon_name = gtk_icon_theme_get_example_icon_name (theme);
+
+		placeholder = gtk_icon_theme_load_icon (theme, icon_name, 100, 0, NULL);
 		image = go_pixbuf_new_from_pixbuf (placeholder);
 		g_object_unref (placeholder);
+
+		if (!screen)
+			g_object_unref (theme);
 	}
 	if (format)
 		*format = g_strdup (type);



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