static gboolean awn_image_expose (GtkWidget *widget, GdkEventExpose *event) { AwnImagePrivate *priv = AWN_IMAGE (widget)->priv; GtkImage *image = GTK_IMAGE (widget); cairo_t *cr; GdkPixbuf *pixbuf = NULL; GdkPixmap *pixmap = NULL; switch (gtk_image_get_storage_type (GTK_IMAGE (widget))) { case GTK_IMAGE_EMPTY: break; case GTK_IMAGE_PIXBUF: pixbuf = gtk_image_get_pixbuf (image); break; case GTK_IMAGE_PIXMAP: gtk_image_get_pixmap (image, &pixmap, NULL); break; default: g_warning ("AwnImage doesn't support this storage type"); return FALSE; } cr = awn_effects_cairo_create_clipped (priv->effects, event); g_return_val_if_fail (cr, FALSE); if (pixbuf || pixmap) { if (pixbuf) { gdk_cairo_set_source_pixbuf (cr, pixbuf, 0.0, 0.0); } else if (pixmap) { gdk_cairo_set_source_pixmap (cr, pixmap, 0.0, 0.0); } cairo_paint (cr); } awn_effects_cairo_destroy (priv->effects); return TRUE; }
GtkWidget *build_line(gint start_x, gint start_y , gint width, gint height, GtkWidget *hour_line, GdkColor *line_color) { GdkColormap *pic1_cmap; GdkVisual *pic1_vis; GdkPixmap *pic1; GdkGC *pic1_gc; GtkWidget *new_hour_line; gint depth = 16; gboolean first = FALSE; /* * GdkPixbuf *scaled; scaled = gdk_pixbuf_scale_simple (pix, w, h, GDK_INTERP_BILINEAR); */ pic1_cmap = gdk_colormap_get_system(); pic1_vis = gdk_colormap_get_visual(pic1_cmap); depth = pic1_vis->depth; if (hour_line == NULL) { pic1 = gdk_pixmap_new(NULL, width, height, depth); gdk_drawable_set_colormap(pic1, pic1_cmap); first = TRUE; } else gtk_image_get_pixmap(GTK_IMAGE(hour_line), &pic1, NULL); pic1_gc = gdk_gc_new(pic1); if (first) { gdk_gc_set_foreground(pic1_gc, line_color); gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height); } else { gdk_draw_rectangle(pic1, pic1_gc, TRUE, start_x, start_y, width, height); } new_hour_line = gtk_image_new_from_pixmap(pic1, NULL); g_object_unref(pic1_gc); g_object_unref(pic1); return(new_hour_line); }