pidgin/gtkwhiteboard.c

changeset 35549
1128302c7511
parent 35547
561418a41b08
child 35550
b18fa06ff063
equal deleted inserted replaced
35548:e3ee59a7965c 35549:1128302c7511
381 static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data) 381 static gboolean pidgin_whiteboard_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
382 { 382 {
383 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data; 383 PidginWhiteboard *gtkwb = (PidginWhiteboard*)data;
384 cairo_t *cr; 384 cairo_t *cr;
385 GtkAllocation allocation; 385 GtkAllocation allocation;
386 #if GTK_CHECK_VERSION(3,0,0)
387 GdkRGBA white = {1.0, 1.0, 1.0, 1.0};
388 #endif
386 389
387 if (gtkwb->priv->cr) 390 if (gtkwb->priv->cr)
388 cairo_destroy(gtkwb->priv->cr); 391 cairo_destroy(gtkwb->priv->cr);
389 if (gtkwb->priv->surface) 392 if (gtkwb->priv->surface)
390 cairo_surface_destroy(gtkwb->priv->surface); 393 cairo_surface_destroy(gtkwb->priv->surface);
392 gtk_widget_get_allocation(widget, &allocation); 395 gtk_widget_get_allocation(widget, &allocation);
393 396
394 gtkwb->priv->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 397 gtkwb->priv->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
395 allocation.width, allocation.height); 398 allocation.width, allocation.height);
396 gtkwb->priv->cr = cr = cairo_create(gtkwb->priv->surface); 399 gtkwb->priv->cr = cr = cairo_create(gtkwb->priv->surface);
400 #if GTK_CHECK_VERSION(3,0,0)
401 gdk_cairo_set_source_rgba(cr, &white);
402 #else
397 gdk_cairo_set_source_color(cr, &gtk_widget_get_style(widget)->white); 403 gdk_cairo_set_source_color(cr, &gtk_widget_get_style(widget)->white);
404 #endif
398 cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); 405 cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
399 cairo_fill(cr); 406 cairo_fill(cr);
400 407
401 return TRUE; 408 return TRUE;
402 } 409 }
630 { 637 {
631 PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); 638 PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb);
632 GtkWidget *widget = gtkwb->drawing_area; 639 GtkWidget *widget = gtkwb->drawing_area;
633 cairo_t *gfx_con = gtkwb->priv->cr; 640 cairo_t *gfx_con = gtkwb->priv->cr;
634 GdkColor col; 641 GdkColor col;
642 #if GTK_CHECK_VERSION(3,0,0)
643 GdkRGBA rgba;
644 #endif
635 645
636 /* Interpret and convert color */ 646 /* Interpret and convert color */
637 pidgin_whiteboard_rgb24_to_rgb48(color, &col); 647 pidgin_whiteboard_rgb24_to_rgb48(color, &col);
638 648
649 #if GTK_CHECK_VERSION(3,0,0)
650 rgba.red = col.red / 0xffff;
651 rgba.green = col.green / 0xffff;
652 rgba.blue = col.blue / 0xffff;
653 rgba.alpha = 1.0;
654 gdk_cairo_set_source_rgba(gfx_con, &rgba);
655 #else
639 gdk_cairo_set_source_color(gfx_con, &col); 656 gdk_cairo_set_source_color(gfx_con, &col);
657 #endif
640 658
641 /* Draw a circle */ 659 /* Draw a circle */
642 cairo_arc(gfx_con, 660 cairo_arc(gfx_con,
643 x, y, 661 x, y,
644 size / 2.0, 662 size / 2.0,
737 { 755 {
738 PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb); 756 PidginWhiteboard *gtkwb = purple_whiteboard_get_ui_data(wb);
739 GtkWidget *drawing_area = gtkwb->drawing_area; 757 GtkWidget *drawing_area = gtkwb->drawing_area;
740 cairo_t *cr = gtkwb->priv->cr; 758 cairo_t *cr = gtkwb->priv->cr;
741 GtkAllocation allocation; 759 GtkAllocation allocation;
760 #if GTK_CHECK_VERSION(3,0,0)
761 GdkRGBA white = {1.0, 1.0, 1.0, 1.0};
762 #endif
742 763
743 gtk_widget_get_allocation(drawing_area, &allocation); 764 gtk_widget_get_allocation(drawing_area, &allocation);
744 765
766 #if GTK_CHECK_VERSION(3,0,0)
767 gdk_cairo_set_source_rgba(cr, &white);
768 #else
745 gdk_cairo_set_source_color(cr, 769 gdk_cairo_set_source_color(cr,
746 &gtk_widget_get_style(drawing_area)->white); 770 &gtk_widget_get_style(drawing_area)->white);
771 #endif
747 cairo_rectangle(cr, 0, 0, allocation.width, allocation.height); 772 cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
748 cairo_fill(cr); 773 cairo_fill(cr);
749 774
750 gtk_widget_queue_draw_area(drawing_area, 0, 0, 775 gtk_widget_queue_draw_area(drawing_area, 0, 0,
751 allocation.width, allocation.height); 776 allocation.width, allocation.height);

mercurial