]> err.no Git - mapper/commitdiff
Fixes to compass widget:
authorKaj-Michael Lang <milang@tal.org>
Mon, 28 Apr 2008 13:41:46 +0000 (16:41 +0300)
committerKaj-Michael Lang <milang@tal.org>
Mon, 28 Apr 2008 13:41:46 +0000 (16:41 +0300)
- Don't use old functions
- Update display faster
- Swap code around some

src/gtkcompass.c

index 69b21046089fc133ecce983045b76648cac93d2e..1f7da5b49675c6d094860f6c0728eb82d7014da7 100644 (file)
@@ -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