aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-02-12 16:43:00 -0600
committerTed Gould <ted@canonical.com>2009-02-12 16:43:00 -0600
commit6b3a32c443111a23d2953d85be2f2f3b930ed405 (patch)
treef46bd0bad30f9ab62f7b77de79b901058d91700d
parenta2e77d6839d9236118886f2cdc761ff298ff43c1 (diff)
downloadlibayatana-indicator-6b3a32c443111a23d2953d85be2f2f3b930ed405.tar.gz
libayatana-indicator-6b3a32c443111a23d2953d85be2f2f3b930ed405.tar.bz2
libayatana-indicator-6b3a32c443111a23d2953d85be2f2f3b930ed405.zip
Changing from using a memory stream to using a buffer, the memory stream one seems to be broken.
-rw-r--r--libindicate/indicator.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/libindicate/indicator.c b/libindicate/indicator.c
index d647930..e4bae76 100644
--- a/libindicate/indicator.c
+++ b/libindicate/indicator.c
@@ -240,22 +240,32 @@ indicate_indicator_set_property (IndicateIndicator * indicator, const gchar * ke
void
indicate_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data)
{
- GOutputStream * output = g_memory_output_stream_new(NULL, 0, g_realloc, g_free);
-
- if (!gdk_pixbuf_save_to_stream(data, output, "png", NULL, NULL, "compress", 9)) {
- g_output_stream_close(output, NULL, NULL);
- g_warning("Unable to create pixbuf data stream");
+ if (!GDK_IS_PIXBUF(data)) {
+ g_warning("Invalide GdkPixbuf");
return;
}
- gpointer png_data = g_memory_output_stream_get_data(output);
- gsize png_data_len = g_memory_output_stream_get_data_size(output);
+ GError * error = NULL;
+ gchar * png_data;
+ gsize png_data_len;
+
+ if (!gdk_pixbuf_save_to_buffer(data, &png_data, &png_data_len, "png", &error, NULL)) {
+ if (error == NULL) {
+ g_warning("Unable to create pixbuf data stream: %d", png_data_len);
+ } else {
+ g_warning("Unable to create pixbuf data stream: %s", error->message);
+ g_error_free(error);
+ error = NULL;
+ }
+
+ return;
+ }
gchar * prop_str = g_base64_encode(png_data, png_data_len);
indicate_indicator_set_property(indicator, key, prop_str);
g_free(prop_str);
- g_output_stream_close(output, NULL, NULL);
+ g_free(png_data);
return;
}