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) { \
}
typedef struct _GtkCompassPriv GtkCompassPriv;
-
struct _GtkCompassPriv
{
PangoContext *context;
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)
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;
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
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;
}
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;
}
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