Back to index

libindicate  12.10.0
indicator.c
Go to the documentation of this file.
00001 /*
00002 A library to allow applictions to provide simple indications of
00003 information to be displayed to users of the application through the
00004 interface shell.
00005 
00006 Copyright 2009 Canonical Ltd.
00007 
00008 Authors:
00009     Ted Gould <ted@canonical.com>
00010 
00011 This program is free software: you can redistribute it and/or modify it 
00012 under the terms of either or both of the following licenses:
00013 
00014 1) the GNU Lesser General Public License version 3, as published by the 
00015 Free Software Foundation; and/or
00016 2) the GNU Lesser General Public License version 2.1, as published by 
00017 the Free Software Foundation.
00018 
00019 This program is distributed in the hope that it will be useful, but 
00020 WITHOUT ANY WARRANTY; without even the implied warranties of 
00021 MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
00022 PURPOSE.  See the applicable version of the GNU Lesser General Public 
00023 License for more details.
00024 
00025 You should have received a copy of both the GNU Lesser General Public 
00026 License version 3 and version 2.1 along with this program.  If not, see 
00027 <http://www.gnu.org/licenses/>
00028 */
00029 
00030 #include "indicator.h"
00031 
00043 void
00044 indicate_gtk_indicator_set_property_icon (IndicateIndicator * indicator, const gchar * key, const GdkPixbuf * data)
00045 {
00046        if (!GDK_IS_PIXBUF(data)) {
00047               g_warning("Invalide GdkPixbuf");
00048               return;
00049        }
00050 
00051        GError * error = NULL;
00052        gchar * png_data;
00053        gsize png_data_len;
00054 
00055        if (!gdk_pixbuf_save_to_buffer((GdkPixbuf *)data, &png_data, &png_data_len, "png", &error, NULL)) {
00056               if (error == NULL) {
00057                      g_warning("Unable to create pixbuf data stream: %d", (gint)png_data_len);
00058               } else {
00059                      g_warning("Unable to create pixbuf data stream: %s", error->message);
00060                      g_error_free(error);
00061                      error = NULL;
00062               }
00063 
00064               return;
00065        }
00066 
00067        gchar * prop_str = g_base64_encode((guchar *)png_data, png_data_len);
00068        indicate_indicator_set_property(indicator, key, prop_str);
00069 
00070        g_free(prop_str);
00071        g_free(png_data);
00072 
00073        return;
00074 }