---
 gtktheory.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 58 insertions(+), 2 deletions(-)

diff --git a/gtktheory.c b/gtktheory.c
index 98036df3..d8485228 100644
--- a/gtktheory.c
+++ b/gtktheory.c
@@ -539,10 +539,52 @@ GraphDraw(GtkWidget * pwGraph, cairo_t * cr, theorywidget 
* ptw)
     for (i = 0; i < 3; i++)
         ax[i] = x + (int) ((float) cx * ptw->aar[iPlayer][i]);
 
+#if GTK_CHECK_VERSION(3, 0, 0)
+    GtkStyleContext *context = gtk_widget_get_style_context(pwGraph);
+    gtk_style_context_save(context);
+    gtk_style_context_set_state(context, GTK_STATE_FLAG_NORMAL);
+
+    gtk_render_background(context, cr, x, 12, cx, cy);
+    gtk_render_frame(context, cr, x, 12, cx, cy);
+
+    cairo_save(cr);
+    cairo_rectangle(cr, x + 1, 13, ax[0] - x, cy - 2);
+    cairo_set_source_rgb(cr, 0.0, 0.5, 0.0);
+    cairo_fill(cr);
+    cairo_restore(cr);
+
+    gtk_style_context_restore(context);
+#else
     gtk_locdef_paint_box(gtk_widget_get_style(pwGraph), 
gtk_widget_get_window(pwGraph), cr, GTK_STATE_NORMAL,
                          GTK_SHADOW_IN, NULL, pwGraph, "doubling-window", x, 
12, cx, cy);
+#endif
 
     /* FIXME it's horrible to abuse the "state" parameters like this */
+#if GTK_CHECK_VERSION(3, 0, 0)
+    if (ptw->aar[iPlayer][1] > ptw->aar[iPlayer][0]) {
+        gtk_style_context_save(context);
+        gtk_style_context_set_state(context, GTK_STATE_FLAG_ACTIVE);
+        gtk_render_background(context, cr, ax[0], 13, ax[1] - ax[0], cy - 2);
+        gtk_render_frame(context, cr, ax[0], 13, ax[1] - ax[0], cy - 2);
+        gtk_style_context_restore(context);
+    }
+
+    if (ptw->aar[iPlayer][2] > ptw->aar[iPlayer][1]) {
+        gtk_style_context_save(context);
+        gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT);
+        gtk_render_background(context, cr, ax[1], 13, ax[2] - ax[1], cy - 2);
+        gtk_render_frame(context, cr, ax[1], 13, ax[2] - ax[1], cy - 2);
+        gtk_style_context_restore(context);
+    }
+
+    if (ptw->aar[iPlayer][2] < 1.0f) {
+        gtk_style_context_save(context);
+        gtk_style_context_set_state(context, GTK_STATE_FLAG_SELECTED);
+        gtk_render_background(context, cr, ax[2], 13, x + cx - ax[2], cy - 2);
+        gtk_render_frame(context, cr, ax[2], 13, x + cx - ax[2], cy - 2);
+        gtk_style_context_restore(context);
+    }
+#else
     if (ptw->aar[iPlayer][1] > ptw->aar[iPlayer][0])
         gtk_locdef_paint_box(gtk_widget_get_style(pwGraph), 
gtk_widget_get_window(pwGraph), cr,
                              GTK_STATE_ACTIVE, GTK_SHADOW_OUT, NULL, pwGraph, 
"take", ax[0], 13, ax[1] - ax[0], cy - 2);
@@ -554,6 +596,7 @@ GraphDraw(GtkWidget * pwGraph, cairo_t * cr, theorywidget * 
ptw)
     if (ptw->aar[iPlayer][2] < 1.0f)
         gtk_locdef_paint_box(gtk_widget_get_style(pwGraph), 
gtk_widget_get_window(pwGraph), cr,
                              GTK_STATE_SELECTED, GTK_SHADOW_OUT, NULL, 
pwGraph, "too-good", ax[2], 13, x + cx - ax[2], cy - 2);
+#endif
 
     return TRUE;
 }
@@ -1073,8 +1116,21 @@ GTKShowTheory(const int fActivePage)
 
     font_desc = pango_font_description_from_string("Monospace");
 #if GTK_CHECK_VERSION(3,0,0)
-    /* FIXME: this is deprecated since version 3.16, use the CSS instead */
-    gtk_widget_override_font(ptw->pwGammonPrice, font_desc);
+{
+    GtkCssProvider *provider = gtk_css_provider_new();
+    GtkStyleContext *context =
+        gtk_widget_get_style_context(ptw->pwGammonPrice);
+
+    gtk_css_provider_load_from_data(provider,
+                                    "textview { font-family: Monospace; }",
+                                    -1, NULL);
+
+    gtk_style_context_add_provider(context,
+                                   GTK_STYLE_PROVIDER(provider),
+                                   GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+    g_object_unref(provider);
+}
 #else
     gtk_widget_modify_font(ptw->pwGammonPrice, font_desc);
 #endif
-- 
2.51.0


Reply via email to