chiark / gitweb /
Cleanup: relieve frontends of the duty to call
[sgt-puzzles.git] / gtk.c
diff --git a/gtk.c b/gtk.c
index b72752a538221c13b6576c5590409d3fbc044c59..07f2535eb22f26d9244a31a388f4b0558a5ecb2a 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -116,7 +116,6 @@ struct frontend {
     GtkWidget *cfgbox;
     void *paste_data;
     int paste_data_len;
-    char *laststatus;
     int pw, ph;                        /* pixmap size (w, h are area size) */
     int ox, oy;                        /* offset of pixmap in drawing area */
     char *filesel_name;
@@ -141,19 +140,11 @@ void frontend_default_colour(frontend *fe, float *output)
 void gtk_status_bar(void *handle, char *text)
 {
     frontend *fe = (frontend *)handle;
-    char *rewritten;
 
     assert(fe->statusbar);
 
-    rewritten = midend_rewrite_statusbar(fe->me, text);
-    if (!fe->laststatus || strcmp(rewritten, fe->laststatus)) {
-       gtk_statusbar_pop(GTK_STATUSBAR(fe->statusbar), fe->statusctx);
-       gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, rewritten);
-       sfree(fe->laststatus);
-       fe->laststatus = rewritten;
-    } else {
-       sfree(rewritten);
-    }
+    gtk_statusbar_pop(GTK_STATUSBAR(fe->statusbar), fe->statusctx);
+    gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, text);
 }
 
 void gtk_start_draw(void *handle)
@@ -290,6 +281,8 @@ void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize,
 
         if (align & ALIGN_VCENTRE)
             rect.y -= rect.height / 2;
+       else
+           rect.y -= rect.height;
 
         if (align & ALIGN_HCENTRE)
             rect.x -= rect.width / 2;
@@ -317,6 +310,8 @@ void gtk_draw_text(void *handle, int x, int y, int fonttype, int fontsize,
                            &lb, &rb, &wid, &asc, &desc);
         if (align & ALIGN_VCENTRE)
             y += asc - (asc+desc)/2;
+       else
+            y += asc;
 
        /*
         * ... but horizontal extents with respect to the provided
@@ -373,7 +368,17 @@ void gtk_draw_poly(void *handle, int *coords, int npoints,
     }
     assert(outlinecolour >= 0);
     gdk_gc_set_foreground(fe->gc, &fe->colours[outlinecolour]);
-    gdk_draw_polygon(fe->pixmap, fe->gc, FALSE, points, npoints);
+
+    /*
+     * In principle we ought to be able to use gdk_draw_polygon for
+     * the outline as well. In fact, it turns out to interact badly
+     * with a clipping region, for no terribly obvious reason, so I
+     * draw the outline as a sequence of lines instead.
+     */
+    for (i = 0; i < npoints; i++)
+       gdk_draw_line(fe->pixmap, fe->gc,
+                     points[i].x, points[i].y,
+                     points[(i+1)%npoints].x, points[(i+1)%npoints].y);
 
     sfree(points);
 }
@@ -540,6 +545,10 @@ static gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
         keyval = MOD_NUM_KEYPAD | '0';
     else if (event->keyval == GDK_KP_Begin || event->keyval == GDK_KP_5)
         keyval = MOD_NUM_KEYPAD | '5';
+    else if (event->keyval == GDK_BackSpace ||
+            event->keyval == GDK_Delete ||
+            event->keyval == GDK_KP_Delete)
+        keyval = '\177';
     else if (event->string[0] && !event->string[1])
         keyval = (unsigned char)event->string[0];
     else
@@ -1652,8 +1661,6 @@ static frontend *new_window(char *arg, char **error)
     fe->fonts = NULL;
     fe->nfonts = fe->fontsize = 0;
 
-    fe->laststatus = NULL;
-
     fe->paste_data = NULL;
     fe->paste_data_len = 0;