Logo Search packages:      
Sourcecode: libnotify version File versions  Download package

void notify_notification_set_icon_from_pixbuf ( NotifyNotification *  notification,
GdkPixbuf *  icon 
)

notify_notification_set_icon_from_pixbuf: : The notification. : The icon.

Sets the icon in the notification from a GdkPixbuf.

This will only work when libnotify is compiled against D-BUS 0.60 or higher.

Definition at line 925 of file notification.c.

{
#if CHECK_DBUS_VERSION(0, 60)
      gint width;
      gint height;
      gint rowstride;
      gint bits_per_sample;
      gint n_channels;
      guchar *image;
      gsize image_len;
      GValueArray *image_struct;
      GValue *value;
#endif

      g_return_if_fail(notification != NULL);
      g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));

#if CHECK_DBUS_VERSION(0, 60)
      width           = gdk_pixbuf_get_width(icon);
      height          = gdk_pixbuf_get_height(icon);
      rowstride       = gdk_pixbuf_get_rowstride(icon);
      n_channels      = gdk_pixbuf_get_n_channels(icon);
      bits_per_sample = gdk_pixbuf_get_bits_per_sample(icon);
      image_len       = (height - 1) * rowstride + width *
                        ((n_channels * bits_per_sample + 7) / 8);

      image = gdk_pixbuf_get_pixels(icon);

      image_struct = g_value_array_new(1);

      _gvalue_array_append_int(image_struct, width);
      _gvalue_array_append_int(image_struct, height);
      _gvalue_array_append_int(image_struct, rowstride);
      _gvalue_array_append_bool(image_struct, gdk_pixbuf_get_has_alpha(icon));
      _gvalue_array_append_int(image_struct, bits_per_sample);
      _gvalue_array_append_int(image_struct, n_channels);
      _gvalue_array_append_byte_array(image_struct, image, image_len);

      value = g_new0(GValue, 1);
      g_value_init(value, G_TYPE_VALUE_ARRAY);
      g_value_set_boxed_take_ownership(value, image_struct);

      g_hash_table_insert(notification->priv->hints,
                                    g_strdup("icon_data"), value);
#else /* D-BUS < 0.60 */
      g_warning("Raw images and pixbufs require D-BUS >= 0.60");
#endif
}


Generated by  Doxygen 1.6.0   Back to index