From: Kaj-Michael Lang Date: Mon, 28 Apr 2008 13:41:46 +0000 (+0300) Subject: Fixes to compass widget: X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=65aedf502c75fe2087e720756d2ddca46c88e418;p=mapper Fixes to compass widget: - Don't use old functions - Update display faster - Swap code around some --- diff --git a/src/gtkcompass.c b/src/gtkcompass.c index 69b2104..1f7da5b 100644 --- a/src/gtkcompass.c +++ b/src/gtkcompass.c @@ -42,6 +42,8 @@ static void gtk_compass_get_property (GObject *object, guint prop_id, GValue *va static void gtk_compass_paint(GtkCompass *compass); static gboolean gtk_compass_refresh_cb(GtkWidget *widget); +static gboolean gtk_compass_cb_button_press(GtkWidget *widget, GdkEventButton *event); + G_DEFINE_TYPE(GtkCompass, gtk_compass, GTK_TYPE_WIDGET); #define BOUND(x, a, b) { \ @@ -52,7 +54,6 @@ G_DEFINE_TYPE(GtkCompass, gtk_compass, GTK_TYPE_WIDGET); } typedef struct _GtkCompassPriv GtkCompassPriv; - struct _GtkCompassPriv { PangoContext *context; @@ -60,8 +61,7 @@ PangoLayout *layout; PangoFontDescription *fontdesc; }; -#define GTK_COMPASS_GET_PRIVATE(o) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_COMPASS, GtkCompassPriv)) +#define GTK_COMPASS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_COMPASS, GtkCompassPriv)) static void gtk_compass_class_init (GtkCompassClass *class) @@ -71,6 +71,8 @@ GtkWidgetClass *widget_class; object_class = (GObjectClass*) class; widget_class = (GtkWidgetClass*) class; + +g_type_class_add_private (object_class, sizeof (GtkCompassPriv)); object_class->finalize = gtk_compass_finalize; object_class->set_property = gtk_compass_set_property; @@ -80,8 +82,6 @@ widget_class->size_request = gtk_compass_size_request; widget_class->expose_event = gtk_compass_expose; widget_class->realize = gtk_compass_realize; widget_class->size_allocate = gtk_compass_size_allocate; - -g_type_class_add_private (object_class, sizeof (GtkCompassPriv)); } static void @@ -121,20 +121,15 @@ compass->way_valid=FALSE; compass->width=300; compass->height=300; compass->esid=0; +g_signal_connect(G_OBJECT(compass), "button_press_event", G_CALLBACK(gtk_compass_cb_button_press), NULL); } static gboolean gtk_compass_cb_button_press(GtkWidget *widget, GdkEventButton *event) { GtkCompass *compass; - compass=GTK_COMPASS(widget); -#ifdef DEBUG -compass->data->heading=0; -compass->heading=180; -#endif - return FALSE; } @@ -144,13 +139,10 @@ gtk_compass_new(GpsData *data) GtkCompass *compass; GtkWidget *widget; -compass=gtk_type_new(gtk_compass_get_type ()); +compass=g_object_new(GTK_COMPASS_TYPE, NULL); widget=GTK_WIDGET(compass); compass->data=data; compass->heading=0; -g_signal_connect(G_OBJECT(widget), "button_press_event", G_CALLBACK(gtk_compass_cb_button_press), NULL); - -compass->esid=g_timeout_add(1000,(GSourceFunc)gtk_compass_refresh_cb, compass); return widget; } @@ -284,6 +276,7 @@ if (!compass->gc_w) { gdk_gc_set_line_attributes(compass->gc_w, 6, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); } +compass->esid=g_timeout_add(300,(GSourceFunc)gtk_compass_refresh_cb, compass); } static void