]> git.cworth.org Git - grrobot/blobdiff - src/grr_board_view.c
Update to 2020
[grrobot] / src / grr_board_view.c
index 6a184419eb2254ace5420815701ec6e1f90ad2ea..ca1d0e1414334b9192a4c802733af6f4cc951ea1 100644 (file)
@@ -1,6 +1,6 @@
 /* grr_board_view - GTK+ widget for displaying an rr_board
  *
- * Copyright © 2003 Carl Worth
+ * Copyright Â© 2003 Carl Worth
  *
  * Permission to use, copy, modify, distribute, and sell this software
  * and its documentation for any purpose is hereby granted without
@@ -30,7 +30,9 @@
 #include <string.h>
 
 #include <cairo.h>
-#include <xsvg.h>
+#include <cairo-xlib.h>
+#include <librsvg/rsvg.h>
+#include <librsvg/rsvg-cairo.h>
 
 #include <gtk/gtkmain.h>
 #include <gtk/gtksignal.h>
@@ -337,6 +339,8 @@ grr_board_view_expose (GtkWidget      *widget,
     rr_board_t *board;
     Display *dpy;
     Drawable drawable;
+    Visual *visual;
+    cairo_surface_t *surface;
     cairo_t *xrs;
     GdkDrawable *real_drawable;
     gint x_off, y_off;
@@ -351,14 +355,7 @@ grr_board_view_expose (GtkWidget      *widget,
     view = GRR_BOARD_VIEW (widget);
     board = view->board;
 
-    /* Unabstract X from GTK+ */
-    gdk_window_get_internal_paint_info (widget->window, &real_drawable, &x_off, &y_off);
-    dpy = gdk_x11_drawable_get_xdisplay (real_drawable);
-    drawable = gdk_x11_drawable_get_xid (real_drawable);
-
-    /* Ignore GTK+ and use Cairo for drawing. */
-    xrs = cairo_create ();
-    cairo_set_target_drawable (xrs, dpy, drawable);
+    xrs = gdk_cairo_create (widget->window);
 
     new_cell_width = widget->allocation.width / view->board_width;
     if (new_cell_width == 0)
@@ -448,23 +445,18 @@ grr_board_view_expose (GtkWidget      *widget,
            cairo_translate (xrs, i * view->cell_width, j * view->cell_height);
 
            if ((i+j) % 2 == 0)
-               grr_icon_draw_predrawn (view->cell1_icon, xrs);
+               grr_icon_draw_predrawn (view->cell1_icon, xrs, 1.0);
            else
-               grr_icon_draw_predrawn (view->cell2_icon, xrs);
-
-           if (target) {
-               if (target && target != goal_target) {
-                   cairo_save (xrs);
-                   cairo_set_alpha (xrs, 0.25);
-                   grr_icon_draw_predrawn (view->target_icon[rr_target_idx (target)], xrs);
-                   cairo_restore (xrs);
-               } else {
-                   grr_icon_draw_predrawn (view->target_icon[rr_target_idx (target)], xrs);
-               }
-           }
+               grr_icon_draw_predrawn (view->cell2_icon, xrs, 1.0);
+
+           if (target)
+               grr_icon_draw_predrawn (view->target_icon[rr_target_idx (target)],
+                                       xrs,
+                                       target == goal_target ? 1.0 : 0.25);
 
            if (robot)
-               grr_icon_draw_predrawn (view->robot_icon[rr_robot_idx (robot)], xrs);
+               grr_icon_draw_predrawn (view->robot_icon[rr_robot_idx (robot)],
+                                       xrs, 1.0);
 
            cairo_restore (xrs);
        }
@@ -481,7 +473,7 @@ grr_board_view_expose (GtkWidget      *widget,
                     2 * view->cell_width / GRR_SVG_ASSUMED_WIDTH,
                     2 * view->cell_height / GRR_SVG_ASSUMED_HEIGHT);
        cairo_rectangle (xrs, 0, 0, GRR_SVG_ASSUMED_WIDTH, GRR_SVG_ASSUMED_HEIGHT);
-       cairo_set_rgb_color (xrs, 1, 1, 1);
+       cairo_set_source_rgb (xrs, 1, 1, 1);
        cairo_fill (xrs);
        grr_icon_draw (view->target_icon[rr_target_idx (goal_target)], xrs);
        cairo_restore (xrs);
@@ -501,8 +493,7 @@ grr_board_view_expose (GtkWidget      *widget,
                       2 * M_PI * (60.0 - view->time) / 60.0 - M_PI_2);
            cairo_close_path (xrs);
 
-           cairo_set_rgb_color (xrs, 0.0, 0.0, 0.0);
-           cairo_set_alpha (xrs, 0.5);
+           cairo_set_source_rgba (xrs, 0.0, 0.0, 0.0, 0.5);
            cairo_fill (xrs);
 
            cairo_restore (xrs);