Fix GTK casts to restore correct compilation on GTK 2.0 after r6022.
[sgt/puzzles] / gtk.c
diff --git a/gtk.c b/gtk.c
index e3bffa5..05d7ad4 100644 (file)
--- a/gtk.c
+++ b/gtk.c
 #define USE_PANGO
 #endif
 
+#ifdef DEBUGGING
+static FILE *debug_fp = NULL;
+
+void dputs(char *buf)
+{
+    if (!debug_fp) {
+        debug_fp = fopen("debug.log", "w");
+    }
+
+    fputs(buf, stderr);
+
+    if (debug_fp) {
+        fputs(buf, debug_fp);
+        fflush(debug_fp);
+    }
+}
+
+void debug_printf(char *fmt, ...)
+{
+    char buf[4096];
+    va_list ap;
+
+    va_start(ap, fmt);
+    vsprintf(buf, fmt, ap);
+    dputs(buf);
+    va_end(ap);
+}
+#endif
+
 /* ----------------------------------------------------------------------
  * Error reporting functions used elsewhere.
  */
@@ -334,6 +363,15 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
     sfree(points);
 }
 
+void draw_circle(frontend *fe, int cx, int cy, int radius,
+                 int fill, int colour)
+{
+    gdk_gc_set_foreground(fe->gc, &fe->colours[colour]);
+    gdk_draw_arc(fe->pixmap, fe->gc, fill,
+                 cx - radius, cy - radius,
+                 2 * radius, 2 * radius, 0, 360 * 64);
+}
+
 struct blitter {
     GdkPixmap *pixmap;
     int w, h, x, y;
@@ -960,7 +998,11 @@ static void menu_preset_event(GtkMenuItem *menuitem, gpointer data)
     fe->w = x;
     fe->h = y;
     gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);
-    gtk_window_resize(GTK_WINDOW(fe->window), 1, 1);
+    {
+        GtkRequisition req;
+        gtk_widget_size_request(GTK_WIDGET(fe->window), &req);
+        gtk_window_resize(GTK_WINDOW(fe->window), req.width, req.height);
+    }
 }
 
 GdkAtom compound_text_atom, utf8_string_atom;
@@ -1105,7 +1147,11 @@ static void menu_config_event(GtkMenuItem *menuitem, gpointer data)
     fe->w = x;
     fe->h = y;
     gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);
-    gtk_window_resize(GTK_WINDOW(fe->window), 1, 1);
+    {
+        GtkRequisition req;
+        gtk_widget_size_request(GTK_WIDGET(fe->window), &req);
+        gtk_window_resize(GTK_WINDOW(fe->window), req.width, req.height);
+    }
 }
 
 static void menu_about_event(GtkMenuItem *menuitem, gpointer data)