From 0f9e88345eeb270f03a7e4be60fedbc891f64089 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Mon, 1 Oct 2007 00:30:20 +0300 Subject: [PATCH] Some fixes to the widgets --- src/gtkcompass.c | 82 +++++++++++----------- src/gtkcompass.h | 14 ++-- src/gtkgps.c | 176 ++++++++++++++++++++--------------------------- src/gtkgps.h | 29 +++----- 4 files changed, 131 insertions(+), 170 deletions(-) diff --git a/src/gtkcompass.c b/src/gtkcompass.c index c24bc02..682e2ab 100644 --- a/src/gtkcompass.c +++ b/src/gtkcompass.c @@ -31,7 +31,7 @@ static void gtk_compass_finalize (GObject *object); static void gtk_compass_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_compass_size_allocate (GtkWidget *widget, GtkAllocation *allocate); -static gint gtk_compass_expose (GtkWidget *widget, GdkEventExpose *event); +static gboolean gtk_compass_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_compass_realize (GtkWidget *widget); static void gtk_compass_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void gtk_compass_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); @@ -39,8 +39,6 @@ static void gtk_compass_paint(GtkCompass *compass); G_DEFINE_TYPE(GtkCompass, gtk_compass, GTK_TYPE_WIDGET); -#define PADDING (15) - #define BOUND(x, a, b) { \ if((x) < (a)) \ (x) = (a); \ @@ -98,7 +96,6 @@ gtk_compass_init (GtkCompass *compass) { g_printf("%s()\n", __PRETTY_FUNCTION__); -compass->heading=0; compass->gc_h=NULL; compass->gc_d=NULL; compass->gc_w=NULL; @@ -119,13 +116,14 @@ return FALSE; } GtkWidget* -gtk_compass_new(void) +gtk_compass_new(GpsData *data) { GtkCompass *compass; GtkWidget *widget; compass=gtk_type_new(gtk_compass_get_type ()); widget=GTK_WIDGET(compass); +compass->data=data; g_signal_connect(G_OBJECT(widget), "button_press_event", G_CALLBACK(gtk_compass_cb_button_press), NULL); return widget; } @@ -161,8 +159,8 @@ compass = GTK_COMPASS (widget); requisition->width=400; requisition->height=300; -compass->width=400 - 10; -compass->height=300 - 10; +compass->width=400; +compass->height=300; } static void @@ -185,8 +183,8 @@ if (GTK_WIDGET_REALIZED (widget)) { allocation->width, allocation->height); } -compass->width=allocation->width-PADDING; -compass->height=allocation->height-PADDING; +compass->width=allocation->width; +compass->height=allocation->height; compass->size = MIN(widget->allocation.width, widget->allocation.height); if (widget->allocation.width > widget->allocation.height) { @@ -301,47 +299,53 @@ widget=GTK_WIDGET(compass); size=compass->size; hsize=size/2; -g_snprintf(htext, 8, "%3.0f°", compass->heading); +g_snprintf(htext, 8, "%3.0f°", compass->data->heading); pango_layout_set_text(compass->layout, htext, -1); pango_layout_get_pixel_size(compass->layout, &x, &y); +gtk_paint_flat_box (widget->style, + widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, + NULL, widget, "trough", 0, 0, + compass->width, compass->height); + gdk_draw_layout(widget->window, - widget->style->fg_gc[GTK_STATE_NORMAL], - compass->xoffset+size/2-x/2, - compass->yoffset+size-y-2, compass->layout); + widget->style->fg_gc[GTK_STATE_NORMAL], + compass->xoffset+size/2-x/2, + compass->yoffset+size-y-2, compass->layout); gdk_draw_arc(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - FALSE, - compass->xoffset, compass->yoffset+size/2, size, size, 0, 64 * 180); + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + FALSE, + compass->xoffset, compass->yoffset+size/2, size, size, 0, 64 * 180); /* Simple arrow for heading */ gdk_draw_line(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - compass->xoffset + size / 2 + 3, - compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + compass->xoffset + size / 2 + 3, + compass->yoffset + size - y - 5, + compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); gdk_draw_line(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - compass->xoffset + size / 2 - 3, - compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + compass->xoffset + size / 2 - 3, + compass->yoffset + size - y - 5, + compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); gdk_draw_line(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - compass->xoffset + size / 2 - 3, - compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size - y - 8); + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + compass->xoffset + size / 2 - 3, + compass->yoffset + size - y - 5, + compass->xoffset + size / 2, compass->yoffset + size - y - 8); gdk_draw_line(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE(widget)], - compass->xoffset + size / 2 + 3, - compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size - y - 8); + widget->style->fg_gc[GTK_WIDGET_STATE(widget)], + compass->xoffset + size / 2 + 3, + compass->yoffset + size - y - 5, + compass->xoffset + size / 2, compass->yoffset + size - y - 8); for (i = 0; i < 5; i++) { - dir = (gint) (compass->heading / 45) * 45 + angle[i]; + dir = (gint) (compass->data->heading / 45) * 45 + angle[i]; switch (dir) { case 0: @@ -377,7 +381,7 @@ for (i = 0; i < 5; i++) { break; } - tmp = ((dir - compass->heading) * (1.f / 180.f)) * G_PI; + tmp = ((dir - compass->data->heading) * (1.f / 180.f)) * G_PI; gdk_draw_line(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], compass->xoffset + size / 2 + ((size / 2 - 5) * sinf(tmp)), @@ -386,8 +390,8 @@ for (i = 0; i < 5; i++) { compass->yoffset + size - ((size / 2 + 5) * cosf(tmp))); x = fsize[i]; - if (abs((guint) (compass->heading / 45) * 45 - compass->heading) - > abs((guint) (compass->heading / 45) * 45 + 45 - compass->heading) && (i > 0)) + if (abs((guint) (compass->data->heading / 45) * 45 - compass->data->heading) + > abs((guint) (compass->data->heading / 45) * 45 + 45 - compass->data->heading) && (i > 0)) x = fsize[i - 1]; pango_font_description_set_size(compass->fontdesc, (10 + x) * PANGO_SCALE); @@ -413,7 +417,7 @@ return TRUE; } -static gint +static gboolean gtk_compass_expose(GtkWidget *widget, GdkEventExpose *event) { GtkCompass *compass; @@ -426,7 +430,7 @@ return TRUE; } void -gtk_compass_set_heading(GtkWidget *widget, gfloat heading) +gtk_compass_refresh(GtkWidget *widget) { GtkCompass *compass; @@ -434,8 +438,6 @@ g_printf("%s()\n", __PRETTY_FUNCTION__); g_return_if_fail(GTK_IS_COMPASS(widget)); compass=GTK_COMPASS(widget); - -compass->heading=heading; gtk_compass_paint(compass); g_printf("%s(): return\n", __PRETTY_FUNCTION__); diff --git a/src/gtkcompass.h b/src/gtkcompass.h index e33ada0..e2074aa 100644 --- a/src/gtkcompass.h +++ b/src/gtkcompass.h @@ -21,6 +21,8 @@ #include +#include "gpsdata.h" + G_BEGIN_DECLS #define GTK_COMPASS_TYPE (gtk_compass_get_type ()) @@ -28,8 +30,6 @@ G_BEGIN_DECLS #define GTK_COMPASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_COMPASS_TYPE, GtkCompassClass)) #define GTK_IS_COMPASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_COMPASS_TYPE)) -#define GTK_COMPASS_SAT_MAX (12) - typedef struct _GtkCompass GtkCompass; typedef struct _GtkCompassClass GtkCompassClass; @@ -47,11 +47,11 @@ struct _GtkCompass { PangoLayout *layout; PangoFontDescription *fontdesc; - gfloat heading; - gfloat dest_heading; - gfloat way_heading; + GpsData *data; gboolean dest_valid; gboolean way_valid; + gfloat dest_heading; + gfloat way_heading; }; struct _GtkCompassClass { @@ -59,8 +59,8 @@ struct _GtkCompassClass { }; GType gtk_compass_get_type(void); -GtkWidget* gtk_compass_new(void); -void gtk_compass_set_heading(GtkWidget *widget, gfloat heading); +GtkWidget* gtk_compass_new(GpsData *data); +void gtk_compass_refresh(GtkWidget *widget); G_END_DECLS diff --git a/src/gtkgps.c b/src/gtkgps.c index 0613efb..4535dee 100644 --- a/src/gtkgps.c +++ b/src/gtkgps.c @@ -28,7 +28,7 @@ static void gtk_gps_finalize (GObject *object); static void gtk_gps_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_gps_size_allocate (GtkWidget *widget, GtkAllocation *allocate); -static gint gtk_gps_expose (GtkWidget *widget, GdkEventExpose *event); +static gboolean gtk_gps_expose (GtkWidget *widget, GdkEventExpose *event); 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); @@ -46,7 +46,7 @@ G_DEFINE_TYPE(GtkGps, gtk_gps, GTK_TYPE_WIDGET); } static void -gtk_gps_class_init (GtkGpsClass *class) +gtk_gps_class_init(GtkGpsClass *class) { GObjectClass *object_class; GtkWidgetClass *widget_class; @@ -65,7 +65,7 @@ widget_class->size_allocate = gtk_gps_size_allocate; } static void -gtk_gps_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) +gtk_gps_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GtkGps *gps; g_return_if_fail(GTK_IS_GPS(object)); @@ -78,7 +78,7 @@ switch (prop_id) { } static void -gtk_gps_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +gtk_gps_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GtkGps *gps; g_return_if_fail(GTK_IS_GPS(object)); @@ -91,12 +91,10 @@ switch (prop_id) { } static void -gtk_gps_init (GtkGps *gps) +gtk_gps_init(GtkGps *gps) { g_printf("%s()\n", __PRETTY_FUNCTION__); -gps->satinview=0; -gps->satinuse=0; gps->gc1=NULL; gps->gc2=NULL; gps->gc3=NULL; @@ -128,13 +126,14 @@ return FALSE; } GtkWidget* -gtk_gps_new(GtkGpsMode display_mode) +gtk_gps_new(GtkGpsMode display_mode, GpsData *data) { GtkGps *gps; GtkWidget *widget; gps=gtk_type_new(gtk_gps_get_type ()); gps->display_mode=display_mode; +gps->data=data; widget=GTK_WIDGET(gps); g_signal_connect(G_OBJECT(widget), "button_press_event", G_CALLBACK(gtk_gps_cb_button_press), NULL); return GTK_WIDGET(gps); @@ -171,8 +170,8 @@ gps = GTK_GPS (widget); requisition->width=400; requisition->height=300; -gps->width=400 - 10; -gps->height=300 - 10; +gps->width=400; +gps->height=300; } static void @@ -195,8 +194,9 @@ if (GTK_WIDGET_REALIZED (widget)) { allocation->width, allocation->height); } -gps->width=allocation->width-PADDING; -gps->height=allocation->height-PADDING; + +gps->width=allocation->width; +gps->height=allocation->height; } static void @@ -231,13 +231,13 @@ widget->style=gtk_style_attach(widget->style, widget->window); gdk_window_set_user_data(widget->window, widget); gtk_style_set_background(widget->style, widget->window, GTK_STATE_ACTIVE); -gps->sat_details_context=gtk_widget_get_pango_context(widget); -gps->sat_details_layout=pango_layout_new(gps->sat_details_context); -gps->sat_details_fontdesc=pango_font_description_new(); -pango_font_description_set_family(gps->sat_details_fontdesc, "Sans Serif"); -pango_font_description_set_size(gps->sat_details_fontdesc, 12*PANGO_SCALE); -pango_layout_set_font_description(gps->sat_details_layout, gps->sat_details_fontdesc); -pango_layout_set_alignment(gps->sat_details_layout, PANGO_ALIGN_CENTER); +gps->context=gtk_widget_get_pango_context(widget); +gps->layout=pango_layout_new(gps->context); +gps->fontdesc=pango_font_description_new(); +pango_font_description_set_family(gps->fontdesc, "Sans Serif"); +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); if (!gps->gc1) { color.red=0; @@ -269,7 +269,7 @@ gtk_gps_paint_sky(GtkGps *gps) { GdkGC *gc; GtkWidget *widget; -guint i, j, x, y, size, halfsize, xoffset, yoffset; +guint i, x, y, size, halfsize, xoffset, yoffset; guint x1, y1, x0, y0; gfloat tmp; gchar buffer[16]; @@ -279,6 +279,8 @@ g_printf("%s()\n", __PRETTY_FUNCTION__); widget=GTK_WIDGET(gps); +g_return_if_fail(gps->data); + if (!GTK_WIDGET_MAPPED(widget)) return; @@ -295,6 +297,20 @@ if (gps->width>gps->height) { yoffset=y0+(gps->height-gps->width-PADDING)/2; } +if (size<200) { + pango_font_description_set_size(gps->fontdesc, 10*PANGO_SCALE); + pango_layout_set_font_description(gps->layout, gps->fontdesc); +} else { + pango_font_description_set_size(gps->fontdesc, 12*PANGO_SCALE); + pango_layout_set_font_description(gps->layout, gps->fontdesc); +} + +gtk_paint_flat_box (widget->style, + widget->window, + GTK_STATE_NORMAL, GTK_SHADOW_NONE, + NULL, widget, "trough", 0, 0, + gps->width, gps->height); + /* 90 */ gdk_draw_arc(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], @@ -333,54 +349,48 @@ for (i = 0; i < 12; i++) { g_snprintf(buffer, 16, "N"); else g_snprintf(buffer, 16, "%d°", line[i]); - pango_layout_set_text(gps->sat_details_layout, buffer, -1); - pango_layout_get_pixel_size(gps->sat_details_layout, &x, &y); + pango_layout_set_text(gps->layout, buffer, -1); + pango_layout_get_pixel_size(gps->layout, &x, &y); gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], (xoffset + halfsize + (halfsize - size / 12) * sinf(tmp)) - x / 2, (yoffset + halfsize - (halfsize - size / 12) * cosf(tmp)) - y / 2, - gps->sat_details_layout); + gps->layout); } /* elevation 30 */ tmp = (30 * (1.f / 180.f)) * G_PI; g_snprintf(buffer, 16, "30°"); -pango_layout_set_text(gps->sat_details_layout, buffer, -1); -pango_layout_get_pixel_size(gps->sat_details_layout, &x, &y); +pango_layout_set_text(gps->layout, buffer, -1); +pango_layout_get_pixel_size(gps->layout, &x, &y); gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], (xoffset + halfsize + size / 6 * 2 * sinf(tmp)) - x / 2, (yoffset + halfsize - size / 6 * 2 * cosf(tmp)) - y / 2, - gps->sat_details_layout); + gps->layout); /* elevation 60 */ tmp = (30 * (1.f / 180.f)) * G_PI; g_snprintf(buffer, 16, "60°"); -pango_layout_set_text(gps->sat_details_layout, buffer, -1); -pango_layout_get_pixel_size(gps->sat_details_layout, &x, &y); +pango_layout_set_text(gps->layout, buffer, -1); +pango_layout_get_pixel_size(gps->layout, &x, &y); gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], (xoffset + halfsize + size / 6 * sinf(tmp)) - x / 2, (yoffset + halfsize - size / 6 * cosf(tmp)) - y / 2, - gps->sat_details_layout); + gps->layout); -for (i=0;isatinview;i++) { +for (i=0;idata->satinview;i++) { /* Sat used or not */ - gc=gps->gc1; - for (j=0;jsatinuse;j++) { - if (gps->satforfix[j]==gps->gps_sat[i].prn) { - gc=gps->gc2; - break; - } - } + gc=(gps->data->sat[i].fix) ? gps->gc2 : gps->gc1; - tmp = (gps->gps_sat[i].azimuth * (1.f / 180.f)) * G_PI; - x = xoffset + halfsize + (90 - gps->gps_sat[i].elevation) * halfsize / 90 * sinf(tmp); - y = yoffset + halfsize - (90 - gps->gps_sat[i].elevation) * halfsize / 90 * cosf(tmp); + tmp = (gps->data->sat[i].azimuth * (1.f / 180.f)) * G_PI; + x = xoffset + halfsize + (90 - gps->data->sat[i].elevation) * halfsize / 90 * sinf(tmp); + y = yoffset + halfsize - (90 - gps->data->sat[i].elevation) * halfsize / 90 * cosf(tmp); gdk_draw_arc(widget->window, gc, TRUE, x - 10, y - 10, 20, 20, 0, 64 * 360); - g_snprintf(buffer, 6, "%02d", gps->gps_sat[i].prn); - pango_layout_set_text(gps->sat_details_layout, buffer, -1); - pango_layout_get_pixel_size(gps->sat_details_layout, &x1, &y1); - gdk_draw_layout(widget->window, gps->gc3, x - x1 / 2, y - y1 / 2, gps->sat_details_layout); + g_snprintf(buffer, 6, "%02d", gps->data->sat[i].prn); + pango_layout_set_text(gps->layout, buffer, -1); + pango_layout_get_pixel_size(gps->layout, &x1, &y1); + gdk_draw_layout(widget->window, gps->gc3, x - x1 / 2, y - y1 / 2, gps->layout); } g_printf("%s(): return\n", __PRETTY_FUNCTION__); @@ -392,7 +402,7 @@ gtk_gps_paint_signals(GtkGps *gps) { GdkGC *gc; GtkWidget *widget; -guint step, i, j, snr_height, bymargin, xoffset, yoffset; +guint step, i, snr_height, bymargin, xoffset, yoffset; guint x, y, x1, y1; gchar tmp[32]; @@ -419,22 +429,16 @@ gdk_draw_line(widget->window, xoffset + 5, yoffset + bymargin - 1, xoffset + gps->width - 10 - 2, yoffset + bymargin - 1); -if (gps->satinview > 0) { +if (gps->data->satinview > 0) { /* Left margin - 5pix, Right margin - 5pix */ - step = (gps->width - 10) / gps->satinview; + step = (gps->width - 10) / gps->data->satinview; - for (i = 0; i < gps->satinview; i++) { + for (i = 0; i < gps->data->satinview; i++) { /* Sat used or not */ - gc = gps->gc1; - for (j = 0; j < gps->satinuse; j++) { - if (gps->satforfix[j] == gps->gps_sat[i].prn) { - gc = gps->gc2; - break; - } - } + gc=(gps->data->sat[i].fix) ? gps->gc1 : gps->gc2; x = 5 + i * step; - snr_height = gps->gps_sat[i].snr * gps->height * 0.78f / 100; + snr_height = gps->data->sat[i].snr * gps->height * 0.78f / 100; y = gps->height * 0.1f + (gps->height * 0.78f - snr_height); /* draw sat rectangle... */ @@ -443,27 +447,27 @@ if (gps->satinview > 0) { xoffset + x, yoffset + y, step - 2, snr_height); - if (gps->gps_sat[i].snr > 0) { + if (gps->data->sat[i].snr > 0) { /* ...snr.. */ - g_snprintf(tmp, 32, "%02d", gps->gps_sat[i].snr); - pango_layout_set_text(gps->sat_details_layout, tmp, 2); - pango_layout_get_pixel_size(gps->sat_details_layout, &x1, &y1); + g_snprintf(tmp, 32, "%02d", gps->data->sat[i].snr); + pango_layout_set_text(gps->layout, tmp, 2); + pango_layout_get_pixel_size(gps->layout, &x1, &y1); gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], xoffset + x + ((step - 2) - x1) / 2, yoffset + y - 15, - gps->sat_details_layout); + gps->layout); } /* ...and sat number */ - g_snprintf(tmp, 32, "%02d", gps->gps_sat[i].prn); - pango_layout_set_text(gps->sat_details_layout, tmp, 2); - pango_layout_get_pixel_size(gps->sat_details_layout, &x1, &y1); + g_snprintf(tmp, 32, "%02d", gps->data->sat[i].prn); + pango_layout_set_text(gps->layout, tmp, 2); + pango_layout_get_pixel_size(gps->layout, &x1, &y1); gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], xoffset + x + ((step - 2) - x1) / 2, yoffset + bymargin + 1, - gps->sat_details_layout); + gps->layout); } } @@ -473,6 +477,8 @@ return; static void gtk_gps_paint_by_mode(GtkGps *gps) { +g_return_if_fail(GTK_IS_GPS(gps)); + switch (gps->display_mode) { case GTK_GPS_MODE_SIGNAL: gtk_gps_paint_signals(gps); @@ -484,10 +490,11 @@ switch (gps->display_mode) { } } -static gint +static gboolean gtk_gps_expose(GtkWidget *widget, GdkEventExpose *event) { GtkGps *gps; + g_return_val_if_fail(GTK_IS_GPS(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); @@ -496,48 +503,13 @@ gtk_gps_paint_by_mode(gps); return TRUE; } -void -gtk_gps_set_satellite_data(GtkWidget *widget, guint sat, gboolean fix, guint prn, guint elevation, guint azimuth, guint snr) -{ -GtkGps *gps; - -g_printf("%s()\n", __PRETTY_FUNCTION__); -g_return_if_fail(GTK_IS_GPS (widget)); - -gps=GTK_GPS(widget); - -if (sat>12) - sat=12; - -BOUND(elevation, 0, 90); -BOUND(azimuth, 0, 360); -BOUND(snr, 0, 99); -gps->gps_sat[sat].prn=prn; -gps->gps_sat[sat].elevation=elevation; -gps->gps_sat[sat].azimuth=azimuth; -gps->gps_sat[sat].snr=snr; -if (fix) - gps->satforfix[sat]=prn; -else - gps->satforfix[sat]=-1; -g_printf("%s(): return\n", __PRETTY_FUNCTION__); -} - void -gtk_gps_set_satellite_in_view(GtkWidget *widget, guint sat) +gtk_gps_refresh(GtkWidget *widget) { GtkGps *gps; -g_printf("%s()\n", __PRETTY_FUNCTION__); g_return_if_fail(GTK_IS_GPS(widget)); gps=GTK_GPS(widget); - -if (sat>12) - sat=12; - -gps->satinview=sat; gtk_gps_paint_by_mode(gps); - -g_printf("%s(): return\n", __PRETTY_FUNCTION__); } diff --git a/src/gtkgps.h b/src/gtkgps.h index c19951f..c032db3 100644 --- a/src/gtkgps.h +++ b/src/gtkgps.h @@ -21,6 +21,7 @@ #define __GTK_GPS_H__ #include +#include "gpsdata.h" G_BEGIN_DECLS @@ -32,14 +33,6 @@ G_BEGIN_DECLS typedef struct _GtkGps GtkGps; typedef struct _GtkGpsClass GtkGpsClass; -typedef struct _GtkGpsSatelliteData GtkGpsSatelliteData; -struct _GtkGpsSatelliteData { - guint prn; - guint elevation; - guint azimuth; - guint snr; -}; - typedef enum { GTK_GPS_MODE_SKY, GTK_GPS_MODE_SIGNAL, @@ -53,19 +46,14 @@ struct _GtkGps { GdkGC *gc2; GdkGC *gc3; gint width, height; + gint size; GtkGpsMode display_mode; - PangoContext *sat_details_context; - PangoLayout *sat_details_layout; - PangoFontDescription *sat_details_fontdesc; - PangoContext *sat_details_expose_context; - PangoLayout *sat_details_expose_layout; - PangoFontDescription *sat_details_expose_fontdesc; + PangoContext *context; + PangoLayout *layout; + PangoFontDescription *fontdesc; - GtkGpsSatelliteData gps_sat[12]; - guint satinview; - guint satinuse; - guint satforfix[12]; + GpsData *data; }; struct _GtkGpsClass { @@ -73,9 +61,8 @@ struct _GtkGpsClass { }; GType gtk_gps_get_type(void); -GtkWidget* gtk_gps_new(GtkGpsMode display_mode); -void gtk_gps_set_satellite_data(GtkWidget *widget, guint sat, gboolean fix, guint prn, guint elevation, guint azimuth, guint snr); -void gtk_gps_set_satellite_in_view(GtkWidget *widget, guint sat); +GtkWidget* gtk_gps_new(GtkGpsMode display_mode, GpsData *data); +void gtk_gps_refresh(GtkWidget *widget); G_END_DECLS -- 2.39.5