diff options
| author | Simon Tatham <anakin@pobox.com> | 2004-04-29 19:23:08 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2004-04-29 19:23:08 +0000 |
| commit | a8c8237bd0362e4fe44a451eb81544b451ae4444 (patch) | |
| tree | c50e8ec0ef03edcdba50cd651076290f657ffa7e /gtk.c | |
| parent | fa7ef572c782c9394f60202d950d3380dfdce5c3 (diff) | |
| download | puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.zip puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.gz puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.bz2 puzzles-a8c8237bd0362e4fe44a451eb81544b451ae4444.tar.xz | |
Added a status bar.
[originally from svn r4174]
Diffstat (limited to 'gtk.c')
| -rw-r--r-- | gtk.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -3,6 +3,7 @@ */ #include <stdio.h> +#include <assert.h> #include <stdlib.h> #include <time.h> #include <stdarg.h> @@ -50,6 +51,8 @@ struct font { struct frontend { GtkWidget *window; GtkWidget *area; + GtkWidget *statusbar; + guint statusctx; GdkPixmap *pixmap; GdkColor *colours; int ncolours; @@ -71,6 +74,14 @@ void frontend_default_colour(frontend *fe, float *output) output[2] = col.blue / 65535.0; } +void status_bar(frontend *fe, char *text) +{ + assert(fe->statusbar); + + gtk_statusbar_pop(GTK_STATUSBAR(fe->statusbar), fe->statusctx); + gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, text); +} + void start_draw(frontend *fe) { fe->gc = gdk_gc_new(fe->area->window); @@ -299,6 +310,21 @@ static gint expose_area(GtkWidget *widget, GdkEventExpose *event, return TRUE; } +static gint map_window(GtkWidget *widget, GdkEvent *event, + gpointer data) +{ + frontend *fe = (frontend *)data; + + /* + * Apparently we need to do this because otherwise the status + * bar will fail to update immediately. Annoying, but there we + * go. + */ + gtk_widget_queue_draw(fe->window); + + return TRUE; +} + static gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data) { @@ -483,6 +509,17 @@ static frontend *new_window(void) } } + if (midend_wants_statusbar(fe->me)) { + fe->statusbar = gtk_statusbar_new(); + gtk_box_pack_end(vbox, fe->statusbar, FALSE, FALSE, 0); + gtk_widget_show(fe->statusbar); + fe->statusctx = gtk_statusbar_get_context_id + (GTK_STATUSBAR(fe->statusbar), "game"); + gtk_statusbar_push(GTK_STATUSBAR(fe->statusbar), fe->statusctx, + ""); + } else + fe->statusbar = NULL; + fe->area = gtk_drawing_area_new(); midend_size(fe->me, &x, &y); gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y); @@ -505,6 +542,8 @@ static frontend *new_window(void) GTK_SIGNAL_FUNC(button_event), fe); gtk_signal_connect(GTK_OBJECT(fe->area), "expose_event", GTK_SIGNAL_FUNC(expose_area), fe); + gtk_signal_connect(GTK_OBJECT(fe->window), "map_event", + GTK_SIGNAL_FUNC(map_window), fe); gtk_signal_connect(GTK_OBJECT(fe->area), "configure_event", GTK_SIGNAL_FUNC(configure_area), fe); |