Skip to content

Instantly share code, notes, and snippets.

@Tefnet
Created December 12, 2012 19:20
Show Gist options
  • Save Tefnet/4270725 to your computer and use it in GitHub Desktop.
Save Tefnet/4270725 to your computer and use it in GitHub Desktop.
Shadow for GtkLabel
static gboolean label_exposed(GtkWidget *widget, GdkEventExpose *event, gpointer userdata)
{
double width = 4.0;
int offset_x = 2;
int offset_y = 2;
cairo_t *cr = gdk_cairo_create(widget->window);
gint x = widget->allocation.x;
gint y = widget->allocation.y;
PangoLayout *layout = gtk_label_get_layout(GTK_LABEL(widget));
if PANGO_IS_LAYOUT(layout) {
cairo_move_to (cr, x+offset_x, y+offset_y);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_set_line_width (cr, width);
pango_cairo_layout_path (cr, layout);
cairo_stroke (cr);
cairo_move_to (cr, x, y);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
pango_cairo_show_layout(cr, layout);
cairo_destroy(cr);
}
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment