From: Kaj-Michael Lang Date: Tue, 30 Oct 2007 20:03:01 +0000 (+0200) Subject: Autorefresh once a second. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20688ede02a8c4413b1308c111a7813cd443e678;p=mapper Autorefresh once a second. --- diff --git a/src/gtkgps.c b/src/gtkgps.c index 06660ce..c68e4bd 100644 --- a/src/gtkgps.c +++ b/src/gtkgps.c @@ -33,6 +33,7 @@ static void gtk_gps_realize (GtkWidget *widget); static void gtk_gps_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gtk_gps_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); static void gtk_gps_paint_by_mode(GtkGps *gps); +static gboolean gtk_gps_refresh_cb(GtkWidget *widget); G_DEFINE_TYPE(GtkGps, gtk_gps, GTK_TYPE_WIDGET); @@ -103,6 +104,7 @@ gps->gc_sf=NULL; gps->width=300; gps->height=300; gps->size=300; +gps->esid=0; } static gboolean @@ -152,6 +154,8 @@ pango_font_description_set_size(gps->fontdesc, 10*PANGO_SCALE); pango_layout_set_font_description(gps->layout, gps->fontdesc); pango_layout_set_alignment(gps->layout, PANGO_ALIGN_CENTER); +gps->esid=g_timeout_add(1000,(GSourceFunc)gtk_gps_refresh_cb, gps); + return GTK_WIDGET(gps); } @@ -163,6 +167,7 @@ GtkGps *gps; g_return_if_fail(GTK_IS_GPS(object)); gps=GTK_GPS(object); +g_source_remove(gps->esid); if (GTK_WIDGET(object)->parent && GTK_WIDGET_MAPPED(object)) { gtk_widget_unmap(GTK_WIDGET(object)); } @@ -181,9 +186,15 @@ g_return_if_fail(requisition!=NULL); gps = GTK_GPS (widget); requisition->width=300; -requisition->height=300; gps->width=300; -gps->height=300; + +if (gps->display_mode==GTK_GPS_MODE_SKY) { + requisition->height=300; + gps->height=300; +} else { + requisition->height=200; + gps->height=200; +} gps->size=300; } @@ -484,6 +495,21 @@ switch (gps->display_mode) { } } +static gboolean +gtk_gps_refresh_cb(GtkWidget *widget) +{ +GtkGps *gps; + +g_return_val_if_fail(GTK_IS_GPS(widget), FALSE); + +if ((GTK_WIDGET_MAPPED(widget)==FALSE) || (GTK_WIDGET_VISIBLE(widget)==FALSE)) + return TRUE; + +gps=GTK_GPS(widget); +gtk_widget_queue_draw_area(widget, 0, 0, gps->width, gps->height); +return TRUE; +} + static gboolean gtk_gps_expose(GtkWidget *widget, GdkEventExpose *event) { diff --git a/src/gtkgps.h b/src/gtkgps.h index 7a0b363..74ae525 100644 --- a/src/gtkgps.h +++ b/src/gtkgps.h @@ -55,6 +55,7 @@ struct _GtkGps { PangoFontDescription *fontdesc; GpsData *data; + gint esid; }; struct _GtkGpsClass {